|
|
|
@@ -1,18 +1,13 @@ |
|
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxCUserBasicInfo; |
|
|
|
import com.iformall.domain.po.WxCardInfo; |
|
|
|
import com.iformall.domain.po.WxCardTransferInfo; |
|
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
|
import com.iformall.domain.po.WxCouponChannel; |
|
|
|
import com.iformall.domain.po.WxCouponOrder; |
|
|
|
import com.iformall.domain.po.WxCouponPassword; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.WxCardTransferVo; |
|
|
|
import com.iformall.domain.vo.WxCardVo; |
|
|
|
@@ -20,17 +15,13 @@ import com.iformall.domain.vo.WxCouponOrderBVo; |
|
|
|
import com.iformall.domain.vo.WxCouponPasswordVo; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxCardInfoMapper; |
|
|
|
import com.iformall.mapper.WxCardTransferInfoMapper; |
|
|
|
import com.iformall.mapper.WxCouponChannelMapper; |
|
|
|
import com.iformall.mapper.WxCouponMapper; |
|
|
|
import com.iformall.mapper.WxCouponOrderMapper; |
|
|
|
import com.iformall.mapper.WxCouponPasswordMapper; |
|
|
|
import com.iformall.mapper.*; |
|
|
|
import com.iformall.service.ExcelService; |
|
|
|
import com.iformall.service.WxCUserBasicInfoService; |
|
|
|
import com.iformall.service.WxCardInfoService; |
|
|
|
import com.iformall.service.WxCouponService; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import com.iformall.utils.RedisLock; |
|
|
|
|
|
|
|
import org.apache.commons.beanutils.BeanUtils; |
|
|
|
@@ -89,6 +80,9 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCardTransferInfoMapper wxCardTransferInfoMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCardSpendMapper wxCardSpendMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -425,7 +419,7 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { |
|
|
|
public ResultData updatePayPassword(WxCardInfo cardInfo, EnumCUserFrom userFrom) { |
|
|
|
WxCardInfo wxCardInfo = wxCardInfoMapper.selectById(cardInfo.getId()); |
|
|
|
if(wxCardInfo == null){ |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_FOUND.getCode()); |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
WxCardInfo updateCIF = new WxCardInfo(); |
|
|
|
updateCIF.setId(cardInfo.getId()); |
|
|
|
@@ -449,6 +443,73 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public ResultData rechargeAmount(WxCardInfo cardInfo) { |
|
|
|
WxCardInfo wxCardInfo = wxCardInfoMapper.selectById(cardInfo.getId()); |
|
|
|
if(wxCardInfo == null){ |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
WxCoupon wxCoupon = wxCouponMapper.selectById(wxCardInfo.getCouponId(), wxCardInfo.getTenantId()); |
|
|
|
if(wxCoupon == null){ |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
if(EnumYesOrNo.NO.getCode().equals(wxCoupon.getIsRecharge())){ |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_RECHARGE); |
|
|
|
} |
|
|
|
if(!wxCoupon.checkIsFree()){ |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_RECHARGE.getCode(),"有价券不支持充值"); |
|
|
|
} |
|
|
|
if(wxCoupon.getSubsidyNum() != null && wxCoupon.getSubsidyNum() > 0){ |
|
|
|
return new ResultData(ErrorCode.CARD_IS_NOT_RECHARGE.getCode(),"有补贴不支持充值"); |
|
|
|
} |
|
|
|
|
|
|
|
Date currentDate = new Date(); |
|
|
|
|
|
|
|
WxCardSpend record = new WxCardSpend(); |
|
|
|
record.updateTenantInfo(cardInfo); |
|
|
|
record.setPayType(EnumPayType.PAY_CARD_RECHARGE.getCode()); |
|
|
|
record.setCardId(cardInfo.getId()); |
|
|
|
if(StringUtils.isBlank(cardInfo.getTransactionId())){ |
|
|
|
Long yyyyMMddHHmmss = Long.valueOf(DateUtils.date2String(currentDate, "yyyyMMddHHmmss")); |
|
|
|
record.setOrderId(yyyyMMddHHmmss);//默认当前日期为订单号 |
|
|
|
} |
|
|
|
WxCardSpend wxCardSpend = wxCardSpendMapper.selectOne(new QueryWrapper<>(record)); |
|
|
|
if(wxCardSpend != null){ |
|
|
|
logger.error("当前已存在充值订单, "); |
|
|
|
throw new MallinkException(ErrorCode.CARD_IS_NOT_RECHARGE.getCode(),"当前已存在充值订单,请确认是否重复充值"); |
|
|
|
} |
|
|
|
|
|
|
|
this.updAmount(cardInfo,cardInfo.getAmount(),cardInfo.getAmount(),null); |
|
|
|
|
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setOwnerId(cardInfo.getOwnerUserId()); |
|
|
|
record.setMerchantId(0l);//充值订单无商户 |
|
|
|
record.setPayFrom(EnumCardSpendFrom.recharge.getCode()); |
|
|
|
record.setDeductionAmount(cardInfo.getAmount()); |
|
|
|
record.setRemark("充值"); |
|
|
|
|
|
|
|
record.setPayment(0); |
|
|
|
record.setRealPayment(0); |
|
|
|
record.setCardBeforeAmount(wxCardInfo.getRemainingAmount()); |
|
|
|
record.setCardRemainAmount(wxCardInfo.getRemainingAmount()+cardInfo.getAmount()); |
|
|
|
record.setCardBeforeRealAmount(0); |
|
|
|
record.setCardRemainRealAmount(0); |
|
|
|
record.setPayStatus(EnumCardSpendStatus.NOT_PAY.getCode());// |
|
|
|
|
|
|
|
record.setCreateDate(currentDate); |
|
|
|
record.setUpdateDate(currentDate); |
|
|
|
try { |
|
|
|
wxCardSpendMapper.insert(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("card spend insert error"); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "card spend 插入出错!"); |
|
|
|
} |
|
|
|
return new ResultData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private List<WxCardTransferVo> toTransferVoList(List<WxCardTransferInfo> transferList,TenantEntity tenantEntity) { |
|
|
|
List<WxCardTransferVo> retList = new ArrayList<WxCardTransferVo>(); |
|
|
|
if (null != transferList && transferList.size() > 0 ) { |
|
|
|
|