|
|
@@ -11,10 +11,8 @@ import com.fs.company.service.ICompanyDivConfigService;
|
|
|
import com.fs.company.service.ICompanyDivItemService;
|
|
|
import com.fs.company.service.impl.CompanyDivConfigServiceImpl;
|
|
|
import com.fs.company.vo.CompanyDivConfigVo;
|
|
|
-import com.fs.his.domain.FsPackageOrder;
|
|
|
-import com.fs.his.domain.FsPayConfig;
|
|
|
-import com.fs.his.domain.FsStoreOrder;
|
|
|
-import com.fs.his.domain.FsStorePayment;
|
|
|
+import com.fs.his.domain.*;
|
|
|
+import com.fs.his.mapper.FsHfpayConfigMapper;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
|
@@ -32,32 +30,48 @@ public class HuiFuUtils {
|
|
|
private static ICompanyDivItemService companyDivItemService = SpringUtils.getBean(ICompanyDivItemService.class);
|
|
|
|
|
|
/**
|
|
|
- * 处理分账
|
|
|
+ * 处理分账
|
|
|
+ *
|
|
|
* @param huiFuCreateOrder
|
|
|
* @param companyId
|
|
|
*/
|
|
|
public static void doDiv(HuiFuCreateOrder huiFuCreateOrder, Long companyId) throws Exception {
|
|
|
//默认汇付账户
|
|
|
- SysConfigMapper sysConfigMapper= SpringUtils.getBean(SysConfigMapper.class);
|
|
|
+ SysConfigMapper sysConfigMapper = SpringUtils.getBean(SysConfigMapper.class);
|
|
|
SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
|
|
|
FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
|
|
|
+
|
|
|
+ // 根据appId动态获取主商户号
|
|
|
String defaultHuifuId = fsPayConfig.getHuifuId();
|
|
|
+ if (StringUtils.isNotBlank(huiFuCreateOrder.getAppId())) {
|
|
|
+ // 如果有appId,查询对应的汇付支付配置
|
|
|
+ FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
|
|
|
+ FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(huiFuCreateOrder.getAppId());
|
|
|
+ if (fsHfpayConfig != null && StringUtils.isNotBlank(fsHfpayConfig.getHuifuId())) {
|
|
|
+ defaultHuifuId = fsHfpayConfig.getHuifuId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("6666000184032670".equals(defaultHuifuId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
//查询是否开启分账
|
|
|
- if (companyId !=null){
|
|
|
+ if (companyId != null) {
|
|
|
|
|
|
CompanyDivConfigVo configVo = companyDivConfigService.selectCompanyDivConfigByCompanyId(companyId);
|
|
|
- if (configVo != null){
|
|
|
+ if (configVo != null) {
|
|
|
Integer divFlag = configVo.getDivFlag();
|
|
|
- if (divFlag != null && divFlag == 1){
|
|
|
+ if (divFlag != null && divFlag == 1) {
|
|
|
//开启分账
|
|
|
//汇付传参
|
|
|
Map<String, Object> acctSplitBunchMap = new HashMap<>();
|
|
|
- List<Map<String,Object>> acctInfos = new ArrayList();
|
|
|
+ List<Map<String, Object>> acctInfos = new ArrayList();
|
|
|
List<CompanyAcctInfo> acctInfoVos = configVo.getAcctInfos();
|
|
|
- if (acctInfoVos != null && !acctInfoVos.isEmpty()){
|
|
|
+ if (acctInfoVos != null && !acctInfoVos.isEmpty()) {
|
|
|
String delayAcctFlag = configVo.getDelayAcctFlag();
|
|
|
String percentageFlag = configVo.getPercentageFlag();
|
|
|
- if (StringUtils.isNotBlank(delayAcctFlag) && delayAcctFlag.equals("N")){
|
|
|
+ if (StringUtils.isNotBlank(delayAcctFlag) && delayAcctFlag.equals("N")) {
|
|
|
//实时分账
|
|
|
if (StringUtils.isNotBlank(percentageFlag) && percentageFlag.equals("Y")){
|
|
|
acctSplitBunchMap.put("percentage_flag","Y");
|
|
|
@@ -90,6 +104,13 @@ public class HuiFuUtils {
|
|
|
defaultAccount.put("percentage_div", String.format("%.2f", 100f - total));
|
|
|
defaultAccount.put("huifu_id", defaultHuifuId);
|
|
|
acctInfos.add(defaultAccount);
|
|
|
+ } else {
|
|
|
+ // 即使没有其他分账接收方,也要包含主商户号,分账比例为0
|
|
|
+ acctInfos = new ArrayList<>();
|
|
|
+ Map<String, Object> defaultAccount = new HashMap<>();
|
|
|
+ defaultAccount.put("percentage_div", "0.00");
|
|
|
+ defaultAccount.put("huifu_id", defaultHuifuId);
|
|
|
+ acctInfos.add(defaultAccount);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -126,6 +147,13 @@ public class HuiFuUtils {
|
|
|
defaultAccount.put("huifu_id", defaultHuifuId);
|
|
|
acctInfos.add(defaultAccount);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 即使没有其他分账接收方,也要包含主商户号,分账金额为0
|
|
|
+ acctInfos = new ArrayList<>();
|
|
|
+ Map<String, Object> defaultAccount = new HashMap<>();
|
|
|
+ defaultAccount.put("div_amt", "0.00");
|
|
|
+ defaultAccount.put("huifu_id", defaultHuifuId);
|
|
|
+ acctInfos.add(defaultAccount);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -148,12 +176,18 @@ public class HuiFuUtils {
|
|
|
|
|
|
public static void saveDivItem(HuiFuCreateOrder o, String orderCode, String payCode) {
|
|
|
CompanyDivItem companyDivItem = new CompanyDivItem();
|
|
|
- if (StringUtils.isNotBlank(o.getAcctSplitBunch())){
|
|
|
+ if (StringUtils.isNotBlank(o.getAcctSplitBunch())) {
|
|
|
companyDivItem.setOrderCode(orderCode);
|
|
|
companyDivItem.setPayCode(payCode);
|
|
|
companyDivItem.setDetail(o.getAcctSplitBunch());
|
|
|
companyDivItem.setIsRefund(0); //支付
|
|
|
- companyDivItem.setIsDelay(0); //延迟分账
|
|
|
+ if (StringUtils.isNotBlank(o.getDelayAcctFlag()) && o.getDelayAcctFlag().equals("Y")) {
|
|
|
+ companyDivItem.setIsDelay(1); //延迟分账
|
|
|
+
|
|
|
+ } else {
|
|
|
+ companyDivItem.setIsDelay(0);
|
|
|
+ companyDivItem.setDelayStatus(0);
|
|
|
+ }
|
|
|
companyDivItemService.insertCompanyDivItem(companyDivItem);
|
|
|
}
|
|
|
}
|