|
@@ -3,14 +3,7 @@ package com.yonge.cooleshow.portal.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
-import com.yonge.cooleshow.portal.dao.PortalProductDao;
|
|
|
-import com.yonge.cooleshow.portal.dto.OrderPayReq;
|
|
|
-import com.yonge.cooleshow.portal.dto.OrderPayRes;
|
|
|
-import com.yonge.toolset.base.exception.BizException;
|
|
|
-
|
|
|
import com.yonge.cooleshow.mall.common.api.CommonPage;
|
|
|
import com.yonge.cooleshow.mall.common.exception.Asserts;
|
|
|
import com.yonge.cooleshow.mall.common.service.RedisService;
|
|
@@ -19,15 +12,16 @@ import com.yonge.cooleshow.mbg.model.*;
|
|
|
import com.yonge.cooleshow.portal.component.CancelOrderSender;
|
|
|
import com.yonge.cooleshow.portal.dao.PortalOrderDao;
|
|
|
import com.yonge.cooleshow.portal.dao.PortalOrderItemDao;
|
|
|
-import com.yonge.cooleshow.portal.dao.SmsCouponHistoryDao;
|
|
|
+import com.yonge.cooleshow.portal.dao.PortalProductDao;
|
|
|
import com.yonge.cooleshow.portal.domain.*;
|
|
|
+import com.yonge.cooleshow.portal.dto.OrderPayReq;
|
|
|
+import com.yonge.cooleshow.portal.dto.OrderPayRes;
|
|
|
import com.yonge.cooleshow.portal.service.*;
|
|
|
-import com.yonge.toolset.payment.base.enums.PaymentClientEnum;
|
|
|
-import com.yonge.toolset.utils.string.StringUtil;
|
|
|
-
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.result.BaseResult;
|
|
|
import com.yonge.toolset.payment.base.enums.OpenEnum;
|
|
|
import com.yonge.toolset.payment.base.enums.PayChannelEnum;
|
|
|
+import com.yonge.toolset.payment.base.enums.PaymentClientEnum;
|
|
|
import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
|
|
|
import com.yonge.toolset.payment.base.model.DeviceInfo;
|
|
|
import com.yonge.toolset.payment.base.model.DivMember;
|
|
@@ -36,7 +30,7 @@ import com.yonge.toolset.payment.base.model.Payment;
|
|
|
import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
|
|
|
import com.yonge.toolset.payment.core.props.PaymentProperties;
|
|
|
import com.yonge.toolset.payment.core.service.PaymentClient;
|
|
|
-
|
|
|
+import com.yonge.toolset.utils.string.StringUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -57,7 +51,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
|
|
|
- private static final Logger log = LoggerFactory.getLogger(OmsPortalOrderService.class);
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(OmsPortalOrderServiceImpl.class);
|
|
|
@Autowired
|
|
|
private UmsMemberService memberService;
|
|
|
@Autowired
|
|
@@ -70,8 +64,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
private UmsIntegrationConsumeSettingMapper integrationConsumeSettingMapper;
|
|
|
@Autowired
|
|
|
private PmsSkuStockMapper skuStockMapper;
|
|
|
- @Autowired
|
|
|
- private SmsCouponHistoryDao couponHistoryDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private OmsOrderMapper orderMapper;
|
|
|
@Autowired
|
|
@@ -375,6 +368,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
//解除订单商品库存锁定
|
|
|
if (!CollectionUtils.isEmpty(orderItemList)) {
|
|
|
portalOrderDao.releaseSkuStockLock(orderItemList);
|
|
|
+ portalOrderDao.releaseProductStockLock(orderItemList);
|
|
|
}
|
|
|
//修改优惠券使用状态
|
|
|
updateCouponStatus(cancelOrder.getCouponId(), cancelOrder.getMemberId(), 0);
|
|
@@ -393,7 +387,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
public void sendDelayMessageCancelOrder(Long orderId) {
|
|
|
//获取订单超时时间
|
|
|
OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L);
|
|
|
- long delayTimes = orderSetting.getNormalOrderOvertime() * 60 * 1000;
|
|
|
+ long delayTimes = orderSetting.getNormalOrderOvertime() * 60 * 1000L;
|
|
|
//发送延迟消息
|
|
|
cancelOrderSender.sendMessage(orderId, delayTimes);
|
|
|
}
|
|
@@ -542,12 +536,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
payment.setOrderDesc("酷乐秀商城订单编号-" + detail.getOrderSn());
|
|
|
|
|
|
//封装订单详情
|
|
|
- List<OrderDetil> orderDetils = new ArrayList<>();
|
|
|
+ List<OrderDetil> orderDetails = new ArrayList<>();
|
|
|
for (OmsOrderItem orderDetailVo : detail.getOrderItemList()) {
|
|
|
- orderDetils.add(new OrderDetil(orderDetailVo.getId().toString(), orderDetailVo.getProductName(),
|
|
|
+ orderDetails.add(new OrderDetil(orderDetailVo.getId().toString(), orderDetailVo.getProductName(),
|
|
|
orderDetailVo.getProductQuantity(), orderDetailVo.getRealAmount().toString()));
|
|
|
}
|
|
|
- payment.setOrderDetils(orderDetils);
|
|
|
+ payment.setOrderDetils(orderDetails);
|
|
|
payment.setPayAmt(detail.getPayAmount().setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
payment.setDescription(payReq.getReason());
|
|
|
|
|
@@ -660,14 +654,15 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
//订单完成
|
|
|
UserOrderPayment userOrderPayment = userOrderPaymentService.getByAdapayNo(data.getPaymentNo());
|
|
|
if (null == userOrderPayment) {
|
|
|
- log.error("汇付支付回调,订单未找到。 req is {}", JSON.toJSONString(data));
|
|
|
+ String string = JSON.toJSONString(data);
|
|
|
+ LOG.error("汇付支付回调,订单未找到。 req is {}", string);
|
|
|
return;
|
|
|
}
|
|
|
OmsOrderDetail detail = detail(userOrderPayment.getOrderNo());
|
|
|
if (detail.getStatus() == 0) {
|
|
|
orderSuccess(detail, data,data.getId());
|
|
|
} else {
|
|
|
- log.error("汇付支付回调,订单状态异常。 req is {}", detail.getOrderSn());
|
|
|
+ LOG.error("汇付支付回调,订单状态异常。 req is {}", detail.getOrderSn());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -680,21 +675,22 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
private void paymentFailedHandle(PaymentCallBack data) {
|
|
|
//订单完成
|
|
|
UserOrderPayment userOrderPayment = userOrderPaymentService.getByAdapayNo(data.getPaymentNo());
|
|
|
+ String dataString = JSON.toJSONString(data);
|
|
|
if (null == userOrderPayment) {
|
|
|
- log.error("汇付支付回调,订单未找到。 req is {}", JSON.toJSONString(data));
|
|
|
+ LOG.error("汇付支付回调,订单未找到。 req is {}", dataString);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
OmsOrderDetail detail = detail(userOrderPayment.getOrderNo());
|
|
|
if (null == detail) {
|
|
|
- log.error("汇付支付回调,订单未找到。 req is {}", JSON.toJSONString(data));
|
|
|
+ LOG.error("汇付支付回调,订单未找到。 req is {}", dataString);
|
|
|
return;
|
|
|
}
|
|
|
if (detail.getStatus() == 0) {
|
|
|
|
|
|
cancelOrder(detail.getId(), data.getErrMsg(),data);
|
|
|
} else {
|
|
|
- log.error("汇付支付回调,订单状态异常。 req is {}", JSON.toJSONString(data));
|
|
|
+ LOG.error("汇付支付回调,订单状态异常。 req is {}", dataString);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -738,12 +734,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
/***
|
|
|
* 处理支付中订单
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
void payingOrderHandle(OmsOrder userOrder) {
|
|
|
//判断汇付订单状态
|
|
|
UserOrderPayment orderPayment = userOrderPaymentService.getByOrderNoAndStatusPaying(userOrder.getOrderSn());
|
|
|
if (null == orderPayment) {
|
|
|
cancelOrder(userOrder.getId(), "支付超时", null);
|
|
|
+ return;
|
|
|
}
|
|
|
OmsOrderDetail detail = detail(orderPayment.getOrderNo());
|
|
|
try {
|
|
@@ -753,7 +749,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
param.setPaymentNo(orderPayment.getAdapayNo());
|
|
|
BaseResult<Payment> res = paymentClient.queryPayment(param);
|
|
|
//支付成功
|
|
|
- if (res.getStatus() && TradeStatusEnum.succeeded.getCode().equals(res.getData().getStatus())
|
|
|
+ if (res.getStatus() && TradeStatusEnum.succeeded.getCode().equals(res.getData().getStatus().getCode())
|
|
|
&& (detail.getStatus() == 0 || detail.getStatus() == 1)
|
|
|
) {
|
|
|
orderSuccess(detail,res.getData().getId());
|
|
@@ -767,7 +763,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
cancelOrder(userOrder.getId(), "支付超时", null);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("轮询处理支付中订单异常,异常参数: {}", JSONObject.toJSONString(userOrder));
|
|
|
+ LOG.error("轮询处理支付中订单异常,异常参数: {}", JSON.toJSONString(userOrder));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -783,12 +779,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
* @updateTime 2022/4/13 17:17
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- void orderSuccess(OmsOrder detail, PaymentCallBack data, String tranId) {
|
|
|
+ public void orderSuccess(OmsOrder detail, PaymentCallBack data, String tranId) {
|
|
|
//更新订单
|
|
|
UserOrderPayment orderPayment = userOrderPaymentService.getByOrderNoAndStatusPaying(detail.getOrderSn());
|
|
|
|
|
|
if (orderPayment == null) {
|
|
|
- log.error("支付回调,支付中订单未找到。 orderNo is {}",detail.getOrderSn());
|
|
|
+ LOG.error("支付回调,支付中订单未找到。 orderNo is {}", detail.getOrderSn());
|
|
|
return;
|
|
|
}
|
|
|
if (data != null) {
|
|
@@ -814,7 +810,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
orderPayment.setFeeAmt(new BigDecimal(data.getExecutePaymentCallBack().getFeeAmt()));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- log.error("完成订单,付款单金额格式化失败,参数{}", JSON.toJSONString(data));
|
|
|
+ LOG.error("完成订单,付款单金额格式化失败,参数{}", JSON.toJSONString(data));
|
|
|
}
|
|
|
}
|
|
|
userOrderPaymentService.saveOrUpdate(orderPayment);
|
|
@@ -856,7 +852,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
* 计算该订单赠送的成长值
|
|
|
*/
|
|
|
private Integer calcGiftGrowth(List<OmsOrderItem> orderItemList) {
|
|
|
- Integer sum = 0;
|
|
|
+ int sum = 0;
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
sum = sum + orderItem.getGiftGrowth() * orderItem.getProductQuantity();
|
|
|
}
|
|
@@ -928,12 +924,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
*/
|
|
|
private BigDecimal calcPayAmount(OmsOrder order) {
|
|
|
//总金额+运费-促销优惠-优惠券优惠-积分抵扣
|
|
|
- BigDecimal payAmount = order.getTotalAmount()
|
|
|
- .add(order.getFreightAmount())
|
|
|
- .subtract(order.getPromotionAmount())
|
|
|
- .subtract(order.getCouponAmount())
|
|
|
- .subtract(order.getIntegrationAmount());
|
|
|
- return payAmount;
|
|
|
+ return order.getTotalAmount()
|
|
|
+ .add(order.getFreightAmount())
|
|
|
+ .subtract(order.getPromotionAmount())
|
|
|
+ .subtract(order.getCouponAmount())
|
|
|
+ .subtract(order.getIntegrationAmount());
|
|
|
}
|
|
|
|
|
|
/**
|