Browse Source

支付保险

master
cgx 5 months ago
parent
commit
b7960eae45
4 changed files with 79 additions and 2 deletions
  1. +3
    -1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/IPayService.java
  2. +74
    -1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/impl/PayServiceImpl.java
  3. +1
    -0
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  4. +1
    -0
      jeecg-boot-module-system/src/main/resources/application-prod.yml

+ 3
- 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/IPayService.java View File

@ -27,6 +27,7 @@ public interface IPayService {
*/ */
Result<?> orderPay(OrderPayReq req, String token); Result<?> orderPay(OrderPayReq req, String token);
/** /**
* 支付回调 * 支付回调
* *
@ -35,8 +36,9 @@ public interface IPayService {
Result<?> notify(PayResponse payResponse); Result<?> notify(PayResponse payResponse);
Result<?> orderPremiumPay(OrderPayReq req, String token);
Result<?> premiumNotify(PayResponse payResponse);
/** /**


+ 74
- 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/userCode/service/impl/PayServiceImpl.java View File

@ -3,6 +3,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.metadata.IPage; 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.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation; 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.tbConf.service.ITbConfService;
import org.jeecg.modules.tbOrder.entity.TbOrder; import org.jeecg.modules.tbOrder.entity.TbOrder;
import org.jeecg.modules.tbOrder.service.ITbOrderService; 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.mapper.RechargeInfoLogMapper;
import org.jeecg.modules.userCode.model.req.OrderPayReq; import org.jeecg.modules.userCode.model.req.OrderPayReq;
import org.jeecg.modules.userCode.model.req.PayBean; import org.jeecg.modules.userCode.model.req.PayBean;
@ -65,7 +68,8 @@ public class PayServiceImpl implements IPayService {
@Value("${wechat.notifyRechargeUrl}") @Value("${wechat.notifyRechargeUrl}")
private String httpRechargecross; private String httpRechargecross;
@Value("${wechat.premiumNotifyUrl}")
private String premiumNotifyUrl;
@Resource @Resource
private ShiroRealm shiroRealm; private ShiroRealm shiroRealm;
@ -84,6 +88,10 @@ public class PayServiceImpl implements IPayService {
@Resource @Resource
private ITbOrderService tbOrderService; private ITbOrderService tbOrderService;
@Resource
private ITbPremiumService tbPremiumService;
@Resource @Resource
private RedisUtil redisUtil; 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);
}
/** /**
* 车主端-充值金额 * 车主端-充值金额


+ 1
- 0
jeecg-boot-module-system/src/main/resources/application-dev.yml View File

@ -338,6 +338,7 @@ wechat:
keyPath: /usr/local/cert/apiclient_cert.p12 keyPath: /usr/local/cert/apiclient_cert.p12
notifyRechargeUrl: https://employadmin.hhlm1688.com/employ-api/pay/payRechargeNotify notifyRechargeUrl: https://employadmin.hhlm1688.com/employ-api/pay/payRechargeNotify
notifyUrl: https://employadmin.hhlm1688.com/employ-api/pay/notify notifyUrl: https://employadmin.hhlm1688.com/employ-api/pay/notify
premiumNotifyUrl: https://employadmin.hhlm1688.com/employ-api/pay/orderPremiumPay
page: /pages/loginAgreement/login page: /pages/loginAgreement/login
codeImg: /usr/codeImage codeImg: /usr/codeImage
savePath: WxCodeFile savePath: WxCodeFile


+ 1
- 0
jeecg-boot-module-system/src/main/resources/application-prod.yml View File

@ -338,6 +338,7 @@ wechat:
keyPath: /usr/local/cert/apiclient_cert.p12 keyPath: /usr/local/cert/apiclient_cert.p12
notifyRechargeUrl: https://employadmin.hhlm1688.com/employ-api/pay/payRechargeNotify notifyRechargeUrl: https://employadmin.hhlm1688.com/employ-api/pay/payRechargeNotify
notifyUrl: https://employadmin.hhlm1688.com/employ-api/pay/notify notifyUrl: https://employadmin.hhlm1688.com/employ-api/pay/notify
premiumNotifyUrl: https://employadmin.hhlm1688.com/employ-api/pay/orderPremiumPay
page: /pages/loginAgreement/login page: /pages/loginAgreement/login
codeImg: /usr/codeImage codeImg: /usr/codeImage
savePath: WxCodeFile savePath: WxCodeFile


Loading…
Cancel
Save