不同app用不同的appid支付
This commit is contained in:
@@ -3,6 +3,7 @@ package com.peanut.common.utils;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
@@ -21,11 +22,11 @@ public class DataMigrationUtil extends Thread {
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
// catalogue();
|
||||
catalogue();
|
||||
// courseCatalogue();
|
||||
// courseCatalogueChapter();
|
||||
// courseCatalogueChapterVideo();
|
||||
user();//用的都是copy表里的数据
|
||||
// user();//用的都是copy表里的数据
|
||||
|
||||
}
|
||||
|
||||
@@ -337,8 +338,9 @@ public class DataMigrationUtil extends Thread {
|
||||
}
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
yljkconn.close();
|
||||
// 1、创建服务,创建线程池
|
||||
ExecutorService service = Executors.newFixedThreadPool(200);
|
||||
ExecutorService service = Executors.newFixedThreadPool(50);
|
||||
for (int i=1;i<=list.size(); i++){
|
||||
DataMigrationUtil d1 = new DataMigrationUtil(list.get(i),i);
|
||||
service.execute(d1);
|
||||
@@ -355,14 +357,10 @@ public class DataMigrationUtil extends Thread {
|
||||
System.out.println("---已插入数据"+i);
|
||||
}
|
||||
String userId = "";
|
||||
BigDecimal userBalance = new BigDecimal(0);
|
||||
Connection fzdsconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test?rewriteBatchedStatements=true",
|
||||
"nuttyreading", "Wu751019!");
|
||||
PreparedStatement telInsertStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_copy1 (name,avatar,nickname,tel,vip,peanut_coin,jf,yljk_oid) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
PreparedStatement userVipStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_vip_copy1 (user_id,type,start_time,end_time,state) VALUES (?, ?, ?, ?, ?)");
|
||||
PreparedStatement oidStatements = fzdsconn.prepareStatement("select * from user_copy1 where del_flag = 0 and yljk_oid = '"+map.get("oid")+"' ");
|
||||
ResultSet oidResultSet = oidStatements.executeQuery();
|
||||
//已绑定过id
|
||||
@@ -373,7 +371,9 @@ public class DataMigrationUtil extends Thread {
|
||||
"vip= "+map.get("payStatus")+" ,peanut_coin = peanut_coin + "+map.get("point")+" , jf = jf + "+map.get("pointByJF")+" where id = "+oidResultSet.getString("id")+"";
|
||||
PreparedStatement oidUpdateStatement = fzdsconn.prepareStatement(sql);
|
||||
userId = oidResultSet.getString("id");
|
||||
userBalance = oidResultSet.getBigDecimal("peanut_coin").add(new BigDecimal(map.get("point").toString()));
|
||||
oidUpdateStatement.execute();
|
||||
oidUpdateStatement.close();
|
||||
}else {
|
||||
//未绑定过id,用电话查询
|
||||
PreparedStatement telStatements = fzdsconn.prepareStatement("select * from user_copy1 where del_flag = 0 and tel = '"+map.get("cellPhone")+"' ");
|
||||
@@ -387,10 +387,15 @@ public class DataMigrationUtil extends Thread {
|
||||
"vip= "+map.get("payStatus")+" ,peanut_coin = peanut_coin + "+map.get("point")+" , jf = jf + "+map.get("pointByJF")+" where tel = '"+map.get("cellPhone")+"'";
|
||||
PreparedStatement telUpdateStatement = fzdsconn.prepareStatement(sql);
|
||||
userId = telResultSet.getString("id");
|
||||
userBalance = oidResultSet.getBigDecimal("peanut_coin").add(new BigDecimal(map.get("point").toString()));
|
||||
telUpdateStatement.execute();
|
||||
telUpdateStatement.close();
|
||||
}
|
||||
}else {
|
||||
//没有关联,直接导入
|
||||
PreparedStatement telInsertStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_copy1 (name,avatar,nickname,tel,vip,peanut_coin,jf,yljk_oid) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
telInsertStatement.setString(1,map.get("nameCN")==null?"":map.get("nameCN").toString());
|
||||
telInsertStatement.setString(2,map.get("icons")==null?"":map.get("icons").toString());
|
||||
telInsertStatement.setString(3,map.get("nickName")==null?"":map.get("nickName").toString());
|
||||
@@ -399,10 +404,19 @@ public class DataMigrationUtil extends Thread {
|
||||
telInsertStatement.setString(6,map.get("point")==null?"":map.get("point").toString());
|
||||
telInsertStatement.setString(7,map.get("pointByJF")==null?"":map.get("pointByJF").toString());
|
||||
telInsertStatement.setString(8,map.get("oid")==null?"":map.get("oid").toString());
|
||||
telInsertStatement.execute();
|
||||
telInsertStatement.execute();//获取添加之后自动增长id值
|
||||
ResultSet rs = telInsertStatement.getGeneratedKeys();
|
||||
while(rs.next()) {
|
||||
Object id = rs.getObject(1);
|
||||
userId = id.toString();
|
||||
}
|
||||
telInsertStatement.close();
|
||||
userBalance = new BigDecimal(map.get("point").toString());
|
||||
}
|
||||
}
|
||||
//添加超v
|
||||
PreparedStatement userVipStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO user_vip_copy1 (user_id,type,start_time,end_time,state) VALUES (?, ?, ?, ?, ?)");
|
||||
if (map.get("paydate")!=null&&map.get("payValidDate")!=null){
|
||||
userVipStatement.setString(1,userId);
|
||||
userVipStatement.setString(2,map.get("payStatus").toString());
|
||||
@@ -414,7 +428,24 @@ public class DataMigrationUtil extends Thread {
|
||||
userVipStatement.setString(5,"1");
|
||||
}
|
||||
userVipStatement.execute();
|
||||
userVipStatement.close();
|
||||
}
|
||||
//添加灵兰币记录
|
||||
PreparedStatement transactionDetailStatement = fzdsconn.prepareStatement(
|
||||
"INSERT ignore INTO transaction_details_copy1 (user_id,order_type,change_amount,remark,user_balance," +
|
||||
"user_name,tel) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
if (map.get("point")!=null&&!"0".equals(map.get("point").toString())){
|
||||
transactionDetailStatement.setString(1,userId);
|
||||
transactionDetailStatement.setString(2,"系统合并结算");
|
||||
transactionDetailStatement.setString(3,map.get("point").toString());
|
||||
transactionDetailStatement.setString(4,"合并");
|
||||
transactionDetailStatement.setBigDecimal(5,userBalance);
|
||||
transactionDetailStatement.setString(6,map.get("nameCN")==null?"":map.get("nameCN").toString());
|
||||
transactionDetailStatement.setString(7,map.get("cellPhone").toString());
|
||||
transactionDetailStatement.execute();
|
||||
transactionDetailStatement.close();
|
||||
}
|
||||
fzdsconn.close();
|
||||
}catch (Exception ee){
|
||||
|
||||
}
|
||||
|
||||
@@ -299,6 +299,7 @@ public class BuyOrderController {
|
||||
paymentInfo.setOrderSn(orderSn);
|
||||
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
|
||||
paymentInfo.setTotalAmount(totalPrice);
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
wxpayService.prepay(paymentInfo);
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
@@ -528,6 +529,7 @@ public class BuyOrderController {
|
||||
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
|
||||
paymentInfo.setBuyOrderId(Integer.valueOf(buyOrderEntity.getProductId()));
|
||||
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
|
||||
paymentInfo.setAppName(buyOrder.getAppName());
|
||||
wxpayService.prepay(paymentInfo);
|
||||
rabbitTemplate.convertAndSend(
|
||||
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,
|
||||
|
||||
@@ -189,4 +189,7 @@ public class BuyOrder implements Serializable {
|
||||
|
||||
@TableField(exist = false)
|
||||
private ConsigneeVo consigneeVo;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String appName;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ public class WechatPayConfig implements Serializable {
|
||||
* APPID
|
||||
*/
|
||||
@Value("${wxpay.appId}")
|
||||
private String appId;
|
||||
private String appId;//fzds
|
||||
@Value("${wxpay.zmzmappId}")
|
||||
private String zmzmappId;
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
|
||||
@@ -63,8 +63,14 @@ public class WeChatPayController {
|
||||
}
|
||||
String nonceStr = UUID.randomUUID().toString().replace("-", "");
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String appid = "";
|
||||
if (paymentInfo.getAppName()==null||"".equals(paymentInfo.getAppName())){
|
||||
appid = wechatPayConfig.getAppId();
|
||||
}else if ("zmzm".equals(paymentInfo.getAppName())){
|
||||
appid = wechatPayConfig.getZmzmappId();
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
paramMap.put("appid", wechatPayConfig.getAppId());
|
||||
paramMap.put("appid", appid);
|
||||
map.put("noncestr", nonceStr);
|
||||
map.put("package", "Sign=WXPay");
|
||||
paramMap.put("mchid", wechatPayConfig.getMchId());
|
||||
@@ -75,7 +81,7 @@ public class WeChatPayController {
|
||||
map.put("prepayid", prepayId);
|
||||
long timestamp = System.currentTimeMillis() / 1000;
|
||||
map.put("timestamp", timestamp);
|
||||
String sign = wxPayUtil.getSign(wechatPayConfig.getAppId(), timestamp, nonceStr, prepayId);
|
||||
String sign = wxPayUtil.getSign(appid, timestamp, nonceStr, prepayId);
|
||||
map.put("sign", sign);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("paramMap", paramMap);
|
||||
|
||||
@@ -20,4 +20,8 @@ public class WechatPaymentInfo implements Serializable {
|
||||
* 总金额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
/**
|
||||
* appName
|
||||
*/
|
||||
private String appName;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,14 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
|
||||
@Override
|
||||
public void prepay(WechatPaymentInfo paymentInfo){
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String appid = "";
|
||||
if (paymentInfo.getAppName()==null||"".equals(paymentInfo.getAppName())){
|
||||
appid = wechatPayConfig.getAppId();
|
||||
}else if ("zmzm".equals(paymentInfo.getAppName())){
|
||||
appid = wechatPayConfig.getZmzmappId();
|
||||
}
|
||||
// app id
|
||||
paramMap.put("appid", wechatPayConfig.getAppId());
|
||||
paramMap.put("appid", appid);
|
||||
// 商户 id
|
||||
paramMap.put("mchid", wechatPayConfig.getMchId());
|
||||
// 描述
|
||||
|
||||
@@ -77,6 +77,8 @@ server:
|
||||
|
||||
wxpay:
|
||||
appId: wx47134a8f15083734
|
||||
zmzmappId: wx912aa600132dc965
|
||||
# wmysappId: wx47134a8f15083734
|
||||
mchId: 1612860909
|
||||
payUrl: https://api.mch.weixin.qq.com/v3/pay/transactions/app
|
||||
notifyUrl: https://testapi.nuttyreading.com/pay/payNotify
|
||||
|
||||
@@ -76,6 +76,8 @@ server:
|
||||
|
||||
wxpay:
|
||||
appId: wx47134a8f15083734
|
||||
zmzmappId: wx912aa600132dc965
|
||||
# wmysappId: wx47134a8f15083734
|
||||
mchId: 1612860909
|
||||
payUrl: https://api.mch.weixin.qq.com/v3/pay/transactions/app
|
||||
notifyUrl: https://testapi.nuttyreading.com/pay/payNotify
|
||||
|
||||
@@ -11,7 +11,7 @@ connection-timeout: 6000000ms
|
||||
spring:
|
||||
# 环境 dev/dev1|test|prod
|
||||
profiles:
|
||||
active: dev1
|
||||
active: dev
|
||||
# jackson时间格式化
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
@@ -58,6 +58,7 @@ mybatis-plus:
|
||||
cache-enabled: false
|
||||
call-setters-on-nulls: true
|
||||
jdbc-type-for-null: 'null'
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
||||
renren:
|
||||
|
||||
Reference in New Issue
Block a user