xiaoyong931011
2021-04-12 a13a93a493e7e94e28b2225c26e7e13b52d3288c
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
@@ -18,6 +18,7 @@
      <result property="freeConsume" column="free_consume" />
      <result property="hisConsume" column="his_consume" />
      <result property="goodsCash" column="goods_cash" />
      <result property="cardCash" column="card_cash" />
      <result property="projNum" column="proj_num" />
      <result property="numberOfPeople" column="number_of_people" />
      <result property="shopName" column="shop_name" />
@@ -44,12 +45,13 @@
      <result property="guwen" column="guwen" />
      <result property="meiliao" column="meiliao" />
      <result property="zkTotal" column="zk_total" />
      <result property="payMethod" column="pay_method" />
      <result property="arriveCnt" column="arrive_cnt" />
      <result property="goodsNo" column="goodsNo" />
      <result property="goodsName" column="goodsName" />
      <result property="payMethod" column="pay_method" />
      <result property="cateName" column="cateName" />
   </resultMap>
@@ -64,8 +66,7 @@
      d.level_name,
      c.vip_name,
      e.name as pro_name,
      (IFNULL(a.goods_cash,0)) as zk_total,
      a.goods_cash,
      b.ZK_TOTAL as zk_total,
      a.his_consume,
      a.free_consume,
      f.su_name meiliao,
@@ -74,9 +75,13 @@
      a.number_of_people,
      a.proj_num,
      a.proj_time,
      i.name as module_subName,
      h.SHOP_NAME shop_name,
      a.order_type
      i.name as cateName,
      h.shop_short_name shop_name,
      a.order_type,
      a.achieveType,
      case when a.pay_method = '现金' then goods_cash end goods_cash,
      case when a.pay_method = '划扣' then goods_cash end card_cash,
      j.pay_method
      from
      achieve_new a
      left join sys_order b on a.order_id=b.id
@@ -88,6 +93,7 @@
      LEFT JOIN sys_shop_info h ON a.SHOP_ID = h.ID
      LEFT JOIN shopping_goods_category i ON e.cate_id = i.id
      left join sys_proj_services l on a.service_order_id=l.id
      left join sys_order_item j on a.order_item_id=j.ID
      <where>
         <if test="record!=null">
            <if
@@ -283,7 +289,7 @@
      <result property="remark" column="remark" />
      <result property="orderType" column="order_type" />
      <result property="projPercentage" column="proj_percentage" />
      <result property="payMethod" column="pay_method" />
      <result property="t1" column="t1" />
      <result property="t2" column="t2" />
      <result property="achieveType" column="achieveType" />
@@ -326,7 +332,8 @@
      t6,
      t8,
      t9,
      company_id
      company_id,
pay_method
   </sql>
   <!-- 属性sql -->
@@ -360,7 +367,8 @@
      #{item.t6},
      #{item.t8},
      #{item.t9},
      #{item.companyId}
      #{item.companyId},
      #{item.payMethod}
   </sql>
   <!-- where sql -->
@@ -608,6 +616,9 @@
         <if test="_parameter.containsKey('t9')">
            t9 = #{t9},
         </if>
         <if test="_parameter.containsKey('payMethod')">
            pay_method = #{payMethod},
         </if>
      </set>
      WHERE id=#{id}
   </update>
@@ -720,6 +731,9 @@
         </if>
         <if test="record.t9 != null and record.t9 != '' ">
            t9 = #{record.t9},
         </if>
         <if test="record.payMethod != null and record.payMethod != '' ">
            pay_method = #{record.payMethod},
         </if>
      </set>
      WHERE id=#{record.id}
@@ -906,7 +920,16 @@
   <select id="selectUserAchieveByTime" resultType="com.matrix.system.app.vo.UserAchieveVo">
      select
         sale_id id,
         sum(goods_cash) orderCash,
         (select ifnull(sum(case pay_method when '现金' then goods_cash else 0 end),0)
            from achieve_new a
         where a.beault_id=#{userId}
         and (date_format(datatime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') >= date_format(datatime, '%Y-%m-%d'))
         ) orderCash,
         (select ifnull(sum(case pay_method when '划扣' then goods_cash else 0 end),0)
            from achieve_new a
         where  a.beault_id=#{userId}
         and (date_format(datatime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') >= date_format(datatime, '%Y-%m-%d'))
         ) cash,
         sum(case order_type when '订单' then proj_percentage else 0 end) cardUse,
         sum(IFNULL(his_consume, 0)) hisConsume,
         sum(IFNULL(free_consume, 0)) freeConsume,
@@ -954,6 +977,7 @@
      select
         b.su_name name,
         b.su_id id,
         b.su_photo photo,
         sum(IFNULL(a.free_consume,0) + IFNULL(a.his_consume, 0) ) amount,
         c.shop_short_name shopName
      from achieve_new a
@@ -987,8 +1011,7 @@
         b.code goodsNo,
         b.name goodsName,
         c.su_name meiliao,
         d.count*d.zk_price zk_total,
          d.pay_method
         d.count*d.zk_price zk_total
      from achieve_new a
      left join shopping_goods b on a.shopping_goods_id=b.id
      left join sys_users c on a.beault_id=c.su_id
@@ -1031,21 +1054,23 @@
      select
         b.shop_short_name name,
         b.SHOP_IMAG photo,
         sum(IFNULL(a.goods_cash,0)) amount
      from achieve_new a
      left join sys_shop_info b on a.shop_id=b.ID and shop_type!=1
         sum(IFNULL(a.amount,0)) amount
      from sys_order_flow a
      inner join sys_order c on a.order_id=c.id and c.STATU != '已取消'
      inner join sys_shop_info b on a.shop_id=b.id and shop_type!=1
      <where>
         a.pay_method not in ('储值卡', '欠款')
         <if test="record.companyId != null">
            and a.company_id=#{record.companyId}
         </if>
         <if test='record.t1 == "1" and record.datatime != null'>
            and date_format(datatime, '%Y-%m-%d') = date_format(#{record.datatime}, '%Y-%m-%d')
            and date_format(a.create_time, '%Y-%m-%d') = date_format(#{record.datatime}, '%Y-%m-%d')
         </if>
         <if test='record.t1 == "2" and record.datatime != null'>
            and date_format(datatime, '%Y-%m') = date_format(#{record.datatime}, '%Y-%m')
            and date_format(a.create_time, '%Y-%m') = date_format(#{record.datatime}, '%Y-%m')
         </if>
         <if test='record.t1 == "3" and record.datatime != null'>
            and date_format(datatime, '%Y') = date_format(#{record.datatime}, '%Y')
            and date_format(a.create_time, '%Y') = date_format(#{record.datatime}, '%Y')
         </if>
      </where>
      group by a.shop_id