|
|
@@ -2,6 +2,7 @@ package com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay;
|
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.models.requestModel.SuperResponseModel;
|
|
|
import com.github.microservice.models.type.PaymentType;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
@@ -16,17 +17,25 @@ import com.zhongshu.payment.client.payModel.commn.CreateOrderParam;
|
|
|
import com.zhongshu.payment.client.payModel.commn.PayNotifyParam;
|
|
|
import com.zhongshu.payment.client.payModel.commn.PayOrderParam;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.model.*;
|
|
|
+import com.zhongshu.payment.client.types.unionFrictionlessPayType.ContractState;
|
|
|
+import com.zhongshu.payment.client.types.unionFrictionlessPayType.UnionUserOpenType;
|
|
|
import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
|
|
|
import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
|
|
|
+import com.zhongshu.payment.server.core.service.org.CollectionIdService;
|
|
|
import com.zhongshu.payment.server.core.service.pay.SuperPayService;
|
|
|
import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.config.UnionFrictionlessPayApiConfig;
|
|
|
import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.config.UnionFrictionlessPayConfig;
|
|
|
+import com.zhongshu.payment.server.core.service.pay.impl.unionFrictionlessPay.config.UnionPaymentConfig;
|
|
|
+import com.zhongshu.payment.server.core.utils.AesUtils;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
/**
|
|
|
* 银联无感支付服务
|
|
|
*
|
|
|
@@ -50,6 +59,9 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
@Autowired
|
|
|
OrganizationFeignService organizationFeignService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ CollectionIdService collectionIdService;
|
|
|
+
|
|
|
/**
|
|
|
* 发起签约
|
|
|
*
|
|
|
@@ -57,49 +69,76 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultContent sign(SignInParam param) {
|
|
|
-// String sign = unionRequestService.signParam(param);
|
|
|
-// log.info("sign: {}", sign);
|
|
|
+ String userId = getCurrentUserId();
|
|
|
String shopOid = param.getShopOid();
|
|
|
- // 验证学校信息
|
|
|
- UnionUserOpenInfo unionUserOpenInfo = new UnionUserOpenInfo();
|
|
|
- unionUserOpenInfo.setShopOid(shopOid);
|
|
|
|
|
|
+ // 验证学校信息
|
|
|
+ String contractNo = collectionIdService.getNextNo();
|
|
|
+ UnionUserOpenInfo unionUserOpenInfo = unionUserOpenInfoDao.findTopByUserId(userId);
|
|
|
+ if (ObjectUtils.isEmpty(unionUserOpenInfo)) {
|
|
|
+ unionUserOpenInfo = new UnionUserOpenInfo();
|
|
|
+ unionUserOpenInfo.setShopOid(shopOid);
|
|
|
+ unionUserOpenInfo.setUserId(userId);
|
|
|
+ unionUserOpenInfo.setUnionUserOpenType(UnionUserOpenType.Shop);
|
|
|
+ unionUserOpenInfo.setContractState(ContractState.UNSIGNED);
|
|
|
+ }
|
|
|
+ unionUserOpenInfo.setContractNo(contractNo);
|
|
|
+ Date expireDate = new Date(System.currentTimeMillis() + UnionPaymentConfig.expireTime);
|
|
|
+ unionUserOpenInfo.setExpiredTime(expireDate.getTime());
|
|
|
|
|
|
+ String expireTime = DateUtils.paresTime(expireDate.getTime(), DateUtils.FORMAT_LONG);
|
|
|
SignParam signParam = new SignParam();
|
|
|
signParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
+ signParam.setMid(UnionPaymentConfig.mid);
|
|
|
+ signParam.setPlanId(UnionPaymentConfig.planId);
|
|
|
+ signParam.setContractNo(contractNo);
|
|
|
+ signParam.setNotifyUrl(UnionPaymentConfig.notifyUrl + "/" + contractNo);
|
|
|
+ signParam.setExpireTime(expireTime);
|
|
|
+ signParam.setInvokeScene(UnionPaymentConfig.invokeScene);
|
|
|
+ signParam.setMchntWxMpAppId(UnionPaymentConfig.mchntWxMpAppId);
|
|
|
+ signParam.setMchntWxMpPath(UnionPaymentConfig.mchntWxMpPath);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.set("certifTp", "01");
|
|
|
+ jsonObject.set("certifId", "511304198608153312");
|
|
|
+ jsonObject.set("customerNm", "唐仁祥");
|
|
|
+ signParam.setCustInfo(AesUtils.base64Encode(jsonObject.toString()));
|
|
|
+
|
|
|
String url = payApiConfig.getUrl(UnionFrictionlessPayApiConfig.sign);
|
|
|
- SuperResponseModel requestAPI = unionRequestService.requestAPI(url, signParam, SuperResponseModel.class);
|
|
|
+ SuperResponseModel requestAPI = unionRequestService.requestAPI(url, signParam, SignResponse.class);
|
|
|
if (requestAPI.isFailed()) {
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
|
-
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.set("walletOption", "SINGLE");
|
|
|
- jsonObject.set("billNo", "31940000201700002");
|
|
|
- jsonObject.set("billDate", "2017-06-26");
|
|
|
- jsonObject.set("sign", "2631915B7F7822C4B00A488A32E03764");
|
|
|
- jsonObject.set("requestTimestamp", "2017-06-26 17:28:02");
|
|
|
- jsonObject.set("instMid", "QRPAYDEFAULT");
|
|
|
- jsonObject.set("msgSrc", "WWW.TEST.COM");
|
|
|
- jsonObject.set("totalAmount", "1");
|
|
|
-
|
|
|
- JSONArray array = new JSONArray();
|
|
|
- JSONObject good = new JSONObject();
|
|
|
- good.set("body", "微信二维码测试");
|
|
|
- good.set("price", "1");
|
|
|
- good.set("goodsName", "微信二维码测试");
|
|
|
- good.set("goodsId", "1");
|
|
|
- good.set("quantity", "1");
|
|
|
- good.set("goodsCategory", "TEST");
|
|
|
- array.add(good);
|
|
|
- jsonObject.set("goods", array);
|
|
|
-
|
|
|
- jsonObject.set("msgType", "bills.getQRCode");
|
|
|
- jsonObject.set("mid", "898340149000005");
|
|
|
- jsonObject.set("tid", "88880001");
|
|
|
-
|
|
|
- String sign1 = unionRequestService.signByJSONObject(jsonObject);
|
|
|
- log.info("sign1: {}", sign1);
|
|
|
+ SignResponse response = (SignResponse) requestAPI;
|
|
|
+ log.info("response: {}", JSONUtil.toJsonStr(response));
|
|
|
+
|
|
|
+ unionUserOpenInfoDao.save(unionUserOpenInfo);
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.set("walletOption", "SINGLE");
|
|
|
+// jsonObject.set("billNo", "31940000201700002");
|
|
|
+// jsonObject.set("billDate", "2017-06-26");
|
|
|
+// jsonObject.set("sign", "2631915B7F7822C4B00A488A32E03764");
|
|
|
+// jsonObject.set("requestTimestamp", "2017-06-26 17:28:02");
|
|
|
+// jsonObject.set("instMid", "QRPAYDEFAULT");
|
|
|
+// jsonObject.set("msgSrc", "WWW.TEST.COM");
|
|
|
+// jsonObject.set("totalAmount", "1");
|
|
|
+//
|
|
|
+// JSONArray array = new JSONArray();
|
|
|
+// JSONObject good = new JSONObject();
|
|
|
+// good.set("body", "微信二维码测试");
|
|
|
+// good.set("price", "1");
|
|
|
+// good.set("goodsName", "微信二维码测试");
|
|
|
+// good.set("goodsId", "1");
|
|
|
+// good.set("quantity", "1");
|
|
|
+// good.set("goodsCategory", "TEST");
|
|
|
+// array.add(good);
|
|
|
+// jsonObject.set("goods", array);
|
|
|
+//
|
|
|
+// jsonObject.set("msgType", "bills.getQRCode");
|
|
|
+// jsonObject.set("mid", "898340149000005");
|
|
|
+// jsonObject.set("tid", "88880001");
|
|
|
+//
|
|
|
+// String sign1 = unionRequestService.signByJSONObject(jsonObject);
|
|
|
+// log.info("sign1: {}", sign1);
|
|
|
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -184,6 +223,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
|
|
|
/**
|
|
|
* 云闪付 申请退款
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -203,6 +243,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
|
|
|
/**
|
|
|
* 云闪付 申请退款
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -222,6 +263,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
|
|
|
/**
|
|
|
* 云闪付 申请退款
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|