diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailController.java b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailController.java index afbf9eb1..40421815 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailController.java @@ -1247,11 +1247,39 @@ public class OrderDetailController extends BaseController { } // 修改子单状态为完单待确认状态,更新完单时间 + Date workFinishTime = new Date(); OrderDetail updateOrderDetail = new OrderDetail(); updateOrderDetail.setId(request.getOrderDetailId()); - updateOrderDetail.setWorkFinishTime(new Date()); + updateOrderDetail.setWorkFinishTime(workFinishTime); updateOrderDetail.setOrderStatus(OrderStatus.FINISH_CHECK.code()); updateOrderDetail.setRemark(request.getRemark()); + + // 查询订单商品对应的类目倒计时小时数,计算分账倒计时结束时间 + try { + List 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); Assert.isTrue(affectedRow == 1, "子订单修改失败,orderDetail=" + orderDetail); diff --git a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html index ea9256bd..0920ee59 100644 --- a/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html +++ b/ghy-admin/src/main/resources/templates/goods/deptcategory/edit.html @@ -252,6 +252,16 @@ +
+
+ +
+ +
+
+
diff --git a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java index 40655bc9..bc3836d6 100644 --- a/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java +++ b/ghy-goods/src/main/java/com/ghy/goods/domain/DeptGoodsCategory.java @@ -114,4 +114,7 @@ public class DeptGoodsCategory extends GoodsCategory { @Excel(name = "服务类目名称", cellType = Excel.ColumnType.STRING) private String serviceCategoryName; // 服务类目名称 + + @Excel(name = "倒计时小时数", cellType = Excel.ColumnType.NUMERIC) + private Integer countdownHours; // 倒计时小时数 } diff --git a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml index 8df74408..b3944d85 100644 --- a/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml +++ b/ghy-goods/src/main/resources/mapper/goods/DeptGoodsCategoryMapper.xml @@ -25,6 +25,7 @@ + @@ -47,7 +48,8 @@ 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, 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 @@ -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.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.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 FROM dept_goods_category dgc LEFT JOIN goods_category gc ON dgc.goods_category_id = gc.goods_category_id @@ -97,6 +99,7 @@ retain_money = #{retainMoney}, service_category_id = #{serviceCategoryId}, service_category_name = #{serviceCategoryName}, + countdown_hours = #{countdownHours}, pc_dept_rate = #{pcDeptRate}, pc_dept_money = #{pcDeptMoney}, @@ -140,6 +143,7 @@ retain_money, service_category_id, service_category_name, + countdown_hours, pc_dept_rate, pc_dept_money, @@ -167,6 +171,7 @@ #{retainMoney}, #{serviceCategoryId}, #{serviceCategoryName}, + #{countdownHours}, #{pcDeptRate}, #{pcDeptMoney}, diff --git a/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java b/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java index 20d72138..48c24f0b 100644 --- a/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java +++ b/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java @@ -7,8 +7,10 @@ import com.ghy.common.enums.WxMsgEnum; import com.ghy.common.utils.WechatMsgUtils; import com.ghy.customer.domain.CustomerAddress; import com.ghy.customer.service.CustomerAddressService; +import com.ghy.goods.domain.DeptGoodsCategory; import com.ghy.goods.domain.Goods; import com.ghy.goods.domain.GoodsStandard; +import com.ghy.goods.service.DeptGoodsCategoryService; import com.ghy.goods.service.GoodsService; import com.ghy.goods.service.GoodsStandardService; import com.ghy.order.domain.*; @@ -62,7 +64,8 @@ public class OrderServiceImpl implements OrderService { private static final Integer ZERO = 0; private static final Integer ONE = 1; private static final Integer TWO = 2; - + @Resource + private DeptGoodsCategoryService deptGoodsCategoryService; /** * 需要超时扣款的订单状态 * @@ -658,10 +661,15 @@ public class OrderServiceImpl implements OrderService { // 查询出"待确认"状态的子订单 List orderDetails = orderDetailService.selectByStatus(Collections.singletonList(OrderStatus.FINISH_CHECK.code())); long now = System.currentTimeMillis(); - //TODO:测试完毕以后改为60分钟 - long day14ago = now - (60 * 60 * 1000L); + // long day14ago = now - 10000L; for (OrderDetail orderDetail : orderDetails) { + int hours=orderDetail.getShareAccountCountdownDuration(); + // 超时时间 + //TODO:修改为后台类目配置时间 + + long day14ago = now - (hours*60 * 60 * 1000L); + // 筛选符合自动确认的订单 if (day14ago > orderDetail.getWorkFinishTime().getTime()) { log.info("子订单自动完成[id={}, code={}]", orderDetail.getId(), orderDetail.getCode()); @@ -1478,7 +1486,35 @@ public class OrderServiceImpl implements OrderService { // 检查是否到达目标时间 if (now.after(targetTime) && orderMaster.getPayStatus() == 1) { log.info("订单[{}]确认截止时间已到,开始转为确认中状态", orderDetail.getCode()); - orderDetail.setWorkFinishTime(new Date()); + Date workFinishTime = new Date(); + orderDetail.setWorkFinishTime(workFinishTime); + + // 查询订单商品对应的类目倒计时小时数,计算分账倒计时结束时间 + try { + List 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); // 更新订单状态为确认中 int result = orderDetailService.updateStatus(orderDetail.getId(), OrderStatus.FINISH_CHECK.code());