|
@@ -92,23 +92,25 @@ public class OderHandleServiceImpl implements OrderHandleService {
|
|
|
BigDecimal operate = payAmount.subtract(omsOrder.getFeeAmount());
|
|
|
//计算优惠券
|
|
|
Long couponId = omsOrder.getCouponId();
|
|
|
- UserCouponDTO userCoupon = userCouponService.getUserCoupon(couponId);
|
|
|
- if(userCoupon != null){
|
|
|
- Long couponMerchantId = userCoupon.getMerchantId();
|
|
|
- if(couponMerchantId == 0L){
|
|
|
- //平台补贴给商家
|
|
|
- BigDecimal couponAmount = omsOrder.getCouponAmount();
|
|
|
- //给商家转账
|
|
|
- assetService.transfer(0L, merchantId, 2, couponAmount, "平台优惠券补贴");
|
|
|
- //更新平台资产
|
|
|
- BigDecimal platformTotal = assetService.updateAsset(1, couponAmount, 0L, 0, 1);
|
|
|
- //记录平台余额明细
|
|
|
- balanceDetailService.recordFlow(omsOrder.getId(), 0, 0L, couponAmount, BigDecimal.ZERO,
|
|
|
- couponAmount, platformTotal, 1, 9, merchantId);
|
|
|
- BigDecimal surplusAmount = assetService.updateAsset(0, couponAmount, merchantId, 2, 1);
|
|
|
- //商家记录余额明细
|
|
|
- balanceDetailService.recordFlow(orderId, 2, merchantId, couponAmount, BigDecimal.ZERO,
|
|
|
- couponAmount, surplusAmount, 0, 9, 0L);
|
|
|
+ if(couponId != null){
|
|
|
+ UserCouponDTO userCoupon = userCouponService.getUserCoupon(couponId);
|
|
|
+ if(userCoupon != null){
|
|
|
+ Long couponMerchantId = userCoupon.getMerchantId();
|
|
|
+ if(couponMerchantId == 0L){
|
|
|
+ //平台补贴给商家
|
|
|
+ BigDecimal couponAmount = omsOrder.getCouponAmount();
|
|
|
+ //给商家转账
|
|
|
+ assetService.transfer(0L, merchantId, 2, couponAmount, "平台优惠券补贴");
|
|
|
+ //更新平台资产
|
|
|
+ BigDecimal platformTotal = assetService.updateAsset(1, couponAmount, 0L, 0, 1);
|
|
|
+ //记录平台余额明细
|
|
|
+ balanceDetailService.recordFlow(omsOrder.getId(), 0, 0L, couponAmount, BigDecimal.ZERO,
|
|
|
+ couponAmount, platformTotal, 1, 9, merchantId);
|
|
|
+ BigDecimal surplusAmount = assetService.updateAsset(0, couponAmount, merchantId, 2, 1);
|
|
|
+ //商家记录余额明细
|
|
|
+ balanceDetailService.recordFlow(orderId, 2, merchantId, couponAmount, BigDecimal.ZERO,
|
|
|
+ couponAmount, surplusAmount, 0, 9, 0L);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//平台金额扣除商品金额
|