|
|
@@ -1,11 +1,14 @@
|
|
|
package com.fs.hisStore.controller;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
+import com.fs.common.constant.HttpStatus;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
@@ -25,10 +28,7 @@ import com.fs.framework.service.TokenService;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
import com.fs.his.service.IFsUserService;
|
|
|
import com.fs.hisStore.config.StoreConfig;
|
|
|
-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.hisStore.dto.ExpressInfoDTO;
|
|
|
import com.fs.hisStore.dto.FsStoreOrderPayDeliveryDTO;
|
|
|
import com.fs.hisStore.dto.StoreOrderProductDTO;
|
|
|
@@ -48,9 +48,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -259,6 +257,71 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
.put("auditLogs", auditLogs);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询当前用户的其余订单
|
|
|
+ * @param param 入参
|
|
|
+ * @return TableDataInfo
|
|
|
+ */
|
|
|
+ @GetMapping("/queryUserOtherOrderPage")
|
|
|
+ public TableDataInfo queryUserOtherOrderPage(FsStoreOrderScrmOtherUserOrderParam param){
|
|
|
+ int total = fsStoreOrderService.selectFsStoreOrderByUserIDexcludeCurrentOrderIdCount(param.getOrderUserId(), param.getOrderId());
|
|
|
+ if(total == 0){
|
|
|
+ return new TableDataInfo(null, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算分页参数
|
|
|
+ Map<String, Integer> pageMap = calculateLimitAndOffset(param.getPageNum(), param.getPageSize());
|
|
|
+ Integer offset = pageMap.get("offset");
|
|
|
+ Integer limit = pageMap.get("limit");
|
|
|
+
|
|
|
+ // 查找订单,排除当前订单
|
|
|
+ List<FsStoreOrderScrm> orderList = fsStoreOrderService.selectFsStoreOrderByUserIDexcludeCurrentOrderId(
|
|
|
+ param.getOrderUserId(), param.getOrderId(), offset, limit);
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(orderList)) {
|
|
|
+ return new TableDataInfo(Collections.emptyList(), 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量获取所有涉及的销售人员信息
|
|
|
+ Set<Long> companyUserIds = orderList.stream()
|
|
|
+ .map(FsStoreOrderScrm::getCompanyUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ Map<Long, String> companyUserMap;
|
|
|
+ if (!companyUserIds.isEmpty()) {
|
|
|
+ List<CompanyUser> companyUsers = companyUserService.selectCompanyUserByIds(companyUserIds);
|
|
|
+ companyUserMap = companyUsers.stream()
|
|
|
+ .collect(Collectors.toMap(CompanyUser::getUserId, CompanyUser::getNickName));
|
|
|
+ } else {
|
|
|
+ companyUserMap = new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建返回结果
|
|
|
+ List<FsStoreOrderScrmOtherUserOrderVO> resultList = orderList.stream()
|
|
|
+ .map(order -> {
|
|
|
+ FsStoreOrderScrmOtherUserOrderVO vo = new FsStoreOrderScrmOtherUserOrderVO();
|
|
|
+ vo.setOrderId(order.getId());
|
|
|
+ vo.setOrderCode(order.getOrderCode());
|
|
|
+ vo.setOrderCreateTime(order.getCreateTime());
|
|
|
+ vo.setOrderType(order.getOrderType());
|
|
|
+ vo.setOrderMoney(order.getPayPrice().add(order.getPayDelivery()));
|
|
|
+ vo.setOrderPayDelivery(order.getPayDelivery());
|
|
|
+ vo.setOrderStatus(order.getStatus());
|
|
|
+
|
|
|
+ // 从缓存中获取销售人员姓名
|
|
|
+ if (order.getCompanyUserId() != null) {
|
|
|
+ vo.setOrderCompanyUserName(companyUserMap.get(order.getCompanyUserId()));
|
|
|
+ }
|
|
|
+ vo.setOrderItemJson(order.getItemJson());
|
|
|
+ return vo;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ return new TableDataInfo(resultList, total);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@GetMapping(value = "/queryAddress/{id}")
|
|
|
@PreAuthorize("@ss.hasPermi('store:storeOrder:queryAddress')")
|
|
|
public R getAddress(@PathVariable("id") Long id)
|