技师数据分成明细

This commit is contained in:
曹磊 2024-07-11 17:19:20 +08:00
parent f4b6b7604a
commit 150954c6bb
7 changed files with 85 additions and 45 deletions

View File

@ -98,7 +98,7 @@ public interface OrdersDao extends BaseMapper<Orders> {
Integer selectOrdersArtificerIntegralAchievement(Long artificerId, String endDate, String startDate); 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); String selectOrdersArtificerIntegral(Long artificerId, String endDate, String startDate);
@ -142,4 +142,6 @@ public interface OrdersDao extends BaseMapper<Orders> {
List<Orders> getParentOrders(Long parentId); List<Orders> getParentOrders(Long parentId);
BigDecimal selectSumRefund(Long artificerId, @Param("startTime") String startTime, @Param("endTime") String endTime);
} }

View File

@ -72,22 +72,25 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
//当期收益 //当期收益
// String earnings = ordersDao.earnings(artificerId, endDate, startDate); // String earnings = ordersDao.earnings(artificerId, endDate, startDate);
String earnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate).toString(); BigDecimal earnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endDate, startDate);
orders.setEarnings(earnings); earnings = earnings.setScale(0,BigDecimal.ROUND_DOWN);
orders.setEarnings(earnings.toString());
//当日收益 //当日收益
String todayEndIncome = DateUtil.formatDateTime(DateUtil.endOfDay(new Date())); String todayEndIncome = DateUtil.formatDateTime(DateUtil.endOfDay(new Date()));
// String dailyEarnings = ordersDao.earnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(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(); BigDecimal dailyEarnings = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, todayEndIncome, String.valueOf(DateUtil.beginOfDay(new Date())));
orders.setDailyEarnings(dailyEarnings); dailyEarnings = dailyEarnings.setScale(0,BigDecimal.ROUND_DOWN);
orders.setDailyEarnings(dailyEarnings.toString());
//当月收益 //当月收益
//当月结束日 //当月结束日
String startFundDataformat = DateUtil.formatDateTime(DateUtil.beginOfMonth(new Date())); String startFundDataformat = DateUtil.formatDateTime(DateUtil.beginOfMonth(new Date()));
String endFundDataformat = DateUtil.formatDateTime(DateUtil.endOfMonth(new Date())); String endFundDataformat = DateUtil.formatDateTime(DateUtil.endOfMonth(new Date()));
// String currentMonthsIncome = ordersDao.earnings(artificerId, endFundDataformat, startFundDataformat); // String currentMonthsIncome = ordersDao.earnings(artificerId, endFundDataformat, startFundDataformat);
String currentMonthsIncome = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endFundDataformat, startFundDataformat).toString(); BigDecimal currentMonthsIncome = ordersDao.selectOrdersArtificerIntegralEarnings(artificerId, endFundDataformat, startFundDataformat);
orders.setCurrentMonthsIncome(currentMonthsIncome); currentMonthsIncome = currentMonthsIncome.setScale(0,BigDecimal.ROUND_DOWN);
orders.setCurrentMonthsIncome(currentMonthsIncome.toString());
//当期结束日 //当期结束日
Period period = obtainCycle(new Date()); Period period = obtainCycle(new Date());
@ -291,7 +294,8 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
String cycleTime = DateUtil.formatDateTime(startFundData); 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); String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, date, cycleTime);
@ -354,7 +358,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
String proportionalSharing = item.getProportionalSharing(); String proportionalSharing = item.getProportionalSharing();
if ( if (
//1.业绩要求 //1.业绩要求
currentPerformance >= outstandingAchievement.intValue() currentPerformance.compareTo(outstandingAchievement) >= 0
//2.加钟率要求 //2.加钟率要求
&& clockRate.compareTo(clockRate1) > -1 && clockRate.compareTo(clockRate1) > -1
//充值率要求 //充值率要求
@ -400,7 +404,8 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
String cycleTime = DateUtil.formatDateTime(startFundData); 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); String storedValueIntegral = ordersDao.selectOrdersStoredValueIntegral(artificerId, date, cycleTime);
@ -465,7 +470,7 @@ public class AppArtificerIntegralServiceImpl implements AppArtificerIntegralServ
String proportionalSharing = item.getProportionalSharing(); String proportionalSharing = item.getProportionalSharing();
if ( if (
//1.业绩要求 //1.业绩要求
currentPerformance >= outstandingAchievement.intValue() currentPerformance.compareTo(outstandingAchievement) >= 0
//2.加钟率要求 //2.加钟率要求
&& clockRate.compareTo(clockRate1) > -1 && clockRate.compareTo(clockRate1) > -1
//充值率要求 //充值率要求

View File

@ -531,7 +531,8 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
for(Map<String,Object> map:pageList.getRecords()){ for(Map<String,Object> map:pageList.getRecords()){
Long artificerId = Long.parseLong(map.get("artificerId").toString()); 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)); map.put("yj",String.valueOf(currentPerformance));
//当期订单数计算订单发生了按摩行为的订单数订单状态经历了开始服务到订单结束 //当期订单数计算订单发生了按摩行为的订单数订单状态经历了开始服务到订单结束
@ -691,8 +692,9 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
if(orderType == 1){//1当期 if(orderType == 1){//1当期
// ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime); // ordersIPage = ordersDao.getDangqiList(pages, userId,isSfwc,startTime,endTime);
ordersIPage = ordersDao.selectDividedIntoDetails(pages, userId,startTime,endTime,null); ordersIPage = ordersDao.selectDividedIntoDetails(pages, userId,startTime,endTime,null);
int yeji = ordersDao.selectOrdersArtificerIntegralEarnings(userId, endTime, startTime); BigDecimal yeji = ordersDao.selectOrdersArtificerIntegralEarnings(userId, endTime, startTime);
earnings = yeji+""; yeji = yeji.setScale(0,BigDecimal.ROUND_DOWN);
earnings = yeji.toString();
}else if(orderType == 2){//2加钟 }else if(orderType == 2){//2加钟
//查询列表 //查询列表
// ordersIPage = ordersDao.getJiazhongList(pages, userId,isSfwc,startTime,endTime); // ordersIPage = ordersDao.getJiazhongList(pages, userId,isSfwc,startTime,endTime);

View File

@ -1512,7 +1512,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
BigDecimal massagePrice = chajia.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(chajia);//技师等级加成金额 BigDecimal massagePrice = chajia.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(chajia);//技师等级加成金额
massagePrice = massagePrice.multiply(orders.getVipRate()).divide(new BigDecimal(100));//会员优惠后金额 massagePrice = massagePrice.multiply(orders.getVipRate()).divide(new BigDecimal(100));//会员优惠后金额
massagePrice = massagePrice.setScale(2, BigDecimal.ROUND_HALF_UP);
orders.setMassageMoney(massagePrice); orders.setMassageMoney(massagePrice);
// chajia = chajia.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(price);//技师等级加成金额 // chajia = chajia.multiply(orders.getTechnicianRate()).divide(new BigDecimal(100)).add(price);//技师等级加成金额
@ -6157,7 +6157,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
String countOrderStr = ordersDao.selectOrdersArtificerIntegral(artificerId, endTime, startTime ); String countOrderStr = ordersDao.selectOrdersArtificerIntegral(artificerId, endTime, startTime );
Integer countOrder = Integer.valueOf(countOrderStr); 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); int countByUserId = collectArtificerService.selectCountByUserId(artificerId, startTime, endTime);
//待服务 //待服务
@ -6652,35 +6654,44 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
@Override @Override
public Result selectDividedIntoDetail(Period period) { public Result selectDividedIntoDetail(Period period) {
QueryWrapper<Orders> queryWrapper = new QueryWrapper();
if(StringUtil.isNotEmpty(period.getArtificerId())) { if(StringUtil.isNotEmpty(period.getArtificerId())) {
Result.error("系统异常,请联系管理员"); Result.error("系统异常,请联系管理员");
} }
queryWrapper.eq("artificer_id", period.getArtificerId()); // QueryWrapper<Orders> queryWrapper = new QueryWrapper();
if(StringUtil.isNotEmpty(period.getStartFundData().toString())){ // queryWrapper.eq("artificer_id", period.getArtificerId());
queryWrapper.between("end_times", period.getStartFundData(), period.getEndFundData()); // 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"); // queryWrapper.in("status", Arrays.asList(5, 3));
List<Orders> orderList = baseMapper.selectList(queryWrapper); // queryWrapper.orderByDesc("end_times");
UserMoneyArtificerDetails userMoneyArtificerDetails = new UserMoneyArtificerDetails(); // List<Orders> orderList = baseMapper.selectList(queryWrapper);
// //计算项目收益
//计算项目收益 // userMoneyArtificerDetails.setProjectBenefits(orderList.stream().map(e -> e.getProjectBenefits()).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP));
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.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.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));
// 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);
BigDecimal all = new BigDecimal(String.valueOf(userMoneyArtificerDetails.getProjectBenefits().add(userMoneyArtificerDetails.getVehicleFareAmount()))).setScale(2, BigDecimal.ROUND_HALF_UP); // userMoneyArtificerDetails.setTotalRevenue(all);
userMoneyArtificerDetails.setTotalRevenue(all);
//插入开始结束时间 //插入开始结束时间
UserMoneyArtificerDetails userMoneyArtificerDetails = new UserMoneyArtificerDetails();
userMoneyArtificerDetails.setStartFundData(period.getStartFundData()); userMoneyArtificerDetails.setStartFundData(period.getStartFundData());
userMoneyArtificerDetails.setEndFundData(period.getEndFundData()); 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); return Result.success().put("data", userMoneyArtificerDetails);
} }

View File

@ -115,7 +115,8 @@ public class AllTaskServiceImpl implements AllTaskSercice {
Integer ynJfgz = jsPar.getYnJfgz();//是否参与积分规则计算0不参与 1参与 Integer ynJfgz = jsPar.getYnJfgz();//是否参与积分规则计算0不参与 1参与
//4.1获取 技师销售金额(order表的 price) 只查询完成的单子 //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为空则是正常订单不为空则是加钟订单 用加钟订单/正常订单为加钟率) //4.2获取 技师加钟率(order表的parent_id为空则是正常订单不为空则是加钟订单 用加钟订单/正常订单为加钟率)
String jsjzl = ordersDao.selectOrdersArtificerIntegraladdNum(jsPar.getArtificerId(),endTime,startTime); String jsjzl = ordersDao.selectOrdersArtificerIntegraladdNum(jsPar.getArtificerId(),endTime,startTime);
//4.3获取 在线时长通过积分表和兑换比例反推在线时长 user_rechange的type=1 //4.3获取 在线时长通过积分表和兑换比例反推在线时长 user_rechange的type=1

View File

@ -635,7 +635,11 @@
<select id="selectCountOrderNum" resultType="int"> <select id="selectCountOrderNum" resultType="int">
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) select ifnull(sum(massage_num), 0) as num
from orders
where artificer_id = #{userId}
and status in (3,5,15)
and ifnull(is_supplement,0) in (0,2)
<if test="startTime!=null and startTime!=''"> <if test="startTime!=null and startTime!=''">
and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d') and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if> </if>
@ -1194,7 +1198,7 @@
) t ) t
</select> </select>
<!--当期收益--> <!--当期收益-->
<select id="selectOrdersArtificerIntegralEarnings" resultType="java.lang.Integer"> <select id="selectOrdersArtificerIntegralEarnings" resultType="java.math.BigDecimal">
select IFNULL(SUM(artificer_money_total),0) AS currentEarnings select IFNULL(SUM(artificer_money_total),0) AS currentEarnings
from ( from (
select (case when o.status = 4 select (case when o.status = 4
@ -1685,6 +1689,21 @@
where parent_id = #{parentId} where parent_id = #{parentId}
</select> </select>
<select id="selectSumRefund" resultType="java.math.BigDecimal">
select IFNULL(SUM(artificer_money),0) AS currentEarnings
from (
select o.*
from orders o
where o.artificer_id =${artificerId}
<if test="startTime!=null and startTime!=''">
and date_format(create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime!=null and endTime!=''">
and date_format(create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if>
and o.status = 4
and o.pay_time is not null
) t
</select>
</mapper> </mapper>

View File

@ -78,10 +78,10 @@
and order_id in and order_id in
(select orders_id from orders where artificer_id = #{userId} and status in (3,5) (select orders_id from orders where artificer_id = #{userId} and status in (3,5)
<if test="startTime!=null and startTime!=''"> <if test="startTime!=null and startTime!=''">
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')
</if> </if>
<if test="endTime!=null and endTime!=''"> <if test="endTime!=null and endTime!=''">
and date_format(pay_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d') and date_format(end_times,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
</if> </if>
) )
</select> </select>