Pārlūkot izejas kodu

鸿森堂--直播订单分账,分账明细,分账退款

wjj 3 nedēļas atpakaļ
vecāks
revīzija
b7bac53bcf

+ 1 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -2224,6 +2224,7 @@ public class Task {
                         shareAmountDetail.setMerchantId(fsSubMerchant.getId());
                         shareAmountDetail.setOrderCode(order.getOrderSn());
                         shareAmountDetail.setOrderId(order.getOrderId());
+                        shareAmountDetail.setOrderType(1);//互医订单
                         //添加分账明细
                         shareAmountDetailService.insertFsShareAmountDetail(shareAmountDetail);
                     }

+ 158 - 7
fs-admin/src/main/java/com/fs/hisStore/task/MallStoreTask.java

@@ -1,13 +1,18 @@
 package com.fs.hisStore.task;
 
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
+import com.fs.company.domain.Company;
+import com.fs.company.mapper.CompanyMapper;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.vo.RedPacketMoneyVO;
+import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.erp.domain.ErpDeliverys;
 import com.fs.erp.domain.ErpGoods;
@@ -19,26 +24,27 @@ import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.service.IErpGoodsService;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.his.config.FsSysConfig;
-import com.fs.his.domain.FsStoreProductAttrValue;
+import com.fs.his.domain.*;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.mapper.FsStoreProductAttrValueMapper;
+import com.fs.his.mapper.FsSubMerchantMapper;
 import com.fs.his.service.IFsExpressService;
+import com.fs.his.service.IFsShareAmountDetailService;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.dto.DateComparisonConfigDTO;
 import com.fs.hisStore.enums.ShipperCodeEnum;
 import com.fs.his.enums.FsUserIntegralLogTypeEnum;
-import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
-import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
-import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
-import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
-import com.fs.hisStore.mapper.FsUserScrmMapper;
-import com.fs.hisStore.mapper.FsUserIntegralLogsScrmMapper;
+import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
+import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
+import com.fs.huifuPay.domain.HuifuOrderConfirm;
+import com.fs.huifuPay.domain.HuifuOrderConfirmResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
+import com.fs.huifuPay.sdk.opps.core.utils.DateTools;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrderPayment;
@@ -184,6 +190,21 @@ public class MallStoreTask
     @Autowired
     private HuiFuService huiFuService;
 
+    @Autowired
+    private FsStoreProductScrmMapper fsStoreProductScrmMapper;
+
+    @Autowired
+    CompanyMapper companyMapper;
+
+    @Autowired
+    private FsSubMerchantMapper fsSubMerchantMapper;
+
+    @Autowired
+    private IFsShareAmountDetailService shareAmountDetailService;
+
+    @Autowired
+    private FsStoreOrderItemScrmMapper fsStoreOrderItemScrmMapper;
+
     // 订单银行回调数据丢失补偿
     public void recoveryBankOrder() {
         // 查询出来最近30分钟的订单 待支付 未退款
@@ -990,4 +1011,134 @@ public class MallStoreTask
         log.info("购物积分发放完成,本次发放{}笔订单", count);
     }
 
+    public void shareAmount(){
+        List<FsStorePaymentScrm> payments = fsStorePaymentMapper.selectSharePaymentList();
+        if (CollectionUtil.isEmpty(payments)) return;
+        log.info("开始处理分享金额");
+        for (FsStorePaymentScrm storePayment : payments) {
+            try {
+                Thread.sleep(1000);
+                //查询订单确认金额
+                V2TradePaymentScanpayQueryRequest request = new V2TradePaymentScanpayQueryRequest();
+                request.setOrgReqDate(DateTools.formatYYYYMMDD(storePayment.getPayTime()));
+                request.setOrgReqSeqId(storePayment.getShareCode()+"-"+storePayment.getPayCode());
+                request.setAppId(storePayment.getAppId());
+                HuiFuQueryOrderResult queryOrderResult = huiFuService.queryOrder(request);
+                log.info("汇付订单查询返回:{}" , queryOrderResult);
+                if (queryOrderResult != null && "00000000".equals(queryOrderResult.getResp_code())) {
+                    //未开启延迟支付的跳出当前循环 执行下次循环
+                    if (queryOrderResult.getDelay_acct_flag().equals("N")) {
+                        FsStorePaymentScrm mapPayment = new FsStorePaymentScrm();
+                        mapPayment.setPaymentId(storePayment.getPaymentId());
+                        mapPayment.setIsShare(0);
+                        fsStorePaymentService.updateFsStorePayment(mapPayment);
+                        continue;
+                    }
+                    log.info("直播分账订单号:{}",storePayment.getOrderId());
+
+                    //待确认金额
+                    BigDecimal unConfirmAmt = new BigDecimal(queryOrderResult.getUnconfirm_amt());
+                    //分账金额
+                    BigDecimal divAmount = null;
+                    //默认全部进入收款主账户
+                    BigDecimal mainAmount = unConfirmAmt;
+
+
+                    FsSubMerchant fsSubMerchant = null;
+                    FsStoreOrderScrm order = null;
+
+                    //是否分账到合作人
+                    boolean isDiv = false;
+                    HuifuOrderConfirm confirm = new HuifuOrderConfirm();
+                    confirm.setAppId(storePayment.getAppId());
+
+                    //支付金额大于等于0.1的进行分账 最低分账金额为0.1
+                    if (storePayment.getPayMoney().compareTo(new BigDecimal("0.1")) > -1) {
+                        //分账订单
+                        order = fsStoreOrderMapper.selectFsStoreOrderById(storePayment.getOrderId());
+                        if (order != null &&  order.getCompanyId() != null) {
+                            List<FsStoreOrderItemVO> itemVOS = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemListByOrderId(order.getId());
+                            if (CollectionUtil.isNotEmpty(itemVOS) && itemVOS.size() == 1) {
+                                FsStoreProductScrm productScrm = fsStoreProductScrmMapper.selectFsStoreProductById(itemVOS.get(0).getProductId());
+                                //公司信息
+                                Company company = companyMapper.selectCompanyById(order.getCompanyId());
+                                //分账比列大于0且公司有分账商户
+                                if (productScrm != null && (productScrm.getShareRate() != null && productScrm.getShareRate() > 0)
+                                        && company != null && company.getSubMerchantId() != null) {
+                                    //分账商户
+                                    fsSubMerchant = fsSubMerchantMapper.selectFsSubMerchantById(company.getSubMerchantId());
+                                    if (fsSubMerchant != null && fsSubMerchant.getMerchantNo() != null) {
+                                        //金额全部进入分账商户 分账比列为100
+                                        if (productScrm.getShareRate() == 100) {
+                                            divAmount = unConfirmAmt;
+                                            mainAmount = BigDecimal.ZERO;
+                                        } else {
+                                            //金额进行分账
+                                            divAmount = unConfirmAmt.multiply(BigDecimal.valueOf(productScrm.getShareRate())).divide(new BigDecimal(100));
+                                            mainAmount = unConfirmAmt.subtract(divAmount);
+                                        }
+                                        isDiv = true;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    log.info("开始确认订单分账..........");
+                    String orderCode = OrderCodeUtils.getOrderSn();
+                    if (StringUtils.isEmpty(orderCode)) {
+                        throw new CustomException("订单生成失败,请重试");
+                    }
+                    confirm.setReqSeqId(orderCode);
+                    if (isDiv) {
+                        //合作人分账金额和商户号
+                        confirm.setDivAmt(divAmount);
+                        confirm.setDivHfId(fsSubMerchant.getMerchantNo());
+                        //分账明细数据
+                        FsShareAmountDetail shareAmountDetail = new FsShareAmountDetail();
+                        shareAmountDetail.setShareAmount(divAmount);
+                        shareAmountDetail.setMerchantId(fsSubMerchant.getId());
+                        shareAmountDetail.setOrderCode(order.getOrderCode());
+                        shareAmountDetail.setOrderId(order.getId());
+                        shareAmountDetail.setOrderType(2);
+                        //添加分账明细
+                        shareAmountDetailService.insertFsShareAmountDetail(shareAmountDetail);
+                    }
+                    confirm.setMainDivAmt(mainAmount);
+                    confirm.setOrgReqDate(queryOrderResult.getOrg_req_date());
+                    confirm.setOrgReqSeqId(queryOrderResult.getOrg_req_seq_id());
+                    confirm.setMainHfId(queryOrderResult.getHuifu_id());
+                    confirm.setTotalAmount(storePayment.getPayMoney());
+
+                    //执行分账
+                    HuifuOrderConfirmResult result = huiFuService.confirmOrder(confirm);
+                    if (result != null && result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
+                        log.info("分账成功,订单号:{}",storePayment.getOrderId());
+                        FsStorePaymentScrm mapPayment = new FsStorePaymentScrm();
+                        //分账标识
+                        mapPayment.setPaymentId(storePayment.getPaymentId());
+                        mapPayment.setShareStatus(1);
+                        mapPayment.setShareDate(result.getReq_date());
+                        mapPayment.setShareCode(result.getReq_seq_id());
+                        log.info("更新支付记录");
+                        fsStorePaymentMapper.updateFsStorePayment(mapPayment);
+                    } else {
+                        throw new CustomException("直播订单分账失败");
+                    }
+                } else {
+                    if (queryOrderResult != null) {
+                        throw new CustomException(queryOrderResult.getResp_desc());
+                    }
+                }
+            } catch (Exception e) {
+                FsStorePaymentScrm mapPayment = new FsStorePaymentScrm();
+                //分账标识
+                mapPayment.setPaymentId(storePayment.getPaymentId());
+                mapPayment.setShareStatus(1);
+                mapPayment.setShareCode(e.getMessage());
+                fsStorePaymentMapper.updateFsStorePayment(mapPayment);
+                log.info("分账失败,订单号:{},原因:{}", storePayment.getBusinessCode(),e.getMessage());
+            }
+        }
+    }
+
 }

+ 2 - 2
fs-admin/src/main/java/com/fs/live/controller/LiveController.java

@@ -11,8 +11,8 @@ import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.vo.CompanyVO;
 import com.fs.framework.web.service.TokenService;
-import com.fs.hisStore.task.LiveTask;
-import com.fs.hisStore.task.MallStoreTask;
+//import com.fs.hisStore.task.LiveTask;
+//import com.fs.hisStore.task.MallStoreTask;
 import com.fs.live.domain.Live;
 import com.fs.live.service.ILiveService;
 import com.fs.live.vo.LiveListVo;

+ 5 - 0
fs-service/src/main/java/com/fs/his/domain/FsShareAmountDetail.java

@@ -36,5 +36,10 @@ public class FsShareAmountDetail extends BaseEntity{
     @Excel(name = "分账金额")
     private BigDecimal shareAmount;
 
+    /**
+     * 订单类型 1-互医订单 2-直播订单
+     */
+    private Integer orderType;
+
 
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStorePaymentScrm.java

@@ -107,4 +107,9 @@ public class FsStorePaymentScrm extends BaseEntity
     // 商户配置ID (用于多汇付支付/退款) 切换汇付后需要查询历史汇付配置信息退款
     private Long merConfigId;
 
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date shareTime;
+
+    private String shareDate;
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreProductScrm.java

@@ -371,6 +371,11 @@ public class FsStoreProductScrm extends BaseEntity
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date activityEndTime;
 
+    /**
+     * 分成比例(0-100)
+     */
+    private Integer shareRate;
+
     @TableField(exist = false)
     private String onShelfTime;
 

+ 6 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java

@@ -4,7 +4,6 @@ import java.util.List;
 import java.util.Map;
 
 import com.alibaba.fastjson.JSONObject;
-import com.fs.his.domain.FsStorePayment;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.param.FsStorePaymentParam;
 import com.fs.hisStore.param.FsStoreStatisticsParam;
@@ -398,4 +397,10 @@ public interface FsStorePaymentScrmMapper
      * @return 支付记录列表
      */
     List<FsStorePaymentScrm> selectByBankTransactionIds(@Param("bankTransactionIds") List<String> bankTransactionIds);
+
+    /**
+     * 今日分账
+     */
+    @Select("SELECT * FROM fs_store_payment_scrm WHERE `status` = 1 AND DATE(share_time) = CURDATE() AND is_share = 1 AND share_status = 0")
+    List<FsStorePaymentScrm> selectSharePaymentList();
 }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreProductAddEditParam.java

@@ -315,4 +315,9 @@ public class FsStoreProductAddEditParam implements Serializable
     private List<Long> tagIds;
 
     private String tagInfo;
+
+    /**
+     * 分成比例(0-100)
+     */
+    private Integer shareRate;
 }

+ 135 - 53
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -17,6 +17,7 @@ import com.fs.common.utils.CloudHostUtils;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.spring.SpringUtils;
+import com.fs.common.utils.uuid.IdUtils;
 import com.fs.company.service.ICompanyService;
 import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxPayProperties;
@@ -46,6 +47,8 @@ import com.fs.hisStore.enums.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
+import com.fs.huifuPay.domain.HuifuConfirmrefundResult;
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmrefundRequest;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
 import com.fs.live.vo.LiveOrderItemListUVO;
@@ -1145,12 +1148,29 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
                             return R.error("退款请求失败"+e.getErrCodeDes());
                         }
                     }else if (payment.getPayMode()!=null&&payment.getPayMode().equals("hf")){
-//
+                        if (CloudHostUtils.hasCloudHostName("鸿森堂")) {
+                            if (payment.getIsShare() == 1) {
+                                V2TradePaymentDelaytransConfirmrefundRequest confirmRefundRequest = new V2TradePaymentDelaytransConfirmrefundRequest();
+                                String orderCode = IdUtils.randomUUID();
+                                confirmRefundRequest.setReqSeqId(orderCode);
+                                confirmRefundRequest.setOrgReqSeqId(payment.getShareCode());
+                                confirmRefundRequest.setOrgReqDate(payment.getShareDate());
+                                HuifuConfirmrefundResult result = huiFuService.confirmRefund(confirmRefundRequest, payment.getAppId());
+                                if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
+                                    refund(payment.getAppId(),payType,payment,order,refundAmount);
+                                } else {
+                                    throw new CustomException("交易确认退款请求失败" + result.getResp_desc());
+                                }
+                            } else {
+                                refund(payment.getAppId(),payType,payment,order,refundAmount);
+                            }
+                        } else {
+
 //                        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
 //                        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
 
-                        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
-                        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+                            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
+                            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
 
 //                        String huifuId="";
 //                        FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
@@ -1172,26 +1192,26 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
 //                            }
 //                        }
 
-                        String huifuId="";
-                        if (payment.getAppId() != null) {
-                            if (merchantAppConfig == null){
-                                huifuId = fsPayConfig.getHuifuId();
-                            }else {
-                                huifuId = merchantAppConfig.getMerchantId();
+                            String huifuId="";
+                            if (payment.getAppId() != null) {
+                                if (merchantAppConfig == null){
+                                    huifuId = fsPayConfig.getHuifuId();
+                                }else {
+                                    huifuId = merchantAppConfig.getMerchantId();
+                                }
+                            } else {
+                                if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
+
+                                    huifuId = merchantAppConfig.getMerchantId();
+                                }else {
+                                    huifuId=fsPayConfig.getHuifuId();
+                                }
                             }
-                        } else {
-                            if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
 
-                                huifuId = merchantAppConfig.getMerchantId();
-                            }else {
-                                huifuId=fsPayConfig.getHuifuId();
-                            }
-                        }
-
-                        V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
-                        DecimalFormat df = new DecimalFormat("0.00");
-                        request.setOrgHfSeqId(payment.getTradeNo());
-                        request.setHuifuId(huifuId);
+                            V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
+                            DecimalFormat df = new DecimalFormat("0.00");
+                            request.setOrgHfSeqId(payment.getTradeNo());
+                            request.setHuifuId(huifuId);
 
 //                        request.setOrdAmt(df.format(refundAmount));
 //                        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
@@ -1200,42 +1220,42 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
 //                        extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
 //                        request.setAppId(payment.getAppId());
 
-                        Map<String, Object> extendInfoMap = new HashMap<>();
-                        if (order.getPayType().equals("99")){
-                            if("北京卓美".equals(companyName)){
-                                request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+                            Map<String, Object> extendInfoMap = new HashMap<>();
+                            if (order.getPayType().equals("99")){
+                                if("北京卓美".equals(companyName)){
+                                    request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+                                }else {
+                                    request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
+                                }
+                                extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
+                                if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
+                                    extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
+                                }
                             }else {
-                                request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
-                            }
-                            extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
-                            if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
-                                extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
+                                if("北京卓美".equals(companyName)){
+                                    request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+                                }else{
+                                    request.setOrdAmt(payment.getPayMoney().toString());
+                                }
+                                extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
+                                request.setAppId(payment.getAppId());
                             }
-                        }else {
-                            if("北京卓美".equals(companyName)){
-                                request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
-                            }else{
-                                request.setOrdAmt(payment.getPayMoney().toString());
-                            }
-                            extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
-                            request.setAppId(payment.getAppId());
-                        }
 
-                        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
-                        request.setReqSeqId("refund-"+payment.getPayCode());
-                        request.setExtendInfo(extendInfoMap);
-                        HuiFuRefundResult refund = huiFuService.refund(request);
-                        logger.info("退款:"+refund);
-                        if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
-                            payment.setRefundMoney(refundAmount);
-                            payment.setStatus(-1);
-                            payment.setRefundTime(new Date());
-                            paymentService.updateFsStorePayment(payment);
-                        }else {
-                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                            return R.error(refund.getResp_desc());
+                            request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
+                            request.setReqSeqId("refund-"+payment.getPayCode());
+                            request.setExtendInfo(extendInfoMap);
+                            HuiFuRefundResult refund = huiFuService.refund(request);
+                            logger.info("退款:"+refund);
+                            if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
+                                payment.setRefundMoney(refundAmount);
+                                payment.setStatus(-1);
+                                payment.setRefundTime(new Date());
+                                paymentService.updateFsStorePayment(payment);
+                            }else {
+                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                return R.error(refund.getResp_desc());
+                            }
                         }
-
                     }else {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return R.error("支付类型异常");
@@ -1260,6 +1280,68 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
         return R.ok();
     }
 
+    private void refund(String appId,String payType,FsStorePaymentScrm payment,FsStoreOrderScrm order,BigDecimal refundAmount){
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(appId,payType);
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+
+        String huifuId="";
+        if (payment.getAppId() != null) {
+            if (merchantAppConfig == null){
+                huifuId = fsPayConfig.getHuifuId();
+            }else {
+                huifuId = merchantAppConfig.getMerchantId();
+            }
+        } else {
+            if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
+
+                huifuId = merchantAppConfig.getMerchantId();
+            }else {
+                huifuId=fsPayConfig.getHuifuId();
+            }
+        }
+
+        V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
+        DecimalFormat df = new DecimalFormat("0.00");
+        request.setOrgHfSeqId(payment.getTradeNo());
+        request.setHuifuId(huifuId);
+
+        Map<String, Object> extendInfoMap = new HashMap<>();
+        if (order.getPayType().equals("99")){
+            if("北京卓美".equals(companyName)){
+                request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+            }else {
+                request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
+            }
+            extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
+            if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
+                extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
+            }
+        }else {
+            if("北京卓美".equals(companyName)){
+                request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+            }else{
+                request.setOrdAmt(payment.getPayMoney().toString());
+            }
+            extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
+            request.setAppId(payment.getAppId());
+        }
+
+        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
+        request.setReqSeqId("refund-"+payment.getPayCode());
+        request.setExtendInfo(extendInfoMap);
+        HuiFuRefundResult refund = huiFuService.refund(request);
+        logger.info("退款:"+refund);
+        if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
+            payment.setRefundMoney(refundAmount);
+            payment.setStatus(-1);
+            payment.setRefundTime(new Date());
+            paymentService.updateFsStorePayment(payment);
+        }else {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            throw new CustomException(refund.getResp_desc());
+        }
+    }
+
     @Autowired
     private IFsStoreProductPurchaseLimitScrmService purchaseLimitService;
 

+ 128 - 44
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -31,6 +31,7 @@ import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.*;
 import com.fs.common.utils.ip.IpUtils;
 import com.fs.common.utils.spring.SpringUtils;
+import com.fs.common.utils.uuid.IdUtils;
 import com.fs.company.domain.*;
 import com.fs.company.mapper.CompanyDeptMapper;
 import com.fs.company.mapper.CompanyMapper;
@@ -104,7 +105,9 @@ import com.fs.hisapi.param.RecipeDetailParam;
 import com.fs.hisapi.service.HisApiService;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
+import com.fs.huifuPay.domain.HuifuConfirmrefundResult;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmrefundRequest;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
 import com.fs.huifuPay.service.HuiFuService;
@@ -198,6 +201,7 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.nio.charset.Charset;
 import java.sql.Timestamp;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
@@ -3621,32 +3625,50 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                         }
                     } else if (payment.getPayMode() != null && payment.getPayMode().equals("hf")) {
 
-                        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
-                        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
-
-                        String huifuId="";
-                        FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
-                        if (payment.getAppId() != null) {
-                            FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(payment.getAppId());
-                            if (fsHfpayConfig == null){
-                                huifuId = fsPayConfig.getHuifuId();
-                            }else {
-                                huifuId = fsHfpayConfig.getHuifuId();
+                        if (CloudHostUtils.hasCloudHostName("鸿森堂")) {
+                            if (payment.getIsShare() == 1) {
+                                V2TradePaymentDelaytransConfirmrefundRequest confirmRefundRequest = new V2TradePaymentDelaytransConfirmrefundRequest();
+                                String orderCode = IdUtils.randomUUID();
+                                confirmRefundRequest.setReqSeqId(orderCode);
+                                confirmRefundRequest.setOrgReqSeqId(payment.getShareCode());
+                                confirmRefundRequest.setOrgReqDate(payment.getShareDate());
+                                HuifuConfirmrefundResult result = huiFuService.confirmRefund(confirmRefundRequest, payment.getAppId());
+                                if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
+                                    refund(payment.getAppId(),payType,payment,order,payment.getPayMoney());
+                                } else {
+                                    throw new CustomException("交易确认退款请求失败" + result.getResp_desc());
+                                }
+                            } else {
+                                refund(payment.getAppId(),payType,payment,order,payment.getPayMoney());
                             }
                         } else {
-                            if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
 
-                                FsHfpayConfig fsPayConfig2 = fsHfpayConfigMapper.selectByAppId("wx0d1a3dd485268521");
-                                huifuId = fsPayConfig2.getHuifuId();
-                            }else {
-                                huifuId=fsPayConfig.getHuifuId();
+                            MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
+                            FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+
+                            String huifuId="";
+                            FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
+                            if (payment.getAppId() != null) {
+                                FsHfpayConfig fsHfpayConfig = fsHfpayConfigMapper.selectByAppId(payment.getAppId());
+                                if (fsHfpayConfig == null){
+                                    huifuId = fsPayConfig.getHuifuId();
+                                }else {
+                                    huifuId = fsHfpayConfig.getHuifuId();
+                                }
+                            } else {
+                                if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
+
+                                    FsHfpayConfig fsPayConfig2 = fsHfpayConfigMapper.selectByAppId("wx0d1a3dd485268521");
+                                    huifuId = fsPayConfig2.getHuifuId();
+                                }else {
+                                    huifuId=fsPayConfig.getHuifuId();
+                                }
                             }
-                        }
 
 
-                        V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
-                        request.setOrgHfSeqId(payment.getTradeNo());
-                        request.setHuifuId(huifuId);
+                            V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
+                            request.setOrgHfSeqId(payment.getTradeNo());
+                            request.setHuifuId(huifuId);
 
 //                        request.setOrdAmt(payment.getPayMoney().toString());
 //                        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
@@ -3655,32 +3677,32 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 //                        extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
 //                        request.setAppId(payment.getAppId());
 //
-                        Map<String, Object> extendInfoMap = new HashMap<>();
-                        if (order.getPayType().equals("99")){
-                            request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
-                            extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
-                        }else {
-                            request.setOrdAmt(payment.getPayMoney().toString());
-                            extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
-                            request.setAppId(payment.getAppId());
-                        }
-
-                        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
-                        request.setReqSeqId("refund-" + payment.getPayCode());
-                        request.setExtendInfo(extendInfoMap);
+                            Map<String, Object> extendInfoMap = new HashMap<>();
+                            if (order.getPayType().equals("99")){
+                                request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
+                                extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
+                            }else {
+                                request.setOrdAmt(payment.getPayMoney().toString());
+                                extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
+                                request.setAppId(payment.getAppId());
+                            }
 
-                        HuiFuRefundResult refund = huiFuService.refund(request);
-                        logger.info("退款:" + refund);
-                        if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
-                            payment.setRefundMoney(payment.getPayMoney());
-                            payment.setStatus(-1);
-                            payment.setRefundTime(new Date());
-                            paymentService.updateFsStorePayment(payment);
-                        } else {
-                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                            return R.error(refund.getResp_desc());
+                            request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
+                            request.setReqSeqId("refund-" + payment.getPayCode());
+                            request.setExtendInfo(extendInfoMap);
+
+                            HuiFuRefundResult refund = huiFuService.refund(request);
+                            logger.info("退款:" + refund);
+                            if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
+                                payment.setRefundMoney(payment.getPayMoney());
+                                payment.setStatus(-1);
+                                payment.setRefundTime(new Date());
+                                paymentService.updateFsStorePayment(payment);
+                            } else {
+                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                return R.error(refund.getResp_desc());
+                            }
                         }
-
                     } else {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return R.error("支付类型异常");
@@ -3768,6 +3790,68 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
 
     }
 
+    private void refund(String appId,String payType,FsStorePaymentScrm payment,FsStoreOrderScrm order,BigDecimal refundAmount){
+        MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(appId,payType);
+        FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
+
+        String huifuId="";
+        if (payment.getAppId() != null) {
+            if (merchantAppConfig == null){
+                huifuId = fsPayConfig.getHuifuId();
+            }else {
+                huifuId = merchantAppConfig.getMerchantId();
+            }
+        } else {
+            if (("益善缘".equals(cloudHostProper.getCompanyName()))) {
+
+                huifuId = merchantAppConfig.getMerchantId();
+            }else {
+                huifuId=fsPayConfig.getHuifuId();
+            }
+        }
+
+        V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
+        DecimalFormat df = new DecimalFormat("0.00");
+        request.setOrgHfSeqId(payment.getTradeNo());
+        request.setHuifuId(huifuId);
+
+        Map<String, Object> extendInfoMap = new HashMap<>();
+        if (order.getPayType().equals("99")){
+            if("北京卓美".equals(companyName)){
+                request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+            }else {
+                request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
+            }
+            extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
+            if("北京卓美".equals(companyName) && order.getOrderType() != null && 2 == order.getOrderType()){
+                extendInfoMap.put("org_req_seq_id", "live-"+payment.getPayCode());
+            }
+        }else {
+            if("北京卓美".equals(companyName)){
+                request.setOrdAmt(refundAmount.setScale(2, RoundingMode.DOWN).toString());
+            }else{
+                request.setOrdAmt(payment.getPayMoney().toString());
+            }
+            extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
+            request.setAppId(payment.getAppId());
+        }
+
+        request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
+        request.setReqSeqId("refund-"+payment.getPayCode());
+        request.setExtendInfo(extendInfoMap);
+        HuiFuRefundResult refund = huiFuService.refund(request);
+        logger.info("退款:"+refund);
+        if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
+            payment.setRefundMoney(refundAmount);
+            payment.setStatus(-1);
+            payment.setRefundTime(new Date());
+            paymentService.updateFsStorePayment(payment);
+        }else {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            throw new CustomException(refund.getResp_desc());
+        }
+    }
+
     @Override
     public R updateExpress(FsStoreOrderExpressEditParam param) {
         FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderById(param.getOrderId());

+ 66 - 16
fs-service/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -6,6 +6,7 @@ import java.sql.Timestamp;
 import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
@@ -78,12 +79,7 @@ import com.fs.hisStore.constants.StoreConstants;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.dto.*;
 import com.fs.hisStore.enums.*;
-import com.fs.hisStore.mapper.FsStoreOrderItemScrmMapper;
-import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
-import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
-import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
-import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
-import com.fs.hisStore.mapper.FsUserScrmMapper;
+import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.common.utils.SnowflakeUtil;
@@ -271,10 +267,6 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     private IFsCityScrmService fsCityService;
     @Autowired
     private IFsShippingTemplatesFreeScrmService shippingTemplatesFreeService;
-
-    @Autowired
-    private FsStoreProductScrmMapper fsStoreProductBaseMapper;
-
     @Autowired
     private FsStoreProductAttrValueScrmMapper attrValueScrmMapper;
     @Autowired
@@ -345,6 +337,9 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     @Autowired
     private FsWxExpressTaskMapper fsWxExpressTaskMapper;
 
+    @Autowired
+    private FsStoreCartScrmMapper cartScrmMapper;
+
     //ERP 类型到服务的映射
     private Map<Integer, IErpOrderService> erpServiceMap;
     private final BlockingQueue<LiveGoods> liveGoodsQueue = new LinkedBlockingQueue<>();
@@ -3455,6 +3450,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                 fsStorePaymentScrmMapper.insertFsStorePayment(storePayment);
 
                 if (merchantAppConfig.getMerchantType().equals("hf")){
+                    boolean shareAmount = false;
                     HuiFuCreateOrder o = new HuiFuCreateOrder();
                     o.setTradeType("T_MINIAPP");
                     o.setOpenid(user.getMaOpenId());
@@ -3462,12 +3458,21 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                     o.setTransAmt(storePayment.getPayMoney().toString());
                     o.setGoodsDesc("直播订单支付");
                     o.setAppId(param.getAppId());
-                    try {
-                        HuiFuUtils.doDiv(o, order.getCompanyId(), storePayment.getMerConfigId());
-                        //存储分账明细
-                        HuiFuUtils.saveDivItem(o, order.getOrderCode(), storePayment.getPayCode());
-                    } catch (Exception e) {
-                        log.error("-------------分账出错:{}", e.getMessage());
+                    if (CloudHostUtils.hasCloudHostName("鸿森堂")) {
+                        //鸿森堂销售公司分账
+                        try {
+                            shareAmount = shareAmount(o, order, storePayment);
+                        } catch (Exception e) {
+                            log.error("-------------鸿森堂分账出错:{}", e.getMessage());
+                        }
+                    } else {
+                        try {
+                            HuiFuUtils.doDiv(o, order.getCompanyId(), storePayment.getMerConfigId());
+                            //存储分账明细
+                            HuiFuUtils.saveDivItem(o, order.getOrderCode(), storePayment.getPayCode());
+                        } catch (Exception e) {
+                            log.error("-------------分账出错:{}", e.getMessage());
+                        }
                     }
                     HuifuCreateOrderResult result = huiFuService.createOrder(o);
                     if(result.getResp_code() != null && (result.getResp_code().equals("00000000") || result.getResp_code().equals("00000100"))){
@@ -3476,6 +3481,15 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                         mt.setTradeNo(result.getHf_seq_id());
                         mt.setAppId(param.getAppId());
                         mt.setBusinessCode(order.getOrderCode());
+                        if (shareAmount) {
+                            mt.setIsShare(1);
+                            mt.setShareCode("live");
+                            //三天后分账
+                            LocalDate now = LocalDate.now();
+                            LocalDate threeDaysLater = now.plusDays(3);
+                            Date threeDay = Date.from(threeDaysLater.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
+                            mt.setShareTime(threeDay);
+                        }
                         fsStorePaymentScrmMapper.updateFsStorePayment(mt);
                         redisCache.setCacheObject("isPaying:" + order.getId(), order.getId().toString(), 1, TimeUnit.MINUTES);
                         Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
@@ -4968,4 +4982,40 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
     public void handleOrderStatus(LiveOrder liveOrder) {
 
     }
+
+    private boolean shareAmount(HuiFuCreateOrder huiFuCreateOrder,FsStoreOrderScrm order,FsStorePaymentScrm payment){
+
+        boolean tag = false;
+        if (! (payment.getPayMoney().compareTo(new  BigDecimal("0.1")) > -1)) {
+            return tag;
+        }
+        if (order.getCompanyId() == null || order.getCompanyId() <= 0) {
+            return tag;
+        }
+        Company company = companyService.selectCompanyById(order.getCompanyId());
+        if (company == null) {
+            return tag;
+        }
+        if (company.getSubMerchantId() == null) {
+            return tag;
+        }
+        List<FsStoreOrderItemVO> itemVOS = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemListByOrderId(order.getId());
+        if (CollectionUtil.isEmpty(itemVOS)) {
+            return tag;
+        }
+        if (itemVOS.size() > 1) {
+            return tag;
+        }
+        FsStoreProductScrm productScrm = fsStoreProductScrmMapper.selectFsStoreProductById(itemVOS.get(0).getProductId());
+        if (productScrm == null) {
+            return tag;
+        }
+        if (productScrm.getShareRate() == null || productScrm.getShareRate() <= 0) {
+            return tag;
+        }
+        //分账且开启延迟
+        tag = true;
+        huiFuCreateOrder.setDelayAcctFlag("Y");
+        return tag;
+    }
 }

+ 5 - 1
fs-service/src/main/resources/mapper/his/FsShareAmountDetailMapper.xml

@@ -12,10 +12,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="shareAmount"    column="share_amount"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateTime"    column="update_time"    />
+        <result property="orderType" column="order_type" />
     </resultMap>
 
     <sql id="selectFsShareAmountDetailVo">
-        select id, order_id, order_code, merchant_id, share_amount, create_time, update_time from fs_share_amount_detail
+        select id, order_id, order_code, merchant_id, share_amount, create_time, update_time, order_type from fs_share_amount_detail
     </sql>
 
     <select id="selectFsShareAmountDetailList"  resultType="com.fs.his.vo.FsShareAmountDetailVO">
@@ -52,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareAmount != null">share_amount,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateTime != null">update_time,</if>
+            <if test="orderType != null">order_type,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderId != null">#{orderId},</if>
@@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareAmount != null">#{shareAmount},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateTime != null">#{updateTime},</if>
+            <if test="orderType != null">#{orderType},</if>
          </trim>
     </insert>
 
@@ -72,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="shareAmount != null">share_amount = #{shareAmount},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="orderType != null">order_type = #{orderType},</if>
         </trim>
         where id = #{id}
     </update>

+ 25 - 1
fs-service/src/main/resources/mapper/hisStore/FsStorePaymentScrmMapper.xml

@@ -31,10 +31,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="appId"    column="app_id"    />
         <result property="businessCode"    column="business_code"    />
         <result property="merConfigId"    column="mer_config_id"    />
+        <result property="shareStatus" column="share_status" />
+        <result property="shareTime" column="share_time" />
+        <result property="shareCode" column="share_code" />
+        <result property="isShare" column="is_share" />
+        <result property="shareDate" column="share_date" />
     </resultMap>
 
     <sql id="selectFsStorePaymentVo">
-        select payment_id,pay_mode, pay_code, pay_type_code, pay_money, pay_time, create_time, trade_no, user_id, open_id, business_type, business_order_id, status,remark,company_id,company_user_id,dept_id,bank_transaction_id,bank_serial_no,refund_money,refund_time,order_id,is_pay_remain,business_code,app_id from fs_store_payment_scrm
+        select payment_id,pay_mode, pay_code, pay_type_code, pay_money, pay_time
+             , create_time, trade_no, user_id, open_id, business_type, business_order_id, status,remark
+             ,company_id,company_user_id,dept_id,bank_transaction_id,bank_serial_no,refund_money,refund_time
+             ,order_id,is_pay_remain,business_code,app_id,mer_config_id,share_status,share_time,share_code,is_share,share_date from fs_store_payment_scrm
 
     </sql>
 
@@ -95,6 +103,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="appId != null">app_id,</if>
             <if test="businessCode != null">business_code,</if>
             <if test="merConfigId != null">mer_config_id,</if>
+            <if test="shareStatus != null">share_status,</if>
+            <if test="shareTime != null">share_time,</if>
+            <if test="shareCode != null">share_code,</if>
+            <if test="isShare != null">is_share,</if>
+            <if test="shareDate != null">share_date,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="payCode != null">#{payCode},</if>
@@ -122,6 +135,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="appId != null">#{appId},</if>
             <if test="businessCode != null">#{businessCode},</if>
             <if test="merConfigId != null">#{merConfigId},</if>
+            <if test="shareStatus != null">#{shareStatus},</if>
+            <if test="shareTime != null">#{shareTime},</if>
+            <if test="shareCode != null">#{shareCode},</if>
+            <if test="isShare != null">#{isShare},</if>
+            <if test="shareDate != null">#{shareDate},</if>
         </trim>
     </insert>
 
@@ -152,6 +170,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="payMode != null">pay_mode = #{payMode},</if>
             <if test="appId != null">app_id = #{appId},</if>
             <if test="businessCode != null and businessCode != ''">business_code = #{businessCode},</if>
+            <if test="merConfigId != null">mer_config_id = #{merConfigId},</if>
+            <if test="shareStatus != null">share_status = #{shareStatus},</if>
+            <if test="shareTime != null">share_time = #{shareTime},</if>
+            <if test="shareCode != null">share_code = #{shareCode},</if>
+            <if test="isShare != null">is_share = #{isShare},</if>
+            <if test="shareDate != null">share_date = #{shareDate},</if>
         </trim>
         where payment_id = #{paymentId}
     </update>

+ 6 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -83,6 +83,7 @@
         <result property="activityStartTime"    column="activity_start_time"    />
         <result property="activityEndTime"    column="activity_end_time"    />
         <result property="tagInfo"    column="tag_info"    />
+        <result property="shareRate" column="share_rate" />
     </resultMap>
 
     <sql id="selectFsStoreProductVo">
@@ -94,7 +95,8 @@
                is_display,tui_cate_id,company_ids,is_drug,drug_image,drug_reg_cert_no,common_name,dosage_form,
                unit_price,batch_number,mah,mah_address,manufacturer,manufacturer_address,indications,dosage,
                adverse_reactions,contraindications,precautions,is_audit,store_id,return_address,sender_phones,brand,food_production_license_code,
-               origin_place,net_content,shelf_life,domestic_imported,app_ids,purchase_limit,single_purchase_limit,activity_type,activity_start_time,activity_end_time,tag_info
+               origin_place,net_content,shelf_life,domestic_imported,app_ids,purchase_limit,single_purchase_limit,activity_type,activity_start_time,
+               activity_end_time,tag_info,share_rate
         from fs_store_product_scrm
     </sql>
 
@@ -296,6 +298,7 @@
             <if test="singlePurchaseLimit != null">single_purchase_limit,</if>
             <if test="activityType != null">activity_type,</if>
             <if test="tagInfo != null and tagInfo != ''">tag_info,</if>
+            <if test="shareRate != null">share_rate,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="image != null and image != ''">#{image},</if>
@@ -373,6 +376,7 @@
             <if test="singlePurchaseLimit != null">#{singlePurchaseLimit},</if>
             <if test="activityType != null">#{activityType},</if>
             <if test="tagInfo != null and tagInfo != ''">#{tagInfo},</if>
+            <if test="shareRate != null">#{shareRate},</if>
         </trim>
     </insert>
 
@@ -454,6 +458,7 @@
             <if test="singlePurchaseLimit != null">single_purchase_limit = #{singlePurchaseLimit},</if>
             <if test="activityType != null">activity_type = #{activityType},</if>
             <if test="tagInfo != null and tagInfo != ''">tag_info = #{tagInfo},</if>
+            <if test="shareRate != null">share_rate = #{shareRate},</if>
             <if test="tagInfo == null or tagInfo == ''">tag_info = #{tagInfo},</if>
         </trim>
         where product_id = #{productId}