|
|
|
@@ -37,6 +37,9 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
@Autowired |
|
|
|
WxMerchantMapper wxMerchantMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMerchantSubsidyMapper wxMerchantSubsidyMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponMerchantMapper wxCouponMerchantMapper; |
|
|
|
|
|
|
|
@@ -50,12 +53,13 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
WxProfitSharingOrderService profitSharingOrderService; |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCUser user) { |
|
|
|
Date curDate = new Date(); |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
// 1. get card info |
|
|
|
WxCardInfo cardInfo = wxCardInfoMapper.selectByPrimaryKey(record.getCardId()); |
|
|
|
if (cardInfo != null) { |
|
|
|
if (cardInfo == null) { |
|
|
|
logger.error("card not found: " + record.getCardId()); |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
@@ -110,7 +114,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
record.setCardBeforeAmount(cardInfo.getRemainingAmount()); |
|
|
|
record.setCardRemainAmount(cardInfo.getRemainingAmount()-record.getDeductionAmount()); |
|
|
|
record.setCardBeforeRealAmount(cardInfo.getRemainingShareFeeAmount()); |
|
|
|
record.setCardRemainAmount(cardInfo.getRemainingShareFeeAmount()-real_payment); |
|
|
|
record.setCardRemainRealAmount(cardInfo.getRemainingShareFeeAmount()-real_payment); |
|
|
|
record.setCreateDate(curDate); |
|
|
|
record.setUpdateDate(curDate); |
|
|
|
try { |
|
|
|
@@ -123,6 +127,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
// 7. update card info |
|
|
|
cardInfo.setRemainingAmount(cardInfo.getRemainingAmount()-record.getDeductionAmount()); |
|
|
|
cardInfo.setRemainingShareFeeAmount(cardInfo.getRemainingShareFeeAmount()-real_payment); |
|
|
|
cardInfo.setUpdateDate(curDate); |
|
|
|
try { |
|
|
|
wxCardInfoMapper.updateByPrimaryKey(cardInfo); |
|
|
|
} catch (Exception e) { |
|
|
|
@@ -149,6 +154,12 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { |
|
|
|
merchantSubsidy.setStatus(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode()); |
|
|
|
merchantSubsidy.setCreateDate(curDate); |
|
|
|
merchantSubsidy.setUpdateDate(curDate); |
|
|
|
try { |
|
|
|
wxMerchantSubsidyMapper.insertSelective(merchantSubsidy); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("merchantSubsidy info insert error"); |
|
|
|
return new ResultData(ErrorCode.DB_FAIL.getCode(), "merchantSubsidy info 插入出错!"); |
|
|
|
} |
|
|
|
// 9. 分账 |
|
|
|
|
|
|
|
|
|
|
|
|