Browse Source

同步优化逻辑

master
xh-pan1 2 years ago
parent
commit
d029f2e1ed
  1. 14
      cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/XsPayController.java
  2. 12
      cereshop-app/src/main/java/com/shop/cereshop/app/pay/xs/service/impl/XsPayServiceImpl.java
  3. 38
      cereshop-app/src/main/java/com/shop/cereshop/app/service/stock/impl/CrossStockServiceImpl.java
  4. 3
      cereshop-app/src/main/java/com/shop/cereshop/app/utils/WechatUtil.java
  5. 13
      cereshop-app/src/main/resources/application.yml
  6. 31
      cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java
  7. 12
      cereshop-business/src/main/resources/application.yml
  8. BIN
      cereshop-business/src/main/resources/static/导入商品模板表.xlsx
  9. 49
      cereshop-commons/src/main/java/com/shop/cereshop/commons/config/CrossStockConfig.java
  10. 7
      cereshop-commons/src/main/java/com/shop/cereshop/commons/config/XspayConfig.java
  11. 5
      cereshop-commons/src/main/java/com/shop/cereshop/commons/exception/CoBusinessException.java
  12. 2
      cereshop-commons/src/main/java/com/shop/cereshop/commons/utils/HttpUtils.java

14
cereshop-app/src/main/java/com/shop/cereshop/app/controller/extend/XsPayController.java

@ -73,7 +73,7 @@ public class XsPayController {
}
}
//TODO 如果不是跨境支付应该不调用接口------pxh
//TODO 如果不是跨境支付应该不调用接口------pxh
if(StringUtils.equals(XspayConfig.DEFUALT_TRADE_TYPE, XsPayEnum.TRADE_TYPE_CROSS_BOARD_PAYMENT.getCode())){
// String payRequestBodyJson = xsPayService.getPayRequestBodyJson(merOrderId, new BigDecimal(Integer.parseInt(content.getString("orderAmount")) * 1.0f / 100),
// XsPayEnum.TRADE_TYPE_CROSS_BOARD_PAYMENT.getCode(), content.getString("payType"));
@ -120,6 +120,18 @@ public class XsPayController {
return "success";
}
@PostMapping("pay/paystockbaoguan")
public String payStockBaoGuan(@RequestParam(name = "msg") String msg) throws Exception {
try {
String orderNo = msg.split(",")[0];
String payTransactionNo = msg.split(",")[1];
crossStockService.ibOrder(orderNo, payTransactionNo);
} catch (Exception e) {
e.printStackTrace();
}
return "success";
}
/**
* 退款通知回调
* @throws Exception

12
cereshop-app/src/main/java/com/shop/cereshop/app/pay/xs/service/impl/XsPayServiceImpl.java

@ -86,7 +86,7 @@ public class XsPayServiceImpl implements XsPayService {
String responeMsg = new String(Base64.getDecoder().decode(resMsg));
JSONObject jsonObject = JSONObject.parseObject(responeMsg);
String payInfoStr = jsonObject.getJSONObject("content").getJSONObject("payInfo").getString("payInfo");
payInfoStr = payInfoStr.substring(1, payInfoStr.length() - 2);
payInfoStr = payInfoStr.replace("{", "").replace("}", "");
String[] payInfoDetailArray = payInfoStr.split(",");
Map<String, String> resultMap = new HashMap<>();
for (String payInfoDetail : payInfoDetailArray) {
@ -94,8 +94,8 @@ public class XsPayServiceImpl implements XsPayService {
int firstIndex = payInfoDetail.indexOf("=");
String key = payInfoDetail.substring(0, firstIndex).trim();
String value = payInfoDetail.substring(firstIndex + 1).trim();
if(StringUtils.equals(key, "signType")){
value = "MD5";
if( !StringUtils.isEmpty(XspayConfig.WX_SIGN_TYPE) && StringUtils.equals(key, "signType")){
value = XspayConfig.WX_SIGN_TYPE;
}
resultMap.put(key, value);
}
@ -285,13 +285,13 @@ public class XsPayServiceImpl implements XsPayService {
CereBuyerUser user = cereBuyerUserService.selectByBuyerUserId(orderList.get(0).getBuyerUserId());
if(user == null){
throw new CoBusinessException("10000","系统出错,请联系管理员");
throw new CoBusinessException("10000","系统出错,请联系管理员", null);
}
if(StringUtils.isEmpty(user.getRealName())){
throw new CoBusinessException("10000","用户需要先设置真实姓名后下单");
throw new CoBusinessException("10000","用户需要先设置真实姓名后下单", null);
}
if(StringUtils.isEmpty(user.getIdCard())){
throw new CoBusinessException("10000","用户需要先设置身份证信息后下单");
throw new CoBusinessException("10000","用户需要先设置身份证信息后下单", null);
}
List<CereOrderProduct> cereOrderProductList = cereOrderProductDAO.findByOrderIds(orderList.stream().map(CereShopOrder::getOrderId).collect(Collectors.toList()));
log.info("cereOrderProductList:" + new Gson().toJson(cereOrderProductList));

38
cereshop-app/src/main/java/com/shop/cereshop/app/service/stock/impl/CrossStockServiceImpl.java

@ -6,6 +6,7 @@
package com.shop.cereshop.app.service.stock.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.gson.Gson;
import com.shop.cereshop.app.dao.order.CereOrderProductDAO;
import com.shop.cereshop.app.dao.order.CereShopOrderDAO;
@ -21,6 +22,7 @@ import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.express.HttpResult;
import com.shop.cereshop.commons.domain.order.CereOrderProduct;
import com.shop.cereshop.commons.domain.order.CereShopOrder;
import com.shop.cereshop.commons.domain.shop.CereShopCrossDetail;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.HttpUtils;
import com.shop.cereshop.commons.utils.StringUtils;
@ -63,10 +65,10 @@ public class CrossStockServiceImpl implements CrossStockService{
List<CereShopOrder> cereShopOrderList = cereShopOrderDAO.findByFormid(orderFromId);
CereShopOrder cereShopOrder = cereShopOrderList.get(0);
//商家详细信息
// CereShopCrossDetail cereShopCrossDetail = cereShopCrossDetailDAO.selectOne(Wrappers.<CereShopCrossDetail>lambdaQuery().eq(CereShopCrossDetail::getShopId, cereShopOrder.getShopId()));
// if(cereShopCrossDetail == null){
// throw new CoBusinessException("10000","商家未设置跨境信息");
// }
CereShopCrossDetail cereShopCrossDetail = cereShopCrossDetailDAO.selectOne(Wrappers.<CereShopCrossDetail>lambdaQuery().eq(CereShopCrossDetail::getShopId, cereShopOrder.getShopId()));
if(cereShopCrossDetail == null){
throw new CoBusinessException("10000","商家未设置跨境信息");
}
log.info("firstOrder:" + new Gson().toJson(cereShopOrder));
@ -106,11 +108,18 @@ public class CrossStockServiceImpl implements CrossStockService{
// private String consigneeidcard;
bo.setConsigneetelephone(cereShopOrder.getReceivePhone());
// bo.setEbpcode(cereShopCrossDetail.getEbpcode());
// bo.setEbpname(cereShopCrossDetail.getEbpname());
bo.setEbpcode("46016601J4");
bo.setEbpname("得壹(海南)科技有限公司");
if(StringUtils.isEmpty(CrossStockConfig.DEFAULT_COMPANY_CODE) &&
StringUtils.isEmpty(CrossStockConfig.DEFAULT_COMPANY_NAME)) {
bo.setEbpcode(cereShopCrossDetail.getEbpcode());
bo.setEbpname(cereShopCrossDetail.getEbpname());
// bo.setEbpcode("46016601J4");
// bo.setEbpname("得壹(海南)科技有限公司");
}else {
bo.setEbpcode(CrossStockConfig.DEFAULT_COMPANY_CODE);
bo.setEbpname(CrossStockConfig.DEFAULT_COMPANY_NAME);
}
bo.setDiscount(cereShopOrder.getDiscountPrice());
bo.setFreight(cereShopOrder.getLogisticsPrice());
@ -125,7 +134,11 @@ public class CrossStockServiceImpl implements CrossStockService{
IbOrderItemRequestBo item = new IbOrderItemRequestBo();
item.setPrice(cereOrderProduct.getProductPrice());
item.setQty(new BigDecimal(cereOrderProduct.getNumber()));
item.setSku(cereOrderProduct.getSKU());
if(StringUtils.isEmpty(CrossStockConfig.DEFAULT_SKU)){
item.setSku(cereOrderProduct.getSKU());
}else {
item.setSku(CrossStockConfig.DEFAULT_SKU);
}
items.add(item);
taxtotal = taxtotal.add(cereOrderProduct.getProductPrice()
@ -139,8 +152,11 @@ public class CrossStockServiceImpl implements CrossStockService{
bo.setOrderno(cereShopOrder.getOrderFormid());
//
bo.setPaycode("460116287K");
bo.setPayname("新生支付有限公司");
bo.setPaycode(CrossStockConfig.DEFAULT_PAY_COMPANY_CODE);
bo.setPayname(CrossStockConfig.DEFAULT_PAY_COMPANY_NAME);
// bo.setPaycode("460116287K");
// bo.setPayname("新生支付有限公司");
bo.setPaytransactionid(payTransactionNo);
bo.setStoreid("DY");

3
cereshop-app/src/main/java/com/shop/cereshop/app/utils/WechatUtil.java

@ -434,7 +434,8 @@ public class WechatUtil {
BufferedImage qrCodeImage = null;
BufferedReader reader = null;
try {
URL url = new URL("https://api.weixin.qq.com/wxa/getwxacode?access_token=" + accessToken);
// https://api.weixin.qq.com/wxa/getwxacode?access_token=
URL url = new URL("https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);

13
cereshop-app/src/main/resources/application.yml

@ -78,15 +78,16 @@ pay:
xspay:
url: https://uwebgate.hnapay.com/webgate/unifiedAPI.htm
app_return_url: xx
app_notice_url: http://14.22.116.132:81/ceres-app-api/extend/xsPay/pay/notify
app_baoguan_notice_url: http://14.22.116.132:81/ceres-app-api/extend/xsPay/pay/baoguannotify
app_notice_url: https://wechat.hnthee.com/ceres-app-api/extend/xsPay/pay/notify
app_baoguan_notice_url: https://wechat.hnthee.com/ceres-app-api/extend/xsPay/pay/baoguannotify
business_return_url: xx
business_notice_url: http://14.22.116.132:81/ceres-business-api/extend/xsPay/pay/notify
business_return_notice_url: http://14.22.116.132:81/ceres-business-api/extend/xsPay/refund/notify
mer_code: 5001626421847836001
business_notice_url: https://wechat.hnthee.com/ceres-business-api/extend/xsPay/pay/notify
business_return_notice_url: https://wechat.hnthee.com/ceres-business-api/extend/xsPay/refund/notify
mer_code: 10000000589
sign_type: 1
rsa_private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIsNcvBCDUYCkEyHcuzYyGL9TOHV0kQWcAUJmQqgIIcn7devK2fCSgZs5N42tVm59m07VyUmYXfXrFzx80qwp0Db3bUrqAZqMDB1YnxjiM+Rrrm0pPAPGvGUR4XunPIEbqidezUe1pZCMavejql+TkouXrtHQhZVJJHOQwhTvO03AgMBAAECgYBaFKRZMPEYYaDJcxXoiaeHOUENLE/C/CYlnUofsAxigmN6Tmh4F02NTA4YRqjFL8uMh9y0nGCYGof2zmcmA7rVPSOaQwqwqmc+lHWq/Jy5Z6cAxlod1UeA+BEF9gc/d6YNJx+1UoywMJgr4o/59K9MCZofFLUPGhxoMTQzTB34wQJBAL49KvP5EktoEbloVrqoMNXalgXmGeETrUGkc29uTegT/K/29FllcY5mlSJhnL/uoW8aMuU2V8h7fv7RoJBX/DUCQQC7HqNbl0tmj4ffBUsggoTyuKQby2bNLqPJ6wHcQB5OAZhP2E4q+KC9MpS3eT0ljC27/6T+y4Qvry+THmiU1jk7AkB4bWJWhZKmN6AYvctBaB1aE4CrBUnWqM0h48fLf4lD4/svLWbrfINRQPEhjadb/OUm3u/fF/KkEEGJcAxzs68NAkAIqCo2mpFKdWl7z+rh3if4csJk5swiwf2h4dV8Mxsz0K8TQpabNlV5a1WmB13k1s9m2zTu9MtwyVISJF4CRMbxAkEAi88aKBXP1TO9AFZwyNE2Z9dVcSk2xruj9yLgfKvpcZF5eGm3/S9wGz9k+753rxe/KMkWfWd0eIK3VK0iYJ9K+Q==
newpay_public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSsyBgvE
newpay_public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSsyBgvE+lwHaiGWUTozg++a+1+wy5UulZtE8uFDIu3tyJECxiPUrw2NE5UBkVqgYsSJu0keb3vvv5/xwsU9/wPEdYb/lhzFMlYt5Z+cob/khek7WQtmdoxCV6+AdGpo5tho2BikbYHbvehNjE894GZGVI1y/rGKxXBltqYqwoEwIDAQAB
huaxun:
url: https://bg.qdhuaxun.cn/index.php

31
cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java

@ -7,6 +7,7 @@ package com.shop.cereshop.business.param.product;
import com.shop.cereshop.commons.poi.IsNeeded;
import com.shop.cereshop.commons.utils.EmptyUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@ -42,6 +43,12 @@ public class ProductImport {
private String threeClassifyName;
/**
* 商品分组名称
*/
@IsNeeded
private Long shopGroupName;
/**
* 商品名称
*/
@IsNeeded
@ -96,6 +103,30 @@ public class ProductImport {
private Integer stockNumber;
/**
* 税率
*/
@IsNeeded
private BigDecimal rate;
/**
* 仓库名称
*/
@IsNeeded
private String storehouseName;
/**
* 是否跨境
*/
@IsNeeded
private String isCross;
/**
* 国际条码
*/
@IsNeeded
private String sku;
/**
* 重量
*/
@IsNeeded

12
cereshop-business/src/main/resources/application.yml

@ -67,13 +67,13 @@ autoDeliveryTime: 604800000
xspay:
url: https://uwebgate.hnapay.com/webgate/unifiedAPI.htm
app_return_url: xx
app_notice_url: http://14.22.116.132:81/ceres-app-api/extend/xsPay/pay/notify
app_baoguan_notice_url: http://14.22.116.132:81/ceres-app-api/extend/xsPay/pay/baoguannotify
app_notice_url: https://wechat.hnthee.com/ceres-app-api/extend/xsPay/pay/notify
app_baoguan_notice_url: https://wechat.hnthee.com/ceres-app-api/extend/xsPay/pay/baoguannotify
business_return_url: xx
business_notice_url: http://14.22.116.132:81/ceres-business-api/extend/xsPay/pay/notify
business_return_notice_url: http://14.22.116.132:81/ceres-business-api/extend/xsPay/refund/notify
mer_code: 5001626421847836001
business_notice_url: https://wechat.hnthee.com/ceres-business-api/extend/xsPay/pay/notify
business_return_notice_url: https://wechat.hnthee.com/ceres-business-api/extend/xsPay/refund/notify
mer_code: 10000000589
sign_type: 1
rsa_private_key: MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIsNcvBCDUYCkEyHcuzYyGL9TOHV0kQWcAUJmQqgIIcn7devK2fCSgZs5N42tVm59m07VyUmYXfXrFzx80qwp0Db3bUrqAZqMDB1YnxjiM+Rrrm0pPAPGvGUR4XunPIEbqidezUe1pZCMavejql+TkouXrtHQhZVJJHOQwhTvO03AgMBAAECgYBaFKRZMPEYYaDJcxXoiaeHOUENLE/C/CYlnUofsAxigmN6Tmh4F02NTA4YRqjFL8uMh9y0nGCYGof2zmcmA7rVPSOaQwqwqmc+lHWq/Jy5Z6cAxlod1UeA+BEF9gc/d6YNJx+1UoywMJgr4o/59K9MCZofFLUPGhxoMTQzTB34wQJBAL49KvP5EktoEbloVrqoMNXalgXmGeETrUGkc29uTegT/K/29FllcY5mlSJhnL/uoW8aMuU2V8h7fv7RoJBX/DUCQQC7HqNbl0tmj4ffBUsggoTyuKQby2bNLqPJ6wHcQB5OAZhP2E4q+KC9MpS3eT0ljC27/6T+y4Qvry+THmiU1jk7AkB4bWJWhZKmN6AYvctBaB1aE4CrBUnWqM0h48fLf4lD4/svLWbrfINRQPEhjadb/OUm3u/fF/KkEEGJcAxzs68NAkAIqCo2mpFKdWl7z+rh3if4csJk5swiwf2h4dV8Mxsz0K8TQpabNlV5a1WmB13k1s9m2zTu9MtwyVISJF4CRMbxAkEAi88aKBXP1TO9AFZwyNE2Z9dVcSk2xruj9yLgfKvpcZF5eGm3/S9wGz9k+753rxe/KMkWfWd0eIK3VK0iYJ9K+Q==
newpay_public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSsyBgvE
newpay_public_key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSsyBgvE+lwHaiGWUTozg++a+1+wy5UulZtE8uFDIu3tyJECxiPUrw2NE5UBkVqgYsSJu0keb3vvv5/xwsU9/wPEdYb/lhzFMlYt5Z+cob/khek7WQtmdoxCV6+AdGpo5tho2BikbYHbvehNjE894GZGVI1y/rGKxXBltqYqwoEwIDAQAB

BIN
cereshop-business/src/main/resources/static/导入商品模板表.xlsx

49
cereshop-commons/src/main/java/com/shop/cereshop/commons/config/CrossStockConfig.java

@ -19,6 +19,32 @@ public class CrossStockConfig {
public static String APPKEY = "4d6e1cf9dbb24dc78c3c4d24db021333";
/**
* 默认报关商家电商平台代码
*/
public static String DEFAULT_COMPANY_CODE = "";
/**
* 默认报关商家电商平台名称
*/
public static String DEFAULT_COMPANY_NAME = "";
/**
* 默认报关支付商家电商平台代码
*/
public static String DEFAULT_PAY_COMPANY_CODE = "";
/**
* 默认报关支付商家电商平台名称
*/
public static String DEFAULT_PAY_COMPANY_NAME = "";
/**
* 默认SKU
*/
public static String DEFAULT_SKU = "";
@Value("${crossstock.url:}")
public void setUrl(String url) {
this.URL = url;
@ -35,6 +61,29 @@ public class CrossStockConfig {
this.APPKEY = appKey;
}
@Value("${crossstock.default_company_code:}")
public void setCompanyCode(String defaultCompanyCode) {
this.DEFAULT_COMPANY_CODE = defaultCompanyCode;
}
@Value("${crossstock.default_company_name:}")
public void setCompanyName(String defaultCompanyName) {
this.DEFAULT_COMPANY_NAME = defaultCompanyName;
}
@Value("${crossstock.default_pay_company_code:}")
public void setPayCompanyCode(String defaultCompanyCode) {
this.DEFAULT_PAY_COMPANY_CODE = defaultCompanyCode;
}
@Value("${crossstock.default_pay_company_name:}")
public void setPayCompanyName(String defaultCompanyName) {
this.DEFAULT_PAY_COMPANY_NAME = defaultCompanyName;
}
@Value("${crossstock.default_sku:}")
public void setSku(String defaultSku) {
this.DEFAULT_SKU = defaultSku;
}
public static String getApiUrl(String apiUrlPath){
return URL + "/" + apiUrlPath + "?apptoken=" + APPTOKEN + "&appkey=" + APPKEY;
}

7
cereshop-commons/src/main/java/com/shop/cereshop/commons/config/XspayConfig.java

@ -76,6 +76,8 @@ public class XspayConfig {
public static String wxAppid = "";
public static String WX_SIGN_TYPE = "";
@Value("${xspay.url:}")
public void setUrl(String url) {
this.URL = url;
@ -140,6 +142,11 @@ public class XspayConfig {
this.DEFAULT_COMPANY_NAME = defaultCompanyName;
}
@Value("${xspay.wx_sign_type:}")
public void setWxSignType(String wxSignType) {
this.WX_SIGN_TYPE = wxSignType;
}
@Value("${weixin.appid:}")
public void setWxAppid(String appId) {
this.wxAppid = appId;

5
cereshop-commons/src/main/java/com/shop/cereshop/commons/exception/CoBusinessException.java

@ -29,6 +29,11 @@ public class CoBusinessException extends BaseException {
super(errorCode, CoReturnFormat.getMessage(errorCode),errorData);
}
public CoBusinessException(String errorCode, String errorMsg, Object errorData) {
super(errorCode, errorMsg,errorData);
}
public CoBusinessException(String errorCode, Throwable t) {
super(errorCode, CoReturnFormat.getMessage(errorCode), t);
}

2
cereshop-commons/src/main/java/com/shop/cereshop/commons/utils/HttpUtils.java

@ -100,7 +100,7 @@ public class HttpUtils {
HttpPost httpPost = new HttpPost(url);
StringEntity entity = new StringEntity(obj.toString());
StringEntity entity = new StringEntity(obj.toString(), "utf-8");
entity.setContentType("text/json");
entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(entity);

Loading…
Cancel
Save