From 85dce973eb29eb2372c76d5b95b30354da9c41c8 Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Tue, 22 Feb 2022 23:08:51 +0800
Subject: [PATCH] fead:新增收银员字段

---
 zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanOrderDao.xml |  121 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 110 insertions(+), 11 deletions(-)

diff --git a/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanOrderDao.xml b/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanOrderDao.xml
index be189d8..84c0ede 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanOrderDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanOrderDao.xml
@@ -50,7 +50,7 @@
 			c.order_no,
 			c.order_money
 		from shop_salesman_order a
-				 left join biz_user b on b.open_id=a.user_id
+				 left join sys_vip_info b on b.id=a.user_id
 				 left join shop_order c on a.order_id=c.id
 		where
 			a.sales_user_id=#{record.userId}
@@ -76,7 +76,10 @@
 						WHERE order_status = 1 and company_id=#{companyId} ) a) waitNum,
 			(SELECT COUNT(*)
 				FROM shop_salesman_order
-				WHERE order_status = 1 and company_id=#{companyId}) waitOrderNum
+				WHERE order_status = 1 and company_id=#{companyId}) waitOrderNum,
+		    (select sum(order_money) from shop_salesman_order a
+				inner join shop_order b on a.order_id=b.ID
+			 where a.company_id=#{companyId}) orderBalance
 		FROM
 			shop_salesman_order
 		where company_id=#{companyId}
@@ -85,25 +88,52 @@
 	<select id="findFenxiaoOrderList" resultType="com.matrix.system.fenxiao.vo.LoadFenxiaoOrderListVo">
 		SELECT
 		a.id id,
-		(select order_no from shop_order where id = a.order_id) orderNo,
-		(select order_money from shop_order where id = a.order_id) actualBalance,
-		(select store_name  from shop_store where store_id = (select store_id from shop_order where id = a.order_id)) address,
+		d.order_no,
+		d.order_money actualBalance,
+		f.shop_name address,
+		d.order_status orderState,
 		b.nick_name custom,
-		(select nick_name from biz_user where open_id = b.parent_open_id) parentSale,
+		b.id customUserId,
+		e.nick_name parentSale,
 		a.revenue_type profitType,
 		a.amount profitBalance,
 		a.order_status settleType,
 		c.order_no settleNo,
 		c.create_time settleTime,
-		(select nick_name from biz_user where c.user_id = open_id) settler
+		g.su_name settler
 		FROM
 		shop_salesman_order a
-		LEFT JOIN biz_user b on a.user_id = b.open_id
+		LEFT JOIN sys_vip_info b on a.user_id = b.id
 		LEFT JOIN shop_saleman_settlement c on a.settlement_id = c.id
+		LEFT JOIN shop_order d on d.id = a.order_id
+		LEFT JOIN sys_vip_info e on a.sales_user_id = e.id
+		LEFT JOIN sys_shop_info f on f.id = d.store_id
+		LEFT JOIN sys_users g on c.user_id = g.su_id
 		<where>
 			a.company_id = #{record.companyId}
 			<if test="record.userName != null and record.userName != ''">
 				and b.nick_name like concat('%',#{record.userName},'%')
+			</if>
+			<if test="record.ddType != null and record.ddType != ''">
+				and d.order_status = #{record.ddType}
+			</if>
+			<if test="record.startTime != null ">
+				and a.create_time >= #{record.startTime}
+			</if>
+			<if test="record.endTime != null">
+				and  #{record.endTime} >= a.create_time
+			</if>
+			<if test="record.tgy != null and record.tgy != ''">
+				and e.nick_name like concat('%',#{record.tgy},'%')
+			</if>
+			<if test="record.orderType != null and record.orderType != ''">
+				and a.order_status = #{record.orderType}
+			</if>
+			<if test="record.jsbh != null and record.jsbh != ''">
+				and c.order_no = #{record.jsbh}
+			</if>
+			<if test="record.ddh != null and record.ddh != ''">
+				and d.order_no = #{record.ddh}
 			</if>
 		</where>
 		<if test="record.sort !=null">
@@ -120,16 +150,22 @@
 		a.order_count setNum,
 		a.man_count setManNum,
 		a.create_time setTime,
-		b.nick_name setMan,
+		b.su_name setMan,
 		a.settlement_way settlementWay,
 		a.remark remark
 		from
 		shop_saleman_settlement a
-		left join biz_user b on a.user_id = b.open_id
+		left join sys_users b on a.user_id = b.su_id
 		<where>
 			a.company_id = #{record.companyId}
 			<if test="record.userName != null and record.userName != ''">
-				and b.nick_name like concat('%',#{record.userName},'%')
+				and b.su_name like concat('%',#{record.userName},'%')
+			</if>
+			<if test="record.startTime != null ">
+				and a.create_time >= #{record.startTime}
+			</if>
+			<if test="record.endTime != null">
+				and  #{record.endTime} >= a.create_time
 			</if>
 		</where>
 		<if test="record.sort !=null">
@@ -138,4 +174,67 @@
 		</if>
 	</select>
 
+	<select id="selectFenxiaoOrderListNoPage" resultType="com.matrix.system.fenxiao.vo.FenxiaoOrderListExportVo">
+		SELECT
+		a.id id,
+		d.order_no,
+		d.order_money actualBalance,
+		f.shop_name address,
+		case when d.order_status = 1 then '待付款'
+			when d.order_status = 2 then '待配送'
+			when d.order_status = 3 then '待收货'
+			when d.order_status = 4 then '待评价'
+			when d.order_status = 5 then '已评价'
+			when d.order_status = 6 then '申请退款'
+			when d.order_status = 7 then '退款成功'
+			when d.order_status = 8 then '退款拒绝'
+			when d.order_status = 9 then '已取消' end  orderState,
+		b.nick_name custom,
+		b.id customUserId,
+		e.nick_name parentSale,
+		case when a.revenue_type = 1 then '推广收益'
+		     when a.revenue_type = 2 then '邀请收益' end profitType,
+		a.amount profitBalance,
+		case when a.order_status = 1 then '待结算'
+			when a.order_status = 2 then '已结算'
+			when a.order_status = 3 then '已退款' end settleType,
+		c.order_no settleNo,
+		c.create_time settleTime,
+		g.su_name settler
+		FROM
+		shop_salesman_order a
+		LEFT JOIN sys_vip_info b on a.user_id = b.id
+		LEFT JOIN shop_saleman_settlement c on a.settlement_id = c.id
+		LEFT JOIN shop_order d on d.id = a.order_id
+		LEFT JOIN sys_vip_info e on a.sales_user_id = e.id
+		LEFT JOIN sys_shop_info f on f.id = d.store_id
+		LEFT JOIN sys_users g on c.user_id = g.su_id
+		<where>
+			a.company_id = #{record.companyId}
+			<if test="record.userName != null and record.userName != ''">
+				and b.nick_name like concat('%',#{record.userName},'%')
+			</if>
+			<if test="record.ddType != null and record.ddType != ''">
+				and d.order_status = #{record.ddType}
+			</if>
+			<if test="record.startTime != null ">
+				and a.create_time >= #{record.startTime}
+			</if>
+			<if test="record.endTime != null">
+				and  #{record.endTime} >= a.create_time
+			</if>
+			<if test="record.tgy != null and record.tgy != ''">
+				and e.nick_name like concat('%',#{record.tgy},'%')
+			</if>
+			<if test="record.orderType != null and record.orderType != ''">
+				and a.order_status = #{record.orderType}
+			</if>
+			<if test="record.jsbh != null and record.jsbh != ''">
+				and c.order_no = #{record.jsbh}
+			</if>
+			<if test="record.ddh != null and record.ddh != ''">
+				and d.order_no = #{record.ddh}
+			</if>
+		</where>
+	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1