Commit 456bf364 by guojx

竞赛单项和赛区接口

parent a9cc3de4
......@@ -6,6 +6,8 @@ import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DataApiUtils;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalVar;
......@@ -59,6 +61,8 @@ public class DataController {
private EnterpriseChannelApiService enterpriseChannelApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private ClerkService clerkService;
private String isProd() {
Config config = ConfigService.getConfig("COMMON.gic-properties");
......@@ -67,6 +71,96 @@ public class DataController {
}
/**
* 获取销售和会员的导购列表数据
* 返回字段具体看数据组接口文档:http://yapi.gicdev.com/project/5177/interface/api/179038
* http://yapi.gicdev.com/project/5177/interface/api/179362
* @param qo
* @return
*/
@RequestMapping(value = "list-clerk-data")
@ResponseBody
public RestResponse listClerkData(@RequestBody ClerkListQO qo) {
String params = qo.getParams();
JSONObject jsonObject = JSONObject.parseObject(params);
String enterpriseId = jsonObject.getString("enterpriseId");
String storeId = jsonObject.getString("storeId");
if (StringUtils.isBlank(enterpriseId) || StringUtils.isBlank(storeId)) {
return RestResponse.failure("-1", "企业id或者门店id为空");
}
List<String> deleteList = new ArrayList<>();
List<String> normalList = new ArrayList<>();
List<String> allList = new ArrayList<>();
List<ClerkListDTO> clerkList = clerkService.getClerkByStoreIdOfAllStatus(enterpriseId, storeId);
if (CollectionUtils.isNotEmpty(clerkList)) {
for (ClerkListDTO dto : clerkList) {
Integer status = dto.getStatus();
allList.add(dto.getClerkId());
if (status != null && status == 0) {
deleteList.add(dto.getClerkId());
} else {
normalList.add(dto.getClerkId());
}
}
}
if (CollectionUtils.isEmpty(deleteList)) {
deleteList.add("no_delete_clerk_id");
}
if (CollectionUtils.isEmpty(normalList)) {
deleteList.add("no_normal_clerk_id");
}
if (CollectionUtils.isEmpty(allList)) {
deleteList.add("no_clerk_id");
}
Integer clerkType = qo.getClerkType();
boolean isSale = clerkType == 1;
Integer pageNum = jsonObject.getInteger("pageNum");
String apolloKey = isSale ? "data_sales_perf_anal_cont_clerk_group" : "data_mbr_scale_stat_clerk_overview";
boolean isFirstPage = pageNum == 1;
if (isSale) {
jsonObject.put("storeGroup", 9);
} else {
jsonObject.put("groupType", 9);
}
jsonObject.put("clerkId", normalList.stream().collect(Collectors.joining(",")));
Map<String, Object> res = DataApiUtils.http(jsonObject.toJSONString(), apolloKey);
Page page = DataApiUtils.getPageData(res);
List<JSONObject> pageList = DataApiUtils.getPageList(res);
if (CollectionUtils.isEmpty(pageList)) {
pageList = new ArrayList<>();
}
if (isFirstPage) {
if (isSale) {
jsonObject.put("storeGroup", 7);
} else {
jsonObject.put("groupType", 8);
}
jsonObject.put("clerkId", allList.stream().collect(Collectors.joining(",")));
JSONObject total = getTotalJson(jsonObject, apolloKey);
if (total != null) {
pageList.add(total);
}
}
int totalPage = page.getTotalCount() % page.getPageSize() != 0 ? page.getTotalCount() / page.getPageSize() + 1 : page.getTotalCount() / page.getPageSize();
boolean isLastPage = totalPage == pageNum;
if (isLastPage) {
// 最后一页添加离职导购数据
jsonObject.put("clerkId", deleteList.stream().collect(Collectors.joining(",")));
if (isSale) {
jsonObject.put("storeGroup", 7);
} else {
jsonObject.put("groupType", 8);
}
JSONObject deleteTotal = getTotalJson(jsonObject, apolloKey);
if (deleteTotal != null) {
pageList.add(deleteTotal);
}
}
return RestResponse.successResult(page);
}
/**
* 会员封装数据
* @param qo
* @return
......@@ -238,17 +332,7 @@ public class DataController {
String storeIdParam = jsonObject.getString("storeId");
boolean hasStoreId = StringUtils.isNotBlank(storeIdParam);
if (!hasStoreId) {
List<String> storeIdList = new ArrayList<>();
String storeId = qo.getStoreId();
if (StringUtils.isBlank(storeId)) {
storeIdList = storeAuthUtils.queryClerkStoreIds(qo.getClerkId(), qo.getWxEnterpriseId());
} else {
storeIdList.add(storeId);
}
if (CollectionUtils.isNotEmpty(storeIdList)) {
//区经有全部门店权限
jsonObject.put("storeId", storeIdList.stream().collect(Collectors.joining(",")));
}
getAuthStore(qo.getStoreId(), qo.getClerkId(), qo.getWxEnterpriseId(), jsonObject);
}
String apolloKey = qo.getApolloKey();
......
package com.gic.haoban.manage.web.qo.data;
import lombok.Data;
import java.io.Serializable;
/**
* @Author guojx
* @Date 2023/11/23 9:13
*/
@Data
public class ClerkListQO implements Serializable {
/**
* 1:销售 2:会员
*/
private Integer clerkType = 1;
/**
* 组装的参数,JSON字符串.数据组提供的yapi文档上有.
* 销售:data_sales_perf_anal_cont_clerk_group 会员:data_mbr_scale_stat_clerk_overview
* 注:门店参数storeId根据storeSelect参数计算
* params里面的销售的storeGroup字段和会员的groupType字段不需要,如果有,也是无效,后端定值覆盖
*/
private String params;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment