记得上下班打卡 | git大法好,push需谨慎

Commit ad3b72f2 authored by zhengfuxin's avatar zhengfuxin

支持 小程序多个支付

parent cc298d6e
...@@ -41,6 +41,8 @@ public class DragonPayBaseReqDto implements Serializable, Cloneable{ ...@@ -41,6 +41,8 @@ public class DragonPayBaseReqDto implements Serializable, Cloneable{
//苹果的stransactionId //苹果的stransactionId
private String transactionId; private String transactionId;
private String appIdType="";
@Override @Override
public String toString(){ public String toString(){
return JsonUtils.toJson(this); return JsonUtils.toJson(this);
......
...@@ -22,6 +22,7 @@ public class IDGenerator { ...@@ -22,6 +22,7 @@ public class IDGenerator {
return nextMilliId().concat(s.substring(s.length() - 7)); return nextMilliId().concat(s.substring(s.length() - 7));
} }
public static String nextTimeId2() { public static String nextTimeId2() {
String s = String.valueOf(System.nanoTime()); String s = String.valueOf(System.nanoTime());
return nextMilliId2().concat(s.substring(s.length() - 7)); return nextMilliId2().concat(s.substring(s.length() - 7));
...@@ -112,6 +113,10 @@ public class IDGenerator { ...@@ -112,6 +113,10 @@ public class IDGenerator {
public static String payCode() { public static String payCode() {
return "PAY" + nextTimeId(); return "PAY" + nextTimeId();
} }
public static String payCodeByType() {
return "PAYB" + nextTimeId();
}
public static String getZxlNftImageCosCode() { public static String getZxlNftImageCosCode() {
return "ZXLNFTIMAGE" + nextTimeId(); return "ZXLNFTIMAGE" + nextTimeId();
...@@ -147,7 +152,11 @@ public class IDGenerator { ...@@ -147,7 +152,11 @@ public class IDGenerator {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(getWriteOffCode()); /*System.out.println(getWriteOffCode());*/
/* System.out.println("202205181331531784685706".length());*/
String s=nextTimeId();
System.out.println(s);
System.out.println(s.length());
} }
/** /**
......
...@@ -50,7 +50,11 @@ public class DragonServiceCommonBiz { ...@@ -50,7 +50,11 @@ public class DragonServiceCommonBiz {
orders.setClientIp(dragonPayBaseReqDto.getClientIp()); orders.setClientIp(dragonPayBaseReqDto.getClientIp());
orders.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl()); orders.setNotifyUrl(dragonPayBaseReqDto.getNotifyUrl());
orders.setNotifyStatus(Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_INIT.getCode())); orders.setNotifyStatus(Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_INIT.getCode()));
orders.setPaymentType((dragonPayBaseReqDto.getDeviceFrom()+dragonPayBaseReqDto.getPayType()).toUpperCase()); if(dragonPayBaseReqDto.getAppIdType().equals("b")){
orders.setPaymentType((dragonPayBaseReqDto.getDeviceFrom()+dragonPayBaseReqDto.getAppIdType()+dragonPayBaseReqDto.getPayType()).toUpperCase());
}else{
orders.setPaymentType((dragonPayBaseReqDto.getDeviceFrom()+dragonPayBaseReqDto.getPayType()).toUpperCase());
}
// orders.setPaymentId(); // orders.setPaymentId();
orders.setPaymentAt(LocalDateTime.now()); orders.setPaymentAt(LocalDateTime.now());
// orders.setFinishedAt(); // orders.setFinishedAt();
......
...@@ -154,7 +154,11 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy { ...@@ -154,7 +154,11 @@ public abstract class AbstractWepayStrategy implements IWepayStrategy {
protected SortedMap<String, Object> buildRequestParamMap(DragonPayBaseReqDto dragonPayBaseReqDto){ protected SortedMap<String, Object> buildRequestParamMap(DragonPayBaseReqDto dragonPayBaseReqDto){
String nonceStr = PayWepayUtils.getInstance().getNonceStr(); String nonceStr = PayWepayUtils.getInstance().getNonceStr();
SortedMap<String, Object> parameters = new TreeMap<>(); SortedMap<String, Object> parameters = new TreeMap<>();
parameters.put("mch_id", PayWepayUtils.getInstance().getMerchantId()); if(dragonPayBaseReqDto.getAppIdType().equals("b")){
parameters.put("mch_id", PayWepayUtils.getInstance().getMerchantBId());
}else{
parameters.put("mch_id", PayWepayUtils.getInstance().getMerchantId());
}
parameters.put("nonce_str", nonceStr); parameters.put("nonce_str", nonceStr);
parameters.put("spbill_create_ip", dragonPayBaseReqDto.getClientIp()); parameters.put("spbill_create_ip", dragonPayBaseReqDto.getClientIp());
parameters.put("total_fee", dragonPayBaseReqDto.getPrice().multiply(BigDecimal.valueOf(100L)).intValue()+""); parameters.put("total_fee", dragonPayBaseReqDto.getPrice().multiply(BigDecimal.valueOf(100L)).intValue()+"");
......
...@@ -32,7 +32,11 @@ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{ ...@@ -32,7 +32,11 @@ public class WepayStrategyAppletImpl extends AbstractWepayStrategy{
@Override @Override
SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap, DragonPayBaseReqDto dragonPayBaseReqDto) { SortedMap<String, Object> appendRequestParam(SortedMap<String, Object> requestMap, DragonPayBaseReqDto dragonPayBaseReqDto) {
requestMap.put("trade_type", "JSAPI"); requestMap.put("trade_type", "JSAPI");
requestMap.put("appid", PayWepayUtils.getInstance().getAPPLET_APP_ID()); if(dragonPayBaseReqDto.getAppIdType().equals("b")){
requestMap.put("appid", PayWepayUtils.getInstance().getAPPLETB_APPID());
}else{
requestMap.put("appid", PayWepayUtils.getInstance().getAPPLET_APP_ID());
}
requestMap.put("openid", dragonPayBaseReqDto.getOpenId()); //只有trade_type="JSAPI"时必须传 requestMap.put("openid", dragonPayBaseReqDto.getOpenId()); //只有trade_type="JSAPI"时必须传
return requestMap; return requestMap;
} }
......
...@@ -91,6 +91,10 @@ public class PayController { ...@@ -91,6 +91,10 @@ public class PayController {
DragonPayBaseReqDto dragonPayBaseReqDto = DragonPayBaseReqDto.getNew(); DragonPayBaseReqDto dragonPayBaseReqDto = DragonPayBaseReqDto.getNew();
dragonPayBaseReqDto.setPayType(payType); dragonPayBaseReqDto.setPayType(payType);
dragonPayBaseReqDto.setDeviceFrom(deviceFrom); dragonPayBaseReqDto.setDeviceFrom(deviceFrom);
if(deviceFrom.equals("appletb")){
dragonPayBaseReqDto.setDeviceFrom("applet");
dragonPayBaseReqDto.setAppIdType("b");
}
dragonPayBaseReqDto.setOpenId(openId); dragonPayBaseReqDto.setOpenId(openId);
dragonPayBaseReqDto.setType(type); dragonPayBaseReqDto.setType(type);
dragonPayBaseReqDto.setPrice(price); dragonPayBaseReqDto.setPrice(price);
......
...@@ -56,7 +56,11 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService { ...@@ -56,7 +56,11 @@ public class DragonOrdersServiceImpl implements IDragonOrdersService {
@Override @Override
public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) { public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) {
//设置支付编号 //设置支付编号
dragonPayBaseReqDto.setCode(IDGenerator.payCode()); if(dragonPayBaseReqDto.getAppIdType().equals("b")){
dragonPayBaseReqDto.setCode(IDGenerator.payCodeByType());
}else{
dragonPayBaseReqDto.setCode(IDGenerator.payCode());
}
log.info("dragon:dragonPay:req:dragonPayBaseReqDto : {}",dragonPayBaseReqDto.toString()); log.info("dragon:dragonPay:req:dragonPayBaseReqDto : {}",dragonPayBaseReqDto.toString());
return payChannelStrategyContext.getStrategy(dragonPayBaseReqDto.getPayType()).dragonPay(dragonPayBaseReqDto); return payChannelStrategyContext.getStrategy(dragonPayBaseReqDto.getPayType()).dragonPay(dragonPayBaseReqDto);
} }
......
...@@ -44,6 +44,9 @@ public class PayWepayUtils { ...@@ -44,6 +44,9 @@ public class PayWepayUtils {
private final String WAP_APP_ID="wx3498304dda39c5a1"; private final String WAP_APP_ID="wx3498304dda39c5a1";
private final String APPLET_APP_ID="wx4732efeaa2b08086"; private final String APPLET_APP_ID="wx4732efeaa2b08086";
private final String APPLETB_APPID="wxe3a093ce7278d5b1";
private final String merchantBId="1614003616";
public PayWepayUtils() { public PayWepayUtils() {
} }
...@@ -60,6 +63,14 @@ public class PayWepayUtils { ...@@ -60,6 +63,14 @@ public class PayWepayUtils {
return APPLET_APP_ID; return APPLET_APP_ID;
} }
public String getAPPLETB_APPID() {
return APPLETB_APPID;
}
public String getMerchantBId() {
return merchantBId;
}
public String getJS_APP_ID() { public String getJS_APP_ID() {
return JS_APP_ID; return JS_APP_ID;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment