|
|
@@ -50,6 +50,7 @@ import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.vo.*;
|
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
+import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.im.dto.*;
|
|
|
import com.fs.im.service.IImService;
|
|
|
@@ -562,7 +563,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
//1.判断是否是全额退款
|
|
|
CompanyDivItem companyDivItem = null;
|
|
|
try {
|
|
|
- companyDivItem = doRefundDiv(fsStoreOrder, reMoney, payment, extendInfoMap);
|
|
|
+ companyDivItem = HuiFuUtils.doRefundDiv(fsStoreOrder.getPayPrice(), reMoney, payment, extendInfoMap);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("-----------------分账退款处理失败{}", e.getMessage());
|
|
|
}
|
|
|
@@ -629,86 +630,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 处理分账退款
|
|
|
- *
|
|
|
- * @param fsStoreOrder
|
|
|
- * @param reMoney
|
|
|
- * @param payment
|
|
|
- * @param extendInfoMap
|
|
|
- */
|
|
|
- private CompanyDivItem doRefundDiv(FsStoreOrder fsStoreOrder, BigDecimal reMoney, FsStorePayment payment, Map<String, Object> extendInfoMap) {
|
|
|
- CompanyDivItem companyDivItem = null;
|
|
|
- Long companyId = fsStoreOrder.getCompanyId();
|
|
|
- if (companyId != null) {
|
|
|
- companyDivItem = companyDivItemService.selectCompanyDivItemByPayCode(payment.getPayCode());
|
|
|
- if (fsStoreOrder.getPayPrice().compareTo(reMoney) > 0) {
|
|
|
- //部分退款
|
|
|
- if (companyDivItem != null) {
|
|
|
- SysConfigMapper sysConfigMapper = SpringUtils.getBean(SysConfigMapper.class);
|
|
|
- SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
|
|
|
- FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
|
|
|
- String defaultHuiFuId = fsPayConfig.getHuifuId(); //默认汇付id
|
|
|
-
|
|
|
- String detail = companyDivItem.getDetail();
|
|
|
- if (StringUtils.isNotBlank(detail)) {
|
|
|
- JSONObject acctSplitBunch = JSONObject.parseObject(detail);
|
|
|
- if (acctSplitBunch.get("percentage_flag") != null) {
|
|
|
- List<Map<String, Object>> param = new ArrayList(); //传入汇付参数
|
|
|
-
|
|
|
- String percentageFlag = acctSplitBunch.get("percentage_flag").toString();
|
|
|
- Object acctInfosObj = acctSplitBunch.get("acct_infos");
|
|
|
- if (acctInfosObj != null) {
|
|
|
- if ("Y".equals(percentageFlag)) {
|
|
|
- // 百分比分账
|
|
|
- List<Map> acctInfos = JSON.parseArray(acctInfosObj.toString(), Map.class);
|
|
|
- if (acctInfos != null && !acctInfos.isEmpty()) {
|
|
|
- BigDecimal remainMoney = reMoney;
|
|
|
-
|
|
|
- for (Map acctInfo : acctInfos) {
|
|
|
- String percentageDiv = acctInfo.get("percentage_div").toString();
|
|
|
- BigDecimal divAmt = reMoney.multiply(BigDecimal.valueOf(Float.valueOf(percentageDiv)).multiply(BigDecimal.valueOf(0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- if (divAmt.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- remainMoney = remainMoney.subtract(divAmt);
|
|
|
- String huiFuId = acctInfo.get("huifu_id").toString();
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("div_amt", divAmt);
|
|
|
- map.put("huifu_id", huiFuId);
|
|
|
-// part_loan_amt 垫资金额
|
|
|
- param.add(map);
|
|
|
- if (remainMoney.compareTo(BigDecimal.ZERO) >= 0) {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (remainMoney.compareTo(BigDecimal.ZERO) >= 0) {
|
|
|
- BigDecimal divAmt = reMoney.subtract(remainMoney).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("div_amt", divAmt);
|
|
|
- map.put("huifu_id", defaultHuiFuId);
|
|
|
- param.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if ("N".equals(percentageFlag)) {
|
|
|
- // 金额分账 目前按照排序从第一个开始扣 扣到满足退款金额
|
|
|
- }
|
|
|
- if (!param.isEmpty()) {
|
|
|
- extendInfoMap.put("acct_split_bunch", JSON.toJSONString(param));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return companyDivItem;
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public List<FsStoreAfterSalesExcelVO> selectFsStoreAfterSalesExcelListVO(FsStoreAfterSalesParam fsStoreAfterSales) {
|