|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.userCode.service.impl; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
@ -26,6 +27,8 @@ 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.tbPremium.entity.TbPremium; |
|
|
|
import org.jeecg.modules.tbPremium.service.ITbPremiumService; |
|
|
|
import org.jeecg.modules.userCode.mapper.RechargeInfoLogMapper; |
|
|
|
import org.jeecg.modules.userCode.model.req.OrderPayReq; |
|
|
|
import org.jeecg.modules.userCode.model.req.PayBean; |
|
|
@ -65,7 +68,8 @@ public class PayServiceImpl implements IPayService { |
|
|
|
|
|
|
|
@Value("${wechat.notifyRechargeUrl}") |
|
|
|
private String httpRechargecross; |
|
|
|
|
|
|
|
@Value("${wechat.premiumNotifyUrl}") |
|
|
|
private String premiumNotifyUrl; |
|
|
|
@Resource |
|
|
|
private ShiroRealm shiroRealm; |
|
|
|
|
|
|
@ -84,6 +88,10 @@ public class PayServiceImpl implements IPayService { |
|
|
|
@Resource |
|
|
|
private ITbOrderService tbOrderService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ITbPremiumService tbPremiumService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
@ -192,6 +200,71 @@ public class PayServiceImpl implements IPayService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Result<?> premiumNotify(PayResponse payResponse) { |
|
|
|
try { |
|
|
|
log.error("进入保险微信付款支付回调接口>>>>>>>>>>>>>>>>>"); |
|
|
|
if (payResponse == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
TbPremium premium = tbPremiumService.getById(payResponse.getOrderId()); |
|
|
|
if (premium == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
// 更新订单状态 |
|
|
|
TbPremium cmOrder1 = new TbPremium(); |
|
|
|
cmOrder1.setId(premium.getId()); |
|
|
|
// 付款时间 |
|
|
|
cmOrder1.setPayTime(DateUtils.getDate()); |
|
|
|
tbPremiumService.updateById(cmOrder1); |
|
|
|
TbOrder tbOrder = new TbOrder(); |
|
|
|
tbOrder.setId(payResponse.getOrderId()); |
|
|
|
tbOrder.setPremium(premium.getPremium()); |
|
|
|
tbOrderService.updateById(tbOrder); |
|
|
|
|
|
|
|
return Result.OK(); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new JeecgBootException("支付回调错误:" + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Result<?> orderPremiumPay(OrderPayReq req, String token) { |
|
|
|
HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiAccount(token); |
|
|
|
TbPremium cmOrder = tbPremiumService.getById(req.getOrderId()); |
|
|
|
if (ValidateTool.isNotNull(cmOrder.getPremium())) { |
|
|
|
throw new JeecgBootException("重复支付"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TbPremium tbPremium = new TbPremium(); |
|
|
|
tbPremium.setId(IdWorker.getIdStr()); |
|
|
|
tbPremium.setUserId(hanHaiMember.getId()); |
|
|
|
tbPremium.setOrderId(req.getOrderId()); |
|
|
|
tbPremium.setMoneyType(0); |
|
|
|
QueryWrapper<TbConf> objectQueryWrapper = new QueryWrapper<>(); |
|
|
|
objectQueryWrapper.eq("name", "premium"); |
|
|
|
TbConf one = tbConfService.getOne(objectQueryWrapper); |
|
|
|
tbPremium.setPremium(new BigDecimal(one.getValue())); |
|
|
|
tbPremiumService.save(tbPremium); |
|
|
|
// 组装付款参数 |
|
|
|
PayBean pay = new PayBean(); |
|
|
|
pay.setOrderId(tbPremium.getId()); |
|
|
|
pay.setOrderName(req.getOrderId() + "保险费"); |
|
|
|
pay.setOpenId(hanHaiMember.getAppletOpenid()); |
|
|
|
pay.setMoney(tbPremium.getPremium().doubleValue()); |
|
|
|
log.warn("读取回调地址:>>>>>>{}", premiumNotifyUrl); |
|
|
|
pay.setReturnUrl(premiumNotifyUrl); |
|
|
|
PayResponse payResponse = this.create(pay); |
|
|
|
payResponse.setToPage(false); |
|
|
|
log.warn("支付数据{}", payResponse); |
|
|
|
return Result.OK(payResponse); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 车主端-充值金额 |
|
|
|