|
@@ -17,6 +17,7 @@ import com.fs.common.utils.CloudHostUtils;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
|
|
|
+import com.fs.common.utils.uuid.IdUtils;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.core.config.WxPayProperties;
|
|
import com.fs.core.config.WxPayProperties;
|
|
@@ -46,6 +47,8 @@ import com.fs.hisStore.enums.*;
|
|
|
import com.fs.hisStore.mapper.*;
|
|
import com.fs.hisStore.mapper.*;
|
|
|
import com.fs.hisStore.param.*;
|
|
import com.fs.hisStore.param.*;
|
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
|
|
|
+import com.fs.huifuPay.domain.HuifuConfirmrefundResult;
|
|
|
|
|
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmrefundRequest;
|
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.live.vo.LiveOrderItemListUVO;
|
|
import com.fs.live.vo.LiveOrderItemListUVO;
|
|
@@ -1145,12 +1148,29 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
return R.error("退款请求失败"+e.getErrCodeDes());
|
|
return R.error("退款请求失败"+e.getErrCodeDes());
|
|
|
}
|
|
}
|
|
|
}else if (payment.getPayMode()!=null&&payment.getPayMode().equals("hf")){
|
|
}else if (payment.getPayMode()!=null&&payment.getPayMode().equals("hf")){
|
|
|
-//
|
|
|
|
|
|
|
+ if (CloudHostUtils.hasCloudHostName("鸿森堂")) {
|
|
|
|
|
+ if (payment.getIsShare() == 1) {
|
|
|
|
|
+ V2TradePaymentDelaytransConfirmrefundRequest confirmRefundRequest = new V2TradePaymentDelaytransConfirmrefundRequest();
|
|
|
|
|
+ String orderCode = IdUtils.randomUUID();
|
|
|
|
|
+ confirmRefundRequest.setReqSeqId(orderCode);
|
|
|
|
|
+ confirmRefundRequest.setOrgReqSeqId(payment.getShareCode());
|
|
|
|
|
+ confirmRefundRequest.setOrgReqDate(payment.getShareDate());
|
|
|
|
|
+ HuifuConfirmrefundResult result = huiFuService.confirmRefund(confirmRefundRequest, payment.getAppId());
|
|
|
|
|
+ if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
|
|
+ refund(payment.getAppId(),payType,payment,order,refundAmount);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new CustomException("交易确认退款请求失败" + result.getResp_desc());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ refund(payment.getAppId(),payType,payment,order,refundAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
// MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
// MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
// FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
// FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
|
|
- MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
- FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
|
|
// String huifuId="";
|
|
// String huifuId="";
|
|
|
// FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
|
|
// FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
|
|
@@ -1172,26 +1192,26 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
- String huifuId="";
|
|
|
|
|
- if (payment.getAppId() != null) {
|
|
|
|
|
- if (merchantAppConfig == null){
|
|
|
|
|
- huifuId = fsPayConfig.getHuifuId();
|
|
|
|
|
- }else {
|
|
|
|
|
- huifuId = merchantAppConfig.getMerchantId();
|
|
|
|
|
|
|
+ String huifuId="";
|
|
|
|
|
+ if (payment.getAppId() != null) {
|
|
|
|
|
+ if (merchantAppConfig == null){
|
|
|
|
|
+ huifuId = fsPayConfig.getHuifuId();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ huifuId = merchantAppConfig.getMerchantId();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
|
|
|
|
|
+
|
|
|
|
|
+ huifuId = merchantAppConfig.getMerchantId();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ huifuId=fsPayConfig.getHuifuId();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
|
|
|
|
|
|
|
|
|
|
- huifuId = merchantAppConfig.getMerchantId();
|
|
|
|
|
- }else {
|
|
|
|
|
- huifuId=fsPayConfig.getHuifuId();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
- request.setOrgHfSeqId(payment.getTradeNo());
|
|
|
|
|
- request.setHuifuId(huifuId);
|
|
|
|
|
|
|
+ V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
+ request.setOrgHfSeqId(payment.getTradeNo());
|
|
|
|
|
+ request.setHuifuId(huifuId);
|
|
|
|
|
|
|
|
// request.setOrdAmt(df.format(refundAmount));
|
|
// request.setOrdAmt(df.format(refundAmount));
|
|
|
// request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
// request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
@@ -1200,42 +1220,42 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
// extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
// extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
// request.setAppId(payment.getAppId());
|
|
// request.setAppId(payment.getAppId());
|
|
|
|
|
|
|
|
- Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
|
|
- if (order.getPayType().equals("99")){
|
|
|
|
|
- if("北京卓美".equals(companyName)){
|
|
|
|
|
- request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
|
|
+ Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
|
|
+ if (order.getPayType().equals("99")){
|
|
|
|
|
+ if("北京卓美".equals(companyName)){
|
|
|
|
|
+ request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
|
|
|
|
|
+ if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
|
|
|
|
|
+ extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
|
|
|
|
|
+ }
|
|
|
}else {
|
|
}else {
|
|
|
- request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
- }
|
|
|
|
|
- extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
|
|
|
|
|
- if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
|
|
|
|
|
- extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
|
|
|
|
|
|
|
+ if("北京卓美".equals(companyName)){
|
|
|
|
|
+ request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
|
|
+ request.setAppId(payment.getAppId());
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
- if("北京卓美".equals(companyName)){
|
|
|
|
|
- request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
- }else{
|
|
|
|
|
- request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
|
|
- }
|
|
|
|
|
- extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
|
|
- request.setAppId(payment.getAppId());
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
|
|
- request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
|
|
- request.setExtendInfo(extendInfoMap);
|
|
|
|
|
- HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
|
|
- logger.info("退款:"+refund);
|
|
|
|
|
- if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
|
|
- payment.setRefundMoney(refundAmount);
|
|
|
|
|
- payment.setStatus(-1);
|
|
|
|
|
- payment.setRefundTime(new Date());
|
|
|
|
|
- paymentService.updateFsStorePayment(payment);
|
|
|
|
|
- }else {
|
|
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
- return R.error(refund.getResp_desc());
|
|
|
|
|
|
|
+ request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
|
|
+ request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
|
|
+ request.setExtendInfo(extendInfoMap);
|
|
|
|
|
+ HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
|
|
+ logger.info("退款:"+refund);
|
|
|
|
|
+ if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
|
|
+ payment.setRefundMoney(refundAmount);
|
|
|
|
|
+ payment.setStatus(-1);
|
|
|
|
|
+ payment.setRefundTime(new Date());
|
|
|
|
|
+ paymentService.updateFsStorePayment(payment);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
+ return R.error(refund.getResp_desc());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}else {
|
|
}else {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return R.error("支付类型异常");
|
|
return R.error("支付类型异常");
|
|
@@ -1260,6 +1280,68 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void refund(String appId,String payType,FsStorePaymentScrm payment,FsStoreOrderScrm order,BigDecimal refundAmount){
|
|
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(appId,payType);
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
+
|
|
|
|
|
+ String huifuId="";
|
|
|
|
|
+ if (payment.getAppId() != null) {
|
|
|
|
|
+ if (merchantAppConfig == null){
|
|
|
|
|
+ huifuId = fsPayConfig.getHuifuId();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ huifuId = merchantAppConfig.getMerchantId();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
|
|
|
|
|
+
|
|
|
|
|
+ huifuId = merchantAppConfig.getMerchantId();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ huifuId=fsPayConfig.getHuifuId();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
+ request.setOrgHfSeqId(payment.getTradeNo());
|
|
|
|
|
+ request.setHuifuId(huifuId);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
|
|
+ if (order.getPayType().equals("99")){
|
|
|
|
|
+ if("北京卓美".equals(companyName)){
|
|
|
|
|
+ request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
|
|
|
|
|
+ if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
|
|
|
|
|
+ extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ if("北京卓美".equals(companyName)){
|
|
|
|
|
+ request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
|
|
+ request.setAppId(payment.getAppId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
|
|
+ request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
|
|
+ request.setExtendInfo(extendInfoMap);
|
|
|
|
|
+ HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
|
|
+ logger.info("退款:"+refund);
|
|
|
|
|
+ if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
|
|
+ payment.setRefundMoney(refundAmount);
|
|
|
|
|
+ payment.setStatus(-1);
|
|
|
|
|
+ payment.setRefundTime(new Date());
|
|
|
|
|
+ paymentService.updateFsStorePayment(payment);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
+ throw new CustomException(refund.getResp_desc());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStoreProductPurchaseLimitScrmService purchaseLimitService;
|
|
private IFsStoreProductPurchaseLimitScrmService purchaseLimitService;
|
|
|
|
|
|