|
|
@@ -1,8 +1,11 @@
|
|
|
package com.yami.shop.wx.service.impl;
|
|
|
+import com.yami.shop.wx.po.*;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.gson.Gson;
|
|
|
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.Verifier;
|
|
|
@@ -13,12 +16,10 @@ import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
|
|
|
import com.yami.shop.bean.bo.PayInfoBo;
|
|
|
import com.yami.shop.wx.config.CombinePayUrlEnum;
|
|
|
import com.yami.shop.wx.config.WechatPayServiceConfig;
|
|
|
-import com.yami.shop.wx.po.JsapiPayInfoPo;
|
|
|
-import com.yami.shop.wx.po.RefundInfoPo;
|
|
|
+import com.yami.shop.wx.config.WxConstants;
|
|
|
+import com.yami.shop.wx.form.*;
|
|
|
import com.yami.shop.wx.service.WxProviderService;
|
|
|
-import com.yami.shop.wx.utils.DateUtils;
|
|
|
-import com.yami.shop.wx.utils.OrderUtils;
|
|
|
-import com.yami.shop.wx.utils.WechatPayValidator;
|
|
|
+import com.yami.shop.wx.utils.*;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
@@ -441,8 +442,9 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
* 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提
|
|
|
*/
|
|
|
public static void uploadShippingInfo(String trackingNo, String transactionId, String itemDesc,
|
|
|
- String phone, String openid, String expressCompany, Integer type, String accessToken) {
|
|
|
- String url = "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" + accessToken;
|
|
|
+ String phone, String openid, String expressCompany, Integer type) {
|
|
|
+ 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();
|
|
|
// 定义日期时间格式化对象
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
|
|
// 格式化日期时间
|
|
|
@@ -492,7 +494,6 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
httpPost.addHeader("Content-Type", "application/json");
|
|
|
StringEntity requestBody = new StringEntity(requestDataJson.toJSONString(), ContentType.APPLICATION_JSON);
|
|
|
httpPost.setEntity(requestBody);
|
|
|
-
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
HttpEntity responseEntity = response.getEntity();
|
|
|
String responseString = EntityUtils.toString(responseEntity);
|
|
|
@@ -504,28 +505,139 @@ public class WxProviderServiceImpl implements WxProviderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static String traceWaybill(TraceWaybill traceWaybill) {
|
|
|
+ AccessToken accessToken = AccessTokenApi.getAccessToken(WxConstants.APPLET_APPID, WxConstants.APPLET_SECRET);
|
|
|
+ String url = "https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill?access_token=" + accessToken.getToken();
|
|
|
+ try {
|
|
|
+ CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
+ httpPost.addHeader("Content-Type", "application/json");
|
|
|
+ StringEntity requestBody = new StringEntity(new Gson().toJson(traceWaybill), ContentType.APPLICATION_JSON.withCharset("UTF-8"));
|
|
|
+ httpPost.setEntity(requestBody);
|
|
|
+ CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ String responseString = EntityUtils.toString(responseEntity,"UTF-8");
|
|
|
+ log.info(responseString);
|
|
|
+ response.close();
|
|
|
+ httpClient.close();
|
|
|
+ return responseString;
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//测试
|
|
|
- public static void serviceAddMerchant() {
|
|
|
- Map<String, Object> parameters = new TreeMap<>();
|
|
|
- //业务申请编号
|
|
|
- parameters.put("business_code", "业务申请编号");
|
|
|
+ public static void serviceAddMerchant(SubmitInfoForm form) {
|
|
|
+ SubmitInfo submitInfo = new SubmitInfo();
|
|
|
+ submitInfo.setBusinessCode("业务申请编号");
|
|
|
|
|
|
//超级管理员信息
|
|
|
- parameters.put("contact_info", "");
|
|
|
+ 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);
|
|
|
|
|
|
//主体资料
|
|
|
- parameters.put("subject_info", "");
|
|
|
+ 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("身份证人像面照片");
|
|
|
+ idCardInfo.setIdCardNational("身份证国徽面照片");
|
|
|
+ idCardInfo.setIdCardName("身份证姓名");
|
|
|
+ idCardInfo.setIdCardNumber("身份证号码");
|
|
|
+ idCardInfo.setIdCardAddress("身份证居住地址-主体类型为企业时,需要填写。其他主体类型,无需上传");
|
|
|
+ idCardInfo.setCardPeriodBegin("身份证有效期开始时间");
|
|
|
+ idCardInfo.setCardPeriodEnd("身份证有效期结束时间");
|
|
|
+ identityInfo.setIdCardInfo(idCardInfo);
|
|
|
+ subjectInfo.setIdentityInfo(identityInfo);
|
|
|
+ List<UBOInfoList> uboInfoList = Lists.newArrayList();
|
|
|
+
|
|
|
+ //最终受益人信息列表(UBO) 主体类型为企业时,需填写
|
|
|
+ UBOInfoList uboInfo = new UBOInfoList();
|
|
|
+ uboInfo.setUboIdDocType("IDENTIFICATION_TYPE_IDCARD");
|
|
|
+ uboInfo.setUboIdDocCopy("证件正面照片");
|
|
|
+ uboInfo.setUboIdDocCopyBack("证件反面照片");
|
|
|
+ uboInfo.setUboIdDocName("证件姓名");
|
|
|
+ uboInfo.setUboIdDocNumber("证件号码");
|
|
|
+ uboInfo.setUboIdDocAddress("证件居住地址");
|
|
|
+ uboInfo.setUboPeriodBegin("证件有效期开始时间");
|
|
|
+ uboInfo.setUboPeriodEnd("证件有效期结束时间");
|
|
|
+ uboInfoList.add(uboInfo);
|
|
|
+ subjectInfo.setUboInfoList(uboInfoList);
|
|
|
+ submitInfo.setSubjectInfo(subjectInfo);
|
|
|
|
|
|
//经营资料
|
|
|
- parameters.put("business_info", "");
|
|
|
-
|
|
|
- //结算规则
|
|
|
- parameters.put("settlement_info", "");
|
|
|
+ BusinessInfo businessInfo = new BusinessInfo();
|
|
|
+ businessInfo.setMerchantShortname("商户简称");
|
|
|
+ businessInfo.setServicePhone("客服电话");
|
|
|
+ SalesInfo salesInfo = new SalesInfo();
|
|
|
+ StoreInfo storeInfo = new StoreInfo();
|
|
|
+ storeInfo.setBizStoreName("线下场所名称");
|
|
|
+ storeInfo.setBizAddressCode("线下场所省市编码");
|
|
|
+ storeInfo.setBizStoreAddress("线下场所地址");
|
|
|
+ storeInfo.setStoreEntrancePic(Lists.newArrayList("线下场所门头照片"));
|
|
|
+ storeInfo.setIndoorPic(Lists.newArrayList("线下场所内部照片"));
|
|
|
+ storeInfo.setBizSubAppid("线下场所对应的商家AppID");
|
|
|
+ salesInfo.setBizStoreInfo(storeInfo);
|
|
|
+ MiniProgramInfo miniProgramInfo = new MiniProgramInfo();
|
|
|
+ miniProgramInfo.setMiniProgramAppid("服务商小程序AppID");
|
|
|
+ miniProgramInfo.setMiniProgramSubAppid("商家小程序AppID");
|
|
|
+ miniProgramInfo.setMiniProgramPics(Lists.newArrayList("小程序截图"));
|
|
|
+ salesInfo.setMiniProgramInfo(miniProgramInfo);
|
|
|
+ businessInfo.setSalesInfo(salesInfo);
|
|
|
+ submitInfo.setBusinessInfo(businessInfo);
|
|
|
+
|
|
|
+ SettlementInfo settlementInfo = new SettlementInfo();
|
|
|
+ settlementInfo.setSettlementId("入驻结算规则ID");
|
|
|
+ settlementInfo.setQualificationType("所属行业-填写指定行业名称");
|
|
|
+ submitInfo.setSettlementInfo(settlementInfo);
|
|
|
+
|
|
|
+ BankAccountInfo bankAccountInfo = new BankAccountInfo();
|
|
|
+ bankAccountInfo.setBankAccountType("对公银行账户/经营者个人银行卡");
|
|
|
+ bankAccountInfo.setAccountName("开户名称");
|
|
|
+ bankAccountInfo.setAccountBank("开户银行");
|
|
|
+ bankAccountInfo.setBankAddressCode("开户银行省市编码");
|
|
|
+ bankAccountInfo.setBankBranchId("开户银行银行号");
|
|
|
+ bankAccountInfo.setBankName("开户银行全称(含支行)");
|
|
|
+ bankAccountInfo.setAccountNumber("银行账号");
|
|
|
+ submitInfo.setBankAccountInfo(bankAccountInfo);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ String json = gson.toJson(submitInfo);
|
|
|
+ System.out.println(json);
|
|
|
+ }
|
|
|
|
|
|
- //结算银行账户
|
|
|
- parameters.put("bank_account_info", "");
|
|
|
+ private static String rsaEncryptData(String data) {
|
|
|
+ return data;
|
|
|
+ }
|
|
|
|
|
|
- System.out.println(parameters);
|
|
|
+ private static String wxUploadImg(String data) {
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ }
|
|
|
}
|