|
@@ -1,20 +1,23 @@
|
|
|
package com.fs.his.task;
|
|
package com.fs.his.task;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import cn.hutool.core.date.DateUnit;
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.fs.common.exception.CustomException;
|
|
|
|
|
+import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.fastGpt.domain.FastgptChatVoiceHomo;
|
|
import com.fs.fastGpt.domain.FastgptChatVoiceHomo;
|
|
|
import com.fs.fastGpt.mapper.FastgptChatVoiceHomoMapper;
|
|
import com.fs.fastGpt.mapper.FastgptChatVoiceHomoMapper;
|
|
|
import com.fs.fastgptApi.util.AudioUtils;
|
|
import com.fs.fastgptApi.util.AudioUtils;
|
|
|
import com.fs.fastgptApi.vo.AudioVO;
|
|
import com.fs.fastgptApi.vo.AudioVO;
|
|
|
import com.fs.hisStore.param.FsStoreOrderExpressEditParam;
|
|
import com.fs.hisStore.param.FsStoreOrderExpressEditParam;
|
|
|
import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
import com.fs.hisStore.service.IFsStoreOrderScrmService;
|
|
|
|
|
+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.sop.domain.QwSopTempVoice;
|
|
import com.fs.sop.domain.QwSopTempVoice;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baidu.dev2.api.sdk.payment.api.PaymentService;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.service.impl.SmsServiceImpl;
|
|
import com.fs.common.service.impl.SmsServiceImpl;
|
|
@@ -33,9 +36,7 @@ import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
|
import com.fs.course.service.ITencentCloudCosService;
|
|
import com.fs.course.service.ITencentCloudCosService;
|
|
|
import com.fs.erp.domain.ErpDeliverys;
|
|
import com.fs.erp.domain.ErpDeliverys;
|
|
|
-import com.fs.erp.domain.ErpOrder;
|
|
|
|
|
import com.fs.erp.domain.ErpOrderQuery;
|
|
import com.fs.erp.domain.ErpOrderQuery;
|
|
|
-import com.fs.erp.domain.FsErpFinishPush;
|
|
|
|
|
import com.fs.erp.dto.ErpOrderQueryRequert;
|
|
import com.fs.erp.dto.ErpOrderQueryRequert;
|
|
|
import com.fs.erp.dto.ErpOrderQueryResponse;
|
|
import com.fs.erp.dto.ErpOrderQueryResponse;
|
|
|
import com.fs.erp.dto.OrderQueryResponseDTO;
|
|
import com.fs.erp.dto.OrderQueryResponseDTO;
|
|
@@ -87,11 +88,11 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.OffsetDateTime;
|
|
import java.time.OffsetDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -236,6 +237,18 @@ public class Task {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IQwGroupMsgService groupMsgService;
|
|
private IQwGroupMsgService groupMsgService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsStorePaymentMapper storePaymentMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HuiFuService huiFuService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsShareAmountDetailService amountDetailService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsAmountsShareMerchantService amountShareMerchantService;
|
|
|
|
|
+
|
|
|
public static final String SOP_TEMP_VOICE_KEY = "sop:tempVoice";
|
|
public static final String SOP_TEMP_VOICE_KEY = "sop:tempVoice";
|
|
|
public void syncExpressToWx() {
|
|
public void syncExpressToWx() {
|
|
|
List<FsWxExpressTask> fsWxExpressTasks = fsWxExpressTaskMapper.selectPendingData();
|
|
List<FsWxExpressTask> fsWxExpressTasks = fsWxExpressTaskMapper.selectPendingData();
|
|
@@ -2064,4 +2077,93 @@ public class Task {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void shareAmount(){
|
|
|
|
|
+ List<FsStorePayment> payments = storePaymentMapper.selectSharePaymentList();
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(payments)) {
|
|
|
|
|
+ for (FsStorePayment storePayment : payments) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ logger.info("分账订单号:{}",storePayment.getBusinessCode());
|
|
|
|
|
+ FsStoreOrder order = fsStoreOrderService.selectFsStoreOrderByOrderCode(storePayment.getBusinessCode());
|
|
|
|
|
+ BigDecimal divAmount = null;
|
|
|
|
|
+ //默认全部进入中医院
|
|
|
|
|
+ BigDecimal ysyAmount = storePayment.getPayMoney();
|
|
|
|
|
+ HuifuOrderConfirm confirm = new HuifuOrderConfirm();
|
|
|
|
|
+
|
|
|
|
|
+ if (order != null) {
|
|
|
|
|
+ //获取聚水潭分账商户
|
|
|
|
|
+ FsAmountsShareMerchant queryMerchant = new FsAmountsShareMerchant();
|
|
|
|
|
+ queryMerchant.setType(order.getErpType());
|
|
|
|
|
+ List<FsAmountsShareMerchant> merchants = amountShareMerchantService.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());
|
|
|
|
|
+ //添加分账明细
|
|
|
|
|
+ amountDetailService.insertFsShareAmountDetail(shareAmountDetail);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new CustomException("订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ logger.info("开始确认订单分账..........");
|
|
|
|
|
+ confirm.setYsyDivAmt(ysyAmount);
|
|
|
|
|
+ confirm.setDivAmt(divAmount);
|
|
|
|
|
+ confirm.setOrgReqSeqId(storePayment.getShareCode()+"-"+storePayment.getPayCode());
|
|
|
|
|
+ confirm.setOrgReqDate(DateTools.getCurrentDateYYYYMMDD());
|
|
|
|
|
+ String orderCode = OrderCodeUtils.getOrderSn();
|
|
|
|
|
+ if (StringUtils.isEmpty(orderCode)) {
|
|
|
|
|
+ throw new CustomException("订单生成失败,请重试");
|
|
|
|
|
+ }
|
|
|
|
|
+ //中医院商户号
|
|
|
|
|
+ confirm.setMainHfId("6666000175632107");
|
|
|
|
|
+ confirm.setReqSeqId(orderCode);
|
|
|
|
|
+ confirm.setTotalAmount(storePayment.getPayMoney());
|
|
|
|
|
+ HuifuOrderConfirmResult result = huiFuService.confirmOrder(confirm);
|
|
|
|
|
+ logger.info("确认订单分账结束..........");
|
|
|
|
|
+ if (result != null && result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
|
|
+ //分账标识
|
|
|
|
|
+ paymentMap.setPaymentId(storePayment.getPaymentId());
|
|
|
|
|
+ paymentMap.setShareStatus(1);
|
|
|
|
|
+ paymentMap.setShareDate(result.getReq_date());
|
|
|
|
|
+ paymentMap.setShareCode(result.getReq_seq_id());
|
|
|
|
|
+ logger.info("更新支付记录");
|
|
|
|
|
+ storePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
|
|
+
|
|
|
|
|
+ FsStoreOrder orderMap = new FsStoreOrder();
|
|
|
|
|
+ orderMap.setOrderId(order.getOrderId());
|
|
|
|
|
+ orderMap.setZyyDivAmount(result.getYsyAmount());
|
|
|
|
|
+ orderMap.setZyyHuifuId(result.getZyzHuifuId());
|
|
|
|
|
+ if (result.getOtherAmount() != null && result.getOtherHuifuId() != null) {
|
|
|
|
|
+ orderMap.setDivHuifuId(result.getOtherHuifuId());
|
|
|
|
|
+ orderMap.setDivAmount(result.getOtherAmount());
|
|
|
|
|
+ }
|
|
|
|
|
+ //更新订单
|
|
|
|
|
+ fsStoreOrderService.updateFsStoreOrder(orderMap);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new CustomException("交易确认订单失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.info("分账失败,订单号:{},原因:{}", storePayment.getBusinessCode(),e.getMessage());
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|