StoreServiceDaoImplMapper.xml 25.8 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 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
<?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="storeServiceDaoImpl">

    <!-- 保存商户信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreInfo" parameterType="Map">
        insert into business_store(store_id, b_id, user_id, name, address, tel, store_type_cd, nearby_landmarks, map_x,
                                   map_y, month, operate)
        values (#{storeId}, #{bId}, #{userId}, #{name}, #{address}, #{tel}, #{storeTypeCd}, #{nearByLandmarks}, #{mapX},
                #{mapY}, #{month}, #{operate})
    </insert>
    <!-- 保存商户属性信息  add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreAttr" parameterType="Map">
        insert into business_store_attr(b_id, attr_id, store_id, spec_cd, value, month, operate)
        values (#{bId}, #{attrId}, #{storeId}, #{specCd}, #{value}, #{month}, #{operate})
    </insert>
    <!-- 保存商户照片信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStorePhoto" parameterType="Map">
        insert into business_store_photo(store_photo_id, b_id, store_id, store_photo_type_cd, photo, month, operate)
        values (#{storePhotoId}, #{bId}, #{storeId}, #{storePhotoTypeCd}, #{photo}, #{month}, #{operate})
    </insert>
    <!-- 保存商户证件信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreCerdentials" parameterType="Map">
        insert into business_store_cerdentials(store_cerdentials_id, b_id, store_id, credentials_cd, value,
                                               validity_period, positive_photo, negative_photo, month, operate)
        values (#{storeCerdentialsId}, #{bId}, #{storeId}, #{credentialsCd}, #{value}, #{validityPeriod},
                #{positivePhoto}, #{negativePhoto}, #{month}, #{operate})
    </insert>

    <!-- 查询商户信息(Business) add by wuxw 2018-07-03 -->
    <select id="getBusinessStoreInfo" parameterType="Map" resultType="Map">
        select
        s.store_id,s.b_id,s.user_id,s.name,s.address,s.tel,s.store_type_cd,s.nearby_landmarks,s.map_x,s.map_y,s.operate
        from business_store s where 1 = 1
        <if test="operate != null and operate != ''">
            and s.operate = #{operate}
        </if>
        <if test="bId != null and bId !=''">
            and s.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId != ''">
            and s.store_id = #{storeId}
        </if>
    </select>


    <!-- 查询商户属性信息(Business) add by wuxw 2018-07-03 -->
    <select id="getBusinessStoreAttrs" parameterType="Map" resultType="Map">
        select sa.b_id,sa.attr_id,sa.store_id,sa.spec_cd,sa.value,sa.operate
        from business_store_attr sa where 1=1
        <if test="operate != null and operate != ''">
            and sa.operate = #{operate}
        </if>
        <if test="bId != null and bId !=''">
            and sa.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId != ''">
            and sa.store_id = #{storeId}
        </if>
        <if test="attrId != null and attrId != ''">
            and sa.attr_id = #{attrId}
        </if>
    </select>

    <!-- 查询商户照片信息 add by wuxw 2018-07-03 -->
    <select id="getBusinessStorePhoto" parameterType="Map" resultType="Map">
        select sp.store_photo_id,sp.b_id,sp.store_id,sp.store_photo_type_cd,sp.photo,sp.operate
        from business_store_photo sp where 1=1
        <if test="bId != null and bId !=''">
            and sp.b_id = #{bId}
        </if>
        <if test="operate != null and operate != ''">
            and sp.operate = #{operate}
        </if>
        <if test="storeId != null and storeId != ''">
            and sp.store_id = #{storeId}
        </if>
    </select>

    <!-- 查询商户 证件信息 add by wuxw 2018-07-03 -->
    <select id="getBusinessStoreCerdentials" parameterType="Map" resultType="Map">
        select
        sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.operate
        from business_store_cerdentials sc where 1 = 1
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
        </if>
        <if test="operate != null and operate != ''">
            and sc.operate = #{operate}
        </if>
        <if test="storeId != null and storeId != ''">
            and sc.store_id = #{storeId}
        </if>
    </select>

    <!-- 保存商户信息至 instance表中 add by wuxw 2018-07-03 -->
    <insert id="saveStoreInfoInstance" parameterType="Map">
        insert into s_store(store_id, b_id, user_id, name, address, tel, store_type_cd, nearby_landmarks, map_x, map_y,
                            status_cd)
        select s.store_id,
               s.b_id,
               s.user_id,
               s.name,
               s.address,
               s.tel,
               s.store_type_cd,
               s.nearby_landmarks,
               s.map_x,
               s.map_y,
               '0'
        from business_store s
        where s.operate = 'ADD'
          and s.b_id = #{bId}
    </insert>

    <!-- 保存商户属性信息到 instance add by wuxw 2018-07-03 -->
    <insert id="saveStoreAttrsInstance" parameterType="Map">
        insert into s_store_attr(b_id, attr_id, store_id, spec_cd, value, status_cd)
        select sa.b_id, sa.attr_id, sa.store_id, sa.spec_cd, sa.value, '0'
        from business_store_attr sa
        where sa.operate = 'ADD'
          and sa.b_id = #{bId}
    </insert>

    <!-- 保存 商户照片信息 instance add by wuxw 2018-07-03 -->
    <insert id="saveStorePhotoInstance" parameterType="Map">
        insert into s_store_photo(store_photo_id, b_id, store_id, store_photo_type_cd, photo, status_cd)
        select sp.store_photo_id, sp.b_id, sp.store_id, sp.store_photo_type_cd, sp.photo, '0'
        from business_store_photo sp
        where sp.operate = 'ADD'
          and sp.b_id = #{bId}
    </insert>
    <!-- 保存 商户证件信息 instance add by wuxw 2018-07-03 -->
    <insert id="saveStoreCerdentialsInstance" parameterType="Map">
        insert into s_store_cerdentials(store_cerdentials_id, b_id, store_id, credentials_cd, value, validity_period,
                                        positive_photo, negative_photo, status_cd)
        select sc.store_cerdentials_id,
               sc.b_id,
               sc.store_id,
               sc.credentials_cd,
               sc.value,
               sc.validity_period,
               sc.positive_photo,
               sc.negative_photo,
               '0'
        from business_store_cerdentials sc
        where sc.operate = 'ADD'
          and sc.b_id = #{bId}
    </insert>

    <!-- 查询商户信息 add by wuxw 2018-07-03 -->
    <select id="getStoreInfo" parameterType="Map" resultType="Map">
        select s.store_id,s.store_id storeId,
        s.b_id,
        s.user_id,
        s.name,
        s.address,
        s.tel,
        s.store_type_cd,
        s.nearby_landmarks,
        s.map_x,s.map_y,
        s.status_cd
        from s_store s
        where 1=1
        <if test="statusCd != null and statusCd != ''">
            and s.status_cd = #{statusCd}
        </if>

        <if test="bId != null and bId !=''">
            and s.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and s.store_id = #{storeId}
        </if>
    </select>

    <!-- 查询商户属性信息 add by wuxw 2018-07-03 -->
    <select id="getStoreAttrs" parameterType="Map" resultType="Map">
        select
        sa.b_id,sa.attr_id,sa.attr_id attrId,
        sa.store_id, sa.store_id storeId,sa.spec_cd,sa.spec_cd specCd,sa.value,sa.status_cd,
        c.name
        from s_store_attr sa inner join spec c on sa.spec_cd = c.spec_cd
        where
        1=1
        <if test="statusCd != null and statusCd != ''">
            and sa.status_cd = #{statusCd}
        </if>
        <if test="bId != null and bId !=''">
            and sa.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sa.store_id = #{storeId}
        </if>
        <if test="storeIds != null">
            and sa.store_id in
            <foreach collection="storeIds" open="(" close=")"
                     separator="," item="item">
                #{item}
            </foreach>
        </if>
        <if test="specCd != null and specCd !=''">
            and sa.spec_cd = #{specCd}
        </if>
        <if test="attrId != null and attrId != ''">
            and sa.attr_id = #{attrId}
        </if>
    </select>

    <!-- 查询商户照片信息 add by wuxw 2018-07-03 -->
    <select id="getStorePhoto" parameterType="Map" resultType="Map">
        select sp.store_photo_id,sp.b_id,sp.store_id,sp.store_photo_type_cd,sp.photo,sp.status_cd
        from s_store_photo sp
        where 1=1
        <if test="statusCd != null and statusCd != ''">
            and sp.status_cd = #{statusCd}
        </if>
        <if test="bId != null and bId !=''">
            and sp.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sp.store_id = #{storeId}
        </if>
    </select>

    <!-- 查询商户证件信息 add by wuxw 2018-07-03 -->
    <select id="getStoreCerdentials" parameterType="Map" resultType="Map">
        select
        sc.store_cerdentials_id,sc.b_id,sc.store_id,sc.credentials_cd,sc.value,sc.validity_period,sc.positive_photo,sc.negative_photo,sc.status_cd
        from s_store_cerdentials sc
        where 1=1
        <if test="statusCd != null and statusCd != ''">
            and sc.status_cd = #{statusCd}
        </if>
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sc.store_id = #{storeId}
        </if>
    </select>


    <!-- 修改商户信息 add by wuxw 2018-07-03 -->
    <update id="updateStoreInfoInstance" parameterType="Map">
        update s_store s set s.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,s.b_id = #{newBId}
        </if>
        <if test="userId != null and userId != ''">
            ,s.user_id = #{userId}
        </if>
        <if test="name != null and name != ''">
            ,s.name = #{name}
        </if>
        <if test="address != null and address != ''">
            ,s.address = #{address}
        </if>
        <if test="tel != null and tel != ''">
            ,s.tel = #{tel}
        </if>
        <if test="storeTypeCd != null and storeTypeCd != ''">
            ,s.store_type_cd = #{storeTypeCd}
        </if>
        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
            ,s.nearby_landmarks = #{nearbyLandmarks}
        </if>
        <if test="mapX != null and mapX != ''">
            ,s.map_x = #{mapX}
        </if>
        <if test="mapY != null and mapY != ''">
            ,s.map_y = #{mapY}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and s.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and s.store_id = #{storeId}
        </if>
    </update>

    <!-- 修改商户属性信息 add by wuxw 2018-07-03 -->
    <update id="updateStoreAttrInstance" parameterType="Map">
        update s_store_attr sa set sa.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,sa.b_id = #{newBId}
        </if>
        <if test="value != null and value != ''">
            ,sa.value = #{value}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and sa.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sa.store_id = #{storeId}
        </if>
        <if test="specCd != null and specCd !=''">
            and sa.spec_cd = #{specCd}
        </if>
        <if test="attrId != null and attrId !=''">
            and sa.attr_id = #{attrId}
        </if>
    </update>

    <!-- 修改商户照片信息 add by wuxw 2018-07-03 -->
    <update id="updateStorePhotoInstance" parameterType="Map">
        update s_store_photo sp set sp.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,sp.b_id = #{newBId}
        </if>
        <if test="storePhotoTypeCd != null and storePhotoTypeCd != ''">
            ,sp.store_photo_type_cd = #{storePhotoTypeCd}
        </if>
        <if test="photo != null and photo != ''">
            ,sp.photo = #{photo}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and sp.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sp.store_id = #{storeId}
        </if>
        <if test="storePhotoId != null and storePhotoId !=''">
            and sp.store_photo_id = #{storePhotoId}
        </if>
    </update>

    <!-- 修改商户证件信息 add by wuxw 2018-07-03 -->
    <update id="updateStoreCerdentailsInstance" parameterType="Map">
        update s_store_cerdentials sc set sc.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,sc.b_id = #{newBId}
        </if>
        <if test="credentialsCd != null and credentialsCd != ''">
            ,sc.credentials_cd = #{credentialsCd}
        </if>
        <if test="value != null and value != ''">
            ,sc.value = #{value}
        </if>
        <if test="validityPeriod != null">
            ,sc.validity_period = #{validityPeriod}
        </if>
        <if test="positivePhoto != null and positivePhoto != ''">
            ,sc.positive_photo = #{positivePhoto}
        </if>
        <if test="negativePhoto != null and negativePhoto != ''">
            ,sc.negative_photo = #{negativePhoto}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sc.store_id = #{storeId}
        </if>
        <if test="storeCerdentialsId != null and storeCerdentialsId !=''">
            and sc.store_cerdentials_id = #{storeCerdentialsId}
        </if>
    </update>

    <!--商户成员加入 add by wuxw 2018-10-27 saveBusinessMemberStore-->
    <insert id="saveBusinessMemberStore" parameterType="Map">
        insert into business_member_store(member_store_id, b_id, store_id, member_id, month, operate)
        values (#{memberStoreId}, #{bId}, #{storeId}, #{memberId}, #{month}, #{operate})
    </insert>

    <!-- 商户成员加入 instance表中 add by wuxw 2018-10-27 -->
    <insert id="saveMemberStoreInstance" parameterType="Map">
        insert into s_member_store(member_store_id, b_id, store_id, member_id, status_cd)
        select ms.member_store_id, ms.b_id, ms.store_id, ms.member_id, '0'
        from business_member_store ms
        where ms.operate = 'ADD'
          and ms.b_id = #{bId}
    </insert>

    <!-- 查询商户成员 add by wuxw 2018-10-27 getBusinessMemberStore-->
    <select id="getBusinessMemberStore" parameterType="Map" resultType="Map">
        select ms.member_store_id,ms.b_id,ms.store_id,ms.member_id,ms.operate
        from business_member_store ms where 1 = 1
        <if test="operate != null and operate != ''">
            and ms.operate = #{operate}
        </if>
        <if test="bId != null and bId !=''">
            and ms.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId != ''">
            and ms.store_id = #{storeId}
        </if>
    </select>


    <!-- 查询商户成员  add by wuxw 2018-07-03 -->
    <select id="getMemberStore" parameterType="Map" resultType="Map">
        select ms.member_store_id,ms.b_id,ms.store_id,ms.member_id,ms.status_cd
        from business_member_store ms
        where 1=1
        <if test="statusCd != null and statusCd != ''">
            and ms.status_cd = #{statusCd}
        </if>

        <if test="bId != null and bId !=''">
            and ms.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and ms.member_store_id = #{memberStoreId}
        </if>
    </select>

    <!-- 修改商户成员 add by wuxw 2018-07-03 -->
    <update id="updateMemberStoreInstance" parameterType="Map">
        update s_member_store ms set ms.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,ms.b_id = #{newBId}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and ms.b_id = #{bId}
        </if>
        <if test="memberStoreId != null and memberStoreId !=''">
            and ms.member_store_id = #{memberStoreId}
        </if>
    </update>


    <!-- 保存物业用户信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessStoreUser" parameterType="Map">
        insert into business_store_user(store_user_id, b_id, store_id, user_id, rel_cd, month, operate)
        values (#{storeUserId}, #{bId}, #{storeId}, #{userId}, #{relCd}, #{month}, #{operate})
    </insert>

    <!-- 查询物业 用户信息 add by wuxw 2018-07-03 -->
    <select id="getBusinessStoreUser" parameterType="Map" resultType="Map">
        select sc.store_user_id,sc.b_id,sc.store_id,sc.user_id,sc.rel_cd,sc.operate
        from business_store_user sc where 1 = 1
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
        </if>
        <if test="operate != null and operate != ''">
            and sc.operate = #{operate}
        </if>
        <if test="storeId != null and storeId != ''">
            and sc.store_id = #{storeId}
        </if>
    </select>

    <!-- 保存 商户用户信息 instance add by wuxw 2018-07-03 -->
    <insert id="saveStoreUserInstance" parameterType="Map">
        insert into s_store_user(store_user_id, b_id, store_id, user_id, rel_cd, status_cd)
        select sc.store_user_id, sc.b_id, sc.store_id, sc.user_id, sc.rel_cd, '0'
        from business_store_user sc
        where sc.operate = 'ADD'
          and sc.b_id = #{bId}
    </insert>

    <!-- 查询商户证件信息 add by wuxw 2018-07-03 -->
    <select id="getStoreUser" parameterType="Map" resultType="Map">
        select sc.store_user_id,sc.b_id,sc.store_id,sc.user_id,sc.rel_cd,sc.status_cd
        from s_store_user sc
        where 1=1
        <if test="statusCd != null and statusCd != ''">
            and sc.status_cd = #{statusCd}
        </if>
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sc.store_id = #{storeId}
        </if>
        <if test="userId != null and userId !=''">
            and sc.user_id = #{userId}
        </if>
    </select>

    <!-- 修改商户用户信息 add by wuxw 2018-07-03 -->
    <update id="updateStoreUserInstance" parameterType="Map">
        update s_store_user sc set sc.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,sc.b_id = #{newBId}
        </if>
        <if test="relCd != null and relCd != ''">
            ,sc.rel_cd = #{relCd}
        </if>
        where 1=1
        <if test="bId != null and bId !=''">
            and sc.b_id = #{bId}
        </if>
        <if test="storeId != null and storeId !=''">
            and sc.store_id = #{storeId}
        </if>
        <if test="storeUserId != null and storeUserId !=''">
            and sc.store_user_id = #{storeUserId}
        </if>
    </update>

    <!-- 查询商户 -->
    <select id="getStores" parameterType="Map" resultType="Map">
        select
        s.store_id,
        s.b_id,
        s.user_id,
        s.name,s.name storeName,
        s.address,
        s.tel,
        s.store_id storeId,
        s.store_type_cd,s.store_type_cd storeTypeCd,
        s.nearby_landmarks,s.nearby_landmarks nearByLandmarks,
        s.map_x,s.map_x mapX,
        s.map_y,s.map_y mapY,
        s.status_cd,
        st.name storeTypeName
        from s_store s,store_type st
        where s.status_cd = '0'
        and s.store_type_cd = st.store_type_cd
        <if test="userId != null and userId != ''">
            and s.user_id = #{userId}
        </if>
        <if test="name != null and name !=''">
            and s.name like concat('%',#{name},'%')
        </if>
        <if test="address != null and address != ''">
            and s.address like concat('%',#{address},'%')
        </if>
        <if test="tel != null and tel != ''">
            and s.tel = #{tel}
        </if>
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and s.store_type_cd = #{storeTypeCd}
        </if>
        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
            and s.nearby_landmarks = #{nearbyLandmarks}
        </if>
        <if test="storeId != null and storeId !=''">
            and s.store_id = #{storeId}
        </if>
        <if test="storeIds !=null">
            and s.store_id in
            <foreach collection="storeIds" open="(" close=")"
                     separator="," item="item">
                #{item}
            </foreach>
        </if>
        order by s.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>

    <!-- 查询商户 -->
    <select id="getStoreCount" parameterType="Map" resultType="Map">
        select count(1) count
        from s_store s,store_type st
        where s.status_cd = '0'
        and s.store_type_cd = st.store_type_cd
        <if test="userId != null and userId != ''">
            and s.user_id = #{userId}
        </if>
        <if test="name != null and name !=''">
            and s.name like concat('%',#{name},'%')
        </if>
        <if test="address != null and address != ''">
            and s.address like concat('%',#{address},'%')
        </if>
        <if test="tel != null and tel != ''">
            and s.tel = #{tel}
        </if>
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and s.store_type_cd = #{storeTypeCd}
        </if>
        <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
            and s.nearby_landmarks = #{nearbyLandmarks}
        </if>
        <if test="storeId != null and storeId !=''">
            and s.store_id = #{storeId}
        </if>
        <if test="storeIds !=null">
            and s.store_id in
            <foreach collection="storeIds" open="(" close=")"
                     separator="," item="item">
                #{item}
            </foreach>
        </if>
    </select>

    <!--查询员工和商户信息-->
    <select id="getStoreUserInfo" parameterType="Map" resultType="Map">
        select s.store_id,s.store_id storeId,s.b_id,s.user_id,s.user_id
        userId,s.name,s.address,s.tel,s.store_type_cd,s.store_type_cd storeTypeCd,
        s.nearby_landmarks,s.map_x,s.map_y,s.create_time,su.store_user_id,su.rel_cd,s.state,
        uu.`name` staffName
        from s_store s
        left join s_store_user su on s.store_id=su.store_id and su.status_cd = '0'
        LEFT JOIN u_user uu on su.user_id = uu.user_id and uu.status_cd = '0'
        where
        s.status_cd = '0'
        <if test="userId != null and userId != ''">
            and su.user_id = #{userId}
        </if>
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and s.store_type_cd = #{storeTypeCd}
        </if>
        <if test="storeId != null and storeId != ''">
            and s.store_id = #{storeId}
        </if>

    </select>


    <select id="getStoreStaffs" parameterType="Map" resultType="Map">
        select t.name storeName,t.address,su.user_id staffId , t.store_id storeId,t.create_time createTime,t.state
        from s_store t
        inner join s_store_user su on t.store_id = su.store_id and su.status_cd = '0'
        <if test="relCd != null and relCd != ''">
            and su.rel_cd = #{relCd}
        </if>
        where
        1=1
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and t.store_type_cd = #{storeTypeCd}
        </if>
        <if test="storeId != null and storeId != ''">
            and t.store_id = #{storeId}
        </if>
        and t.status_cd = '0'
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>

    <select id="getStoreStaffCount" parameterType="Map" resultType="Map">
        select count(1) count
        from s_store t
        inner join s_store_user su on t.store_id = su.store_id and su.status_cd = '0'
        <if test="relCd != null and relCd != ''">
            and su.rel_cd = #{relCd}
        </if>
        where
        1=1
        <if test="storeTypeCd != null and storeTypeCd != ''">
            and t.store_type_cd = #{storeTypeCd}
        </if>
        <if test="storeId != null and storeId != ''">
            and t.store_id = #{storeId}
        </if>
        and t.status_cd = '0'
    </select>

    <!-- 修改商户信息 add by wuxw 2018-07-03 -->
    <update id="updateStore" parameterType="Map">
        update s_store s
        <set>
            <if test="userId != null and userId != ''">
                s.user_id = #{userId},
            </if>
            <if test="name != null and name != ''">
                s.name = #{name},
            </if>
            <if test="address != null and address != ''">
                s.address = #{address},
            </if>
            <if test="tel != null and tel != ''">
                s.tel = #{tel},
            </if>
            <if test="storeTypeCd != null and storeTypeCd != ''">
                s.store_type_cd = #{storeTypeCd},
            </if>
            <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
                s.nearby_landmarks = #{nearbyLandmarks},
            </if>
            <if test="mapX != null and mapX != ''">
                s.map_x = #{mapX},
            </if>
            <if test="mapY != null and mapY != ''">
                s.map_y = #{mapY},
            </if>
            <if test="state != null and state != ''">
                s.state = #{state},
            </if>
        </set>
        where 1=1
        and s.store_id = #{storeId}
        and s.status_cd = '0'
    </update>
</mapper>