Explorar el Código

Merge remote-tracking branch 'origin/master'

zyp hace 20 horas
padre
commit
7ae6e73918

+ 4 - 1
fs-service-system/src/main/java/com/fs/erp/dto/sdk/wangdian/api/WdtClient.java

@@ -29,7 +29,9 @@ public class WdtClient {
 	@Autowired
 	ConfigUtil configUtil;
 
-
+	private String getWarehouseNo() {
+		return configUtil.getErpConfig().getErpWarehouseCode();
+	}
 	private String getAppKey() {
 		return configUtil.getErpConfig().getErpWdAppKey();
 	}
@@ -147,6 +149,7 @@ public class WdtClient {
 		log.info("开始执行请求,相对路径:{},请求参数:{}", relativeUrl, params);
 
 
+		params.put("warehouse_no", getWarehouseNo());
 		params.put("appkey", getAppKey());
 		params.put("sid", getSid());
 		params.put("timestamp", Long.toString(System.currentTimeMillis()/1000));

+ 1 - 0
fs-service-system/src/main/java/com/fs/store/config/StoreConfig.java

@@ -22,5 +22,6 @@ public class StoreConfig implements Serializable {
     private String refundPhoneNumber;
     private String refundAddress;
     private Integer auditSwitch; // 订单审核开关
+    private Integer createSalesOrderType; // 订单改价方式 1 商品改价 2总价改价
 
 }

+ 7 - 1
fs-service-system/src/main/java/com/fs/store/domain/FsStoreCart.java

@@ -4,9 +4,11 @@ import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import lombok.*;
 
+import java.math.BigDecimal;
+
 /**
  * 购物车对象 fs_store_cart
- * 
+ *
  * @author fs
  * @date 2022-03-21
  */
@@ -54,5 +56,9 @@ public class FsStoreCart extends BaseEntity
     @Excel(name = "是否为立即购买")
     private Integer isBuy;
 
+    /** 改价(商品单价) */
+    @Excel(name = "改价(商品单价)")
+    private BigDecimal changePrice;
+
 
 }

+ 22 - 0
fs-service-system/src/main/java/com/fs/store/param/FsStoreOrderMoneyByProductParam.java

@@ -0,0 +1,22 @@
+package com.fs.store.param;
+
+import com.fs.store.domain.FsStoreCart;
+import com.fs.store.domain.FsStoreOrder;
+import com.fs.store.vo.FsStoreCartQueryVO;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@Data
+public class FsStoreOrderMoneyByProductParam {
+    //销售token
+    @NotNull(message = "token不能为空")
+    private String token;
+
+    @NotNull(message = "createOrderKey不能为空")
+    private String createOrderKey;
+
+    //购物车明细
+    private List<FsStoreCartQueryVO> carts;
+}

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStoreOrderService.java

@@ -235,4 +235,6 @@ public interface IFsStoreOrderService
     List<OrderStatisticsVo> selectOrderDimensionStatisticsList(OrderStatisticsParam param);
 
     List<FsStoreOrderCountsVO> selectFsStoreOrderCountsByDept(Map<String, Object> map,Long deptId);
+
+    R updateSalesOrderMoneyByProduct(FsStoreOrderMoneyByProductParam param);
 }

+ 60 - 1
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -377,7 +377,17 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     public R confirmOrder(long uid, FsStoreConfirmOrderParam cartParam) {
         //获取地址信息和购物车信息
         FsUserAddress address= userAddressMapper.selectFsUserAddressByDefaultAddress(uid);
-        List<FsStoreCartQueryVO>  carts=cartMapper.selectFsStoreCartListByIds(cartParam.getCartIds());
+        List<FsStoreCartQueryVO> carts=cartMapper.selectFsStoreCartListByIds(cartParam.getCartIds());
+        for (FsStoreCartQueryVO cart : carts) {
+            if (cart.getChangePrice() != null && BigDecimal.ZERO.compareTo(cart.getChangePrice())<0){
+                cart.setPrice(cart.getChangePrice());
+                //删除改价
+                FsStoreCart fsStoreCart = new FsStoreCart();
+                fsStoreCart.setId(cart.getId());
+                fsStoreCart.setChangePrice(BigDecimal.ZERO);
+                cartMapper.updateFsStoreCart(fsStoreCart);
+            }
+        }
         String uuid = IdUtil.randomUUID();
         redisCache.setCacheObject("orderKey:"+uuid, cartParam.getCartIds(), 300, TimeUnit.SECONDS);
         redisCache.setCacheObject("orderCarts:"+uuid, carts, 300, TimeUnit.SECONDS);
@@ -2053,6 +2063,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                     .isPay(0)
                     .isDel(0)
                     .isBuy(1)
+                    .changePrice(vo.getPrice())
                     .build();
             storeCart.setCreateTime(new Date());
             cartMapper.insertFsStoreCart(storeCart);
@@ -2738,6 +2749,54 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         return vos;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R updateSalesOrderMoneyByProduct(FsStoreOrderMoneyByProductParam param) {
+        String json=configService.selectConfigByKey("store.config");
+        StoreConfig config= JSONUtil.toBean(json,StoreConfig.class);
+        Integer createSalesOrderType = config.getCreateSalesOrderType();
+        if(createSalesOrderType !=null){
+            if (createSalesOrderType != 1) {
+                return R.error("改价方式错误");
+            }
+        } else {
+            return R.error("未设置改价方式");
+        }
+
+        String createOrderKey = param.getCreateOrderKey();
+        String key=redisCache.getCacheObject("createOrderKey:"+createOrderKey);
+        if (StringUtils.isEmpty(key)) {
+            throw new CustomException("订单已过期",501);
+        }
+//        List<FsStoreCartQueryVO> carts = redisCache.getCacheObject("orderCarts:" + createOrderKey);
+        List<FsStoreCartQueryVO> carts = param.getCarts();
+        if (carts.isEmpty()) {
+            return R.error("购物车不能为空");
+        }
+        BigDecimal totalMoney= BigDecimal.ZERO;
+        //新购物车明细
+        for(FsStoreCartQueryVO vo:carts){
+            //单个价格不能为0
+            BigDecimal price = vo.getPrice();
+            if (price==null || price.compareTo(BigDecimal.ZERO)<=0){
+                return R.error("商品单价不能为0");
+            }
+            //更新购物车表
+            FsStoreCart storeCart = new FsStoreCart();
+            storeCart.setId(vo.getId());
+            storeCart.setChangePrice(price);
+            cartMapper.updateFsStoreCart(storeCart);
+            //计算总价
+            totalMoney=totalMoney.add(price.multiply(new BigDecimal(vo.getCartNum().toString())));
+        }
+
+        redisCache.setCacheObject("createOrderMoney:"+createOrderKey, totalMoney, 24, TimeUnit.HOURS);
+        //更新redis的购物车明细
+        redisCache.setCacheObject("orderCarts:" + createOrderKey,carts,24, TimeUnit.HOURS);
+
+        return R.ok();
+    }
+
     private FsStoreOrderCountsVO addTotal(CompanyDept companyDept, List<FsStoreOrderCountsVO> vos,boolean isEmpty) {
         FsStoreOrderCountsVO vo = new FsStoreOrderCountsVO();
         Long totalCalls = 0L;

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/vo/FsStoreCartQueryVO.java

@@ -63,5 +63,7 @@ import java.math.BigDecimal;
 
     private BigDecimal brokerageThree;
 
+    private BigDecimal changePrice;
+
 
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/vo/FsStoreOrderVO.java

@@ -242,5 +242,7 @@ public class FsStoreOrderVO implements Serializable
 
     private String orderVisit;
 
+    private String orderMedium;
+
 
 }

+ 14 - 8
fs-service-system/src/main/resources/mapper/store/FsStoreCartMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fs.store.mapper.FsStoreCartMapper">
-    
+
     <resultMap type="FsStoreCart" id="FsStoreCartResult">
         <result property="id"    column="id"    />
         <result property="userId"    column="user_id"    />
@@ -16,15 +16,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isPay"    column="is_pay"    />
         <result property="isDel"    column="is_del"    />
         <result property="isBuy"    column="is_buy"    />
+        <result property="changePrice"    column="change_price"    />
     </resultMap>
 
     <sql id="selectFsStoreCartVo">
-        select id, user_id, type, product_id, product_attr_value_id, cart_num, create_time, update_time, is_pay, is_del, is_buy from fs_store_cart
+        select id, user_id, type, product_id, product_attr_value_id, cart_num, create_time, update_time, is_pay, is_del,
+               is_buy,change_price from fs_store_cart
     </sql>
 
     <select id="selectFsStoreCartList" parameterType="FsStoreCart" resultMap="FsStoreCartResult">
         <include refid="selectFsStoreCartVo"/>
-        <where>  
+        <where>
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="type != null  and type != ''"> and type = #{type}</if>
             <if test="productId != null "> and product_id = #{productId}</if>
@@ -33,14 +35,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPay != null "> and is_pay = #{isPay}</if>
             <if test="isDel != null "> and is_del = #{isDel}</if>
             <if test="isBuy != null "> and is_buy = #{isBuy}</if>
+            <if test="changePrice != null "> and change_price = #{changePrice}</if>
         </where>
     </select>
-    
+
     <select id="selectFsStoreCartById" parameterType="Long" resultMap="FsStoreCartResult">
         <include refid="selectFsStoreCartVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertFsStoreCart" parameterType="FsStoreCart" useGeneratedKeys="true" keyProperty="id">
         insert into fs_store_cart
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -54,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPay != null">is_pay,</if>
             <if test="isDel != null">is_del,</if>
             <if test="isBuy != null">is_buy,</if>
+            <if test="changePrice != null">change_price,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="userId != null">#{userId},</if>
@@ -66,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPay != null">#{isPay},</if>
             <if test="isDel != null">#{isDel},</if>
             <if test="isBuy != null">#{isBuy},</if>
+            <if test="changePrice != null">#{changePrice},</if>
          </trim>
     </insert>
 
@@ -82,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isPay != null">is_pay = #{isPay},</if>
             <if test="isDel != null">is_del = #{isDel},</if>
             <if test="isBuy != null">is_buy = #{isBuy},</if>
+            <if test="changePrice != null">change_price = #{changePrice},</if>
         </trim>
         where id = #{id}
     </update>
@@ -91,10 +97,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteFsStoreCartByIds" parameterType="String">
-        delete from fs_store_cart where id in 
+        delete from fs_store_cart where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-    
-</mapper>
+
+</mapper>

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/CommonController.java

@@ -464,7 +464,7 @@ public class CommonController extends AppBaseController {
 		List<DictVO> storeProductPackageCate=dictDataService.selectDictDataListByType("store_product_package_cate");
 		List<DictVO> storeProductTuiCate=dictDataService.selectDictDataListByType("store_product_tui_cate");
 		List<DictVO> storeOrderType=dictDataService.selectDictDataListByType("store_order_type");
-		List<DictVO> storeOrderMedium=dictDataService.selectDictDataListByType("store_order_medium");
+		List<DictVO> storeOrderMedium=dictDataService.selectDictDataListByType("crm_customer_source");
 		return R.ok()
 				.put("storeProductPackageCate",storeProductPackageCate)
 				.put("storeAfterSalesStatus",storeAfterSalesStatus)

+ 12 - 0
fs-user-app/src/main/java/com/fs/app/controller/CompanyOrderController.java

@@ -7,6 +7,7 @@ import com.fs.company.domain.CompanyUser;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.store.domain.FsStoreOrder;
 import com.fs.store.enums.OrderLogEnum;
+import com.fs.store.param.FsStoreOrderMoneyByProductParam;
 import com.fs.store.param.FsStoreProductQueryParam;
 import com.fs.store.service.IFsStoreOrderService;
 import com.fs.store.service.IFsStoreOrderStatusService;
@@ -97,6 +98,17 @@ public class CompanyOrderController extends  AppBaseController {
         return orderService.updateSalseOrderMoney(createOrderKey,money,payAmount);
     }
 
+    @ApiOperation("商品改价")
+    @PostMapping("/updateSalesOrderMoneyByProduct")
+    public R updateSalesOrderMoneyByProduct(@RequestBody FsStoreOrderMoneyByProductParam param){
+        Long userId=redisCache.getCacheObject("company-user-token:"+param.getToken());
+        if(userId==null){
+            return R.error(403,"用户失效");
+        }
+
+        return orderService.updateSalesOrderMoneyByProduct(param);
+    }
+
 
     @ApiOperation("获取订单")
     @GetMapping("/getSalesOrder")