From ec87cf1ee2b9382bf9d089711f0ff82ae8e7077c Mon Sep 17 00:00:00 2001 From: jyy <jyy> Date: Wed, 09 Jun 2021 20:44:16 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/api_score_meger' into api_score_meger --- zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml | 292 ++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 194 insertions(+), 98 deletions(-) diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml index fc99f96..651ca07 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml @@ -17,10 +17,8 @@ <result property="vipId" column="vip_id" /> <result property="freeConsume" column="free_consume" /> <result property="hisConsume" column="his_consume" /> - <result property="consume" column="consume" /> - <result property="cardCash" column="card_cash" /> - <result property="projCash" column="proj_cash" /> <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" /> @@ -28,10 +26,9 @@ <result property="remark" column="remark" /> <result property="orderType" column="order_type" /> <result property="projPercentage" column="proj_percentage" /> - <result property="achieveMoney" column="achieveMoney" /> <result property="t1" column="t1" /> <result property="t2" column="t2" /> - <result property="t3" column="t3" /> + <result property="achieveType" column="achieveType" /> <result property="t4" column="t4" /> <result property="t5" column="t5" /> <result property="t6" column="t6" /> @@ -48,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="zkPrice" column="zkPrice" /> + + <result property="cateName" column="cateName" /> </resultMap> @@ -68,25 +66,22 @@ d.level_name, c.vip_name, e.name as pro_name, - a.card_cash, - (IFNULL(a.card_cash,0) +IFNULL(a.proj_cash,0) + IFNULL(a.goods_cash,0) - ) as zk_total, - a.proj_cash, - a.goods_cash, - a.card_cash, - a.consume, + b.ZK_TOTAL as zk_total, a.his_consume, a.free_consume, - a.achieveMoney, f.su_name meiliao, g.su_name guwen, a.proj_percentage, 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 @@ -98,7 +93,9 @@ 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> + and a.company_id = #{record.companyId} <if test="record!=null"> <if test="(record.shopId!=null and record.shopId!='') or (record.shopId!='' and record.shopId==0) "> @@ -122,9 +119,7 @@ <if test="record.beaultId != null and record.beaultId !='' "> and a.beault_id = #{record.beaultId} </if> - <if test="record.companyId != null and record.companyId !='' "> - and a.company_id = #{record.companyId} - </if> + <if test="record.beaultId != null and record.beaultId !='' "> and a.beault_id = #{record.beaultId} </if> @@ -200,7 +195,41 @@ </where> </select> +<!-- + 统计员工业绩 + +select + u.name, + g.su_name guwen, + cast(SUM(b.ZK_TOTAL) AS decimal(15,2)) as zk_total, + cast(SUM(a.his_consume) AS decimal(15,2)), + cast(SUM(a.free_consume) AS decimal(15,2)), + cast(SUM(a.proj_percentage) AS decimal(15,2)), + cast(SUM(a.number_of_people) AS decimal(15,2)), + cast(SUM(a.proj_num) AS decimal(15,2)), + cast(SUM(a.proj_time) AS decimal(15,2)), + h.shop_short_name shop_name, + a.order_type, + a.achieveType + from + achieve_new a + left join sys_order b on a.order_id=b.id + left join sys_vip_info c on a.vip_id=c.id + left join sys_vip_level d on c.LEVEL_ID=d.id + left join shopping_goods e on a.shopping_goods_id=e.id + LEFT JOIN sys_users f on a.beault_id=f.su_id + LEFT JOIN sys_users g on a.sale_id = g.su_id + 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 + left join achieve_rule u on u.id=e.achieve_rule_id + where h.shop_short_name='龙华店' + GROUP BY g.su_name , a.order_type, h.id,a.achieveType + ORDER BY g.su_name + +--> <select id="findSumDailyInfoNew" resultMap="AchieveNewMap"> @@ -208,12 +237,8 @@ YEAR (a.datatime) year, MONTH (a.datatime) month, DAY(a.datatime) day, - SUM(a.card_cash) as card_cash , - SUM((IFNULL(a.card_cash,0) +IFNULL(a.proj_cash,0) + IFNULL(a.goods_cash,0) ) )as zk_total, - SUM(a.proj_cash) as proj_cash, + SUM( IFNULL(a.goods_cash,0) )as zk_total, SUM(a.goods_cash) as goods_cash, - SUM(a.card_cash) as card_cash, - SUM(a.consume) as consume, SUM(a.his_consume) as his_consume, SUM(a.free_consume) as free_consume, SUM(a.proj_percentage) as proj_percentage, @@ -289,9 +314,6 @@ <result property="vipId" column="vip_id" /> <result property="freeConsume" column="free_consume" /> <result property="hisConsume" column="his_consume" /> - <result property="consume" column="consume" /> - <result property="cardCash" column="card_cash" /> - <result property="projCash" column="proj_cash" /> <result property="goodsCash" column="goods_cash" /> <result property="projNum" column="proj_num" /> <result property="numberOfPeople" column="number_of_people" /> @@ -300,10 +322,10 @@ <result property="remark" column="remark" /> <result property="orderType" column="order_type" /> <result property="projPercentage" column="proj_percentage" /> - <result property="achieveMoney" column="achieveMoney" /> + <result property="payMethod" column="pay_method" /> <result property="t1" column="t1" /> <result property="t2" column="t2" /> - <result property="t3" column="t3" /> + <result property="achieveType" column="achieveType" /> <result property="t4" column="t4" /> <result property="t5" column="t5" /> <result property="t6" column="t6" /> @@ -326,9 +348,6 @@ vip_id, free_consume, his_consume, - consume, - card_cash, - proj_cash, goods_cash, proj_num, number_of_people, @@ -337,16 +356,17 @@ remark, order_type, proj_percentage, - achieveMoney, + t1, t2, - t3, + achieveType, t4, t5, t6, t8, t9, - company_id + company_id, +pay_method </sql> <!-- 属性sql --> @@ -363,9 +383,6 @@ #{item.vipId}, #{item.freeConsume}, #{item.hisConsume}, - #{item.consume}, - #{item.cardCash}, - #{item.projCash}, #{item.goodsCash}, #{item.projNum}, #{item.numberOfPeople}, @@ -374,16 +391,17 @@ #{item.remark}, #{item.orderType}, #{item.projPercentage}, - #{item.achieveMoney}, + #{item.t1}, #{item.t2}, - #{item.t3}, + #{item.achieveType}, #{item.t4}, #{item.t5}, #{item.t6}, #{item.t8}, #{item.t9}, - #{item.companyId} + #{item.companyId}, + #{item.payMethod} </sql> <!-- where sql --> @@ -441,18 +459,8 @@ test="(record.hisConsume!=null and record.hisConsume!='') or (record.hisConsume!='' and record.hisConsume==0) "> and his_consume = #{record.hisConsume} </if> - <if - test="(record.consume!=null and record.consume!='') or (record.consume!='' and record.consume==0) "> - and consume = #{record.consume} - </if> - <if - test="(record.cardCash!=null and record.cardCash!='') or (record.cardCash!='' and record.cardCash==0) "> - and card_cash = #{record.cardCash} - </if> - <if - test="(record.projCash!=null and record.projCash!='') or (record.projCash!='' and record.projCash==0) "> - and proj_cash = #{record.projCash} - </if> + + <if test="(record.goodsCash!=null and record.goodsCash!='') or (record.goodsCash!='' and record.goodsCash==0) "> and goods_cash = #{record.goodsCash} @@ -494,8 +502,8 @@ and t2 = #{record.t2} </if> <if - test="(record.t3!=null and record.t3!='') or (record.t3!='' and record.t3==0) "> - and t3 = #{record.t3} + test="(record.achieveType!=null and record.achieveType!='') or (record.achieveType!='' and record.achieveType==0) "> + and achieveType = #{record.achieveType} </if> <if test="(record.t4!=null and record.t4!='') or (record.t4!='' and record.t4==0) "> @@ -589,15 +597,9 @@ <if test="_parameter.containsKey('hisConsume')"> his_consume = #{hisConsume}, </if> - <if test="_parameter.containsKey('consume')"> - consume = #{consume}, - </if> - <if test="_parameter.containsKey('cardCash')"> - card_cash = #{cardCash}, - </if> - <if test="_parameter.containsKey('projCash')"> - proj_cash = #{projCash}, - </if> + + + <if test="_parameter.containsKey('goodsCash')"> goods_cash = #{goodsCash}, </if> @@ -622,17 +624,15 @@ <if test="_parameter.containsKey('projPercentage')"> proj_percentage = #{projPercentage}, </if> - <if test="_parameter.containsKey('achieveMoney')"> - achieveMoney = #{achieveMoney}, - </if> + <if test="_parameter.containsKey('t1')"> t1 = #{t1}, </if> <if test="_parameter.containsKey('t2')"> t2 = #{t2}, </if> - <if test="_parameter.containsKey('t3')"> - t3 = #{t3}, + <if test="_parameter.containsKey('achieveType')"> + achieveType = #{achieveType}, </if> <if test="_parameter.containsKey('t4')"> t4 = #{t4}, @@ -648,6 +648,9 @@ </if> <if test="_parameter.containsKey('t9')"> t9 = #{t9}, + </if> + <if test="_parameter.containsKey('payMethod')"> + pay_method = #{payMethod}, </if> </set> WHERE id=#{id} @@ -711,15 +714,8 @@ <if test="record.hisConsume != null "> his_consume = #{record.hisConsume}, </if> - <if test="record.consume != null "> - consume = #{record.consume}, - </if> - <if test="record.cardCash != null "> - card_cash = #{record.cardCash}, - </if> - <if test="record.projCash != null "> - proj_cash = #{record.projCash}, - </if> + + <if test="record.goodsCash != null "> goods_cash = #{record.goodsCash}, </if> @@ -744,17 +740,15 @@ <if test="record.projPercentage != null "> proj_percentage = #{record.projPercentage}, </if> - <if test="record.achieveMoney != null "> - achieveMoney = #{record.achieveMoney}, - </if> + <if test="record.t1 != null and record.t1 != '' "> t1 = #{record.t1}, </if> <if test="record.t2 != null and record.t2 != '' "> t2 = #{record.t2}, </if> - <if test="record.t3 != null and record.t3 != '' "> - t3 = #{record.t3}, + <if test="record.achieveType != null and record.achieveType != '' "> + achieveType = #{record.achieveType}, </if> <if test="record.t4 != null and record.t4 != '' "> t4 = #{record.t4}, @@ -770,6 +764,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} @@ -795,6 +792,11 @@ DELETE FROM achieve_new where 1=1 <include refid="where_sql"></include> + </delete> + + + <delete id="deleteByOrderId"> + DELETE FROM achieve_new where order_id=#{orderId} </delete> @@ -868,7 +870,7 @@ sum(b.hisConsume) his_consume from sys_vip_info a inner join ( - select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id + select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) )) buyConsume from achieve_new a group by vip_id ) b on a.ID = b.vip_id inner join ( select vip_id, count(1) cnt from ( @@ -915,7 +917,7 @@ select count(1) from sys_vip_info a inner join ( - select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) + IFNULL(card_cash, 0)) buyConsume from achieve_new a group by vip_id + select vip_id,datatime, sum(a.free_consume) freeConsume, sum(a.his_consume) hisConsume, sum(IFNULL(goods_cash, 0) ) buyConsume from achieve_new a group by vip_id ) b on a.ID = b.vip_id inner join ( select vip_id, count(1) cnt from ( @@ -951,8 +953,16 @@ <select id="selectUserAchieveByTime" resultType="com.matrix.system.app.vo.UserAchieveVo"> select sale_id id, - sum(case t3 when '现金业绩' then card_cash else 0 end) orderCash, - sum(case t3 when '划扣业绩' then consume else 0 end) cash, + (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, @@ -965,7 +975,7 @@ <select id="selectApiOrderItemAchieve" resultType="com.matrix.system.app.vo.OrderDetailAchieveItemVo"> select b.su_name name, - IFNULL(a.card_cash, 0) + IFNULL(a.proj_cash, 0) + IFNULL(a.goods_cash, 0) achieve + IFNULL(a.goods_cash, 0) achieve from achieve_new a inner join sys_users b on (a.beault_id=b.su_id or a.sale_id = b.su_id) where a.order_item_id=#{itemId} and order_type = '订单' @@ -1000,7 +1010,8 @@ select b.su_name name, b.su_id id, - sum(IFNULL(a.free_consume,0) + IFNULL(a.his_consume, 0) + IFNULL(a.consume, 0)) amount, + 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 inner join sys_users b on a.beault_id=b.su_id @@ -1046,7 +1057,7 @@ b.su_name name, b.su_id id, b.su_photo photo, - sum(ifnull(card_cash,0)) amount, + sum(ifnull(goods_cash,0)) amount, c.shop_short_name shopName from achieve_new a inner join sys_users b on a.beault_id=b.su_id @@ -1076,24 +1087,109 @@ select b.shop_short_name name, b.SHOP_IMAG photo, - sum(IFNULL(a.consume,0) + IFNULL(a.card_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 order by amount desc, a.shop_id </select> + + <!-- 顾问当天下单列表 --> + <select id="selectSaleManAchieveList" resultMap="AchieveNewMap"> + select * from achieve_new + where sale_id=#{saleId} and vip_id=#{vipId} and sale_id=beault_id + and date_format(datatime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') + </select> + + <select id="selectBeautyManAchieveList" resultMap="AchieveNewMap"> + select * from achieve_new + where beault_id=#{beautyId} and vip_id=#{vipId} + and date_format(datatime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') + </select> + + <select id="achieveNewStatistics" resultType="com.matrix.system.hive.vo.AchieveNewStatisticsVo"> + + select + u.name ruleName, + f.su_name guwen, + f.su_id gwid, + g.su_name createBy, + g.su_id createId, + cast(SUM(b.ZK_TOTAL) AS decimal(15,2)) as zk_total, + cast(SUM(a.his_consume) AS decimal(15,2)) his_consume, + cast(SUM(a.free_consume) AS decimal(15,2)) free_consume, + cast(SUM(a.proj_percentage) AS decimal(15,2)) proj_percentage, + cast(SUM(a.number_of_people) AS decimal(15,2)) number_of_people, + cast(SUM(a.proj_num) AS decimal(15,2)) proj_num, + cast(SUM(case when a.pay_method = '划扣' then goods_cash end )AS decimal(15,2)) card_cash, + cast(SUM(a.proj_time) AS decimal(15,2)) proj_time, + cast(SUM(case when a.pay_method = '现金' then goods_cash end )AS decimal(15,2)) goods_cash, + h.shop_short_name shop_name, + a.order_type + from + achieve_new a + left join sys_order b on a.order_id=b.id + left join sys_vip_info c on a.vip_id=c.id + left join sys_vip_level d on c.LEVEL_ID=d.id + left join shopping_goods e on a.shopping_goods_id=e.id + LEFT JOIN sys_users f on a.beault_id=f.su_id + LEFT JOIN sys_users g on a.sale_id = g.su_id + 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 + left join achieve_rule u on u.id=e.achieve_rule_id + <where> + and a.company_id = #{record.companyId} + <if test="record.shopId != null"> + and a.shop_id = #{record.shopId} + </if> + <if test="record.achieveRuleId != null"> + and u.id = #{record.achieveRuleId} + </if> + + <if test="record.staffName != null and record.staffName!=''"> + <!-- 创建人和归属人都有业绩 --> + and (f.su_name like concat('%',#{record.staffName},'%') or g.su_name like concat('%',#{record.staffName},'%') ) + </if> + + <if test="record.orderType != null and record.orderType != '' "> + and a.order_type= #{record.orderType} + </if> + <if test="record.beginTime != null "> + and a.datatime >= #{record.beginTime} + </if> + <if test="record.endTime != null "> + <![CDATA[and a.datatime <= #{record.endTime}]]> + </if> + + </where> + GROUP BY g.su_id , f.su_id, a.order_type, h.id,a.achieveType,u.name + <if test="record.sort !=null and record.sort!=''"> order by ${record.sort} ${record.order}</if> + + </select> + + + <update id="updateAchieveNumOfPeople"> + <foreach collection="list" item="item" index="index" + separator=";"> + update achieve_new set number_of_people=#{num} where id=#{item.id} + </foreach> + </update> </mapper> \ No newline at end of file -- Gitblit v1.9.1