|
@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
|
|
import cn.binarywang.wx.miniapp.bean.express.result.WxMaExpressOrderInfoResult;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.yiqi.app.domain.AppGoodsMarket;
|
|
|
import com.yiqi.app.domain.vo.AppUserInfoVO;
|
|
@@ -24,6 +25,7 @@ import com.yiqi.common.utils.DateUtils;
|
|
|
import com.yiqi.common.utils.EnumUtils;
|
|
|
import com.yiqi.common.utils.OrderNoUtils;
|
|
|
import com.yiqi.common.utils.SecurityUtils;
|
|
|
+import com.yiqi.common.utils.pay.PayCodeUtils;
|
|
|
import com.yiqi.core.domain.GoodsInfo;
|
|
|
import com.yiqi.core.domain.GoodsSkuStore;
|
|
|
import com.yiqi.core.domain.dto.GoodsSkuStockRecordDTO;
|
|
@@ -31,6 +33,8 @@ import com.yiqi.core.domain.dto.GoodsUpdateSalesDTO;
|
|
|
import com.yiqi.core.service.IGoodsInfoService;
|
|
|
import com.yiqi.core.service.IGoodsSkuStockRecordService;
|
|
|
import com.yiqi.core.service.IGoodsSkuStoreService;
|
|
|
+import com.yiqi.delay.DelayMessage;
|
|
|
+import com.yiqi.delay.DelayQueueCache;
|
|
|
import com.yiqi.order.domain.*;
|
|
|
import com.yiqi.order.domain.dto.*;
|
|
|
import com.yiqi.order.domain.dto.weapp.AppGoodsOrderInfoQueryDTO;
|
|
@@ -55,7 +59,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
* @date 2023-12-06
|
|
|
*/
|
|
|
@Service
|
|
|
-public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoods> implements IOrderGoodsService {
|
|
|
+public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGoods> implements IOrderGoodsService {
|
|
|
|
|
|
@Autowired
|
|
|
private OrderNoUtils orderNoUtils;
|
|
@@ -93,7 +97,13 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Autowired
|
|
|
private IThirdDeliveryService thirdDeliveryService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderPayInfoService orderPayInfoService;
|
|
|
+ @Autowired
|
|
|
+ private DelayQueueCache delayQueueCache;
|
|
|
+
|
|
|
//<editor-folder desc="基础韩素">
|
|
|
+
|
|
|
/**
|
|
|
* 查询零售商品订单
|
|
|
*
|
|
@@ -113,6 +123,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* APP分页获取订单商品列表
|
|
|
+ *
|
|
|
* @param appGoodsOrderInfoQueryDTO
|
|
|
* @return
|
|
|
*/
|
|
@@ -120,12 +131,12 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
public List<AppGoodsOrderInfoQueryVO> getGoodsOrderListByApp(AppGoodsOrderInfoQueryDTO appGoodsOrderInfoQueryDTO) {
|
|
|
// 分页获取用户的商品订单
|
|
|
List<AppGoodsOrderInfoQueryVO> goodsOrderList = baseMapper.getGoodsOrderListByApp(appGoodsOrderInfoQueryDTO);
|
|
|
- if (CollUtil.isEmpty(goodsOrderList)){
|
|
|
+ if (CollUtil.isEmpty(goodsOrderList)) {
|
|
|
return goodsOrderList;
|
|
|
}
|
|
|
// 通过商品订单编号,获取物料集合商品数量
|
|
|
Map<String, List<OrderGoodsSku>> listMap = orderGoodsSkuService.list(new QueryWrapper<OrderGoodsSku>().lambda()
|
|
|
- .in(OrderGoodsSku::getOrderNo, goodsOrderList.stream().map(AppGoodsOrderInfoQueryVO::getOrderNo).collect(Collectors.toList())))
|
|
|
+ .in(OrderGoodsSku::getOrderNo, goodsOrderList.stream().map(AppGoodsOrderInfoQueryVO::getOrderNo).collect(Collectors.toList())))
|
|
|
.stream().collect(Collectors.groupingBy(OrderGoodsSku::getOrderNo));
|
|
|
// 获取订单商品信息
|
|
|
List<OrderRetailGoodsSkuVO> goodsSkuVOS = this.selectOrderGoodsByOrderNos(goodsOrderList.stream().map(AppGoodsOrderInfoQueryVO::getOrderNo).collect(Collectors.toList()));
|
|
@@ -133,11 +144,11 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
|
|
|
// 通过物料集合计算总件数
|
|
|
- goodsOrderList.forEach(goodsOrder ->{
|
|
|
- if (listMap.containsKey(goodsOrder.getOrderNo())){
|
|
|
+ goodsOrderList.forEach(goodsOrder -> {
|
|
|
+ if (listMap.containsKey(goodsOrder.getOrderNo())) {
|
|
|
goodsOrder.setGoodsNumber(listMap.get(goodsOrder.getOrderNo()).stream().mapToInt(OrderGoodsSku::getBuyNum).sum());
|
|
|
}
|
|
|
- if (map.containsKey(goodsOrder.getOrderNo())){
|
|
|
+ if (map.containsKey(goodsOrder.getOrderNo())) {
|
|
|
goodsOrder.setOrderGoodsSkuList(map.get(goodsOrder.getOrderNo()));
|
|
|
}
|
|
|
});
|
|
@@ -154,7 +165,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
public List<GoodsOrderQueryVO> selectOrderGoodsList(GoodsOrderQueryDTO goodsOrderQueryDTO) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
goodsOrderQueryDTO.setSourceType(user.getUserType());
|
|
|
- if (!SourceType.MANAGER.getCode().equals(user.getUserType())){
|
|
|
+ if (!SourceType.MANAGER.getCode().equals(user.getUserType())) {
|
|
|
goodsOrderQueryDTO.setOrgId(SourceType.STORE.getCode().equals(user.getUserType()) ? user.getStoreId() : user.getFactoryId());
|
|
|
}
|
|
|
return baseMapper.selectOrderGoodsList(goodsOrderQueryDTO);
|
|
@@ -170,23 +181,18 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public OrderGoodsPayResultVO insertRetailOrderGoods(OrderGoodsDTO orderGoodsDTO, List<OrderGoodsSkuInfoVO> orderGoodsSkuInfoVOS) {
|
|
|
+ public OrderPayResultVO insertRetailOrderGoods(OrderGoodsDTO orderGoodsDTO, List<OrderGoodsSkuInfoVO> orderGoodsSkuInfoVOS) {
|
|
|
// 保存零售商品订单
|
|
|
OrderGoods orderGoods = this.buildRetailOrderGoodsInfo(orderGoodsDTO, orderGoodsSkuInfoVOS);
|
|
|
- // 减库存
|
|
|
- List<OrderGoodsSku> orderGoodsSkus = this.handleMinusStock(orderGoods);
|
|
|
- // 出库记录
|
|
|
- this.buildStockRecord(orderGoods, orderGoodsSkus, Boolean.FALSE, Boolean.FALSE);
|
|
|
- //处理销售数量 - 新增销量
|
|
|
- this.buildUpdateGoodsSales(orderGoodsSkus, Boolean.TRUE);
|
|
|
// 处理支付流程
|
|
|
- return this.handlePay(orderGoods, orderGoodsDTO);
|
|
|
-
|
|
|
+ OrderPayResultVO orderPayResultVO = this.handlePay(orderGoods, orderGoodsDTO);
|
|
|
+ return orderPayResultVO;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 保存零售订单
|
|
|
+ *
|
|
|
* @param orderGoodsDTO
|
|
|
* @return
|
|
|
*/
|
|
@@ -197,28 +203,15 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
orderGoods.buildCreateData();
|
|
|
orderGoods.setGoodsOrderType(GoodsOrderType.retail.getCode());
|
|
|
orderGoods.setGoodsType(orderGoodsDTO.getGoodsType());
|
|
|
-// if (orderGoodsDTO.getIsDeduct()){
|
|
|
-//// orderGoods.setDeductAmount(orderGoodsDTO.getDeductAmount());
|
|
|
-// orderGoods.setDeductAmount(new BigDecimal(BigInteger.ZERO));
|
|
|
-// }else {
|
|
|
-// orderGoods.setDeductAmount(new BigDecimal(BigInteger.ZERO));
|
|
|
-// }
|
|
|
orderGoods.setDeductAmount(orderGoodsDTO.getDeductAmount());
|
|
|
- orderGoods.setCouponDeductAmount(orderGoodsDTO.getCouponDeductAmount() == null?BigDecimal.ZERO:orderGoodsDTO.getCouponDeductAmount());
|
|
|
+ orderGoods.setCouponDeductAmount(orderGoodsDTO.getCouponDeductAmount() == null ? BigDecimal.ZERO : orderGoodsDTO.getCouponDeductAmount());
|
|
|
orderGoods.setCashDeductAmount(orderGoodsDTO.getDeductAmount());
|
|
|
orderGoods.setPayAmount(orderGoodsDTO.getTotalPrice().subtract(orderGoods.getDeductAmount()));
|
|
|
-// orderGoods.setDeductPoint(orderGoodsDTO.getDeductPoint());
|
|
|
orderGoods.setOrderStatus(OrderGoodsStatusType.NO_PAY.getCode());
|
|
|
orderGoods.setDeliveryWay(this.getDeliveryWayByOrderSource(orderGoodsDTO.getOrderSource()));
|
|
|
orderGoods.setDelFlag(UserStatus.OK.getCode());
|
|
|
// 生成订单编号
|
|
|
orderGoods.setOrderNo(orderNoUtils.getGoodsOrderNo());
|
|
|
- // 设置APP用户扣款前余额
|
|
|
- RechargePasswordCard rechargePasswordCard = rechargePasswordCardService.selectTotalBalanceGroupByAppUser
|
|
|
- (orderGoodsDTO.getAppUserId());
|
|
|
- orderGoods.setAppUserBalanceAmount(rechargePasswordCard.getRechargeBalance()
|
|
|
- .add(rechargePasswordCard.getGiveBalance()));
|
|
|
-
|
|
|
this.save(orderGoods);
|
|
|
|
|
|
// 无法批量插入, orderGoodsSku.setOrderPurchaseGoodsItemId
|
|
@@ -254,16 +247,17 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 通过物料id,查询整个商品物料信息
|
|
|
+ *
|
|
|
* @param skuIdList
|
|
|
* @param orderSource
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public List<OrderGoodsSkuInfoVO> getSkuInfoList(List<Long> skuIdList, String orderSource) {
|
|
|
- if (OrderSourceType.APP.getCode().equals(orderSource)){
|
|
|
+ if (OrderSourceType.APP.getCode().equals(orderSource)) {
|
|
|
return goodsInfoService.getSkuInfoList(skuIdList, SourceType.MANAGER.getCode());
|
|
|
}
|
|
|
- if (OrderSourceType.OFFLINE.getCode().equals(orderSource)){
|
|
|
+ if (OrderSourceType.OFFLINE.getCode().equals(orderSource)) {
|
|
|
return goodsInfoService.getSkuInfoList(skuIdList, SourceType.STORE.getCode());
|
|
|
}
|
|
|
return null;
|
|
@@ -272,46 +266,81 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 处理支付
|
|
|
+ *
|
|
|
* @param orderGoods
|
|
|
* @param orderGoodsDTO
|
|
|
* @return
|
|
|
*/
|
|
|
- private OrderGoodsPayResultVO handlePay(OrderGoods orderGoods, OrderGoodsDTO orderGoodsDTO) {
|
|
|
- OrderGoodsPayResultVO orderGoodsPayResultVO = new OrderGoodsPayResultVO();
|
|
|
- orderGoodsPayResultVO.setOrderId(orderGoods.getId());
|
|
|
- orderGoodsPayResultVO.setOrderNo(orderGoods.getOrderNo());
|
|
|
- switch (EnumUtils.getEnumByType(orderGoods.getPayType(), PayType.class)) {
|
|
|
- //余额支付
|
|
|
- case CASH:
|
|
|
- // 现金
|
|
|
- case BALANCE: {
|
|
|
- // 扣余额
|
|
|
- this.handlePaySuccessUpdateOrderStatus(orderGoods.getOrderNo());
|
|
|
- break;
|
|
|
+ private OrderPayResultVO handlePay(OrderGoods orderGoods, OrderGoodsDTO orderGoodsDTO) {
|
|
|
+ OrderPayResultVO orderPayResultVO = null;
|
|
|
+ if (orderGoods == null) {
|
|
|
+ throw new ServiceException("未查询到订单");
|
|
|
+ }
|
|
|
+ if (!orderGoods.getOrderStatus().equals(OrderGoodsStatusType.NO_PAY.getCode())) {
|
|
|
+ throw new ServiceException("订单状态不正确支付");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (orderGoods.getPayType().equals(PayType.CASH.getCode()) && OrderSourceType.OFFLINE.getCode().equals(orderGoods.getOrderSource())) {
|
|
|
+ orderGoods.setPayType(PayType.CASH.getCode());
|
|
|
+ this.handlePaySuccessUpdateOrderStatus(orderGoods.getOrderNo(), null);
|
|
|
+ orderPayResultVO = OrderPayResultVO.paySuccess(orderGoods.getOrderNo());
|
|
|
+ orderPayResultVO.setOrderId(orderGoods.getId());
|
|
|
+ return orderPayResultVO;
|
|
|
+ }
|
|
|
+ if (orderGoods.getPayType().equals(PayType.WECHAT.getCode()) && OrderSourceType.OFFLINE.getCode().equals(orderGoods.getOrderSource())) {
|
|
|
+ String payType = null;
|
|
|
+ try {
|
|
|
+ payType = PayCodeUtils.getPayTypeByCode(orderGoodsDTO.getAuthCode());
|
|
|
+ } catch (ServiceException e) {
|
|
|
+ return OrderPayResultVO.payError(e.getMessage());
|
|
|
}
|
|
|
-
|
|
|
- // 微信
|
|
|
- case WECHAT:
|
|
|
- orderGoodsPayResultVO.setAppPayRespVO(payService.appPay(PayOrderAppDTO.buildGoodsOrderPayData(orderGoods, orderGoodsDTO.getPlatform())));
|
|
|
- // 支付宝
|
|
|
- case ALIPAY: {
|
|
|
- if (OrderSourceType.APP.getCode().equals(orderGoods.getOrderSource())) {
|
|
|
- orderGoodsPayResultVO.setAppPayRespVO(payService.appPay(PayOrderAppDTO.buildGoodsOrderPayData(orderGoods, orderGoodsDTO.getPlatform())));
|
|
|
+ orderGoods.setPayType(payType);
|
|
|
+ this.updateById(orderGoods);
|
|
|
+ try {
|
|
|
+ //创建支付订单,防止出现错误
|
|
|
+ OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(orderGoods.getOrderNo(), orderGoods.getPayAmount(), orderGoods.getPayType());
|
|
|
+ //优先增加到延迟队列
|
|
|
+ DelayMessage delayMessage = new DelayMessage(orderPayInfo.getPayOrderNo(), DelayTagsEnum.ORDER_PAY_DELAY_QUEUE.getCode(), JSONUtil.toJsonStr(orderPayInfo));
|
|
|
+ //暂不执行
|
|
|
+ delayMessage.setIsRun(0);
|
|
|
+ delayQueueCache.addDelayJob(delayMessage, PayQueryTimesEnum.getDelayTime(delayMessage.getPollingNum()));
|
|
|
+ PayResponseDTO payResponseDTO = payService.faceToFacePay(PayOrderFaceToFaceDTO.createRechargeOrderPayData(orderPayInfo.getPayOrderNo(), orderPayInfo.getPayAmount(), orderPayInfo.getPayType(), orderGoodsDTO.getAuthCode()));
|
|
|
+ if (payResponseDTO.getPayResult().equals(PayResult.success.getCode())) {
|
|
|
+ this.handlePaySuccessUpdateOrderStatus(orderGoods.getOrderNo(), null);
|
|
|
+ orderPayResultVO = OrderPayResultVO.paySuccess(orderGoods.getOrderNo());
|
|
|
+ orderPayResultVO.setOrderId(orderGoods.getId());
|
|
|
+ delayQueueCache.deleteDelayJob(orderPayInfo.getPayOrderNo());
|
|
|
+ return orderPayResultVO;
|
|
|
+ } else if (payResponseDTO.getPayResult().equals(PayResult.fail.getCode())) {
|
|
|
+ delayQueueCache.deleteDelayJob(orderPayInfo.getPayOrderNo());
|
|
|
+ return OrderPayResultVO.payError(payResponseDTO.getPayMsg());
|
|
|
} else {
|
|
|
- if (StrUtil.isEmpty(orderGoodsDTO.getAuthCode())){
|
|
|
- throw new ServiceException("请输入客户收款码");
|
|
|
- }
|
|
|
- try {
|
|
|
- // 门店 扫收款码
|
|
|
- payService.faceToFacePay(PayOrderFaceToFaceDTO.buildGoodsOrderPayData(orderGoods, orderGoodsDTO.getAuthCode()));
|
|
|
- }catch (Exception e){
|
|
|
- throw new ServiceException("扫收款码支付失败");
|
|
|
- }
|
|
|
+ //更新开始执行查询
|
|
|
+ delayMessage.setIsRun(1);
|
|
|
+ delayQueueCache.addDelayJob(delayMessage, PayQueryTimesEnum.getDelayTime(delayMessage.getPollingNum()));
|
|
|
+ return OrderPayResultVO.payWait(orderGoods.getOrderNo());
|
|
|
}
|
|
|
- break;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return OrderPayResultVO.payError("扫收款码支付失败");
|
|
|
}
|
|
|
}
|
|
|
- return orderGoodsPayResultVO;
|
|
|
+ //会员余额支付
|
|
|
+ if (orderGoods.getPayType().equals(PayType.BALANCE.getCode())) {
|
|
|
+ RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderGoods.getAppUserId(), orderGoods.getOrgId(), orderGoods.getOrderNo(), orderGoods.getPayAmount(), OrderType.goods.getCode());
|
|
|
+ rechargePasswordCardService.orderPayByBalance(rechargeCardPayDTO);
|
|
|
+ this.handlePaySuccessUpdateOrderStatus(orderGoods.getOrderNo(), null);
|
|
|
+ orderPayResultVO = OrderPayResultVO.paySuccess(orderGoods.getOrderNo());
|
|
|
+ orderPayResultVO.setOrderId(orderGoods.getId());
|
|
|
+ return orderPayResultVO;
|
|
|
+ }
|
|
|
+ //微信或者支付宝小程序支付
|
|
|
+ if (orderGoods.getPayType().equals(PayType.WECHAT.getCode()) || orderGoods.getPayType().equals(PayType.ALIPAY.getCode())) {
|
|
|
+ orderPayResultVO.setAppPayRespVO(payService.appPay(PayOrderAppDTO.buildGoodsOrderPayData(orderGoods, orderGoodsDTO.getPlatform())));
|
|
|
+ orderPayResultVO.setPayResult(100);
|
|
|
+ return orderPayResultVO;
|
|
|
+ }
|
|
|
+ return OrderPayResultVO.payError("请重新支付");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -321,15 +350,17 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public R handlePaySuccessUpdateOrderStatus(String orderNo){
|
|
|
+ public R handlePaySuccessUpdateOrderStatus(String orderNo, String outTradeNo) {
|
|
|
OrderGoods orderGoods = this.getOne(new QueryWrapper<OrderGoods>().lambda().eq(OrderGoods::getOrderNo, orderNo));
|
|
|
- if (orderGoods == null){
|
|
|
- throw new ServiceException("商品订单不存在,"+ orderNo);
|
|
|
+ if (orderGoods == null) {
|
|
|
+ throw new ServiceException("商品订单不存在," + orderNo);
|
|
|
+ }
|
|
|
+ if (!OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
+ return R.fail("订单状态异常,请稍后再试");
|
|
|
}
|
|
|
switch (Objects.requireNonNull(EnumUtils.getEnumByType(orderGoods.getGoodsType(), GoodsType.class))) {
|
|
|
- case NORMAL:
|
|
|
- {
|
|
|
- if (OrderSourceType.APP.getCode().equals(orderGoods.getOrderSource())) {
|
|
|
+ case NORMAL: {
|
|
|
+ if (OrderSourceType.APP.getCode().equals(orderGoods.getOrderSource()) || OrderSourceType.WXAPP.getCode().equals(orderGoods.getOrderSource())) {
|
|
|
orderGoods.setOrderStatus(OrderGoodsStatusType.NO_SEND.getCode());
|
|
|
} else {
|
|
|
// 门店
|
|
@@ -346,34 +377,38 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
orderGoods.setPayTime(DateUtils.getNowDate());
|
|
|
orderGoods.buildUpdateData();
|
|
|
this.updateById(orderGoods);
|
|
|
- // 扣款 并记录账单
|
|
|
- appUserBillMstrService.consumeRecord(ConsumeOrderDTO.buildOrderGoodsData(orderGoods));
|
|
|
+ // 减库存
|
|
|
+ List<OrderGoodsSku> orderGoodsSkus = this.handleMinusStock(orderGoods);
|
|
|
+ // 出库记录
|
|
|
+ this.buildStockRecord(orderGoods, orderGoodsSkus, Boolean.FALSE, Boolean.FALSE);
|
|
|
+ //处理销售数量 - 新增销量
|
|
|
+ this.buildUpdateGoodsSales(orderGoodsSkus, Boolean.TRUE);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 快递签收成功后,处理订单
|
|
|
+ *
|
|
|
* @param orderNo
|
|
|
*/
|
|
|
@Override
|
|
|
- public void handleDeliverySuccessUpdateOrderStatus(String orderNo){
|
|
|
+ public void handleDeliverySuccessUpdateOrderStatus(String orderNo) {
|
|
|
OrderGoods orderGoods = this.getOne(new QueryWrapper<OrderGoods>().lambda().eq(OrderGoods::getOrderNo, orderNo));
|
|
|
- if (orderGoods == null){
|
|
|
- throw new ServiceException("商品订单不存在,"+ orderNo);
|
|
|
+ if (orderGoods == null) {
|
|
|
+ throw new ServiceException("商品订单不存在," + orderNo);
|
|
|
}
|
|
|
- if (OrderGoodsStatusType.CONFIRM_RECEIVE.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
- log.debug("该订单已完成,无需处理, 订单编号:"+ orderNo);
|
|
|
+ if (OrderGoodsStatusType.CONFIRM_RECEIVE.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
+ log.debug("该订单已完成,无需处理, 订单编号:" + orderNo);
|
|
|
return;
|
|
|
}
|
|
|
switch (Objects.requireNonNull(EnumUtils.getEnumByType(orderGoods.getGoodsType(), GoodsType.class))) {
|
|
|
- case NORMAL:
|
|
|
- {
|
|
|
+ case NORMAL: {
|
|
|
orderGoods.setOrderStatus(OrderGoodsStatusType.CONFIRM_RECEIVE.getCode());
|
|
|
break;
|
|
|
}
|
|
|
case LIFE_SERVICE:
|
|
|
case CAR: {
|
|
|
- log.debug("该订单是服务类型订单,无需处理, 订单编号:"+ orderNo);
|
|
|
+ log.debug("该订单是服务类型订单,无需处理, 订单编号:" + orderNo);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -391,14 +426,14 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public int cancelOrder(AppOrderGoodsCancelDTO appOrderGoodsCancelDTO) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(appOrderGoodsCancelDTO.getOrderId());
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (OrderGoodsStatusType.CANCEL_ORDER.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
- log.debug("订单已取消,不需要处理,订单id:"+appOrderGoodsCancelDTO.getOrderId());
|
|
|
+ if (OrderGoodsStatusType.CANCEL_ORDER.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
+ log.debug("订单已取消,不需要处理,订单id:" + appOrderGoodsCancelDTO.getOrderId());
|
|
|
return 1;
|
|
|
}
|
|
|
- if (!OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (!OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单状态已支付,无法取消");
|
|
|
}
|
|
|
// 加库存 返回库存
|
|
@@ -425,14 +460,14 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
public String handlePayFailCancelOrder(String orderNo) {
|
|
|
OrderGoods orderGoods = this.getOne(new QueryWrapper<OrderGoods>().lambda()
|
|
|
.eq(OrderGoods::getOrderNo, orderNo));
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
return "订单不存在";
|
|
|
}
|
|
|
- if (OrderGoodsStatusType.CANCEL_ORDER.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
- log.debug("订单已取消,不需要处理,订单编号:"+ orderNo);
|
|
|
+ if (OrderGoodsStatusType.CANCEL_ORDER.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
+ log.debug("订单已取消,不需要处理,订单编号:" + orderNo);
|
|
|
return "订单已取消,不需要处理";
|
|
|
}
|
|
|
- if (!OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (!OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单状态已支付,无法取消");
|
|
|
}
|
|
|
// 加库存 返回库存
|
|
@@ -451,14 +486,13 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int rePayOrder(OrderGoodsDTO orderGoodsDTO) {
|
|
|
+ public OrderPayResultVO rePayOrder(OrderGoodsDTO orderGoodsDTO) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderGoodsDTO.getId());
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
// 处理支付流程
|
|
|
- this.handlePay(orderGoods, orderGoodsDTO);
|
|
|
- return 1;
|
|
|
+ return this.handlePay(orderGoods, orderGoodsDTO);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -471,10 +505,10 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public int outOrderGoods(OrderGoodsOutGoodsDTO orderGoodsOutGoodsDTO) throws Exception {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderGoodsOutGoodsDTO.getOrderId());
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (!OrderGoodsStatusType.NO_SEND.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (!OrderGoodsStatusType.NO_SEND.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单状态不符合,无法出货");
|
|
|
}
|
|
|
orderGoods.setOrderStatus(OrderGoodsStatusType.SENDING.getCode());
|
|
@@ -489,8 +523,8 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
List<Long> goodIdList = new ArrayList<>(goodsItems.stream().collect(Collectors.groupingBy(OrderGoodsItem::getGoodsId)).keySet());
|
|
|
List<GoodsInfo> goodsInfoList = goodsInfoService.list(new QueryWrapper<GoodsInfo>().lambda().in(GoodsInfo::getId, goodIdList));
|
|
|
// 生成快递订单
|
|
|
- WxMaExpressOrderInfoResult result = thirdDeliveryService.addDeliveryOrder(OrderThirdDeliveryAddDTO.buildDeliveryOrderByGoodsOrder(orderGoods, orderGoodsOutGoodsDTO,goodsInfoList, appUserInfo));
|
|
|
- if (result != null){
|
|
|
+ WxMaExpressOrderInfoResult result = thirdDeliveryService.addDeliveryOrder(OrderThirdDeliveryAddDTO.buildDeliveryOrderByGoodsOrder(orderGoods, orderGoodsOutGoodsDTO, goodsInfoList, appUserInfo));
|
|
|
+ if (result != null) {
|
|
|
orderGoods.setDeliveryNo(result.getWaybillId());
|
|
|
}
|
|
|
|
|
@@ -500,16 +534,17 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 生活服务/汽车美容订单-总部接单
|
|
|
+ *
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int receiveOrder(Long orderId) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderId);
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (!OrderGoodsStatusType.CONFIRM_PAY.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (!OrderGoodsStatusType.CONFIRM_PAY.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单状态不对,无法接单");
|
|
|
}
|
|
|
// 更新订单状态
|
|
@@ -520,16 +555,17 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 生活服务/汽车美容订单-确认完成
|
|
|
+ *
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int confirmFinish(Long orderId) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderId);
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (!OrderGoodsStatusType.SENDING.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (!OrderGoodsStatusType.SENDING.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单状态不对,无法确认完成");
|
|
|
}
|
|
|
// 更新订单状态
|
|
@@ -541,43 +577,44 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 商品订单-操作退款申请
|
|
|
+ *
|
|
|
* @param orderGoodsRefundDTO
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int refundOrderGoodsApply(OrderGoodsRefundDTO orderGoodsRefundDTO, String sourceType) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderGoodsRefundDTO.getOrderId());
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
// app客户操作
|
|
|
- if (SourceType.CUSTOM.getCode().equals(sourceType)){
|
|
|
+ if (SourceType.CUSTOM.getCode().equals(sourceType)) {
|
|
|
// 操作人校验
|
|
|
- if (!AuthHolder.userId().equals(orderGoods.getAppUserId())){
|
|
|
+ if (!AuthHolder.userId().equals(orderGoods.getAppUserId())) {
|
|
|
throw new ServiceException("当前登录人没有权限操作");
|
|
|
}
|
|
|
// 总部操作
|
|
|
- }else if (SourceType.MANAGER.getCode().equals(sourceType)){
|
|
|
+ } else if (SourceType.MANAGER.getCode().equals(sourceType)) {
|
|
|
// 操作人校验
|
|
|
- if (!SecurityUtils.getLoginUser().getSourceType().equals(SourceType.MANAGER.getCode())){
|
|
|
+ if (!SecurityUtils.getLoginUser().getSourceType().equals(SourceType.MANAGER.getCode())) {
|
|
|
throw new ServiceException("当前登录人没有权限操作");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (OrderRefundStatus.REFUND_SUCCESS.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (OrderRefundStatus.REFUND_SUCCESS.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("订单已退款,无法继续申请退款操作");
|
|
|
}
|
|
|
- if (OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("退款申请中,无法操作退款申请");
|
|
|
}
|
|
|
- if (!OrderSourceType.APP.getCode().equals(orderGoods.getOrderSource())){
|
|
|
+ if (!OrderSourceType.APP.getCode().equals(orderGoods.getOrderSource())) {
|
|
|
throw new GlobalException("非APP下单,无法操作退款申请");
|
|
|
}
|
|
|
// 超过3个月不能退单
|
|
|
- if ((DateUtils.getNowDate().compareTo(DateUtils.addMonths(orderGoods.getCreateTime(), 3))) > 0){
|
|
|
+ if ((DateUtils.getNowDate().compareTo(DateUtils.addMonths(orderGoods.getCreateTime(), 3))) > 0) {
|
|
|
throw new GlobalException("订单已经超过退单时间,不能操作退单");
|
|
|
}
|
|
|
- if (OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单未支付,不能操作退单");
|
|
|
}
|
|
|
// 更新订单状态
|
|
@@ -596,12 +633,12 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public R refundSuccess(String orderNo) {
|
|
|
OrderGoods orderGoods = this.getOne(new QueryWrapper<OrderGoods>().lambda().eq(OrderGoods::getOrderNo, orderNo));
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if(orderGoods.getRefundStatus() != OrderRefundStatus.REFUNDING.getCode()
|
|
|
+ if (orderGoods.getRefundStatus() != OrderRefundStatus.REFUNDING.getCode()
|
|
|
&& orderGoods.getRefundStatus() != OrderRefundStatus.REFUND_APPLYING.getCode()
|
|
|
- && orderGoods.getRefundStatus() != OrderRefundStatus.ERROR.getCode()){//退款状态不正确,直接跳过
|
|
|
+ && orderGoods.getRefundStatus() != OrderRefundStatus.ERROR.getCode()) {//退款状态不正确,直接跳过
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
@@ -617,7 +654,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
// 处理销量 - 扣商品销量
|
|
|
List<OrderGoodsSku> list = orderGoodsSkuService.list(new QueryWrapper<OrderGoodsSku>().lambda().eq(OrderGoodsSku::getOrderId, orderGoods.getId()));
|
|
|
- if (CollUtil.isNotEmpty(list)){
|
|
|
+ if (CollUtil.isNotEmpty(list)) {
|
|
|
this.buildUpdateGoodsSales(list, Boolean.FALSE);
|
|
|
}
|
|
|
//此处添加退款记录
|
|
@@ -628,7 +665,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public R refundClosed(String orderNo) {
|
|
|
OrderGoods orderGoods = this.getOne(new QueryWrapper<OrderGoods>().lambda().eq(OrderGoods::getOrderNo, orderNo));
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
orderGoods.setRefundStatus(OrderRefundStatus.REFUND_CANCEL.getCode());
|
|
@@ -639,7 +676,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public R refundError(String orderNo) {
|
|
|
OrderGoods orderGoods = this.getOne(new QueryWrapper<OrderGoods>().lambda().eq(OrderGoods::getOrderNo, orderNo));
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
orderGoods.setRefundStatus(OrderRefundStatus.ERROR.getCode());
|
|
@@ -654,13 +691,13 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public int refundApprovalPass(Long orderId) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderId);
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (!OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (!OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("订单非退款中状态,无法退单");
|
|
|
}
|
|
|
- if (OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())){
|
|
|
+ if (OrderGoodsStatusType.NO_PAY.getCode().equals(orderGoods.getOrderStatus())) {
|
|
|
throw new GlobalException("订单未支付,不能操作退单");
|
|
|
}
|
|
|
|
|
@@ -687,10 +724,10 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public int refundApprovalReject(Long orderId) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderId);
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (!OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (!OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("订单非退款中状态,无法拒单");
|
|
|
}
|
|
|
// 更新订单状态
|
|
@@ -702,20 +739,21 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 商品订单退款-APP取消退款
|
|
|
+ *
|
|
|
* @param orderId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int cancelRefund(Long orderId) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderId);
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
- if (!OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (!OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("订单非退款中状态,无法取消");
|
|
|
}
|
|
|
// 操作人校验
|
|
|
- if (!AuthHolder.userId().equals(orderGoods.getAppUserId())){
|
|
|
+ if (!AuthHolder.userId().equals(orderGoods.getAppUserId())) {
|
|
|
throw new ServiceException("当前登录人没有权限操作");
|
|
|
}
|
|
|
// 更新订单状态
|
|
@@ -726,23 +764,24 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 商品订单退款-APP申请退款
|
|
|
+ *
|
|
|
* @param appOrderGoodsRefundDTO
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int applyRefundOrderGoods(AppOrderGoodsRefundDTO appOrderGoodsRefundDTO) {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(appOrderGoodsRefundDTO.getOrderId());
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
// 操作人校验
|
|
|
- if (!AuthHolder.userId().equals(orderGoods.getAppUserId())){
|
|
|
+ if (!AuthHolder.userId().equals(orderGoods.getAppUserId())) {
|
|
|
throw new ServiceException("当前登录人没有权限操作");
|
|
|
}
|
|
|
- if(OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (OrderRefundStatus.REFUND_APPLYING.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("商品订单退款申请中,请勿重复操作");
|
|
|
}
|
|
|
- if(OrderRefundStatus.REFUND_SUCCESS.getCode().equals(orderGoods.getRefundStatus())){
|
|
|
+ if (OrderRefundStatus.REFUND_SUCCESS.getCode().equals(orderGoods.getRefundStatus())) {
|
|
|
throw new GlobalException("商品订单已退款,请勿重复操作");
|
|
|
}
|
|
|
orderGoods.setRefundReason(appOrderGoodsRefundDTO.getRefundReason());
|
|
@@ -752,20 +791,22 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 零售出货 - 组装库存记录list
|
|
|
+ * 零售出货 - 组装库存记录list
|
|
|
+ *
|
|
|
* @param orderGoods
|
|
|
* @param orderGoodsSkus
|
|
|
* @param isAdd
|
|
|
* @param isRefund
|
|
|
*/
|
|
|
private void buildStockRecord(OrderGoods orderGoods, List<OrderGoodsSku> orderGoodsSkus, Boolean isAdd, Boolean isRefund) {
|
|
|
- goodsSkuStockRecordService.saveBatch(GoodsSkuStockRecordDTO.buildStockRecordByOrderRetailGoods(orderGoods,orderGoodsSkus,isAdd,isRefund));
|
|
|
+ goodsSkuStockRecordService.saveBatch(GoodsSkuStockRecordDTO.buildStockRecordByOrderRetailGoods(orderGoods, orderGoodsSkus, isAdd, isRefund));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过订单物料明细, 更新商品销售数量
|
|
|
- * @param orderGoodsSkus
|
|
|
- * @param isAdd 是否新增销量
|
|
|
+ *
|
|
|
+ * @param orderGoodsSkus
|
|
|
+ * @param isAdd 是否新增销量
|
|
|
*/
|
|
|
private void buildUpdateGoodsSales(List<OrderGoodsSku> orderGoodsSkus, boolean isAdd) {
|
|
|
Map<Long, Integer> goodsSaleNumberMap = orderGoodsSkus.stream().collect(Collectors.groupingBy(OrderGoodsSku::getGoodsId))
|
|
@@ -782,14 +823,14 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
goodsInfoService.handleGoodsSellNum(goodsUpdateSales, isAdd);
|
|
|
}
|
|
|
|
|
|
- public String getDeliveryWayByOrderSource(String orderSource){
|
|
|
- if (OrderSourceType.APP.getCode().equals(orderSource)){
|
|
|
- return DeliveryWayType.TO_STORE.getCode();
|
|
|
+ public String getDeliveryWayByOrderSource(String orderSource) {
|
|
|
+ if (OrderSourceType.APP.getCode().equals(orderSource)) {
|
|
|
+ return DeliveryWayType.DELIVERY.getCode();
|
|
|
}
|
|
|
- if (OrderSourceType.WXAPP.getCode().equals(orderSource)){
|
|
|
+ if (OrderSourceType.WXAPP.getCode().equals(orderSource)) {
|
|
|
return DeliveryWayType.DELIVERY.getCode();
|
|
|
}
|
|
|
- if (OrderSourceType.OFFLINE.getCode().equals(orderSource)){
|
|
|
+ if (OrderSourceType.OFFLINE.getCode().equals(orderSource)) {
|
|
|
return DeliveryWayType.DELIVERY.getCode();
|
|
|
}
|
|
|
return null;
|
|
@@ -801,28 +842,28 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
* @return 用于计算总价,和创建订单时用到的一些商品信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<OrderGoodsSkuInfoVO> getOrderSkuInfoByGoodsMarket(){
|
|
|
+ public List<OrderGoodsSkuInfoVO> getOrderSkuInfoByGoodsMarket() {
|
|
|
List<AppGoodsMarket> appGoodsMarketList = appGoodsMarketService.list(new QueryWrapper<AppGoodsMarket>().lambda()
|
|
|
.eq(AppGoodsMarket::getAppUserId, AuthHolder.userId())
|
|
|
.eq(AppGoodsMarket::getIsSelect, SysBoolType.YES.getCode()));
|
|
|
- if(appGoodsMarketList == null || appGoodsMarketList.size() == 0){
|
|
|
+ if (appGoodsMarketList == null || appGoodsMarketList.size() == 0) {
|
|
|
throw new ServiceException("请选择商品");
|
|
|
}
|
|
|
- if (appGoodsMarketList.stream().anyMatch(item -> item.getBuyNum() == null || item.getBuyNum() == 0)){
|
|
|
+ if (appGoodsMarketList.stream().anyMatch(item -> item.getBuyNum() == null || item.getBuyNum() == 0)) {
|
|
|
throw new ServiceException("商品数量不能为0");
|
|
|
}
|
|
|
|
|
|
List<OrderGoodsSkuInfoVO> skuInfoList = this.getSkuInfoList(
|
|
|
appGoodsMarketList.stream()
|
|
|
.map(AppGoodsMarket::getGoodsSkuId).collect(Collectors.toList()), OrderSourceType.APP.getCode());
|
|
|
- if (CollUtil.isEmpty(skuInfoList)){
|
|
|
+ if (CollUtil.isEmpty(skuInfoList)) {
|
|
|
throw new GlobalException("商品物料信息为空,无法下单");
|
|
|
}
|
|
|
Map<Long, AppGoodsMarket> orderGoodsSkuInfoVOMap = appGoodsMarketList.stream()
|
|
|
.collect(Collectors.toMap(AppGoodsMarket::getGoodsSkuId, AppGoodsMarket -> AppGoodsMarket));
|
|
|
|
|
|
for (OrderGoodsSkuInfoVO orderGoodsSkuInfoVO : skuInfoList) {
|
|
|
- if(!orderGoodsSkuInfoVOMap.containsKey(orderGoodsSkuInfoVO.getSkuId())){
|
|
|
+ if (!orderGoodsSkuInfoVOMap.containsKey(orderGoodsSkuInfoVO.getSkuId())) {
|
|
|
continue;
|
|
|
}
|
|
|
orderGoodsSkuInfoVO.setBuyNum(orderGoodsSkuInfoVOMap.get(orderGoodsSkuInfoVO.getSkuId()).getBuyNum());
|
|
@@ -833,43 +874,45 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 通过购买选择的物料id,查询物料信息,并加入购买数量返回
|
|
|
+ *
|
|
|
* @param orderGoodsDTO
|
|
|
* @return 用于计算总价,和创建订单时用到的一些商品信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<OrderGoodsSkuInfoVO> getOrderSkuInfoByOrderSkuId(OrderGoodsDTO orderGoodsDTO){
|
|
|
+ public List<OrderGoodsSkuInfoVO> getOrderSkuInfoByOrderSkuId(OrderGoodsDTO orderGoodsDTO) {
|
|
|
List<OrderRetailGoodsSkusDTO> retailGoodsVOList = orderGoodsDTO.getRetailGoodsVOList();
|
|
|
- if (CollUtil.isEmpty(retailGoodsVOList)){
|
|
|
+ if (CollUtil.isEmpty(retailGoodsVOList)) {
|
|
|
throw new GlobalException("操作失败,商品信息为空");
|
|
|
}
|
|
|
- if (retailGoodsVOList.stream().anyMatch(item -> item.getBuyNum() == null || item.getBuyNum() == 0)){
|
|
|
+ if (retailGoodsVOList.stream().anyMatch(item -> item.getBuyNum() == null || item.getBuyNum() == 0)) {
|
|
|
throw new ServiceException("商品数量不能为0");
|
|
|
}
|
|
|
|
|
|
List<OrderGoodsSkuInfoVO> skuInfoList = this.getSkuInfoList(
|
|
|
retailGoodsVOList.stream()
|
|
|
.map(OrderRetailGoodsSkusDTO::getSkuId).collect(Collectors.toList()), orderGoodsDTO.getOrderSource());
|
|
|
- if (CollUtil.isEmpty(skuInfoList)){
|
|
|
+ if (CollUtil.isEmpty(skuInfoList)) {
|
|
|
throw new GlobalException("商品物料信息为空,无法下单");
|
|
|
}
|
|
|
Map<Long, OrderRetailGoodsSkusDTO> orderGoodsSkuInfoVOMap = retailGoodsVOList.stream()
|
|
|
.collect(Collectors.toMap(OrderRetailGoodsSkusDTO::getSkuId, OrderRetailGoodsSkusDTO -> OrderRetailGoodsSkusDTO));
|
|
|
|
|
|
for (OrderGoodsSkuInfoVO orderGoodsSkuInfoVO : skuInfoList) {
|
|
|
- if(!orderGoodsSkuInfoVOMap.containsKey(orderGoodsSkuInfoVO.getSkuId())){
|
|
|
+ if (!orderGoodsSkuInfoVOMap.containsKey(orderGoodsSkuInfoVO.getSkuId())) {
|
|
|
continue;
|
|
|
}
|
|
|
orderGoodsSkuInfoVO.setBuyNum(orderGoodsSkuInfoVOMap.get(orderGoodsSkuInfoVO.getSkuId()).getBuyNum());
|
|
|
}
|
|
|
- return skuInfoList;
|
|
|
+ return skuInfoList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理减库存
|
|
|
+ *
|
|
|
* @param orderGoods
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<OrderGoodsSku> handleMinusStock(OrderGoods orderGoods){
|
|
|
+ public List<OrderGoodsSku> handleMinusStock(OrderGoods orderGoods) {
|
|
|
// 处理商品库存 查询本次订单内容
|
|
|
List<OrderGoodsSku> orderGoodsSkus = orderGoodsSkuService.list(new QueryWrapper<OrderGoodsSku>().lambda()
|
|
|
.eq(OrderGoodsSku::getOrderId, orderGoods.getId()));
|
|
@@ -882,10 +925,11 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
|
|
|
/**
|
|
|
* 处理加库存
|
|
|
+ *
|
|
|
* @param orderGoods
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<OrderGoodsSku> handleAddStock(OrderGoods orderGoods){
|
|
|
+ public List<OrderGoodsSku> handleAddStock(OrderGoods orderGoods) {
|
|
|
// 处理商品库存 查询本次订单内容
|
|
|
List<OrderGoodsSku> orderGoodsSkus = orderGoodsSkuService.list(new QueryWrapper<OrderGoodsSku>().lambda()
|
|
|
.eq(OrderGoodsSku::getOrderId, orderGoods.getId()));
|
|
@@ -897,7 +941,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BigDecimal getDeductAmountByUserPoint(){
|
|
|
+ public BigDecimal getDeductAmountByUserPoint() {
|
|
|
return new BigDecimal(BigInteger.ZERO);
|
|
|
}
|
|
|
|
|
@@ -905,7 +949,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
public List<GoodsOrderRefundQueryVO> getRefundOrderGoodsList(GoodsOrderRefundQueryDTO goodsOrderRefundQueryDTO) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
goodsOrderRefundQueryDTO.setSourceType(user.getUserType());
|
|
|
- if (!SourceType.MANAGER.getCode().equals(user.getUserType())){
|
|
|
+ if (!SourceType.MANAGER.getCode().equals(user.getUserType())) {
|
|
|
goodsOrderRefundQueryDTO.setOrgId(SourceType.STORE.getCode().equals(user.getUserType()) ? user.getStoreId() : user.getFactoryId());
|
|
|
}
|
|
|
return baseMapper.getRefundOrderGoodsList(goodsOrderRefundQueryDTO);
|
|
@@ -914,7 +958,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
@Override
|
|
|
public OrderDeliveryPathVO getDeliveryPath(Long orderId) throws Exception {
|
|
|
OrderGoods orderGoods = baseMapper.selectById(orderId);
|
|
|
- if(orderGoods == null){
|
|
|
+ if (orderGoods == null) {
|
|
|
throw new GlobalException("订单不存在");
|
|
|
}
|
|
|
AppUserInfoVO appUserInfo = appUserService.getAppUserInfoById(orderGoods.getAppUserId());
|
|
@@ -943,7 +987,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
List<OrderGoodsFinancialVO> todayData = baseMapper.listFinancialStatisticsByGoodsOrderToday(today,
|
|
|
SecurityUtils.getLoginUser().getOrgId(),
|
|
|
SecurityUtils.getLoginUser().getSourceType());
|
|
|
- if (CollUtil.isEmpty(todayData)){
|
|
|
+ if (CollUtil.isEmpty(todayData)) {
|
|
|
orderFinancialQueryVO.setTodayOrderGoodsCount(0);
|
|
|
}
|
|
|
// 今日商品件数
|
|
@@ -957,7 +1001,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper,OrderGoo
|
|
|
public void listFinancialStatisticsByGoodsOrderMTD(OrderFinancialQueryVO orderFinancialQueryVO) {
|
|
|
// 查询本月商品订单
|
|
|
List<OrderGoodsFinancialVO> todayData = baseMapper.listFinancialStatisticsByGoodsOrderMTD(SecurityUtils.getLoginUser().getOrgId(), SecurityUtils.getLoginUser().getSourceType());
|
|
|
- if (CollUtil.isEmpty(todayData)){
|
|
|
+ if (CollUtil.isEmpty(todayData)) {
|
|
|
orderFinancialQueryVO.setTodayOrderGoodsCount(0);
|
|
|
}
|
|
|
// 本月商品件数
|