Commit 94772bf3 by huluobin

美甲师排班

parent ba02730b
...@@ -51,7 +51,7 @@ public class StoreClassesTechnicianServiceImpl extends ServiceImpl<StoreClassesT ...@@ -51,7 +51,7 @@ public class StoreClassesTechnicianServiceImpl extends ServiceImpl<StoreClassesT
@Override @Override
public List<StoreClassesTechnician> listClassesTechnicianDetail(Integer userId, String days) { public List<StoreClassesTechnician> listClassesTechnicianDetail(Integer userId, String days) {
return storeClassesTechnicianMapper.listClassesTechnicianDetail(userId, days); return storeClassesTechnicianMapper.listClassesTechnicianDetail(userId, days, SessionUtils.getTechnicianToken().getDepartmentId());
} }
@Override @Override
......
...@@ -25,7 +25,7 @@ public interface StoreClassesTechnicianMapper extends BaseMapper<StoreClassesTec ...@@ -25,7 +25,7 @@ public interface StoreClassesTechnicianMapper extends BaseMapper<StoreClassesTec
List<StoreClassesTechnician> listClassTimeByStartDate(@Param("startDate") String startDate, @Param("startTime") String startTime, @Param("departmentId") Integer departmentId); List<StoreClassesTechnician> listClassTimeByStartDate(@Param("startDate") String startDate, @Param("startTime") String startTime, @Param("departmentId") Integer departmentId);
List<StoreClassesTechnician> listClassesTechnicianDetail(@Param("userId") Integer userId, @Param("days") String days); List<StoreClassesTechnician> listClassesTechnicianDetail(@Param("userId") Integer userId, @Param("days") String days, @Param("departmentId") Integer departmentId);
List<StoreClassesTechnician> listClassesTechnicianDetailByDays(@Param("userId") Integer userId, @Param("days") String days); List<StoreClassesTechnician> listClassesTechnicianDetailByDays(@Param("userId") Integer userId, @Param("days") String days);
......
...@@ -304,7 +304,6 @@ public class Schedule { ...@@ -304,7 +304,6 @@ public class Schedule {
orderServeMapper.syncOrderServeTimes(); orderServeMapper.syncOrderServeTimes();
} }
@Scheduled(cron = "0 0/1 * * * *") @Scheduled(cron = "0 0/1 * * * *")
public void weekTest() { public void weekTest() {
log.debug("同步闲时折扣周"); log.debug("同步闲时折扣周");
......
spring: spring:
profiles: profiles:
active: pre active: prod
servlet: servlet:
#文件上传最大容量 #文件上传最大容量
multipart: multipart:
......
...@@ -80,14 +80,17 @@ ...@@ -80,14 +80,17 @@
</sql> </sql>
<select id="listClassesTechnicianDetail" resultMap="classesTechnicianMap"> <select id="listClassesTechnicianDetail" resultMap="classesTechnicianMap">
select SELECT *
<include refid="storeClassesTechnicianSql"/> FROM (
from SELECT ct.*
store_classes_technician ct FROM store_classes_technician ct
where LEFT JOIN store_classes sc ON ct.classes = sc.id
user_id = #{userId} WHERE ct.user_id = #{userId}
and AND date_format(ct.days, '%Y-%m') = #{days}
date_format(days, '%Y-%m') = #{days} and (sc.department_id = #{departmentId} or sc.department_id is null)
ORDER BY ct.days, ct.classes DESC
) t
GROUP BY days
</select> </select>
<select id="listClassesTechnicianDetailByDays" <select id="listClassesTechnicianDetailByDays"
......
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gogirl.application.market.CouponCustomerRelevanceService; import com.gogirl.application.market.CouponCustomerRelevanceService;
import com.gogirl.application.market.TimesCardCustomerRelevanceService; import com.gogirl.application.market.TimesCardCustomerRelevanceService;
import com.gogirl.application.market.TimesCardUsedRecordService; import com.gogirl.application.market.TimesCardUsedRecordService;
import com.gogirl.application.store.store.StoreTechnicianService;
import com.gogirl.application.xcx.GogirlTokenService; import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.domain.market.coupon.CouponCustomerRelevance; import com.gogirl.domain.market.coupon.CouponCustomerRelevance;
import com.gogirl.domain.order.pay.OrderPay; import com.gogirl.domain.order.pay.OrderPay;
...@@ -14,7 +15,9 @@ import com.gogirl.domain.order.serve.OrderServe; ...@@ -14,7 +15,9 @@ import com.gogirl.domain.order.serve.OrderServe;
import com.gogirl.domain.store.complaint.ComplaintDetailed; import com.gogirl.domain.store.complaint.ComplaintDetailed;
import com.gogirl.domain.store.complaint.ComplaintDetailedTechnician; import com.gogirl.domain.store.complaint.ComplaintDetailedTechnician;
import com.gogirl.domain.store.complaint.ComplaintMain; import com.gogirl.domain.store.complaint.ComplaintMain;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.user.customer.Customer; import com.gogirl.domain.user.customer.Customer;
import com.gogirl.domain.user.customer.CustomerBalanceRecord;
import com.gogirl.domain.xcx.GogirlToken; import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.domain.xcx.TimeNode; import com.gogirl.domain.xcx.TimeNode;
import com.gogirl.domain.xcx.WeekConfig; import com.gogirl.domain.xcx.WeekConfig;
...@@ -28,6 +31,7 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper; ...@@ -28,6 +31,7 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedMapper; import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedTechnicianMapper; import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedTechnicianMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintMainMapper; import com.gogirl.infrastructure.mapper.store.complaint.ComplaintMainMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper;
import com.gogirl.infrastructure.mapper.xcx.TimeNodeMapper; import com.gogirl.infrastructure.mapper.xcx.TimeNodeMapper;
import com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper; import com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper;
...@@ -44,7 +48,9 @@ import java.text.SimpleDateFormat; ...@@ -44,7 +48,9 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
...@@ -248,273 +254,67 @@ public class Test { ...@@ -248,273 +254,67 @@ public class Test {
TimesCardUsedRecordService timesCardUsedRecordService; TimesCardUsedRecordService timesCardUsedRecordService;
@Resource @Resource
TimesCardCustomerRelevanceService timesCardCustomerRelevanceService; TimesCardCustomerRelevanceService timesCardCustomerRelevanceService;
@Resource
StoreTechnicianService storeTechnicianService;
@Resource
CustomerBalanceRecordMapper customerBalanceRecordMapper;
@org.junit.Test
public void setChargeReferees() {
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务开始");
SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
String day = "2020-03-12";
log.debug("设置推荐人:当天服务的技师为推荐人");
Map<String, String> mapTechnicianManage = new HashMap<>();
List<StoreTechnician> listTechnicianManage = storeTechnicianService.listTechnicianForPage(new StoreTechnician());
//查出所有的技师,找到技师id和user_id
for (StoreTechnician item : listTechnicianManage) {
mapTechnicianManage.put(String.valueOf(item.getTechnicianId()), String.valueOf(item.getUserId()));
}
//找到当天的订单的推荐人
List<CustomerBalanceRecord> list = customerBalanceRecordMapper.getXcxChargeRecord(day);
//遍历设置推荐人
for (CustomerBalanceRecord customerBalanceRecord : list) {
//推荐人列表
Map<String, String> map = new HashMap<>();
//推荐人id
StringBuilder referee_ids = new StringBuilder();
//充值记录
CustomerBalanceRecord cbrt = customerBalanceRecordMapper.selectByPrimaryKey(customerBalanceRecord.getId());
//每次都修改推荐人,且每晚都会设置推荐人
if (customerBalanceRecord.getRefereeId() != null) {
String[] arr = customerBalanceRecord.getRefereeId().split(",");
//
for (String s : arr) {
if (!map.containsKey(s)) {
map.put(s, s);
referee_ids.append(",").append(mapTechnicianManage.get(s));
}
}
//去掉首尾,
if (referee_ids.toString().startsWith(",")) {
referee_ids = new StringBuilder(referee_ids.substring(1));
}
customerBalanceRecord.setRefereeId(referee_ids.toString());
}
//如果店铺id不为空
if (cbrt != null && cbrt.getDepartmentId() != null) {
customerBalanceRecord.setDepartmentId(cbrt.getDepartmentId());
}
if (customerBalanceRecord.getId() != null
&& (customerBalanceRecord.getRefereeId() != null || customerBalanceRecord.getDepartmentId() != null)) {
customerBalanceRecordMapper.updateByPrimaryKeySelective(customerBalanceRecord);
}
}
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束");
}
// public void orderAch() {
// List<OrderManage> orderManageList = orderManageMapper.selectList(new LambdaQueryWrapper<OrderManage>()
// .in(OrderManage::getStatus, Lists.newArrayList(3, 4))
// .ge(OrderManage::getCreateTime, "2020-03-01"));
// orderManageList.forEach(orderManage -> {
// Integer orderId = orderManage.getId();
// //订单使用的内部券
// List<CouponCustomerRelevance> innerCouponCustomerRelevanceServiceList = couponCustomerRelevanceService
// .list(new LambdaQueryWrapper<CouponCustomerRelevance>()
// .eq(CouponCustomerRelevance::getOrderId, orderId)
// .eq(CouponCustomerRelevance::getState, 1)
// .eq(CouponCustomerRelevance::getSourceType, 0));
//
// //订单使用的外部券
// List<CouponCustomerRelevance> outerCouponCustomerRelevanceServiceList = couponCustomerRelevanceService
// .list(new LambdaQueryWrapper<CouponCustomerRelevance>()
// .eq(CouponCustomerRelevance::getOrderId, orderId)
// .eq(CouponCustomerRelevance::getState, 1)
// .eq(CouponCustomerRelevance::getSourceType, 1));
//
//
// //订单使用的次卡
// List<TimesCardUsedRecord> timesCardUsedRecordList = timesCardUsedRecordService
// .list(new LambdaQueryWrapper<TimesCardUsedRecord>()
// .eq(TimesCardUsedRecord::getOrderId, orderId)
// .eq(TimesCardUsedRecord::getStatus, 1));
//
//
// //查询订单聚合
//
// List<OrderServe> orderServeList = orderServeMapper.selectList(new LambdaQueryWrapper<OrderServe>().eq(OrderServe::getOrderId, orderId));
// orderManage.setListOrderServer(orderServeList);
// orderServeList.forEach(orderServe -> {
// orderServe.setBindInnerCoupon(2);
// orderServe.setBindTimesCard(2);
// orderServe.setBindOuterCoupon(2);
// });
//
// //1.改价结算
// //总支付金额等于 总价格+总改价
// orderManage.setTotalPaymentAmount(orderManage.getTotalPrice().add(orderManage.getChangePrice()));
// //总折扣金额
// orderManage.setDiscountPrice(BigDecimal.ZERO);
//
// orderManage.getListOrderServer().forEach(orderServe -> {
// //服务实际支付金额=服务价格+服务改价
// orderServe.setPayPrice(orderServe.getPrice().add(orderServe.getServeChangePrice()));
// //服务折金额=0
// orderServe.setDiscountPrice(BigDecimal.ZERO);
// //业绩的实际支付金额
// orderServe.setAchievement(orderServe.getPrice().add(orderServe.getServeChangePrice()));
// });
//
// //3.次卡
// if (ListUtil.isNotEmpty(timesCardUsedRecordList)) {
// //次卡使用记录
// timesCardUsedRecordList.forEach(timesCardUsedRecord -> timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_CHOSE));
//
// timesCardUsedRecordList.stream()
// .sorted(Comparator.comparing(TimesCardUsedRecord::getDiscountAmount))
// .forEach(timesCardUsedRecord -> {
//
//
// //次卡能用的服务id
// List<Integer> serveIds = timesCardCustomerRelevanceMapper.queryTimesCardServeIds(timesCardUsedRecord.getCardTypeId());
// //抵扣的服务为 作用范围内支付金额最高的服务
// OrderServe orderServe = this.queryMaxPayPrice(orderManage, serveIds);
// if (orderServe != null) {
//
// BigDecimal actualDiscountAmount = orderServe.getPayPrice().min(timesCardUsedRecord.getDiscountAmount());
// //更新次卡记录 已使用
// timesCardUsedRecord.setStatus(TimesCardUsedRecord.STATUS_USED);
// //次卡对应订单服务的美甲师
// timesCardUsedRecord.setTechnicianName(orderServe.getTechnicianName());
// //次卡店铺名称
// timesCardUsedRecord.setDepartmentName(orderManage.getDepartmentName());
// //次卡店铺id
// timesCardUsedRecord.setDepartmentId(orderManage.getDepartmentId());
// //次卡折扣的
// timesCardUsedRecord.setServeName(orderServe.getServeName());
// //次卡作用的服务id
// timesCardUsedRecord.setOrderServeId(orderServe.getServeId());
// timesCardUsedRecord.setOrderId(orderId);
// timesCardUsedRecord.setActualDiscountAmount(actualDiscountAmount);
//
// //在主服务上折扣的钱
// TimesCardOrderServeDetail timesCardOrderServeDetail = new TimesCardOrderServeDetail();
// timesCardOrderServeDetail.setDiscountAmount(actualDiscountAmount);
// timesCardOrderServeDetail.setOrderServeId(orderServe.getId());
// timesCardOrderServeDetail.setOrderId(orderId);
// timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
// //业绩
// timesCardOrderServeDetail.setAchievement(timesCardUsedRecord.getPayAmount());
//
// //订单折扣金额更新
// orderServe.setBindTimesCard(1);
// orderServe.addDiscountPrice(actualDiscountAmount);
//
// //业绩
// orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
// orderManage.addDiscountPrice(actualDiscountAmount);
//
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
// } else {
// throw new RRException("次卡冲突");
// }
//
// });
// }
//
//
// //4。外部券
// if (ListUtil.isNotEmpty(outerCouponCustomerRelevanceServiceList)) {
//
//
//
// outerCouponCustomerRelevanceServiceList
// .stream()
// .sorted(Comparator.comparing(CouponCustomerRelevance::getDiscountAmount).reversed())
// .forEach(couponCustomerRelevance -> {
//
//
// //外部券能用的服务id
// List<Integer> serveIds = couponCustomerRelevanceMapper.queryCouponCustomerServeRelevance(couponCustomerRelevance.getCouponId());
//
// //抵扣的服务为 作用范围内支付金额最高的服务
// OrderServe orderServe = this.queryMaxPayPrice(orderManage, serveIds);
//
// if (orderServe != null) {
// //如果有属于这个服务的辅助服务 就查出来一起折扣
// OrderServe supportServe = this.querySupportServe(orderManage, orderServe);
//
// BigDecimal actualDiscountAmount = orderServe.getPayPrice().min(couponCustomerRelevance.getDiscountAmount());
//
// //新增外部券抵扣情况记录
// CouponOrderRelevance couponOrderRelevance = CouponOrderRelevance.builder()
// .couponCustomerRelevanceId(couponCustomerRelevance.getId())
// .couponId(couponCustomerRelevance.getCouponId())
// .couponName(couponCustomerRelevance.getCouponName())
// .orderServeId(orderServe.getId())
// .serveName(orderServe.getServeName())
// .orderId(orderManage.getId())
// //支付金额
// .payForOrderServe(couponCustomerRelevance.getPayAmount())
// //折扣金额
// .discountAmount(actualDiscountAmount)
// .createTime(new Date())
// .confirmTime(new Date())
// .message(orderServe.getServeName())
// .customerId(orderManage.getOrderUser())
// .status(2)
// .build();
// //如果计算业绩
// if (couponCustomerRelevance.getIsCalcAchievement() == 1) {
// couponOrderRelevance.setAchievement(couponCustomerRelevance.getPayAmount());
// } else {
// couponOrderRelevance.setAchievement(couponOrderRelevance.getDiscountAmount());
// }
//
// //业绩
// orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(couponCustomerRelevance.getPayAmount()));
//
// orderServe.addDiscountPrice(actualDiscountAmount);
// orderManage.addDiscountPrice(actualDiscountAmount);
// orderServe.setBindOuterCoupon(1);
// couponOrderRelevanceService.save(couponOrderRelevance);
//
// } else {
// throw new RRException("外部券冲突");
// }
//
// });
// }
// //5.内部券
// if (ListUtil.isNotEmpty(innerCouponCustomerRelevanceServiceList)) {
//
// innerCouponCustomerRelevanceServiceList
// .forEach(couponCustomerRelevance -> {
// //内部券能用的服务id
// List<Integer> serveIds = couponCustomerRelevanceMapper.queryCouponCustomerServeRelevance(couponCustomerRelevance.getCouponId());
//
// //作用的服务id
// List<OrderServe> canUserOrderServeList = this.queryCanDiscount(orderManage, serveIds, couponCustomerRelevance.getCouponId());
//
// //打折订单项总支付金额
// BigDecimal total = canUserOrderServeList.stream().map(OrderServe::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
//
// if (!total.setScale(2, BigDecimal.ROUND_HALF_UP).equals(BigDecimal.ZERO.setScale(2, BigDecimal.ROUND_HALF_UP))) {
// //卡券的总折扣金额
// BigDecimal totalCouponDiscount = couponCustomerRelevance.getDiscountAmount();
// //卡券总支付金额
// BigDecimal totalCouponPay = couponCustomerRelevance.getPayAmount();
//
// //计算参数(最后一个订单服务的折扣金额要用总折扣金额减 防止除法计算精度问题)
// BigDecimal discountCalc = BigDecimal.ZERO;
//
// //计算参数(最后一个订单服务的实际支付要用总实际支付金额减 防止除法计算精度问题)
// BigDecimal payCalc = BigDecimal.ZERO;
//
// for (OrderServe orderServe : canUserOrderServeList) {
//
// //每个服务的内部券抵扣金额
// BigDecimal discountAmount = orderServe.getPayPrice().multiply(totalCouponDiscount).divide(total, 2, BigDecimal.ROUND_HALF_UP);
// //每个服务的卡券实际支付金额
// BigDecimal payAmount = orderServe.getPayPrice().multiply(totalCouponPay).divide(total, 2, BigDecimal.ROUND_HALF_UP);
//
//
// //最后一个服务使用总额减法而不是除法
// if (canUserOrderServeList.lastIndexOf(orderServe) == canUserOrderServeList.size() - 1) {
// discountAmount = totalCouponDiscount.subtract(discountCalc);
// payAmount = totalCouponPay.subtract(payCalc);
// }
// BigDecimal actualDiscountAmount = discountAmount.min(orderServe.getPayPrice());
//
// //卡券在订单服务上的抵扣情况
// CouponOrderRelevance couponOrderRelevance = CouponOrderRelevance.builder()
// .discountAmount(actualDiscountAmount)
// //卡券在这个服务上的实际支付金额
// .payForOrderServe(payAmount)
// .createTime(new Date())
// .orderServeId(orderServe.getId())
// .orderId(orderManage.getId())
// .couponId(couponCustomerRelevance.getCouponId())
// .couponCustomerRelevanceId(couponCustomerRelevance.getId())
// .confirmTime(new Date())
// .message(orderServe.getServeName())
// .customerId(orderManage.getOrderUser())
// .status(2)
// .build();
//
// //如果计算业绩
// if (couponCustomerRelevance.getIsCalcAchievement() == 1) {
// couponOrderRelevance.setAchievement(couponCustomerRelevance.getPayAmount());
// } else {
// couponOrderRelevance.setAchievement(couponOrderRelevance.getDiscountAmount());
// }
//
// //免单券Id
// List<Integer> discountConfigListCouponId = discountConfigMapper.selectList(new QueryWrapper<>()).stream().map(DiscountConfig::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
// //如果不是免单券 业绩就要扣除实际折扣金额
// if (!discountConfigListCouponId.contains(couponCustomerRelevance.getCouponId())) {
// orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount));
// }
//
// orderServe.addDiscountPrice(actualDiscountAmount);
// orderManage.addDiscountPrice(actualDiscountAmount);
//
// orderServe.setBindInnerCoupon(1);
// discountCalc = discountCalc.add(discountAmount);
// payCalc = payCalc.add(payAmount);
// }
// }
// //内部券抵扣不了
// else {
// throw new RRException("内部券冲突");
// }
// });
// }
// });
// }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment