yumeng 10 ماه پیش
والد
کامیت
6a1d4852cc

+ 563 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KwaiXiaoDianReportController.java

@@ -0,0 +1,563 @@
+package com.ruixuan.isc.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import com.ruixuan.common.constant.HttpStatus;
+import com.ruixuan.common.core.page.TableDataInfo;
+import com.ruixuan.common.utils.Check;
+import com.ruixuan.common.utils.DateUtils;
+import com.ruixuan.isc.service.IKwaiXiaoDianReportService;
+import com.ruixuan.isc.service.IKwaixiaodianItemGetService;
+import com.ruixuan.system.service.ISysDeptService;
+import com.ruixuan.system.service.ISysRoleService;
+import com.ruixuan.system.service.ISysUserService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.ruixuan.common.utils.PageUtils.startPage;
+
+@RestController
+@RequestMapping("/kwaixiaodian/report")
+public class KwaiXiaoDianReportController {
+    @Autowired
+    private IKwaiXiaoDianReportService kwaiXiaoDianReportService;
+
+    @Autowired
+    private ISysRoleService sysRoleService;
+
+    @Autowired
+    private IKwaixiaodianItemGetService kwaixiaodianItemGetService;
+
+    // 供应链盯盘数据
+    @GetMapping("/getSumInfo")
+    public JSONObject getSumInfo(Long userId, String startDate, String endDate, Long companyId) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("admin".equals(roleId)) { // 管理员查看所有
+                if (!Check.isNull(companyId)) {
+                    requestMap.put("companyId", companyId);
+                }
+            } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
+                companyId = kwaixiaodianItemGetService.getCompanyId(userId);
+                if (Check.isNull(companyId)) {
+                    throw new Exception("此用户未查询到归属公司");
+                }
+                requestMap.put("companyId", companyId);
+            } else if ("industry_sale_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
+                List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_sale".equals(roleId)) { //   销售 查看自己的数据
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 招商、采购经理角色查看部门下所有成员数据
+                List<Long> courtshipPurchaseIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(courtshipPurchaseIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 采购 招商 查看自己的数据
+                List<Long> courtshipPurchaseIds = new ArrayList<>();
+                courtshipPurchaseIds.add(userId);
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            }
+
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            JSONObject date = kwaiXiaoDianReportService.getSumInfo(requestMap);
+            returnJson.put("code", 200);
+            returnJson.put("data", date);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @GetMapping("/getMonthData")
+    public JSONObject getMonthData(Long userId, String startDate, String endDate, Long companyId) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("admin".equals(roleId)) { // 管理员查看所有
+                if (!Check.isNull(companyId)) {
+                    requestMap.put("companyId", companyId);
+                }
+            } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
+                companyId = kwaixiaodianItemGetService.getCompanyId(userId);
+                if (Check.isNull(companyId)) {
+                    throw new Exception("此用户未查询到归属公司");
+                }
+                requestMap.put("companyId", companyId);
+            } else if ("industry_sale_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
+                List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_sale".equals(roleId)) { //   销售 查看自己的数据
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 招商、采购经理角色查看部门下所有成员数据
+                List<Long> courtshipPurchaseIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(courtshipPurchaseIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 采购 招商 查看自己的数据
+                List<Long> courtshipPurchaseIds = new ArrayList<>();
+                courtshipPurchaseIds.add(userId);
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            }
+
+            String monthEndDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String monthStartDay = DateUtils.getMonthStartDay(monthEndDate);
+
+            Long monthStart = DateUtils.strDateToInt(monthStartDay);
+            Long monthEnd = DateUtils.strDateToInt(monthEndDate);
+            requestMap.put("monthStart", monthStart);
+            requestMap.put("monthEnd", monthEnd);
+            String lastMonthFirstDate = DateUtils.getLastMonthFirstDayByDate(monthEndDate);// 上个月开始时间
+            String lastMonthEndDate = DateUtils.getLastMonthNowDay(monthEndDate);// 上个月结束时间
+            requestMap.put("lastMonthStart", DateUtils.strDateToInt(lastMonthFirstDate));
+            requestMap.put("lastMonthEnd", DateUtils.strDateToInt(lastMonthEndDate));
+            JSONObject monthDate = kwaiXiaoDianReportService.getMonthInfo(requestMap);
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) { // 如果传入时间为当天,取当前月的数据
+                requestMap.put("echartStart", monthStart);
+                requestMap.put("echartEnd", monthEnd);
+            } else {
+                requestMap.put("echartStart", start);
+                requestMap.put("echartEnd", end);
+            }
+            List<JSONObject> list = kwaiXiaoDianReportService.getEchartData(requestMap);
+            monthDate.put("list", list);
+            returnJson.put("code", 200);
+            returnJson.put("data", monthDate);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @GetMapping("/getGmvHours")
+    public JSONObject getGmvHours(Long userId, Long companyId) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("admin".equals(roleId)) { // 管理员查看所有
+                if (!Check.isNull(companyId)) {
+                    requestMap.put("companyId", companyId);
+                }
+            } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
+                companyId = kwaixiaodianItemGetService.getCompanyId(userId);
+                if (Check.isNull(companyId)) {
+                    throw new Exception("此用户未查询到归属公司");
+                }
+                requestMap.put("companyId", companyId);
+            } else if ("industry_sale_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
+                List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_sale".equals(roleId)) { //   销售 查看自己的数据
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 招商、采购经理角色查看部门下所有成员数据
+                List<Long> courtshipPurchaseIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(courtshipPurchaseIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 采购 招商 查看自己的数据
+                List<Long> courtshipPurchaseIds = new ArrayList<>();
+                courtshipPurchaseIds.add(userId);
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            }
+
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            requestMap.put("date", DateUtils.strDateToInt(nowDate));
+            List<JSONObject> today = kwaiXiaoDianReportService.getGmvHours(requestMap);
+            String lastDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);  //  日期 -1
+            requestMap.put("date", DateUtils.strDateToInt(lastDate));
+            List<JSONObject> yesterday = kwaiXiaoDianReportService.getGmvHours(requestMap);
+            JSONObject data = new JSONObject();
+            data.put("today", today);
+            data.put("yesterday", yesterday);
+            returnJson.put("code", 200);
+            returnJson.put("data", data);
+            returnJson.put("success", true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @GetMapping("/getShopListData")
+    public TableDataInfo getShopListData(String startDate, String endDate, Long userId, Long companyId, Integer pageNum, Integer pageSize) {
+        TableDataInfo rspData = new TableDataInfo();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("admin".equals(roleId)) { // 管理员查看所有
+                if (!Check.isNull(companyId)) {
+                    requestMap.put("companyId", companyId);
+                }
+            } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
+                companyId = kwaixiaodianItemGetService.getCompanyId(userId);
+                if (Check.isNull(companyId)) {
+                    throw new Exception("此用户未查询到归属公司");
+                }
+                requestMap.put("companyId", companyId);
+            } else if ("industry_sale_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
+                List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_sale".equals(roleId)) { //   销售 查看自己的数据
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 招商、采购经理角色查看部门下所有成员数据
+                List<Long> courtshipPurchaseIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(courtshipPurchaseIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 采购 招商 查看自己的数据
+                List<Long> courtshipPurchaseIds = new ArrayList<>();
+                courtshipPurchaseIds.add(userId);
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(courtshipPurchaseIds);
+                requestMap.put("itemIds", itemIds);
+            }
+
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            startPage(pageNum, pageSize);
+            List<JSONObject> list = kwaiXiaoDianReportService.getShopListData(requestMap);
+            rspData.setCode(HttpStatus.SUCCESS);
+            rspData.setMsg("查询成功");
+            rspData.setRows(list);
+            rspData.setTotal(new PageInfo(list).getTotal());
+        } catch (Exception e) {
+            e.printStackTrace();
+            rspData.setCode(HttpStatus.ERROR);
+            rspData.setMsg(e.getMessage());
+        }
+        return rspData;
+    }
+
+
+    @GetMapping("/getTeamList")
+    public TableDataInfo getTeamList(String startDate, String endDate, Long userId, Long companyId, Integer pageNum, Integer pageSize) {
+        TableDataInfo rspData = new TableDataInfo();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("admin".equals(roleId)) { // 管理员查看所有
+                if (!Check.isNull(companyId)) {
+                    requestMap.put("companyId", companyId);
+                }
+
+            } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
+                companyId = kwaixiaodianItemGetService.getCompanyId(userId);
+                if (Check.isNull(companyId)) {
+                    throw new Exception("此用户未查询到归属公司");
+                }
+                requestMap.put("companyId", companyId);
+            } else if ("industry_sale_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
+                List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                requestMap.put("userIds", userIds);
+            } else if ("industry_sale".equals(roleId)) { //   销售 查看自己的数据
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                requestMap.put("userIds", userIds);
+            } else if ("industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 招商、采购经理角色查看部门下所有成员数据
+                List<Long> courtshipPurchaseIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(courtshipPurchaseIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                requestMap.put("userIds", courtshipPurchaseIds);
+            } else if ("industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 采购 招商 查看自己的数据
+                List<Long> courtshipPurchaseIds = new ArrayList<>();
+                courtshipPurchaseIds.add(userId);
+                requestMap.put("userIds", courtshipPurchaseIds);
+            }
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            startPage(pageNum, pageSize);
+            List<JSONObject> list = kwaiXiaoDianReportService.getTeamList(requestMap);
+            rspData.setCode(HttpStatus.SUCCESS);
+            rspData.setMsg("查询成功");
+            rspData.setRows(list);
+            rspData.setTotal(new PageInfo(list).getTotal());
+        } catch (Exception e) {
+            e.printStackTrace();
+            rspData.setCode(HttpStatus.ERROR);
+            rspData.setMsg(e.getMessage());
+        }
+        return rspData;
+    }
+
+
+    @GetMapping("/getTeamDetail")
+    public JSONObject getTeamDetail(String startDate, String endDate, Long userId, Integer pageNum, Integer pageSize, Long deptId, String type) {
+        JSONObject rspData = new JSONObject();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            if (Check.isNull(deptId)) {
+                throw new Exception("请传入部门ID");
+            }
+
+            if (Check.isNull(type)) {
+                throw new Exception("请传入类型");
+            }
+
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("deptId", deptId);
+            requestMap.put("type", type);
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("industry_sale".equals(roleId) || "industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { //   销售 查看自己的数据
+                requestMap.put("userId", userId);
+            }
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            List<JSONObject> list = kwaiXiaoDianReportService.getTeamDetail(requestMap);
+            rspData.put("code", 200);
+            rspData.put("message", "查询成功");
+            rspData.put("data", list);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            rspData.put("code", 500);
+            rspData.put("message", "查询失败");
+        }
+        return rspData;
+    }
+
+
+    @GetMapping("/getItemList")
+    public TableDataInfo getItemList(String startDate, String endDate, Long userId, Long companyId, Integer pageNum, Integer pageSize, Integer itemType) {
+        TableDataInfo rspData = new TableDataInfo();
+        try {
+            if (Check.isNull(userId)) {
+                throw new Exception("请传入用户ID");
+            }
+            Map<String, Object> requestMap = new HashMap<>();
+            String roleId = sysRoleService.getRoleBYUserId(userId);
+            if ("admin".equals(roleId)) { // 管理员查看所有
+                if (!Check.isNull(companyId)) {
+                    requestMap.put("companyId", companyId);
+                }
+            } else if ("industry_admin".equals(roleId)) { // 供应链管理员查看所属公司
+                companyId = kwaixiaodianItemGetService.getCompanyId(userId);
+                if (Check.isNull(companyId)) {
+                    throw new Exception("此用户未查询到归属公司");
+                }
+                requestMap.put("companyId", companyId);
+            } else if ("industry_sale_manager".equals(roleId)) { // 经理角色查看部门下所有成员数据
+                List<Long> userIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+                List<Long> itemIds = kwaixiaodianItemGetService.getItemIdsByUserIds(userIds);
+                if (Check.isNull(itemIds)) {
+                    throw new Exception("商品ID为空");
+                }
+                requestMap.put("itemIds", itemIds);
+            } else if ("industry_sale".equals(roleId)) { //   销售 查看自己的数据
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(userId);
+                if (Check.isNull(userIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+
+                requestMap.put("userIds", userIds);
+            } else if ("industry_courtship_manager".equals(roleId) || "industry_purchase_manager".equals(roleId)) { // 招商、采购经理角色查看部门下所有成员数据
+                List<Long> courtshipPurchaseIds = kwaixiaodianItemGetService.getUserIds(userId);
+                if (Check.isNull(courtshipPurchaseIds)) {
+                    throw new Exception("此用户未查询到部门成员信息");
+                }
+
+                requestMap.put("courtshipPurchaseIds", courtshipPurchaseIds);
+            } else if ("industry_purchase".equals(roleId) || "industry_courtship".equals(roleId)) { // 采购 招商 查看自己的数据
+                List<Long> courtshipPurchaseIds = new ArrayList<>();
+                courtshipPurchaseIds.add(userId);
+                requestMap.put("courtshipPurchaseIds", courtshipPurchaseIds);
+            }
+
+            if (!Check.isNull(itemType)) {
+                if (itemType != 0) {
+                    requestMap.put("itemType", itemType);
+                }
+            }
+
+            Long start = DateUtils.strDateToInt(startDate);
+            Long end = DateUtils.strDateToInt(endDate);
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(startDate), simpleDateFormat.parse(endDate));
+            String lastEndStr = DateUtils.getAnotherDay("yyyy-MM-dd", startDate, -1); // 上一时段结束日期
+            String lastStartStr = DateUtils.getAnotherDay("yyyy-MM-dd", lastEndStr, -differDay); // 上一时段开始日期
+            requestMap.put("lastEnd", DateUtils.strDateToInt(lastEndStr));
+            requestMap.put("lastStart", DateUtils.strDateToInt(lastStartStr));
+            Long nowDate = Long.valueOf(DateUtils.getNowDate("yyyyMMdd"));
+            if (start.equals(nowDate) && end.equals(nowDate)) {
+                Integer nowHour = DateUtils.getNowHour();
+                requestMap.put("nowHour", nowHour);
+            }
+            startPage(pageNum, pageSize);
+            List<JSONObject> list = kwaiXiaoDianReportService.getItemList(requestMap);
+            rspData.setCode(HttpStatus.SUCCESS);
+            rspData.setMsg("查询成功");
+            rspData.setRows(list);
+            rspData.setTotal(new PageInfo(list).getTotal());
+        } catch (Exception e) {
+            e.printStackTrace();
+            rspData.setCode(HttpStatus.ERROR);
+            rspData.setMsg(e.getMessage());
+        }
+        return rspData;
+    }
+
+
+}

+ 24 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KwaixiaodianItemGetController.java

@@ -167,6 +167,30 @@ public class KwaixiaodianItemGetController extends BaseController {
         return returnJson;
     }
 
+
+    @GetMapping("/getCompanyList")
+    public JSONObject getCompanyList() {
+
+        JSONObject returnJson = new JSONObject();
+        try {
+
+
+            List<JSONObject> companyList = kwaixiaodianItemGetService.getCompanyList();
+            returnJson.put("code", 200);
+            returnJson.put("success", true);
+            returnJson.put("data", companyList);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", 500);
+            returnJson.put("success", false);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+
     @GetMapping("/getCourtshipPurchaseIds")
     public JSONObject getCourtshipPurchaseIds(Long userId) {
 

+ 28 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KwaiXiaoDianReportMapper.java

@@ -0,0 +1,28 @@
+package com.ruixuan.isc.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface KwaiXiaoDianReportMapper {
+    JSONObject getSumInfo(Map<String, Object> requestMap);
+
+    JSONObject getMonthInfo(Map<String, Object> requestMap);
+
+    List<JSONObject> getEchartData(Map<String, Object> requestMap);
+
+    List<JSONObject> getGmvHours(Map<String, Object> requestMap);
+
+    List<JSONObject> getShopListData(Map<String, Object> requestMap);
+
+    List<JSONObject> getTeamList(Map<String, Object> requestMap);
+
+    JSONObject getItemInfo(Map<String, Object> map);
+
+    List<Long> getUserListByDeptId(Long deptId);
+
+    List<JSONObject> getTeamDetail(Map<String, Object> requestMap);
+
+    List<JSONObject> getItemList(Map<String, Object> requestMap);
+}

+ 4 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KwaixiaodianItemGetMapper.java

@@ -36,4 +36,8 @@ public interface KwaixiaodianItemGetMapper {
     KwaixiaodianItemGet selectKwaixiaodianItemGetById(@Param("id") Long id);
 
     int updateKwaixiaodianItemGet(KwaixiaodianItemGet kwaixiaodianItemGet);
+
+    List<Long> getItemIdsByUserIds(@Param("userIds") List<Long> userIds);
+
+    List<JSONObject> getCompanyList();
 }

+ 24 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKwaiXiaoDianReportService.java

@@ -0,0 +1,24 @@
+package com.ruixuan.isc.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IKwaiXiaoDianReportService {
+    JSONObject getSumInfo(Map<String, Object> requestMap);
+
+    JSONObject getMonthInfo(Map<String, Object> requestMap);
+
+    List<JSONObject> getEchartData(Map<String, Object> requestMap);
+
+    List<JSONObject> getGmvHours(Map<String, Object> requestMap);
+
+    List<JSONObject> getShopListData(Map<String, Object> requestMap);
+
+    List<JSONObject> getTeamList(Map<String, Object> requestMap);
+
+    List<JSONObject> getTeamDetail(Map<String, Object> requestMap);
+
+    List<JSONObject> getItemList(Map<String, Object> requestMap);
+}

+ 4 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKwaixiaodianItemGetService.java

@@ -36,4 +36,8 @@ public interface IKwaixiaodianItemGetService {
     KwaixiaodianItemGet selectKwaixiaodianItemGetById(Long id);
 
     int updateKwaixiaodianItemGet(KwaixiaodianItemGet kwaixiaodianItemGet);
+
+    List<Long> getItemIdsByUserIds(List<Long> userIds);
+
+    List<JSONObject> getCompanyList();
 }

+ 92 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KwaiXiaoDianReportServiceImpl.java

@@ -0,0 +1,92 @@
+package com.ruixuan.isc.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ruixuan.common.utils.Check;
+import com.ruixuan.isc.mapper.KwaiXiaoDianReportMapper;
+import com.ruixuan.isc.service.IKwaiXiaoDianReportService;
+import com.ruixuan.system.service.ISysDeptService;
+import com.ruixuan.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class KwaiXiaoDianReportServiceImpl implements IKwaiXiaoDianReportService {
+    @Autowired
+    private KwaiXiaoDianReportMapper kwaiXiaoDianReportMapper;
+
+    @Override
+    public JSONObject getSumInfo(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getSumInfo(requestMap);
+    }
+
+    @Override
+    public JSONObject getMonthInfo(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getMonthInfo(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getEchartData(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getEchartData(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getGmvHours(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getGmvHours(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getShopListData(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getShopListData(requestMap);
+    }
+
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private ISysDeptService sysDeptService;
+
+    @Override
+    public List<JSONObject> getTeamList(Map<String, Object> requestMap) {
+        List<JSONObject> teamList = kwaiXiaoDianReportMapper.getTeamList(requestMap);
+        if (!Check.isNull(teamList)) {
+            String start = requestMap.get("start").toString();
+            String end = requestMap.get("end").toString();
+            for (int i = 0; i < teamList.size(); i++) {
+                Map<String, Object> map = new HashMap<>();
+                map.put("start", start);
+                map.put("end", end);
+                JSONObject jsonObject = teamList.get(i);
+                Long deptId = jsonObject.getLong("deptId");
+                List<Long> userIds = kwaiXiaoDianReportMapper.getUserListByDeptId(deptId);
+                String type = jsonObject.getString("type");
+                if (type.equals("1")) {
+                    map.put("userIds", userIds);
+                }
+                if (type.equals("2")) {
+                    map.put("courtshipPurchaseIds", userIds);
+                }
+                JSONObject itemInfo = kwaiXiaoDianReportMapper.getItemInfo(map);
+                if (!Check.isNull(itemInfo)) {
+                    jsonObject.put("zxOrderNum", itemInfo.getString("zxOrderNum"));
+                    jsonObject.put("tpOrderNum", itemInfo.getString("tpOrderNum"));
+                }
+
+            }
+
+        }
+        return teamList;
+    }
+
+    @Override
+    public List<JSONObject> getTeamDetail(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getTeamDetail(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getItemList(Map<String, Object> requestMap) {
+        return kwaiXiaoDianReportMapper.getItemList(requestMap);
+    }
+}

+ 10 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KwaixiaodianItemGetServiceImpl.java

@@ -235,6 +235,16 @@ public class KwaixiaodianItemGetServiceImpl implements IKwaixiaodianItemGetServi
         return mapper.updateKwaixiaodianItemGet(kwaixiaodianItemGet);
     }
 
+    @Override
+    public List<Long> getItemIdsByUserIds(List<Long> userIds) {
+        return mapper.getItemIdsByUserIds(userIds);
+    }
+
+    @Override
+    public List<JSONObject> getCompanyList() {
+        return mapper.getCompanyList();
+    }
+
 
     private void replaceItemGetSku(JSONArray skuInfos) {
         try {

+ 802 - 0
ruixuan-live/src/main/resources/mapper/isc/KwaiXiaoDianReportMapper.xml

@@ -0,0 +1,802 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruixuan.isc.mapper.KwaiXiaoDianReportMapper">
+
+
+    <select id="getSumInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
+        round((t.totalFee - tt.totalFee) / tt.totalFee * 100, 2) AS 'totalFeeRate',
+        t.*,ttt.*
+        FROM (
+        SELECT COUNT(t1.oid) AS 'orderNum',
+        IFNULL(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END), 0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END) / COUNT(t1.oid) * 100,2) AS
+        'validRadio',
+        SUM(CASE WHEN t1.status >= 40 AND t1.status &lt; 80 THEN 1 ELSE 0 END) AS 'deliveryNum',
+        ifnull(
+        round(sum(case when t1.status >= 40 and t1.status &lt; 80 then 1 else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2),
+        0) AS 'deliveryRate',
+        SUM(CASE WHEN t1.status = 30 THEN 1 ELSE 0 END) AS 'notDeliveryNum',
+        round(SUM(t1.express_fee) / 100, 2) AS 'expressFee',
+        SUM(CASE WHEN t2.item_type = 1 THEN 1 ELSE 0 END) AS 'zxOrderNUm',
+        SUM(CASE WHEN t2.item_type = 2 THEN 1 ELSE 0 END) AS 'tpOrderNUm',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+
+        round(sum(case
+        when t1.status != 80 and t1.status != 10 then t1.total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        round(sum(case when t1.status != 80 and t1.status != 10 then t1.total_fee else 0 end) / sum(t1.total_fee) *
+        100,
+        2) as 'validTotalFeeRadio',
+        round(sum(case when t2.item_type = 1 then t1.total_fee else 0 end) / 1000000,2) as 'zxTotalFee',
+        round(sum(case when t2.item_type = 2 then t1.total_fee else 0 end) / 1000000, 2) as 'tpTotalFee',
+        COUNT(DISTINCT t1.item_id) AS 'itemCount',
+        COUNT(DISTINCT
+        (
+        CASE
+        WHEN t2.item_type = 1
+        THEN t1.item_id
+        END
+        )
+        ) AS 'zxOrderCount',
+        COUNT(DISTINCT
+        (
+        CASE
+        WHEN t2.item_type = 2
+        THEN t1.item_id
+        END
+        )
+        ) AS 'tpOrderCount'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        WHERE t1.stat_date &gt;= #{start}
+        AND t1.stat_date &lt;= #{end}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        ) t
+        JOIN (
+        SELECT COUNT(t1.oid) AS 'orderNum',
+        round(SUM(t1.total_fee) / 100, 2) AS 'totalFee'
+        FROM kwaixiaodian_order_cursor_list t1
+        WHERE t1.stat_date &gt;= #{lastStart}
+        AND t1.stat_date &lt;= #{lastEnd}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) tt join (
+        SELECT
+        ifnull( round(sum(case when t1.status >= 40 and t1.status &lt; 80 then t1.total_fee else 0 end) / 100, 2),0) as
+        'estimatedIncome',
+        ifnull(round(sum(case when t1.status >= 40 and t1.status &lt; 80 and t2.item_type = 1 then t1.total_fee else 0
+        end) / 100 , 2), 0 ) as 'zxEstimatedIncome',
+        ifnull(round(sum(case when t1.status >= 40 and t1.status &lt; 80 and t2.item_type = 2 then t1.total_fee else 0
+        end) / 100 , 2),0) as 'tpEstimatedIncome'
+        FROM kwaixiaodian_order_cursor_list t1 LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        WHERE t1.send_time &gt;= #{start}
+        AND t1.send_time &lt;= #{end}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        ) ttt
+    </select>
+    <select id="getMonthInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
+        round((t.totalFee - tt.totalFee) / tt.totalFee * 100, 2) AS 'totalFeeRate', t.* from(
+        select count(t1.oid) as 'orderNum',
+        IFNULL(SUM(CASE WHEN t1.status != 80 and t1.status != 10 THEN 1 ELSE 0 END),
+        0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) / count(t1.oid) * 100,
+        2) as 'validRadio',
+        sum(case when t1.status >= 40 and t1.status &lt; 80 then 1 else 0 end) as 'deliveryNum',
+        ifnull(
+        round(sum(case when t1.status >= 40 and t1.status &lt; 80 then 1 else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2),
+        0) as 'deliveryRate',
+        sum(case when t1.status = 30 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(t1.express_fee) / 100, 2) as 'expressFee',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+        round(sum(case
+        when t1.status != 80 and t1.status != 10 then t1.total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        round(sum(case when t1.status != 80 and t1.status != 10 then t1.total_fee else 0 end) / sum(t1.total_fee) *
+        100,
+        2) as 'validTotalFeeRadio',
+
+        count(distinct t1.item_id) as 'itemCount'
+        from kwaixiaodian_order_cursor_list t1
+        where t1.stat_date &gt;= #{monthStart}
+        AND t1.stat_date &lt;= #{monthEnd}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) t join (
+        select count(t1.oid) as 'orderNum',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee'
+        from kwaixiaodian_order_cursor_list t1
+        where t1.stat_date &gt;= #{lastMonthStart}
+        AND t1.stat_date &lt;= #{lastMonthEnd}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        ) tt
+    </select>
+    <select id="getEchartData" resultType="com.alibaba.fastjson.JSONObject">
+        select date_format(stat_date, '%m-%d') as 'date',
+        count(oid) as 'orderNum',
+        IFNULL(SUM(CASE WHEN status != 80 and status != 10 THEN 1 ELSE 0 END),
+        0) AS 'validOrderNum',
+        round(sum(case
+        when status != 80 and status != 10 then total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        count(distinct item_id) as 'itemCount'
+        from kwaixiaodian_order_cursor_list
+        where stat_date &gt;= #{echartStart}
+        and stat_date &lt;= #{echartEnd}
+        <if test='companyId != null and companyId != ""'>
+            and company_id = #{companyId}
+        </if>
+
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by stat_date
+        order by stat_date asc
+
+    </select>
+    <select id="getGmvHours" resultType="com.alibaba.fastjson.JSONObject">
+        select stat_hour as 'time',
+        round(sum(case
+        when status != 80 and status != 10 then total_fee
+        else 0 end) / 100,
+        2) as 'charge'
+        from kwaixiaodian_order_cursor_list
+        where stat_date = #{date}
+        <if test='companyId != null and companyId != ""'>
+            and company_id = #{companyId}
+        </if>
+
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by stat_hour
+        order by stat_hour
+    </select>
+    <select id="getShopListData" resultType="com.alibaba.fastjson.JSONObject">
+        select round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
+        t.*
+        from (SELECT t1.shop_id as 'shopId',
+        t2.shop_name as 'shopName',
+        t2.master_score as 'masterScore',
+        t2.shop_score as 'shopScore',
+        COUNT(t1.oid) AS 'orderNum',
+        IFNULL(
+        SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END),
+        0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END) / COUNT(t1.oid) * 100, 2) AS
+        'validRadio',
+        SUM(CASE
+        WHEN t1.status >= 40 AND t1.status
+        &lt;
+        80 THEN 1
+        ELSE 0 END) AS 'deliveryNum',
+        ifnull(
+        round(sum(case when t1.status >= 40 and t1.status
+        &lt;
+        80 then 1 else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2),
+        0) AS 'deliveryRate',
+        SUM(CASE WHEN t1.status = 30 THEN 1 ELSE 0 END) AS 'notDeliveryNum',
+        round(SUM(t1.express_fee) / 100, 2) AS 'expressFee',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+        round(sum(case
+        when t1.status != 80 and t1.status != 10 then t1.total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        round(sum(case when t1.status != 80 and t1.status != 10 then t1.total_fee else 0 end) / sum(t1.total_fee) *
+        100,
+        2) as 'validTotalFeeRadio',
+        COUNT(DISTINCT t1.item_id) AS 'itemCount'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_shop_score t2
+        ON t1.shop_id = t2.shop_id
+        WHERE t1.stat_date &gt;= #{start}
+        AND t1.stat_date &lt;= #{end}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t1.shop_id) t
+        left join (SELECT t1.shop_id as 'shopId',
+        COUNT(t1.oid) AS 'orderNum'
+        FROM kwaixiaodian_order_cursor_list t1
+        WHERE t1.stat_date &gt;= #{lastStart}
+        AND t1.stat_date &lt;= #{lastEnd}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='itemIds != null and itemIds.size() > 0'>
+            AND t1.item_it in
+            <foreach collection="itemIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t1.shop_id) tt on t.shopId = tt.shopId
+        order by t.orderNum desc
+
+    </select>
+    <select id="getTeamList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT * from(
+        select
+        '1' as 'type',
+        round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
+        t.*,
+        ifnull((select user.nick_name
+        from sys_user user
+        left join sys_user_role userRole on user.user_id = userRole.user_id
+        left join sys_role role on userRole.role_id = role.role_id
+        where user.dept_id = t.deptId
+        and role.role_key in (
+        'industry_sale_manager', 'industry_courtship_manager', 'industry_purchase_manager'
+        )
+        and user.status = 0
+        limit 1),'-') as 'leaderName'
+        from (SELECT t3.dept_id as 'deptId',
+        t4.dept_name as 'deptName',
+        count(distinct t2.user_id) as 'userCount',
+        COUNT(t1.oid) AS 'orderNum',
+        IFNULL(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END),
+        0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END) / COUNT(t1.oid) * 100, 2) AS
+        'validRadio',
+        SUM(CASE
+        WHEN t1.status >= 40 AND t1.status
+        &lt;
+        80 THEN 1
+        ELSE 0 END) AS 'deliveryNum',
+        ifnull(
+        round(sum(case
+        when t1.status >= 40 and t1.status
+        &lt;
+        80 then 1
+        else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2),
+        0) AS 'deliveryRate',
+        SUM(CASE WHEN t1.status = 30 THEN 1 ELSE 0 END) AS 'notDeliveryNum',
+        round(SUM(t1.express_fee) / 100, 2) AS 'expressFee',
+        SUM(CASE WHEN t2.item_type = 1 THEN 1 ELSE 0 END) AS 'zxOrderNUm',
+        SUM(CASE WHEN t2.item_type = 2 THEN 1 ELSE 0 END) AS 'tpOrderNUm',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+
+        round(sum(case
+        when t1.status != 80 and t1.status != 10 then t1.total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        round(sum(case when t1.status != 80 and t1.status != 10 then t1.total_fee else 0 end) / sum(t1.total_fee) *
+        100,
+        2) as 'validTotalFeeRadio',
+        round(sum(case when t2.item_type = 1 then t1.total_fee else 0 end) / 1000000,
+        2) as 'zxTotalFee',
+        round(sum(case when t2.item_type = 2 then t1.total_fee else 0 end) / 1000000,
+        2) as 'tpTotalFee',
+        COUNT(DISTINCT t1.item_id) AS 'itemCount',
+        COUNT(DISTINCT
+        (
+        CASE
+        WHEN t2.item_type = 1
+        THEN t1.item_id
+        END
+        )
+        ) AS 'zxOrderCount',
+        COUNT(DISTINCT
+        (
+        CASE
+        WHEN t2.item_type = 2
+        THEN t1.item_id
+        END
+        )
+        ) AS 'tpOrderCount'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        left join sys_user t3 on t2.user_id = t3.user_id
+        left join sys_dept t4 on t3.dept_id = t4.dept_id
+        WHERE t1.stat_date &gt;= #{start}
+        AND t1.stat_date &lt;= #{end}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='userIds != null and userIds.size() > 0'>
+            AND t2.user_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        and t3.dept_id is not null
+        group by t3.dept_id) t
+        left join (SELECT t3.dept_id as 'deptId',
+        COUNT(t1.oid) AS 'orderNum'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        left join sys_user t3 on t2.user_id = t3.user_id
+        left join sys_dept t4 on t3.dept_id = t4.dept_id
+        WHERE t1.stat_date &gt;= #{lastStart}
+        AND t1.stat_date &lt;= #{lastEnd}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='userIds != null and userIds.size() > 0'>
+            AND t2.user_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        and t3.dept_id is not null
+        group by t3.dept_id) tt on t.deptId = tt.deptId
+        union all
+        select
+        '2' as 'type',
+        round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
+        t.*,
+
+        ifnull((select user.nick_name
+        from sys_user user
+        left join sys_user_role userRole on user.user_id = userRole.user_id
+        left join sys_role role on userRole.role_id = role.role_id
+        where user.dept_id = t.deptId
+        and role.role_key in (
+        'industry_sale_manager', 'industry_courtship_manager', 'industry_purchase_manager'
+        )
+        and user.status = 0
+        limit 1),'-') as 'leaderName'
+        from (SELECT t3.dept_id as 'deptId',
+        t4.dept_name as 'deptName',
+        count(distinct t2.courtship_purchase_id) as 'userCount',
+        COUNT(t1.oid) AS 'orderNum',
+        IFNULL(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END),
+        0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END) / COUNT(t1.oid) * 100, 2) AS
+        'validRadio',
+        SUM(CASE
+        WHEN t1.status >= 40 AND t1.status
+        &lt;
+        80 THEN 1
+        ELSE 0 END) AS 'deliveryNum',
+        ifnull(
+        round(sum(case
+        when t1.status >= 40 and t1.status
+        &lt;
+        80 then 1
+        else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2),
+        0) AS 'deliveryRate',
+        SUM(CASE WHEN t1.status = 30 THEN 1 ELSE 0 END) AS 'notDeliveryNum',
+        round(SUM(t1.express_fee) / 100, 2) AS 'expressFee',
+        SUM(CASE WHEN t2.item_type = 1 THEN 1 ELSE 0 END) AS 'zxOrderNUm',
+        SUM(CASE WHEN t2.item_type = 2 THEN 1 ELSE 0 END) AS 'tpOrderNUm',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+        round(sum(case
+        when t1.status != 80 and t1.status != 10 then t1.total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        round(sum(case when t1.status != 80 and t1.status != 10 then t1.total_fee else 0 end) / sum(t1.total_fee) *
+        100,
+        2) as 'validTotalFeeRadio',
+        round(sum(case when t2.item_type = 1 then t1.total_fee else 0 end) / 1000000,
+        2) as 'zxTotalFee',
+        round(sum(case when t2.item_type = 2 then t1.total_fee else 0 end) / 1000000,
+        2) as 'tpTotalFee',
+        COUNT(DISTINCT t1.item_id) AS 'itemCount',
+        COUNT(DISTINCT
+        (
+        CASE
+        WHEN t2.item_type = 1
+        THEN t1.item_id
+        END
+        )
+        ) AS 'zxOrderCount',
+        COUNT(DISTINCT
+        (
+        CASE
+        WHEN t2.item_type = 2
+        THEN t1.item_id
+        END
+        )
+        ) AS 'tpOrderCount'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        left join sys_user t3 on t2.courtship_purchase_id = t3.user_id
+        left join sys_dept t4 on t3.dept_id = t4.dept_id
+        WHERE t1.stat_date &gt;= #{start}
+        AND t1.stat_date &lt;= #{end}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='userIds != null and userIds.size() > 0'>
+            AND t2.courtship_purchase_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        and t3.dept_id is not null
+        group by t3.dept_id) t
+        left join (SELECT t3.dept_id as 'deptId',
+        COUNT(t1.oid) AS 'orderNum'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        left join sys_user t3 on t2.courtship_purchase_id = t3.user_id
+        left join sys_dept t4 on t3.dept_id = t4.dept_id
+        WHERE t1.stat_date &gt;= #{lastStart}
+        AND t1.stat_date &lt;= #{lastEnd}
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='userIds != null and userIds.size() > 0'>
+            AND t2.courtship_purchase_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        and t3.dept_id is not null
+        group by t3.dept_id) tt on t.deptId = tt.deptId
+        ) team order by team.orderNum desc
+
+    </select>
+    <select id="getItemInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ifnull(SUM(CASE WHEN item_type = 1 THEN 1 ELSE 0 END),'-') AS 'zxOrderNum',
+        ifnull(SUM(CASE WHEN item_type = 2 THEN 1 ELSE 0 END) ,'-') AS 'tpOrderNum'
+        FROM kwaixiaodian_item_get
+        WHERE 1 = 1
+        AND data_create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
+        %H:%i:%s')
+        AND data_create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d %H:%i:%s')
+        <if test='userIds != null and userIds.size() > 0'>
+            AND user_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test='courtshipPurchaseIds != null and courtshipPurchaseIds.size() > 0'>
+            AND courtship_purchase_id in
+            <foreach collection="courtshipPurchaseIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+    <select id="getUserListByDeptId" resultType="java.lang.Long"
+            parameterType="java.lang.Long">
+        SELECT user_id
+        FROM sys_user
+        WHERE dept_id = #{deptId}
+
+    </select>
+    <select id="getTeamDetail" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        t.*,
+        round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
+        ifnull(ttt.zxOrderNum,'-') as 'zxOrderNum',
+        ifnull(ttt.tpOrderNum,'-') as 'tpOrderNum'
+        from (SELECT t3.user_id as 'userId',
+        t3.nick_name as 'userName',
+        COUNT(t1.oid) AS 'orderNum',
+        IFNULL(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END),
+        0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END) / COUNT(t1.oid) * 100, 2) AS
+        'validRadio',
+        SUM(CASE
+        WHEN t1.status >= 40 AND t1.status
+        &lt;
+        80 THEN 1
+        ELSE 0 END) AS 'deliveryNum',
+        ifnull(
+        round(sum(case
+        when t1.status >= 40 and t1.status
+        &lt;
+        80 then 1
+        else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2),
+        0) AS 'deliveryRate',
+        SUM(CASE WHEN t1.status = 30 THEN 1 ELSE 0 END) AS 'notDeliveryNum',
+        round(SUM(t1.express_fee) / 100, 2) AS 'expressFee',
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+
+        round(sum(case
+        when t1.status != 80 and t1.status != 10 then t1.total_fee
+        else 0 end) / 100,
+        2) as 'validTotalFee',
+        round(sum(case when t1.status != 80 and t1.status != 10 then t1.total_fee else 0 end) / sum(t1.total_fee) *
+        100,
+        2) as 'validTotalFeeRadio',
+        round(sum(case when t2.item_type = 1 then t1.total_fee else 0 end) / 1000000,
+        2) as 'zxTotalFee',
+        round(sum(case when t2.item_type = 2 then t1.total_fee else 0 end) / 1000000,
+        2) as 'tpTotalFee',
+        COUNT(DISTINCT t1.item_id) AS 'itemCount'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        left join sys_user t3
+        <if test="type == '1'.toString()">
+            on t2.user_id = t3.user_id
+        </if>
+        <if test="type == '2'.toString()">
+            on t2.courtship_purchase_id = t3.user_id
+        </if>
+
+        WHERE t1.stat_date &gt;= #{start}
+        AND t1.stat_date &lt;= #{end}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='userId != null and userId != ""'>
+            and t2.user_id = #{userId}
+        </if>
+        and t3.dept_id = #{deptId}
+        group by t3.user_id) t
+        left join (SELECT t3.user_id as 'userId',
+        COUNT(t1.oid) AS 'orderNum'
+        FROM kwaixiaodian_order_cursor_list t1
+        LEFT JOIN kwaixiaodian_item_get t2
+        ON t1.company_id = t2.company_id AND t1.item_id = t2.item_id
+        left join sys_user t3
+        <if test="type == '1'.toString()">
+            on t2.user_id = t3.user_id
+        </if>
+        <if test="type == '2'.toString()">
+            on t2.courtship_purchase_id = t3.user_id
+        </if>
+        WHERE t1.stat_date &gt;= #{lastStart}
+        AND t1.stat_date &lt;= #{lastEnd}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='userId != null and userId != ""'>
+            and t2.user_id = #{userId}
+        </if>
+        and t3.dept_id = #{deptId}
+        group by t3.user_id) tt on t.userId = tt.userId
+        <if test="type == '1'.toString()">
+            left join (
+            select t1.user_id as 'userId',
+            SUM(CASE WHEN t1.item_type = 1 THEN 1 ELSE 0 END) AS 'zxOrderNum',
+            SUM(CASE WHEN t1.item_type = 2 THEN 1 ELSE 0 END) AS 'tpOrderNum'
+            from kwaixiaodian_item_get t1
+            left join sys_user t2 on t1.user_id = t2.user_id
+            where t2.dept_id = #{deptId}
+            AND t1.data_create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
+            %H:%i:%s')
+            AND t1.data_create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
+            %H:%i:%s')
+            <if test='userId != null and userId != ""'>
+                and t1.user_id = #{userId}
+            </if>
+            group by t1.user_id
+            )
+        </if>
+
+        <if test="type == '2'.toString()">
+            left join (
+            select t1.courtship_purchase_id as 'userId',
+            (CASE WHEN t1.item_type = 1 THEN 1 ELSE 0 END) AS 'zxOrderNum',
+            SUM(CASE WHEN t1.item_type = 2 THEN 1 ELSE 0 END) AS 'tpOrderNum'
+            from kwaixiaodian_item_get t1
+            left join sys_user t2 on t1.courtship_purchase_id = t2.user_id
+            where t2.dept_id = #{deptId}
+            AND t1.data_create_time &gt;= str_to_date(concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
+            %H:%i:%s')
+            AND t1.data_create_time &lt;= str_to_date(concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
+            %H:%i:%s')
+            <if test='userId != null and userId != ""'>
+                and t1.courtship_purchase_id = #{userId}
+            </if>
+            group by t1.courtship_purchase_id
+            )
+        </if>
+        ttt on t.userId = ttt.userId
+        order by t.orderNum desc
+
+    </select>
+    <select id="getItemList" resultType="com.alibaba.fastjson.JSONObject">
+        select t1.*,
+        round((t1.orderNum - t2.orderNum) / t2.orderNum * 100, 2) as 'orderNumRate'
+        from (
+        select ifnull(t2.user_name,'-') as 'userName',
+        ifnull(t2.courtship_purchase_name,'-') as 'courtshipPurchaseName',
+        (
+        CASE when t2.item_type = 1
+        then '自选品'
+        when t2.item_type = 2
+        then '推品'
+        else '-'
+        end
+        ) as 'itemType',
+        t1.item_id as itemId,
+        t1.item_title as 'itemTitle',
+        t1.item_pic_url as 'itemPicUrl',
+        (case
+        when min(t1.price) = max(t1.price)
+        then concat(round(min(t1.price) / 100, 2), '元')
+        else concat(round(min(t1.price) / 100, 2), '~', round(max(t1.price) / 100, 2), '元')
+        end
+        ) as price,
+        round(sum(t1.total_fee) / 100, 2) as 'totalFee',
+        IFNULL(round(SUM(CASE WHEN t1.status != 80 and t1.status != 10 THEN t1.total_fee ELSE 0 END) / 100, 2), 0) as
+        'validTotalFee',
+        count(t1.oid) as 'orderNum',
+        IFNULL(SUM(CASE WHEN t1.status != 80 and t1.status != 10 THEN 1 ELSE 0 END), 0) AS 'validOrderNum',
+        IFNULL(SUM(CASE WHEN t1.status = 80 THEN 1 ELSE 0 END), 0) AS 'effOrderNum',
+        round(sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) / count(t1.oid) * 100,
+        2) as 'validRadio',
+        sum(case when t1.status >= 40 and t1.status &lt; 80 then 1 else 0 end) as 'deliveryNum',
+        round(sum(case when t1.status >= 40 and t1.status &lt; 80 then 1 else 0 end) /
+        sum(case when t1.status != 80 and t1.status != 10 then 1 else 0 end) * 100, 2) as 'deliveryRate',
+        sum(case when t1.status = 30 then 1 else 0 end) as 'notDeliveryNum',
+        round(sum(t1.express_fee) / 100, 2) as 'expressFee'
+        from kwaixiaodian_order_cursor_list t1
+        left join kwaixiaodian_item_get t2
+        on t1.item_id = t2.item_id
+        and t1.company_id = t2.company_id
+        where t1.stat_date &gt;= #{start}
+        and t1.stat_date &lt;= #{end}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='shopId != null and shopId != ""'>
+            and t1.shop_id = #{shopId}
+        </if>
+        <if test='itemType != null and itemType != ""'>
+            and t2.item_type = #{itemType}
+        </if>
+        <if test='userIds != null and userIds.size() > 0'>
+            AND t2.user_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test='courtshipPurchaseIds != null and courtshipPurchaseIds.size() > 0'>
+            AND t2.courtship_purchase_id in
+            <foreach collection="courtshipPurchaseIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t1.item_id) t1
+        left join (
+        select t1.item_id as itemId,
+        count(t1.oid) as 'orderNum'
+        from kwaixiaodian_order_cursor_list t1 left join kwaixiaodian_item_get t2
+        on t1.item_id = t2.item_id
+        and t1.company_id = t2.company_id
+        where t1.stat_date &gt;= #{lastStart}
+        and t1.stat_date &lt;= #{lastEnd}
+        <if test='nowHour != null and nowHour != ""'>
+            and t1.stat_hour &lt;= #{nowHour}
+        </if>
+        <if test='companyId != null and companyId != ""'>
+            and t1.company_id = #{companyId}
+        </if>
+        <if test='shopId != null and shopId != ""'>
+            and t1.shop_id = #{shopId}
+        </if>
+
+        <if test='userIds != null and userIds.size() > 0'>
+            AND t2.user_id in
+            <foreach collection="userIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        group by t1.item_id) t2 on t1.itemId = t2.itemId
+        order by t1.orderNum desc
+
+    </select>
+</mapper>

+ 17 - 0
ruixuan-live/src/main/resources/mapper/isc/KwaixiaodianItemGetMapper.xml

@@ -554,6 +554,23 @@
         <include refid="selectKwaixiaodianItemGetVo"/>
         where id = #{id}
     </select>
+    <select id="getItemIdsByUserIds" resultType="java.lang.Long">
+        select item_id from kwaixiaodian_item_get where
+        1 = 1
+        and user_id in
+        <foreach collection="userIds" item="userId" separator="," open="(" close=")">
+            #{userId}
+        </foreach>
+        group by item_id
+
+    </select>
+    <select id="getCompanyList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT company_id AS 'companyId', company_name AS 'companyName'
+        FROM kwaixiaodian_access_token
+        GROUP BY company_id
+        ORDER BY company_id
+
+    </select>
 
 
 </mapper>

+ 0 - 2
ruixuan-live/src/main/resources/mapper/isc/KwaixiaodianOrderCursorListMapper.xml

@@ -500,8 +500,6 @@
         <if test='itemTitle != null and itemTitle != ""'>
             and t1.item_title like concat('%',#{itemTitle},'%')
         </if>
-
-
         group by t1.item_id) t1
         left join (
         select t1.item_id as itemId,