| | |
| | | package com.taoke.autopay.manager; |
| | | |
| | | import com.taoke.autopay.entity.credit.CreditSetting; |
| | | import com.taoke.autopay.entity.credit.UserCreditBalance; |
| | | import com.taoke.autopay.entity.credit.UserCreditRecord; |
| | | import com.taoke.autopay.exception.UserCreditException; |
| | | import com.taoke.autopay.service.credit.CreditSettingService; |
| | | import com.taoke.autopay.service.credit.UserCreditBalanceService; |
| | | import com.taoke.autopay.service.credit.UserCreditRecordService; |
| | | import com.taoke.autopay.utils.TimeUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | @Component |
| | | public class UserCreditManager { |
| | |
| | | |
| | | @Resource |
| | | private UserCreditRecordService userCreditRecordService; |
| | | |
| | | @Resource |
| | | private CreditSettingService creditSettingService; |
| | | |
| | | |
| | | /** |
| | |
| | | // 增加积分记录 |
| | | userCreditRecordService.addCreditRecord(creditRecord); |
| | | } |
| | | |
| | | /** |
| | | * 抖音订单支付记录 |
| | | * @param uid |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addDYOrderPayRecord(Long uid,String keyId) throws UserCreditException { |
| | | CreditSetting setting = creditSettingService.getSettingCacheByType(CreditSetting.CreditSettingType.DOUYIN_PAYMENT_SUCCESS_CREDITS,new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(System.currentTimeMillis(),"yyyyMMddHHmm"),"yyyyMMddHHmm"))); |
| | | if(setting==null){ |
| | | throw new UserCreditException("未配置抖音支付成功积分"); |
| | | } |
| | | UserCreditRecord record = UserCreditRecord.builder() |
| | | .creditAmount(Integer.parseInt(setting.getValue())) |
| | | .acquisitionMethod(UserCreditRecord.AcquisitionMethod.COMMAND_PAYMENT) |
| | | .direction(UserCreditRecord.DIRECTION_GAIN) |
| | | .identifierId(keyId) |
| | | .uid(uid) |
| | | .description("抖音代付") |
| | | .build(); |
| | | increaseCredit(record); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 快手订单支付成功增加积分 |
| | | * @param uid |
| | | * @param keyId |
| | | * @throws UserCreditException |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addKSOrderPayRecord(Long uid,String keyId) throws UserCreditException { |
| | | CreditSetting setting = creditSettingService.getSettingCacheByType(CreditSetting.CreditSettingType.KUAISHOU_PAYMENT_SUCCESS_CREDITS,new Date(TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(System.currentTimeMillis(),"yyyyMMddHHmm"),"yyyyMMddHHmm"))); |
| | | if(setting==null){ |
| | | throw new UserCreditException("未配置快手支付成功积分"); |
| | | } |
| | | UserCreditRecord record = UserCreditRecord.builder() |
| | | .creditAmount(Integer.parseInt(setting.getValue())) |
| | | .acquisitionMethod(UserCreditRecord.AcquisitionMethod.COMMAND_PAYMENT) |
| | | .direction(UserCreditRecord.DIRECTION_GAIN) |
| | | .identifierId(keyId) |
| | | .uid(uid) |
| | | .description("快手代付") |
| | | .build(); |
| | | increaseCredit(record); |
| | | } |
| | | |
| | | } |