多用充值绑定接口

This commit is contained in:
小魔仙~
2024-12-27 18:33:12 +08:00
parent ea1d053ba7
commit 22de4635e4
7 changed files with 111 additions and 36 deletions

View File

@ -59,4 +59,14 @@ private static final long serialVersionUID = 1L;
@ApiModelProperty("微信平台证书")
private String platformCertificates;
/** 微信支付公钥id */
@Excel(name = "微信支付公钥id")
@ApiModelProperty("微信支付公钥id")
private Long wechatPublicKeyId;
/** 平台证书序列号 */
@Excel(name = "平台证书序列号")
@ApiModelProperty("平台证书序列号")
private String platformCertificateSerialNumber;
}

View File

@ -24,4 +24,8 @@ public class NgMerchantsDto {
private String platformCertificates;
private String deptName;
private Long wechatPublicKeyId;
private String platformCertificateSerialNumber;
}

View File

@ -15,4 +15,7 @@ public class WeChatRecharge {
private String openId;//openId
private BigDecimal total;//amount中的total
private String currency;//amount中的currency
private Long deptId;
private Long wechatPublicKeyId;
private String platformCertificateSerialNumber;
}

View File

@ -47,6 +47,9 @@ public class NgMerchantsServiceImpl implements INgMerchantsService
NgMerchantsDto ngMerchantsDto = new NgMerchantsDto();
NgMerchants ngMerchants = ngMerchantsMapper.selectNgMerchantsById(id);
SysDept sysDept = sysDeptMapper.selectDeptById(ngMerchants.getDeptId());
ngMerchantsDto.setWechatPublicKeyId(ngMerchants.getWechatPublicKeyId());
ngMerchantsDto.setPlatformCertificateSerialNumber(
ngMerchants.getPlatformCertificateSerialNumber());
ngMerchantsDto.setId(ngMerchants.getId());
ngMerchantsDto.setApiV3Key(ngMerchants.getApiV3Key());
ngMerchantsDto.setMchId(ngMerchants.getMchId());
@ -78,6 +81,9 @@ public class NgMerchantsServiceImpl implements INgMerchantsService
.map(ngMerchants1 -> {
NgMerchantsDto ngMerchantsDto = new NgMerchantsDto();
ngMerchantsDto.setId(ngMerchants1.getId());
ngMerchantsDto.setWechatPublicKeyId(ngMerchants1.getWechatPublicKeyId());
ngMerchantsDto.setPlatformCertificateSerialNumber(
ngMerchants1.getPlatformCertificateSerialNumber());
ngMerchantsDto.setApiV3Key(ngMerchants1.getApiV3Key());
ngMerchantsDto.setMchId(ngMerchants1.getMchId());
ngMerchantsDto.setPrivateKeyPath(ngMerchants1.getPrivateKeyPath());

View File

@ -2,9 +2,12 @@ package com.fastbee.rechargecard.service.impl;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fastbee.common.utils.pay.AesUtil;
import com.fastbee.common.utils.pay.wxPayConfig;
import com.fastbee.rechargecard.domain.NgMerchants;
import com.fastbee.rechargecard.domain.dto.WeChatRecharge;
import com.fastbee.rechargecard.mapper.NgMerchantsMapper;
import com.fastbee.rechargecard.service.INgUserRechargeRecordsService;
import com.fastbee.rechargecard.service.IUserConsumptionDetailsService;
import com.fastbee.rechargecard.service.IUserRechargeCardsService;
@ -41,7 +44,8 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
public static String privateKeyPath = "fastbee-common/src/main/java/com/fastbee/common/utils/pay/damogang_apiclient_key.pem";
//TODO 生产环境私钥路径
//public static String privateKeyPath = "/home/soft/hzwmiot/fastbee-admin/target/damogang_apiclient_key.pem";
@Autowired
private NgMerchantsMapper ngMerchantsMapper;
/** 商户API证书序列号 */
//public static String serial_no = "3075B63EF52666EDC3EAFC5D4FB35C02CE123A9C";
@ -71,6 +75,12 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
* @throws Exception
*/
public Map<String, String> CreateOrder(WeChatRecharge recharge) throws Exception {
QueryWrapper queryWrapper=new QueryWrapper();
queryWrapper.eq("dept_id",recharge.getDeptId());
NgMerchants ngMerchants = ngMerchantsMapper.selectOne(queryWrapper);
if (ngMerchants==null){
return null;
}
System.out.println("CreateOrder");
//请求URL
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi");
@ -86,7 +96,8 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
reqdata.put("amount",amount);
reqdata.put("appid",appId);
reqdata.put("mchid",mchId);
// reqdata.put("mchid",mchId);
reqdata.put("mchid",ngMerchants.getMchId());
reqdata.put("description",recharge.getCardnumber()+recharge.getAmount().toString());
reqdata.put("out_trade_no",recharge.getRechargeCode());
reqdata.put("notify_url",notify_url+"/"+mchId);//"\t\n" +
@ -97,13 +108,19 @@ public class UserWechatPayServiceImpl implements IUserWechatPayService {
String nonce_str=info.get("nonce_str");
result.put("timeStamp",timeStamp);
result.put("mchid",mchId);
// result.put("mchid",mchId);
reqdata.put("mchid",ngMerchants.getMchId());
result.put("signType","RSA");
result.put("nonceStr",nonce_str);
result.put("partnerid",mchId);
// result.put("partnerid",mchId);
reqdata.put("mchid",ngMerchants.getMchId());
String Signature=info.get("sign");
String Authorization="WECHATPAY2-SHA256-RSA2048 mchid=\""+mchId+"\",nonce_str=\""+nonce_str+"\",signature=\""+Signature+"\",timestamp=\""+timeStamp+"\",serial_no=\""+serial_no+"\"";
String Authorization="WECHATPAY2-SHA256-RSA2048 mchid=\""+ngMerchants.getMchId()+
"\",nonce_str=\""+nonce_str+"\",signature=\""+Signature+"\",timestamp=\""+timeStamp+"\",serial_no=\""
+
// serial_no
ngMerchants.getSerialNo()+"\"";
StringEntity entity = new StringEntity(JSONUtil.toJsonStr(reqdata), "utf-8");
entity.setContentType("application/json");

View File

@ -13,10 +13,12 @@
<result property="publicKeyPath" column="public_key_path" />
<result property="deptId" column="dept_id" />
<result property="platformCertificates" column="platform_certificates" />
<result property="wechatPublicKeyId" column="wechat_public_key_id" />
<result property="platformCertificateSerialNumber" column="platform_certificate_serial_number" />
</resultMap>
<sql id="selectNgMerchantsVo">
select id, mch_id, private_key_path, serial_no, api_v3_key, public_key_path, dept_id, platform_certificates from ng_merchants
select id, mch_id, private_key_path, serial_no, api_v3_key, public_key_path, dept_id, platform_certificates, wechat_public_key_id, platform_certificate_serial_number from ng_merchants
</sql>
<select id="selectNgMerchantsList" parameterType="NgMerchants" resultMap="NgMerchantsResult">
@ -29,6 +31,8 @@
<if test="publicKeyPath != null and publicKeyPath != ''"> and public_key_path = #{publicKeyPath}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="platformCertificates != null and platformCertificates != ''"> and platform_certificates = #{platformCertificates}</if>
<if test="wechatPublicKeyId != null "> and wechat_public_key_id = #{wechatPublicKeyId}</if>
<if test="platformCertificateSerialNumber != null and platformCertificateSerialNumber != ''"> and platform_certificate_serial_number = #{platformCertificateSerialNumber}</if>
</where>
</select>
@ -47,6 +51,8 @@
<if test="publicKeyPath != null">public_key_path,</if>
<if test="deptId != null">dept_id,</if>
<if test="platformCertificates != null">platform_certificates,</if>
<if test="wechatPublicKeyId != null">wechat_public_key_id,</if>
<if test="platformCertificateSerialNumber != null">platform_certificate_serial_number,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="mchId != null">#{mchId},</if>
@ -56,6 +62,8 @@
<if test="publicKeyPath != null">#{publicKeyPath},</if>
<if test="deptId != null">#{deptId},</if>
<if test="platformCertificates != null">#{platformCertificates},</if>
<if test="wechatPublicKeyId != null">#{wechatPublicKeyId},</if>
<if test="platformCertificateSerialNumber != null">#{platformCertificateSerialNumber},</if>
</trim>
</insert>
@ -69,6 +77,8 @@
<if test="publicKeyPath != null">public_key_path = #{publicKeyPath},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="platformCertificates != null">platform_certificates = #{platformCertificates},</if>
<if test="wechatPublicKeyId != null">wechat_public_key_id = #{wechatPublicKeyId},</if>
<if test="platformCertificateSerialNumber != null">platform_certificate_serial_number = #{platformCertificateSerialNumber},</if>
</trim>
where id = #{id}
</update>