Просмотр исходного кода

Merge branch 'release_real_202103' of https://git.malls.iformall.com/server/formallProject into release_real_202103

release_toaliyun_real
xhxu 5 лет назад
Родитель
Сommit
cdb3684149
1 измененных файлов: 30 добавлений и 27 удалений
  1. +30
    -27
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java

+ 30
- 27
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -527,34 +527,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
WxPayAccount wxPayAccount = wxPayAccountMapper.selectOne(new QueryWrapper<>(wxPayAccountQuery));
if (wxPayAccount != null && wxPayAccount.getShare().equals(EnumPayShare.NO.getCode())) {
try {
// 核销记账
// 核销记账,并且往账户里面记帐
if (couponOrder.getCouponPrice() > 0) {
WxMerchantSubsidy subsidy = recordAfterVerified(couponOrder, bUser.getMerchantId());
//是否开通了商户提现,开通了商户提现往商户账户里面加金额
WxMall mall = wxMallMapper.getByTenantId(couponOrder.getTenantId());
if (null != mall && mall.getCashOutSupport().intValue() == EnumCashOut.YES.getCode().intValue()) {
WxMerchant merchant = wxMerchantMapper.selectById(bUser.getMerchantId());
if (null != merchant) {
//此处需要加锁,防止并发设置
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
String timeStr = String.valueOf(time);
boolean cashsetlock = redisLock.lock("merchantLockCashSet_"+merchant.getId(), timeStr);
if (cashsetlock) {
try {
merchant.setCashOutNumber(couponOrder.getCouponPrice());
wxMerchantMapper.increaseCash(merchant);
logger.info("wxcoupon update cashout success.wxCouponOrderId:["+couponOrder.getId()+"] subsidyId:["+subsidy.getId()+"].");
redisLock.unlock("merchantLockCashSet_"+merchant.getId(), timeStr);
}catch(Exception e) {
redisLock.unlock("merchantLockCashSet_"+merchant.getId(), timeStr);
logger.error("update cashout fail.wxCouponOrderId:["+couponOrder.getId()+"] subsidyId:["+subsidy.getId()+"].",e);
}finally {
redisLock.unlock("merchantLockCashSet_"+merchant.getId(), timeStr);
}
}
}
}
recordAfterVerified(couponOrder, bUser.getMerchantId());
}
} catch (Exception e) {
logger.error("核销记账失败"+e.getMessage(),e);
@@ -592,6 +567,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxMerchantSubsidy recordAfterVerified(WxCouponOrder couponOrder, Long merchantId) {
WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId());
WxMerchantSubsidy merchantSubsidy = new WxMerchantSubsidy();
@@ -626,6 +602,33 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
merchantSubsidy.setUpdateDate(curDate);
merchantSubsidy.setStatus(EnumMerchantSubsidyStatus.NOT_SUBSIDY.getCode());
wxMerchantSubsidyMapper.insert(merchantSubsidy);
//是否开通了商户提现,开通了商户提现往商户账户里面加金额
WxMall mall = wxMallMapper.getByTenantId(couponOrder.getTenantId());
if (null != mall && mall.getCashOutSupport().intValue() == EnumCashOut.YES.getCode().intValue()) {
WxMerchant merchant = wxMerchantMapper.selectById(merchantId);
if (null != merchant) {
//此处需要加锁,防止并发设置
long time = System.currentTimeMillis() + RedisLock.TIMEOUT;
String timeStr = String.valueOf(time);
boolean cashsetlock = redisLock.lock("merchantLockCashSet_"+merchant.getId(), timeStr);
if (cashsetlock) {
try {
merchant.setCashOutNumber(couponOrder.getCouponPrice());
wxMerchantMapper.increaseCash(merchant);
logger.info("wxcoupon update cashout success.wxCouponOrderId:["+couponOrder.getId()+"] subsidyId:["+merchantSubsidy.getId()+"].");
redisLock.unlock("merchantLockCashSet_"+merchant.getId(), timeStr);
}catch(Exception e) {
redisLock.unlock("merchantLockCashSet_"+merchant.getId(), timeStr);
logger.error("update cashout fail.wxCouponOrderId:["+couponOrder.getId()+"] subsidyId:["+merchantSubsidy.getId()+"].",e);
}finally {
redisLock.unlock("merchantLockCashSet_"+merchant.getId(), timeStr);
}
}
}
}
return merchantSubsidy;
}



Загрузка…
Отмена
Сохранить