yumeng 2 anos atrás
pai
commit
f33559a8bf

+ 13 - 0
ruixuan-admin/src/main/java/com/ruixuan/web/controller/system/SysUserController.java

@@ -48,6 +48,19 @@ public class SysUserController extends BaseController
     @Autowired
     private ISysPostService postService;
 
+
+    /**
+     * 根据userId获取roleKey
+     * @param userId
+     * @return
+     */
+    @GetMapping("/getRoleKeyByUserId")
+    public String getRoleKeyByUserId(String userId) {
+       String roleKey = userService.getRoleKeyByUserId(userId);
+        return roleKey;
+    }
+
+
     /**
      * 获取用户列表
      */

+ 5 - 2
ruixuan-common/src/main/java/com/ruixuan/common/utils/DateUtils.java

@@ -1,7 +1,6 @@
 package com.ruixuan.common.utils;
 
 import java.lang.management.ManagementFactory;
-import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -15,7 +14,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.lang3.time.DateFormatUtils;
-import org.springframework.security.config.web.servlet.headers.HttpPublicKeyPinningDsl;
 
 /**
  * 时间工具类
@@ -50,6 +48,11 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return new Date();
     }
 
+    public static String getNowDateStr() {
+        SimpleDateFormat simp = new SimpleDateFormat("yyyy-MM-dd");
+        return simp.format(new Date());
+    }
+
     /**
      * 获取当前日期, 默认格式为yyyy-MM-dd
      *

+ 1 - 0
ruixuan-framework/src/main/java/com/ruixuan/framework/config/SecurityConfig.java

@@ -122,6 +122,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                     .antMatchers("/system/user/getUserByRoleName").permitAll()
                     .antMatchers("/system/industry/**").permitAll()
                     .antMatchers("/isv/supply_chain/*").permitAll()
+                    .antMatchers("/system/user/*").permitAll()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 299 - 6
ruixuan-live/src/main/java/com/ruixuan/isc/controller/SupplyChainController.java

@@ -1,6 +1,5 @@
 package com.ruixuan.isc.controller;
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.page.TableDataInfo;
@@ -10,18 +9,16 @@ import com.ruixuan.data.utils.ExportExcelUtils;
 import com.ruixuan.isc.service.ISupplyChainService;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import lombok.SneakyThrows;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @RestController
 @RequestMapping("/isv/supply_chain")
@@ -778,5 +775,301 @@ public class SupplyChainController extends BaseController {
         }
     }
 
+    /**
+     * 获取供应链人员列表
+     *
+     * @return
+     */
+    @GetMapping("/getSupplyChainUserList")
+    @ApiOperation(value = "获取供应链成员列表")
+    public TableDataInfo getSupplyChainUserList() {
+        List<JSONObject> list = supplyChainService.getSupplyChainUserList();
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 获取商品绑定人员列表
+     *
+     * @param status
+     * @param userId
+     * @param itemId
+     * @param itemTitle
+     * @param activityId
+     * @return
+     */
+    @GetMapping("/bindUserItemList")
+    @ApiOperation(value = "商品认领列表")
+    public TableDataInfo bindUserItemList(
+            @ApiParam("状态") @RequestParam(value = "status", required = false) Integer status,
+            @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
+            @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId,
+            @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) String itemTitle,
+            @ApiParam("活动ID") @RequestParam(value = "activityId", required = false) Long activityId
+    ) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(status)) {
+            requestMap.put("status", status);
+        }
+        if (!Check.isNull(userId)) {
+            requestMap.put("userId", userId);
+        }
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+        if (!Check.isNull(activityId)) {
+            requestMap.put("activityId", activityId);
+        }
+        startPage();
+        List<JSONObject> list = supplyChainService.bindUserItemList(requestMap);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 商品解绑
+     *
+     * @param itemId
+     * @return
+     */
+    @GetMapping("/unbindUser")
+    @ApiOperation(value = "商品解绑")
+    public JSONObject unbindUser(
+            @ApiParam("商品id") @RequestParam(value = "itemId", required = false) Long itemId) {
+        JSONObject returnJson = new JSONObject();
+        if (Check.isNull(itemId)) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "请传入商品ID");
+            return returnJson;
+        }
+        boolean isTrueOrFalse = supplyChainService.unbindUser(itemId);
+        if (isTrueOrFalse) {
+            returnJson.put("code", 0);
+            returnJson.put("message", "解绑成功");
+            return returnJson;
+        } else {
+            returnJson.put("code", -1);
+            returnJson.put("message", "解绑失败");
+            return returnJson;
+        }
+    }
+
+
+    /**
+     * 绑定商品
+     *
+     * @param itemId
+     * @return
+     */
+    @GetMapping("/bindUser")
+    @ApiOperation(value = "绑定商品")
+    public JSONObject bindUser(
+            @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId,
+            @ApiParam("用户ID") @RequestParam(value = "userId", required = false) Long userId,
+            @ApiParam("用户名称") @RequestParam(value = "nikeName", required = false) String nikeName) {
+        JSONObject returnJson = new JSONObject();
+        if (Check.isNull(itemId)) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "请传入商品ID");
+            return returnJson;
+        }
+        if (Check.isNull("userId")) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "请传入用户ID");
+            return returnJson;
+        }
+        if (Check.isNull("nikeName")) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "请传入用户名称");
+            return returnJson;
+        }
+        boolean isTrueOrFalse = supplyChainService.bindUser(itemId, userId, nikeName);
+        if (isTrueOrFalse) {
+            returnJson.put("code", 0);
+            returnJson.put("message", "认领成功");
+            return returnJson;
+        } else {
+            returnJson.put("code", -1);
+            returnJson.put("message", "认领失败");
+            return returnJson;
+        }
+    }
+
 
+    /**
+     * 供应链管理员统计列表
+     *
+     * @param orderStartDate
+     * @param orderEndDate
+     * @return
+     */
+    @GetMapping("/adminReportList")
+    @ApiOperation(value = "供应链管理员统计列表")
+    public TableDataInfo adminReportList(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.getStartLongTime(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.getEndLongTime(orderEndDate);
+            requestMap.put("end", end);
+        }
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(-1);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = supplyChainService.adminReportList(requestMap);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 认领商品列表
+     *
+     * @param userId
+     * @param orderStartDate
+     * @param orderEndDate
+     * @param itemId
+     * @param itemTitle
+     * @return
+     */
+    @GetMapping("/userItemDetail")
+    @ApiOperation(value = "认领商品列表")
+    public TableDataInfo userItemDetail(
+            @ApiParam("userId") @RequestParam(value = "userId", required = false) Long userId,
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("商品Id") @RequestParam(value = "itemId", required = false) String itemId,
+            @ApiParam("商品名称") @RequestParam(value = "itemTitle", required = false) Long itemTitle) {
+        Map<String, Object> requestMap = new HashMap<>();
+        if (!Check.isNull(userId)) {
+            requestMap.put("userId", userId);
+        }
+        if (!Check.isNull(orderStartDate)) {
+            Long start = DateUtils.getStartLongTime(orderStartDate);
+            requestMap.put("start", start);
+        }
+        if (!Check.isNull(orderEndDate)) {
+            Long end = DateUtils.getEndLongTime(orderEndDate);
+            requestMap.put("end", end);
+        }
+        if (!Check.isNull(itemId)) {
+            requestMap.put("itemId", itemId);
+        }
+        if (!Check.isNull(itemTitle)) {
+            requestMap.put("itemTitle", itemTitle);
+        }
+        TableDataInfo dataInfo = new TableDataInfo();
+        if (Check.isNullMap(requestMap)) {
+            dataInfo.setCode(-1);
+            dataInfo.setMsg("入参不能为空");
+            return dataInfo;
+        }
+        startPage();
+        List<JSONObject> list = supplyChainService.userItemDetail(requestMap);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 首页-时段对比
+     *
+     * @param orderStartDate
+     * @param orderEndDate
+     * @return
+     */
+    @SneakyThrows
+    @GetMapping("/indexTimeIntervalRatio")
+    @ApiOperation(value = "首页-时段对比")
+    public JSONObject indexTimeIntervalRatio(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate) {
+        Map<String, Object> requestMap = new HashMap<>();
+        String nowDate = DateUtils.getNowDateStr();
+        String thisCycleEnd = null; // 当前时段结束日期
+        String thisCycleStart = null; // 当前时段开始日期
+        String lastCycleEnd = null; // 上一时段结束日期
+        String lastCycleStart = null; // 上一时段开始日期
+        if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
+            thisCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            thisCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleEnd, -6);
+            lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", thisCycleStart, -1);
+            lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -6);
+        } else {
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            int differDay = DateUtils.differentDaysByMillisecond(simpleDateFormat.parse(orderStartDate), simpleDateFormat.parse(orderEndDate));
+            thisCycleEnd = orderEndDate;
+            thisCycleStart = orderStartDate;
+            lastCycleEnd = DateUtils.getAnotherDay("yyyy-MM-dd", orderStartDate, -1);
+            lastCycleStart = DateUtils.getAnotherDay("yyyy-MM-dd", lastCycleEnd, -differDay);
+        }
+        if (!Check.isNull(thisCycleStart)) {
+            Long thisCycleStartTemp = DateUtils.getStartLongTime(thisCycleStart);
+            requestMap.put("thisCycleStartTemp", thisCycleStartTemp);
+        }
+        if (!Check.isNull(thisCycleEnd)) {
+            Long thisCycleEndTemp = DateUtils.getEndLongTime(thisCycleEnd);
+            requestMap.put("thisCycleEndTemp", thisCycleEndTemp);
+        }
+        if (!Check.isNull(lastCycleStart)) {
+            Long lastCycleStartTemp = DateUtils.getStartLongTime(lastCycleStart);
+            requestMap.put("lastCycleStartTemp", lastCycleStartTemp);
+        }
+        if (!Check.isNull(lastCycleEnd)) {
+            Long lastCycleEndTemp = DateUtils.getEndLongTime(lastCycleEnd);
+            requestMap.put("lastCycleEndTemp", lastCycleEndTemp);
+        }
+        JSONObject timeIntervalRatioJson = supplyChainService.getTimeIntervalRatio(requestMap);
+        return timeIntervalRatioJson;
+    }
+
+
+    /**
+     * 首页-统计图
+     *
+     * @param orderStartDate
+     * @param orderEndDate
+     * @param type
+     * @return
+     */
+    @GetMapping("/indexStatistics")
+    @ApiOperation(value = "首页-统计图")
+    public List<JSONObject> indexStatistics(
+            @ApiParam("开始时间") @RequestParam(value = "orderStartDate", required = false) String orderStartDate,
+            @ApiParam("结束时间") @RequestParam(value = "orderEndDate", required = false) String orderEndDate,
+            @ApiParam("类型") @RequestParam(value = "type", required = false) String type) {
+        Map<String, Object> requestMap = new HashMap<>();
+        String nowDate = DateUtils.getNowDateStr();
+        String start = null;
+        String end = null;
+        if (nowDate.equals(orderStartDate) && nowDate.equals(orderEndDate)) {
+            end = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            start = DateUtils.getAnotherDay("yyyy-MM-dd", end, -6);
+        } else {
+            start = orderStartDate;
+            end = orderEndDate;
+        }
+        if (!Check.isNull(start)) {
+            Long startTemp = DateUtils.getStartLongTime(start);
+            requestMap.put("startTemp", startTemp);
+        }
+        if (!Check.isNull(end)) {
+            Long endTemp = DateUtils.getEndLongTime(end);
+            requestMap.put("endTemp", endTemp);
+        }
+        if (!Check.isNull(type)) {
+            requestMap.put("type", type);
+        }
+        List<JSONObject> list = supplyChainService.indexStatistics(requestMap);
+        return list;
+    }
 }

+ 15 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -35,7 +35,7 @@ public interface SupplyChainMapper {
 
     List<JSONObject> getOrderRankRatioList(Map<String, Object> requestMap);
 
-    List<JSONObject>  getOrderRankList(Map<String, Object> requestMap);
+    List<JSONObject> getOrderRankList(Map<String, Object> requestMap);
 
     List<JSONObject> getPromoterRankRatioList(Map<String, Object> requestMap);
 
@@ -49,5 +49,19 @@ public interface SupplyChainMapper {
 
     List<JSONObject> getTopPromoterByItemId(Map<String, Object> requestMap);
 
+    List<JSONObject> bindUserItemList(Map<String, Object> requestMap);
 
+    List<JSONObject> getSupplyChainUserList();
+
+    boolean unbindUser(@Param("itemId") Long itemId);
+
+    boolean bindUser(@Param("itemId") Long itemId, @Param("userId") Long userId, @Param("nikeName") String nikeName);
+
+    List<JSONObject> adminReportList(Map<String, Object> requestMap);
+
+    List<JSONObject> userItemDetail(Map<String, Object> requestMap);
+
+    JSONObject getTimeIntervalRatio(Map<String, Object> requestMap);
+
+    List<JSONObject> indexStatistics(Map<String, Object> requestMap);
 }

+ 22 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/ISupplyChainService.java

@@ -63,5 +63,27 @@ public interface ISupplyChainService {
     //根据商品ID获取top达人
     List<JSONObject> getTopPromoterByItemId(Map<String, Object> requestMap);
 
+    //商品认领列表
+    List<JSONObject> bindUserItemList(Map<String, Object> requestMap);
 
+    // 获取供应链人员列表
+    List<JSONObject> getSupplyChainUserList();
+
+    // 商品解绑
+    boolean unbindUser(Long itemId);
+
+    // 商品绑定
+    boolean bindUser(Long itemId, Long userId, String nikeName);
+
+    //供应链管理员统计列表
+    List<JSONObject> adminReportList(Map<String, Object> requestMap);
+
+    // 认领商品列表
+    List<JSONObject> userItemDetail(Map<String, Object> requestMap);
+
+    // 获取时段数据对比
+    JSONObject getTimeIntervalRatio(Map<String, Object> requestMap);
+
+    // 首页-曲线图
+    List<JSONObject> indexStatistics(Map<String, Object> requestMap);
 }

+ 42 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/SupplyChainServiceImpl.java

@@ -46,7 +46,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     //商品列表
     @Override
     public List<JSONObject> itemList(Map<String, Object> requestMap) {
-        List<JSONObject>  list =   supplyChainMapper.itemList(requestMap);
+        List<JSONObject> list = supplyChainMapper.itemList(requestMap);
 
         return list;
     }
@@ -92,7 +92,7 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     }
 
     @Override
-    public List<JSONObject>  getOrderRankList(Map<String, Object> requestMap) {
+    public List<JSONObject> getOrderRankList(Map<String, Object> requestMap) {
         return supplyChainMapper.getOrderRankList(requestMap);
     }
 
@@ -125,4 +125,44 @@ public class SupplyChainServiceImpl implements ISupplyChainService {
     public List<JSONObject> getTopPromoterByItemId(Map<String, Object> requestMap) {
         return supplyChainMapper.getTopPromoterByItemId(requestMap);
     }
+
+    @Override
+    public List<JSONObject> bindUserItemList(Map<String, Object> requestMap) {
+        return supplyChainMapper.bindUserItemList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getSupplyChainUserList() {
+        return supplyChainMapper.getSupplyChainUserList();
+    }
+
+    @Override
+    public boolean unbindUser(Long itemId) {
+        return supplyChainMapper.unbindUser(itemId);
+    }
+
+    @Override
+    public boolean bindUser(Long itemId, Long userId, String nikeName) {
+        return supplyChainMapper.bindUser(itemId, userId, nikeName);
+    }
+
+    @Override
+    public List<JSONObject> adminReportList(Map<String, Object> requestMap) {
+        return supplyChainMapper.adminReportList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> userItemDetail(Map<String, Object> requestMap) {
+        return supplyChainMapper.userItemDetail(requestMap);
+    }
+
+    @Override
+    public JSONObject getTimeIntervalRatio(Map<String, Object> requestMap) {
+        return supplyChainMapper.getTimeIntervalRatio(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> indexStatistics(Map<String, Object> requestMap) {
+        return supplyChainMapper.indexStatistics(requestMap);
+    }
 }

+ 198 - 0
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -3,6 +3,15 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruixuan.isc.mapper.SupplyChainMapper">
+    <insert id="bindUser">
+        insert into
+        kuaishou_item_bind_user(item_id,user_id,user_name)
+        value
+        (#{itemId},#{userId},#{nikeName})
+    </insert>
+    <delete id="unbindUser" parameterType="java.lang.Long">
+        delete  from kuaishou_item_bind_user where  item_id = #{itemId}
+    </delete>
 
 
     <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
@@ -553,6 +562,195 @@
         group by item_id,promoter_id) t
         order by t.itemId,t.orderNum desc
     </select>
+    <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select t1.item_id as 'itemId',
+        t1.item_title as 'itemTitle',
+        t1.reserve_price as 'reservePrice',
+        t1.image_url as 'imageUrl',
+        t1.activity_id as 'activityId',
+        t1.regimental_promotion_rate as 'regimentalPromotionRate',
+        t2.user_id as 'userId',
+        case when t2.user_id is null then 1 else 0 end as 'status',
+        t2.user_name as 'userName',
+        t2.create_time as 'bindTime'
+        from kuaishou_item_info t1
+        left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
+        where 1 = 1
+        <if test="userId != null and userId != ''">
+            and t2.user_id = #{userId}
+        </if>
+        <if test="itemId != null and itemId != ''">
+            and t1.item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and t1.item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        <if test="activityId != null and activityId != ''">
+            and t1.activity_id = #{activityId}
+        </if>
+        order by t1.create_time desc) t
+        where 1 = 1
+        <if test="status != null and status != ''">
+            and t.status = #{status}
+        </if>
+
+    </select>
+    <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
+    select t3.user_id as 'userId',
+       t3.nick_name as 'nickMame',
+       t1.role_name as 'roleName',
+       t3.status
+    from sys_role t1
+         left join sys_user_role t2 on t1.role_id = t2.role_id
+         left join sys_user t3 on t2.user_id = t3.user_id
+     where t1.role_key in (
+                      'supplyChain',
+                      'commodityManagement',
+                      'supplyChainAdmin'
+    ) order  by t3.create_time asc
+
+    </select>
+    <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select t1.user_id as 'userId',
+        t1.user_name as 'userName',
+        count(distinct t2.item_id) as 'itemCount',
+        count(t2.oid) as 'orderNum',
+        sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
+        sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
+        when t2.order_status != 80
+        then 1
+        else 0 end),
+        4) as 'deliveryRadio',
+        sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
+        sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
+        sum(case
+        when t2.order_status != 80 then t2.regimental_promotion_amount
+        else 0 end) as 'regimentalPromotionAmount'
+        from kuaishou_item_bind_user t1
+        left join kuaishou_supply_chain t2
+        on t1.item_id = t2.item_id
+        where 1= 1
+        <if test="start != null and start != ''">
+            and t2.order_create_time &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t2.order_create_time &lt;= #{end}
+        </if>
+        group by t1.user_id) t
+        order by t.orderNum desc
+    </select>
+    <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        from (select
+        t2.item_id as 'itemId',
+        t2.item_title as 'itemTitle',
+        t2.image_url as 'imageUrl',
+        t2.reserve_price as 'reservePrice',
+        count(t2.oid) as 'orderNum',
+        sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
+        round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),
+        4) as 'validRadio',
+        sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
+        round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
+        when t2.order_status != 80
+        then 1
+        else 0 end),
+        4) as 'deliveryRadio',
+        sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
+        sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
+        sum(case
+        when t2.order_status != 80 then t2.regimental_promotion_amount
+        else 0 end) as 'regimentalPromotionAmount'
+        from kuaishou_item_bind_user t1
+        left join kuaishou_supply_chain t2
+        on t1.item_id = t2.item_id
+        where
+        t1.user_id = #{userId}
+        <if test="start != null and start != ''">
+            and t2.order_create_time &gt;= #{start}
+        </if>
+        <if test="end != null and end != ''">
+            and t2.order_create_time &lt;= #{end}
+        </if>
+        <if test="itemId != null and itemId != ''">
+            and item_id = #{itemId}
+        </if>
+        <if test="itemTitle != null and itemTitle != ''">
+            and item_title like concat(concat('%',#{itemTitle}),'%')
+        </if>
+        group by t1.item_id) t
+        order by t.orderNum desc
+    </select>
+    <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
+        select
+        round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
+        round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
+        from (
+        select count(oid) as 'oid',
+        sum(order_amount) as 'orderAmount'
+        from kuaishou_supply_chain
+        where 1= 1
+        <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
+            and order_create_time &gt;= #{thisCycleStartTemp}
+        </if>
+        <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
+            and order_create_time &lt;= #{thisCycleEndTemp}
+        </if>
+        ) t1
+        join (
+        select count(oid) as 'oid',
+        sum(order_amount) as 'orderAmount'
+        from kuaishou_supply_chain
+        where 1=1
+        <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
+            and order_create_time &gt;= #{lastCycleStartTemp}
+        </if>
+        <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
+            and order_create_time &lt;= #{lastCycleEndTemp}
+        </if>
+        ) t2
+
+    </select>
+    <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
+        select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
+        <if test="type == 'orderNum' ">
+            count(t.oid) as 'orderNum'
+        </if>
+        <if test="type == 'validOrderNum' ">
+            sum(case when t.order_status = 80 then 1 else 0 end) as 'invalidOrderNum'
+        </if>
+        <if test="type == 'orderAmount' ">
+            sum(t.order_amount) as 'orderAmount'
+        </if>
+        <if test="type == 'baseAmount' ">
+            sum(t.base_amount) as 'baseAmount'
+        </if>
+        <if test="type == 'deliveryNum' ">
+            sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
+        </if>
+        from (select
+        oid,
+        order_status,
+        order_amount,
+        base_amount,
+        send_status,
+        order_create_time
+        from kuaishou_supply_chain
+        where 1 = 1
+        <if test="startTemp != null and startTemp != ''">
+            and order_create_time &gt;= #{startTemp}
+        </if>
+        <if test="endTemp != null and endTemp != ''">
+            and order_create_time &lt;= #{endTemp}
+        </if>
+        ) t
+        group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
+        order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') desc
+    </select>
 
 
 </mapper>

+ 19 - 21
ruixuan-system/src/main/java/com/ruixuan/system/mapper/SysUserMapper.java

@@ -8,14 +8,13 @@ import com.ruixuan.common.core.domain.entity.SysUser;
 
 /**
  * 用户表 数据层
- * 
+ *
  * @author ruixuan
  */
-public interface SysUserMapper
-{
+public interface SysUserMapper {
     /**
      * 根据条件分页查询用户列表
-     * 
+     *
      * @param sysUser 用户信息
      * @return 用户信息集合信息
      */
@@ -23,7 +22,7 @@ public interface SysUserMapper
 
     /**
      * 根据条件分页查询已配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -31,7 +30,7 @@ public interface SysUserMapper
 
     /**
      * 根据条件分页查询未分配用户角色列表
-     * 
+     *
      * @param user 用户信息
      * @return 用户信息集合信息
      */
@@ -39,7 +38,7 @@ public interface SysUserMapper
 
     /**
      * 通过用户名查询用户
-     * 
+     *
      * @param userName 用户名
      * @return 用户对象信息
      */
@@ -52,9 +51,10 @@ public interface SysUserMapper
      * @return 用户对象信息
      */
     SysUser selectUserByNickName(String nickName);
+
     /**
      * 通过用户ID查询用户
-     * 
+     *
      * @param userId 用户ID
      * @return 用户对象信息
      */
@@ -62,7 +62,7 @@ public interface SysUserMapper
 
     /**
      * 新增用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -70,7 +70,7 @@ public interface SysUserMapper
 
     /**
      * 修改用户信息
-     * 
+     *
      * @param user 用户信息
      * @return 结果
      */
@@ -78,16 +78,16 @@ public interface SysUserMapper
 
     /**
      * 修改用户头像
-     * 
+     *
      * @param userName 用户名
-     * @param avatar 头像地址
+     * @param avatar   头像地址
      * @return 结果
      */
     public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar);
 
     /**
      * 重置用户密码
-     * 
+     *
      * @param userName 用户名
      * @param password 密码
      * @return 结果
@@ -96,7 +96,7 @@ public interface SysUserMapper
 
     /**
      * 通过用户ID删除用户
-     * 
+     *
      * @param userId 用户ID
      * @return 结果
      */
@@ -104,7 +104,7 @@ public interface SysUserMapper
 
     /**
      * 批量删除用户信息
-     * 
+     *
      * @param userIds 需要删除的用户ID
      * @return 结果
      */
@@ -112,7 +112,7 @@ public interface SysUserMapper
 
     /**
      * 校验用户名称是否唯一
-     * 
+     *
      * @param userName 用户名称
      * @return 结果
      */
@@ -147,6 +147,7 @@ public interface SysUserMapper
 
     /**
      * 根据用户id 查询用户和角色信息
+     *
      * @param userId
      * @return
      */
@@ -154,15 +155,12 @@ public interface SysUserMapper
 
     /**
      * 根据角色名称 查询用户信息
+     *
      * @param roleCodeList
      * @return
      */
     List<JSONObject> getUserByRoleName(@Param("roleCodeList") List<String> roleCodeList);
 
 
-
-
-
-
-
+    String getRoleKeyByUserId(@Param("userId") String userId);
 }

+ 1 - 0
ruixuan-system/src/main/java/com/ruixuan/system/service/ISysUserService.java

@@ -226,4 +226,5 @@ public interface ISysUserService {
 
     List<JSONObject> getUserByRoleName(List<String> roleCodeList);
 
+    String getRoleKeyByUserId(String userId);
 }

+ 5 - 0
ruixuan-system/src/main/java/com/ruixuan/system/service/impl/SysUserServiceImpl.java

@@ -540,4 +540,9 @@ public class SysUserServiceImpl implements ISysUserService {
         return userMapper.getUserByRoleName(roleCodeList);
     }
 
+    @Override
+    public String getRoleKeyByUserId(String userId) {
+        return userMapper.getRoleKeyByUserId(userId);
+    }
+
 }

+ 16 - 12
ruixuan-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -155,7 +155,7 @@
         where u.user_name = #{userName}
     </select>
 
-     <select id="selectUserByNickName" parameterType="String" resultMap="SysUserResult">
+    <select id="selectUserByNickName" parameterType="String" resultMap="SysUserResult">
         <include refid="selectUserVo"/>
         where u.nick_name = #{nickName}
     </select>
@@ -321,7 +321,6 @@
     </select>
 
 
-
     <!-- 根据用户id 查询用户和角色信息-->
     <select id="getUserRoleByUserId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
@@ -343,17 +342,17 @@
     <!-- 根据角色名称 查询用户信息-->
     <select id="getUserByRoleName" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            u.*,
-            r.role_name,
-            r.role_key
+        u.*,
+        r.role_name,
+        r.role_key
         FROM
-            sys_user u
-                LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
-                LEFT JOIN sys_role r ON r.role_id = ur.role_id
+        sys_user u
+        LEFT JOIN sys_user_role ur ON ur.user_id = u.user_id
+        LEFT JOIN sys_role r ON r.role_id = ur.role_id
         WHERE
-            r.del_flag = 0
-          AND u.del_flag = 0
-          AND u.STATUS = 0
+        r.del_flag = 0
+        AND u.del_flag = 0
+        AND u.STATUS = 0
         <if test="roleCodeList != null and roleCodeList.size() != 0 ">
             and r.role_key in
             <foreach collection="roleCodeList" item="item" separator=","
@@ -363,7 +362,12 @@
         </if>
 
     </select>
-
+    <select id="getRoleKeyByUserId" resultType="java.lang.String" parameterType="java.lang.String">
+         select t2.role_key
+         from sys_user_role t1
+         left join sys_role t2 on t1.role_id = t2.role_id
+         where t1.user_id = #{userId}
+    </select>
 
 
 </mapper>