Ver código fonte

Merge remote-tracking branch 'origin/康年堂' into 康年堂

yh 2 semanas atrás
pai
commit
97c754e360

+ 34 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreAfterSalesScrmController.java

@@ -5,6 +5,8 @@ import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
+import com.fs.common.core.domain.entity.SysRole;
+import com.fs.common.core.domain.entity.SysUser;
 import com.fs.common.core.domain.model.LoginUser;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
@@ -30,6 +32,7 @@ import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.vo.FsStoreAfterSalesVO;
 import com.fs.hisStore.vo.FsStoreOrderItemExportRefundZMVO;
 import com.fs.hisStore.vo.FsStoreOrderItemExportZMVO;
+import com.fs.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -173,9 +176,40 @@ public class FsStoreAfterSalesScrmController extends BaseController
         FsUser user=userService.selectFsUserById(afterSales.getUserId());
         user.setPhone(ParseUtils.parsePhone(user.getPhone()));
         FsStoreOrderScrm order=fsStoreOrderService.selectFsStoreOrderByOrderCode(afterSales.getOrderCode());
+        if(order!=null){
+            SysRole sysRole = isCheckPermission();
+            String userPhone = order.getUserPhone();
+            if(StringUtils.isNotBlank(userPhone) && !(sysRole.getIsCheckPhone()==1)){
+                order.setUserPhone(ParseUtils.parsePhone(userPhone));
+            }
+            String userAddress = order.getUserAddress();
+            if(StringUtils.isNotBlank(userAddress) && !(sysRole.getIsCheckAddress()==1)){
+                order.setUserAddress(ParseUtils.parseAddress(userAddress));
+            }
+        }
         return R.ok().put("afterSales",afterSales).put("items",items).put("logs",logs).put("user",user).put("order",order);
     }
 
+    @Autowired
+    private ISysRoleService sysRoleService;
+    private SysRole isCheckPermission() {
+        SysRole sysRole = new SysRole();
+        SysUser user = getLoginUser().getUser();
+        boolean flag = user.isAdmin();
+        if (flag) {
+            sysRole.setIsCheckPhone(1);
+            sysRole.setIsCheckAddress(1);
+        } else {
+            List<SysRole> roles = user.getRoles();
+            if (roles != null && !roles.isEmpty()) {
+                Long[] roleIds = roles.stream().map(SysRole::getRoleId).toArray(Long[]::new);
+                return sysRoleService.getIsCheckPermission(roleIds);
+            }
+        }
+        return sysRole;
+    }
+
+
     /**
      * 新增售后记录
      */

+ 4 - 0
fs-service/src/main/java/com/fs/his/config/StoreConfig.java

@@ -3,6 +3,7 @@ package com.fs.his.config;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 @Data
 public class StoreConfig implements Serializable {
@@ -22,5 +23,8 @@ public class StoreConfig implements Serializable {
     private String API_URL;
     private String HASHCODE;
     private String SECRET_KEY;
+    private String payPriceTip;//支付金额达限提示
+    private BigDecimal yearPayPrice;//年支付金额限制
+    private BigDecimal canPayPrice;//达限后支付限制金额
 
 }

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

@@ -1,5 +1,6 @@
 package com.fs.hisStore.mapper;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 import com.fs.his.vo.FsStoreOrderItemListDVO;
@@ -305,4 +306,6 @@ public interface FsStoreOrderItemScrmMapper
     List<FsStoreOrderItemVO> selectFsStoreOrderItemListByOrderIds(@Param("orderIds")List<Long> orderIds);
 
     String selectFsStoreOrderItemByOrderId(@Param("orderId") Long orderId);
+
+    BigDecimal selectPayPriceByYear(@Param("userId") String userId);
 }

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreProductScrmMapper.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.mapper;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -10,6 +11,7 @@ import com.fs.his.vo.FsStoreProductListSVO;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.FsStoreProductRuleScrm;
+import com.fs.hisStore.param.FsStoreOrderCheckContinueParam;
 import com.fs.live.domain.LiveGoods;
 import com.fs.statis.dto.ModifyMoreDTO;
 import com.fs.hisStore.domain.FsStoreProductScrm;
@@ -406,4 +408,6 @@ public interface FsStoreProductScrmMapper
     List<FsStoreProductListVO> liveList(@Param("maps") LiveGoods maps);
 
     List<FsStoreProductScrm> selectFsStoreProductByProductIds(@Param("productIds") List<Long> productIdsLong);
+
+    BigDecimal selectFsStoreProductTotalMoneyByIds(@Param("productInfos")List<FsStoreOrderCheckContinueParam.ProductInfo> productInfos);
 }

+ 25 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderCheckContinueParam.java

@@ -0,0 +1,25 @@
+package com.fs.hisStore.param;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class FsStoreOrderCheckContinueParam {
+    // 商品信息对象
+    private List<ProductInfo> productInfo;
+
+    // 套餐id
+    private Long packageId;
+
+    // 类型 1:商品 2:套餐
+    private Integer type;
+
+    @Data
+    public static class ProductInfo {
+        // 商品id集合
+        private Long productId;
+        // 商品数量
+        private Integer num;
+    }
+}

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

@@ -363,4 +363,6 @@ public interface IFsStoreOrderScrmService
     ExpressInfoDTO getDfExpressInfoDTO(FsStoreOrderScrm order);
 
     String importOrderStatusData(List<FsStoreOrderStateVo> list);
+
+    BigDecimal selectPayPriceByYear(String userId);
 }

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreProductScrmService.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.service;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -12,6 +13,7 @@ import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.vo.FsStoreProductExcelVO;
 import com.fs.his.vo.FsStoreProductListSVO;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.param.FsStoreOrderCheckContinueParam;
 import com.fs.hisStore.vo.*;
 import com.fs.live.domain.LiveGoods;
 import com.fs.statis.dto.ModifyMoreDTO;
@@ -146,4 +148,6 @@ public interface IFsStoreProductScrmService
     List<FsStoreProductListVO> liveList(LiveGoods liveId);
 
     R copyStoreProduct(Long productId);
+
+    BigDecimal selectFsStoreProductTotalMoneyByIds(List<FsStoreOrderCheckContinueParam.ProductInfo> productInfos);
 }

+ 30 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -374,7 +374,22 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
         //生成售后订单
         FsStoreAfterSalesScrm storeAfterSales = new FsStoreAfterSalesScrm();
         storeAfterSales.setOrderCode(storeAfterSalesParam.getOrderCode());
-        storeAfterSales.setRefundAmount(storeAfterSalesParam.getRefundAmount());
+
+        BigDecimal refundAmount = storeAfterSalesParam.getRefundAmount();
+        //查询实付金额
+        BigDecimal payMoney = order.getPayMoney();
+        if (refundAmount != null && payMoney != null && refundAmount.compareTo(payMoney) >= 0) {
+            //已发货 运费不退
+            refundAmount = payMoney;
+            if (orderStatus.compareTo(OrderInfoEnum.STATUS_1.getValue())>0) {
+                if (order.getPayPostage() != null) {
+                    refundAmount = payMoney.subtract(order.getPayPostage());
+                }
+            }
+        }
+
+
+        storeAfterSales.setRefundAmount(refundAmount);
         storeAfterSales.setServiceType(storeAfterSalesParam.getServiceType());
         storeAfterSales.setReasons(storeAfterSalesParam.getReasons());
         storeAfterSales.setExplains(storeAfterSalesParam.getExplains());
@@ -1230,6 +1245,20 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
         //生成售后订单
         FsStoreAfterSalesScrm storeAfterSales = new FsStoreAfterSalesScrm();
         storeAfterSales.setOrderCode(storeAfterSalesParam.getOrderCode());
+
+        BigDecimal refundAmount = storeAfterSalesParam.getRefundAmount();
+        //查询实付金额
+        BigDecimal payMoney = order.getPayMoney();
+        if (refundAmount != null && payMoney != null && refundAmount.compareTo(payMoney) >= 0) {
+            //已发货 运费不退
+            refundAmount = payMoney;
+            if (orderStatus.compareTo(OrderInfoEnum.STATUS_1.getValue())>0) {
+                if (order.getPayPostage() != null) {
+                    refundAmount = payMoney.subtract(order.getPayPostage());
+                }
+            }
+        }
+
         storeAfterSales.setRefundAmount(storeAfterSalesParam.getRefundAmount());
         storeAfterSales.setServiceType(storeAfterSalesParam.getServiceType());
         storeAfterSales.setReasons(storeAfterSalesParam.getReasons());

+ 17 - 1
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -4109,7 +4109,18 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         FsStoreAfterSalesScrm fsStoreAfterSales = new FsStoreAfterSalesScrm();
         fsStoreAfterSales.setOrderId(order.getId());
         fsStoreAfterSales.setStoreId(order.getStoreId());
-        fsStoreAfterSales.setRefundAmount(order.getPayMoney());
+
+        //查询实付金额
+        BigDecimal payMoney = order.getPayMoney();
+        //已发货 运费不退
+        BigDecimal refundAmount = payMoney;
+        if (order.getStatus().compareTo(OrderInfoEnum.STATUS_1.getValue())>0) {
+            if (order.getPayPostage() != null) {
+                refundAmount = payMoney.subtract(order.getPayPostage());
+            }
+        }
+
+        fsStoreAfterSales.setRefundAmount(refundAmount);
         fsStoreAfterSales.setCreateTime(DateUtils.getNowDate());
         if (order.getStatus() == 2 || order.getStatus() == 3) {
             fsStoreAfterSales.setRefundType(0);
@@ -5572,6 +5583,11 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         return successMsg.toString();
     }
 
+    @Override
+    public BigDecimal selectPayPriceByYear(String userId) {
+        return fsStoreOrderItemMapper.selectPayPriceByYear(userId);
+    }
+
     private static final DateTimeFormatter CST_FORMATTER = DateTimeFormatter
             .ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US)
             .withZone(ZoneId.of("Asia/Shanghai"));

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreProductScrmServiceImpl.java

@@ -33,6 +33,7 @@ import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.enums.CompanyEnum;
 import com.fs.hisStore.mapper.*;
+import com.fs.hisStore.param.FsStoreOrderCheckContinueParam;
 import com.fs.hisStore.utils.StoreAuditLogUtil;
 import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveGoods;
@@ -1554,4 +1555,9 @@ public class FsStoreProductScrmServiceImpl implements IFsStoreProductScrmService
         return R.ok();
 
     }
+
+    @Override
+    public BigDecimal selectFsStoreProductTotalMoneyByIds(List<FsStoreOrderCheckContinueParam.ProductInfo> productInfos) {
+        return fsStoreProductMapper.selectFsStoreProductTotalMoneyByIds(productInfos);
+    }
 }

+ 8 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderItemScrmMapper.xml

@@ -124,5 +124,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE order_id = #{orderId}
         GROUP BY order_id;
     </select>
+    <select id="selectPayPriceByYear" resultType="java.math.BigDecimal">
+        SELECT SUM(pay_price) AS total_pay
+        FROM fs_store_order_scrm
+        WHERE status NOT IN (0, -1,-3)
+          AND user_id = #{userId}
+          AND pay_time >= CONCAT(YEAR(CURDATE()), '-01-01')
+          AND pay_time &lt; DATE_ADD(CONCAT(YEAR(CURDATE()), '-01-01'), INTERVAL 1 YEAR);
+    </select>
 
 </mapper>

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

@@ -1841,7 +1841,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and o.status = #{maps.status}
             </if>
             <if test="maps.status == 6">
-                and o.`status`= 2
+                and o.`status`= 1
                 and  ( o.extend_order_id is null or  o.extend_order_id like '')
             </if>
             <if test="maps.isUpload != null and maps.isUpload == 0    ">

+ 15 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreProductScrmMapper.xml

@@ -553,4 +553,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         #{item}
     </foreach>
     </select>
+    <select id="selectFsStoreProductTotalMoneyByIds" resultType="java.math.BigDecimal">
+        WITH product_temp AS (
+        <foreach collection="productInfos" item="item" index="index" separator=" UNION ALL ">
+            SELECT
+            #{item.productId} as product_id,
+            #{item.num} as num
+        </foreach>
+        )
+        SELECT
+        SUM(p.price * pt.num) as totalMoney
+        FROM
+        fs_store_product_scrm p
+        INNER JOIN
+        product_temp pt ON p.product_id = pt.product_id
+    </select>
 </mapper>

+ 46 - 23
fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

@@ -1,53 +1,30 @@
 package com.fs.app.controller.store;
 
-import cn.binarywang.wx.miniapp.api.WxMaService;
-import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
-import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.TypeReference;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
-import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.*;
-import com.fs.common.utils.ip.IpUtils;
-import com.fs.core.config.WxMaConfiguration;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.dto.ExpressInfoDTO;
 import com.fs.his.utils.ConfigUtil;
-import com.fs.hisStore.config.FsErpConfig;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.dto.FsStoreOrderComputeDTO;
 import com.fs.hisStore.enums.OrderInfoEnum;
-import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
-import com.fs.huifuPay.domain.HuiFuCreateOrder;
-import com.fs.huifuPay.domain.HuifuCreateOrderResult;
-import com.fs.huifuPay.service.HuiFuService;
-import com.fs.pay.pay.dto.OrderQueryDTO;
-import com.fs.pay.service.IPayService;
 import com.fs.store.config.StoreConfig;
 import com.fs.system.service.ISysConfigService;
-import com.fs.wx.miniapp.config.WxMaProperties;
-import com.fs.ybPay.domain.OrderResult;
-import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
-import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
-import com.github.binarywang.wxpay.config.WxPayConfig;
-import com.github.binarywang.wxpay.exception.WxPayException;
-import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.error.WxErrorException;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
@@ -122,6 +99,10 @@ public class StoreOrderScrmController extends AppBaseController {
     @Autowired
     private IFsExpressScrmService expressService;
 
+    @Autowired
+    private IFsStoreProductScrmService storeProductService;
+
+
 
     @Login
     @ApiOperation("获取我的订单列表")
@@ -591,4 +572,46 @@ public class StoreOrderScrmController extends AppBaseController {
     }
 
 
+    @Login
+    @ApiOperation("校验是否可继续下单")
+    @PostMapping("/checkContinue")
+    public R checkContinue(@RequestBody FsStoreOrderCheckContinueParam param){
+        String userId = getUserId();
+        String json = configService.selectConfigByKey("his.store");
+        com.fs.his.config.StoreConfig config = JSONUtil.toBean(json, com.fs.his.config.StoreConfig.class);
+        BigDecimal canPayPrice = config.getCanPayPrice();
+        BigDecimal yearPayPrice = config.getYearPayPrice();
+        if(canPayPrice==null||yearPayPrice==null){
+            return R.ok();
+        }
+        String payPriceTip = config.getPayPriceTip();
+        BigDecimal totalMoney = BigDecimal.ZERO;
+        //查询用户本年内支付处方订单+公私域套餐包总金额 (类型 1:商品 2:套餐)
+        if (param.getType() == 1){
+            List<FsStoreOrderCheckContinueParam.ProductInfo> productInfos = param.getProductInfo();
+            if(productInfos==null|| productInfos.isEmpty()){
+                return R.error("缺少必要参数");
+            }
+            totalMoney = storeProductService.selectFsStoreProductTotalMoneyByIds(productInfos);
+        }else if (param.getType() == 2){
+            Long packageId = param.getPackageId();
+            if(packageId==null){
+                return R.error("缺少必要参数");
+            }
+            FsStoreProductPackageScrm packageScrm = productPackageService.selectFsStoreProductPackageById(packageId);
+            totalMoney = packageScrm.getPayMoney();
+        } else {
+            return R.error("类型不能为空");
+        }
+
+        BigDecimal bigDecimal = orderService.selectPayPriceByYear(userId);
+        if(bigDecimal==null || totalMoney == null){
+            return R.ok();
+        }
+        if (bigDecimal.compareTo(yearPayPrice)>=0&&totalMoney.compareTo(canPayPrice)>=0){
+            return R.ok().put("tip",payPriceTip);
+        }
+        return R.ok();
+    }
+
 }