|
@@ -69,6 +69,7 @@ import com.cyksj.mapper.mirrorshop.UserMirrorShopDistributeWaitingSendPointsMapp
|
|
|
import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
|
|
import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
|
|
|
import com.cyksj.mapper.mirrorshop.UserMirrorShopOrderRelateMapper;
|
|
import com.cyksj.mapper.mirrorshop.UserMirrorShopOrderRelateMapper;
|
|
|
import com.cyksj.mapper.mirrorshop.UserMirrorShopUserDistributeSharedMapper;
|
|
import com.cyksj.mapper.mirrorshop.UserMirrorShopUserDistributeSharedMapper;
|
|
|
|
|
+import com.cyksj.mapper.order.OrderDonTicketQueryMapper;
|
|
|
import com.cyksj.mapper.renew.RenewUpgradePackageMapper;
|
|
import com.cyksj.mapper.renew.RenewUpgradePackageMapper;
|
|
|
import com.cyksj.mapper.shop.YhShopGoodsSkuMapper;
|
|
import com.cyksj.mapper.shop.YhShopGoodsSkuMapper;
|
|
|
import com.cyksj.mapper.sys.SysConfigMapper;
|
|
import com.cyksj.mapper.sys.SysConfigMapper;
|
|
@@ -145,6 +146,9 @@ import java.util.stream.Collectors;
|
|
|
public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> implements OrderDonService {
|
|
public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> implements OrderDonService {
|
|
|
|
|
|
|
|
private static final Long EXPIRY_TIME = 1000 * 60 * 5L;
|
|
private static final Long EXPIRY_TIME = 1000 * 60 * 5L;
|
|
|
|
|
+ private static final long PAYMENT_QUERY_RETRY_DELAY = 181_000L;
|
|
|
|
|
+ private static final int PAYMENT_QUERY_MAX_RETRIES = 5;
|
|
|
|
|
+ private static final String PAYMENT_QUERY_RETRY_KEY = "payment:query:retry:";
|
|
|
|
|
|
|
|
private static final Sequence SEQUENCE = new Sequence(0);
|
|
private static final Sequence SEQUENCE = new Sequence(0);
|
|
|
|
|
|
|
@@ -182,6 +186,12 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
private final OrderDonMapper orderDonMapper;
|
|
private final OrderDonMapper orderDonMapper;
|
|
|
|
|
|
|
|
|
|
+ private final OrderDonTicketQueryMapper orderDonTicketQueryMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final MultiQuantityOrderConfigService multiQuantityOrderConfigService;
|
|
|
|
|
+
|
|
|
|
|
+ private final MultiQuantityOrderService multiQuantityOrderService;
|
|
|
|
|
+
|
|
|
private final EnvCommonService envCommonService;
|
|
private final EnvCommonService envCommonService;
|
|
|
|
|
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
|
|
private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
|
|
@@ -425,6 +435,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
public OrderDon submit(OrderPayRequest payRequest) throws Exception {
|
|
public OrderDon submit(OrderPayRequest payRequest) throws Exception {
|
|
|
GoodsDonSku sku = null;
|
|
GoodsDonSku sku = null;
|
|
|
Long goodsId;
|
|
Long goodsId;
|
|
|
|
|
+ int cmt = normalizeCmt(payRequest.getCmt());
|
|
|
|
|
+ payRequest.setCmt(cmt);
|
|
|
List<GiftCardPayReq> giftCards = null;
|
|
List<GiftCardPayReq> giftCards = null;
|
|
|
GiftCardDto gcPayInfo = payRequest.getGcPayInfo();
|
|
GiftCardDto gcPayInfo = payRequest.getGcPayInfo();
|
|
|
if (gcPayInfo != null && gcPayInfo.getGiftCards() != null) {
|
|
if (gcPayInfo != null && gcPayInfo.getGiftCards() != null) {
|
|
@@ -435,9 +447,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
String customId = payRequest.getCustomId();
|
|
String customId = payRequest.getCustomId();
|
|
|
UserMirrorShop userMirrorShop = null;
|
|
UserMirrorShop userMirrorShop = null;
|
|
|
Long yhsId = 0l;
|
|
Long yhsId = 0l;
|
|
|
- if (payRequest.getCmt() == 1) {
|
|
|
|
|
|
|
+ if (cmt == 1) {
|
|
|
yhsId = yhShopFrontService.checkShopCustomIdAndReturnShopId(customId);
|
|
yhsId = yhShopFrontService.checkShopCustomIdAndReturnShopId(customId);
|
|
|
- } else if (payRequest.getCmt() == 2) {
|
|
|
|
|
|
|
+ } else if (cmt == 2) {
|
|
|
if (StrUtil.isNotEmpty(customId)) {
|
|
if (StrUtil.isNotEmpty(customId)) {
|
|
|
userMirrorShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class).eq(UserMirrorShop::getCustomId, customId).last("limit 1"));
|
|
userMirrorShop = userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class).eq(UserMirrorShop::getCustomId, customId).last("limit 1"));
|
|
|
if (userMirrorShop == null || !userMirrorShop.getStatus()) {
|
|
if (userMirrorShop == null || !userMirrorShop.getStatus()) {
|
|
@@ -457,6 +469,26 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
goodsId = sku.getGoodsId();
|
|
goodsId = sku.getGoodsId();
|
|
|
}
|
|
}
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(goodsId);
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(goodsId);
|
|
|
|
|
+ if (goodsDon == null) {
|
|
|
|
|
+ throw new BusinessRuntimeException("商品不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer quantity = Optional.ofNullable(payRequest.getNum()).orElse(1);
|
|
|
|
|
+ if (quantity <= 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("购买数量必须大于0");
|
|
|
|
|
+ }
|
|
|
|
|
+ payRequest.setNum(quantity);
|
|
|
|
|
+ Long multiQuantitySkuId = sku == null ? null : sku.getId();
|
|
|
|
|
+ boolean multiQuantity = multiQuantityOrderConfigService.isMultiQuantity(multiQuantitySkuId, quantity);
|
|
|
|
|
+ if (quantity > 1 && !multiQuantity) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该规格不支持一次购买多个");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ validateMultiQuantitySubmit(payRequest, goodsDon, sku, isGiftCardPay.get(), yhsId);
|
|
|
|
|
+ multiQuantityOrderConfigService.validateAndGet(multiQuantitySkuId, quantity);
|
|
|
|
|
+ if (!isSkuEnabled(sku)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("SKU is disabled");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
//是否是补差价订单
|
|
//是否是补差价订单
|
|
|
if (goodsDon.getType() != null && goodsDon.getType() == 5) {
|
|
if (goodsDon.getType() != null && goodsDon.getType() == 5) {
|
|
|
return generateDifferOrderDon(payRequest, goodsDon, sku);
|
|
return generateDifferOrderDon(payRequest, goodsDon, sku);
|
|
@@ -535,7 +567,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//校验奈飞限购信息
|
|
//校验奈飞限购信息
|
|
|
- checkNfPayLimit(goodsId, userId);
|
|
|
|
|
|
|
+ if (!multiQuantity) {
|
|
|
|
|
+ checkNfPayLimit(goodsId, userId);
|
|
|
|
|
+ }
|
|
|
GroupsRelation relation = null;
|
|
GroupsRelation relation = null;
|
|
|
String orderPhone = payRequest.getPhone();
|
|
String orderPhone = payRequest.getPhone();
|
|
|
if (StrUtil.isNotBlank(orderPhone)) {
|
|
if (StrUtil.isNotBlank(orderPhone)) {
|
|
@@ -553,11 +587,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
|
payOpenId = user.getOpenId();
|
|
payOpenId = user.getOpenId();
|
|
|
- if (sku != null) {
|
|
|
|
|
|
|
+ if (sku != null && !multiQuantity) {
|
|
|
//ChatGPT Plus账号限购校验
|
|
//ChatGPT Plus账号限购校验
|
|
|
checkChatGPTPlusPurchaseLimit(user.getId(), goodsDon.getId(), goodsDon.getTitle(), sku.getId(), sku.getSpecVal());
|
|
checkChatGPTPlusPurchaseLimit(user.getId(), goodsDon.getId(), goodsDon.getTitle(), sku.getId(), sku.getSpecVal());
|
|
|
}
|
|
}
|
|
|
- if (goodsDon.getType() == 1 && isNeedTicket) {
|
|
|
|
|
|
|
+ if (!multiQuantity && goodsDon.getType() == 1 && isNeedTicket) {
|
|
|
//获取座位
|
|
//获取座位
|
|
|
relation = getRelation(payRequest, sku, yhsId);
|
|
relation = getRelation(payRequest, sku, yhsId);
|
|
|
relationId = relation.getId();
|
|
relationId = relation.getId();
|
|
@@ -649,9 +683,15 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setDeposit(rentGoodsDonDeposit);
|
|
orderDon.setDeposit(rentGoodsDonDeposit);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- orderDon.setMoney(payRequest.getDonMoney());
|
|
|
|
|
- orderDon.setRealMoney(payRequest.getDonMoney());
|
|
|
|
|
- orderDon.setOriMoney(sku != null ? sku.getPrice() : orderDon.getMoney());
|
|
|
|
|
|
|
+ BigDecimal authoritativeTotal = multiQuantity
|
|
|
|
|
+ ? sku.getPrice().multiply(BigDecimal.valueOf(quantity.longValue()))
|
|
|
|
|
+ : payRequest.getDonMoney();
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ payRequest.setDonMoney(authoritativeTotal);
|
|
|
|
|
+ }
|
|
|
|
|
+ orderDon.setMoney(authoritativeTotal);
|
|
|
|
|
+ orderDon.setRealMoney(authoritativeTotal);
|
|
|
|
|
+ orderDon.setOriMoney(multiQuantity ? authoritativeTotal : (sku != null ? sku.getPrice() : orderDon.getMoney()));
|
|
|
|
|
|
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
@@ -688,7 +728,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setGoodsId(goodsDon.getId());
|
|
orderDon.setGoodsId(goodsDon.getId());
|
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
orderDon.setStatus(OrderDon.Status.noPayment);
|
|
|
orderDon.setUserId(user.getId());
|
|
orderDon.setUserId(user.getId());
|
|
|
- orderDon.setType(OrderDon.Type.getType(payRequest.getType()));
|
|
|
|
|
|
|
+ orderDon.setType(resolveSubmitPaymentType(multiQuantity, payRequest.getType()));
|
|
|
orderDon.setIsWebPay(payRequest.getIsWebPay());
|
|
orderDon.setIsWebPay(payRequest.getIsWebPay());
|
|
|
orderDon.setSource(payRequest.getSource());
|
|
orderDon.setSource(payRequest.getSource());
|
|
|
orderDon.setCouponExCode(payRequest.getCouponExCode());
|
|
orderDon.setCouponExCode(payRequest.getCouponExCode());
|
|
@@ -715,7 +755,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
if (sku != null) {
|
|
if (sku != null) {
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
- deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon, payRequest.getGcCash(), payRequest.getGcpIds(), payRequest.getIsAcReduce(), subsidyId, sku, payRequest.getGalaxyCoin(), null);
|
|
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ deductGalaxyCoinPayOrderMoney(orderDon, authoritativeTotal, payRequest.getGalaxyCoin(), user);
|
|
|
|
|
+ deductBalancePayOrderMoney(orderDon, payRequest.getBalance(), user);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(),
|
|
|
|
|
+ goodsDon, payRequest.getGcCash(), payRequest.getGcpIds(),
|
|
|
|
|
+ payRequest.getIsAcReduce(), subsidyId, sku, payRequest.getGalaxyCoin(), null);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
@@ -734,6 +781,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
groupsRelationMapper.updateById(relation);
|
|
groupsRelationMapper.updateById(relation);
|
|
|
}
|
|
}
|
|
|
this.saveOrUpdate(orderDon);
|
|
this.saveOrUpdate(orderDon);
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ multiQuantityOrderService.initialize(orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Long orderId = orderDon.getId();
|
|
Long orderId = orderDon.getId();
|
|
|
//使用银河币记录
|
|
//使用银河币记录
|
|
@@ -828,6 +878,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//余额支付订单
|
|
//余额支付订单
|
|
|
if (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0) {
|
|
if (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
orderDon = orderDonMapper.selectById(orderId);
|
|
orderDon = orderDonMapper.selectById(orderId);
|
|
|
|
|
+ orderDon.setPayTime(DateTime.now());
|
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
}
|
|
}
|
|
|
if (orderDon.getStatus() == OrderDon.Status.noPayment) {
|
|
if (orderDon.getStatus() == OrderDon.Status.noPayment) {
|
|
@@ -958,12 +1009,66 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void validateMultiQuantitySubmit(OrderPayRequest request, GoodsDon goods,
|
|
|
|
|
+ GoodsDonSku sku, boolean giftCardOrder, Long shopId) {
|
|
|
|
|
+ if (goods.getType() == null || goods.getType() != 1 || sku == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("多数量下单仅支持已配置的虚拟商品");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getUserId() == null || Boolean.TRUE.equals(request.getIsNoLogin())
|
|
|
|
|
+ || StrUtil.isNotBlank(request.getPhone())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("多数量下单必须使用已登录账号");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (giftCardOrder || goods.getSpecialType() != null || Boolean.TRUE.equals(sku.getIsMirror())
|
|
|
|
|
+ || Boolean.TRUE.equals(sku.getIsDp()) || Boolean.TRUE.equals(request.getIsSpecificPrice())
|
|
|
|
|
+ || Boolean.TRUE.equals(request.getIsAcReduce()) || request.getSubsidyId() != null
|
|
|
|
|
+ || request.getPackageId() != null || request.getOriginalOrderId() != null
|
|
|
|
|
+ || request.getBenefitsId() != null || request.getRenewSource() != null
|
|
|
|
|
+ || request.getGcCash() != null || CollUtil.isNotEmpty(request.getGcpIds())
|
|
|
|
|
+ || CollUtil.isNotEmpty(request.getDpSkuIds()) || request.getCmt() == null
|
|
|
|
|
+ || request.getCmt() != 1 || (shopId != null && shopId > 0)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该下单方式不支持多数量购买");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (goods.getId() == Constant.CLAUDE_CODE_GOODS_ID
|
|
|
|
|
+ || goods.getId() == Constant.CODEX_GOODS_ID
|
|
|
|
|
+ || goods.getId() == Constant.NANO_GOODS_ID) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该商品存在续期或专属发放逻辑,暂不支持多数量购买");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getCouponId() != null || StrUtil.isNotBlank(request.getCouponExCode())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("多数量下单不支持优惠券或优惠码");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request.getRelationId() != null && request.getRelationId() > 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("多数量下单不支持指定或续费车票");
|
|
|
|
|
+ }
|
|
|
|
|
+ OrderDon.Type payType = OrderDon.Type.getType(request.getType());
|
|
|
|
|
+ if (payType == OrderDon.Type.STRIPE || payType == OrderDon.Type.PAYPAL) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("Multi-quantity orders do not support PayPal or Stripe yet");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static int normalizeCmt(Integer cmt) {
|
|
|
|
|
+ return Optional.ofNullable(cmt).orElse(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static boolean isSkuEnabled(GoodsDonSku sku) {
|
|
|
|
|
+ return sku != null && Boolean.TRUE.equals(sku.getStatus());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static OrderDon.Type resolveSubmitPaymentType(boolean multiQuantity, String requestedType) {
|
|
|
|
|
+ if (multiQuantity && StrUtil.isBlank(requestedType)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return OrderDon.Type.getType(requestedType);
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
public H5JsPayParams pay(Long orderId, String tradeType) throws Exception {
|
|
public H5JsPayParams pay(Long orderId, String tradeType) throws Exception {
|
|
|
log.info("调起微信支付[start] orderId:{}", orderId);
|
|
log.info("调起微信支付[start] orderId:{}", orderId);
|
|
|
|
|
|
|
|
OrderDon orderDon = this.getById(orderId);
|
|
OrderDon orderDon = this.getById(orderId);
|
|
|
-
|
|
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean multiQuantity = multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId());
|
|
|
|
|
+ validateMultiQuantityPrepay(orderDon, OrderDon.Type.WeChat, multiQuantity);
|
|
|
OrderAttach attach = new OrderAttach();
|
|
OrderAttach attach = new OrderAttach();
|
|
|
attach.setO(orderDon.getId());
|
|
attach.setO(orderDon.getId());
|
|
|
|
|
|
|
@@ -976,10 +1081,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (shopConfig != null) {
|
|
if (shopConfig != null) {
|
|
|
shopId = shopConfig.getAppId();
|
|
shopId = shopConfig.getAppId();
|
|
|
}
|
|
}
|
|
|
- orderDon.setType(OrderDon.Type.WeChat);
|
|
|
|
|
- orderDon.setShopId(shopId);
|
|
|
|
|
- orderDon.setIsWebPay(false);
|
|
|
|
|
- this.updateById(orderDon);
|
|
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ multiQuantityOrderService.preparePrepay(orderDon, OrderDon.Type.WeChat, shopId, false);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ orderDon.setType(OrderDon.Type.WeChat);
|
|
|
|
|
+ orderDon.setShopId(shopId);
|
|
|
|
|
+ orderDon.setIsWebPay(false);
|
|
|
|
|
+ this.updateById(orderDon);
|
|
|
|
|
+ }
|
|
|
H5JsPayParams params = weChatService.getJsPayParams(
|
|
H5JsPayParams params = weChatService.getJsPayParams(
|
|
|
weChatConfig.getAppid(),
|
|
weChatConfig.getAppid(),
|
|
|
shopId,
|
|
shopId,
|
|
@@ -1001,7 +1110,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
public H5JsPayParams wxPcWebPay(Long orderId, String tradeType) throws Exception {
|
|
public H5JsPayParams wxPcWebPay(Long orderId, String tradeType) throws Exception {
|
|
|
log.info("调起微信支付[start] orderId:{}", orderId);
|
|
log.info("调起微信支付[start] orderId:{}", orderId);
|
|
|
OrderDon orderDon = this.getById(orderId);
|
|
OrderDon orderDon = this.getById(orderId);
|
|
|
-
|
|
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean multiQuantity = multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId());
|
|
|
|
|
+ validateMultiQuantityPrepay(orderDon, OrderDon.Type.WeChat, multiQuantity);
|
|
|
OrderAttach attach = new OrderAttach();
|
|
OrderAttach attach = new OrderAttach();
|
|
|
attach.setO(orderDon.getId());
|
|
attach.setO(orderDon.getId());
|
|
|
|
|
|
|
@@ -1015,10 +1128,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (shopConfig != null) {
|
|
if (shopConfig != null) {
|
|
|
shopId = shopConfig.getAppId();
|
|
shopId = shopConfig.getAppId();
|
|
|
}
|
|
}
|
|
|
- orderDon.setShopId(shopId);
|
|
|
|
|
- orderDon.setType(OrderDon.Type.WeChat);
|
|
|
|
|
- orderDon.setIsWebPay(true);
|
|
|
|
|
- this.updateById(orderDon);
|
|
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ multiQuantityOrderService.preparePrepay(orderDon, OrderDon.Type.WeChat, shopId, true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ orderDon.setShopId(shopId);
|
|
|
|
|
+ orderDon.setType(OrderDon.Type.WeChat);
|
|
|
|
|
+ orderDon.setIsWebPay(true);
|
|
|
|
|
+ this.updateById(orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
H5JsPayParams params = weChatService.getJsPayParams(
|
|
H5JsPayParams params = weChatService.getJsPayParams(
|
|
|
weChatConfig.getAppid(),
|
|
weChatConfig.getAppid(),
|
|
@@ -1037,6 +1154,19 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return params;
|
|
return params;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void validateMultiQuantityPrepay(OrderDon orderDon, OrderDon.Type requestedType,
|
|
|
|
|
+ boolean multiQuantity) {
|
|
|
|
|
+ if (!multiQuantity) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderDon.getStatus() != OrderDon.Status.noPayment) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单已处理,请勿重复支付");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderDon.getType() != null && orderDon.getType() != requestedType) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单支付方式已确定,请勿切换支付方式");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@Override
|
|
@Override
|
|
@@ -1060,13 +1190,29 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.info("微信商家订单号orderNo:{},status:{},进行回调", order.getOrderNo(), order.getStatus());
|
|
log.info("微信商家订单号orderNo:{},status:{},进行回调", order.getOrderNo(), order.getStatus());
|
|
|
|
|
|
|
|
String appId = map.get("mch_id");
|
|
String appId = map.get("mch_id");
|
|
|
|
|
+ ShopConfig callbackShop = shopConfigMapper.getByAppId(appId);
|
|
|
|
|
+ if (callbackShop == null || !StrUtil.equals(appId, order.getShopId())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("微信支付回调商户不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 校验签名
|
|
// 校验签名
|
|
|
- boolean f = weChatService.checkSignWithMd5(map, shopConfigMapper.getByAppId(appId).getSecret());
|
|
|
|
|
|
|
+ boolean f = weChatService.checkSignWithMd5(map, callbackShop.getSecret());
|
|
|
if (!f) {
|
|
if (!f) {
|
|
|
log.error("回调数据:{}", map);
|
|
log.error("回调数据:{}", map);
|
|
|
throw BusinessRuntimeException.getInstance("支付成功回调, 校验签名失败.");
|
|
throw BusinessRuntimeException.getInstance("支付成功回调, 校验签名失败.");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!StrUtil.equals(order.getOrderNo(), map.get("out_trade_no"))) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("微信支付回调订单号不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal callbackMoney;
|
|
|
|
|
+ try {
|
|
|
|
|
+ callbackMoney = new BigDecimal(map.get("total_fee"));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("微信支付回调金额异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (order.getMoney() == null || callbackMoney.compareTo(order.getMoney()) != 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("微信支付回调金额不匹配");
|
|
|
|
|
+ }
|
|
|
GoodsDonSku sku = null;
|
|
GoodsDonSku sku = null;
|
|
|
if (order.getSkuId() != null) {
|
|
if (order.getSkuId() != null) {
|
|
|
sku = goodsDonSkuMapper.selectById(order.getSkuId());
|
|
sku = goodsDonSkuMapper.selectById(order.getSkuId());
|
|
@@ -1076,6 +1222,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
String transactionId = map.get("transaction_id");
|
|
String transactionId = map.get("transaction_id");
|
|
|
|
|
|
|
|
if (!order.getStatus().equals(OrderDon.Status.noPayment) && !order.getStatus().equals(OrderDon.Status.close)) {
|
|
if (!order.getStatus().equals(OrderDon.Status.noPayment) && !order.getStatus().equals(OrderDon.Status.close)) {
|
|
|
|
|
+ if (StrUtil.isNotBlank(order.getTransactionId())
|
|
|
|
|
+ && !StrUtil.equals(order.getTransactionId(), transactionId)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("微信支付交易号不匹配");
|
|
|
|
|
+ }
|
|
|
log.info("已回调,重复修改状态 id:{}", order.getId());
|
|
log.info("已回调,重复修改状态 id:{}", order.getId());
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1124,6 +1274,26 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (orderDon == null) {
|
|
if (orderDon == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ if (orderDon.getStatus() == OrderDon.Status.noPayment
|
|
|
|
|
+ && multiQuantityOrderService.isMultiQuantityOrder(orderId)) {
|
|
|
|
|
+ PaymentQueryState queryState = queryAndSyncPaymentState(orderDon);
|
|
|
|
|
+ if (queryState == PaymentQueryState.UNKNOWN) {
|
|
|
|
|
+ schedulePaymentQueryRetry(orderDon);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (queryState != PaymentQueryState.NOT_PAID) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ clearPaymentQueryRetry(orderDon.getId());
|
|
|
|
|
+ int closed = orderDonMapper.update(null, Wrappers.lambdaUpdate(OrderDon.class)
|
|
|
|
|
+ .set(OrderDon::getStatus, OrderDon.Status.close)
|
|
|
|
|
+ .eq(OrderDon::getId, orderId)
|
|
|
|
|
+ .eq(OrderDon::getStatus, OrderDon.Status.noPayment));
|
|
|
|
|
+ if (closed == 1) {
|
|
|
|
|
+ returnMultiQuantityPaymentBenefits(orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (userId != null) {
|
|
if (userId != null) {
|
|
|
List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
if (!relationUserIdList.contains(orderDon.getUserId())) {
|
|
if (!relationUserIdList.contains(orderDon.getUserId())) {
|
|
@@ -1133,8 +1303,13 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.info("关闭订单 orderId:{}", orderId);
|
|
log.info("关闭订单 orderId:{}", orderId);
|
|
|
if (OrderDon.Status.noPayment.equals(orderDon.getStatus())) {
|
|
if (OrderDon.Status.noPayment.equals(orderDon.getStatus())) {
|
|
|
//调用微信、支付宝第三方接口查询订单是否支付
|
|
//调用微信、支付宝第三方接口查询订单是否支付
|
|
|
- OrderDon.Status status = isHasPaid(orderDon);
|
|
|
|
|
- if (status == OrderDon.Status.noPayment) {
|
|
|
|
|
|
|
+ PaymentQueryState queryState = queryAndSyncPaymentState(orderDon);
|
|
|
|
|
+ if (queryState == PaymentQueryState.UNKNOWN) {
|
|
|
|
|
+ schedulePaymentQueryRetry(orderDon);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (queryState == PaymentQueryState.NOT_PAID) {
|
|
|
|
|
+ clearPaymentQueryRetry(orderDon.getId());
|
|
|
//查询微信支付是否已支付
|
|
//查询微信支付是否已支付
|
|
|
orderDon.setStatus(OrderDon.Status.close);
|
|
orderDon.setStatus(OrderDon.Status.close);
|
|
|
updateById(orderDon);
|
|
updateById(orderDon);
|
|
@@ -1192,6 +1367,29 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void returnMultiQuantityPaymentBenefits(OrderDon orderDon) {
|
|
|
|
|
+ if (Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ Integer returned = userBalanceSourceRecordMapper.selectCount(Wrappers.lambdaQuery(UserBalanceSourceRecord.class)
|
|
|
|
|
+ .eq(UserBalanceSourceRecord::getOrderId, orderDon.getId())
|
|
|
|
|
+ .eq(UserBalanceSourceRecord::getSource, UserBalanceSourceRecord.Source.order_close));
|
|
|
|
|
+ if (returned == null || returned == 0) {
|
|
|
|
|
+ userBenefitsService.addUserBalance(orderDon.getUserId(), orderDon.getBalance(),
|
|
|
|
|
+ UserBalanceSourceRecord.Source.order_close, null, orderDon.getId(),
|
|
|
|
|
+ UserBalanceSourceRecord.Source.order_close.getDesc(), true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ UserGalaxyCoinRecord useRecord = userGalaxyCoinRecordMapper.selectOne(
|
|
|
|
|
+ Wrappers.lambdaQuery(UserGalaxyCoinRecord.class)
|
|
|
|
|
+ .eq(UserGalaxyCoinRecord::getOrderId, orderDon.getId())
|
|
|
|
|
+ .eq(UserGalaxyCoinRecord::getSource, OrderDonGalaxyCoinRecord.Source.ordinary.ordinal())
|
|
|
|
|
+ .eq(UserGalaxyCoinRecord::getRemark, PointsRecordConst.ORDER)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (useRecord != null) {
|
|
|
|
|
+ userGalaxyCoinService.sendOrderGalaxyCloseOrder(orderDon.getId(), orderDon.getUserId(),
|
|
|
|
|
+ useRecord.getGalaxyCoin().abs(), OrderDonGalaxyCoinRecord.Source.ordinary);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public OrderDon renewal(OrderPayRequest payRequest) throws Exception {
|
|
public OrderDon renewal(OrderPayRequest payRequest) throws Exception {
|
|
@@ -1453,16 +1651,42 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
@Override
|
|
@Override
|
|
|
public OrderDetailView getDetail(Long orderId, Long userId) {
|
|
public OrderDetailView getDetail(Long orderId, Long userId) {
|
|
|
OrderDon orderDon = this.getById(orderId);
|
|
OrderDon orderDon = this.getById(orderId);
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
|
|
+ }
|
|
|
MapBuilder builder = MapUtils.builder()
|
|
MapBuilder builder = MapUtils.builder()
|
|
|
.field(OrderDonView::getId, orderId)
|
|
.field(OrderDonView::getId, orderId)
|
|
|
.orderBy(OrderDonView::getId).desc();
|
|
.orderBy(OrderDonView::getId).desc();
|
|
|
- if (userId != null && orderDon.getOrderType() != 2) {
|
|
|
|
|
|
|
+ boolean multiQuantity = multiQuantityOrderService.isMultiQuantityOrder(orderId);
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ if (!isMultiQuantityOrderOwner(orderDon, userId)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在或无权查看");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (userId != null && orderDon.getOrderType() != 2) {
|
|
|
builder.field(OrderDonView::getUserId, userId);
|
|
builder.field(OrderDonView::getUserId, userId);
|
|
|
}
|
|
}
|
|
|
OrderDetailView detail = beanSearcher.searchFirst(OrderDetailView.class, builder.build());
|
|
OrderDetailView detail = beanSearcher.searchFirst(OrderDetailView.class, builder.build());
|
|
|
|
|
+ if (detail == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在或无权查看");
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> userIdList = userId == null
|
|
|
|
|
+ ? Collections.emptyList()
|
|
|
|
|
+ : (multiQuantity ? List.of(orderDon.getUserId())
|
|
|
|
|
+ : userBindRelationService.getRelationUserIdList(userId, null));
|
|
|
|
|
+ if (multiQuantity) {
|
|
|
|
|
+ List<MultiQuantityOrderTicketView> tickets = orderDonTicketQueryMapper.selectOrderTicketViews(orderId, userIdList);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(tickets)) {
|
|
|
|
|
+ detail.setMultiQuantity(true);
|
|
|
|
|
+ detail.setTicketTotal(detail.getNum());
|
|
|
|
|
+ detail.setDeliveredCount((int) tickets.stream()
|
|
|
|
|
+ .filter(ticket -> ticket.getDeliveryStatus() == OrderDonTicketRecord.Status.success)
|
|
|
|
|
+ .count());
|
|
|
|
|
+ detail.setTickets(tickets);
|
|
|
|
|
+ return detail;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
//获取对应车票订单 账号密码
|
|
//获取对应车票订单 账号密码
|
|
|
if (userId != null) {
|
|
if (userId != null) {
|
|
|
- List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
|
|
RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
|
|
|
.field(RenewalView::getUserId, userIdList).op(Operator.InList)
|
|
.field(RenewalView::getUserId, userIdList).op(Operator.InList)
|
|
|
.field(RenewalView::getRelationId, detail.getRelationId())
|
|
.field(RenewalView::getRelationId, detail.getRelationId())
|
|
@@ -1481,6 +1705,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return detail;
|
|
return detail;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static boolean isMultiQuantityOrderOwner(OrderDon orderDon, Long userId) {
|
|
|
|
|
+ return orderDon != null && userId != null && userId.equals(orderDon.getUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<OrderDon> getAppleOneOrderDons(List<Long> skuIds, List<String> noOrderStatus, Date yesZeroDate, Date thisZeroDate) {
|
|
public List<OrderDon> getAppleOneOrderDons(List<Long> skuIds, List<String> noOrderStatus, Date yesZeroDate, Date thisZeroDate) {
|
|
|
return orderDonMapper.getAppleOneOrderDons(skuIds, noOrderStatus, yesZeroDate, thisZeroDate);
|
|
return orderDonMapper.getAppleOneOrderDons(skuIds, noOrderStatus, yesZeroDate, thisZeroDate);
|
|
@@ -1505,21 +1733,39 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (null == orderDon) {
|
|
if (null == orderDon) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在.");
|
|
throw BusinessRuntimeException.getInstance("订单不存在.");
|
|
|
}
|
|
}
|
|
|
- if (orderDon.getPopularizeId() == null) {
|
|
|
|
|
- orderDon.setShopId(null);
|
|
|
|
|
- }
|
|
|
|
|
String appId = params.get("app_id");
|
|
String appId = params.get("app_id");
|
|
|
- boolean signVerified = AlipaySignature.rsaCheckV1(params, shopConfigMapper.getByAppId(appId).getPublicKey(), BaseZfbConfig.charset, BaseZfbConfig.signType);
|
|
|
|
|
|
|
+ ShopConfig callbackShop = shopConfigMapper.getByAppId(appId);
|
|
|
|
|
+ if (callbackShop == null || !isCallbackShopMatched(orderDon.getShopId(), appId)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝回调商户不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean signVerified = AlipaySignature.rsaCheckV1(params, callbackShop.getPublicKey(), BaseZfbConfig.charset, BaseZfbConfig.signType);
|
|
|
if (!signVerified) {
|
|
if (!signVerified) {
|
|
|
log.error("支付宝回调校验签名错误,自定义入参:{}", params.get("body"));
|
|
log.error("支付宝回调校验签名错误,自定义入参:{}", params.get("body"));
|
|
|
throw BusinessRuntimeException.getInstance("支付宝回调校验签名错误");
|
|
throw BusinessRuntimeException.getInstance("支付宝回调校验签名错误");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!StrUtil.equals(orderDon.getOrderNo(), orderNo) || !ObjectUtil.equal(orderDon.getId(), oderId)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝回调订单号不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal callbackMoney;
|
|
|
|
|
+ try {
|
|
|
|
|
+ callbackMoney = new BigDecimal(params.get("total_amount"))
|
|
|
|
|
+ .multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.UNNECESSARY);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝回调金额异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderDon.getMoney() == null || callbackMoney.compareTo(orderDon.getMoney()) != 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝回调金额不匹配");
|
|
|
|
|
+ }
|
|
|
String transactionId = params.get("trade_no");
|
|
String transactionId = params.get("trade_no");
|
|
|
String payTimeStr = params.get("gmt_payment");
|
|
String payTimeStr = params.get("gmt_payment");
|
|
|
//买家支付宝账号
|
|
//买家支付宝账号
|
|
|
String buyerId = Optional.ofNullable(params.get("buyer_id")).orElse(params.get("buyer_open_id"));
|
|
String buyerId = Optional.ofNullable(params.get("buyer_id")).orElse(params.get("buyer_open_id"));
|
|
|
log.info("支付宝回调信息:{}", Jsons.toJson(params));
|
|
log.info("支付宝回调信息:{}", Jsons.toJson(params));
|
|
|
if (!orderDon.getStatus().equals(OrderDon.Status.noPayment) && !orderDon.getStatus().equals(OrderDon.Status.close)) {
|
|
if (!orderDon.getStatus().equals(OrderDon.Status.noPayment) && !orderDon.getStatus().equals(OrderDon.Status.close)) {
|
|
|
|
|
+ if (StrUtil.isNotBlank(orderDon.getTransactionId())
|
|
|
|
|
+ && !StrUtil.equals(orderDon.getTransactionId(), transactionId)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝交易号不匹配");
|
|
|
|
|
+ }
|
|
|
log.info("支付宝已回调,重复修改状态 id:{}", orderDon.getId());
|
|
log.info("支付宝已回调,重复修改状态 id:{}", orderDon.getId());
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1542,17 +1788,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setShopId(appId);
|
|
orderDon.setShopId(appId);
|
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
orderDon.setType(OrderDon.Type.ALI_PAY);
|
|
|
orderDon.setBuyerId(buyerId);
|
|
orderDon.setBuyerId(buyerId);
|
|
|
|
|
+ boolean multiQuantity = multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId());
|
|
|
//该支付账号id 是否被后台拉黑
|
|
//该支付账号id 是否被后台拉黑
|
|
|
- Integer count1 = userPayOrderBlockMapper.selectCount(Wrappers.lambdaQuery(UserPayOrderBlock.class)
|
|
|
|
|
- .eq(UserPayOrderBlock::getBuyerId, buyerId));
|
|
|
|
|
- if (count1 > 0) {
|
|
|
|
|
- log.info("该支付账号id:{} 已被后台拉黑", buyerId);
|
|
|
|
|
- notifyRefundOrder(orderDon, goodsDon, sku);
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ if (!multiQuantity) {
|
|
|
|
|
+ Integer count1 = userPayOrderBlockMapper.selectCount(Wrappers.lambdaQuery(UserPayOrderBlock.class)
|
|
|
|
|
+ .eq(UserPayOrderBlock::getBuyerId, buyerId));
|
|
|
|
|
+ if (count1 > 0) {
|
|
|
|
|
+ log.info("该支付账号id:{} 已被后台拉黑", buyerId);
|
|
|
|
|
+ notifyRefundOrder(orderDon, goodsDon, sku);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//是否是河南濮阳ip 直接退款mj
|
|
//是否是河南濮阳ip 直接退款mj
|
|
|
- if (orderDon.getGoodsId() == 26) {
|
|
|
|
|
|
|
+ if (!multiQuantity && orderDon.getGoodsId() == 26) {
|
|
|
OrderDonLocationRelate orderDonLocationRelate = orderDonLocationRelateMapper.selectOne(Wrappers.lambdaQuery(OrderDonLocationRelate.class)
|
|
OrderDonLocationRelate orderDonLocationRelate = orderDonLocationRelateMapper.selectOne(Wrappers.lambdaQuery(OrderDonLocationRelate.class)
|
|
|
.eq(OrderDonLocationRelate::getOrderId, orderDon.getId())
|
|
.eq(OrderDonLocationRelate::getOrderId, orderDon.getId())
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
@@ -1575,7 +1824,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//单个支付每月限购2单奈飞
|
|
//单个支付每月限购2单奈飞
|
|
|
- if (orderDon.getGoodsId() == 1) {
|
|
|
|
|
|
|
+ if (!multiQuantity && orderDon.getGoodsId() == 1) {
|
|
|
Boolean isCheck = true;
|
|
Boolean isCheck = true;
|
|
|
SysConfig purchaseLimitConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
SysConfig purchaseLimitConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
.eq(SysConfig::getSysKey, Constant.NF_PURCHASE_LIMIT_KEY)
|
|
.eq(SysConfig::getSysKey, Constant.NF_PURCHASE_LIMIT_KEY)
|
|
@@ -1607,7 +1856,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- if (orderDon.getOrderType() == 1 && StrUtil.isNotEmpty(buyerId)) {
|
|
|
|
|
|
|
+ if (!multiQuantity && orderDon.getOrderType() == 1 && StrUtil.isNotEmpty(buyerId)) {
|
|
|
//近一个月同一买家id 只能购买一次 多人 非镜像
|
|
//近一个月同一买家id 只能购买一次 多人 非镜像
|
|
|
if (orderDon.getGoodsId() == 26l && sku.getNum() != 1 && !sku.getIsMirror()) {
|
|
if (orderDon.getGoodsId() == 26l && sku.getNum() != 1 && !sku.getIsMirror()) {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(orderDon.getUserId(), null);
|
|
@@ -1638,7 +1887,14 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ static boolean isCallbackShopMatched(String persistedShopId, String callbackAppId) {
|
|
|
|
|
+ return StrUtil.isNotBlank(persistedShopId) && StrUtil.equals(persistedShopId, callbackAppId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void notifyRefundCodeOrderDon(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) throws Exception {
|
|
private void notifyRefundCodeOrderDon(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) throws Exception {
|
|
|
|
|
+ if (multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("Multi-quantity orders only support the unified whole-order refund flow");
|
|
|
|
|
+ }
|
|
|
//退款
|
|
//退款
|
|
|
OrderRefundReq orderRefundReq = new OrderRefundReq();
|
|
OrderRefundReq orderRefundReq = new OrderRefundReq();
|
|
|
orderRefundReq.setOrderId(orderDon.getId());
|
|
orderRefundReq.setOrderId(orderDon.getId());
|
|
@@ -1747,10 +2003,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
} else {
|
|
} else {
|
|
|
response = alipayClient.execute(request);
|
|
response = alipayClient.execute(request);
|
|
|
}
|
|
}
|
|
|
- if (response.isSuccess()) {
|
|
|
|
|
- return response;
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ return response;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -2266,16 +2519,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
distributeWaitingSendPointsMapper.insert(distributeWaitingSendPoints);
|
|
distributeWaitingSendPointsMapper.insert(distributeWaitingSendPoints);
|
|
|
- //暂定虚物 商务可首单提成
|
|
|
|
|
- //普通订单
|
|
|
|
|
- if (order.getOrderType() == 1 && businessId != null) {
|
|
|
|
|
- //是否是绑定两个月内的渠道
|
|
|
|
|
- Date businessBindTime = userDistribute.getBusinessBindTime();
|
|
|
|
|
- if (businessBindTime != null && businessBindTime.after(DateUtil.offsetMonth(DateTime.now(), -2))) {
|
|
|
|
|
- //给商务人员 分配提成权益
|
|
|
|
|
- userBusinessFrontService.taskDistributeRateBenefits(userDistributeShared.getSharedId(), businessId, goodsDon.getType(), order, rate);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+ log.info("订单id:{}分销待发记录已存在", order.getId());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ //暂定虚物 商务可首单提成
|
|
|
|
|
+ //普通订单
|
|
|
|
|
+ if (order.getOrderType() == 1 && businessId != null) {
|
|
|
|
|
+ //是否是绑定两个月内的渠道
|
|
|
|
|
+ Date businessBindTime = userDistribute.getBusinessBindTime();
|
|
|
|
|
+ if (businessBindTime != null && businessBindTime.after(DateUtil.offsetMonth(DateTime.now(), -2))) {
|
|
|
|
|
+ //给商务人员 分配提成权益
|
|
|
|
|
+ userBusinessFrontService.taskDistributeRateBenefits(userDistributeShared.getSharedId(), businessId, goodsDon.getType(), order, rate);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
//是否是cc普通推广
|
|
//是否是cc普通推广
|
|
|
//并且购买claude code作为首单
|
|
//并且购买claude code作为首单
|
|
|
// if (userDistribute == null && Constant.CC_DISTRIBUTE_MARK.equals(userDistributeShared.getRemark()) && order.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
// if (userDistribute == null && Constant.CC_DISTRIBUTE_MARK.equals(userDistributeShared.getRemark()) && order.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
@@ -2287,9 +2544,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
// log.error("给用户{}发放claude code积分卡失败:{}", userDistributeShared.getSharedId(), e.getMessage());
|
|
// log.error("给用户{}发放claude code积分卡失败:{}", userDistributeShared.getSharedId(), e.getMessage());
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -2625,44 +2879,168 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
* 查询第三放接口订单是否已支付
|
|
* 查询第三放接口订单是否已支付
|
|
|
*/
|
|
*/
|
|
|
public OrderDon.Status isHasPaid(OrderDon orderDon) {
|
|
public OrderDon.Status isHasPaid(OrderDon orderDon) {
|
|
|
|
|
+ queryAndSyncPaymentState(orderDon);
|
|
|
|
|
+ return orderDon.getStatus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private PaymentQueryState queryAndSyncPaymentState(OrderDon orderDon) {
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
if (orderDon.getType() == OrderDon.Type.WeChat) {
|
|
if (orderDon.getType() == OrderDon.Type.WeChat) {
|
|
|
try {
|
|
try {
|
|
|
- Map<String, String> reMap = weChatService.getWxOrderDetail(orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
|
|
- if (reMap != null) {
|
|
|
|
|
- String orderStatus = reMap.get("trade_state");
|
|
|
|
|
- if ("SUCCESS".equals(orderStatus)) {
|
|
|
|
|
- orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
|
|
- orderDon.setTransactionId(reMap.get("transaction_id"));
|
|
|
|
|
- return updateNoPayment(orderDon, goodsDon);
|
|
|
|
|
|
|
+ Map<String, String> result = weChatService.getWxOrderDetail(
|
|
|
|
|
+ orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
|
|
+ PaymentQueryState queryState = classifyWxPaymentQuery(result);
|
|
|
|
|
+ if (queryState == PaymentQueryState.PAID) {
|
|
|
|
|
+ validateWxActiveQuery(orderDon, result);
|
|
|
|
|
+ orderDon.setTransactionId(result.get("transaction_id"));
|
|
|
|
|
+ if (StrUtil.isNotBlank(result.get("time_end"))) {
|
|
|
|
|
+ orderDon.setPayTime(DateUtil.parse(result.get("time_end"), "yyyyMMddHHmmss"));
|
|
|
}
|
|
}
|
|
|
|
|
+ updateNoPayment(orderDon, goodsDon);
|
|
|
|
|
+ clearPaymentQueryRetry(orderDon.getId());
|
|
|
}
|
|
}
|
|
|
|
|
+ return queryState;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
|
|
|
|
+ log.error("微信主动查单校验失败, orderId:{}", orderDon.getId(), e);
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
}
|
|
}
|
|
|
} else if (orderDon.getType() == OrderDon.Type.ALI_PAY) {
|
|
} else if (orderDon.getType() == OrderDon.Type.ALI_PAY) {
|
|
|
try {
|
|
try {
|
|
|
- AlipayTradeQueryResponse zfbOrderDetail = getZfbOrderDetail(orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
|
|
- if (zfbOrderDetail != null) {
|
|
|
|
|
- String tradeStatus = zfbOrderDetail.getTradeStatus();
|
|
|
|
|
- if ("TRADE_SUCCESS".equals(tradeStatus)) {
|
|
|
|
|
- orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
|
|
- orderDon.setTransactionId(zfbOrderDetail.getTradeNo());
|
|
|
|
|
- Date sendPayDate = zfbOrderDetail.getSendPayDate();
|
|
|
|
|
- orderDon.setPayTime(sendPayDate);
|
|
|
|
|
- //买家支付宝账号
|
|
|
|
|
- String buyerId = Optional.ofNullable(zfbOrderDetail.getBuyerUserId()).orElse(zfbOrderDetail.getBuyerOpenId());
|
|
|
|
|
- orderDon.setBuyerId(buyerId);
|
|
|
|
|
- return updateNoPayment(orderDon, goodsDon);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ AlipayTradeQueryResponse result = getZfbOrderDetail(
|
|
|
|
|
+ orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
|
|
+ PaymentQueryState queryState = classifyAliPaymentQuery(result);
|
|
|
|
|
+ if (queryState == PaymentQueryState.PAID) {
|
|
|
|
|
+ validateAliActiveQuery(orderDon, result);
|
|
|
|
|
+ orderDon.setTransactionId(result.getTradeNo());
|
|
|
|
|
+ orderDon.setPayTime(result.getSendPayDate());
|
|
|
|
|
+ orderDon.setBuyerId(Optional.ofNullable(result.getBuyerUserId())
|
|
|
|
|
+ .orElse(result.getBuyerOpenId()));
|
|
|
|
|
+ updateNoPayment(orderDon, goodsDon);
|
|
|
|
|
+ clearPaymentQueryRetry(orderDon.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ return queryState;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
+ log.error("支付宝主动查单校验失败, orderId:{}", orderDon.getId(), e);
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return PaymentQueryState.NOT_PAID;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ static PaymentQueryState classifyWxPaymentQuery(Map<String, String> result) {
|
|
|
|
|
+ if (result == null || !"SUCCESS".equals(result.get("return_code"))) {
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!"SUCCESS".equals(result.get("result_code"))) {
|
|
|
|
|
+ return "ORDERNOTEXIST".equals(result.get("err_code"))
|
|
|
|
|
+ ? PaymentQueryState.NOT_PAID : PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+ String tradeState = result.get("trade_state");
|
|
|
|
|
+ if ("SUCCESS".equals(tradeState)) {
|
|
|
|
|
+ return PaymentQueryState.PAID;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("NOTPAY".equals(tradeState) || "CLOSED".equals(tradeState)
|
|
|
|
|
+ || "REVOKED".equals(tradeState) || "PAYERROR".equals(tradeState)) {
|
|
|
|
|
+ return PaymentQueryState.NOT_PAID;
|
|
|
|
|
+ }
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static PaymentQueryState classifyAliPaymentQuery(AlipayTradeQueryResponse result) {
|
|
|
|
|
+ if (result == null) {
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+ return classifyAliPaymentQuery(result.isSuccess(), result.getSubCode(), result.getTradeStatus());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static PaymentQueryState classifyAliPaymentQuery(boolean success, String subCode, String tradeStatus) {
|
|
|
|
|
+ if (!success) {
|
|
|
|
|
+ return "ACQ.TRADE_NOT_EXIST".equals(subCode)
|
|
|
|
|
+ ? PaymentQueryState.NOT_PAID : PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)) {
|
|
|
|
|
+ return PaymentQueryState.PAID;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("WAIT_BUYER_PAY".equals(tradeStatus)) {
|
|
|
|
|
+ return PaymentQueryState.NOT_PAID;
|
|
|
|
|
+ }
|
|
|
|
|
+ return PaymentQueryState.UNKNOWN;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void schedulePaymentQueryRetry(OrderDon orderDon) {
|
|
|
|
|
+ String retryKey = PAYMENT_QUERY_RETRY_KEY + orderDon.getId();
|
|
|
|
|
+ try {
|
|
|
|
|
+ Long retryNum = redisService.incr(retryKey, 1L);
|
|
|
|
|
+ if (retryNum != null && retryNum == 1L) {
|
|
|
|
|
+ redisService.expire(retryKey, 24 * 60 * 60L);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (retryNum != null && retryNum <= PAYMENT_QUERY_MAX_RETRIES) {
|
|
|
|
|
+ jobManager.addJob(PAYMENT_QUERY_RETRY_DELAY,
|
|
|
|
|
+ () -> closeOrder(orderDon.getId(), null));
|
|
|
|
|
+ log.warn("支付状态查询未知,已安排重试, orderId:{}, retry:{}",
|
|
|
|
|
+ orderDon.getId(), retryNum);
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+ log.error("支付状态查询连续失败,停止主服务重试并等待外部任务兜底, orderId:{}",
|
|
|
|
|
+ orderDon.getId());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("安排支付状态查询重试失败, orderId:{}", orderDon.getId(), e);
|
|
|
}
|
|
}
|
|
|
- return orderDon.getStatus();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void clearPaymentQueryRetry(Long orderId) {
|
|
|
|
|
+ if (orderId != null) {
|
|
|
|
|
+ redisService.del(PAYMENT_QUERY_RETRY_KEY + orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ enum PaymentQueryState {
|
|
|
|
|
+ PAID,
|
|
|
|
|
+ NOT_PAID,
|
|
|
|
|
+ UNKNOWN
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void validateWxActiveQuery(OrderDon order, Map<String, String> result) {
|
|
|
|
|
+ if (!StrUtil.equals(order.getShopId(), result.get("mch_id"))
|
|
|
|
|
+ || !StrUtil.equals(order.getOrderNo(), result.get("out_trade_no"))
|
|
|
|
|
+ || !matchesPersistedTransaction(order.getTransactionId(), result.get("transaction_id"))
|
|
|
|
|
+ || !matchesCentAmount(order.getMoney(), result.get("total_fee"))) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("微信主动查单信息不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void validateAliActiveQuery(OrderDon order, AlipayTradeQueryResponse result) {
|
|
|
|
|
+ if (!StrUtil.equals(order.getOrderNo(), result.getOutTradeNo())
|
|
|
|
|
+ || !matchesPersistedTransaction(order.getTransactionId(), result.getTradeNo())
|
|
|
|
|
+ || !matchesYuanAmount(order.getMoney(), result.getTotalAmount())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝主动查单信息不匹配");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static boolean matchesPersistedTransaction(String persisted, String queried) {
|
|
|
|
|
+ return StrUtil.isBlank(persisted) || StrUtil.equals(persisted, queried);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static boolean matchesCentAmount(BigDecimal expectedCent, String actualCent) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return expectedCent != null && new BigDecimal(actualCent).compareTo(expectedCent) == 0;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static boolean matchesYuanAmount(BigDecimal expectedCent, String actualYuan) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ BigDecimal actualCent = new BigDecimal(actualYuan).multiply(BigDecimal.valueOf(100))
|
|
|
|
|
+ .setScale(0, RoundingMode.UNNECESSARY);
|
|
|
|
|
+ return expectedCent != null && actualCent.compareTo(expectedCent) == 0;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
private OrderDon.Status updateNoPayment(OrderDon orderDon, GoodsDon goodsDon) {
|
|
private OrderDon.Status updateNoPayment(OrderDon orderDon, GoodsDon goodsDon) {
|
|
|
GoodsDonSku sku = null;
|
|
GoodsDonSku sku = null;
|
|
|
if (orderDon.getSkuId() != null) {
|
|
if (orderDon.getSkuId() != null) {
|
|
@@ -3058,6 +3436,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDonGalaxyCoinRecord.setOrderNo(orderDon.getOrderNo());
|
|
orderDonGalaxyCoinRecord.setOrderNo(orderDon.getOrderNo());
|
|
|
orderDonGalaxyCoinRecord.setGalaxyCoin(subGalxyCoin);
|
|
orderDonGalaxyCoinRecord.setGalaxyCoin(subGalxyCoin);
|
|
|
orderDonGalaxyCoinRecord.setDeductMoney(thisDeductMoney);
|
|
orderDonGalaxyCoinRecord.setDeductMoney(thisDeductMoney);
|
|
|
|
|
+ orderDonGalaxyCoinRecord.setSource(OrderDonGalaxyCoinRecord.Source.ordinary.ordinal());
|
|
|
orderDonGalaxyCoinRecordMapper.insert(orderDonGalaxyCoinRecord);
|
|
orderDonGalaxyCoinRecordMapper.insert(orderDonGalaxyCoinRecord);
|
|
|
orderDon.setMoney(orderMoney.subtract(thisDeductMoney));
|
|
orderDon.setMoney(orderMoney.subtract(thisDeductMoney));
|
|
|
}
|
|
}
|
|
@@ -3172,6 +3551,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
* 统一订单信息回调
|
|
* 统一订单信息回调
|
|
|
*/
|
|
*/
|
|
|
public void unifiedHandlerOrderNotify(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) {
|
|
public void unifiedHandlerOrderNotify(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) {
|
|
|
|
|
+ if (multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId())) {
|
|
|
|
|
+ multiQuantityOrderService.handlePaidOrder(orderDon, goodsDon, sku);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
|
|
|
//补差价
|
|
//补差价
|
|
|
if (goodsDon.getType() != null && goodsDon.getType() == 5) {
|
|
if (goodsDon.getType() != null && goodsDon.getType() == 5) {
|
|
@@ -3937,6 +4320,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
* 回调后 直接退款
|
|
* 回调后 直接退款
|
|
|
*/
|
|
*/
|
|
|
public void notifyRefundOrder(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) throws Exception {
|
|
public void notifyRefundOrder(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku) throws Exception {
|
|
|
|
|
+ if (multiQuantityOrderService.isMultiQuantityOrder(orderDon.getId())) {
|
|
|
|
|
+ log.warn("Skip legacy relation-based auto refund for multi-quantity orderId:{}", orderDon.getId());
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("批量订单仅支持整单退款,请使用统一退款入口");
|
|
|
|
|
+ }
|
|
|
//续费订单过滤
|
|
//续费订单过滤
|
|
|
if (orderDon.getOrderType() == 2) {
|
|
if (orderDon.getOrderType() == 2) {
|
|
|
return;
|
|
return;
|