增加类目倒计时小时数 增加新字段来表示分账结束时间

This commit is contained in:
cb 2025-09-11 11:47:57 +08:00
parent 87bcdda6f8
commit 5cc6d5736d
5 changed files with 89 additions and 7 deletions

View File

@ -1247,11 +1247,39 @@ public class OrderDetailController extends BaseController {
} }
// 修改子单状态为完单待确认状态更新完单时间 // 修改子单状态为完单待确认状态更新完单时间
Date workFinishTime = new Date();
OrderDetail updateOrderDetail = new OrderDetail(); OrderDetail updateOrderDetail = new OrderDetail();
updateOrderDetail.setId(request.getOrderDetailId()); updateOrderDetail.setId(request.getOrderDetailId());
updateOrderDetail.setWorkFinishTime(new Date()); updateOrderDetail.setWorkFinishTime(workFinishTime);
updateOrderDetail.setOrderStatus(OrderStatus.FINISH_CHECK.code()); updateOrderDetail.setOrderStatus(OrderStatus.FINISH_CHECK.code());
updateOrderDetail.setRemark(request.getRemark()); updateOrderDetail.setRemark(request.getRemark());
// 查询订单商品对应的类目倒计时小时数计算分账倒计时结束时间
try {
List<OrderGoods> orderGoodsList = orderGoodsService.selectByOrderDetailId(request.getOrderDetailId());
if (CollectionUtils.isNotEmpty(orderGoodsList)) {
// 取第一个商品的规格ID查询类目信息
OrderGoods firstOrderGoods = orderGoodsList.get(0);
GoodsStandard goodsStandard = goodsStandardService.selectById(firstOrderGoods.getGoodsStandardId());
if (goodsStandard != null && goodsStandard.getDeptGoodsCategoryId() != null) {
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId());
if (deptGoodsCategory != null && deptGoodsCategory.getCountdownHours() != null) {
// 计算分账倒计时结束时间workFinishTime + 倒计时小时数
long countdownMillis = deptGoodsCategory.getCountdownHours() * 60 * 60 * 1000L;
Date shareAccountCountdownEndTime = new Date(workFinishTime.getTime() + countdownMillis);
updateOrderDetail.setShareAccountCountdownEndTime(shareAccountCountdownEndTime);
updateOrderDetail.setShareAccountCountdownDuration(deptGoodsCategory.getCountdownHours());
logger.info("订单[{}]设置分账倒计时:完单时间={}, 倒计时小时数={}, 分账倒计时结束时间={}",
request.getOrderDetailId(), workFinishTime, deptGoodsCategory.getCountdownHours(), shareAccountCountdownEndTime);
}
}
}
} catch (Exception e) {
logger.error("设置分账倒计时失败订单ID{}", request.getOrderDetailId(), e);
}
int affectedRow = orderDetailService.updateOrderDetail(updateOrderDetail); int affectedRow = orderDetailService.updateOrderDetail(updateOrderDetail);
Assert.isTrue(affectedRow == 1, "子订单修改失败orderDetail=" + orderDetail); Assert.isTrue(affectedRow == 1, "子订单修改失败orderDetail=" + orderDetail);

View File

@ -252,6 +252,16 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-6 control-label is-required">倒计时小时数:</label>
<div class="col-sm-6">
<input name="countdownHours" placeholder="请输入倒计时小时数" class="form-control" type="number" min="1" max="168"
th:field="*{countdownHours}"
required>
</div>
</div>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="row"> <div class="row">

View File

@ -114,4 +114,7 @@ public class DeptGoodsCategory extends GoodsCategory {
@Excel(name = "服务类目名称", cellType = Excel.ColumnType.STRING) @Excel(name = "服务类目名称", cellType = Excel.ColumnType.STRING)
private String serviceCategoryName; // 服务类目名称 private String serviceCategoryName; // 服务类目名称
@Excel(name = "倒计时小时数", cellType = Excel.ColumnType.NUMERIC)
private Integer countdownHours; // 倒计时小时数
} }

View File

@ -25,6 +25,7 @@
<result property="retainMoney" column="retain_money"/> <result property="retainMoney" column="retain_money"/>
<result property="serviceCategoryId" column="service_category_id"/> <result property="serviceCategoryId" column="service_category_id"/>
<result property="serviceCategoryName" column="service_category_name"/> <result property="serviceCategoryName" column="service_category_name"/>
<result property="countdownHours" column="countdown_hours"/>
<!-- pc扣点部分 start--> <!-- pc扣点部分 start-->
<result property="pcOneRate" column="pc_one_rate"/> <result property="pcOneRate" column="pc_one_rate"/>
<result property="pcTwoRate" column="pc_two_rate"/> <result property="pcTwoRate" column="pc_two_rate"/>
@ -47,7 +48,8 @@
SELECT dept_goods_category_id, dept_id, goods_category_id, category_sort, is_hot, cover, hot_name, SELECT dept_goods_category_id, dept_id, goods_category_id, category_sort, is_hot, cover, hot_name,
simple_goods_category_name, is_sure, is_cert, one_rate, two_rate, three_rate, dept_rate, simple_goods_category_name, is_sure, is_cert, one_rate, two_rate, three_rate, dept_rate,
pc_one_rate, pc_two_rate, pc_three_rate, pc_dept_rate, pc_dept_money, pc_retain_rate, pc_retain_money, pc_one_rate, pc_two_rate, pc_three_rate, pc_dept_rate, pc_dept_money, pc_retain_rate, pc_retain_money,
dept_money, retain_rate, retain_money, create_by, create_time, remark, service_category_id, service_category_name dept_money, retain_rate, retain_money, create_by, create_time, remark, service_category_id, service_category_name,
countdown_hours
FROM dept_goods_category FROM dept_goods_category
</sql> </sql>
@ -57,7 +59,7 @@
dgc.is_hot, dgc.cover, dgc.hot_name, dgc.is_sure, dgc.is_cert, dgc.dept_rate, dgc.dept_money, dgc.is_hot, dgc.cover, dgc.hot_name, dgc.is_sure, dgc.is_cert, dgc.dept_rate, dgc.dept_money,
dgc.retain_rate, dgc.retain_money, dgc.simple_goods_category_name, dgc.retain_rate, dgc.retain_money, dgc.simple_goods_category_name,
dgc.pc_one_rate, dgc.pc_two_rate, dgc.pc_three_rate, dgc.pc_dept_rate, dgc.pc_dept_money, dgc.pc_retain_rate, dgc.pc_retain_money, dgc.pc_one_rate, dgc.pc_two_rate, dgc.pc_three_rate, dgc.pc_dept_rate, dgc.pc_dept_money, dgc.pc_retain_rate, dgc.pc_retain_money,
dgc.service_category_id, dgc.service_category_name, dgc.service_category_id, dgc.service_category_name, dgc.countdown_hours,
gc.goods_category_name, gc.level, gc.parent_category_id, gc.type, gc.status gc.goods_category_name, gc.level, gc.parent_category_id, gc.type, gc.status
FROM dept_goods_category dgc LEFT JOIN goods_category gc ON dgc.goods_category_id = gc.goods_category_id FROM dept_goods_category dgc LEFT JOIN goods_category gc ON dgc.goods_category_id = gc.goods_category_id
</sql> </sql>
@ -97,6 +99,7 @@
<if test="retainMoney != null">retain_money = #{retainMoney},</if> <if test="retainMoney != null">retain_money = #{retainMoney},</if>
<if test="serviceCategoryId != null">service_category_id = #{serviceCategoryId},</if> <if test="serviceCategoryId != null">service_category_id = #{serviceCategoryId},</if>
<if test="serviceCategoryName != null and serviceCategoryName != ''">service_category_name = #{serviceCategoryName},</if> <if test="serviceCategoryName != null and serviceCategoryName != ''">service_category_name = #{serviceCategoryName},</if>
<if test="countdownHours != null">countdown_hours = #{countdownHours},</if>
<if test="pcDeptRate != null and pcDeptRate != ''">pc_dept_rate = #{pcDeptRate},</if> <if test="pcDeptRate != null and pcDeptRate != ''">pc_dept_rate = #{pcDeptRate},</if>
<if test="pcDeptMoney != null">pc_dept_money = #{pcDeptMoney},</if> <if test="pcDeptMoney != null">pc_dept_money = #{pcDeptMoney},</if>
@ -140,6 +143,7 @@
<if test="retainMoney != null and retainMoney != ''">retain_money,</if> <if test="retainMoney != null and retainMoney != ''">retain_money,</if>
<if test="serviceCategoryId != null">service_category_id,</if> <if test="serviceCategoryId != null">service_category_id,</if>
<if test="serviceCategoryName != null and serviceCategoryName != ''">service_category_name,</if> <if test="serviceCategoryName != null and serviceCategoryName != ''">service_category_name,</if>
<if test="countdownHours != null">countdown_hours,</if>
<if test="pcDeptRate != null and pcDeptRate != ''">pc_dept_rate,</if> <if test="pcDeptRate != null and pcDeptRate != ''">pc_dept_rate,</if>
<if test="pcDeptMoney != null and pcDeptMoney != ''">pc_dept_money,</if> <if test="pcDeptMoney != null and pcDeptMoney != ''">pc_dept_money,</if>
@ -167,6 +171,7 @@
<if test="retainMoney != null and retainMoney != ''">#{retainMoney},</if> <if test="retainMoney != null and retainMoney != ''">#{retainMoney},</if>
<if test="serviceCategoryId != null">#{serviceCategoryId},</if> <if test="serviceCategoryId != null">#{serviceCategoryId},</if>
<if test="serviceCategoryName != null and serviceCategoryName != ''">#{serviceCategoryName},</if> <if test="serviceCategoryName != null and serviceCategoryName != ''">#{serviceCategoryName},</if>
<if test="countdownHours != null">#{countdownHours},</if>
<if test="pcDeptRate != null and pcDeptRate != ''">#{pcDeptRate},</if> <if test="pcDeptRate != null and pcDeptRate != ''">#{pcDeptRate},</if>
<if test="pcDeptMoney != null and pcDeptMoney != ''">#{pcDeptMoney},</if> <if test="pcDeptMoney != null and pcDeptMoney != ''">#{pcDeptMoney},</if>

View File

@ -7,8 +7,10 @@ import com.ghy.common.enums.WxMsgEnum;
import com.ghy.common.utils.WechatMsgUtils; import com.ghy.common.utils.WechatMsgUtils;
import com.ghy.customer.domain.CustomerAddress; import com.ghy.customer.domain.CustomerAddress;
import com.ghy.customer.service.CustomerAddressService; import com.ghy.customer.service.CustomerAddressService;
import com.ghy.goods.domain.DeptGoodsCategory;
import com.ghy.goods.domain.Goods; import com.ghy.goods.domain.Goods;
import com.ghy.goods.domain.GoodsStandard; import com.ghy.goods.domain.GoodsStandard;
import com.ghy.goods.service.DeptGoodsCategoryService;
import com.ghy.goods.service.GoodsService; import com.ghy.goods.service.GoodsService;
import com.ghy.goods.service.GoodsStandardService; import com.ghy.goods.service.GoodsStandardService;
import com.ghy.order.domain.*; import com.ghy.order.domain.*;
@ -62,7 +64,8 @@ public class OrderServiceImpl implements OrderService {
private static final Integer ZERO = 0; private static final Integer ZERO = 0;
private static final Integer ONE = 1; private static final Integer ONE = 1;
private static final Integer TWO = 2; private static final Integer TWO = 2;
@Resource
private DeptGoodsCategoryService deptGoodsCategoryService;
/** /**
* 需要超时扣款的订单状态 * 需要超时扣款的订单状态
* *
@ -658,10 +661,15 @@ public class OrderServiceImpl implements OrderService {
// 查询出"待确认"状态的子订单 // 查询出"待确认"状态的子订单
List<OrderDetail> orderDetails = orderDetailService.selectByStatus(Collections.singletonList(OrderStatus.FINISH_CHECK.code())); List<OrderDetail> orderDetails = orderDetailService.selectByStatus(Collections.singletonList(OrderStatus.FINISH_CHECK.code()));
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
//TODO:测试完毕以后改为60分钟
long day14ago = now - (60 * 60 * 1000L);
// long day14ago = now - 10000L; // long day14ago = now - 10000L;
for (OrderDetail orderDetail : orderDetails) { for (OrderDetail orderDetail : orderDetails) {
int hours=orderDetail.getShareAccountCountdownDuration();
// 超时时间
//TODO:修改为后台类目配置时间
long day14ago = now - (hours*60 * 60 * 1000L);
// 筛选符合自动确认的订单 // 筛选符合自动确认的订单
if (day14ago > orderDetail.getWorkFinishTime().getTime()) { if (day14ago > orderDetail.getWorkFinishTime().getTime()) {
log.info("子订单自动完成[id={}, code={}]", orderDetail.getId(), orderDetail.getCode()); log.info("子订单自动完成[id={}, code={}]", orderDetail.getId(), orderDetail.getCode());
@ -1478,7 +1486,35 @@ public class OrderServiceImpl implements OrderService {
// 检查是否到达目标时间 // 检查是否到达目标时间
if (now.after(targetTime) && orderMaster.getPayStatus() == 1) { if (now.after(targetTime) && orderMaster.getPayStatus() == 1) {
log.info("订单[{}]确认截止时间已到,开始转为确认中状态", orderDetail.getCode()); log.info("订单[{}]确认截止时间已到,开始转为确认中状态", orderDetail.getCode());
orderDetail.setWorkFinishTime(new Date()); Date workFinishTime = new Date();
orderDetail.setWorkFinishTime(workFinishTime);
// 查询订单商品对应的类目倒计时小时数计算分账倒计时结束时间
try {
List<OrderGoods> orderGoodsList = orderGoodsService.selectByOrderDetailId(orderDetail.getId());
if (orderGoodsList.size()>0) {
// 取第一个商品的规格ID查询类目信息
OrderGoods firstOrderGoods = orderGoodsList.get(0);
GoodsStandard goodsStandard = goodsStandardService.selectById(firstOrderGoods.getGoodsStandardId());
if (goodsStandard != null && goodsStandard.getDeptGoodsCategoryId() != null) {
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId());
if (deptGoodsCategory != null && deptGoodsCategory.getCountdownHours() != null) {
// 计算分账倒计时结束时间workFinishTime + 倒计时小时数
long countdownMillis = deptGoodsCategory.getCountdownHours() * 60 * 60 * 1000L;
Date shareAccountCountdownEndTime = new Date(workFinishTime.getTime() + countdownMillis);
orderDetail.setShareAccountCountdownEndTime(shareAccountCountdownEndTime);
orderDetail.setShareAccountCountdownDuration(deptGoodsCategory.getCountdownHours());
log.info("订单[{}]设置分账倒计时:完单时间={}, 倒计时小时数={}, 分账倒计时结束时间={}",
orderDetail.getCode(), workFinishTime, deptGoodsCategory.getCountdownHours(), shareAccountCountdownEndTime);
}
}
}
} catch (Exception e) {
log.error("设置分账倒计时失败订单ID{}", orderDetail.getId(), e);
}
orderDetailService.updateOrderDetail(orderDetail); orderDetailService.updateOrderDetail(orderDetail);
// 更新订单状态为确认中 // 更新订单状态为确认中
int result = orderDetailService.updateStatus(orderDetail.getId(), OrderStatus.FINISH_CHECK.code()); int result = orderDetailService.updateStatus(orderDetail.getId(), OrderStatus.FINISH_CHECK.code());