SiteMapper.xml 22 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.runsa.portal.base.dao.SiteMapper">
	<resultMap id="BaseResultMap" type="cn.runsa.portal.base.entity.Site">
		<id column="siId" property="siid" jdbcType="INTEGER" />
		<result column="beId" property="beid" jdbcType="INTEGER" />
		<result column="siCode" property="sicode" jdbcType="VARCHAR" />
		<result column="siName" property="siname" jdbcType="VARCHAR" />
		<result column="siSaleType" property="sisaletype" jdbcType="SMALLINT" />
		<result column="siType" property="sitype" jdbcType="INTEGER" />
		<result column="ptValid" property="ptvalid" jdbcType="SMALLINT" />
		<result column="siPos" property="sipos" jdbcType="BIT" />
		<result column="siAssistant" property="siassistant" jdbcType="BIT" />
		<result column="diId" property="diid" jdbcType="INTEGER" />
		<result column="ptAddr" property="ptaddr" jdbcType="VARCHAR" />
		<result column="ptTphone" property="pttphone" jdbcType="VARCHAR" />
		<result column="ptChief" property="ptchief" jdbcType="VARCHAR" />
		<result column="siPosition" property="siposition" jdbcType="VARCHAR" />
		<result column="siNavHash" property="sinavhash" jdbcType="VARCHAR" />
		<result column="siNavLat" property="sinavlat" jdbcType="DOUBLE" />
		<result column="siNavLng" property="sinavlng" jdbcType="DOUBLE" />
		<result column="siStartHours" property="sistarthours" jdbcType="TIME" />
		<result column="siEndHours" property="siendhours" jdbcType="TIME" />
		<result column="siPlOpDate" property="siplopdate" jdbcType="TIMESTAMP" />
		<result column="siPlClDate" property="siplcldate" jdbcType="TIMESTAMP" />
		<result column="siOpenDate" property="siopendate" jdbcType="TIMESTAMP" />
		<result column="siCloseDate" property="siclosedate" jdbcType="TIMESTAMP" />
		<result column="ptAnniversary" property="ptanniversary" jdbcType="DATE" />
		<result column="bebId" property="bebid" jdbcType="INTEGER" />
		<result column="orId" property="orid" jdbcType="INTEGER" />
		<result column="mcId" property="mcid" jdbcType="INTEGER" />
		<result column="siCashType" property="sicashtype" jdbcType="SMALLINT" />
		<result column="siPayBizEntity" property="sipaybizentity" jdbcType="INTEGER" />
		<result column="siPayDecimals" property="sipaydecimals" jdbcType="SMALLINT" />
		<result column="siBizPeriod" property="sibizperiod" jdbcType="INTEGER" />
		<result column="ptRemark1" property="ptremark1" jdbcType="VARCHAR" />
		<result column="ptRemark2" property="ptremark2" jdbcType="VARCHAR" />
		<result column="ptRemark3" property="ptremark3" jdbcType="VARCHAR" />
		<result column="ptUpTime" property="ptuptime" jdbcType="TIMESTAMP" />
		<result column="ptUpdater" property="ptupdater" jdbcType="INTEGER" />

		<!-- 组织类型名称 -->
		<result column="vaiName" property="vainame" jdbcType="VARCHAR" />
		<!-- 经营主体名称 -->
		<result column="beName" property="bename" jdbcType="VARCHAR" />
		<!-- 结算主体名称 -->
		<result column="bebName" property="bebname" jdbcType="VARCHAR" />
		
		<!-- 当前管辖组织名称 -->
		<result column="orNameNow" property="ornamenow" jdbcType="VARCHAR" />

		<!-- <result column="brIds" property="brids" jdbcType="VARCHAR" />经营品牌ID集合 <result column="brNames" property="brnames" jdbcType="VARCHAR" />经营品牌名称集合 -->

		<collection property="srlist" javaType="ArrayList" ofType="cn.runsa.portal.base.entity.SiteRange">
			<id column="sirId" property="id" />
			<result column="chId" property="chid" />
			<result column="sirCode" property="code" />
			<result column="sirSupplier" property="supplier" />
			<result column="sirReturner" property="returner" />
			<result column="orId" property="orid" />
			<result column="ptRemark" property="remark" />
			<result column="ptUpdater" property="updater" />
			<result column="ptUpTime" property="uptime" />

			<!-- 经营渠道名称 管理组织名称 -->
			<result column="chName" property="chname" />
			<result column="orName" property="orname" />

			<result column="brIds" property="brids" jdbcType="VARCHAR" /><!-- 经营品牌ID集合 -->
			<result column="brNames" property="brnames" jdbcType="VARCHAR" /><!-- 经营品牌名称集合 -->
		</collection>

		<collection property="sblist" javaType="ArrayList" ofType="cn.runsa.portal.base.entity.SiteBrand">
			<id column="sirId" property="sirid" />
			<result column="brId" property="brid" />

			<!-- 经营品牌名称 -->
			<result column="brName" property="brname" />
		</collection>

		<collection property="spwlist" javaType="ArrayList" ofType="cn.runsa.portal.base.entity.SitePayway">
			<id column="sipId" property="id" />
			<result column="bepId" property="bepid" />
			<result column="sipPoint" property="point" />
			<result column="valid" property="valid" />
			<result column="ptUpdater" property="updater" />
			<result column="ptUpTime" property="uptime" />

			<!-- /结算账套-收款方式 -收款帐户 收款方/银行 收款人 收/付款方式 收款方式名称 币种单位 名称和汇率 -->
			<result column="bepAccount" property="account" />
			<result column="bepProceeds" property="proceeds" />
			<result column="bepPayee" property="payee" />
			<result column="pwName" property="pwname" />
			<result column="cuName" property="cuname" />
			<result column="cuRate" property="curate" />
		</collection>

	</resultMap>

	<resultMap id="SiteRangeResultMap" type="cn.runsa.portal.base.entity.SiteRange">
		<id column="sirId" property="id" />
	</resultMap>

	<resultMap id="MsgChannelMap" type="cn.runsa.portal.base.entity.MsgChannel" >
	    <id column="mcId" property="id" jdbcType="INTEGER" />
	    <result column="mcName" property="name" jdbcType="VARCHAR" />
    </resultMap>
    
	<sql id="Base_Column_List">
		siId, beId, siCode, siName, siSaleType, siType, ptValid, siPos, siAssistant, diId,
		ptAddr, ptTphone, ptChief, siPosition, siNavHash, siNavLat, siNavLng, siStartHours,
		siEndHours, siPlOpDate, siPlClDate, siOpenDate, siCloseDate, ptAnniversary, bebId,
		siCashType, siPayBizEntity, siPayDecimals, siBizPeriod, ptRemark1, ptRemark2, ptRemark3,
		ptUpTime, ptUpdater
	</sql>
	<select id="findById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List" />
		from mtSite
		where siId = #{siid,jdbcType=INTEGER}
	</select>

	<insert id="insert" parameterType="cn.runsa.portal.base.entity.Site">
		<selectKey resultType="java.lang.Integer" keyProperty="siid" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into mtSite (beId, siCode,
		siName, siSaleType, siType,
		ptValid, siPos, siAssistant,
		diId, ptAddr, ptTphone,
		ptChief, siPosition, siNavHash,
		siNavLat, siNavLng, siStartHours,
		siEndHours, siPlOpDate, siPlClDate,
		siOpenDate, siCloseDate, ptAnniversary,
		bebId, orId, mcId, siCashType, siPayBizEntity,
		siPayDecimals, siBizPeriod, ptRemark1,
		ptRemark2, ptRemark3, ptUpTime,
		ptUpdater)
		values (#{beid,jdbcType=INTEGER}, #{sicode,jdbcType=VARCHAR},
		#{siname,jdbcType=VARCHAR}, #{sisaletype,jdbcType=SMALLINT}, #{sitype,jdbcType=INTEGER},
		#{ptvalid,jdbcType=SMALLINT}, #{sipos,jdbcType=BIT}, #{siassistant,jdbcType=BIT},
		#{diid,jdbcType=INTEGER}, #{ptaddr,jdbcType=VARCHAR}, #{pttphone,jdbcType=VARCHAR},
		#{ptchief,jdbcType=VARCHAR}, #{siposition,jdbcType=VARCHAR}, #{sinavhash,jdbcType=VARCHAR},
		#{sinavlat,jdbcType=DOUBLE},
		#{sinavlng,jdbcType=DOUBLE}, #{sistarthours,jdbcType=TIME},
		#{siendhours,jdbcType=TIME}, #{siplopdate,jdbcType=TIMESTAMP}, #{siplcldate,jdbcType=TIMESTAMP},
		#{siopendate,jdbcType=TIMESTAMP}, #{siclosedate,jdbcType=TIMESTAMP}, #{ptanniversary,jdbcType=DATE},
		#{bebid,jdbcType=INTEGER},#{orid,jdbcType=INTEGER},#{mcid,jdbcType=INTEGER}, #{sicashtype,jdbcType=SMALLINT}, #{sipaybizentity,jdbcType=INTEGER},
		#{sipaydecimals,jdbcType=SMALLINT}, #{sibizperiod,jdbcType=INTEGER}, #{ptremark1,jdbcType=VARCHAR},
		#{ptremark2,jdbcType=VARCHAR}, #{ptremark3,jdbcType=VARCHAR}, #{ptuptime,jdbcType=TIMESTAMP},
		#{ptupdater,jdbcType=INTEGER})
	</insert>
	<insert id="insertSelective" parameterType="cn.runsa.portal.base.entity.Site">
		insert into mtSite
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="siid != null">
				siId,
			</if>
			<if test="beid != null">
				beId,
			</if>
			<if test="sicode != null">
				siCode,
			</if>
			<if test="siname != null">
				siName,
			</if>
			<if test="sisaletype != null">
				siSaleType,
			</if>
			<if test="sitype != null">
				siType,
			</if>
			<if test="ptvalid != null">
				ptValid,
			</if>
			<if test="sipos != null">
				siPos,
			</if>
			<if test="siassistant != null">
				siAssistant,
			</if>
			<if test="diid != null">
				diId,
			</if>
			<if test="ptaddr != null">
				ptAddr,
			</if>
			<if test="pttphone != null">
				ptTphone,
			</if>
			<if test="ptchief != null">
				ptChief,
			</if>
			<if test="siposition != null">
				siPosition,
			</if>
			<if test="sinavhash != null">
				siNavHash,
			</if>
			<if test="sinavlat != null">
				siNavLat,
			</if>
			<if test="sinavlng != null">
				siNavLng,
			</if>
			<if test="sistarthours != null">
				siStartHours,
			</if>
			<if test="siendhours != null">
				siEndHours,
			</if>
			<if test="siplopdate != null">
				siPlOpDate,
			</if>
			<if test="siplcldate != null">
				siPlClDate,
			</if>
			<if test="siopendate != null">
				siOpenDate,
			</if>
			<if test="siclosedate != null">
				siCloseDate,
			</if>
			<if test="ptanniversary != null">
				ptAnniversary,
			</if>
			<if test="bebid != null">
				bebId,
			</if>
			<if test="orid != null">
				orId,
			</if>
			<if test="mcid != null">
				mcId,
			</if>
			<if test="sicashtype != null">
				siCashType,
			</if>
			<if test="sipaybizentity != null">
				siPayBizEntity,
			</if>
			<if test="sipaydecimals != null">
				siPayDecimals,
			</if>
			<if test="sibizperiod != null">
				siBizPeriod,
			</if>
			<if test="ptremark1 != null">
				ptRemark1,
			</if>
			<if test="ptremark2 != null">
				ptRemark2,
			</if>
			<if test="ptremark3 != null">
				ptRemark3,
			</if>
			<if test="ptuptime != null">
				ptUpTime,
			</if>
			<if test="ptupdater != null">
				ptUpdater,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="siid != null">
				#{siid,jdbcType=INTEGER},
			</if>
			<if test="beid != null">
				#{beid,jdbcType=INTEGER},
			</if>
			<if test="sicode != null">
				#{sicode,jdbcType=VARCHAR},
			</if>
			<if test="siname != null">
				#{siname,jdbcType=VARCHAR},
			</if>
			<if test="sisaletype != null">
				#{sisaletype,jdbcType=SMALLINT},
			</if>
			<if test="sitype != null">
				#{sitype,jdbcType=INTEGER},
			</if>
			<if test="ptvalid != null">
				#{ptvalid,jdbcType=SMALLINT},
			</if>
			<if test="sipos != null">
				#{sipos,jdbcType=BIT},
			</if>
			<if test="siassistant != null">
				#{siassistant,jdbcType=BIT},
			</if>
			<if test="diid != null">
				#{diid,jdbcType=INTEGER},
			</if>
			<if test="ptaddr != null">
				#{ptaddr,jdbcType=VARCHAR},
			</if>
			<if test="pttphone != null">
				#{pttphone,jdbcType=VARCHAR},
			</if>
			<if test="ptchief != null">
				#{ptchief,jdbcType=VARCHAR},
			</if>
			<if test="siposition != null">
				#{siposition,jdbcType=VARCHAR},
			</if>
			<if test="sinavhash != null">
				#{sinavhash,jdbcType=VARCHAR},
			</if>
			<if test="sinavlat != null">
				#{sinavlat,jdbcType=DOUBLE},
			</if>
			<if test="sinavlng != null">
				#{sinavlng,jdbcType=DOUBLE},
			</if>
			<if test="sistarthours != null">
				#{sistarthours,jdbcType=TIME},
			</if>
			<if test="siendhours != null">
				#{siendhours,jdbcType=TIME},
			</if>
			<if test="siplopdate != null">
				#{siplopdate,jdbcType=TIMESTAMP},
			</if>
			<if test="siplcldate != null">
				#{siplcldate,jdbcType=TIMESTAMP},
			</if>
			<if test="siopendate != null">
				#{siopendate,jdbcType=TIMESTAMP},
			</if>
			<if test="siclosedate != null">
				#{siclosedate,jdbcType=TIMESTAMP},
			</if>
			<if test="ptanniversary != null">
				#{ptanniversary,jdbcType=DATE},
			</if>
			<if test="bebid != null">
				#{bebid,jdbcType=INTEGER},
			</if>
			<if test="orid != null">
				#{orid,jdbcType=INTEGER},
			</if>
			<if test="mcid != null">
				#{mcid,jdbcType=INTEGER},
			</if>
			<if test="sicashtype != null">
				#{sicashtype,jdbcType=SMALLINT},
			</if>
			<if test="sipaybizentity != null">
				#{sipaybizentity,jdbcType=INTEGER},
			</if>
			<if test="sipaydecimals != null">
				#{sipaydecimals,jdbcType=SMALLINT},
			</if>
			<if test="sibizperiod != null">
				#{sibizperiod,jdbcType=INTEGER},
			</if>
			<if test="ptremark1 != null">
				#{ptremark1,jdbcType=VARCHAR},
			</if>
			<if test="ptremark2 != null">
				#{ptremark2,jdbcType=VARCHAR},
			</if>
			<if test="ptremark3 != null">
				#{ptremark3,jdbcType=VARCHAR},
			</if>
			<if test="ptuptime != null">
				#{ptuptime,jdbcType=TIMESTAMP},
			</if>
			<if test="ptupdater != null">
				#{ptupdater,jdbcType=INTEGER},
			</if>
		</trim>
	</insert>
	<update id="updateBySelective" parameterType="cn.runsa.portal.base.entity.Site">
		update mtSite
		<set>
			<if test="beid != null">
				beId = #{beid,jdbcType=INTEGER},
			</if>
			<if test="sicode != null">
				siCode = #{sicode,jdbcType=VARCHAR},
			</if>
			<if test="siname != null">
				siName = #{siname,jdbcType=VARCHAR},
			</if>
			<if test="sisaletype != null">
				siSaleType = #{sisaletype,jdbcType=SMALLINT},
			</if>
			<if test="sitype != null">
				siType = #{sitype,jdbcType=INTEGER},
			</if>
			<if test="ptvalid != null">
				ptValid = #{ptvalid,jdbcType=SMALLINT},
			</if>
			<if test="sipos != null">
				siPos = #{sipos,jdbcType=BIT},
			</if>
			<if test="siassistant != null">
				siAssistant = #{siassistant,jdbcType=BIT},
			</if>
			<if test="diid != null">
				diId = #{diid,jdbcType=INTEGER},
			</if>
			<if test="ptaddr != null">
				ptAddr = #{ptaddr,jdbcType=VARCHAR},
			</if>
			<if test="pttphone != null">
				ptTphone = #{pttphone,jdbcType=VARCHAR},
			</if>
			<if test="ptchief != null">
				ptChief = #{ptchief,jdbcType=VARCHAR},
			</if>
			<if test="siposition != null">
				siPosition = #{siposition,jdbcType=VARCHAR},
			</if>
			<if test="sinavhash != null">
				siNavHash = #{sinavhash,jdbcType=VARCHAR},
			</if>
			<if test="sinavlat != null">
				siNavLat = #{sinavlat,jdbcType=DOUBLE},
			</if>
			<if test="sinavlng != null">
				siNavLng = #{sinavlng,jdbcType=DOUBLE},
			</if>
			<if test="sistarthours != null">
				siStartHours = #{sistarthours,jdbcType=TIME},
			</if>
			<if test="siendhours != null">
				siEndHours = #{siendhours,jdbcType=TIME},
			</if>
			<if test="siplopdate != null">
				siPlOpDate = #{siplopdate,jdbcType=TIMESTAMP},
			</if>
			<if test="siplcldate != null">
				siPlClDate = #{siplcldate,jdbcType=TIMESTAMP},
			</if>
			<if test="siopendate != null">
				siOpenDate = #{siopendate,jdbcType=TIMESTAMP},
			</if>
			<if test="siclosedate != null">
				siCloseDate = #{siclosedate,jdbcType=TIMESTAMP},
			</if>
			<if test="ptanniversary != null">
				ptAnniversary = #{ptanniversary,jdbcType=DATE},
			</if>
			<if test="bebid != null">
				bebId = #{bebid,jdbcType=INTEGER},
			</if>
			<if test="orid != null">
				orId = #{orid,jdbcType=INTEGER},
			</if>
			<if test="mcid != null">
				mcId = #{chid,jdbcType=INTEGER},
			</if>
			<if test="sicashtype != null">
				siCashType = #{sicashtype,jdbcType=SMALLINT},
			</if>
			<if test="sipaybizentity != null">
				siPayBizEntity = #{sipaybizentity,jdbcType=INTEGER},
			</if>
			<if test="sipaydecimals != null">
				siPayDecimals = #{sipaydecimals,jdbcType=SMALLINT},
			</if>
			<if test="sibizperiod != null">
				siBizPeriod = #{sibizperiod,jdbcType=INTEGER},
			</if>
			<if test="ptremark1 != null">
				ptRemark1 = #{ptremark1,jdbcType=VARCHAR},
			</if>
			<if test="ptremark2 != null">
				ptRemark2 = #{ptremark2,jdbcType=VARCHAR},
			</if>
			<if test="ptremark3 != null">
				ptRemark3 = #{ptremark3,jdbcType=VARCHAR},
			</if>
			<if test="ptuptime != null">
				ptUpTime = #{ptuptime,jdbcType=TIMESTAMP},
			</if>
			<if test="ptupdater != null">
				ptUpdater = #{ptupdater,jdbcType=INTEGER},
			</if>
		</set>
		where siId = #{siid,jdbcType=INTEGER}
	</update>
	<update id="update" parameterType="cn.runsa.portal.base.entity.Site">
		update mtSite
		set beId = #{beid,jdbcType=INTEGER},
		siCode = #{sicode,jdbcType=VARCHAR},
		siName = #{siname,jdbcType=VARCHAR},
		siSaleType = #{sisaletype,jdbcType=SMALLINT},
		siType = #{sitype,jdbcType=INTEGER},
		ptValid = #{ptvalid,jdbcType=SMALLINT},
		siPos = #{sipos,jdbcType=BIT},
		siAssistant = #{siassistant,jdbcType=BIT},
		diId = #{diid,jdbcType=INTEGER},
		ptAddr = #{ptaddr,jdbcType=VARCHAR},
		ptTphone = #{pttphone,jdbcType=VARCHAR},
		ptChief = #{ptchief,jdbcType=VARCHAR},
		siPosition = #{siposition,jdbcType=VARCHAR},
		siNavHash = #{sinavhash,jdbcType=VARCHAR},
	    siNavLat = #{sinavlat,jdbcType=DOUBLE},
		siNavLng = #{sinavlng,jdbcType=DOUBLE},
		siStartHours = #{sistarthours,jdbcType=TIME},
		siEndHours = #{siendhours,jdbcType=TIME},
		siPlOpDate = #{siplopdate,jdbcType=TIMESTAMP},
		siPlClDate = #{siplcldate,jdbcType=TIMESTAMP},
		siOpenDate = #{siopendate,jdbcType=TIMESTAMP},
		siCloseDate = #{siclosedate,jdbcType=TIMESTAMP},
		ptAnniversary = #{ptanniversary,jdbcType=DATE},
		bebId = #{bebid,jdbcType=INTEGER},
		orId = #{orid,jdbcType=INTEGER},
		mcId = #{mcid,jdbcType=INTEGER},
		siCashType = #{sicashtype,jdbcType=SMALLINT},
		siPayBizEntity = #{sipaybizentity,jdbcType=INTEGER},
		siPayDecimals = #{sipaydecimals,jdbcType=SMALLINT},
		siBizPeriod = #{sibizperiod,jdbcType=INTEGER},
		ptRemark1 = #{ptremark1,jdbcType=VARCHAR},
		ptRemark2 = #{ptremark2,jdbcType=VARCHAR},
		ptRemark3 = #{ptremark3,jdbcType=VARCHAR},
		ptUpTime = #{ptuptime,jdbcType=TIMESTAMP},
		ptUpdater = #{ptupdater,jdbcType=INTEGER}
		where siId = #{siid,jdbcType=INTEGER}
	</update>
	<select id="findByCode" parameterType="java.lang.String" resultMap="BaseResultMap">
		select * from mtSite where siCode = #{code}
	</select>

	<!-- 新增网点范围 -->
	<insert id="insertSiteRange" parameterType="cn.runsa.portal.base.entity.SiteRange">
		<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER">
			SELECT LAST_INSERT_ID()
		</selectKey>
		insert into mtSiteRange (siId,sirCode,chId,sirSupplier,sirReturner,orId,ptRemark,ptUpdater,ptUpTime) values
		(#{siid},#{code},#{chid},#{supplier},#{returner},#{orid},#{remark},#{updater},now())
	</insert>

	<!-- 新增网点经营品牌 -->
	<insert id="insertSiteBrand" parameterType="cn.runsa.portal.base.entity.SiteBrand">
		insert into mtSiteBrand (sirId,brId) values (#{sirid},#{brid})
	</insert>

	<!-- 新增店铺付款方式 -->
	<insert id="insertSitePayway" parameterType="cn.runsa.portal.base.entity.Site">
		insert into mtSitePayway (siId,bepId,sipPoint,ptValid,ptUpdater,ptUpTime) values
		<foreach collection="spwlist" item="item" separator=",">
			(#{siid},#{item.bepid},#{item.point},#{item.valid},#{item.updater},now())
		</foreach>
	</insert>

	<!-- 根据网点Id查询网点范围Id -->
	<select id="findSirIdbySiid" parameterType="java.lang.Integer" resultMap="SiteRangeResultMap">
		select sirId from mtSiteRange where siId = #{siid}
	</select>

	<!-- 删除主网点 -->
	<delete id="deleteSite" parameterType="java.lang.Integer">
		delete from mtSite where siId = #{siid,jdbcType=INTEGER}
	</delete>

	<!-- 删除网点范围 -->
	<delete id="deleteSiteRange" parameterType="java.lang.Integer">
		delete from mtSiteRange where siId = #{siid,jdbcType=INTEGER}
	</delete>

	<!-- 删除网点经营品牌 -->
	<delete id="deleteSiteBrand" parameterType="java.lang.Integer">
		delete from mtSiteBrand where sirId = #{sirid,jdbcType=INTEGER}
	</delete>

	<!-- 删除店铺付款方式 -->
	<delete id="deleteSitePayway" parameterType="java.lang.Integer">
		delete from mtSitePayway where siId = #{siid,jdbcType=INTEGER}
	</delete>

	<select id="selectSiteBySiid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		SELECT
		t1.siId,
		t1.bebId,
		t1.beId,
		t1.mcId,
		t1.orId,
		t11.orName as orNameNow,
		t1.siCode, 
		t1.siName,
		t1.siType,
		t1.sisaletype,
		t1.ptValid,
		t1.siPos,
		t1.siAssistant,
		t1.diId,
		t1.ptAddr,
		t1.ptTphone,
		t1.ptChief,
		t1.siStartHours,
		t1.siEndHours,
		t1.siPosition,
		t1.sinavlat,
		t1.sinavlng,
		t1.siPlOpDate,
		t1.siPlClDate,
		t1.siOpenDate,
		t1.siCloseDate,
		t1.ptAnniversary,
		t1.siCashType,
		t1.siPayBizEntity,
		t1.siPayDecimals,
		t1.siBizPeriod,
		t2.beName,
		t3.bebName,
		t4.chId,
		t4.sirCode,
		GROUP_CONCAT(DISTINCT t7.brId) brIds,
		t5.chName,
		GROUP_CONCAT(DISTINCT t7.brName) brNames,
		t8.vaiName
		FROM
		mtSite t1
		LEFT JOIN mtbizentity t2 ON t2.beId = t1.beId
		LEFT JOIN mtbizsetofbook t3 ON t3.bebId = t1.bebId
		LEFT JOIN mtsiterange t4 ON t4.siId = t1.siId
		LEFT JOIN mtchannel t5 ON t5.chId = t4.chId
		LEFT JOIN mtsitebrand t6 ON t6.sirId = t4.sirId
		LEFT JOIN mtbrand t7 ON t7.brId = t6.brId
		LEFT JOIN mtvaritem t8 ON t8.vaiCodeExt = t1.siType
		LEFT JOIN mtvariable t9 ON t8.vaId = t9.vaId
		LEFT JOIN mtorganization t11 ON t11.orId = t1.orId
		WHERE
		t1.siId = #{siid,jdbcType=INTEGER} AND t9.vaCode = 'OrgType'
		GROUP BY t4.chId
	</select>

	<select id="selectSitePayWayBySiid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
		SELECT
		t2.bepId,
		t2.sipPoint,
		t2.ptValid as valid,
		t3.bepAccount,
		t3.bepProceeds,
		t3.bepPayee,
		t4.pwName,
		t5.cuName,
		t5.cuRate
		FROM
		mtSite t1
		INNER JOIN mtSitePayway t2 ON t2.siId = t1.siId
		INNER JOIN mtBizPayway t3 ON t3.bepId = t2.bepId
		INNER JOIN mtPayway t4 ON t4.pwId = t3.pwId
		INNER JOIN mtCurrencyUnit t5 ON t5.cuId = t4.cuId
		WHERE
		t1.siId = #{siid,jdbcType=INTEGER} order by t2.ptValid desc<!-- and t2.ptValid=1 -->
	</select>

	<select id="existsSiCode" resultType="java.lang.Integer" parameterType="java.lang.String">
		select
		COUNT(*)
		from mtSite
		where CAST(siCode AS CHAR)=#{sicode}
	</select>
	
	<select id="findMsgChannel" resultMap="MsgChannelMap" parameterType="java.lang.Integer">
		select t1.mcId, t1.mcName from smMsgChannel t1
		LEFT JOIN smPlatMsgChannel t2 on t2.mcId=t1.mcId
		where t1.mcType=1 and t1.mcProtocol=1 and t2.plId=#{plId} and t2.pmcType=2
	</select>
	
	<select id="existsSiteRange" resultType="Boolean" parameterType="java.lang.Integer">
		SELECT COUNT(*) FROM mtSiteRange WHERE siId = #{siId,jdbcType=INTEGER} AND chId = #{chId,jdbcType=INTEGER}
	</select>
</mapper>