From 26ac9c5538b49a395264efb65fb746663536beb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E7=A3=8A?= <45566618@qq.com> Date: Thu, 11 Jul 2024 14:14:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E5=B8=88=E6=95=B0=E6=8D=AE=E7=BB=9F?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/app/dao/UserMoneyDetailsDao.java | 2 + .../app/service/UserMoneyDetailsService.java | 2 + .../impl/UserMoneyDetailsServiceImpl.java | 5 ++ .../sqx/modules/artificer/dao/OrdersDao.java | 2 +- .../service/impl/OrdersServiceImpl.java | 14 ++-- .../mapper/app/UserMoneyDetailsDao.xml | 16 +++++ .../resources/mapper/artificer/OrdersDao.xml | 71 +++++++++++++++---- 7 files changed, 92 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java b/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java index 6c9056e..ce2e45f 100644 --- a/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java +++ b/src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java @@ -22,4 +22,6 @@ public interface UserMoneyDetailsDao extends BaseMapper { IPage findUserMontyDetailPage(Page page, @Param("userId") Long userId); List selectArtificerQianbao(Long userId, String startTime, String endTime); + + BigDecimal selectArtificerMoney(Long userId,String startTime,String endTime); } diff --git a/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java b/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java index 7bbe1b7..68f4ae0 100644 --- a/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java +++ b/src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java @@ -26,4 +26,6 @@ public interface UserMoneyDetailsService extends IService { int insert(UserMoneyDetails userMoneyDetails); Result selectArtificerQianbao(Long artificerId, String startTime, String endTime,Integer page, Integer limit); + + BigDecimal selectArtificerMoney(Long userId, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java index d2f374a..97d41f0 100644 --- a/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java +++ b/src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java @@ -20,6 +20,7 @@ import com.sqx.modules.artificer.service.ArtificerService; import com.sqx.modules.artificer.service.ArtificerTimeService; import com.sqx.modules.common.service.CommonInfoService; import jodd.util.StringUtil; +import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -400,4 +401,8 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl { BigDecimal selectOrdersMoney(String time, Integer type,Integer status); - BigDecimal selectSumMoney(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime); + BigDecimal selectSumOrdersMoney(Long userId,@Param("startTime") String startTime,@Param("endTime") String endTime); BigDecimal selectSumMoneyMonth(Long userId,@Param("time") String time); diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java index 83e3edf..017a586 100644 --- a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java @@ -1465,7 +1465,12 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setOldMassageDuration(oldOrders.getDuration()); orders.setOldArtificerMoney(oldOrders.getArtificerMoney()); orders.setArtificerTaxiMoney(oldOrders.getArtificerTaxiMoney()); - orders.setOldProjectBenefits(oldOrders.getProjectBenefits()); + if(oldOrders.getIsSupplement().equals(1)){ + BigDecimal projectBenefits = oldOrders.getProjectBenefits().add(oldOrders.getOldProjectBenefits()); + orders.setOldProjectBenefits(projectBenefits); + }else{ + orders.setOldProjectBenefits(oldOrders.getProjectBenefits()); + } //获取用户VIP的优惠信息 BigDecimal vipRate = new BigDecimal(100); @@ -6127,15 +6132,16 @@ public class OrdersServiceImpl extends ServiceImpl implements Artificer artificer = artificerService.getById(artificerId); Map result = new HashMap(); //总收益 - BigDecimal sumMoney = ordersDao.selectSumMoney(artificerId, startTime, endTime); + BigDecimal sumMoney = userMoneyDetailsService.selectArtificerMoney(artificer.getUserId(), startTime, endTime); //总销量 有关这个技师的订单销售数量的累计 int countOrderNum = ordersDao.selectCountOrderNum(artificerId, startTime, endTime); //评价分数 Double countTakingByUserId = orderTakingCommentDao.selectCountTakingByUserId(artificerId, startTime, endTime); //订单收入 - BigDecimal orderMoney = sumMoney; + BigDecimal orderMoney = ordersDao.selectSumOrdersMoney(artificerId, startTime, endTime); //总订单数 - int countOrder = ordersDao.selectCountOrder(artificerId, null, startTime, endTime); + String countOrderStr = ordersDao.selectOrdersArtificerIntegral(artificerId, endTime, startTime ); + Integer countOrder = Integer.valueOf(countOrderStr); //退款金额 BigDecimal sumRefund = userMoneyDetailsService.selectSumRefund(artificer.getUserId(), startTime, endTime); //访客人数 diff --git a/src/main/resources/mapper/app/UserMoneyDetailsDao.xml b/src/main/resources/mapper/app/UserMoneyDetailsDao.xml index f512eb3..3df5716 100644 --- a/src/main/resources/mapper/app/UserMoneyDetailsDao.xml +++ b/src/main/resources/mapper/app/UserMoneyDetailsDao.xml @@ -136,4 +136,20 @@ GROUP BY type + + + \ No newline at end of file diff --git a/src/main/resources/mapper/artificer/OrdersDao.xml b/src/main/resources/mapper/artificer/OrdersDao.xml index fef66c4..517766f 100644 --- a/src/main/resources/mapper/artificer/OrdersDao.xml +++ b/src/main/resources/mapper/artificer/OrdersDao.xml @@ -569,14 +569,50 @@ - + select IFNULL(SUM(artificer_money_total),0) AS currentEarnings + from ( + select (case when o.status = 4 + then o.artificer_money + ifnull(o.add_artificer_money,0) + else o.artificer_money + ifnull(o.add_artificer_money,0) + ifnull(o2.artificer_money,0) + ifnull(o2.add_artificer_money,0) + ifnull(o3.artificer_money,0) + ifnull(o3.add_artificer_money,0) + end) as artificer_money_total + from orders o + left join orders o2 on o.old_orders_id = o2.orders_id and o2.status != 4 + left join orders o3 on o2.old_orders_id = o3.orders_id and o3.status != 4 + where o.artificer_id = #{userId} + and o.old_orders_id is not null + and o.status not in (4,11,15) + + and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d') + + + and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d') + + and o.status in (3,5) + union all + select o.artificer_money + ifnull(o.add_artificer_money,0) as artificer_money_total + from orders o + where o.artificer_id = #{userId} + and o.parent_id = 0 + and o.orders_id not in ( + select orders_id from orders + where old_orders_id is not null + and status != 4 + ) + and o.orders_id not in ( + select old_orders_id from orders + where old_orders_id is not null + and status != 4 + ) + + and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d') + + + and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d') + + and o.status in (3,5) + ) t select ifnull(sum(massage_num), 0) as num from orders where artificer_id = #{userId} and status in (2,3,5,6,7,8,9,10) - and date_format(pay_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d') + and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d') - and date_format(pay_time,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d') + and date_format(end_times,'%Y-%m-%d') <= date_format(#{endTime},'%Y-%m-%d') @@ -1217,10 +1253,10 @@ and o.old_orders_id is not null and o.status not in (4,11,15) - and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate} + and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startDate},'%Y-%m-%d') - and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate} + and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endDate},'%Y-%m-%d') and o.status in (3,5) union all @@ -1239,14 +1275,13 @@ and status != 4 ) - and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') >= #{startDate} + and date_format(o.end_times,'%Y-%m-%d') >= date_format(#{startDate},'%Y-%m-%d') - and date_format(o.end_times,'%Y-%m-%d %H:%i:%s') <= #{endDate} + and date_format(o.end_times,'%Y-%m-%d') <= date_format(#{endDate},'%Y-%m-%d') and o.status in (3,5) ) t -