|
@ -2,6 +2,7 @@ package org.jeecg.modules.userCode.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
|
@ -20,6 +21,7 @@ import org.jeecg.common.util.RedisUtil; |
|
|
import org.jeecg.config.shiro.ShiroRealm; |
|
|
import org.jeecg.config.shiro.ShiroRealm; |
|
|
import org.jeecg.modules.bean.RechargeReq; |
|
|
import org.jeecg.modules.bean.RechargeReq; |
|
|
import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; |
|
|
import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; |
|
|
|
|
|
import org.jeecg.modules.hanHaiMember.mapper.HanHaiMemberMapper; |
|
|
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; |
|
|
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; |
|
|
import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; |
|
|
import org.jeecg.modules.rechargeInfoLog.entity.TbRechargeInfoLog; |
|
|
import org.jeecg.modules.rechargeInfoLog.service.ITbRechargeInfoLogService; |
|
|
import org.jeecg.modules.rechargeInfoLog.service.ITbRechargeInfoLogService; |
|
@ -91,7 +93,8 @@ public class PayServiceImpl implements IPayService { |
|
|
@Resource |
|
|
@Resource |
|
|
private ITbPremiumService tbPremiumService; |
|
|
private ITbPremiumService tbPremiumService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private HanHaiMemberMapper hanHaiMemberMappere; |
|
|
@Resource |
|
|
@Resource |
|
|
private RedisUtil redisUtil; |
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
@ -154,7 +157,7 @@ public class PayServiceImpl implements IPayService { |
|
|
pay.setOrderId(orderVO.getId()); |
|
|
pay.setOrderId(orderVO.getId()); |
|
|
pay.setOrderName(orderVO.getTitle()); |
|
|
pay.setOrderName(orderVO.getTitle()); |
|
|
pay.setOpenId(hanHaiMember.getAppletOpenid()); |
|
|
pay.setOpenId(hanHaiMember.getAppletOpenid()); |
|
|
pay.setMoney(0.01); |
|
|
|
|
|
|
|
|
pay.setMoney(new BigDecimal("0.01").doubleValue()); |
|
|
log.warn("读取回调地址:>>>>>>{}", httpcross); |
|
|
log.warn("读取回调地址:>>>>>>{}", httpcross); |
|
|
pay.setReturnUrl(httpcross); |
|
|
pay.setReturnUrl(httpcross); |
|
|
PayResponse payResponse = this.create(pay); |
|
|
PayResponse payResponse = this.create(pay); |
|
@ -163,6 +166,67 @@ public class PayServiceImpl implements IPayService { |
|
|
return Result.OK(payResponse); |
|
|
return Result.OK(payResponse); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public Result<?> payOrderByBalance(OrderPayReq req, String token) { |
|
|
|
|
|
|
|
|
|
|
|
HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); |
|
|
|
|
|
log.warn("orderPay参数{}==={}", JSONObject.toJSONString(req)); |
|
|
|
|
|
if (req == null) { |
|
|
|
|
|
throw new JeecgBootException("订单错误,请稍后重试"); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isEmpty(req.getOrderId())) { |
|
|
|
|
|
throw new JeecgBootException("订单错误,请稍后重试"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查询订单信息 |
|
|
|
|
|
TbOrder order = tbOrderService.getById(req.getOrderId()); |
|
|
|
|
|
if (ValidateTool.isNull(order)) { |
|
|
|
|
|
return Result.error("订单记录不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 实时获取订单中的金额 (可能存在提交订单未付款,后面开通会员的情况) |
|
|
|
|
|
* */ |
|
|
|
|
|
if (order.getOrderStatus() == 5 || order.getOrderStatus() == 6) { |
|
|
|
|
|
throw new JeecgBootException("订单已支付,请勿重复支付"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hanHaiMember.getPrice().doubleValue() <= 0 |
|
|
|
|
|
|| hanHaiMember.getPrice().doubleValue() < order.getPayMoney().doubleValue()) { |
|
|
|
|
|
throw new JeecgBootException("余额不足,请充值"); |
|
|
|
|
|
} |
|
|
|
|
|
UpdateWrapper<HanHaiMember> updateWrapper = new UpdateWrapper<>(); |
|
|
|
|
|
updateWrapper.setSql("price = price - " + order.getPayMoney()); |
|
|
|
|
|
updateWrapper.eq("id", hanHaiMember.getId()).last("and price - " + order.getPayMoney() + ">= 0"); |
|
|
|
|
|
int update = hanHaiMemberMappere.update(null, updateWrapper); |
|
|
|
|
|
if (update < 1) { |
|
|
|
|
|
log.warn("余额扣除失败 订单id{}金额{}", order.getId(), order.getPayMoney()); |
|
|
|
|
|
throw new JeecgBootException("网络异常"); |
|
|
|
|
|
} |
|
|
|
|
|
TbRechargeInfoLog rechargeLog = new TbRechargeInfoLog(); |
|
|
|
|
|
rechargeLog.setTitle(order.getTitle()); |
|
|
|
|
|
rechargeLog.setMoney(order.getPayMoney()); |
|
|
|
|
|
rechargeLog.setMemberId(hanHaiMember.getId()); |
|
|
|
|
|
rechargeLog.setUserMoney(hanHaiMember.getPrice()); |
|
|
|
|
|
rechargeLog.setType(0); |
|
|
|
|
|
rechargeLog.setIsPay(1); |
|
|
|
|
|
rechargeLog.setPayTime(new Date()); |
|
|
|
|
|
rechargeLog.setOrderId(order.getId()); |
|
|
|
|
|
rechargeInfoLogMapper.insert(rechargeLog); |
|
|
|
|
|
|
|
|
|
|
|
// 更新订单状态 |
|
|
|
|
|
TbOrder cmOrder1 = new TbOrder(); |
|
|
|
|
|
cmOrder1.setId(order.getId()); |
|
|
|
|
|
cmOrder1.setOrderStatus(8); |
|
|
|
|
|
|
|
|
|
|
|
tbOrderService.updateById(cmOrder1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.OK(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public Result<?> notify(PayResponse payResponse) { |
|
|
public Result<?> notify(PayResponse payResponse) { |
|
|