This commit is contained in:
yangjun 2024-07-11 17:20:54 +08:00
commit 465231abfc
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 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<Orders> {
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.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
//充值率要求

View File

@ -531,7 +531,8 @@ public class ArtificerServiceImpl extends ServiceImpl<ArtificerDao, Artificer> i
for(Map<String,Object> 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<ArtificerDao, Artificer> 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);

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);//技师等级加成金额
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<OrdersDao, Orders> 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<OrdersDao, Orders> implements
@Override
public Result selectDividedIntoDetail(Period period) {
QueryWrapper<Orders> 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<Orders> 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<Orders> 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<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.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);
}

View File

@ -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

View File

@ -635,7 +635,11 @@
<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!=''">
and date_format(end_times,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
</if>
@ -1194,7 +1198,7 @@
) t
</select>
<!--当期收益-->
<select id="selectOrdersArtificerIntegralEarnings" resultType="java.lang.Integer">
<select id="selectOrdersArtificerIntegralEarnings" resultType="java.math.BigDecimal">
select IFNULL(SUM(artificer_money_total),0) AS currentEarnings
from (
select (case when o.status = 4
@ -1685,6 +1689,21 @@
where parent_id = #{parentId}
</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>

View File

@ -78,10 +78,10 @@
and order_id in
(select orders_id from orders where artificer_id = #{userId} and status in (3,5)
<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 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>
)
</select>