From a0cd34acf14a149cc3c08b41ca4dde6938a29ecc Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Wed, 07 Jul 2021 22:31:34 +0800
Subject: [PATCH] modify
---
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml | 307 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 224 insertions(+), 83 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 9eb3473..1e20546 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
@@ -18,8 +18,6 @@
<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" />
@@ -30,7 +28,7 @@
<result property="projPercentage" column="proj_percentage" />
<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" />
@@ -50,7 +48,10 @@
<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>
@@ -65,13 +66,8 @@
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,
+ b.ZK_TOTAL as zk_total,
a.goods_cash,
- a.card_cash,
- a.consume,
a.his_consume,
a.free_consume,
f.su_name meiliao,
@@ -80,9 +76,11 @@
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,
+ j.pay_method
from
achieve_new a
left join sys_order b on a.order_id=b.id
@@ -94,6 +92,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
@@ -204,12 +203,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,
@@ -285,9 +280,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" />
@@ -296,9 +288,10 @@
<result property="remark" column="remark" />
<result property="orderType" column="order_type" />
<result property="projPercentage" column="proj_percentage" />
+
<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" />
@@ -321,9 +314,6 @@
vip_id,
free_consume,
his_consume,
- consume,
- card_cash,
- proj_cash,
goods_cash,
proj_num,
number_of_people,
@@ -332,9 +322,10 @@
remark,
order_type,
proj_percentage,
+
t1,
t2,
- t3,
+ achieveType,
t4,
t5,
t6,
@@ -357,9 +348,6 @@
#{item.vipId},
#{item.freeConsume},
#{item.hisConsume},
- #{item.consume},
- #{item.cardCash},
- #{item.projCash},
#{item.goodsCash},
#{item.projNum},
#{item.numberOfPeople},
@@ -368,9 +356,10 @@
#{item.remark},
#{item.orderType},
#{item.projPercentage},
+
#{item.t1},
#{item.t2},
- #{item.t3},
+ #{item.achieveType},
#{item.t4},
#{item.t5},
#{item.t6},
@@ -434,18 +423,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}
@@ -487,8 +466,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) ">
@@ -582,15 +561,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>
@@ -615,14 +588,15 @@
<if test="_parameter.containsKey('projPercentage')">
proj_percentage = #{projPercentage},
</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},
@@ -701,15 +675,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>
@@ -734,14 +701,15 @@
<if test="record.projPercentage != null ">
proj_percentage = #{record.projPercentage},
</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},
@@ -757,6 +725,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}
@@ -782,6 +753,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>
@@ -855,7 +831,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 (
@@ -873,12 +849,17 @@
<if test="record.shopId != null">
and a.shop_id=#{record.shopId}
</if>
- <if test="record.beginTime != null and record.endTime!=null">
- and date_format(b.datatime, '%Y-%m-%d') between #{record.beginTime} and #{record.endTime}
+ <if test="record.beginTime != null">
+ and date_format(b.datatime, '%Y-%m-%d') >= date_format(#{record.beginTime}, '%Y-%m-%d')
</if>
-
+ <if test="record.endTime!=null">
+ and date_format(b.datatime, '%Y-%m-%d') >= date_format(#{record.endTime}, '%Y-%m-%d')
+ </if>
<if test="record.beaultId != null and record.beaultId!=''">
and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID)
+ </if>
+ <if test='record.t1 == "on"'>
+ and a.BEATUY_ID is not null
</if>
group by a.PHONE
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
@@ -897,7 +878,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 (
@@ -915,26 +896,186 @@
<if test="record.shopId != null">
and a.shop_id=#{record.shopId}
</if>
- <if test="record.beginTime != null and record.endTime!=null">
- and date_format(b.datatime, '%Y-%m-%d') between #{record.beginTime} and #{record.endTime}
+ <if test="record.beginTime != null">
+ and date_format(b.datatime, '%Y-%m-%d') >= date_format(#{record.beginTime}, '%Y-%m-%d')
</if>
-
+ <if test="record.endTime!=null">
+ and date_format(b.datatime, '%Y-%m-%d') >= date_format(#{record.endTime}, '%Y-%m-%d')
+ </if>
<if test="record.beaultId != null and record.beaultId!=''">
and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID)
+ </if>
+ <if test='record.t1 == "on"'>
+ and a.BEATUY_ID is not null
</if>
</select>
<select id="selectUserAchieveByTime" resultType="com.matrix.system.app.vo.UserAchieveVo">
select
- sum(IFNULL(proj_cash,0) + IFNULL(goods_cash,0) + IFNULL(card_cash,0)) allCash,
- sum(card_cash) card,
- sum(proj_cash) project,
- sum(goods_cash) product,
- sum(consume) cardUse,
- sum(proj_percentage) projCommission
- from achieve_new
- where sale_id=#{userId}
- and (date_format(datatime, "%Y-%m-%d") >= #{startTime} or #{endTime} >= date_format(datatime, "%Y-%m-%d"))
+ sale_id id,
+ (select ifnull(sum(case b.pay_method when '现金' then goods_cash else 0 end),0)
+ from achieve_new a
+ inner join sys_order_item b on a.order_item_id=b.ID
+ 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 b.pay_method when '划扣' then goods_cash else 0 end),0)
+ from achieve_new a
+ inner join sys_order_item b on a.order_item_id=b.ID
+ 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,
+ sum(case order_type when '服务单' then proj_percentage else 0 end) projCommission
+ 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'))
+ </select>
+
+ <select id="selectApiOrderItemAchieve" resultType="com.matrix.system.app.vo.OrderDetailAchieveItemVo">
+ select
+ b.su_name name,
+ 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 = '订单'
+ </select>
+
+ <select id="selectShopConsumeAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo">
+ select
+ b.shop_short_name name,
+ b.SHOP_IMAG photo,
+ sum(IFNULL(a.free_consume,0) + IFNULL(a.his_consume,0)) amount
+ from achieve_new a
+ left join sys_shop_info b on a.shop_id=b.ID and b.shop_type!=1
+ <where>
+ <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')
+ </if>
+ <if test='record.t1 == "2" and record.datatime != null'>
+ and date_format(datatime, '%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')
+ </if>
+ </where>
+ group by a.shop_id
+ order by amount desc, a.shop_id
+ </select>
+
+ <select id="selectBeauticianConsumeAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo">
+ select
+ b.su_name name,
+ b.su_id id,
+ 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
+ left join sys_shop_info c on a.shop_id=c.ID
+ <where>
+ a.order_type='服务单'
+ <if test="record.companyId != null">
+ and a.company_id=#{record.companyId}
+ </if>
+ <if test="record.shopId != null">
+ and a.shop_id=#{record.shopId}
+ </if>
+ <if test='record.t1 == "1" and record.datatime != null'>
+ and date_format(datatime, '%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')
+ </if>
+ <if test='record.t1 == "3" and record.datatime != null'>
+ and date_format(datatime, '%Y') = date_format(#{record.datatime}, '%Y')
+ </if>
+ </where>
+ group by a.beault_id
+ order by amount desc
+ </select>
+
+ <select id="selectOrderItemAchieveByOrderId" resultMap="AchieveNewMap">
+ select
+ a.*,
+ b.code goodsNo,
+ b.name goodsName,
+ c.su_name meiliao,
+ d.count*d.zk_price zk_total,
+ d.pay_method
+ 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
+ left join sys_order_item d on a.order_item_id=d.id
+ where a.order_id=#{orderId}
+ </select>
+
+ <select id="selectStaffSaleAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo">
+ select
+ b.su_name name,
+ b.su_id id,
+ b.su_photo photo,
+ 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
+ inner join sys_shop_info c on a.SHOP_ID=c.ID
+ <where>
+ <if test="record.companyId != null">
+ and b.company_id=#{record.companyId}
+ </if>
+ <if test="record.shopId != null">
+ and b.shop_id=#{record.shopId}
+ </if>
+ <if test='record.type == "1" and record.datatime != null'>
+ and date_format(datatime, '%Y-%m-%d') = date_format(#{record.datatime}, '%Y-%m-%d')
+ </if>
+ <if test='record.type == "2" and record.datatime != null'>
+ and date_format(datatime, '%Y-%m') = date_format(#{record.datatime}, '%Y-%m')
+ </if>
+ <if test='record.type == "3" and record.datatime != null'>
+ and date_format(datatime, '%Y') = date_format(#{record.datatime}, '%Y')
+ </if>
+ </where>
+ group by b.su_id
+ order by amount desc, b.su_id
+ </select>
+
+ <select id="selectShopSaleAchieveRanking" resultType="com.matrix.system.app.vo.RankingVo">
+ 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
+ <where>
+ <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')
+ </if>
+ <if test='record.t1 == "2" and record.datatime != null'>
+ and date_format(datatime, '%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')
+ </if>
+ </where>
+ group by a.shop_id
+ order by amount desc, a.shop_id
+ </select>
+
+ <select id="selectAchieveByServiceOrderId" resultMap="AchieveNewMap">
+ select * from achieve_new where service_order_id=#{serviceOrderId}
+ </select>
+
+ <select id="selectAchieveForOrder" resultMap="AchieveNewMap">
+ select * from achieve_new where order_type='订单'
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.1