Authored by Lixiaodi

Merge branch 'dev_order' into test6.8.2

... ... @@ -154,7 +154,7 @@
and amount + #{amount,jdbcType=DECIMAL} >= 0
</if>
<if test="lockAmount != null" >
and lock_amount = lock_amount + #{lockAmount,jdbcType=DECIMAL} &gt;= 0
and lock_amount + #{lockAmount,jdbcType=DECIMAL} &gt;= 0
</if>
and status=1
</update>
... ...
... ... @@ -95,10 +95,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
try {
logger.info("首次充值后回调,调用商家入驻接口,uid={}", orderInfo.getUid());
ufoServiceCaller.call("ufo.user.addUserAsStoredSeller", ApiResponse.class, orderInfo.getUid());
com.yoho.tools.common.beans.ApiResponse<?> resp = ufoServiceCaller.call("ufo.user.addUserAsStoredSeller", ApiResponse.class, orderInfo.getUid());
if (resp == null || resp.getCode() != 200) {
throw new Exception("调用商家入驻接口返回结果code不是200");
}
} catch (Exception e) {
logger.error("首次充值后回调,商家入驻接口失败,uid={}", orderInfo.getUid());
CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode());
logger.error("首次充值后回调,商家入驻接口失败,uid={}, msg={}", orderInfo.getUid(), e.getMessage());
CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode() + ",err="+ e.getMessage());
return;
}
}
... ... @@ -523,6 +526,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
BigDecimal beforeLockAmount = sw.getLockAmount();
BigDecimal availAmount = null;
BigDecimal lockAmount = null;
BigDecimal tradeAmount = null;
// 减去保证金
if (type == SellerWalletDetail.Type.PUBLISH
... ... @@ -530,6 +534,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
|| type == SellerWalletDetail.Type.SUBTRACT_PRICE) {
availAmount = money.multiply(new BigDecimal("-1"));
lockAmount = money;
tradeAmount = availAmount;
} else if (type == SellerWalletDetail.Type.SELLER_OFF
|| type == SellerWalletDetail.Type.SYSTEM_OFF
|| type == SellerWalletDetail.Type.APPRAISE_OK
... ... @@ -538,20 +543,22 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
// 增加保证金
availAmount = money;
lockAmount = money.multiply(new BigDecimal("-1"));
tradeAmount = money;
} else if (type == SellerWalletDetail.Type.SELLER_CANCEL
|| type == SellerWalletDetail.Type.SELLER_OVER_TIME
|| type == SellerWalletDetail.Type.APPRAISE_FAIL) {
// 处罚保证金
lockAmount = money.multiply(new BigDecimal("-1"));
tradeAmount = lockAmount;
}
sw.setAmount(availAmount);
sw.setLockAmount(lockAmount);
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
logger.info("{}修改钱包表余额,bean={}", sw);
logger.info("{}修改钱包表余额,bean={}", message, sw);
if (sellerWalletMapper.addMoney(sw) == 0) {
logger.error(message + "失败,(并发)更新表返回0,bean={}", sw);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "(并发)更新表返回0,uid=" + uid + ", bean为:"+ sw);
logger.error(message + "失败,(余额不足货钱包不可用)更新表返回0,bean={}", sw);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePrice", "(余额不足货钱包不可用)更新表返回0,uid=" + uid + ", bean为:"+ sw);
return null;
}
logger.info("{}修改钱包表余额成功,bean={}", sw);
... ... @@ -561,7 +568,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setType(type.getValue());
swd.setUid(uid);
swd.setWalletId(sw.getId());
swd.setAmount(money);
swd.setAmount(tradeAmount);
swd.setIsBatch(0);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
swd.setUpdateTime(0);
... ...
... ... @@ -90,7 +90,7 @@ public class ChangePricePrepareProcessor {
//若needChangePriceSkupList中有skup出现不存在于skupOfSalingMap keys中,说明该skup走到了其他状态中
Map<Integer, SkupDto> skupMap = checkNeedProcessSkups(needChangePriceSkupList,skupOfSalingMap);
//
SkupDto sampleSkupDto = skupMap.get(0);
SkupDto sampleSkupDto = skupMap.values().iterator().next();
int sampleSkup = sampleSkupDto.getSkup();
SellerOrderGoods sampleSog = sampleSkupDto.getSellerOrderGoods();
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(sampleSkup);
... ... @@ -157,6 +157,10 @@ public class ChangePricePrepareProcessor {
SellerOrderGoods condition = new SellerOrderGoods();
condition.setBatchNo(batchNo);
List<SellerOrderGoods> sellerOrderGoodList = sellerOrderGoodsMapper.selectByBatchNo(condition, Arrays.asList(SkupStatus.CAN_SELL.getCode(), SkupStatus.SELL_OUT.getCode()));
if (CollectionUtils.isEmpty(sellerOrderGoodList)){
logger.warn("ChangePrice checkAndAcquire not find skups by batchNo, req {}", req);
throw new UfoServiceException(501, "商品不能变价");
}
List<Integer> skups = sellerOrderGoodList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList());
logger.info("batch change price checkExistWaitingBuyerPay req {} skups {}", req, skups);
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectBySkups(skups);
... ... @@ -167,7 +171,8 @@ public class ChangePricePrepareProcessor {
buyerOrderList = buyerOrderMapper.selectByOrderCodes(orderCodeList, Arrays.asList(OrderStatus.WAITING_PAY.getCode()));
}
if (CollectionUtils.isNotEmpty(buyerOrderList)){
logger.warn("ChangePrice checkAndAcquire storageId illegal , req {}", req);
List<Long> waitingPayOrderCodes = buyerOrderList.parallelStream().map(BuyerOrder::getOrderCode).collect(Collectors.toList());
logger.warn("ChangePrice checkAndAcquire exist waiting pay skup , req {} waitingPayOrderCodes {}", req, waitingPayOrderCodes);
throw new UfoServiceException(400, "部分商品正在等待买家支付");
}
return sellerOrderGoodList.parallelStream().collect(Collectors.toMap(SellerOrderGoods::getId,
... ...