<?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="com.sqx.modules.goods.dao.GoodsShopDao">

    <select id="selectAllShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select gs.*, (SELECT GROUP_CONCAT(st1.shop_type_name SEPARATOR ',')
        FROM shop_type st1 WHERE FIND_IN_SET(st1.id,gs.shop_type_id) ) as shopTypeName,
        (select user_id from sys_user where user_id in (select s.user_id from sys_user_shop s where
        s.shop_id=gs.shop_id) and user_type=2) as adminUserId
        from goods_shop gs
        left join shop_type st on gs.shop_type_id = st.id
        where 1 = 1 and status = 1
        <if test="shopName!=null and shopName!=''">
            and shop_name like concat('%',#{shopName},'%')
        </if>
        <if test="region!=null and region!=''">
            and (province like concat('%',#{region},'%') or
            city like concat('%',#{region},'%') or
            district like concat('%',#{region},'%') )
        </if>
        <if test="isActivity!=null">
            <if test="isActivity==0">
                and gs.activity_id is null
            </if>
            <if test="isActivity==1">
                and gs.activity_id is not null
            </if>
        </if>
        <if test="vipPromotion != null and vipPromotion != ''">
            and gs.vip_promotion = #{vipPromotion}
        </if>
        order by create_time desc
    </select>

    <select id="selectAllShopByAdmin" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select gs.* from goods_shop gs left join sys_user_shop sus on sus.shop_id = gs.shop_id where 1 = 1
        and sus.user_id = #{userId}
        <if test="shopName!=null and shopName!=''">
            and shop_name like concat('%',#{shopName},'%')
        </if>
    </select>

    <select id="selectListByAdmin" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select gs.*
        from goods_shop gs
                 left join sys_user_shop sus on sus.shop_id = gs.shop_id
        where 1 = 1
          and sus.user_id = #{userId}
    </select>

    <select id="selectAdminGoodsList" resultType="com.sqx.modules.goods.entity.Goods">
        select g.*, gc.classify_name as classifyName,gsr.sales as sales, gs.shop_name as shopName, gsr.inventory as inventory,
        IF(gsr.inventory = 0,2,gsr.status) AS gsrStatus
        from goods g
        left join goods_classify gc on g.classify_id = gc.classify_id
        left join goods_shop gs on g.shop_id = gs.shop_id
        left join goods_shop_relevancy gsr on g.goods_id = gsr.goods_id
        where 1 = 1
        <if test="classifyId!=null">
            and g.classify_id = #{classifyId}
        </if>
        <if test="goodsName!=null and goodsName!=''">
            and g.goods_name like concat('%',#{goodsName},'%')
        </if>
        <if test="status!=null">
            and g.status = #{status}
        </if>
        <if test="shopId!=null">
            and g.shop_id = #{shopId}
        </if>
        <if test="shopName!=null and shopName!=''">
            and gs.shop_name like concat('%',#{shopName},'%')
        </if>
        order by g.create_time desc
    </select>

    <select id="selectGoodsByShopId" resultType="com.sqx.modules.goods.entity.Goods">
        select g.*,gc.classify_name as classifyName,gsr.sales, gsr.inventory as inventory, IF(gsr.inventory =
        0,2,gsr.status) AS gsrStatus
        from goods g
        left join goods_shop_relevancy gsr on gsr.goods_id = g.goods_id
        left join goods_classify gc on g.classify_id = gc.classify_id
        where gsr.shop_id = #{shopId}
        <if test="goodsName!=null and goodsName!=''">
            and g.goods_name like concat('%',#{goodsName},'%')
        </if>
        <if test="classifyId!=null">
            and g.classify_id = #{classifyId}
        </if>
        <if test="status!=null">
            <if test="status!=2">
                and g.status = #{status}
            </if>
            <if test="status==2">
                AND gsr.inventory = 0
            </if>
        </if>
        order by LPAD(g.sort, 10, '0') ASC,gsr.create_time desc
    </select>


    <select id="selectGoodsByNotShopId" resultType="com.sqx.modules.goods.entity.Goods">
        select g.*, gc.classify_name as classifyName from goods g
        left join goods_classify gc on g.classify_id = gc.classify_id
        where g.goods_id not in (select gsr.goods_id from goods_shop_relevancy gsr where gsr.shop_id = #{shopId})
        and g.status = 0
        <if test="goodsName!=null and goodsName!=''">
            and g.goods_name like concat('%',#{goodsName},'%')
        </if>
    </select>

    <insert id="addGoodsByShopId" parameterType="com.sqx.modules.goods.entity.GoodsShopRelevancy">
        insert into goods_shop_relevancy (shop_id, goods_id, status, create_time, sales, inventory) values
        <foreach item="item" collection="goodsShopRelevancyList" separator=",">
            (#{item.shopId}, #{item.goodsId}, 0, #{date}, 0, 999)
        </foreach>
    </insert>

    <delete id="deleteGoodsByShopId">
        delete
        from goods_shop_relevancy
        where shop_id = #{shopId}
          and goods_id = #{goodsId}
    </delete>

    <delete id="deleteGoods">
        delete
        from goods
        where shop_id = #{shopId}
          and goods_id = #{goodsId}
    </delete>
    <delete id="cancelActivityShop">
        update goods_shop
        set activity_id =null
        where shop_id = #{shopId}
    </delete>

    <update id="updateShopSales">
        update goods_shop
        <if test="type==1">
            set shop_sales = shop_sales + #{goodsNum}
        </if>
        <if test="type==2">
            set shop_sales = shop_sales - #{goodsNum}
        </if>
        where shop_id = #{shopId}
    </update>

    <update id="updateCashDeposit">
        update goods_shop
        set cash_deposit = cash_deposit + #{money}
        where shop_id = #{shopId}
    </update>

    <update id="updateShopCashDeposit">
        update goods_shop set
        <if test="type==1">
            cash_deposit = cash_deposit+#{money}
        </if>
        <if test="type==2">
            cash_deposit = cash_deposit-#{money}
        </if>
        where shop_id = #{shopId}
    </update>

    <update id="soldOutOrPutaway">
        update goods_shop_relevancy
        set status = #{status}
        where shop_id = #{shopId}
          and goods_id = #{goodsId}
    </update>

    <select id="selectStoreCount" resultType="int">
        select count(*) from tb_order where shop_id = #{shopId} and status = 4
        <if test="(endTime!=null and endTime!='') or (startTime!=null and startTime!='')">
            and date_format(pay_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
            and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
        </if>

    </select>

    <select id="selectStoreMoney" resultType="java.math.BigDecimal">
        select ifnull(sum(pay_money), 0) from tb_order where shop_id = #{shopId} and status = 4
        <if test="(endTime!=null and endTime!='') or (startTime!=null and startTime!='')">
            and date_format(pay_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
            and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
        </if>
    </select>

    <select id="selectStoreMessage" resultType="com.sqx.modules.order.entity.TbOrder">
        select
            tor.*,
            gs.shop_name as shopName
        from
            tb_order tor
            left join goods_shop gs on tor.shop_id = gs.shop_id
        where
            tor.status in (3, 4, 6, 7)
            <if test="shopId != null">
                and tor.shop_id = #{shopId}
            </if>
            <if test="(endTime != null and endTime != '') and (startTime != null and startTime != '')">
                and date_format(tor.pay_time, '%Y-%m-%d') &gt;= date_format(#{startTime}, '%Y-%m-%d')
                and date_format(tor.pay_time, '%Y-%m-%d') &lt;= date_format(#{endTime}, '%Y-%m-%d')
            </if>
        order by tor.pay_time desc
    </select>

    <select id="selectSearch" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select gs.*,
               (st_distance(point(shop_lng, shop_lat), point(#{lng}, #{lat})) * 111195) AS distance,
               st.shop_type_name                                                        as shopTypeName
        from goods_shop gs
                 left join shop_type st on gs.shop_type_id = st.id
        where gs.status = 1
          and gs.city = #{city}
          and ((gs.shop_name like concat('%', #{impotr}, '%')) or
               (st.shop_type_name like concat('%', #{impotr}, '%')) or (gs.shop_lable like concat('%', #{impotr}, '%')))
        order by distance asc
    </select>

    <select id="selectShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select
            *
        from
            (
                select
                    gs.*,
                    (st_distance (point (gs.shop_lng,gs.shop_lat),point(#{lng}, #{lat}) ) * 111195) AS distance
                from
                    goods_shop gs
                left join shop_type st on gs.shop_type_id = st.id
                where
                    gs.status = 1
                    and gs.city = #{city}
                    and gs.putaway_flag = 0
                    and gs.is_supplier=1
                    and (gs.is_conceal =0 or gs.is_conceal is NULL)
                <if test="impotr!=null and impotr!=''">
                    AND (
                        gs.shop_name LIKE concat('%',#{impotr},'%')
                        or st.shop_type_name like concat('%',#{impotr},'%')
                        or gs.shop_lable LIKE concat('%',#{impotr},'%')
                        or gs.shop_id in (
                            select shop_id from goods where goods_name like concat('%',#{impotr},'%')
                        )
                    )
                </if>
                <if test="activityId!=null">
                    and gs.activity_id = #{activityId}
                </if>
                <if test="shopTypeId!=null">
                    and FIND_IN_SET(#{shopTypeId},gs.shop_type_id)
                </if>
                <if test="vipPromotion !=null and vipPromotion != ''">
                    and gs.vip_promotion = #{vipPromotion}
                </if>
                order by
                    gs.is_recommend desc
                <if test="screen == 1">
                    ,gs.sort,gs.shop_score desc, gs.shop_sales desc, gs.create_time desc
                </if>
                <if test="screen == 2">
                    ,gs.shop_score desc
                </if>
                <if test="screen == 3">
                    ,gs.shop_sales desc
                </if>
                <if test="screen == 4">
                    ,gs.create_time desc
                </if>
            ) a
        where
            distribution_distance >= distance
    </select>

    <select id="selectEvaluate" resultType="com.sqx.modules.order.entity.Evaluate">
        select e.*, tu.nick_name as userName, tu.avatar as avatar from evaluate e
        left join tb_user tu on e.user_id = tu.user_id
        where e.shop_id = #{shopId}
        <if test="grade==1">
            and e.score = 5
        </if>
        <if test="grade==2">
            and e.score in (4, 3)
        </if>
        <if test="grade==3">
            and e.score in (2, 1)
        </if>
        <if test="goodsId!=null and goodsId!=''">
            and e.goods_id like concat("%",#{goodsId},"%")
        </if>
        order by e.create_time desc
    </select>

    <select id="selectEvaluateByGoodsId" resultType="com.sqx.modules.order.entity.Evaluate">
        select e.*, tu.nick_name as nickName, tu.avatar as avatar
        from evaluate e
        left join tb_user tu on e.user_id = tu.user_id
        where goods_id =#{goodsId}
        <if test="grade!=null and grade ==0">
            and e.score in (1,2,3,4,5)
        </if>
        <if test="grade!=null and grade ==1">
            and e.score =5
        </if>
        <if test="grade!=null and grade ==2">
            and e.score in (4,3)
        </if>
        <if test="grade!=null and grade ==3">
            and e.score in (2,1)
        </if>
        order by create_time desc
    </select>

    <select id="selectShopList" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select gs.*, st.shop_type_name as shopTypeName from goods_shop gs left join shop_type st on gs.shop_type_id =
        st.id where 1 = 1
        <if test="shopName!=null and shopName!=''">
            and shop_name like concat('%',#{shopName},'%')
        </if>
        <if test="status!=null">
            and status = #{status}
        </if>
        <if test="shopType!=null">
            and shop_type_id = #{shopType}
        </if>
        order by create_time desc
    </select>

    <insert id="addGoodsShopRelevancy" parameterType="com.sqx.modules.goods.entity.GoodsShopRelevancy">
        insert into goods_shop_relevancy (shop_id, goods_id, status, create_time, sales, inventory)
        values (#{shopId}, #{goodsId}, #{status}, #{createTime}, #{sales}, #{inventory})
    </insert>

    <select id="shopAllEarnings" resultType="java.math.BigDecimal">
        select ifnull(sum(shop_income_money), 0)
        from tb_order
        where shop_id = #{shopId}
          and is_pay = 1
          and status = 4
    </select>

    <select id="shopEarningsDay" resultType="java.math.BigDecimal">
        select ifnull(sum(shop_income_money), 0)
        from tb_order
        where shop_id = #{shopId}
          and is_pay = 1
          and status = 4
          and date_format(pay_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
    </select>

    <select id="shopEarningsMonth" resultType="java.math.BigDecimal">
        select ifnull(sum(shop_income_money), 0)
        from tb_order
        where shop_id = #{shopId}
          and is_pay = 1
          and status = 4
          and date_format(pay_time, '%Y-%m') = date_format(#{date}, '%Y-%m')
    </select>

    <select id="allMoney" resultType="java.math.BigDecimal">
        select ifnull(sum(shop_income_money), 0) from tb_order where shop_id = #{shopId} and is_pay = 1 and status = 4
        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
            and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
            str_to_date(#{endTime}, '%Y-%m-%d')
        </if>
    </select>

    <select id="selectCountOrder" resultType="int">
        select count(*) from tb_order where 1 = 1 and status = #{status} and shop_id = #{shopId}
        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
            and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
            str_to_date(#{endTime}, '%Y-%m-%d')
        </if>
    </select>

    <select id="allCount" resultType="int">
        select ifnull(sum(og.goods_num), 0) from tb_order tor left join order_goods og on tor.order_id = og.order_id
        where 1 = 1 and tor.shop_id = #{shopId} and tor.is_pay = 1 and tor.status = 4
        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
            and str_to_date(tor.pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
            str_to_date(#{endTime}, '%Y-%m-%d')
        </if>
    </select>

    <select id="orderMoney" resultType="java.math.BigDecimal">
        select ifnull(sum(pay_money), 0) from tb_order where 1 = 1 and shop_id = #{shopId} and is_pay = 1 and status = 4
        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
            and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
            str_to_date(#{endTime}, '%Y-%m-%d')
        </if>
    </select>

    <select id="sumCountOrder" resultType="int">
        select count(*) from tb_order where 1 = 1 and shop_id = #{shopId} and is_pay = 1
        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
            and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
            str_to_date(#{endTime}, '%Y-%m-%d')
        </if>
    </select>

    <select id="refundMoney" resultType="java.math.BigDecimal">
        select ifnull(sum(pay_money), 0) from tb_order where 1 = 1 and is_pay = 1 and shop_id = #{shopId} and status in
        (5, 8)
        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
            and str_to_date(pay_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
            str_to_date(#{endTime}, '%Y-%m-%d')
        </if>
    </select>

    <select id="putawayCount" resultType="int">
        select count(*)
        from goods
        where shop_id = #{shopId}
          and status = 0
    </select>

    <select id="soldoutCount" resultType="int">
        select count(*)
        from goods
        where shop_id = #{shopId}
          and status = 1
    </select>

    <select id="selectGoodsList" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select *,
               (st_distance(point(shop_lng, shop_lat), point(#{lng}, #{lat})) * 111195) AS distance,
               st.shop_type_name                                                        as shopTypeName
        from goods_shop gs
                 left join shop_type st on gs.shop_type_id = st.id
        where shop_id = #{shopId}
    </select>

    <select id="selectGoodShopByPhone" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select *,
               st.shop_type_name as shopTypeName
        from goods_shop gs
                 left join shop_type st on gs.shop_type_id = st.id
        where phone = #{phone}
    </select>

    <select id="selectGoodReputation" resultType="int">
        select count(*)
        from evaluate
        where 1=1
        <if test="shopId!=null">
            and shop_id = #{shopId}
        </if>
        <if test="goodsId!=null and goodsId!=''">
            and goods_id like concat("%",#{goodsId},"%")
        </if>

        and score = 5
    </select>

    <select id="selectMediumReview" resultType="int">
        select count(*)
        from evaluate
        where 1=1
        <if test="shopId!=null">
            and shop_id = #{shopId}
        </if>
        <if test="goodsId!=null and goodsId!=''">
            and goods_id like concat("%",#{goodsId},"%")
        </if>
        and score in (4, 3)
    </select>

    <select id="selectNegativeComment" resultType="int">
        select count(*)
        from evaluate
        where 1=1
        <if test="shopId!=null">
            and shop_id = #{shopId}
        </if>
        <if test="goodsId!=null and goodsId!=''">
            and goods_id like concat("%",#{goodsId},"%")
        </if>
        and score in (2, 1)
    </select>
    <select id="getShoActivityShopList" resultType="com.sqx.modules.goods.entity.GoodsShop">
       select * from ( SELECT
        s.*,
        (st_distance(POINT(s.shop_lng, s.shop_lat),POINT(#{goodsShop.shopLng}, #{goodsShop.shopLat})) * 111195) AS distance,
        (SELECT shop_type_name FROM shop_type t WHERE t.id = s.shop_type_id) AS shopTypeName
        FROM
        goods_shop s
        WHERE 1 = 1
        and s.status=1 and s.putaway_flag=0 and s.banned_flag=0
        <if test="goodsShop.activityId!=null">
            and s.activity_id = #{goodsShop.activityId}
        </if>
        <if test="goodsShop.city!=null and goodsShop.city!=''">
            and s.city = #{goodsShop.city}
        </if>
        ) t1

        WHERE t1.distribution_distance >= distance
        order by t1.sort,distance asc
    </select>

    <select id="getAdminShoActivityShopList" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select * from ( SELECT
        s.*,
        (st_distance(POINT(s.shop_lng, s.shop_lat),POINT(#{goodsShop.shopLng}, #{goodsShop.shopLat})) * 111195) AS distance,
        (SELECT shop_type_name FROM shop_type t WHERE t.id = s.shop_type_id) AS shopTypeName
        FROM
        goods_shop s
        WHERE 1 = 1
        <if test="goodsShop.activityId!=null">
            and s.activity_id = #{goodsShop.activityId}
        </if>
        <if test="goodsShop.city!=null and goodsShop.city!=''">
            and s.city = #{goodsShop.city}
        </if>
        ) t1
        order by distance asc
    </select>

    <select id="selectSupplierShop" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select * from (select gs.*,(st_distance (point (gs.shop_lng,gs.shop_lat),point(#{lng},#{lat}) ) *111195) AS
        distance
        from goods_shop gs
        left join shop_type st on gs.shop_type_id = st.id
        where gs.status = 1 and gs.city = #{city} and gs.putaway_flag = 0 and gs.is_supplier=0
        <if test="impotr!=null and impotr!=''">
            AND (gs.shop_name LIKE concat('%',#{impotr},'%') or
            st.shop_type_name like concat('%',#{impotr},'%') or
            gs.shop_lable LIKE concat('%',#{impotr},'%') or
            gs.shop_id in (
            select shop_id from goods where goods_name like concat('%',#{impotr},'%')
            )
            )
        </if>

        <if test="activityId!=null">
            and gs.activity_id = #{activityId}
        </if>
        <if test="shopTypeId!=null">
            and  FIND_IN_SET(#{shopTypeId},gs.shop_type_id)
        </if>
        order by gs.is_recommend desc
        <if test="screen==1">
            ,gs.sort,gs.shop_score desc, distance asc
        </if>
        <if test="screen==3">
            ,distance asc
        </if>
        <if test="screen==4">
            ,gs.shop_sales desc
        </if>
        ) a
        where distribution_distance >= distance
    </select>

    <select id="getByAdminUserId" resultType="com.sqx.modules.goods.entity.GoodsShop">
        select
               gs.*
        from
             goods_shop gs
             left join sys_user_shop sus on sus.shop_id = gs.shop_id
        where sus.user_id = #{adminUserId}
    </select>


    <insert id="insertGoodsShop" useGeneratedKeys="true" keyProperty="shopId"
            parameterType="com.sqx.modules.goods.entity.GoodsShop">
        INSERT INTO goods_shop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="null != shopName and '' != shopName">
                shop_name,
            </if>
            <if test="null != userId and '' != userId">
                user_id,
            </if>
            <if test="null != shopTypeId and '' != shopTypeId">
                shop_type_id,
            </if>
            <if test="null != shopLable and '' != shopLable">
                shop_lable,
            </if>
            <if test="null != detailedAddress and '' != detailedAddress">
                detailed_address,
            </if>
            <if test="null != shopLng and '' != shopLng">
                shop_lng,
            </if>
            <if test="null != shopLat and '' != shopLat">
                shop_lat,
            </if>
            <if test="null != province and '' != province">
                province,
            </if>
            <if test="null != city and '' != city">
                city,
            </if>
            <if test="null != district and '' != district">
                district,
            </if>
            <if test="null != accessNumber and '' != accessNumber">
                access_number,
            </if>
            <if test="null != shopNotice and '' != shopNotice">
                shop_notice,
            </if>
            <if test="null != shopScore and '' != shopScore">
                shop_score,
            </if>
            <if test="null != shopSales and '' != shopSales">
                shop_sales,
            </if>
            <if test="null != businessHours and '' != businessHours">
                business_hours,
            </if>
            <if test="null != lockHours and '' != lockHours">
                lock_hours,
            </if>
            <if test="null != shopCover and '' != shopCover">
                shop_cover,
            </if>
            <if test="null != shopBanner and '' != shopBanner">
                shop_banner,
            </if>
            <if test="null != createTime and '' != createTime">
                create_time,
            </if>
            <if test="null != realName and '' != realName">
                real_name,
            </if>
            <if test="null != identitycardNumber and '' != identitycardNumber">
                identitycard_number,
            </if>
            <if test="null != phone and '' != phone">
                phone,
            </if>
            <if test="null != businessLicense and '' != businessLicense">
                business_license,
            </if>
            <if test="null != identitycardPro and '' != identitycardPro">
                identitycard_pro,
            </if>
            <if test="null != identitycardCon and '' != identitycardCon">
                identitycard_con,
            </if>
            <if test="null != auditReason and '' != auditReason">
                audit_reason,
            </if>
            <if test="null != cashDeposit and '' != cashDeposit">
                cash_deposit,
            </if>
            <if test="null != auditTime and '' != auditTime">
                audit_time,
            </if>
            <if test="null != status and '' != status">
                status,
            </if>
            <if test="null != errandMoney and '' != errandMoney">
                errand_money,
            </if>
            <if test="null != distributionDistance and '' != distributionDistance">
                distribution_distance,
            </if>
            <if test="null != exemptErrandFlag ">
                exempt_errand_flag,
            </if>
            <if test="null != exemptMinMoney and '' != exemptMinMoney">
                exempt_min_money,
            </if>
            <if test="null != minimumDelivery ">
                minimum_delivery,
            </if>
            <if test="null != putawayFlag ">
                putaway_flag,
            </if>
            <if test="null != autoSendOrder and '' != autoSendOrder">
                auto_send_order,
            </if>
            <if test="null != bannedFlag ">
                banned_flag,
            </if>
            <if test="null != snCode and '' != snCode">
                sn_code,
            </if>
            <if test="null != value and '' != value">
                `value`,
            </if>
            <if test="null != facility ">
                facility,
            </if>
            <if test="null != autoAcceptOrder ">
                auto_accept_order
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="null != shopName and '' != shopName">
                #{shopName},
            </if>
            <if test="null != userId and '' != userId">
                #{userId},
            </if>
            <if test="null != shopTypeId and '' != shopTypeId">
                #{shopTypeId},
            </if>
            <if test="null != shopLable and '' != shopLable">
                #{shopLable},
            </if>
            <if test="null != detailedAddress and '' != detailedAddress">
                #{detailedAddress},
            </if>
            <if test="null != shopLng and '' != shopLng">
                #{shopLng},
            </if>
            <if test="null != shopLat and '' != shopLat">
                #{shopLat},
            </if>
            <if test="null != province and '' != province">
                #{province},
            </if>
            <if test="null != city and '' != city">
                #{city},
            </if>
            <if test="null != district and '' != district">
                #{district},
            </if>
            <if test="null != accessNumber and '' != accessNumber">
                #{accessNumber},
            </if>
            <if test="null != shopNotice and '' != shopNotice">
                #{shopNotice},
            </if>
            <if test="null != shopScore and '' != shopScore">
                #{shopScore},
            </if>
            <if test="null != shopSales and '' != shopSales">
                #{shopSales},
            </if>
            <if test="null != businessHours and '' != businessHours">
                #{businessHours},
            </if>
            <if test="null != lockHours and '' != lockHours">
                #{lockHours},
            </if>
            <if test="null != shopCover and '' != shopCover">
                #{shopCover},
            </if>
            <if test="null != shopBanner and '' != shopBanner">
                #{shopBanner},
            </if>
            <if test="null != createTime and '' != createTime">
                #{createTime},
            </if>
            <if test="null != realName and '' != realName">
                #{realName},
            </if>
            <if test="null != identitycardNumber and '' != identitycardNumber">
                #{identitycardNumber},
            </if>
            <if test="null != phone and '' != phone">
                #{phone},
            </if>
            <if test="null != businessLicense and '' != businessLicense">
                #{businessLicense},
            </if>
            <if test="null != identitycardPro and '' != identitycardPro">
                #{identitycardPro},
            </if>
            <if test="null != identitycardCon and '' != identitycardCon">
                #{identitycardCon},
            </if>
            <if test="null != auditReason and '' != auditReason">
                #{auditReason},
            </if>
            <if test="null != cashDeposit and '' != cashDeposit">
                #{cashDeposit},
            </if>
            <if test="null != auditTime and '' != auditTime">
                #{auditTime},
            </if>
            <if test="null != status and '' != status">
                #{status},
            </if>
            <if test="null != errandMoney and '' != errandMoney">
                #{errandMoney},
            </if>
            <if test="null != distributionDistance and '' != distributionDistance">
                #{distributionDistance},
            </if>
            <if test="null != exemptErrandFlag ">
                #{exemptErrandFlag},
            </if>
            <if test="null != exemptMinMoney and '' != exemptMinMoney">
                #{exemptMinMoney},
            </if>
            <if test="null != minimumDelivery ">
                #{minimumDelivery},
            </if>
            <if test="null != putawayFlag ">
                #{putawayFlag},
            </if>
            <if test="null != autoSendOrder and '' != autoSendOrder">
                #{autoSendOrder},
            </if>
            <if test="null != bannedFlag">
                #{bannedFlag},
            </if>
            <if test="null != snCode and '' != snCode">
                #{snCode},
            </if>
            <if test="null != value and '' != value">
                #{value},
            </if>
            <if test="null != facility ">
                #{facility},
            </if>
            <if test="null != autoAcceptOrder ">
                #{autoAcceptOrder}
            </if>
        </trim>
    </insert>


</mapper>