浏览代码

1、库存退回问题处理
2、新增新商城对接接口

yys 3 周之前
父节点
当前提交
3944e53d74

+ 5 - 2
fs-company-app/src/main/java/com/fs/app/controller/FsUserController.java

@@ -299,11 +299,14 @@ public class FsUserController extends AppBaseController {
     @ApiOperation("修改用户标签")
     @PostMapping("/changeUserTags")
     public ResponseResult<Object> changeUserTags(@Valid @RequestBody FsUserPageListParam param) {
-        log.debug("修改用户标签 param:{}", JSON.toJSONString(param));
+        log.info("修改用户标签 param:{}", JSON.toJSONString(param));
         if (param.getCompanyUserId() == null) {
-            param.setCompanyUserId(getUserId());
+            param.setUserId(Long.valueOf(getUserId()));
         }
         if (CollectionUtils.isEmpty(param.getUserCompanyUserIds())) {
+            if (ObjectUtil.isNotEmpty(param.getUserId())) {
+                return ResponseResult.fail(500,"数据有误!请选择条件。");
+            }
             List<Long> list = userCompanyUserService.selectIdListByCompanyUserId(param);
             param.setUserCompanyUserIds(list);
         }

+ 9 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserAddressScrmMapper.java

@@ -49,7 +49,7 @@ public interface FsUserAddressScrmMapper
      */
     public int updateFsUserAddress(FsUserAddressScrm fsUserAddress);
 
-    /**
+        /**
      * 删除用户地址
      *
      * @param id 用户地址ID
@@ -76,4 +76,12 @@ public interface FsUserAddressScrmMapper
     @Select("select * from fs_user_address where user_id=#{uid} and is_default=1 and is_del=0 limit 1")
     @DataSource(DataSourceType.SLAVE)
     FsUserAddress selectFsUserAddressByDefault(long userId);
+
+    /**
+     * 修改该用户的用户默认地址
+     *
+     * @param userId
+     * @return
+     */
+    int updateByUserId(Long userId);
 }

+ 36 - 4
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreOrderScrmService.java

@@ -18,10 +18,7 @@ import com.fs.his.param.FsIntegralOrderDoPayParam;
 import com.fs.his.param.FsStoreOrderSalesParam;
 import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
 import com.fs.his.vo.FsStoreOrderExcelVO;
-import com.fs.hisStore.domain.FsStoreOrderItemScrm;
-import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
-import com.fs.hisStore.domain.FsStoreOrderScrm;
-import com.fs.hisStore.domain.FsStorePaymentScrm;
+import com.fs.hisStore.domain.*;
 import com.fs.hisStore.dto.ExpressNotifyDTO;
 import com.fs.hisStore.dto.ExpressResultDTO;
 import com.fs.hisStore.dto.FsStoreOrderComputeDTO;
@@ -369,4 +366,39 @@ public interface IFsStoreOrderScrmService
     int updateStoreOrderItemJson(Long orderId,Integer backendEditProductType);
 
     R payment(FsIntegralOrderDoPayParam param, PaymentMethodEnum paymentMethodEnum);
+
+
+    /**
+     * 创建制单收货地址
+     *
+     * @param orderKey
+     * @param fsUserAddressScrm
+     * @return
+     */
+    R createAddress(String orderKey, FsUserAddressScrm fsUserAddressScrm);
+
+    /**
+     * 查询制单收货地址
+     *
+     * @param orderKey
+     * @return
+     */
+    R getAddress(String orderKey);
+
+    /**
+     * 修改制单收货地址,增加到用户默认地址上
+     *
+     * @param orderKey
+     * @param userId
+     * @return
+     */
+    R updateAddress(String orderKey, Long userId);
+
+    /**
+     * 查询订单状态数量
+     *
+     * @param type
+     * @return
+     */
+    R selectOrderCount(Integer type,Long userId);
 }

+ 112 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -172,6 +172,8 @@ import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import static com.fs.common.utils.SecurityUtils.getUserId;
+import static com.fs.common.utils.SecurityUtils.getUsername;
 import static com.fs.his.utils.PhoneUtil.decryptPhone;
 import static com.fs.hisStore.constants.StoreConstants.DELIVERY;
 
@@ -1109,6 +1111,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 FsStoreOrderItemScrm item = new FsStoreOrderItemScrm();
                 item.setOrderId(storeOrder.getId());
                 item.setOrderCode(orderSn);
+                item.setProductAttrValueId(vo.getProductAttrValueId());
                 item.setCartId(vo.getId());
                 item.setProductId(vo.getProductId());
                 item.setJsonInfo(JSONUtil.toJsonStr(fsStoreCartDTO));
@@ -1848,6 +1851,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
                 item.setOrderCode(orderSn);
                 item.setCartId(vo.getId());
                 item.setProductId(vo.getProductId());
+                item.setProductAttrValueId(vo.getProductAttrValueId());
                 item.setJsonInfo(JSONUtil.toJsonStr(fsStoreCartDTO));
                 item.setNum(vo.getCartNum());
                 item.setIsAfterSales(0);
@@ -5917,4 +5921,112 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         }
         return payOrderParam;
     }
+
+
+
+    @Override
+    public R createAddress(String orderKey, FsUserAddressScrm fsUserAddressScrm) {
+        fsUserAddressScrm.setIsDefault(1);
+//        fsUserAddressScrm.setCreateBy(getUsername());
+        fsUserAddressScrm.setCreateTime(new Date());
+         redisCache.setCacheObject("createAddressKey:" + orderKey, fsUserAddressScrm, 24, TimeUnit.HOURS);
+        return R.ok().put("orderKey",orderKey).put("fsUserAddressScrm",fsUserAddressScrm);
+    }
+
+    @Override
+    public R getAddress(String orderKey) {
+        // 参数校验
+        if (orderKey == null || orderKey.isEmpty()) {
+            return R.error("订单标识不能为空");
+        }
+
+        try {
+            // 从Redis获取缓存对象
+            String cacheKey = "createAddressKey:" + orderKey;
+            FsUserAddressScrm fsUserAddressScrm = redisCache.getCacheObject(cacheKey);
+
+            // 空值检查
+            if (ObjectUtil.isNotEmpty(fsUserAddressScrm)) {
+                return R.ok().put("data", fsUserAddressScrm);
+            } else {
+                return R.error("地址信息不存在或已过期,请重新创建");
+            }
+
+        } catch (Exception e) {
+            // 记录异常日志
+            log.error("获取地址信息异常, orderKey: {}", orderKey, e);
+            return R.error("系统异常,请稍后重试");
+        }
+    }
+
+    @Override
+    public R updateAddress(String orderKey, Long userId) {
+        // 参数校验
+        if (orderKey == null || orderKey.isEmpty() || userId == null) {
+            return R.error("参数不能为空");
+        }
+
+        try {
+            // 更新用户地址
+            int update = userAddressMapper.updateByUserId(userId);
+
+            if (update > 0) {
+                // 从Redis获取缓存对象
+                String cacheKey = "createAddressKey:" + orderKey;
+                FsUserAddressScrm fsUserAddressScrm = redisCache.getCacheObject(cacheKey);
+
+                // 空值检查
+                if (fsUserAddressScrm == null) {
+                    return R.error("缓存数据不存在或已过期");
+                }
+
+                // 设置属性并插入
+                fsUserAddressScrm.setUserId(userId);
+
+                int insertResult = userAddressMapper.insertFsUserAddress(fsUserAddressScrm);
+
+                if (insertResult > 0) {
+                    // 可选: 插入成功后删除缓存
+                    // redisCache.deleteObject(cacheKey);
+                    return R.ok("地址更新成功").put("data",fsUserAddressScrm);
+                } else {
+                    return R.error("地址插入失败");
+                }
+            }
+
+            return R.error("更新失败");
+
+        } catch (Exception e) {
+            // 记录异常日志
+            log.error("更新地址异常, orderKey: {}, userId: {}", orderKey, userId, e);
+            return R.error("系统异常,请稍后重试");
+        }
+    }
+
+    /**
+     * 查询订单数量统计
+     * @param type 类型:1-仅查询待发货和待收货;其他-查询全部状态
+     * @param userId 用户ID
+     * @return 订单统计结果
+     */
+    @Override
+    public R selectOrderCount(Integer type, Long userId) {
+        OrderCountVO vo = new OrderCountVO();
+
+        if (ObjectUtil.isNotEmpty(type) && type.equals(1)) {
+            // 查询待发货和待收货
+            vo.setUnshippedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 1));
+            vo.setUnreceivedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 2));
+        } else {
+            // 查询全部订单状态统计
+            vo.setUnpaidCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 0));
+            vo.setUnshippedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 1));
+            vo.setUnreceivedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 2));
+            vo.setCompletedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, 3));
+            vo.setRefundingCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, -1));
+            vo.setRefundedCount(fsStoreOrderMapper.selectFsStoreOrderCount(userId, -2));
+        }
+        return R.ok().put("data",vo);
+    }
+
 }

+ 22 - 0
fs-service/src/main/java/com/fs/hisStore/vo/OrderCountVO.java

@@ -0,0 +1,22 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+/**
+ * 订单统计VO
+ */
+@Data
+public class OrderCountVO {
+    /** 待付款数量 */
+    private Integer unpaidCount;
+    /** 待发货数量 */
+    private Integer unshippedCount;
+    /** 待收货数量 */
+    private Integer unreceivedCount;
+    /** 已完成数量 */
+    private Integer completedCount;
+    /** 退款中数量 */
+    private Integer refundingCount;
+    /** 已退款数量 */
+    private Integer refundedCount;
+}

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

@@ -14,10 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="num"    column="num"    />
         <result property="isAfterSales"    column="is_after_sales"    />
         <result property="isPrescribe"    column="is_prescribe"    />
+        <result property="productAttrValueId"    column="product_attr_value_id"    />
     </resultMap>
 
     <sql id="selectFsStoreOrderItemVo">
-        select item_id, order_id, order_code, cart_id, product_id, json_info, num, is_after_sales,is_prescribe from fs_store_order_item_scrm
+        select item_id, order_id, order_code,product_attr_value_id, cart_id, product_id, json_info, num, is_after_sales,is_prescribe from fs_store_order_item_scrm
     </sql>
 
     <select id="selectFsStoreOrderItemList" parameterType="FsStoreOrderItemScrm" resultMap="FsStoreOrderItemResult">
@@ -31,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null "> and num = #{num}</if>
             <if test="isAfterSales != null "> and is_after_sales = #{isAfterSales}</if>
             <if test="isPrescribe != null "> and is_prescribe = #{isPrescribe}</if>
+            <if test="productAttrValueId != null "> and product_attr_value_id = #{productAttrValueId}</if>
         </where>
     </select>
 
@@ -56,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null">num,</if>
             <if test="isAfterSales != null">is_after_sales,</if>
             <if test="isPrescribe != null">is_prescribe,</if>
+            <if test="productAttrValueId != null">product_attr_value_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderId != null">#{orderId},</if>
@@ -66,6 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null">#{num},</if>
             <if test="isAfterSales != null">#{isAfterSales},</if>
             <if test="isPrescribe != null">#{isPrescribe},</if>
+            <if test="productAttrValueId != null">#{productAttrValueId},</if>
+
          </trim>
     </insert>
 
@@ -80,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="num != null">num = #{num},</if>
             <if test="isAfterSales != null">is_after_sales = #{isAfterSales},</if>
             <if test="isPrescribe != null">is_prescribe = #{isPrescribe},</if>
+            <if test="productAttrValueId != null">product_attr_value_id = #{productAttrValueId},</if>
         </trim>
         where item_id = #{itemId}
     </update>
@@ -100,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         t1.order_id,
         t1.order_code,
         t1.json_info,
+        t1.product_attr_value_id,
         t2.cost,
         t3.cate_name
         from fs_store_order_item_scrm t1

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

@@ -129,4 +129,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </update>
 
+
+    <update id="updateByUserId" parameterType="Long">
+        update fs_user_address
+        set is_default = 0,
+            update_time = NOW()
+        where user_id = #{userId}
+          and is_default = 1
+    </update>
 </mapper>

+ 52 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/CompanyOrderNewScrmController.java

@@ -0,0 +1,52 @@
+package com.fs.app.controller.store;
+
+import com.fs.app.annotation.Login;
+import com.fs.app.controller.AppBaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.domain.R;
+import com.fs.company.domain.CompanyUser;
+import com.fs.hisStore.domain.FsUserAddressScrm;
+import com.fs.hisStore.service.IFsStoreOrderScrmService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+@Api("销售订单")
+@RestController
+@RequestMapping(value="/store/app/companyOrderNew")
+public class CompanyOrderNewScrmController extends AppBaseController {
+
+    @Autowired
+    private IFsStoreOrderScrmService orderService;
+    @Login
+    @ApiOperation("制单创建收货地址")
+    @PostMapping("/createAddress/{orderKey}")
+    public R createAddress(@PathVariable("orderKey")String orderKey,@RequestBody FsUserAddressScrm fsUserAddressScrm){
+        return orderService.createAddress(orderKey,fsUserAddressScrm);
+    }
+
+    @Login
+    @ApiOperation("查询制单收货地址")
+    @GetMapping("/createAddress")
+    public R getAddress(String orderKey){
+        return orderService.getAddress(orderKey);
+    }
+
+    @Login
+    @ApiOperation("修改默认制单收货地址")
+    @PostMapping("/updateAddress")
+    public R updateAddress(String orderKey){
+        return orderService.updateAddress(orderKey,Long.valueOf(getUserId()));
+    }
+
+
+    @Login
+    @ApiOperation("查询订单数量")
+    @PostMapping("/selectOrderCount")
+    public R selectOrderCount(Integer type){
+        return orderService.selectOrderCount(type,Long.valueOf(getUserId()));
+    }
+}