Преглед на файлове

存在文化发货单导出功能和自定义代付金额功能提交

yjwang преди 2 дни
родител
ревизия
b227d15a54

+ 43 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java

@@ -15,9 +15,11 @@ import com.fs.company.service.ICompanyMoneyLogsService;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.his.service.IFsUserService;
+import com.fs.hisStore.domain.FsStoreProductScrm;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
 import com.fs.hisStore.param.FsStoreOrderParam;
 import com.fs.hisStore.service.*;
+import com.fs.hisStore.vo.FsStoreOrderDeliveryNoteExportVO;
 import com.fs.hisStore.vo.FsStoreOrderExportVO;
 import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
 import com.fs.hisStore.vo.FsStoreOrderVO;
@@ -26,6 +28,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
 
 @RestController
@@ -52,6 +56,9 @@ public class FsStoreHealthOrderScrmController extends BaseController {
     @Autowired
     private ICompanyMoneyLogsService moneyLogsService;
 
+    @Autowired
+    private IFsStoreProductScrmService productScrmService;
+
     // 允许的文件扩展名
     private static final String[] ALLOWED_EXCEL_EXTENSIONS = {".xlsx", ".xls"};
 
@@ -295,6 +302,42 @@ public class FsStoreHealthOrderScrmController extends BaseController {
         return util.importTemplateExcel("订单发货导入模板");
     }
 
+    /**
+     * 发货单导出接口
+     * **/
+    @PreAuthorize("@ss.hasPermi('store:storeOrder:healthExportShippingOrder')")
+    @GetMapping("/healthExportShippingOrder")
+    public AjaxResult healthExportShippingOrder(FsStoreOrderParam param){
+        if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
+            param.setBeginTime(null);
+            param.setEndTime(null);
+        }
+        if (fsStoreOrderService.isEntityNull(param)){
+            return AjaxResult.error("请筛选数据导出");
+        }else if(param.getProductId() == null || param.getProductId() <= 0L){
+            return AjaxResult.error("查询条件,请选择发货商品!");
+        }
+        if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+            param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getPayTimeRange())){
+            param.setPayTimeList(param.getPayTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+            param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+            param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+        }
+        param.setIsHealth("1");
+        List<FsStoreOrderDeliveryNoteExportVO> storeOrderDeliveryNoteExportVOList=fsStoreOrderService.getDeliveryNote(param);
+        ExcelUtil<FsStoreOrderDeliveryNoteExportVO> util = new ExcelUtil<>(FsStoreOrderDeliveryNoteExportVO.class);
+        //通过商品ID获取关键字
+        FsStoreProductScrm productScrm = productScrmService.selectFsStoreProductById(param.getProductId());
+        String fileName="077AC"+productScrm.getKeyword()+new SimpleDateFormat("yyyyMMdd").format(new Date());
+        return util.exportExcel(storeOrderDeliveryNoteExportVOList, fileName);
+    }
+
     private boolean isValidExcelFile(String fileName) {
         for (String ext : ALLOWED_EXCEL_EXTENSIONS) {
             if (fileName.toLowerCase().endsWith(ext)) {

+ 42 - 4
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -28,10 +28,7 @@ import com.fs.his.service.IFsExpressService;
 import com.fs.his.service.IFsUserService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.hisStore.config.FsErpConfig;
-import com.fs.hisStore.domain.FsStoreOrderItemScrm;
-import com.fs.hisStore.domain.FsStoreOrderScrm;
-import com.fs.hisStore.domain.FsStoreOrderStatusScrm;
-import com.fs.hisStore.domain.FsStorePaymentScrm;
+import com.fs.hisStore.domain.*;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.hisStore.dto.StoreOrderExpressExportDTO;
 import com.fs.hisStore.dto.StoreOrderProductDTO;
@@ -49,8 +46,10 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -107,6 +106,9 @@ public class FsStoreOrderScrmController extends BaseController {
     @Autowired
     private TokenService tokenService;
 
+    @Autowired
+    private IFsStoreProductScrmService productScrmService;
+
     private IErpOrderService getErpService(){
         //判断是否开启erp
         IErpOrderService erpOrderService = null;
@@ -719,6 +721,42 @@ public class FsStoreOrderScrmController extends BaseController {
         return util.exportExcel(list, "订单员工维度统计");
     }
 
+    /**
+     * 发货单导出接口
+     * **/
+    @PreAuthorize("@ss.hasPermi('store:storeOrder:exportShippingOrder')")
+    @GetMapping("/exportShippingOrder")
+    public AjaxResult exportShippingOrder(FsStoreOrderParam param){
+        if ("".equals(param.getBeginTime()) && "".equals(param.getEndTime())){
+            param.setBeginTime(null);
+            param.setEndTime(null);
+        }
+        if (fsStoreOrderService.isEntityNull(param)){
+            return AjaxResult.error("请筛选数据导出");
+        }else if(param.getProductId() == null || param.getProductId() <= 0L){
+            return AjaxResult.error("查询条件,请选择发货商品!");
+        }
+        if(!StringUtils.isEmpty(param.getCreateTimeRange())){
+            param.setCreateTimeList(param.getCreateTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getPayTimeRange())){
+            param.setPayTimeList(param.getPayTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
+            param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
+        }
+        if(!StringUtils.isEmpty(param.getDeliverySendTimeRange())){
+            param.setDeliverySendTimeList(param.getDeliverySendTimeRange().split("--"));
+        }
+        param.setNotHealth(1);
+        List<FsStoreOrderDeliveryNoteExportVO> storeOrderDeliveryNoteExportVOList=fsStoreOrderService.getDeliveryNote(param);
+        ExcelUtil<FsStoreOrderDeliveryNoteExportVO> util = new ExcelUtil<>(FsStoreOrderDeliveryNoteExportVO.class);
+        //通过商品ID获取关键字
+        FsStoreProductScrm productScrm = productScrmService.selectFsStoreProductById(param.getProductId());
+        String fileName="077AC"+productScrm.getKeyword()+new SimpleDateFormat("yyyyMMdd").format(new Date());
+        return util.exportExcel(storeOrderDeliveryNoteExportVOList, fileName);
+    }
+
     /**
      * 对象列表类型转换
      */

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java

@@ -7,6 +7,7 @@ import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.param.FsStoreOrderParam;
 import com.fs.hisStore.vo.FsStoreOrderItemExportVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.hospital.dto.FsOrderPayMoneyScrmDTO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
@@ -229,4 +230,10 @@ public interface FsStoreOrderItemScrmMapper
 
     @Select("select product_id,json_info,num from fs_store_order_item_scrm where order_id=#{orderId}")
     List<FsStoreOrderItemListDVO> selectFsStoreOrderItemListDVOByOrderId(Long orderId);
+
+    /**
+     * 获取关联商品详情表
+     * @param orderId 订单Id
+     * **/
+    List<FsOrderPayMoneyScrmDTO> getOrderProducrAttrValueByOrderId(@Param("orderId") Long orderId);
 }

+ 7 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderScrmMapper.java

@@ -9,7 +9,6 @@ import com.fs.api.param.OrderListParam;
 import com.fs.api.vo.OrderListVO;
 import com.fs.company.param.CompanyStatisticsParam;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
-import com.fs.his.domain.FsStoreOrder;
 import com.fs.his.vo.FsStoreOrderExcelVO;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
@@ -1234,4 +1233,11 @@ public interface FsStoreOrderScrmMapper
      * 获取未结算订单
      * **/
     List<FsStoreOrderScrm> getUnsettledOrder();
+
+    /**
+     * 获取发货单数据
+     * @param maps 查询参数
+     * @return list
+     * **/
+    List<FsStoreOrderDeliveryNoteExportVO> getDeliveryNote(@Param("maps") FsStoreOrderParam maps);
 }

+ 0 - 6
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductAttrValueScrmMapper.java

@@ -138,10 +138,4 @@ public interface FsStoreProductAttrValueScrmMapper
             "        </foreach>"+
             "</script>"})
     void updateFsStoreProductAttrValuePrice(List<Long> ids, double v);
-
-    /**
-     * 获取关联商品详情表
-     * @param orderId 订单Id
-     * **/
-    List<FsStoreProductAttrValueScrm> getOrderProducrAttrValueByOrderId(@Param("orderId") Long orderId);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderParam.java

@@ -70,6 +70,8 @@ public class FsStoreOrderParam extends BaseEntity implements Serializable
 
     private Integer isUpload;
 
+    private Long productId;
+
     /** 开始时间 */
     @JsonIgnore
     private String beginTime;

+ 10 - 1
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java

@@ -15,6 +15,7 @@ import com.fs.erp.domain.ErpOrder;
 import com.fs.his.domain.FsStorePayment;
 import com.fs.his.param.FsStoreOrderSalesParam;
 import com.fs.his.vo.FsStoreOrderExcelVO;
+import com.fs.hisStore.config.StoreConfig;
 import com.fs.hisStore.domain.FsStoreOrderItemScrm;
 import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
@@ -297,6 +298,14 @@ public interface IFsStoreOrderScrmService
     /**
      * 代付金额计算方法
      * @param order 订单信息
+     * @param rate 比例
      * **/
-    void calculateAgentPayment(FsStoreOrderScrm order);
+    void calculateAgentPayment(FsStoreOrderScrm order,Integer rate);
+
+    /**
+     * 获取发货单数据
+     * @param param 查询条件
+     * @return list
+     * **/
+    List<FsStoreOrderDeliveryNoteExportVO> getDeliveryNote(FsStoreOrderParam param);
 }

+ 109 - 7
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -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;
     }
 

+ 82 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreOrderDeliveryNoteExportVO.java

@@ -0,0 +1,82 @@
+package com.fs.hisStore.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 发货单导出(商城订单)
+ * **/
+@Data
+public class FsStoreOrderDeliveryNoteExportVO implements Serializable {
+    //系统订单号
+    @Excel(name = "原始单号",width = 20,sort = 1)
+    private String orderNumber;
+
+    @Excel(name = "收件人",width = 10,sort = 2)
+    private String recipient;
+
+    @Excel(name = "收件人手机",width = 20,sort = 3)
+    private String recipientPhone;
+
+    @Excel(name = "收件人电话",width = 20,sort = 4)
+    private String recipientTelephone;
+
+    //具体到某个街道和小区
+    @Excel(name = "收件人详细地址",width = 30,sort = 5)
+    private String recipientAddress;
+
+//    //省市区
+//    @Excel(name = "收货地址",width = 20,sort = 6)
+//    private String receivingAddress;
+
+    //编号和数量:662551*2
+    @Excel(name = "组合编号及数量",width = 20,sort = 7)
+    private String number;
+
+    //名称和数量:商品名称*2
+    @Excel(name = "组合名称及数量",width = 20,sort = 8)
+    private String nameAndNumber;
+
+    @Excel(name = "代收金额",width = 10,sort = 9)
+    private BigDecimal collectionAmount;
+
+    @Excel(name = "物流公司",width = 10,sort = 10)
+    private String logisticsCompany;
+
+    @Excel(name = "物流产品",width = 10,sort = 11)
+    private String logisticsProduct;
+
+    @Excel(name = "物流付款方式",width = 15,sort = 12)
+    private String logisticsPayMethod;
+
+    @Excel(name = "包裹数",width = 10,sort = 13)
+    private Long packageNum;
+
+    @Excel(name = "寄件人",width = 10,sort = 14)
+    private String sender;
+
+    @Excel(name = "寄件人手机",width = 20,sort = 15)
+    private String senderPhone;
+
+    @Excel(name = "寄件人电话",width = 20,sort = 16)
+    private String senderTelephone;
+
+    @Excel(name = "寄件公司",width = 10,sort = 17)
+    private String senderCompany;
+
+    //具体到某个街道和小区
+    @Excel(name = "寄件人详细地址",width = 30,sort = 18)
+    private String senderAddress;
+
+    @Excel(name = "出库仓库",width = 10,sort = 19)
+    private String outboundWarehouse;
+
+    @Excel(name = "订单付款方式",width = 10,sort = 20)
+    private String payMethod;
+
+    @Excel(name = "订单备注",width = 20,sort = 21)
+    private String orderNotes;
+}

+ 25 - 0
fs-service/src/main/java/com/fs/hospital/dto/FsOrderPayMoneyScrmDTO.java

@@ -0,0 +1,25 @@
+package com.fs.hospital.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 订单支付金额DTO
+ * **/
+@Data
+public class FsOrderPayMoneyScrmDTO implements Serializable {
+
+    //商品属性ID
+    private Long id;
+
+    //商品支付金额
+    private BigDecimal basePayMoney;
+
+    //是否开启定金类型(0否,1是)
+    private Long hasDepositFeatureType;
+
+    //代付金额
+    private BigDecimal baseOnBehalfPaymentAmount;
+}

+ 35 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderItemScrmMapper.xml

@@ -88,5 +88,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{itemId}
         </foreach>
     </delete>
-    
+
+    <select id="getOrderProducrAttrValueByOrderId" resultType="com.fs.hospital.dto.FsOrderPayMoneyScrmDTO">
+        SELECT
+            sub.id,
+            sub.basePayMoney,
+            sub.baseOnBehalfPaymentAmount,
+            sub.hasDepositFeatureType
+        FROM
+            (
+                SELECT
+                    spavs.id,
+                    CASE
+                        WHEN spavs.has_deposit_feature_type = 0 THEN
+                            ROUND(sois.num * spavs.price, 2)
+                        WHEN spavs.has_deposit_feature_type = 1 THEN
+                            ROUND(sois.num * spavs.deposit_amount, 2)
+                        END AS basePayMoney,
+                    CASE
+                        WHEN spavs.has_deposit_feature_type = 0 THEN
+                            ROUND(sois.num * spavs.price, 2)
+                        WHEN spavs.has_deposit_feature_type = 1 THEN
+                            ROUND(sois.num * spavs.on_behalf_payment_amount, 2)
+                        END AS baseOnBehalfPaymentAmount,
+                    sois.num,
+                    spavs.on_behalf_payment_amount,
+                    spavs.has_deposit_feature_type AS hasDepositFeatureType
+                FROM
+                    fs_store_order_scrm sos
+                        INNER JOIN fs_store_order_item_scrm sois ON sos.id = sois.order_id
+                        INNER JOIN fs_store_product_attr_value_scrm spavs ON sois.product_id = spavs.product_id
+                WHERE
+                    sos.id = #{orderId}
+            ) sub
+    </select>
+
 </mapper>

+ 139 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderScrmMapper.xml

@@ -987,6 +987,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                                                   WHERE os.order_code IN <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
         #{item}
     </foreach>
+    AND  sps.`status` = 1
     </select>
 
     <select id="getUnsettledOrder" resultType="com.fs.hisStore.domain.FsStoreOrderScrm">
@@ -1005,4 +1006,142 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                       sos.delivery_send_time
                   ) >= 3
     </select>
+
+    <select id="getDeliveryNote" resultType="com.fs.hisStore.vo.FsStoreOrderDeliveryNoteExportVO">
+        SELECT
+        CONCAT('AC', o.id) AS orderNumber,
+        o.real_name AS recipient,
+        o.user_phone AS recipientPhone,
+        o.user_address AS recipientAddress,
+        GROUP_CONCAT(
+        DISTINCT IFNULL(
+        CASE WHEN LENGTH(sps.product_name) > 0
+        THEN CONCAT(sps.product_name, '*', sois.num)
+        END, ''
+        )
+        SEPARATOR '+'
+        ) AS nameAndNumber,
+        IF(o.pay_type = 2, o.pay_delivery, 0) AS collectionAmount,
+        IFNULL(o.delivery_name, '顺丰') AS logisticsCompany,
+        '电商标快' AS logisticsProduct,
+        '寄付月结' AS logisticsPayMethod,
+        '1' AS packageNum,
+        '北京市通州区嘉创五路3号东升联启大院快递电商库' AS senderAddress,
+        '077' AS outboundWarehouse,
+        CONCAT('077', o.mark, 'A') AS orderNotes
+        FROM
+        fs_store_order_scrm o
+        LEFT JOIN fs_store_order_item_scrm sois
+        ON sois.order_id = o.id
+        LEFT JOIN fs_store_product_scrm sps
+        ON sps.product_id = sois.product_id
+        LEFT JOIN fs_user u
+        ON o.user_id = u.user_id
+        LEFT JOIN company c
+        ON c.company_id = o.company_id
+        LEFT JOIN company_user cu
+        ON cu.user_id = o.company_user_id
+        LEFT JOIN (
+        SELECT DISTINCT order_id
+        FROM fs_store_payment_scrm
+        WHERE is_pay_remain != 0 AND STATUS != 0
+        ) fp
+        ON o.id = fp.order_id
+        WHERE
+        1 = 1
+        <if test="maps.orderCode != null and maps.orderCode != ''">
+            AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
+        </if>
+        <if test="maps.userId != null">
+            AND o.user_id = #{maps.userId}
+        </if>
+        <if test="maps.deliveryId != null and maps.deliveryId != ''">
+            AND o.delivery_id = #{maps.deliveryId}
+        </if>
+        <if test="maps.nickname != null and maps.nickname != ''">
+            AND u.nickname LIKE CONCAT('%', #{maps.nickname}, '%')
+        </if>
+        <if test="maps.realName != null and maps.realName != ''">
+            AND o.real_name LIKE CONCAT('%', #{maps.realName}, '%')
+        </if>
+        <if test="maps.phone != null and maps.phone != ''">
+            AND u.phone LIKE CONCAT('%', #{maps.phone}, '%')
+        </if>
+        <if test="maps.userPhone != null and maps.userPhone != ''">
+            AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
+        </if>
+        <if test="maps.status == null">
+            AND o.status = 1
+        </if>
+        <if test="maps.status != null">
+            AND o.status = #{maps.status}
+        </if>
+        <if test="maps.deliveryStatus != null">
+            AND o.delivery_status = #{maps.deliveryStatus}
+        </if>
+        <if test="maps.deliveryPayStatus != null">
+            AND o.delivery_pay_status = #{maps.deliveryPayStatus}
+        </if>
+        <if test="maps.companyId != null">
+            AND o.company_id = #{maps.companyId}
+        </if>
+        <if test="maps.isHealth != null and maps.isHealth != ''">
+            AND o.company_id IS NULL
+        </if>
+        <if test="maps.notHealth != null and maps.notHealth != ''">
+            AND o.company_id IS NOT NULL
+        </if>
+        <if test="maps.companyUserId != null">
+            AND o.company_user_id = #{maps.companyUserId}
+        </if>
+        <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
+            AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
+        </if>
+        <if test="maps.orderType != null">
+            AND o.order_type = #{maps.orderType}
+        </if>
+        <if test="maps.payType != null">
+            AND o.pay_type = #{maps.payType}
+        </if>
+        <if test="maps.createTimeList != null">
+            AND o.create_time >= STR_TO_DATE(#{maps.createTimeList[0]}, '%Y%m%d')
+            AND o.create_time &lt; DATE_ADD(STR_TO_DATE(#{maps.createTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
+        </if>
+        <if test="maps.payTimeList != null">
+            AND o.pay_time >= STR_TO_DATE(#{maps.payTimeList[0]}, '%Y%m%d')
+            AND o.pay_time &lt; DATE_ADD(STR_TO_DATE(#{maps.payTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
+        </if>
+        <if test="maps.deliverySendTimeList != null">
+            AND o.delivery_send_time >= STR_TO_DATE(#{maps.deliverySendTimeList[0]}, '%Y%m%d')
+            AND o.delivery_send_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliverySendTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
+        </if>
+        <if test="maps.deliveryImportTimeList != null">
+            AND o.delivery_import_time >= STR_TO_DATE(#{maps.deliveryImportTimeList[0]}, '%Y%m%d')
+            AND o.delivery_import_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliveryImportTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
+        </if>
+        <if test="maps.deptId != null">
+            AND (o.dept_id = #{maps.deptId}
+            OR o.dept_id IN (SELECT t.dept_id FROM company_dept t WHERE FIND_IN_SET(#{maps.deptId}, t.ancestors)))
+        </if>
+        <if test="maps.isUpload != null and maps.isUpload == 0">
+            AND o.certificates IS NULL
+        </if>
+        <if test="maps.scheduleId != null">
+            AND o.schedule_id = #{maps.scheduleId}
+        </if>
+        <if test="maps.isUpload != null and maps.isUpload == 1">
+            AND o.certificates IS NOT NULL
+        </if>
+        AND EXISTS (
+        SELECT 1
+        FROM fs_store_order_item_scrm sois2
+        LEFT JOIN fs_store_product_scrm sps2 ON sois2.product_id = sps2.product_id
+        WHERE sois2.order_id = o.id
+        AND sps2.product_id = #{maps.productId}
+        )
+        ${maps.params.dataScope}
+        AND o.paid = 1
+        GROUP BY o.id
+        LIMIT 10000;
+    </select>
 </mapper>

+ 0 - 13
fs-service/src/main/resources/mapper/hisStore/FsStoreProductAttrValueScrmMapper.xml

@@ -141,17 +141,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
-
-    <select id="getOrderProducrAttrValueByOrderId" resultType="com.fs.hisStore.domain.FsStoreProductAttrValueScrm">
-        SELECT
-            spavs.*
-        FROM
-            fs_store_order_scrm sos
-                INNER JOIN fs_store_order_item_scrm sois ON sos.id = sois.order_id
-                INNER JOIN fs_store_product_scrm sps ON sps.product_id=sois.product_id
-                INNER JOIN fs_store_product_attr_value_scrm spavs ON sps.product_id = spavs.product_id
-        WHERE
-            sos.id=#{orderId}
-    </select>
-
 </mapper>

+ 19 - 9
fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

@@ -316,11 +316,14 @@ public class StoreOrderScrmController extends AppBaseController {
                     order.setPayDelivery(BigDecimal.ZERO);
                 }
                 else if(param.getPayType().equals(2)){
+
                     order.setPayType("2");
-                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
-                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
-                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
-                    order.setPayMoney(payMoney);
+                    //存在文化定制化需求自定义代付金额
+                    orderService.calculateAgentPayment(order,storeConfig.getPayRate());
+//                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+//                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+//                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+//                    order.setPayMoney(payMoney);
                 }
                 else if(param.getPayType().equals(3)){
                     //货到付款
@@ -441,7 +444,11 @@ public class StoreOrderScrmController extends AppBaseController {
         }
         String orderId=redisCache.getCacheObject("isPaying:"+order.getId());
         if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getId().toString())){
-            return R.error("正在支付中...");
+            //如果正在支付中则返回订单信息,类型不一样则提示
+            if(!order.getPayType().equals(String.valueOf(param.getPayType()))){
+                return R.error("正在支付中...");
+            }
+            return R.ok().put("order",order);
         }
         List<FsStorePaymentScrm>  payments=fsStorePaymentMapper.selectFsStorePaymentByOrder(order.getId());
         if(payments.size()>0){
@@ -474,10 +481,13 @@ public class StoreOrderScrmController extends AppBaseController {
                 else if(param.getPayType().equals(2)){
 
                     order.setPayType("2");
-                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
-                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
-                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
-                    order.setPayMoney(payMoney);
+                    //存在文化定制化需求自定义代付金额
+                    orderService.calculateAgentPayment(order,storeConfig.getPayRate());
+
+//                    BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
+//                    payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
+//                    order.setPayDelivery(order.getPayPrice().subtract(payMoney));
+//                    order.setPayMoney(payMoney);
                 }
                 else if(param.getPayType().equals(3)){
                     //货到付款