|
@@ -1,10 +1,8 @@
|
|
|
package com.yami.shop.wx.service.impl;
|
|
package com.yami.shop.wx.service.impl;
|
|
|
-import com.yami.shop.wx.po.*;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
|
|
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
|
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
|
|
@@ -17,7 +15,9 @@ import com.yami.shop.bean.bo.PayInfoBo;
|
|
|
import com.yami.shop.wx.config.CombinePayUrlEnum;
|
|
import com.yami.shop.wx.config.CombinePayUrlEnum;
|
|
|
import com.yami.shop.wx.config.WechatPayServiceConfig;
|
|
import com.yami.shop.wx.config.WechatPayServiceConfig;
|
|
|
import com.yami.shop.wx.config.WxConstants;
|
|
import com.yami.shop.wx.config.WxConstants;
|
|
|
-import com.yami.shop.wx.form.*;
|
|
|
|
|
|
|
+import com.yami.shop.wx.po.JsapiPayInfoPo;
|
|
|
|
|
+import com.yami.shop.wx.po.RefundInfoPo;
|
|
|
|
|
+import com.yami.shop.wx.po.TraceWaybill;
|
|
|
import com.yami.shop.wx.service.WxProviderService;
|
|
import com.yami.shop.wx.service.WxProviderService;
|
|
|
import com.yami.shop.wx.utils.*;
|
|
import com.yami.shop.wx.utils.*;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
@@ -43,7 +43,10 @@ import java.nio.charset.StandardCharsets;
|
|
|
import java.security.PrivateKey;
|
|
import java.security.PrivateKey;
|
|
|
import java.security.Signature;
|
|
import java.security.Signature;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Base64;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -436,14 +439,14 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
* @param trackingNo 物流单号
|
|
* @param trackingNo 物流单号
|
|
|
* @param transactionId 原支付交易对应的微信订单号
|
|
* @param transactionId 原支付交易对应的微信订单号
|
|
|
* @param expressCompany 物流公司编码 例如:SF
|
|
* @param expressCompany 物流公司编码 例如:SF
|
|
|
- * @param itemDesc 例如:微信红包抱枕*1个,限120个字以内
|
|
|
|
|
|
|
+ * @param itemDesc 例如:微信红包抱枕*1个,限120个字以内
|
|
|
* @param phone 当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一
|
|
* @param phone 当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一
|
|
|
* @param openid 微信open_id-小程序
|
|
* @param openid 微信open_id-小程序
|
|
|
* @param type 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式
|
|
* @param type 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式
|
|
|
* 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
|
|
* 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
|
|
|
*/
|
|
*/
|
|
|
public static void uploadShippingInfo(String trackingNo, String transactionId, String itemDesc,
|
|
public static void uploadShippingInfo(String trackingNo, String transactionId, String itemDesc,
|
|
|
- String phone, String openid, String expressCompany, Integer type) {
|
|
|
|
|
|
|
+ String phone, String openid, String expressCompany, Integer type) {
|
|
|
AccessToken accessToken = AccessTokenApi.getAccessToken(WxConstants.APPLET_APPID, WxConstants.APPLET_SECRET);
|
|
AccessToken accessToken = AccessTokenApi.getAccessToken(WxConstants.APPLET_APPID, WxConstants.APPLET_SECRET);
|
|
|
String url = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" + accessToken.getToken();
|
|
String url = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" + accessToken.getToken();
|
|
|
// 定义日期时间格式化对象
|
|
// 定义日期时间格式化对象
|
|
@@ -498,6 +501,7 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
HttpEntity responseEntity = response.getEntity();
|
|
HttpEntity responseEntity = response.getEntity();
|
|
|
String responseString = EntityUtils.toString(responseEntity);
|
|
String responseString = EntityUtils.toString(responseEntity);
|
|
|
|
|
+ System.out.println(" ==========返回结果========= " + responseString);
|
|
|
log.info(responseString);
|
|
log.info(responseString);
|
|
|
response.close();
|
|
response.close();
|
|
|
httpClient.close();
|
|
httpClient.close();
|
|
@@ -514,11 +518,11 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
HttpPost httpPost = new HttpPost(url);
|
|
HttpPost httpPost = new HttpPost(url);
|
|
|
httpPost.addHeader("Content-Type", "application/json");
|
|
httpPost.addHeader("Content-Type", "application/json");
|
|
|
- StringEntity requestBody = new StringEntity(new Gson().toJson(traceWaybill), ContentType.APPLICATION_JSON.withCharset("UTF-8"));
|
|
|
|
|
|
|
+ StringEntity requestBody = new StringEntity(new Gson().toJson(traceWaybill), ContentType.APPLICATION_JSON.withCharset("UTF-8"));
|
|
|
httpPost.setEntity(requestBody);
|
|
httpPost.setEntity(requestBody);
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
HttpEntity responseEntity = response.getEntity();
|
|
HttpEntity responseEntity = response.getEntity();
|
|
|
- String responseString = EntityUtils.toString(responseEntity,"UTF-8");
|
|
|
|
|
|
|
+ String responseString = EntityUtils.toString(responseEntity, "UTF-8");
|
|
|
log.info(responseString);
|
|
log.info(responseString);
|
|
|
response.close();
|
|
response.close();
|
|
|
httpClient.close();
|
|
httpClient.close();
|
|
@@ -529,142 +533,6 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //测试
|
|
|
|
|
- public static void serviceAddMerchant(SubmitInfoForm form) {
|
|
|
|
|
- SubmitInfo submitInfo = new SubmitInfo();
|
|
|
|
|
- submitInfo.setBusinessCode("业务申请编号");
|
|
|
|
|
-
|
|
|
|
|
- //超级管理员信息
|
|
|
|
|
- ContactInfo contactInfo = new ContactInfo();
|
|
|
|
|
- contactInfo.setContactType("LEGAL");
|
|
|
|
|
- contactInfo.setContactName(rsaEncryptData(form.getContactName()));
|
|
|
|
|
- contactInfo.setMobilePhone(rsaEncryptData(form.getMobilePhone()));
|
|
|
|
|
- contactInfo.setContactEmail(rsaEncryptData(form.getContactEmail()));
|
|
|
|
|
- submitInfo.setContactInfo(contactInfo);
|
|
|
|
|
-
|
|
|
|
|
- //主体资料
|
|
|
|
|
- SubjectInfo subjectInfo = new SubjectInfo();
|
|
|
|
|
- subjectInfo.setSubjectType(form.getSubjectType());
|
|
|
|
|
- subjectInfo.setFinanceInstitution(false);
|
|
|
|
|
-
|
|
|
|
|
- //营业执照
|
|
|
|
|
- BusinessLicense businessLicense = new BusinessLicense();
|
|
|
|
|
- businessLicense.setLicenseCopy(wxUploadImg(form.getLicenseCopy()));
|
|
|
|
|
- businessLicense.setLicenseNumber(form.getLicenseNumber());
|
|
|
|
|
- businessLicense.setMerchantName(form.getMerchantName());
|
|
|
|
|
- businessLicense.setLegalPerson(form.getLegalPerson());
|
|
|
|
|
- businessLicense.setLicenseAddress(form.getLicenseAddress());
|
|
|
|
|
- businessLicense.setPeriodBegin(form.getPeriodBegin());
|
|
|
|
|
- businessLicense.setPeriodEnd(form.getPeriodEnd());
|
|
|
|
|
- subjectInfo.setBusinessLicenseInfo(businessLicense);
|
|
|
|
|
-
|
|
|
|
|
- //经营者/法定代表人身份证件
|
|
|
|
|
- IdentityInfo identityInfo = new IdentityInfo();
|
|
|
|
|
- identityInfo.setIdDocType("IDENTIFICATION_TYPE_IDCARD");
|
|
|
|
|
-
|
|
|
|
|
- //身份证信息
|
|
|
|
|
- IdCardInfo idCardInfo = new IdCardInfo();
|
|
|
|
|
- idCardInfo.setIdCardCopy(wxUploadImg(form.getIdCardCopy()));
|
|
|
|
|
- idCardInfo.setIdCardNational(wxUploadImg(form.getIdCardNational()));
|
|
|
|
|
- idCardInfo.setIdCardName(rsaEncryptData(form.getIdCardName()));
|
|
|
|
|
- idCardInfo.setIdCardNumber(rsaEncryptData(form.getIdCardNumber()));
|
|
|
|
|
- idCardInfo.setIdCardAddress(rsaEncryptData(form.getIdCardAddress()));
|
|
|
|
|
- idCardInfo.setCardPeriodBegin(form.getCardPeriodBegin());
|
|
|
|
|
- idCardInfo.setCardPeriodEnd(form.getCardPeriodEnd());
|
|
|
|
|
- identityInfo.setIdCardInfo(idCardInfo);
|
|
|
|
|
- subjectInfo.setIdentityInfo(identityInfo);
|
|
|
|
|
- List<UBOInfoList> uboInfoList = Lists.newArrayList();
|
|
|
|
|
-
|
|
|
|
|
- //最终受益人信息列表(UBO) 主体类型为企业时,需填写
|
|
|
|
|
- UBOInfoList uboInfo = new UBOInfoList();
|
|
|
|
|
- uboInfo.setUboIdDocType("IDENTIFICATION_TYPE_IDCARD");
|
|
|
|
|
- uboInfo.setUboIdDocCopy(wxUploadImg(form.getIdCardCopy()));
|
|
|
|
|
- uboInfo.setUboIdDocCopyBack(wxUploadImg(form.getIdCardNational()));
|
|
|
|
|
- uboInfo.setUboIdDocName(rsaEncryptData(form.getIdCardName()));
|
|
|
|
|
- uboInfo.setUboIdDocNumber(rsaEncryptData(form.getIdCardNumber()));
|
|
|
|
|
- uboInfo.setUboIdDocAddress(rsaEncryptData(form.getIdCardAddress()));
|
|
|
|
|
- uboInfo.setUboPeriodBegin(form.getCardPeriodBegin());
|
|
|
|
|
- uboInfo.setUboPeriodEnd(form.getCardPeriodEnd());
|
|
|
|
|
- uboInfoList.add(uboInfo);
|
|
|
|
|
- subjectInfo.setUboInfoList(uboInfoList);
|
|
|
|
|
- submitInfo.setSubjectInfo(subjectInfo);
|
|
|
|
|
-
|
|
|
|
|
- //经营资料
|
|
|
|
|
- BusinessInfo businessInfo = new BusinessInfo();
|
|
|
|
|
- businessInfo.setMerchantShortname(form.getMerchantShortname());
|
|
|
|
|
- businessInfo.setServicePhone(form.getServicePhone());
|
|
|
|
|
-
|
|
|
|
|
- //经营场景
|
|
|
|
|
- SalesInfo salesInfo = new SalesInfo();
|
|
|
|
|
- salesInfo.setSalesScenesType(Lists.newArrayList("SALES_SCENES_STORE","SALES_SCENES_MINI_PROGRAM"));
|
|
|
|
|
-
|
|
|
|
|
- //线下场所场景
|
|
|
|
|
- StoreInfo storeInfo = new StoreInfo();
|
|
|
|
|
- storeInfo.setBizStoreName(form.getBizStoreName());
|
|
|
|
|
- storeInfo.setBizAddressCode(form.getBizAddressCode());
|
|
|
|
|
- storeInfo.setBizStoreAddress(form.getBizStoreAddress());
|
|
|
|
|
-
|
|
|
|
|
- storeInfo.setStoreEntrancePic(wxUploadImgList(Lists.newArrayList(form.getStoreEntrancePic())));
|
|
|
|
|
- storeInfo.setIndoorPic(wxUploadImgList(Lists.newArrayList(form.getIndoorPic())));
|
|
|
|
|
-
|
|
|
|
|
- storeInfo.setBizSubAppid("wx472b8557b46b80c2");
|
|
|
|
|
- salesInfo.setBizStoreInfo(storeInfo);
|
|
|
|
|
-
|
|
|
|
|
- //小程序场景
|
|
|
|
|
- MiniProgramInfo miniProgramInfo = new MiniProgramInfo();
|
|
|
|
|
- miniProgramInfo.setMiniProgramAppid("wx84ac4c97670ae96f");
|
|
|
|
|
- miniProgramInfo.setMiniProgramSubAppid("wx472b8557b46b80c2");
|
|
|
|
|
- miniProgramInfo.setMiniProgramPics(wxUploadImgList(Lists.newArrayList("小程序截图")));
|
|
|
|
|
- salesInfo.setMiniProgramInfo(miniProgramInfo);
|
|
|
|
|
- businessInfo.setSalesInfo(salesInfo);
|
|
|
|
|
- submitInfo.setBusinessInfo(businessInfo);
|
|
|
|
|
-
|
|
|
|
|
- //结算规则
|
|
|
|
|
- SettlementInfo settlementInfo = new SettlementInfo();
|
|
|
|
|
- settlementInfo.setSettlementId(form.getSubjectType().equals("SUBJECT_TYPE_INDIVIDUAL") ? "719" : "716");
|
|
|
|
|
- settlementInfo.setQualificationType(form.getQualificationType());
|
|
|
|
|
- submitInfo.setSettlementInfo(settlementInfo);
|
|
|
|
|
-
|
|
|
|
|
- //结算银行账户
|
|
|
|
|
- BankAccountInfo bankAccountInfo = new BankAccountInfo();
|
|
|
|
|
- bankAccountInfo.setBankAccountType(form.getBankAccountType());
|
|
|
|
|
- bankAccountInfo.setAccountName(rsaEncryptData(form.getAccountName()));
|
|
|
|
|
-
|
|
|
|
|
- //开户银行-对私银行列表-对公银行列表-查看是否需要填写支行字段-bank_alias_code
|
|
|
|
|
- bankAccountInfo.setAccountBank(form.getAccountBank());
|
|
|
|
|
- //查询接口
|
|
|
|
|
- if (form.getBankBranchId()!=null){
|
|
|
|
|
- bankAccountInfo.setBankBranchId(form.getBankBranchId());
|
|
|
|
|
- }
|
|
|
|
|
- bankAccountInfo.setAccountNumber(rsaEncryptData(form.getAccountNumber()));
|
|
|
|
|
- submitInfo.setBankAccountInfo(bankAccountInfo);
|
|
|
|
|
- String json = new Gson().toJson(submitInfo);
|
|
|
|
|
- System.out.println(json);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static String rsaEncryptData(String data) {
|
|
|
|
|
- return data;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static String wxUploadImg(String data) {
|
|
|
|
|
- return data;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static List<String> wxUploadImgList(List<String> imgList) {
|
|
|
|
|
- List<String> wxImgList = Lists.newArrayList();
|
|
|
|
|
- for (String img : imgList) {
|
|
|
|
|
- wxImgList.add(wxUploadImg(img));
|
|
|
|
|
- }
|
|
|
|
|
- return wxImgList;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static String toDataImgList(List<String> imgList) {
|
|
|
|
|
- return String.join(",", imgList);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
}
|
|
}
|