|
|
@@ -63,7 +63,9 @@ import com.fs.hisapi.param.RecipeDetailParam;
|
|
|
import com.fs.hisapi.service.HisApiService;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
+import com.fs.huifuPay.domain.HuifuOrderConfirm;
|
|
|
import com.fs.huifuPay.domain.HuifuOrderConfirmResult;
|
|
|
+import com.fs.huifuPay.sdk.opps.core.utils.DateTools;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.im.dto.*;
|
|
|
import com.fs.im.service.IImService;
|
|
|
@@ -323,6 +325,12 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
@Autowired
|
|
|
private FsUserInformationCollectionScheduleMapper scheduleMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFsShareAmountDetailService shareAmountDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsAmountsShareMerchantService amountsShareMerchantService;
|
|
|
+
|
|
|
//ERP 类型到服务的映射
|
|
|
private Map<Integer, IErpOrderService> erpServiceMap;
|
|
|
@PostConstruct
|
|
|
@@ -903,7 +911,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
order.setZyyHuifuId(result.getZyzHuifuId());
|
|
|
if (result.getOtherAmount() != null && result.getOtherHuifuId() != null) {
|
|
|
order.setDivHuifuId(result.getOtherHuifuId());
|
|
|
- order.setZyyDivAmount(result.getOtherAmount());
|
|
|
+ order.setDivAmount(result.getOtherAmount());
|
|
|
}
|
|
|
}
|
|
|
Long prescribeId =null;
|
|
|
@@ -1713,18 +1721,6 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
if (storePayment != null) {
|
|
|
if (storePayment.getStatus().equals(0)) {
|
|
|
|
|
|
-// log.info("开始确认订单分账..........");
|
|
|
-// HuifuOrderConfirm confirm = new HuifuOrderConfirm();
|
|
|
-// confirm.setOrgReqSeqId("store-"+payCode);
|
|
|
-// confirm.setOrgReqDate(DateTools.getCurrentDateYYYYMMDD());
|
|
|
-// String orderSn = OrderCodeUtils.getOrderSn();
|
|
|
-// if (StringUtils.isEmpty(orderSn)) {
|
|
|
-// return R.error("订单生成失败,请重试");
|
|
|
-// }
|
|
|
-// confirm.setReqSeqId(orderSn);
|
|
|
-// confirm.setTotalAmount(storePayment.getPayMoney());
|
|
|
-// result = huiFuService.confirmOrder(confirm);
|
|
|
-// log.info("确认订单分账结束..........");
|
|
|
|
|
|
log.info(payCode + "待支付");
|
|
|
FsStorePayment paymentMap = new FsStorePayment();
|
|
|
@@ -1734,16 +1730,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
paymentMap.setTradeNo(tradeNo);
|
|
|
paymentMap.setBankSerialNo(bankSerialNo);
|
|
|
paymentMap.setBankTransactionId(bankTransactionId);
|
|
|
-// if (result != null && result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
-// //分账标识
|
|
|
-// paymentMap.setShareStatus(1);
|
|
|
-// paymentMap.setIsShare(1);
|
|
|
-// paymentMap.setShareDate(result.getReq_date());
|
|
|
-// paymentMap.setShareCode(result.getReq_seq_id());
|
|
|
-// } else {
|
|
|
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
-// throw new CustomException("交易确认订单失败");
|
|
|
-// }
|
|
|
+
|
|
|
|
|
|
if (payType.equals(PayType.WECHAT_MINI_PROGRAM_PAYMENT.getCode())) {
|
|
|
paymentMap.setPayTypeCode(PayType.WECHAT_MINI_PROGRAM_PAYMENT.name());
|
|
|
@@ -1757,9 +1744,67 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
paymentMap.setBankSerialNo(orderResult.getBankOrderId());
|
|
|
paymentMap.setBankTransactionId(orderResult.getBankTrxId());
|
|
|
}
|
|
|
+ order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(Long.parseLong(storePayment.getBusinessId()));
|
|
|
+ log.info("订单数据{}", order);
|
|
|
+ BigDecimal divAmount = null;
|
|
|
+ //默认全部进入中医院
|
|
|
+ BigDecimal ysyAmount = storePayment.getPayMoney();
|
|
|
+ HuifuOrderConfirm confirm = new HuifuOrderConfirm();
|
|
|
+ //获取聚水潭分账商户
|
|
|
+ FsAmountsShareMerchant queryMerchant = new FsAmountsShareMerchant();
|
|
|
+ queryMerchant.setType(order.getErpType());
|
|
|
+ List<FsAmountsShareMerchant> merchants = amountsShareMerchantService.selectFsAmountsShareMerchantList(queryMerchant);
|
|
|
+
|
|
|
+ //支付金额大于等于0.1的进行分账 最低分账金额为0.1
|
|
|
+ if (storePayment.getPayMoney().compareTo(new BigDecimal("0.1")) > -1) {
|
|
|
+ if (order.getErpType() != null && order.getErpType() == 1) {
|
|
|
+ if (merchants != null && !merchants.isEmpty()) {
|
|
|
+ int i = (int) (Math.random() * merchants.size());
|
|
|
+ FsAmountsShareMerchant merchant = merchants.get(i);
|
|
|
+ //分账商户号
|
|
|
+ confirm.setDivHfId(merchant.getMerchantAccount());
|
|
|
+ //益寿缘分账金额
|
|
|
+ ysyAmount = storePayment.getPayMoney().multiply(new BigDecimal("0.2"));
|
|
|
+ //其它商户分账金额
|
|
|
+ divAmount = storePayment.getPayMoney().subtract(ysyAmount);
|
|
|
+ //分账明细数据
|
|
|
+ FsShareAmountDetail shareAmountDetail = new FsShareAmountDetail();
|
|
|
+ shareAmountDetail.setShareAmount(divAmount);
|
|
|
+ shareAmountDetail.setMerchantId(merchant.getId());
|
|
|
+ shareAmountDetail.setOrderCode(order.getOrderCode());
|
|
|
+ shareAmountDetail.setOrderId(order.getOrderId());
|
|
|
+ //添加分账明细
|
|
|
+ shareAmountDetailService.insertFsShareAmountDetail(shareAmountDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("开始确认订单分账..........");
|
|
|
+ confirm.setYsyDivAmt(ysyAmount);
|
|
|
+ confirm.setDivAmt(divAmount);
|
|
|
+ confirm.setOrgReqSeqId("store-"+payCode);
|
|
|
+ confirm.setOrgReqDate(DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ String orderSn = OrderCodeUtils.getOrderSn();
|
|
|
+ if (StringUtils.isEmpty(orderSn)) {
|
|
|
+ return R.error("订单生成失败,请重试");
|
|
|
+ }
|
|
|
+ //中医院商户号
|
|
|
+ confirm.setMainHfId("6666000175632107");
|
|
|
+ confirm.setReqSeqId(orderSn);
|
|
|
+ confirm.setTotalAmount(storePayment.getPayMoney());
|
|
|
+ result = huiFuService.confirmOrder(confirm);
|
|
|
+ log.info("确认订单分账结束..........");
|
|
|
+ if (result != null && result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
+ //分账标识
|
|
|
+ paymentMap.setShareStatus(1);
|
|
|
+ paymentMap.setIsShare(1);
|
|
|
+ paymentMap.setShareDate(result.getReq_date());
|
|
|
+ paymentMap.setShareCode(result.getReq_seq_id());
|
|
|
+ } else {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ throw new CustomException("交易确认订单失败");
|
|
|
+ }
|
|
|
fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
log.info(payCode + "已支付");
|
|
|
- order = fsStoreOrderMapper.selectFsStoreOrderByOrderId(Long.parseLong(storePayment.getBusinessId()));
|
|
|
}
|
|
|
} else {
|
|
|
log.info(payCode + "支付单号不存在");
|
|
|
@@ -1805,19 +1850,20 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
|
|
|
storeOrder.setPayTime(new Date());
|
|
|
|
|
|
//确认订单返回结果
|
|
|
-// log.info("确认交易返回数据{}========>",result);
|
|
|
-// if (result != null && result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
-// storeOrder.setZyyDivAmount(result.getYsyAmount());
|
|
|
-// storeOrder.setZyyHuifuId(result.getZyzHuifuId());
|
|
|
-// if (result.getOtherAmount() != null && result.getOtherHuifuId() != null) {
|
|
|
-// storeOrder.setDivHuifuId(result.getOtherHuifuId());
|
|
|
-// storeOrder.setZyyDivAmount(result.getOtherAmount());
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
-// throw new CustomException("交易确认订单失败");
|
|
|
-// }
|
|
|
-
|
|
|
+ log.info("确认交易返回数据{}========>",result);
|
|
|
+ if (result != null ) {
|
|
|
+ if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
+ storeOrder.setZyyDivAmount(result.getYsyAmount());
|
|
|
+ storeOrder.setZyyHuifuId(result.getZyzHuifuId());
|
|
|
+ if (result.getOtherAmount() != null && result.getOtherHuifuId() != null) {
|
|
|
+ storeOrder.setDivHuifuId(result.getOtherHuifuId());
|
|
|
+ storeOrder.setDivAmount(result.getOtherAmount());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ throw new CustomException("交易确认订单失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
|
|
|
try {
|
|
|
//更新用户下单次数(获取阈值,当订单总价大于等于阈值,则下单次数+1)
|