|
@@ -1,8 +1,6 @@
|
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
-import cn.binarywang.wx.miniapp.api.WxMaOrderShippingService;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
|
|
|
-import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetListResponse;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
@@ -15,6 +13,7 @@ import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.fs.api.param.OrderListParam;
|
|
|
import com.fs.api.vo.OrderListVO;
|
|
|
import com.fs.api.vo.ProductListVO;
|
|
@@ -71,6 +70,7 @@ import com.fs.hisapi.domain.ApiResponse;
|
|
|
import com.fs.hisapi.param.CreateOrderParam;
|
|
|
import com.fs.hisapi.param.RecipeDetailParam;
|
|
|
import com.fs.hisapi.service.HisApiService;
|
|
|
+import com.fs.hospital.dto.FsOrderPayMoneyScrmDTO;
|
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
@@ -82,6 +82,8 @@ import com.fs.hisStore.constants.StoreConstants;
|
|
|
import com.fs.hisStore.domain.*;
|
|
|
import com.fs.hisStore.enums.*;
|
|
|
import com.fs.hisStore.service.*;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.ybPay.domain.RefundResult;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
@@ -91,6 +93,7 @@ import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
|
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
+import com.google.gson.Gson;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
@@ -317,6 +320,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Autowired
|
|
|
private FsPackageOrderMapper fsPackageOrderMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysConfigMapper sysConfigMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询订单
|
|
|
*
|
|
@@ -3689,7 +3695,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
batchUpdateDeliveryNotes(successList);
|
|
|
}
|
|
|
|
|
|
- return R.ok(builder.toString());
|
|
|
+ return R.ok(builder.toString().equals("操作成功!")?"":builder.toString());
|
|
|
} catch (Exception e) {
|
|
|
log.error("导入发货单快递信息失败", e);
|
|
|
return R.error("导入失败:" + e.getMessage());
|
|
@@ -3762,14 +3768,109 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void calculateAgentPayment(FsStoreOrderScrm order) {
|
|
|
- //通过订单获取关联商品信息
|
|
|
- List<FsStoreProductAttrValueScrm> attrValueScrmList = fsStoreProductAttrValueMapper.getOrderProducrAttrValueByOrderId(order.getId());
|
|
|
- //计算代付定金金额
|
|
|
+ public void calculateAgentPayment(FsStoreOrderScrm order,Integer rate) {
|
|
|
+ if (order == null || rate == null || order.getId() == null) {
|
|
|
+ log.warn("计算代理商支付金额时入参不完整,order: {}, storeConfig: {}", order, rate);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 通过订单获取关联商品信息
|
|
|
+ List<FsOrderPayMoneyScrmDTO> payMoneyScrmDTOList = fsStoreOrderItemMapper.getOrderProducrAttrValueByOrderId(order.getId());
|
|
|
+ // 初始化金额
|
|
|
+ BigDecimal totalPayMoney = BigDecimal.ZERO; // 定金总额
|
|
|
+ BigDecimal payRate = new BigDecimal(rate)
|
|
|
+ .divide(new BigDecimal(100), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(payMoneyScrmDTOList)) {
|
|
|
+ for (FsOrderPayMoneyScrmDTO dto : payMoneyScrmDTOList) {
|
|
|
+ if (dto == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (Long.valueOf(1).equals(dto.getHasDepositFeatureType())) {
|
|
|
+ totalPayMoney = totalPayMoney.add(nullToZero(dto.getBasePayMoney()));
|
|
|
+ } else {
|
|
|
+ BigDecimal basePayMoney = nullToZero(dto.getBasePayMoney());
|
|
|
+ BigDecimal calculatedMoney = basePayMoney.multiply(payRate);
|
|
|
+ totalPayMoney = totalPayMoney.add(calculatedMoney);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal totalPayDelivery = order.getTotalPrice().subtract(totalPayMoney);// 代付总额
|
|
|
+
|
|
|
+ //验证订单是否使用优惠卷
|
|
|
+ if(order.getCouponId() != null && order.getCouponId() > 0L){
|
|
|
+ //根据优惠卷金额减掉费用
|
|
|
+ totalPayMoney = totalPayMoney.subtract(order.getCouponPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据积分减免
|
|
|
+ if(order.getUseIntegral() != null && order.getUseIntegral().compareTo(new BigDecimal(0)) > 0){
|
|
|
+ Double integralMax = Double.valueOf(100);
|
|
|
+ BigDecimal integralFull = new BigDecimal(0);
|
|
|
+ Double integralRatio = Double.valueOf(0);
|
|
|
+ //使用了多少积分
|
|
|
+ String json = configService.selectConfigByKey("store.integral");
|
|
|
+ if(StringUtils.isNotEmpty(json)){
|
|
|
+ StoreIntegralConfig integralConfig = JSONUtil.toBean(json, StoreIntegralConfig.class);
|
|
|
+
|
|
|
+ if(integralConfig.getIntegralMax() != null){
|
|
|
+ integralMax = integralConfig.getIntegralMax();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(integralConfig.getIntegralFull() != null){
|
|
|
+ integralFull = integralConfig.getIntegralFull();
|
|
|
|
|
|
+ }
|
|
|
+ if(integralConfig.getIntegralRatio() != null){
|
|
|
+ integralRatio =integralConfig.getIntegralRatio();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //积分抵扣金额
|
|
|
+ if (totalPayMoney.compareTo(integralFull) >= 0) {//减免后价格
|
|
|
+ Double userIntegral = order.getUseIntegral().doubleValue();
|
|
|
+ if (integralMax.intValue() > 0 && Double.compare(userIntegral, integralMax) >= 0) {
|
|
|
+ userIntegral = integralMax;
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal deductionPrice = BigDecimal.valueOf(NumberUtil.mul(userIntegral, integralRatio));
|
|
|
+ if (deductionPrice.compareTo(totalPayMoney) < 0) {
|
|
|
+ totalPayMoney = NumberUtil.sub(totalPayMoney, deductionPrice);
|
|
|
+ } else {
|
|
|
+// deductionPrice = totalPayMoney;
|
|
|
+ totalPayMoney = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ order.setPayDelivery(totalPayDelivery);
|
|
|
+ order.setPayMoney(totalPayMoney);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<FsStoreOrderDeliveryNoteExportVO> getDeliveryNote(FsStoreOrderParam param) {
|
|
|
+ List<FsStoreOrderDeliveryNoteExportVO> noteExportVOS=fsStoreOrderMapper.getDeliveryNote(param);
|
|
|
|
|
|
+ //根据配置处理发货人信息
|
|
|
+ SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.store");
|
|
|
+ StoreConfig fsPayConfig = JSON.parseObject(sysConfig.getConfigValue(),StoreConfig.class);
|
|
|
+ noteExportVOS.forEach(n->{
|
|
|
+ if(StringUtils.isEmpty(fsPayConfig.getRefundConsignee()) || StringUtils.isEmpty(fsPayConfig.getRefundPhoneNumber())){
|
|
|
+ throw new ServiceException("导出失败,请在系统配置里的商城配置页面,设置退货人信息!");
|
|
|
+ }
|
|
|
+ n.setSender("007"+fsPayConfig.getRefundConsignee()+"A");
|
|
|
+ n.setSenderPhone(fsPayConfig.getRefundPhoneNumber());
|
|
|
+ n.setSenderCompany(fsPayConfig.getRefundPhoneNumber());
|
|
|
+ });
|
|
|
+ return noteExportVOS;
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理BigDecimal可能为null的情况,避免空指针
|
|
|
+ */
|
|
|
+ private BigDecimal nullToZero(BigDecimal value) {
|
|
|
+ return value == null ? BigDecimal.ZERO : value;
|
|
|
}
|
|
|
|
|
|
private boolean uploadShippingInfoToWechat(WxMaService wxService,
|
|
@@ -3860,6 +3961,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
map.put("ZTO", "中通");
|
|
|
map.put("JD", "京东");
|
|
|
map.put("DBL", "德邦");
|
|
|
+ map.put("YT", "圆通");
|
|
|
return map;
|
|
|
}
|
|
|
|