jyy
2021-07-13 a24cea1b37de9ae98d7f25c13b60eecd0280f534
zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml
@@ -85,12 +85,15 @@
      <result property="goodsSortName" column="goodsSortName" />
      <result property="achieveRuleName" column="achieveRuleName" />
      <result property="payMethods" column="pay_methods" />
      <result property="invalidTime" column="invalid_time" />
      <result property="useValid" column="use_valid" />
      <result property="buyValid" column="buy_valid" />
      <result property="isInfinite" column="is_infinite" />
      <result property="achieveRuleId" column="achieve_rule_id" />
@@ -160,11 +163,14 @@
      <!-- 服务项目信息 -->
      <result property="proReward" column="proReward" />
      <result property="timeLength" column="TIME_LENGTH" />
      <result property="achieveRuleId" column="achieve_rule_id" />
      <!-- 扩展属性 -->
      <result property="cateName" column="cate_name" />
      <result property="goodsSortName" column="goodsSortName" />
      <result property="achieveRuleName" column="achieveRuleName" />
   </resultMap>
@@ -301,7 +307,9 @@
      use_valid,
      invalid_time,
      pay_methods,
      is_infinite
      is_infinite,
      achieve_rule_id
      )
      VALUES (
      #{id},
@@ -362,7 +370,9 @@
         #{useValid},
         #{invalidTime},
         #{payMethods},
         #{isInfinite}
         #{isInfinite},
         #{achieveRuleId}
      )
   </insert>
@@ -419,7 +429,7 @@
         <if test="isPresent != null and isPresent !='' ">
            is_present = #{isPresent},
         </if>
         <if test="isOnce != null and isOnce !='' ">
         <if test="isOnce != null  ">
            is_once = #{isOnce},
         </if>
         <if test="salePlatform != null and salePlatform !='' ">
@@ -437,13 +447,13 @@
         </if>
         <if
            test="(carMaxSaleCount != null and carMaxSaleCount !='') or carMaxSaleCount==0">
            test="carMaxSaleCount != null">
            car_max_sale_count = #{carMaxSaleCount},
         </if>
         <if test="carIsAll != null and carIsAll !='' ">
            car_is_all = #{carIsAll},
         </if>
         <if test="(carUseCount != null and carUseCount !='') or carUseCount==0 ">
         <if test="carUseCount != null ">
            car_use_count = #{carUseCount},
         </if>
         <if test="isVipCar != null and isVipCar !='' ">
@@ -538,6 +548,10 @@
         <if test="isInfinite != null and isInfinite !='' ">
            is_infinite = #{isInfinite},
         </if>
         <if test="achieveRuleId != null and achieveRuleId !='' ">
            achieve_rule_id = #{achieveRuleId},
         </if>
            invalid_time = #{invalidTime},
            buy_valid = #{buyValid},
            use_valid = #{useValid},
@@ -576,8 +590,9 @@
   <select id="selectInPage" resultMap="ShoppingGoodsMap">
      select
      a.*,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from shopping_goods_category t where t.id=a.cate_id) cate_name,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) as  goodsSortName,
      (select NAME from shopping_goods_category t where t.id=a.cate_id) as cate_name,
      (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shop_name
      from shopping_goods a
      where 1=1
@@ -652,6 +667,11 @@
         </if>
         <if test="record.achieveRuleId != null and record.achieveRuleId !='' ">
            and achieve_rule_id = #{record.achieveRuleId}
         </if>
         <if test="record.headquarters != null and record.headquarters !='' ">
            and headquarters = #{record.headquarters}
@@ -685,28 +705,25 @@
         <if test="record.queryNoGoodsype != null and record.queryNoGoodsype !='' ">
            and good_type !=#{record.queryNoGoodsype}
         </if>
         <if test="record.name != null and record.name !='' ">
            and (instr(name,#{record.name}) or instr(zjm,#{record.name}))
         </if>
         <if test="record.zjm != null and record.zjm !='' ">
            and instr(zjm,#{record.zjm})
         </if>
         <if test="record.staus != null and record.staus !='' ">
            and staus =#{record.staus}
         </if>
         <if test="record.code != null and record.code !=''">
            and code = #{record.code}
         </if>
         <if test="record.isAssemble != null and record.isAssemble !='' ">
            and is_assemble =#{record.isAssemble}
         </if>
         <if test="record.deleted != null and record.deleted !='' ">
            and deleted =#{record.deleted}
         </if>
         <if test="record.isDel != null and record.isDel !='' ">
            and is_del = #{record.isDel}
         </if>
         <if test="record.zjm != null and record.zjm !='' ">
            and instr(zjm,#{record.zjm})
         </if>
         <if test="record.cateId != null and record.cateId !='' ">
            and cate_id =#{record.cateId}
         </if>
@@ -721,39 +738,54 @@
         <if test="record.isVipCar != null and record.isVipCar !='' ">
            and is_vip_car = #{record.isVipCar}
         </if>
         <if test="record.achieveRuleId != null and record.achieveRuleId !='' ">
            and achieve_rule_id = #{record.achieveRuleId}
         </if>
         <if test="record.isCourse != null and record.isCourse !=''">
            and is_course = #{record.isCourse}
         </if>
         <if test="record.code != null and record.code !=''">
            and code = #{record.code}
         </if>
         <if test="record.startTime != null ">
            and create_time <![CDATA[ >= ]]> #{record.startTime}
         </if>
         <if test="record.endTime != null ">
            and create_time <![CDATA[ <= ]]> #{record.endTime}
         </if>
         <if test="record.shopId != null and record.shopId !='' ">
            <![CDATA[   and ( shop_id = #{record.shopId}
            or  ISNULL(use_shop) || LENGTH(trim(use_shop))<1
            or FIND_IN_SET(#{record.shopId},use_shop) ) ]]>
            <![CDATA[   and ( shop_id = #{record.shopId} or
                  (  headquarters=1 and  ( ISNULL(use_shop) or LENGTH(trim(use_shop))<1 or FIND_IN_SET(#{record.shopId},use_shop))))]]>
         </if>
         <if test="record.companyId != null and record.companyId !='' ">
            and company_id = #{record.companyId}
         </if>
         <if test="record.isDel != null and record.isDel !='' ">
            and is_del = #{record.isDel}
         </if>
         <if test="record.headquarters != null and record.headquarters !='' ">
            and headquarters = #{record.headquarters}
         </if>
      </if>
   </select>
   <select id="selectAll" resultMap="ShoppingGoodsSimpleMap">
      select
      *,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from
      shopping_goods_category t where t.id=cate_id)
@@ -859,6 +891,7 @@
   <select id="findByCode" resultMap="ShoppingGoodsMap">
      select
      *,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from shopping_goods_category t where
      t.id=cate_id)
@@ -871,6 +904,7 @@
   <select id="selectSimpleMapById" resultMap="ShoppingGoodsSimpleMap">
      select
      *,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from
      shopping_goods_category t where t.id=cate_id)
@@ -890,6 +924,7 @@
   <select id="selectByModel" resultMap="ShoppingGoodsMap">
      select
      *,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from
      shopping_goods_category t where t.id=cate_id)
@@ -969,6 +1004,7 @@
   <select id="selectByModel1" resultMap="ShoppingGoodsMap">
      select
      *,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from
      shopping_goods_category t where t.id=cate_id)
@@ -1047,6 +1083,7 @@
   <select id="selectInPageNoTaocan" resultMap="ShoppingGoodsMap">
      select
      *,
      (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
      (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
      (select NAME from
      shopping_goods_category t where t.id=cate_id)
@@ -1218,6 +1255,10 @@
</foreach>
   </update>
   <update id="updateInvalidProduct">
      update shopping_goods set staus = '下架'
      where    date_format(now(), '%Y-%m-%d') > date_format(sale_off_time, '%Y-%m-%d') and staus='上架'
   </update>
   <!-- 根据code查询 -->
@@ -1239,12 +1280,22 @@
         measure measure,
         a.good_type goodsType
      from shopping_goods a
      where 1=1
      where 1=1 and staus = '上架' and a.is_del=1
      <if test="record.queryKey != null and record.queryKey != ''">
         and (instr(name,#{record.queryKey}) or instr(code ,#{record.queryKey}) or instr(zjm ,#{record.queryKey}))
      </if>
      <if test="record.cateId!=null">
         and a.cate_id in ( select b.id from shopping_goods_category b where (b.id=#{record.cateId} or b.parent_id=#{record.cateId}))
      </if>
      <if test="record.shopId != null and record.shopId !='' ">
         <![CDATA[   and ( a.shop_id = #{record.shopId} or
                  (  a.headquarters=1 and  ( ISNULL(a.use_shop) or LENGTH(trim(a.use_shop))<1 or FIND_IN_SET(#{record.shopId},a.use_shop))))]]>
      </if>
      <if test="record.companyId != null and record.companyId !='' ">
         and a.company_id=#{record.companyId}
      </if>
      <if test="record.goodType!=null">
         and a.good_type=#{record.goodType}
      </if>
      <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
         <if test="pageVo.sort !=null  and pageVo.order !=null">
@@ -1259,12 +1310,32 @@
   <select id="selectShopppingGoodsAipTotal" resultType="java.lang.Integer">
      select count(1)
      from shopping_goods a
      where 1=1
      where 1=1 and staus = '上架'
      <if test="record.queryKey != null and record.queryKey != ''">
         and (instr(name,#{record.queryKey}) or instr(code ,#{record.queryKey}) or instr(zjm ,#{record.queryKey}))
      </if>
      <if test="record.cateId!=null">
         and a.cate_id in ( select b.id from shopping_goods_category b where (b.id=#{record.cateId} or b.parent_id=#{record.cateId}))
      </if>
      <if test="record.shopId != null and record.shopId !='' ">
         <![CDATA[   and ( a.shop_id = #{record.shopId} or
                  (  a.headquarters=1 and  ( ISNULL(a.use_shop) or LENGTH(trim(a.use_shop))<1 or FIND_IN_SET(#{record.shopId},a.use_shop))))]]>
      </if>
      <if test="record.companyId != null and record.companyId !='' ">
         and a.company_id=#{record.companyId}
      </if>
      <if test="record.goodType!=null">
         and a.good_type=#{record.goodType}
      </if>
   </select>
   <select id="selectByIds" resultMap="ShoppingGoodsSimpleMap">
      select
      *
      from shopping_goods
      where id in
      <foreach collection="ids" item="item" separator="," open="(" close=")">
         #{item}
      </foreach>
   </select>
</mapper>