فهرست منبع

feat:自提订单-核销功能

caoliqin 2 هفته پیش
والد
کامیت
69658869b7

+ 16 - 1
fs-company/src/main/java/com/fs/hisStore/controller/FsStoreOrderScrmController.java

@@ -115,7 +115,8 @@ public class FsStoreOrderScrmController extends BaseController
     private IFsUserCourseVideoService fsUserCourseVideoService;
     @Autowired
     private FsStoreOrderScrmMapper fsStoreOrderMapper;
-
+    @Autowired
+    private IFsStoreOrderPickService fsStoreOrderPickService;
     /**
      * 查询订单列表
      */
@@ -718,4 +719,18 @@ public class FsStoreOrderScrmController extends BaseController
             param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
         }
     }
+
+    /**
+     * 销售核销自提订单
+     */
+    @PreAuthorize("@ss.hasPermi('store:storeOrder:redeem')")
+    @Log(title = "商品自提订单-销售核销", businessType = BusinessType.UPDATE)
+    @PostMapping("/redeem")
+    public R redeem(@Validated @RequestBody FsStoreOrderPickRedeemParam param)
+    {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setRedeemedUserId(loginUser.getUser().getUserId());
+        return fsStoreOrderPickService.redeemFsStoreOrderPick(null, param);
+    }
+
 }

+ 19 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStoreOrderPickRedeemParam.java

@@ -0,0 +1,19 @@
+package com.fs.hisStore.param;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class FsStoreOrderPickRedeemParam {
+    @NotNull(message = "订单id不能为空")
+    private Long orderId;
+
+    @NotNull(message = "核销人员id不能为空")
+    private Long redeemedUserId;
+
+    /**
+     * 取消订单说明
+     */
+    private String cancelExplain;
+}

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

@@ -3,12 +3,12 @@ package com.fs.hisStore.service;
 import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.common.core.domain.R;
-import com.fs.his.param.FsIntegralOrderDoPayParam;
 import com.fs.hisStore.domain.FsStoreOrderPick;
 import com.fs.hisStore.param.FsStoreOrderPickAddParam;
 import com.fs.hisStore.param.FsStoreOrderPickComputeParam;
 import com.fs.hisStore.param.FsStoreOrderPickPayParam;
 import com.fs.hisStore.param.FsStoreOrderPickPaymentParam;
+import com.fs.hisStore.param.FsStoreOrderPickRedeemParam;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -110,4 +110,20 @@ public interface IFsStoreOrderPickService extends IService<FsStoreOrderPick>{
      * 自提订单详情
      */
     R getFsStoreOrderPickDetail(Long userId, Long orderId);
+
+    /**
+     * 核销自提订单
+     * @param userId 用户id
+     * @param param 订单信息入参
+     * @return
+     */
+    R redeemFsStoreOrderPick(Long userId, FsStoreOrderPickRedeemParam param);
+
+    /**
+     * 取消核销自提订单
+     * @param userId 用户id
+     * @param param 订单信息入参
+     * @return
+     */
+    R cancelRedeemOrderPick(Long userId, FsStoreOrderPickRedeemParam param);
 }

+ 85 - 10
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderPickServiceImpl.java

@@ -21,7 +21,6 @@ import com.fs.his.domain.FsPayConfig;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.MerchantAppConfig;
 import com.fs.his.domain.FsUserWx;
-import com.fs.his.param.FsIntegralOrderDoPayParam;
 import com.fs.his.mapper.FsUserWxMapper;
 import com.fs.his.mapper.MerchantAppConfigMapper;
 import com.fs.his.service.IFsUserService;
@@ -32,6 +31,7 @@ import com.fs.hisStore.domain.FsStoreOrderPick;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.domain.FsStoreProductScrm;
+import com.fs.hisStore.domain.FsStoreRedeemedRecord;
 import com.fs.hisStore.domain.FsUserAddressScrm;
 import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.mapper.FsStorePaymentScrmMapper;
@@ -43,11 +43,12 @@ import com.fs.hisStore.param.FsStoreOrderPickAddParam;
 import com.fs.hisStore.param.FsStoreOrderPickComputeParam;
 import com.fs.hisStore.param.FsStoreOrderPickPayParam;
 import com.fs.hisStore.param.FsStoreOrderPickPaymentParam;
+import com.fs.hisStore.param.FsStoreOrderPickRedeemParam;
 import com.fs.hisStore.service.IFsStoreOrderPickService;
+import com.fs.hisStore.service.IFsStoreRedeemedRecordService;
 import com.fs.hisStore.service.IFsStoreOrderScrmService;
 import com.fs.hisStore.service.IFsStoreProductScrmService;
 import com.fs.hisStore.service.IFsUserScrmService;
-import com.fs.hisStore.vo.FSUserVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
 import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
@@ -122,6 +123,8 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
     private IFsUserService userService;
     @Autowired
     private WxPayProperties wxPayProperties;
+    @Autowired
+    private IFsStoreRedeemedRecordService fsStoreRedeemedRecordService;
 
     /**
      * 查询自提商品订单
@@ -202,7 +205,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
             return R.error("用户不存在");
         }
         FsStoreProductScrm product = fsStoreProductScrmService.selectFsStoreProductById(param.getProductId());
-        if (product == null || Integer.valueOf(1).equals(product.getIsDel())) {
+        if (product == null || 1 == product.getIsDel()) {
             return R.error("商品不存在");
         }
         String orderCode = OrderCodeUtils.getOrderSn();
@@ -229,9 +232,9 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
         order.setIsDel(0);
         order.setIsSysDel(0);
         Integer productShippingType = product.getShippingType();
-        if (Integer.valueOf(1).equals(productShippingType)) {
+        if (1 == productShippingType) {
             order.setShippingType(2);
-        } else if (Integer.valueOf(2).equals(productShippingType)) {
+        } else if (2 == productShippingType) {
             order.setShippingType(1);
         } else {
             order.setShippingType(2);
@@ -283,7 +286,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
             return R.error("订单号不能为空");
         }
         FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
-        if (order == null || !userId.equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
+        if (order == null || !userId.equals(order.getUserId()) || 1 != order.getIsPickup()) {
             return R.error("订单不存在");
         }
         Map<String, Object> moneys = computeOrderMoney(order.getTotalPrice(), param);
@@ -322,6 +325,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public R payFsStoreOrderPick(Long userId, FsStoreOrderPickPayParam param) {
         if (param == null || param.getOrderId() == null) {
             return R.error("订单号不能为空");
@@ -330,7 +334,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
             return R.error("非法操作");
         }
         FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
-        if (order == null || !userId.equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
+        if (order == null || !userId.equals(order.getUserId()) || 1 != order.getIsPickup()) {
             return R.error("订单不存在");
         }
         // 状态必须要是待支付
@@ -374,7 +378,7 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
             return R.error("参数错误");
         }
         FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
-        if (order == null || !param.getUserId().equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
+        if (order == null || !param.getUserId().equals(order.getUserId()) || 1 != order.getIsPickup()) {
             return R.error("订单不存在");
         }
         if (!Integer.valueOf(0).equals(order.getStatus())) {
@@ -613,19 +617,90 @@ public class FsStoreOrderPickServiceImpl extends ServiceImpl<FsStoreOrderPickMap
     @Override
     public R getFsStoreOrderPickDetail(Long userId, Long orderId) {
         FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(orderId);
-        if (order == null || !userId.equals(order.getUserId()) || !Integer.valueOf(1).equals(order.getIsPickup())) {
+        if (order == null || !userId.equals(order.getUserId()) || 1 != order.getIsPickup()) {
             return R.error("订单不存在");
         }
         List<FsStoreOrderItemVO> items = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemListByOrderId(orderId);
         return R.ok().put("order", order).put("items", items);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R redeemFsStoreOrderPick(Long userId, FsStoreOrderPickRedeemParam param) {
+        FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
+        if (order == null || 1 != order.getIsPickup()) {
+            return R.error("订单不存在");
+        }
+        if (1 != order.getRedeemedStatus()) {
+            return R.error("非法操作");
+        }
+        FsStoreOrderItemScrm itemQuery = new FsStoreOrderItemScrm();
+        itemQuery.setOrderId(order.getId());
+        List<FsStoreOrderItemScrm> orderItems = fsStoreOrderItemScrmMapper.selectFsStoreOrderItemList(itemQuery);
+        if (orderItems == null || orderItems.isEmpty()) {
+            return R.ok().put("data", false);
+        }
+        for (FsStoreOrderItemScrm orderItem : orderItems) {
+            FsStoreProductScrm product = fsStoreProductScrmService.selectFsStoreProductById(orderItem.getProductId());
+            if (product == null || 1 != product.getShippingType()) {
+                return R.error("非自提订单不允许核销");
+            }
+        }
+        Date now = DateUtils.getNowDate();
+        FsStoreRedeemedRecord record = new FsStoreRedeemedRecord();
+        record.setUserId(order.getUserId());
+        record.setOrderId(order.getId());
+        record.setOrderCode(order.getOrderCode());
+        record.setRedeemedTime(now);
+        record.setCompanyUserId(order.getCompanyUserId());
+        record.setCompanyId(order.getCompanyId());
+        record.setRedeemedUserId(param.getRedeemedUserId().toString());
+        record.setStatus(1);
+        int insertRows = fsStoreRedeemedRecordService.insertFsStoreRedeemedRecord(record);
+        if (insertRows <= 0) {
+            return R.error("核销失败");
+        }
+        FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
+        updateOrder.setId(order.getId());
+        updateOrder.setRedeemedTime(now);
+        updateOrder.setRedeemedStatus(2);
+        updateOrder.setRedeemedId(record.getId());
+        updateOrder.setUpdateTime(now);
+        fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
+        return R.ok("核销成功");
+    }
+
+    @Override
+    public R cancelRedeemOrderPick(Long userId, FsStoreOrderPickRedeemParam param) {
+        FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(param.getOrderId());
+        if (order == null || 1 != order.getIsPickup()) {
+            return R.error("订单不存在");
+        }
+        if (3 == order.getRedeemedStatus()) {
+            return R.error("订单已取消核销,请勿重复操作");
+        }
+        if (1 != order.getRedeemedStatus()) {
+            return R.error("当前订单状态非待核销");
+        }
+        FsStoreOrderScrm updateOrder = new FsStoreOrderScrm();
+        updateOrder.setId(order.getId());
+        updateOrder.setRedeemedStatus(3);
+        updateOrder.setCancelExplain(param.getCancelExplain());
+        updateOrder.setCancelTime(DateUtils.getNowDate());
+        updateOrder.setUpdateTime(DateUtils.getNowDate());
+        int updateRows = fsStoreOrderScrmMapper.updateFsStoreOrder(updateOrder);
+        if (updateRows <= 0) {
+            return R.error("取消核销失败");
+        }
+        return R.ok("取消核销成功");
+    }
+
     private R buildPickOrderPreview(FsStoreOrderPickAddParam param) {
         if (param == null || param.getUserId() == null || param.getProductId() == null) {
             return R.error("参数错误");
         }
         FsStoreProductScrm product = fsStoreProductScrmService.selectFsStoreProductById(param.getProductId());
-        if (product == null || Integer.valueOf(1).equals(product.getIsDel())) {
+        if (product == null || 1 == product.getIsDel()) {
             return R.error("商品不存在");
         }
         BigDecimal price = product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();

+ 20 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/FsStoreOrderPickController.java

@@ -113,4 +113,24 @@ public class FsStoreOrderPickController extends AppBaseController
         return fsStoreOrderPickService.getFsStoreOrderPickDetail(Long.parseLong(getUserId()), orderId);
     }
 
+    /**
+     * 核销自提订单
+     */
+    @Login
+    @PostMapping("/redeem")
+    public R redeem(@Validated @RequestBody FsStoreOrderPickRedeemParam param)
+    {
+        return fsStoreOrderPickService.redeemFsStoreOrderPick(Long.parseLong(getUserId()), param);
+    }
+
+    /**
+     * 取消核销自提订单
+     */
+    @Login
+    @PostMapping("/cancelRedeem")
+    public R cancelRedeem(@Validated @RequestBody FsStoreOrderPickRedeemParam param)
+    {
+        return fsStoreOrderPickService.cancelRedeemOrderPick(Long.parseLong(getUserId()), param);
+    }
+
 }