From 150954c6bb3d3215cd0611636df23fc40ec73d4b 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 17:19:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E5=B8=88=E6=95=B0=E6=8D=AE=E5=88=86?= =?UTF-8?q?=E6=88=90=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sqx/modules/artificer/dao/OrdersDao.java | 4 +- .../impl/AppArtificerIntegralServiceImpl.java | 25 +++++--- .../service/impl/ArtificerServiceImpl.java | 8 ++- .../service/impl/OrdersServiceImpl.java | 61 +++++++++++-------- .../task/service/impl/AllTaskServiceImpl.java | 3 +- .../resources/mapper/artificer/OrdersDao.xml | 25 +++++++- .../mapper/taking/OrderTakingCommentDao.xml | 4 +- 7 files changed, 85 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java b/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java index 2e15b93..91ae4bd 100644 --- a/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java +++ b/src/main/java/com/sqx/modules/artificer/dao/OrdersDao.java @@ -98,7 +98,7 @@ public interface OrdersDao extends BaseMapper { Integer selectOrdersArtificerIntegralAchievement(Long artificerId, String endDate, String startDate); - Integer selectOrdersArtificerIntegralEarnings(Long artificerId, String endDate, String startDate); + BigDecimal selectOrdersArtificerIntegralEarnings(Long artificerId, String endDate, String startDate); String selectOrdersArtificerIntegral(Long artificerId, String endDate, String startDate); @@ -142,4 +142,6 @@ public interface OrdersDao extends BaseMapper { List getParentOrders(Long parentId); + BigDecimal selectSumRefund(Long artificerId, @Param("startTime") String startTime, @Param("endTime") String endTime); + } \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java index 6e46c60..dc73e7c 100644 --- a/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificer/service/impl/AppArtificerIntegralServiceImpl.java @@ -72,22 +72,25 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ //当期收益 // String earnings = ordersDao.earnings(artificerId, endDate, startDate); - String earnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate).toString(); - orders.setEarnings(earnings); + BigDecimal earnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate); + earnings = earnings.setScale(0,BigDecimal.ROUND_DOWN); + orders.setEarnings(earnings.toString()); //当日收益 String todayEndIncome = DateUtil.formatDateTime(DateUtil.endOfDay(new Date())); // String dailyEarnings = ordersDao.earnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date()))); - String dailyEarnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date()))).toString(); - orders.setDailyEarnings(dailyEarnings); + BigDecimal dailyEarnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date()))); + dailyEarnings = dailyEarnings.setScale(0,BigDecimal.ROUND_DOWN); + orders.setDailyEarnings(dailyEarnings.toString()); //当月收益 //当月结束日 String startFundDataformat = DateUtil.formatDateTime(DateUtil.beginOfMonth(new Date())); String endFundDataformat = DateUtil.formatDateTime(DateUtil.endOfMonth(new Date())); // String currentMonthsIncome = ordersDao.earnings(artificerId, endFundDataformat, startFundDataformat); - String currentMonthsIncome = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endFundDataformat, startFundDataformat).toString(); - orders.setCurrentMonthsIncome(currentMonthsIncome); + BigDecimal currentMonthsIncome = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endFundDataformat, startFundDataformat); + currentMonthsIncome = currentMonthsIncome.setScale(0,BigDecimal.ROUND_DOWN); + orders.setCurrentMonthsIncome(currentMonthsIncome.toString()); //当期结束日 Period period = obtainCycle(new Date()); @@ -291,7 +294,8 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ String cycleTime = DateUtil.formatDateTime(startFundData); //当前一周期业绩 - Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, date, cycleTime); + BigDecimal currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, date, cycleTime); + currentPerformance = currentPerformance.setScale(0,BigDecimal.ROUND_DOWN); //当前一周期储值积分数 String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, date, cycleTime); @@ -354,7 +358,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ String proportionalSharing = item.getProportionalSharing(); if ( //1.业绩要求 - currentPerformance >= outstandingAchievement.intValue() + currentPerformance.compareTo(outstandingAchievement) >= 0 //2.加钟率要求 && clockRate.compareTo(clockRate1) > -1 //充值率要求 @@ -400,7 +404,8 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ String cycleTime = DateUtil.formatDateTime(startFundData); //当前一周期业绩 - Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, date, cycleTime); + BigDecimal currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, date, cycleTime); + currentPerformance = currentPerformance.setScale(0,BigDecimal.ROUND_DOWN); //当前一周期储值积分数 String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, date, cycleTime); @@ -465,7 +470,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ String proportionalSharing = item.getProportionalSharing(); if ( //1.业绩要求 - currentPerformance >= outstandingAchievement.intValue() + currentPerformance.compareTo(outstandingAchievement) >= 0 //2.加钟率要求 && clockRate.compareTo(clockRate1) > -1 //充值率要求 diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java index c31ed29..69608af 100644 --- a/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificer/service/impl/ArtificerServiceImpl.java @@ -531,7 +531,8 @@ public class ArtificerServiceImpl extends ServiceImpl i for(Map map:pageList.getRecords()){ Long artificerId = Long.parseLong(map.get("artificerId").toString()); //当期业绩 - Integer currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endTime, startTime); + BigDecimal currentPerformance = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endTime, startTime); + currentPerformance = currentPerformance.setScale(0,BigDecimal.ROUND_DOWN); map.put("yj",String.valueOf(currentPerformance)); //当期订单数:计算订单发生了按摩行为的订单数,订单状态经历了开始服务到订单结束。 @@ -691,8 +692,9 @@ public class ArtificerServiceImpl extends ServiceImpl i if(orderType == 1){//1当期 // ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime); ordersIPage = ordersDao.selectDividedIntoDetails(pages, userId,startTime,endTime,null); - int yeji = ordersDao.selectOrdersArtificerIntegralEarnings(userId, endTime, startTime); - earnings = yeji+""; + BigDecimal yeji = ordersDao.selectOrdersArtificerIntegralEarnings(userId, endTime, startTime); + yeji = yeji.setScale(0,BigDecimal.ROUND_DOWN); + earnings = yeji.toString(); }else if(orderType == 2){//2加钟 //查询列表 // ordersIPage = ordersDao.getJiazhongList(pages, userId,isSfwc,startTime,endTime); 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 0960f9a..5be82ae 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 @@ -1512,7 +1512,7 @@ public class OrdersServiceImpl extends ServiceImpl implements BigDecimal massagePrice = chajia.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(chajia);//技师等级加成金额 massagePrice = massagePrice.multiply(orders.getVipRate()).divide(new BigDecimal(100));//会员优惠后金额 - + massagePrice = massagePrice.setScale(2, BigDecimal.ROUND_HALF_UP); orders.setMassageMoney(massagePrice); // chajia = chajia.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(price);//技师等级加成金额 @@ -6157,7 +6157,9 @@ public class OrdersServiceImpl extends ServiceImpl implements String countOrderStr = ordersDao.selectOrdersArtificerIntegral(artificerId, endTime, startTime ); Integer countOrder = Integer.valueOf(countOrderStr); //退款金额 - BigDecimal sumRefund = userMoneyDetailsService.selectSumRefund(artificer.getUserId(), startTime, endTime); +// BigDecimal sumRefund = userMoneyDetailsService.selectSumRefund(artificer.getUserId(), startTime, endTime); + BigDecimal sumRefund = ordersDao.selectSumRefund(artificerId, startTime, endTime); + //访客人数 int countByUserId = collectArtificerService.selectCountByUserId(artificerId, startTime, endTime); //待服务 @@ -6652,35 +6654,44 @@ public class OrdersServiceImpl extends ServiceImpl implements @Override public Result selectDividedIntoDetail(Period period) { - QueryWrapper queryWrapper = new QueryWrapper(); if(StringUtil.isNotEmpty(period.getArtificerId())) { Result.error("系统异常,请联系管理员"); } - queryWrapper.eq("artificer_id", period.getArtificerId()); - if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ - queryWrapper.between("end_times", period.getStartFundData(), period.getEndFundData()); - } - //只查询已完成和待评价的订单 - queryWrapper.in("status", Arrays.asList(5, 3)); - queryWrapper.orderByDesc("end_times"); - List orderList = baseMapper.selectList(queryWrapper); - UserMoneyArtificerDetails userMoneyArtificerDetails = new UserMoneyArtificerDetails(); - - //计算项目收益 - userMoneyArtificerDetails.setProjectBenefits(orderList.stream().map(e -> e.getProjectBenefits()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); - //计算车费收益 - userMoneyArtificerDetails.setVehicleFareAmount(orderList.stream().map(e -> e.getArtificerTaxiMoney()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); - //暂时去掉 -// //计算渠道扣款 -// userMoneyArtificerDetails.setChannelDeduction(orderList.stream().map(e -> e.getChannelDeduction()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); -// //计算储值扣款 -// userMoneyArtificerDetails.setValueStorageDeduction(orderList.stream().map(e -> e.getValueStorageDeduction()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); - //计算当期收益 项目收益 + 车费收益 (暂时去掉了 减去渠道扣款和储值扣款) - BigDecimal all = new BigDecimal(String.valueOf(userMoneyArtificerDetails.getProjectBenefits().add(userMoneyArtificerDetails.getVehicleFareAmount()))).setScale(2, BigDecimal.ROUND_HALF_UP); - userMoneyArtificerDetails.setTotalRevenue(all); +// QueryWrapper queryWrapper = new QueryWrapper(); +// queryWrapper.eq("artificer_id", period.getArtificerId()); +// if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ +// queryWrapper.between("end_times", period.getStartFundData(), period.getEndFundData()); +// } +// //只查询已完成和待评价的订单 +// queryWrapper.in("status", Arrays.asList(5, 3)); +// queryWrapper.orderByDesc("end_times"); +// List orderList = baseMapper.selectList(queryWrapper); +// //计算项目收益 +// userMoneyArtificerDetails.setProjectBenefits(orderList.stream().map(e -> e.getProjectBenefits()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); +// //计算车费收益 +// userMoneyArtificerDetails.setVehicleFareAmount(orderList.stream().map(e -> e.getArtificerTaxiMoney()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); +// //暂时去掉 +//// //计算渠道扣款 +//// userMoneyArtificerDetails.setChannelDeduction(orderList.stream().map(e -> e.getChannelDeduction()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); +//// //计算储值扣款 +//// userMoneyArtificerDetails.setValueStorageDeduction(orderList.stream().map(e -> e.getValueStorageDeduction()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP)); +// //计算当期收益 项目收益 + 车费收益 (暂时去掉了 减去渠道扣款和储值扣款) +// BigDecimal all = new BigDecimal(String.valueOf(userMoneyArtificerDetails.getProjectBenefits().add(userMoneyArtificerDetails.getVehicleFareAmount()))).setScale(2, BigDecimal.ROUND_HALF_UP); +// userMoneyArtificerDetails.setTotalRevenue(all); //插入开始结束时间 + UserMoneyArtificerDetails userMoneyArtificerDetails = new UserMoneyArtificerDetails(); userMoneyArtificerDetails.setStartFundData(period.getStartFundData()); userMoneyArtificerDetails.setEndFundData(period.getEndFundData()); + + Long artificerId = Long.valueOf(period.getArtificerId()); + String startDate = DateUtils.format(period.getStartFundData()); + String endDate = DateUtils.format(period.getEndFundData()); + //总顶顶那收益 + BigDecimal sy = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId,endDate,startDate); + userMoneyArtificerDetails.setTotalRevenue(sy); + + + //资金明细添加到返回对象中 return Result.success().put("data", userMoneyArtificerDetails); } diff --git a/src/main/java/com/sqx/modules/task/service/impl/AllTaskServiceImpl.java b/src/main/java/com/sqx/modules/task/service/impl/AllTaskServiceImpl.java index 4418845..eb2f5bc 100644 --- a/src/main/java/com/sqx/modules/task/service/impl/AllTaskServiceImpl.java +++ b/src/main/java/com/sqx/modules/task/service/impl/AllTaskServiceImpl.java @@ -115,7 +115,8 @@ public class AllTaskServiceImpl implements AllTaskSercice { Integer ynJfgz = jsPar.getYnJfgz();//是否参与积分规则计算(0不参与 1参与) //4.1获取 技师销售金额(order表的 price) 只查询完成的单子 - int jsdqyj = ordersDao.selectOrdersArtificerIntegralEarnings(jsPar.getArtificerId(),endTime,startTime); + BigDecimal jsdqyj = ordersDao.selectOrdersArtificerIntegralEarnings(jsPar.getArtificerId(),endTime,startTime); + jsdqyj = jsdqyj.setScale(0,BigDecimal.ROUND_DOWN); //4.2获取 技师加钟率(order表的parent_id为空则是正常订单,不为空则是加钟订单 用加钟订单/正常订单为加钟率) String jsjzl = ordersDao.selectOrdersArtificerIntegraladdNum(jsPar.getArtificerId(),endTime,startTime); //4.3获取 在线时长(通过积分表和兑换比例反推在线时长 user_rechange的type=1) diff --git a/src/main/resources/mapper/artificer/OrdersDao.xml b/src/main/resources/mapper/artificer/OrdersDao.xml index 517766f..6c03576 100644 --- a/src/main/resources/mapper/artificer/OrdersDao.xml +++ b/src/main/resources/mapper/artificer/OrdersDao.xml @@ -635,7 +635,11 @@ - select IFNULL(SUM(artificer_money_total),0) AS currentEarnings from ( select (case when o.status = 4 @@ -1685,6 +1689,21 @@ where parent_id = #{parentId} - + \ No newline at end of file diff --git a/src/main/resources/mapper/taking/OrderTakingCommentDao.xml b/src/main/resources/mapper/taking/OrderTakingCommentDao.xml index 57fd79a..42f484c 100644 --- a/src/main/resources/mapper/taking/OrderTakingCommentDao.xml +++ b/src/main/resources/mapper/taking/OrderTakingCommentDao.xml @@ -78,10 +78,10 @@ and order_id in (select orders_id from orders where artificer_id = #{userId} and status in (3,5) - 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') )