|
|
@@ -62,9 +62,9 @@ import com.sqx.modules.order.entity.Evaluate;
|
|
|
import com.sqx.modules.order.entity.OrderGoods;
|
|
|
import com.sqx.modules.order.entity.TbOrder;
|
|
|
import com.sqx.modules.order.service.AppOrderService;
|
|
|
-import com.sqx.modules.pay.dto.PayOrderDTO;
|
|
|
import com.sqx.modules.pay.controller.app.AliPayController;
|
|
|
import com.sqx.modules.pay.dao.PayDetailsDao;
|
|
|
+import com.sqx.modules.pay.dto.PayOrderDTO;
|
|
|
import com.sqx.modules.pay.entity.PayDetails;
|
|
|
import com.sqx.modules.pay.service.WxErrService;
|
|
|
import com.sqx.modules.shop.service.ShopMessageService;
|
|
|
@@ -395,8 +395,11 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 注意:调用shopMessageService获取店铺信息,这个service对店铺的抽成比例有特殊处理(历史代码就是如此/(ㄒoㄒ)/~~)
|
|
|
GoodsShop goodsShop = shopMessageService.selectShopId(parentOrder.getShopId());
|
|
|
|
|
|
- // 设置订单类型
|
|
|
- parentOrder.setOrderType(payOrderDTO.getOrderType());
|
|
|
+ // // 设置订单类型
|
|
|
+ // parentOrder.setOrderType(payOrderDTO.getOrderType());
|
|
|
+
|
|
|
+ // 校验订单类型
|
|
|
+ checkOrderType(parentOrder, payOrderDTO, goodsShop);
|
|
|
|
|
|
// 校验订单信息
|
|
|
checkOrderGoods(parentOrder);
|
|
|
@@ -419,6 +422,64 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
return parentOrder;
|
|
|
}
|
|
|
|
|
|
+ private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DateUtils.TIME_PATTERN1);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验订单类型
|
|
|
+ */
|
|
|
+ private void checkOrderType(TbOrder order, PayOrderDTO payOrderDTO, GoodsShop goodsShop) {
|
|
|
+ Integer orderType = payOrderDTO.getOrderType();
|
|
|
+
|
|
|
+ String reservationFlag = payOrderDTO.getReservationFlag();
|
|
|
+ if (StrUtil.equals(reservationFlag, Constant.YES)) {
|
|
|
+ if (ObjectUtil.isNull(payOrderDTO.getExpectDeliveryTime())) {
|
|
|
+ throw new SqxException("预约订单期望送达时间不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2 外卖订单
|
|
|
+ if (orderType == 2) {
|
|
|
+ // 店铺是否开启自动派单 0开启 1关闭
|
|
|
+ Integer autoSendOrder = goodsShop.getAutoSendOrder() == 0 ? 0 : 1;
|
|
|
+
|
|
|
+ // 设置订单类型拓展 1上门 2骑手配送 3商家配送
|
|
|
+ if (autoSendOrder == 1) {
|
|
|
+ order.setOrderTypeExtra(3);
|
|
|
+ } else {
|
|
|
+ order.setOrderTypeExtra(2);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ order.setOrderTypeExtra(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 骑手配送订单
|
|
|
+ if (2 == order.getOrderTypeExtra()) {
|
|
|
+ // 骑手工作时间段
|
|
|
+ String workingHoursOfRider = commonInfoService.findOne(422).getValue();
|
|
|
+ String[] split = workingHoursOfRider.split("-");
|
|
|
+ String startTimeStr = split[0];
|
|
|
+ String endTimeStr = split[1];
|
|
|
+
|
|
|
+ LocalTime startTime = LocalTime.parse(startTimeStr, DTF);
|
|
|
+ LocalTime endTime = LocalTime.parse(endTimeStr, DTF);
|
|
|
+ LocalTime nowTime = LocalTime.now();
|
|
|
+
|
|
|
+ // 非骑手上班期间且不是预定订单则进行错误提示
|
|
|
+ if (nowTime.isAfter(endTime) || nowTime.isBefore(startTime)) {
|
|
|
+ if (!StrUtil.equals(reservationFlag, Constant.YES)) {
|
|
|
+ throw new SqxException("当前时间不能直接下单,请选择预约下单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置订单是否预约单及期望送达时间
|
|
|
+ order.setReservationFlag(reservationFlag);
|
|
|
+ order.setExpectDeliveryTime(payOrderDTO.getExpectDeliveryTime());
|
|
|
+
|
|
|
+ // 设置订单类型
|
|
|
+ order.setOrderType(orderType);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 检查活动信息
|
|
|
* @param activityId 活动id
|
|
|
@@ -492,9 +553,13 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 添加消息记录并且进行推送
|
|
|
addOrderMessageAndPush(order, goodsShop, mpPushConfig, userEntity);
|
|
|
|
|
|
- // 判断店铺是否设置自动接单
|
|
|
+ // 是否自动接单
|
|
|
boolean autoAccept = goodsShop.getAutoAcceptOrder() != null && goodsShop.getAutoAcceptOrder() == 0;
|
|
|
- if(autoAccept) {
|
|
|
+ // 是否预约订单
|
|
|
+ boolean reservationFlag = StrUtil.equals(order.getReservationFlag(), Constant.YES);
|
|
|
+
|
|
|
+ // 店铺自动接单且当前订单不是预约订单
|
|
|
+ if(autoAccept && !reservationFlag) {
|
|
|
// 6制作中
|
|
|
order.setStatus(6);
|
|
|
order.setShopReceivingTime(currentTimeStr);
|
|
|
@@ -509,18 +574,23 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 扣减库存
|
|
|
this.subStock(order);
|
|
|
|
|
|
- // 如果是外卖订单,则生成一个跑腿的订单
|
|
|
- tbIndentService.insertIndent(order);
|
|
|
-
|
|
|
// 优惠券变成已使用状态
|
|
|
updateCouponState(order);
|
|
|
|
|
|
// 如果是支付宝或者微信支付,用户钱包新增消费记录
|
|
|
addConsumeRecordInUserMoneyDetail(order);
|
|
|
|
|
|
- if (autoAccept) {
|
|
|
+ // 已接单状态的订单生成跑腿订单
|
|
|
+ if (order.getStatus() == 6) {
|
|
|
+ // 如果是外卖订单,则生成一个跑腿的订单
|
|
|
+ tbIndentService.insertIndent(order);
|
|
|
+
|
|
|
// 发送商家接单通知
|
|
|
sendOrderAcceptMessage(order, goodsShop, mpPushConfig, userEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 订单已接单或者当前订单为预约订单时打印小票
|
|
|
+ if (order.getStatus() == 6 || reservationFlag) {
|
|
|
// 打印小票
|
|
|
if (StringUtils.isNotEmpty(goodsShop.getSnCode())) {
|
|
|
// 查询当天店铺所有已支付的订单号,按支付时间排序
|
|
|
@@ -857,13 +927,6 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 店铺是否开启自动派单 0开启 1关闭
|
|
|
Integer autoSendOrder = goodsShop.getAutoSendOrder() == 0 ? 0 : 1;
|
|
|
|
|
|
- // 设置订单类型拓展 1上门 2骑手配送 3商家配送
|
|
|
- if (autoSendOrder == 1) {
|
|
|
- order.setOrderTypeExtra(3);
|
|
|
- } else {
|
|
|
- order.setOrderTypeExtra(2);
|
|
|
- }
|
|
|
-
|
|
|
// 店铺开启了配送费满减
|
|
|
if (enableFullReductionFlag == 0) {
|
|
|
if(shopErrandMoney.doubleValue() > 0
|
|
|
@@ -910,9 +973,6 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
|
|
|
// 跑腿费设置为0
|
|
|
order.setErrandMoney(BigDecimal.ZERO);
|
|
|
-
|
|
|
- // 订单类型拓展 1上门 2骑手配送 3商家配送
|
|
|
- order.setOrderTypeExtra(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1487,8 +1547,15 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
if (tbOrder.getStatus().equals(6)) {
|
|
|
return Result.success();
|
|
|
}
|
|
|
+
|
|
|
+ // 修改订单状态
|
|
|
+ order.setStatus(6);
|
|
|
//商家接单
|
|
|
order.setShopReceivingTime(format1);
|
|
|
+
|
|
|
+ // 生成跑腿订单
|
|
|
+ tbIndentService.insertIndent(order);
|
|
|
+
|
|
|
//设置小程序消息推送
|
|
|
CommonInfo one = commonInfoService.findOne(269);
|
|
|
List<String> msgList = new ArrayList<>();
|
|
|
@@ -1504,7 +1571,6 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
userService.pushToSingle("商家已接单", "亲爱的用户您好,商家已接单,请耐心等待!", userEntity.getClientid());
|
|
|
|
|
|
//计算商户应得金额
|
|
|
-
|
|
|
BigDecimal shopRate = goodsShop.getShopRate();
|
|
|
BigDecimal sumMoney = tbOrder.getPayMoney();
|
|
|
if (tbOrder.getCouponId() != null) {
|
|
|
@@ -1521,11 +1587,15 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
tbOrder.setShopIncomeMoney(shopMoney);
|
|
|
|
|
|
SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 1);
|
|
|
- if (StringUtils.isNotEmpty(goodsShop.getSnCode())) {
|
|
|
- // 查询当天店铺所有已支付的订单号,按支付时间排序
|
|
|
- int sequence = selectCurrentOrderSequenceByShopId(tbOrder.getOrderId(), shopId);
|
|
|
- tbOrder.setCountOrder(sequence);
|
|
|
- FeiYunUtils.print(goodsShop.getSnCode(), null, tbOrder);
|
|
|
+
|
|
|
+ // 如果是预约订单,则不再打印小票(订单支付的时候已经打印过了)
|
|
|
+ if (!StrUtil.equals(order.getReservationFlag(), Constant.YES)) {
|
|
|
+ if (StringUtils.isNotEmpty(goodsShop.getSnCode())) {
|
|
|
+ // 查询当天店铺所有已支付的订单号,按支付时间排序
|
|
|
+ int sequence = selectCurrentOrderSequenceByShopId(tbOrder.getOrderId(), shopId);
|
|
|
+ tbOrder.setCountOrder(sequence);
|
|
|
+ FeiYunUtils.print(goodsShop.getSnCode(), null, tbOrder);
|
|
|
+ }
|
|
|
}
|
|
|
} else if (order.getStatus() == 3) {
|
|
|
if (tbOrder.getStatus().equals(3)) {
|