|
|
@@ -2,6 +2,7 @@ package com.fs.live.service.impl;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
@@ -1369,6 +1370,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
IErpOrderService erpOrderService = getErpService();
|
|
|
FsErpConfig erpConfig = configUtil.generateStructConfigByKey("his.config", FsErpConfig.class);
|
|
|
LiveOrder order = baseMapper.selectLiveOrderByOrderId(String.valueOf(orderId));
|
|
|
+// TODO 售后单问题处理
|
|
|
LiveAfterSales updateSales = liveAfterSalesMapper.getLiveAfterSalesByOrderId(orderId);
|
|
|
if (updateSales == null) {
|
|
|
return R.error("售后单不存在");
|
|
|
@@ -1463,17 +1465,20 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
if (payments != null && !payments.isEmpty()) {
|
|
|
// String json = configService.selectConfigByKey("his.pay");
|
|
|
// FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
-
|
|
|
+ SysConfig sysConfig = configService.selectConfigByConfigKey("app.config");
|
|
|
+ AppConfig config = new Gson().fromJson(sysConfig.getConfigValue(), AppConfig.class);
|
|
|
for (LiveOrderPayment payment : payments) {
|
|
|
- FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
|
|
|
- if (fsCoursePlaySourceConfig == null) {
|
|
|
- throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
|
|
|
+ if (order.getPayType().equals("99")){
|
|
|
+ payment.setAppId(config.getAppId());
|
|
|
}
|
|
|
- Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
- if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
- throw new CustomException("小程序没有配置商户信息");
|
|
|
+// payment.setAppId(config.getAppId());
|
|
|
+
|
|
|
+ String payType = payment.getPayMode();
|
|
|
+ if ("wxApp".equals(payment.getPayMode())){
|
|
|
+ payType = "wx";
|
|
|
}
|
|
|
- MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
+
|
|
|
FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
if (payment.getPayMode() == null || "wx".equals(payment.getPayMode())) {
|
|
|
@@ -1510,18 +1515,15 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
}
|
|
|
} else if (payment.getPayMode() != null && "hf".equals(payment.getPayMode())) {
|
|
|
String huifuId = "";
|
|
|
- FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
|
|
|
if (payment.getAppId() != null) {
|
|
|
- FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(payment.getAppId());
|
|
|
- if (fsHfpayConfig != null) {
|
|
|
- huifuId = fsHfpayConfig.getHuifuId();
|
|
|
+ if (merchantAppConfig != null) {
|
|
|
+ huifuId = merchantAppConfig.getMerchantId();
|
|
|
}
|
|
|
} else {
|
|
|
CloudHostProper cloudHostProper = SpringUtils.getBean(CloudHostProper.class);
|
|
|
if ("益善缘".equals(cloudHostProper.getCompanyName())) {
|
|
|
- FsHfpayConfig fsPayConfig2 = fsHfpayConfigMapper.selectByAppId("wx0d1a3dd485268521");
|
|
|
- if (fsPayConfig2 != null) {
|
|
|
- huifuId = fsPayConfig2.getHuifuId();
|
|
|
+ if (merchantAppConfig != null) {
|
|
|
+ huifuId = merchantAppConfig.getMerchantId();
|
|
|
}
|
|
|
} else {
|
|
|
huifuId = fsPayConfig.getHuifuId();
|
|
|
@@ -1531,13 +1533,19 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
request.setOrgHfSeqId(payment.getTradeNo());
|
|
|
request.setHuifuId(huifuId);
|
|
|
- request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
- extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
+
|
|
|
+ if (order.getPayType().equals("99")){
|
|
|
+ request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
|
|
|
+ extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
|
|
|
+ }else {
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
+ extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
+ request.setAppId(payment.getAppId());
|
|
|
+ }
|
|
|
request.setExtendInfo(extendInfoMap);
|
|
|
- request.setAppId(payment.getAppId());
|
|
|
HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
log.info("退款:" + refund);
|
|
|
if (refund != null && ("00000000".equals(refund.getResp_code()) || "00000100".equals(refund.getResp_code()))
|
|
|
@@ -1607,8 +1615,11 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 封装微信参数
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private WxPayService getWxPayService(){
|
|
|
SysConfig sysConfig = configService.selectConfigByConfigKey("app.config");
|
|
|
AppConfig config = new Gson().fromJson(sysConfig.getConfigValue(), AppConfig.class);
|
|
|
@@ -1617,15 +1628,15 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
throw new CustomException("未找到appId对应的小程序配置: " + config.getAppId());
|
|
|
}
|
|
|
MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
- FsPayConfig payConfig1 = com.hc.openapi.tool.fastjson.JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+ FsPayConfig payConfig1 = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(payConfig1.getAppId());
|
|
|
+ payConfig.setAppId(merchantAppConfig.getAppId());
|
|
|
payConfig.setMchId(payConfig1.getWxMchId());
|
|
|
payConfig.setMchKey(payConfig1.getWxMchKey());
|
|
|
payConfig.setSubAppId(StringUtils.trimToNull(null));
|
|
|
payConfig.setSubMchId(StringUtils.trimToNull(null));
|
|
|
- payConfig.setKeyPath(null);
|
|
|
+ payConfig.setKeyPath(payConfig1.getKeyPath());
|
|
|
payConfig.setNotifyUrl(payConfig1.getNotifyUrlScrm());
|
|
|
WxPayServiceImpl payService = new WxPayServiceImpl();
|
|
|
payService.setConfig(payConfig);
|