|
|
@@ -7,6 +7,7 @@ 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.FsCompanyApplication;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.constant.HttpStatus;
|
|
|
@@ -45,13 +46,16 @@ import com.fs.hisStore.dto.FsStoreOrderPayDeliveryDTO;
|
|
|
import com.fs.hisStore.dto.StoreOrderProductDTO;
|
|
|
import com.fs.hisStore.enums.OrderLogEnum;
|
|
|
import com.fs.hisStore.enums.ShipperCodeEnum;
|
|
|
+import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.hisStore.param.*;
|
|
|
import com.fs.hisStore.service.*;
|
|
|
import com.fs.hisStore.vo.*;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -109,6 +113,8 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
private IFsUserCoursePeriodService fsUserCoursePeriodService;
|
|
|
@Autowired
|
|
|
private IFsUserCourseVideoService fsUserCourseVideoService;
|
|
|
+ @Autowired
|
|
|
+ private FsStoreOrderScrmMapper fsStoreOrderMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询订单列表
|
|
|
@@ -118,7 +124,7 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
public TableDataInfo list(FsStoreOrderParam param)
|
|
|
{
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ applyCompanyDataScope(param, loginUser);
|
|
|
|
|
|
// 郑多燕需求
|
|
|
if("广州郑多燕".equals(cloudHostProper.getCompanyName())){
|
|
|
@@ -127,32 +133,14 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
if(!companyUsers.isEmpty()){
|
|
|
List<Long> companyUserIds = companyUsers.stream().map(CompanyUser::getUserId).collect(Collectors.toList());
|
|
|
param.setCompanyUserIds(companyUserIds);
|
|
|
+ param.setCompanyUserId(null);
|
|
|
} else {
|
|
|
- // 表示数据权限是本人
|
|
|
param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
}
|
|
|
}
|
|
|
startPage();
|
|
|
-
|
|
|
- String configJson = configService.selectConfigByKey("his.store");
|
|
|
- StoreConfig storeConfig = JSONUtil.toBean(configJson, StoreConfig.class);
|
|
|
- if(storeConfig != null && Boolean.TRUE.equals(storeConfig.getEnableCompanyOrderMode())){
|
|
|
- if(!"00".equals(loginUser.getUser().getUserType()) && !hasRoleKey(loginUser, "finance_order_goods")){//非管理员看见自己数据
|
|
|
- param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
- }
|
|
|
- param.setIsCompanyOrder(1);//是否销售订单
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
- param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(param.getPayTimeRange())){
|
|
|
- param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
- param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
- }
|
|
|
+ applyCompanyOrderModeIfEnabled(param);
|
|
|
+ fillListTimeRange(param);
|
|
|
List<FsStoreOrderVO> list = fsStoreOrderService.selectFsStoreOrderListVO(param);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
@@ -211,24 +199,9 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
return AjaxResult.error("请筛选数据导出");
|
|
|
}
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
- param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(param.getPayTimeRange())){
|
|
|
- param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
- param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
- }
|
|
|
- String configJson = configService.selectConfigByKey("his.store");
|
|
|
- StoreConfig storeConfig = JSONUtil.toBean(configJson, StoreConfig.class);
|
|
|
- if(storeConfig != null && Boolean.TRUE.equals(storeConfig.getEnableCompanyOrderMode())){
|
|
|
- if(!"00".equals(loginUser.getUser().getUserType()) && !hasRoleKey(loginUser, "finance_order_goods")){//非管理员看见自己数据
|
|
|
- param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
- }
|
|
|
- param.setIsCompanyOrder(1);//是否销售订单
|
|
|
- }
|
|
|
+ applyCompanyDataScope(param, loginUser);
|
|
|
+ applyCompanyOrderModeIfEnabled(param);
|
|
|
+ fillListTimeRange(param);
|
|
|
List<FsStoreOrderErpExportVO> list = fsStoreOrderService.selectFsStoreOrderListVOByExport(param);
|
|
|
//对手机号脱敏
|
|
|
if(list!=null){
|
|
|
@@ -446,6 +419,17 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
lastFourNumber = StrUtil.sub(order.getVirtualPhone(), order.getVirtualPhone().length(), -4);
|
|
|
expressInfoDTO=expressService.getExpressInfo(order.getOrderCode(),order.getDeliverySn(),order.getDeliveryId(),lastFourNumber);
|
|
|
}
|
|
|
+ if(expressInfoDTO!=null){
|
|
|
+ FsStoreOrderScrm map = new FsStoreOrderScrm();
|
|
|
+ map.setDeliveryStatus(Integer.parseInt(expressInfoDTO.getState()));
|
|
|
+ map.setId(order.getId());
|
|
|
+ map.setDeliveryType(expressInfoDTO.getStateEx());
|
|
|
+ fsStoreOrderMapper.updateFsStoreOrder(map);
|
|
|
+ //如果是正常签收,更新订单状态
|
|
|
+ if (expressInfoDTO.getState().equals("3") && (expressInfoDTO.getStateEx().equals("301") || expressInfoDTO.getStateEx().equals("302") || expressInfoDTO.getStateEx().equals("304") || expressInfoDTO.getStateEx().equals("311"))) {
|
|
|
+ fsStoreOrderService.finishOrder(order.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
return R.ok().put("data",expressInfoDTO);
|
|
|
}
|
|
|
// 原逻辑
|
|
|
@@ -538,25 +522,9 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
return AjaxResult.error("请筛选数据导出");
|
|
|
}
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
- param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
-
|
|
|
- if(!StringUtils.isEmpty(param.getCreateTimeRange())){
|
|
|
- param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(param.getPayTimeRange())){
|
|
|
- param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
- }
|
|
|
- if(!StringUtils.isEmpty(param.getDeliveryImportTimeRange())){
|
|
|
- param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
- }
|
|
|
- String configJson = configService.selectConfigByKey("his.store");
|
|
|
- StoreConfig storeConfig = JSONUtil.toBean(configJson, StoreConfig.class);
|
|
|
- if(storeConfig != null && Boolean.TRUE.equals(storeConfig.getEnableCompanyOrderMode())){
|
|
|
- if(!"00".equals(loginUser.getUser().getUserType()) && !hasRoleKey(loginUser, "finance_order_goods")){//非管理员看见自己数据
|
|
|
- param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
- }
|
|
|
- param.setIsCompanyOrder(1);//是否销售订单
|
|
|
- }
|
|
|
+ applyCompanyDataScope(param, loginUser);
|
|
|
+ applyCompanyOrderModeIfEnabled(param);
|
|
|
+ fillListTimeRange(param);
|
|
|
List<FsStoreOrderItemExportVO> list=orderItemService.selectFsStoreOrderItemListExportVO(param);
|
|
|
//对手机号脱敏
|
|
|
if(list!=null){
|
|
|
@@ -700,4 +668,34 @@ public class FsStoreOrderScrmController extends BaseController
|
|
|
}
|
|
|
return roles.stream().anyMatch(role -> roleKey.equals(role.getRoleKey()));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 销售端数据权限:限定本公司;非管理员且非财务订单角色仅看本人订单
|
|
|
+ */
|
|
|
+ private void applyCompanyDataScope(FsStoreOrderParam param, LoginUser loginUser) {
|
|
|
+ param.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
+ if (!"00".equals(loginUser.getUser().getUserType()) && !hasRoleKey(loginUser, "finance_order_goods")) {
|
|
|
+ param.setCompanyUserId(loginUser.getUser().getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void applyCompanyOrderModeIfEnabled(FsStoreOrderParam param) {
|
|
|
+ String configJson = configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig storeConfig = JSONUtil.toBean(configJson, StoreConfig.class);
|
|
|
+ if (storeConfig != null && Boolean.TRUE.equals(storeConfig.getEnableCompanyOrderMode())) {
|
|
|
+ param.setIsCompanyOrder(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillListTimeRange(FsStoreOrderParam param) {
|
|
|
+ if (!StringUtils.isEmpty(param.getCreateTimeRange())) {
|
|
|
+ param.setCreateTimeList(param.getCreateTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(param.getPayTimeRange())) {
|
|
|
+ param.setPayTimeList(param.getPayTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(param.getDeliveryImportTimeRange())) {
|
|
|
+ param.setDeliveryImportTimeList(param.getDeliveryImportTimeRange().split("--"));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|