|
@@ -6,12 +6,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ylx.common.constant.MassageConstants;
|
|
|
import com.ylx.common.core.domain.entity.SysDept;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
-import com.ylx.massage.domain.TJs;
|
|
|
-import com.ylx.massage.domain.TJsDay;
|
|
|
-import com.ylx.massage.domain.TOrder;
|
|
|
-import com.ylx.massage.domain.TSign;
|
|
|
+import com.ylx.massage.domain.*;
|
|
|
+import com.ylx.massage.enums.BillTypeEnum;
|
|
|
import com.ylx.massage.enums.JsStatusEnum;
|
|
|
import com.ylx.massage.enums.OrderStatusEnum;
|
|
|
+import com.ylx.massage.mapper.TConsumptionLogMapper;
|
|
|
import com.ylx.massage.service.*;
|
|
|
import com.ylx.massage.utils.DateTimeUtils;
|
|
|
import com.ylx.system.service.ISysDeptService;
|
|
@@ -21,6 +20,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -50,6 +50,15 @@ public class massageTask {
|
|
|
@Resource
|
|
|
private TJsDayService jsDayService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TConsumptionLogService consumptionLogService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TConsumptionLogMapper consumptionLogMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private TWxUserService userService;
|
|
|
+
|
|
|
|
|
|
public void cancelOrder() {
|
|
|
|
|
@@ -91,17 +100,16 @@ public class massageTask {
|
|
|
public void timeoutNotOrder() {
|
|
|
|
|
|
Date nowDate = new Date();
|
|
|
- log.info("开始执行取消订单任务当前时间,{}", nowDate);
|
|
|
+ log.info("开始执行超时未接单任务,{}", nowDate);
|
|
|
|
|
|
Date date = DateTimeUtils.addMinute(nowDate, -10);
|
|
|
- log.info("开始执行取消订单任务当前时间减5分钟,{}", date);
|
|
|
+ log.info("开始执行超时未接单任务当前时间减10分钟,{}", date);
|
|
|
long total = 1L;
|
|
|
while (total > 0L) {
|
|
|
total = timeoutNotOrder(date);
|
|
|
}
|
|
|
}
|
|
|
private Long timeoutNotOrder(Date nowDate) {
|
|
|
- log.info("extracted 开始执行取消订单任务时间,{}", nowDate);
|
|
|
LambdaQueryWrapper<TOrder> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
objectLambdaQueryWrapper.eq(TOrder::getnStatus, OrderStatusEnum.WAIT_JD.getCode()).
|
|
|
le(TOrder::getPayTime, nowDate).
|
|
@@ -114,7 +122,6 @@ public class massageTask {
|
|
|
if (CollectionUtil.isNotEmpty(resPage.getRecords())) {
|
|
|
resPage.getRecords().forEach(order -> {
|
|
|
//调用拒绝接单
|
|
|
- //todo 订单锁
|
|
|
order.setReasonRefusal("超时未接单");
|
|
|
orderService.jujue(order);
|
|
|
});
|
|
@@ -123,6 +130,58 @@ public class massageTask {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public void isGetAmount() {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ log.info("定时分配出账金额日期,{}", nowDate);
|
|
|
+
|
|
|
+ Date date = DateTimeUtils.addDays(nowDate, -7);
|
|
|
+ log.info("定时分配出账金额日期,{}", date);
|
|
|
+ isGetAmount(date);
|
|
|
+ }
|
|
|
+ private void isGetAmount(Date date) {
|
|
|
+
|
|
|
+ //查询所有部门
|
|
|
+ List<SysDept> sysDepts = deptService.selectDeptList(new SysDept());
|
|
|
+ //遍历部门技师
|
|
|
+ sysDepts.forEach(sysDept -> {
|
|
|
+ LambdaQueryWrapper<TJs> jsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ jsLambdaQueryWrapper.eq(TJs::getnTong, JsStatusEnum.JS_PASS.getCode()).eq(TJs::getDeptId, sysDept.getDeptId());
|
|
|
+ List<TJs> jsList = jsService.list(jsLambdaQueryWrapper);
|
|
|
+ if (CollectionUtil.isNotEmpty(jsList)) {
|
|
|
+ jsList.forEach(js -> {
|
|
|
+ //根据技师openId 查询未领取金额
|
|
|
+ LambdaQueryWrapper<TConsumptionLog> logLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ logLambdaQueryWrapper.eq(TConsumptionLog::getIsGet, MassageConstants.INTEGER_ZERO).
|
|
|
+ eq(TConsumptionLog::getOpenId, js.getcOpenId()).
|
|
|
+ in(TConsumptionLog::getBillType, Arrays.asList(BillTypeEnum.INCOME.getCode(),BillTypeEnum.DISTRIBUTION.getCode())).
|
|
|
+ le(TConsumptionLog::getCreateTime, date).
|
|
|
+ orderByAsc(TConsumptionLog::getCreateTime);
|
|
|
+ List<TConsumptionLog> consumptionLogList = consumptionLogService.list(logLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(consumptionLogList)) {
|
|
|
+ //处理可提现金额
|
|
|
+ //1.修改余额记录状态
|
|
|
+ consumptionLogList.forEach(consumptionLog -> {
|
|
|
+ //修改状态未已到提现账户
|
|
|
+ consumptionLog.setIsGet(MassageConstants.INTEGER_ONE);
|
|
|
+ });
|
|
|
+ int i = consumptionLogMapper.insertOrUpdateBatch(consumptionLogList);
|
|
|
+ //2.修改技师提现账户
|
|
|
+ BigDecimal getAmount = consumptionLogList.stream().map(TConsumptionLog::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ TWxUser user = userService.getByOpenId(js.getcOpenId());
|
|
|
+ user.setGetAmount(user.getGetAmount().add(getAmount));
|
|
|
+ userService.updateById(user);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public void cancelNewJs() {
|
|
|
|
|
|
Date nowDate = new Date();
|