|
@@ -12,6 +12,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
@@ -20,7 +21,11 @@ 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.poi.ExcelUtil;
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
|
|
+import com.fs.common.utils.spring.SpringUtils;
|
|
|
|
|
+import com.fs.company.domain.CompanyDivItem;
|
|
|
import com.fs.company.param.FsStoreStatisticsParam;
|
|
import com.fs.company.param.FsStoreStatisticsParam;
|
|
|
|
|
+import com.fs.company.service.ICompanyDivConfigService;
|
|
|
|
|
+import com.fs.company.service.ICompanyDivItemService;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.impl.CompanyServiceImpl;
|
|
import com.fs.company.service.impl.CompanyServiceImpl;
|
|
|
import com.fs.company.vo.FsStoreOrderStatisticsVO;
|
|
import com.fs.company.vo.FsStoreOrderStatisticsVO;
|
|
@@ -160,6 +165,9 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStoreOrderLogsService fsStoreOrderLogsService;
|
|
private IFsStoreOrderLogsService fsStoreOrderLogsService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyDivItemService companyDivItemService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询售后记录
|
|
* 查询售后记录
|
|
|
*
|
|
*
|
|
@@ -289,7 +297,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
|
//添加订单日志
|
|
//添加订单日志
|
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getValue(),
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getValue(),
|
|
|
- logs.getOperator()+" "+FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getDesc());
|
|
|
|
|
|
|
+ logs.getOperator() + " " + FsStoreOrderLogEnum.PLATFORM_REVIEW_SALES.getDesc());
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -318,7 +326,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
|
//添加订单日志
|
|
//添加订单日志
|
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getValue(),
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getValue(),
|
|
|
- logs.getOperator() + " " +FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getDesc());
|
|
|
|
|
|
|
+ logs.getOperator() + " " + FsStoreOrderLogEnum.PLATFORM_REVIEW_CANCEL.getDesc());
|
|
|
// FsStoreOrderLogs Logs = new FsStoreOrderLogs();
|
|
// FsStoreOrderLogs Logs = new FsStoreOrderLogs();
|
|
|
// Logs.setChangeMessage("已取消退款");
|
|
// Logs.setChangeMessage("已取消退款");
|
|
|
// Logs.setOrderId(order.getOrderId());
|
|
// Logs.setOrderId(order.getOrderId());
|
|
@@ -330,7 +338,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
or.setStatus(order.getOrderStatus());
|
|
or.setStatus(order.getOrderStatus());
|
|
|
fsStoreOrderMapper.updateFsStoreOrder(or);
|
|
fsStoreOrderMapper.updateFsStoreOrder(or);
|
|
|
//金牛订单取消售后审核不需要操作
|
|
//金牛订单取消售后审核不需要操作
|
|
|
- if(!CloudHostUtils.hasCloudHostName("金牛名医","康年堂")){
|
|
|
|
|
|
|
+ if (!CloudHostUtils.hasCloudHostName("金牛名医", "康年堂")) {
|
|
|
if (order.getOrderStatus() == 2) {
|
|
if (order.getOrderStatus() == 2) {
|
|
|
FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(order.getOrderId());
|
|
FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(order.getOrderId());
|
|
|
String newOrderSn = OrderCodeUtils.getOrderSn();
|
|
String newOrderSn = OrderCodeUtils.getOrderSn();
|
|
@@ -376,7 +384,6 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -402,7 +409,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
|
//添加订单日志
|
|
//添加订单日志
|
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getValue(),
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getValue(),
|
|
|
- logs.getOperator() + " " +FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getDesc());
|
|
|
|
|
|
|
+ logs.getOperator() + " " + FsStoreOrderLogEnum.FINANCE_REVIEW_SALES.getDesc());
|
|
|
//更改订单状态
|
|
//更改订单状态
|
|
|
FsStoreOrder or = new FsStoreOrder();
|
|
FsStoreOrder or = new FsStoreOrder();
|
|
|
or.setOrderId(order.getOrderId());
|
|
or.setOrderId(order.getOrderId());
|
|
@@ -464,7 +471,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
}
|
|
}
|
|
|
if (payments != null && payments.size() > 0) {
|
|
if (payments != null && payments.size() > 0) {
|
|
|
FsStorePayment payment = payments.get(0);
|
|
FsStorePayment payment = payments.get(0);
|
|
|
- if (reMoney.compareTo(payment.getPayMoney())>0) {
|
|
|
|
|
|
|
+ if (reMoney.compareTo(payment.getPayMoney()) > 0) {
|
|
|
return 0; //退款金额不能大于实际支付金额
|
|
return 0; //退款金额不能大于实际支付金额
|
|
|
}
|
|
}
|
|
|
String json = configService.selectConfigByKey("his.pay");
|
|
String json = configService.selectConfigByKey("his.pay");
|
|
@@ -550,6 +557,16 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
request.setReqSeqId("refund-" + payment.getPayCode());
|
|
request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
Map<String, Object> extendInfoMap = new HashMap<>();
|
|
Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
extendInfoMap.put("org_req_seq_id", orderType + "-" + payment.getPayCode());
|
|
extendInfoMap.put("org_req_seq_id", orderType + "-" + payment.getPayCode());
|
|
|
|
|
+
|
|
|
|
|
+ //处理分账退款
|
|
|
|
|
+ //1.判断是否是全额退款
|
|
|
|
|
+ CompanyDivItem companyDivItem = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ companyDivItem = doRefundDiv(fsStoreOrder, reMoney, payment, extendInfoMap);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("-----------------分账退款处理失败{}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
request.setExtendInfo(extendInfoMap);
|
|
request.setExtendInfo(extendInfoMap);
|
|
|
HuiFuRefundResult refund = huiFuService.refund(request);
|
|
HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
logger.info("订单退款返回结果:退款订单id:" + order.getOrderId() + refund);
|
|
logger.info("订单退款返回结果:退款订单id:" + order.getOrderId() + refund);
|
|
@@ -560,6 +577,15 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
paymentMap.setRefundMoney(payment.getPayMoney());
|
|
paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
|
|
+ try {
|
|
|
|
|
+ //处理分账退款明细表
|
|
|
|
|
+ if (companyDivItem !=null && companyDivItem.getId() != null) {
|
|
|
|
|
+ companyDivItem.setIsRefund(1);
|
|
|
|
|
+ companyDivItemService.updateCompanyDivItem(companyDivItem);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("-----------------分账退款明细处理失败{}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
throw new CustomException("退款请求失败" + refund.getResp_desc());
|
|
throw new CustomException("退款请求失败" + refund.getResp_desc());
|
|
|
}
|
|
}
|
|
@@ -576,17 +602,17 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
Integer erpType = sysConfig.getErpType();
|
|
Integer erpType = sysConfig.getErpType();
|
|
|
if (erpType == 1) {
|
|
if (erpType == 1) {
|
|
|
erpOrderService.refundUpdate(request);
|
|
erpOrderService.refundUpdate(request);
|
|
|
- }else if (erpType == 2) {
|
|
|
|
|
|
|
+ } else if (erpType == 2) {
|
|
|
//旺店通
|
|
//旺店通
|
|
|
wdtErpOrderService.refundUpdate(request);
|
|
wdtErpOrderService.refundUpdate(request);
|
|
|
} else if (erpType == 3) {
|
|
} else if (erpType == 3) {
|
|
|
//瀚智
|
|
//瀚智
|
|
|
hzOMSerpOrderService.refundUpdate(request);
|
|
hzOMSerpOrderService.refundUpdate(request);
|
|
|
- } else if (erpType == 4) {
|
|
|
|
|
|
|
+ } else if (erpType == 4) {
|
|
|
dfOrderService.refundUpdate(request);
|
|
dfOrderService.refundUpdate(request);
|
|
|
- }else if(erpType == 5){
|
|
|
|
|
|
|
+ } else if (erpType == 5) {
|
|
|
jSTOrderService.refundUpdate(request);
|
|
jSTOrderService.refundUpdate(request);
|
|
|
- }else if(erpType == 6){
|
|
|
|
|
|
|
+ } else if (erpType == 6) {
|
|
|
k9OrderService.refundUpdate(request);
|
|
k9OrderService.refundUpdate(request);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -603,6 +629,87 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
return i;
|
|
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
|
|
@Override
|
|
|
public List<FsStoreAfterSalesExcelVO> selectFsStoreAfterSalesExcelListVO(FsStoreAfterSalesParam fsStoreAfterSales) {
|
|
public List<FsStoreAfterSalesExcelVO> selectFsStoreAfterSalesExcelListVO(FsStoreAfterSalesParam fsStoreAfterSales) {
|
|
|
return fsStoreAfterSalesMapper.selectFsStoreAfterSalesExcelListVO(fsStoreAfterSales);
|
|
return fsStoreAfterSalesMapper.selectFsStoreAfterSalesExcelListVO(fsStoreAfterSales);
|
|
@@ -743,17 +850,17 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
Integer erpType = sysConfig.getErpType();
|
|
Integer erpType = sysConfig.getErpType();
|
|
|
BaseResponse response = null;
|
|
BaseResponse response = null;
|
|
|
if (erpType == 1) {
|
|
if (erpType == 1) {
|
|
|
- response = erpOrderService.refundUpdate(request);
|
|
|
|
|
- }else if (erpType == 2) {
|
|
|
|
|
|
|
+ response = erpOrderService.refundUpdate(request);
|
|
|
|
|
+ } else if (erpType == 2) {
|
|
|
//旺店通
|
|
//旺店通
|
|
|
response = wdtErpOrderService.refundUpdate(request);
|
|
response = wdtErpOrderService.refundUpdate(request);
|
|
|
- } else if (erpType == 3) {
|
|
|
|
|
|
|
+ } else if (erpType == 3) {
|
|
|
//瀚智
|
|
//瀚智
|
|
|
- response = hzOMSerpOrderService.refundUpdate(request);
|
|
|
|
|
|
|
+ response = hzOMSerpOrderService.refundUpdate(request);
|
|
|
} else if (erpType == 4) {
|
|
} else if (erpType == 4) {
|
|
|
- response = dfOrderService.refundUpdate(request);
|
|
|
|
|
- }else if(erpType == 5){
|
|
|
|
|
- response=jSTOrderService.refundUpdate(request);
|
|
|
|
|
|
|
+ response = dfOrderService.refundUpdate(request);
|
|
|
|
|
+ } else if (erpType == 5) {
|
|
|
|
|
+ response = jSTOrderService.refundUpdate(request);
|
|
|
}
|
|
}
|
|
|
if (response.getSuccess()) {
|
|
if (response.getSuccess()) {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
@@ -898,7 +1005,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
|
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
|
|
|
//添加订单日志
|
|
//添加订单日志
|
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getValue(),
|
|
fsStoreOrderLogsService.create(order.getOrderId(), FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getValue(),
|
|
|
- logs.getOperator() + " " +FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getDesc());
|
|
|
|
|
|
|
+ logs.getOperator() + " " + FsStoreOrderLogEnum.WAREHOUSE_REVIEW_SALES.getDesc());
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|