|
|
@@ -13,6 +13,7 @@ import com.kuaidi100.sdk.request.SubscribeReq;
|
|
|
import com.ruixuan.common.core.domain.entity.SysUser;
|
|
|
import com.ruixuan.common.utils.Check;
|
|
|
import com.ruixuan.common.utils.DateUtils;
|
|
|
+import com.ruixuan.common.utils.PageUtils;
|
|
|
import com.ruixuan.isc.entity.KuaishouItemCollectSampleExpress;
|
|
|
import com.ruixuan.isc.entity.KuaishouItemCollectSampleLog;
|
|
|
import com.ruixuan.isc.entity.KuaishouItemCollectSamples;
|
|
|
@@ -20,6 +21,7 @@ import com.ruixuan.isc.mapper.KuaishouItemCollectSamplesMapper;
|
|
|
import com.ruixuan.isc.service.IKuaishouItemCollectSamplesService;
|
|
|
import com.ruixuan.isc.service.IKuaishouPromoterService;
|
|
|
import com.ruixuan.isc.service.ISupplyChainService;
|
|
|
+import com.ruixuan.system.service.ISysDeptService;
|
|
|
import com.ruixuan.system.service.ISysUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -27,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
@@ -55,6 +58,9 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
@Autowired
|
|
|
private ISupplyChainService supplyChainService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询【请填写功能名称】
|
|
|
*
|
|
|
@@ -351,12 +357,21 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
|
|
|
@Override
|
|
|
public JSONObject getPersonalInfo(Long userId, String type) {
|
|
|
- Long collectSampleId = null;
|
|
|
- Long itemCreateId = null;
|
|
|
- if ("1".equals(type)) {
|
|
|
- collectSampleId = userId;
|
|
|
+ String roleKey = userService.getRoleKeyByUserId(String.valueOf(userId));
|
|
|
+ List<Long> userList = null;
|
|
|
+ if ("courtshipManager".equals(roleKey) || "bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
|
|
|
+ Long deptId = deptService.getDeptIdByUserId(userId);
|
|
|
+ userList = deptService.getDeptUserListByDeptId(deptId);
|
|
|
} else {
|
|
|
- itemCreateId = userId;
|
|
|
+ userList = Arrays.asList(userId);
|
|
|
+ }
|
|
|
+ int userType = 1;
|
|
|
+ if (!"1".equals(type)) {
|
|
|
+ userType = 2;
|
|
|
+ if ("supplyChainAdmin".equals(roleKey)) {
|
|
|
+ //供应链管理员查看 招商人员数据
|
|
|
+ userList = deptService.getDeptUserListByDeptId(150200L);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
@@ -366,11 +381,11 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
data.put("userName", sysUser.getNickName());
|
|
|
}
|
|
|
Integer status = 1; //待审核领样数
|
|
|
- data.put("toBeReviewed", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(collectSampleId, itemCreateId, status));
|
|
|
+ data.put("toBeReviewed", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(userList, userType, status));
|
|
|
status = 3;//待发货领样数
|
|
|
- data.put("toBeShipped", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(collectSampleId, itemCreateId, status));
|
|
|
- status = 5;//待上传作业数
|
|
|
- data.put("toBeUploaded", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(collectSampleId, itemCreateId, status));
|
|
|
+ data.put("toBeShipped", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(userList, userType, status));
|
|
|
+ status = 6;//作业上传成功待招商审核
|
|
|
+ data.put("toBeUploaded", kuaishouItemCollectSamplesMapper.getSampleCountByUserId(userList, userType, status));
|
|
|
returnJson.put("code", 0);
|
|
|
returnJson.put("message", "调用成功");
|
|
|
returnJson.put("data", data);
|
|
|
@@ -379,21 +394,34 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
|
|
|
@Override
|
|
|
public JSONObject getOrderData(Long userId, String startDate, String endDate, String type) {
|
|
|
+ String roleKey = userService.getRoleKeyByUserId(String.valueOf(userId));
|
|
|
+ List<Long> userList = null;
|
|
|
+ if ("courtshipManager".equals(roleKey) || "bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
|
|
|
+ Long deptId = deptService.getDeptIdByUserId(userId);
|
|
|
+ userList = deptService.getDeptUserListByDeptId(deptId);
|
|
|
+ } else {
|
|
|
+ userList = Arrays.asList(userId);
|
|
|
+ }
|
|
|
+
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
returnJson.put("code", 0);
|
|
|
returnJson.put("message", "调用成功");
|
|
|
if ("1".equals(type)) {
|
|
|
- returnJson.put("data", getgetOrderDataByChannel(userId, startDate, endDate));
|
|
|
+ returnJson.put("data", getgetOrderDataByChannel(userList, startDate, endDate));
|
|
|
} else {
|
|
|
- returnJson.put("data", getgetOrderDataByAttractInvestment(userId, startDate, endDate));
|
|
|
+ if ("supplyChainAdmin".equals(roleKey)) {
|
|
|
+ //供应链管理员查看 招商人员数据
|
|
|
+ userList = deptService.getDeptUserListByDeptId(150200L);
|
|
|
+ }
|
|
|
+ returnJson.put("data", getgetOrderDataByAttractInvestment(userList, startDate, endDate));
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
//渠道数据
|
|
|
- private JSONObject getgetOrderDataByChannel(Long userId, String startDate, String endDate) {
|
|
|
+ private JSONObject getgetOrderDataByChannel(List<Long> userList, String startDate, String endDate) {
|
|
|
JSONObject data = new JSONObject();
|
|
|
- List<Long> promoterIds = promoterService.selectPromoterIdList(userId);
|
|
|
+ List<Long> promoterIds = promoterService.selectPromoterIdList(userList);
|
|
|
if (Check.isNotNull(promoterIds)) {
|
|
|
data.put("promoterCount", promoterIds.size());//达人总数
|
|
|
JSONObject Sample = kuaishouItemCollectSamplesMapper.queryTheNumberOfCompletedJobs(promoterIds, startDate, endDate);
|
|
|
@@ -449,14 +477,14 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
|
|
|
|
|
|
//招商数据
|
|
|
- private JSONObject getgetOrderDataByAttractInvestment(Long userId, String startDate, String endDate) {
|
|
|
+ private JSONObject getgetOrderDataByAttractInvestment(List<Long> userList, String startDate, String endDate) {
|
|
|
JSONObject data = new JSONObject();
|
|
|
List<Long> promoterIds = promoterService.selectPromoterIdList(null);
|
|
|
if (Check.isNotNull(promoterIds)) {
|
|
|
data.put("promoterCount", promoterIds.size());//达人总数
|
|
|
}
|
|
|
//查询登录人(创建人)的所有商品
|
|
|
- List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userId);
|
|
|
+ List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userList);
|
|
|
if (Check.isNotNull(itemIds)) {
|
|
|
JSONObject order = supplyChainService.selectOrderInfoByItemIds(itemIds, startDate, endDate);
|
|
|
data.put("sendCount", order.getInteger("sendCount"));//发货数
|
|
|
@@ -511,21 +539,40 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
|
|
|
@Override
|
|
|
public JSONObject getDataAnalysis(Long userId, String type) {
|
|
|
+ String roleKey = userService.getRoleKeyByUserId(String.valueOf(userId));
|
|
|
+ List<Long> userList = null;
|
|
|
+ if ("courtshipManager".equals(roleKey) || "bdManager".equals(roleKey) || "associationManager".equals(roleKey)) {
|
|
|
+ Long deptId = deptService.getDeptIdByUserId(userId);
|
|
|
+ userList = deptService.getDeptUserListByDeptId(deptId);
|
|
|
+ } else {
|
|
|
+ userList = Arrays.asList(userId);
|
|
|
+ }
|
|
|
+
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
returnJson.put("code", 0);
|
|
|
returnJson.put("message", "调用成功");
|
|
|
if ("1".equals(type)) {
|
|
|
- returnJson.put("data", getDataAnalysisByChannel(userId));
|
|
|
+ returnJson.put("data", getDataAnalysisByChannel(userList));
|
|
|
} else {
|
|
|
- returnJson.put("data", getDataAnalysisByAttractInvestment(userId));
|
|
|
+ if ("supplyChainAdmin".equals(roleKey)) {
|
|
|
+ //供应链管理员查看 招商人员数据
|
|
|
+ userList = deptService.getDeptUserListByDeptId(150200L);
|
|
|
+ }
|
|
|
+ returnJson.put("data", getDataAnalysisByAttractInvestment(userList));
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<JSONObject> queryProductList(Map<String, Object> map) {
|
|
|
+ PageUtils.startPage();
|
|
|
+ return kuaishouItemCollectSamplesMapper.queryProductList(map);
|
|
|
+ }
|
|
|
+
|
|
|
// 渠道—数据分析
|
|
|
- private JSONObject getDataAnalysisByChannel(Long userId) {
|
|
|
+ private JSONObject getDataAnalysisByChannel(List<Long> userList) {
|
|
|
JSONObject data = new JSONObject();
|
|
|
- List<Long> promoterIds = promoterService.selectPromoterIdList(userId);
|
|
|
+ List<Long> promoterIds = promoterService.selectPromoterIdList(userList);
|
|
|
if (Check.isNotNull(promoterIds)) {
|
|
|
//当天
|
|
|
String end = DateUtils.getNowDateStr();
|
|
|
@@ -534,7 +581,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("start", start);
|
|
|
map.put("end", end);
|
|
|
- map.put("userId", userId);
|
|
|
+ map.put("userId", userList);
|
|
|
map.put("promoterIds", promoterIds);
|
|
|
map.put("startLong", DateUtils.getStartLongTime(start));
|
|
|
map.put("endLong", DateUtils.getEndLongTime(end));
|
|
|
@@ -569,7 +616,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
data.put("orderAmountRate", amount.getString("orderAmountRate"));
|
|
|
data.put("totalRegimentalSettleAmountRate", amount.getString("totalRegimentalSettleAmountRate"));
|
|
|
}
|
|
|
- JSONObject promoter = promoterService.getgetMonthPromoterTotal(userId, start, end);
|
|
|
+ JSONObject promoter = promoterService.getgetMonthPromoterTotal(userList, start, end);
|
|
|
if (Check.isNotNull(promoter)) {
|
|
|
data.put("promoterCount", promoter.getString("count"));
|
|
|
data.put("promoterRate", promoter.getString("rate"));
|
|
|
@@ -579,10 +626,10 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
}
|
|
|
|
|
|
// 招商—数据分析
|
|
|
- private JSONObject getDataAnalysisByAttractInvestment(Long userId) {
|
|
|
+ private JSONObject getDataAnalysisByAttractInvestment(List<Long> userList) {
|
|
|
JSONObject data = new JSONObject();
|
|
|
//查询登录人(创建人)的所有商品
|
|
|
- List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userId);
|
|
|
+ List<Long> itemIds = kuaishouItemCollectSamplesMapper.getItemIdsByCreateId(userList);
|
|
|
if (Check.isNotNull(itemIds)) {
|
|
|
//当天
|
|
|
String end = DateUtils.getNowDateStr();
|
|
|
@@ -591,7 +638,6 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("start", start);
|
|
|
map.put("end", end);
|
|
|
- map.put("userId", userId);
|
|
|
map.put("itemIds", itemIds);
|
|
|
map.put("startLong", DateUtils.getStartLongTime(start));
|
|
|
map.put("toStartLong", DateUtils.getStartLongTime(end));
|