|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import lombok.extern.log4j.Log4j2; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
@ -21,17 +22,24 @@ import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; |
|
|
|
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; |
|
|
|
import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; |
|
|
|
import org.jeecg.modules.rechargeInfoLog.service.ITbRechargeInfoLogService; |
|
|
|
import org.jeecg.modules.tbConf.entity.TbConf; |
|
|
|
import org.jeecg.modules.tbConf.service.ITbConfService; |
|
|
|
import org.jeecg.modules.tbOrder.entity.TbOrder; |
|
|
|
import org.jeecg.modules.tbOrder.service.ITbOrderService; |
|
|
|
import org.jeecg.modules.userCode.mapper.RechargeInfoLogMapper; |
|
|
|
import org.jeecg.modules.userCode.model.req.OrderPayReq; |
|
|
|
import org.jeecg.modules.userCode.model.req.PayBean; |
|
|
|
import org.jeecg.modules.userCode.model.req.RechargeInfoLogReq; |
|
|
|
import org.jeecg.modules.userCode.model.req.WithawalReq; |
|
|
|
import org.jeecg.modules.userCode.service.IPayService; |
|
|
|
import org.jeecg.modules.userRole.service.ITbUserRoleService; |
|
|
|
import org.jeecg.modules.utils.SubmitUtil; |
|
|
|
import org.jeecg.modules.utils.ValidateTool; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestHeader; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -73,13 +81,17 @@ public class PayServiceImpl implements IPayService { |
|
|
|
private RechargeInfoLogMapper rechargeInfoLogMapper; |
|
|
|
|
|
|
|
|
|
|
|
ExecutorService cachedThreadPool = new ThreadPoolExecutor(32, 32, |
|
|
|
0L, TimeUnit.MILLISECONDS, |
|
|
|
new LinkedBlockingQueue<Runnable>()); |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ITbOrderService tbOrderService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ITbConfService tbConfService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ITbRechargeInfoLogService tbRechargeInfoLogService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 订单支付 |
|
|
@ -289,6 +301,7 @@ public class PayServiceImpl implements IPayService { |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
public Result<?> rechargeLog(String token, RechargeInfoLogReq rechargeInfoLogReq) { |
|
|
|
HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); |
|
|
@ -317,4 +330,60 @@ public class PayServiceImpl implements IPayService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
@Override |
|
|
|
public Result<?> withdrawal(String token, WithawalReq withawalReq) { |
|
|
|
HanHaiMember account = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); |
|
|
|
SubmitUtil.submit(account, "withdrawal", redisUtil); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<TbConf> objectQueryWrapper = new QueryWrapper<>(); |
|
|
|
objectQueryWrapper.eq("name", "withdrawal_min_money"); |
|
|
|
TbConf one = tbConfService.getOne(objectQueryWrapper); |
|
|
|
|
|
|
|
QueryWrapper<TbConf> withdrawalRate = new QueryWrapper<>(); |
|
|
|
withdrawalRate.eq("name", "withdrawal_rate"); |
|
|
|
TbConf withdrawalRates = tbConfService.getOne(withdrawalRate); |
|
|
|
|
|
|
|
|
|
|
|
//提现最低余额 |
|
|
|
BigDecimal withawalMinMoney = new BigDecimal(one.getValue()); |
|
|
|
if (withawalReq.getMoney().compareTo(withawalMinMoney) < 0) { |
|
|
|
throw new JeecgBootException("提现金额不能小于" + withawalMinMoney); |
|
|
|
} |
|
|
|
|
|
|
|
//获取提现手续费率 |
|
|
|
BigDecimal withawalServiceRate = new BigDecimal(withdrawalRates.getValue()); |
|
|
|
|
|
|
|
BigDecimal serviceCharge = withawalReq.getMoney().multiply(withawalServiceRate); |
|
|
|
BigDecimal money = withawalReq.getMoney().subtract(serviceCharge); |
|
|
|
|
|
|
|
if (withawalReq.getMoney().compareTo(account.getPrice()) == 1) { |
|
|
|
throw new JeecgBootException("提现金额不可以大于金额"); |
|
|
|
} |
|
|
|
//写入提现日志 |
|
|
|
TbRechargeInfoLog merRechargeInfoLog = new TbRechargeInfoLog(); |
|
|
|
merRechargeInfoLog.setTitle("提现"); |
|
|
|
merRechargeInfoLog.setMoney(money); |
|
|
|
merRechargeInfoLog.setUserMoney(account.getPrice()); |
|
|
|
merRechargeInfoLog.setIsPay(1); |
|
|
|
merRechargeInfoLog.setPayTime(new Date()); |
|
|
|
merRechargeInfoLog.setMemberId(account.getId()); |
|
|
|
merRechargeInfoLog.setType(0); |
|
|
|
merRechargeInfoLog.setServiceCharge(serviceCharge); |
|
|
|
merRechargeInfoLog.setRealName(account.getName()); |
|
|
|
merRechargeInfoLog.setState(0); |
|
|
|
boolean save = tbRechargeInfoLogService.save(merRechargeInfoLog); |
|
|
|
if (!save) { |
|
|
|
throw new JeecgBootException("操作失败,请稍后重试"); |
|
|
|
} |
|
|
|
HanHaiMember hanHaiMember = new HanHaiMember(); |
|
|
|
hanHaiMember.setId(account.getId()); |
|
|
|
hanHaiMember.setPrice(account.getPrice().subtract(withawalReq.getMoney())); |
|
|
|
boolean b = hanHaiMemberService.updateById(hanHaiMember); |
|
|
|
if (!b) { |
|
|
|
throw new JeecgBootException("操作失败,请稍后重试"); |
|
|
|
} |
|
|
|
return Result.OKMsg(); |
|
|
|
} |
|
|
|
} |