Authored by Lixiaodi

Merge branch 'dev_order' into test6.8.2

@@ -154,7 +154,7 @@ @@ -154,7 +154,7 @@
154 and amount + #{amount,jdbcType=DECIMAL} >= 0 154 and amount + #{amount,jdbcType=DECIMAL} >= 0
155 </if> 155 </if>
156 <if test="lockAmount != null" > 156 <if test="lockAmount != null" >
157 - and lock_amount = lock_amount + #{lockAmount,jdbcType=DECIMAL} &gt;= 0 157 + and lock_amount + #{lockAmount,jdbcType=DECIMAL} &gt;= 0
158 </if> 158 </if>
159 and status=1 159 and status=1
160 </update> 160 </update>
@@ -95,10 +95,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -95,10 +95,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
95 if (orderInfo.getType() == TYPE_FIRST_RECHARGE) { 95 if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
96 try { 96 try {
97 logger.info("首次充值后回调,调用商家入驻接口,uid={}", orderInfo.getUid()); 97 logger.info("首次充值后回调,调用商家入驻接口,uid={}", orderInfo.getUid());
98 - ufoServiceCaller.call("ufo.user.addUserAsStoredSeller", ApiResponse.class, orderInfo.getUid()); 98 + com.yoho.tools.common.beans.ApiResponse<?> resp = ufoServiceCaller.call("ufo.user.addUserAsStoredSeller", ApiResponse.class, orderInfo.getUid());
  99 + if (resp == null || resp.getCode() != 200) {
  100 + throw new Exception("调用商家入驻接口返回结果code不是200");
  101 + }
99 } catch (Exception e) { 102 } catch (Exception e) {
100 - logger.error("首次充值后回调,商家入驻接口失败,uid={}", orderInfo.getUid());  
101 - CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()); 103 + logger.error("首次充值后回调,商家入驻接口失败,uid={}, msg={}", orderInfo.getUid(), e.getMessage());
  104 + CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode() + ",err="+ e.getMessage());
102 return; 105 return;
103 } 106 }
104 } 107 }
@@ -523,6 +526,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -523,6 +526,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
523 BigDecimal beforeLockAmount = sw.getLockAmount(); 526 BigDecimal beforeLockAmount = sw.getLockAmount();
524 BigDecimal availAmount = null; 527 BigDecimal availAmount = null;
525 BigDecimal lockAmount = null; 528 BigDecimal lockAmount = null;
  529 + BigDecimal tradeAmount = null;
526 530
527 // 减去保证金 531 // 减去保证金
528 if (type == SellerWalletDetail.Type.PUBLISH 532 if (type == SellerWalletDetail.Type.PUBLISH
@@ -530,6 +534,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -530,6 +534,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
530 || type == SellerWalletDetail.Type.SUBTRACT_PRICE) { 534 || type == SellerWalletDetail.Type.SUBTRACT_PRICE) {
531 availAmount = money.multiply(new BigDecimal("-1")); 535 availAmount = money.multiply(new BigDecimal("-1"));
532 lockAmount = money; 536 lockAmount = money;
  537 + tradeAmount = availAmount;
533 } else if (type == SellerWalletDetail.Type.SELLER_OFF 538 } else if (type == SellerWalletDetail.Type.SELLER_OFF
534 || type == SellerWalletDetail.Type.SYSTEM_OFF 539 || type == SellerWalletDetail.Type.SYSTEM_OFF
535 || type == SellerWalletDetail.Type.APPRAISE_OK 540 || type == SellerWalletDetail.Type.APPRAISE_OK
@@ -538,20 +543,22 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -538,20 +543,22 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
538 // 增加保证金 543 // 增加保证金
539 availAmount = money; 544 availAmount = money;
540 lockAmount = money.multiply(new BigDecimal("-1")); 545 lockAmount = money.multiply(new BigDecimal("-1"));
  546 + tradeAmount = money;
541 } else if (type == SellerWalletDetail.Type.SELLER_CANCEL 547 } else if (type == SellerWalletDetail.Type.SELLER_CANCEL
542 || type == SellerWalletDetail.Type.SELLER_OVER_TIME 548 || type == SellerWalletDetail.Type.SELLER_OVER_TIME
543 || type == SellerWalletDetail.Type.APPRAISE_FAIL) { 549 || type == SellerWalletDetail.Type.APPRAISE_FAIL) {
544 // 处罚保证金 550 // 处罚保证金
545 lockAmount = money.multiply(new BigDecimal("-1")); 551 lockAmount = money.multiply(new BigDecimal("-1"));
  552 + tradeAmount = lockAmount;
546 } 553 }
547 554
548 sw.setAmount(availAmount); 555 sw.setAmount(availAmount);
549 sw.setLockAmount(lockAmount); 556 sw.setLockAmount(lockAmount);
550 sw.setUpdateTime(TimeUtils.getTimeStampSecond()); 557 sw.setUpdateTime(TimeUtils.getTimeStampSecond());
551 - logger.info("{}修改钱包表余额,bean={}", sw); 558 + logger.info("{}修改钱包表余额,bean={}", message, sw);
552 if (sellerWalletMapper.addMoney(sw) == 0) { 559 if (sellerWalletMapper.addMoney(sw) == 0) {
553 - logger.error(message + "失败,(并发)更新表返回0,bean={}", sw);  
554 - CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "(并发)更新表返回0,uid=" + uid + ", bean为:"+ sw); 560 + logger.error(message + "失败,(余额不足货钱包不可用)更新表返回0,bean={}", sw);
  561 + CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "(余额不足货钱包不可用)更新表返回0,uid=" + uid + ", bean为:"+ sw);
555 return null; 562 return null;
556 } 563 }
557 logger.info("{}修改钱包表余额成功,bean={}", sw); 564 logger.info("{}修改钱包表余额成功,bean={}", sw);
@@ -561,7 +568,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -561,7 +568,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
561 swd.setType(type.getValue()); 568 swd.setType(type.getValue());
562 swd.setUid(uid); 569 swd.setUid(uid);
563 swd.setWalletId(sw.getId()); 570 swd.setWalletId(sw.getId());
564 - swd.setAmount(money); 571 + swd.setAmount(tradeAmount);
565 swd.setIsBatch(0); 572 swd.setIsBatch(0);
566 swd.setCreateTime(TimeUtils.getTimeStampSecond()); 573 swd.setCreateTime(TimeUtils.getTimeStampSecond());
567 swd.setUpdateTime(0); 574 swd.setUpdateTime(0);
@@ -90,7 +90,7 @@ public class ChangePricePrepareProcessor { @@ -90,7 +90,7 @@ public class ChangePricePrepareProcessor {
90 //若needChangePriceSkupList中有skup出现不存在于skupOfSalingMap keys中,说明该skup走到了其他状态中 90 //若needChangePriceSkupList中有skup出现不存在于skupOfSalingMap keys中,说明该skup走到了其他状态中
91 Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(needChangePriceSkupList,skupOfSalingMap); 91 Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(needChangePriceSkupList,skupOfSalingMap);
92 // 92 //
93 - SkupDto sampleSkupDto = skupMap.get(0); 93 + SkupDto sampleSkupDto = skupMap.values().iterator().next();
94 int sampleSkup = sampleSkupDto.getSkup(); 94 int sampleSkup = sampleSkupDto.getSkup();
95 SellerOrderGoods sampleSog = sampleSkupDto.getSellerOrderGoods(); 95 SellerOrderGoods sampleSog = sampleSkupDto.getSellerOrderGoods();
96 SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(sampleSkup); 96 SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(sampleSkup);
@@ -157,6 +157,10 @@ public class ChangePricePrepareProcessor { @@ -157,6 +157,10 @@ public class ChangePricePrepareProcessor {
157 SellerOrderGoods condition = new SellerOrderGoods(); 157 SellerOrderGoods condition = new SellerOrderGoods();
158 condition.setBatchNo(batchNo); 158 condition.setBatchNo(batchNo);
159 List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByBatchNo(condition, Arrays.asList(SkupStatus.CAN_SELL.getCode(), SkupStatus.SELL_OUT.getCode())); 159 List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByBatchNo(condition, Arrays.asList(SkupStatus.CAN_SELL.getCode(), SkupStatus.SELL_OUT.getCode()));
  160 + if (CollectionUtils.isEmpty(sellerOrderGoodList)){
  161 + logger.warn("ChangePrice checkAndAcquire not find skups by batchNo, req {}", req);
  162 + throw new UfoServiceException(501, "商品不能变价");
  163 + }
160 List<Integer> skups = sellerOrderGoodList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList()); 164 List<Integer> skups = sellerOrderGoodList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList());
161 logger.info("batch change price checkExistWaitingBuyerPay req {} skups {}", req, skups); 165 logger.info("batch change price checkExistWaitingBuyerPay req {} skups {}", req, skups);
162 List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectBySkups(skups); 166 List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectBySkups(skups);
@@ -167,7 +171,8 @@ public class ChangePricePrepareProcessor { @@ -167,7 +171,8 @@ public class ChangePricePrepareProcessor {
167 buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, Arrays.asList(OrderStatus.WAITING_PAY.getCode())); 171 buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, Arrays.asList(OrderStatus.WAITING_PAY.getCode()));
168 } 172 }
169 if (CollectionUtils.isNotEmpty(buyerOrderList)){ 173 if (CollectionUtils.isNotEmpty(buyerOrderList)){
170 - logger.warn("ChangePrice checkAndAcquire storageId illegal , req {}", req); 174 + List<Long> waitingPayOrderCodes = buyerOrderList.parallelStream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
  175 + logger.warn("ChangePrice checkAndAcquire exist waiting pay skup , req {} waitingPayOrderCodes {}", req, waitingPayOrderCodes);
171 throw new UfoServiceException(400, "部分商品正在等待买家支付"); 176 throw new UfoServiceException(400, "部分商品正在等待买家支付");
172 } 177 }
173 return sellerOrderGoodList.parallelStream().collect(Collectors.toMap(SellerOrderGoods::getId, 178 return sellerOrderGoodList.parallelStream().collect(Collectors.toMap(SellerOrderGoods::getId,