From 32169b0b5af53ae87ccde57c31c1d6ad6e44a055 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 14 Jul 2021 16:51:32 +0800
Subject: [PATCH] Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop

---
 gc-user/src/main/java/com/xzx/gc/user/dto/HeadProfitLitDto.java            |   22 +++++
 gc-user/src/main/java/com/xzx/gc/user/vo/HeadProfitListVo.java             |   37 +++++++++
 gc-core/src/main/resources/application.properties                          |    2 
 gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java          |   20 ++++
 gc-user/src/main/java/com/xzx/gc/user/vo/HeadTeamVo.java                   |   34 ++++++++
 gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml            |   13 +++
 gc-user/src/main/java/com/xzx/gc/user/dto/HeadTeamDto.java                 |   23 +++++
 gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadDetailsMapper.java    |   14 +++
 gc-user/src/main/resources/mapper/user/UserHeadDetailsMapper.xml           |   21 +++++
 gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java     |    5 +
 gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java |   33 ++++++++
 11 files changed, 221 insertions(+), 3 deletions(-)

diff --git a/gc-core/src/main/resources/application.properties b/gc-core/src/main/resources/application.properties
index b09f250..832738b 100644
--- a/gc-core/src/main/resources/application.properties
+++ b/gc-core/src/main/resources/application.properties
@@ -11,7 +11,7 @@
 
 
 #log
-project.log.path=xzx/logs
+project.log.path=/xzx/logs
 logstash.server.url=localhost:4560
 
 #spring
diff --git a/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java b/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java
index 405159a..26dcc51 100644
--- a/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java
+++ b/gc-user/src/main/java/com/xzx/gc/user/controller/ApiDistribController.java
@@ -3,16 +3,24 @@
 import com.xzx.gc.common.request.BaseController;
 import com.xzx.gc.model.JsonResult;
 import com.xzx.gc.user.dto.DistribJoinDto;
+import com.xzx.gc.user.dto.HeadProfitLitDto;
+import com.xzx.gc.user.dto.HeadTeamDto;
 import com.xzx.gc.user.service.DistribService;
 import com.xzx.gc.user.vo.HeadInfoVo;
+import com.xzx.gc.user.vo.HeadProfitListVo;
+import com.xzx.gc.user.vo.HeadTeamVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 /**
  * @author wzy
@@ -33,10 +41,33 @@
         return JsonResult.success();
     }
 
-
     @ApiOperation("获取团长信息")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "success", response = HeadInfoVo.class)
+    })
     @PostMapping(value = "/distrib/headInfo")
     public JsonResult<HeadInfoVo> headInfo(HttpServletRequest request) {
         return JsonResult.success(distribService.findHeadInfo(getUserId(request)));
     }
+
+    @ApiOperation("我的收益")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "success", response = HeadProfitListVo.class)
+    })
+    @PostMapping(value = "/distrib/headProfit")
+    public JsonResult<List<HeadProfitListVo>> headProfitList(@RequestBody HeadProfitLitDto headProfitLitDto, HttpServletRequest request) {
+        headProfitLitDto.setUserId(getUserId(request));
+        return JsonResult.success(distribService.findHeadProfitListInPage(headProfitLitDto));
+    }
+
+    @ApiOperation("我的团队")
+    @ApiResponses({
+            @ApiResponse(code = 200, message = "success", response = HeadProfitListVo.class)
+    })
+    @PostMapping(value = "/distrib/headTeam")
+    public JsonResult<List<HeadTeamVo>> headTimeList(@RequestBody HeadTeamDto headTeamDto, HttpServletRequest request) {
+        headTeamDto.setUserId(getUserId(request));
+        return JsonResult.success(distribService.findHeadTeamListInPage(headTeamDto));
+    }
+
 }
diff --git a/gc-user/src/main/java/com/xzx/gc/user/dto/HeadProfitLitDto.java b/gc-user/src/main/java/com/xzx/gc/user/dto/HeadProfitLitDto.java
new file mode 100644
index 0000000..5cd7c6d
--- /dev/null
+++ b/gc-user/src/main/java/com/xzx/gc/user/dto/HeadProfitLitDto.java
@@ -0,0 +1,22 @@
+package com.xzx.gc.user.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author wzy
+ * @date 2021-07-14
+ **/
+@Data
+@ApiModel(value = "HeadProfitLitDto", description = "我的收益接收参数类")
+public class HeadProfitLitDto {
+    @ApiModelProperty(value = "第几页", required = true)
+    private int page;
+
+    @ApiModelProperty(value = "每一页数量", required = true)
+    private int limit;
+
+    @ApiModelProperty(hidden = true)
+    private String userId;
+}
diff --git a/gc-user/src/main/java/com/xzx/gc/user/dto/HeadTeamDto.java b/gc-user/src/main/java/com/xzx/gc/user/dto/HeadTeamDto.java
new file mode 100644
index 0000000..6afc0af
--- /dev/null
+++ b/gc-user/src/main/java/com/xzx/gc/user/dto/HeadTeamDto.java
@@ -0,0 +1,23 @@
+package com.xzx.gc.user.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author wzy
+ * @date 2021-07-14
+ **/
+@Data
+@ApiModel(value = "HeadTeamDto", description = "我的团队接收参数类")
+public class HeadTeamDto {
+
+    @ApiModelProperty(value = "第几页", required = true)
+    private int page;
+
+    @ApiModelProperty(value = "每一页数量", required = true)
+    private int limit;
+
+    @ApiModelProperty(hidden = true)
+    private String userId;
+}
diff --git a/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadDetailsMapper.java b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadDetailsMapper.java
new file mode 100644
index 0000000..63b2db9
--- /dev/null
+++ b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadDetailsMapper.java
@@ -0,0 +1,14 @@
+package com.xzx.gc.user.mapper;
+
+import com.xzx.gc.entity.UserHeadDetails;
+import com.xzx.gc.user.dto.HeadProfitLitDto;
+import com.xzx.gc.user.vo.HeadProfitListVo;
+import com.xzx.gc.util.GcMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface UserHeadDetailsMapper extends GcMapper<UserHeadDetails> {
+
+    List<HeadProfitListVo> selectHeadProfitListInPage(@Param("userId") String userId);
+}
diff --git a/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java
index 25015d6..9e84222 100644
--- a/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java
+++ b/gc-user/src/main/java/com/xzx/gc/user/mapper/UserHeadRelateMapper.java
@@ -2,12 +2,17 @@
 
 import com.xzx.gc.entity.UserHeadRelate;
 import com.xzx.gc.user.vo.HeadInfoVo;
+import com.xzx.gc.user.vo.HeadTeamVo;
 import com.xzx.gc.util.GcMapper;
 import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface UserHeadRelateMapper extends GcMapper<UserHeadRelate> {
 
     UserHeadRelate selectMemberByUserId(@Param("userId") String userId);
 
     HeadInfoVo selectHeadStatisticsData(@Param("userId") String userId);
+
+    List<HeadTeamVo> selectHeadTeamListInPage(@Param("userId") String userId);
 }
diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java
index d8eeaed..766ea84 100644
--- a/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java
+++ b/gc-user/src/main/java/com/xzx/gc/user/service/DistribService.java
@@ -12,6 +12,12 @@
 import com.xzx.gc.entity.SysMessage;
 import com.xzx.gc.entity.UserHeadRelate;
 import com.xzx.gc.entity.UserShareInfo;
+import com.xzx.gc.user.dto.HeadProfitLitDto;
+import com.xzx.gc.user.dto.HeadTeamDto;
+import com.xzx.gc.user.mapper.*;
+import com.xzx.gc.user.vo.HeadInfoVo;
+import com.xzx.gc.user.vo.HeadProfitListVo;
+import com.xzx.gc.user.vo.HeadTeamVo;
 import com.xzx.gc.user.dto.AdddistribDto;
 import com.xzx.gc.user.dto.DistribInfoListDto;
 import com.xzx.gc.user.dto.DistribListDto;
@@ -37,6 +43,7 @@
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 @Service
@@ -47,7 +54,8 @@
     private RedPaperRuleMapper redPaperRuleMapper;
     @Autowired
     private UserHeadRelateMapper userHeadRelateMapper;
-
+    @Autowired
+    private UserHeadDetailsMapper userHeadDetailsMapper;
     @Autowired
     private AccountMapper accountMapper;
     @Autowired
@@ -145,6 +153,16 @@
         return headInfoVo;
     }
 
+    public List<HeadProfitListVo> findHeadProfitListInPage(HeadProfitLitDto profitLitDto) {
+        PageHelper.startPage(profitLitDto.getPage(), profitLitDto.getLimit());
+        return userHeadDetailsMapper.selectHeadProfitListInPage(profitLitDto.getUserId());
+    }
+
+    public List<HeadTeamVo> findHeadTeamListInPage(HeadTeamDto teamDto) {
+        PageHelper.startPage(teamDto.getPage(), teamDto.getLimit());
+        return userHeadRelateMapper.selectHeadTeamListInPage(teamDto.getUserId());
+    }
+
     public void addSetting(UpdateSettingDto model) {
         RedPaperRule redPaperRule = new RedPaperRule();
         StringBuffer stringBuffer = new StringBuffer();
diff --git a/gc-user/src/main/java/com/xzx/gc/user/vo/HeadProfitListVo.java b/gc-user/src/main/java/com/xzx/gc/user/vo/HeadProfitListVo.java
new file mode 100644
index 0000000..a923c18
--- /dev/null
+++ b/gc-user/src/main/java/com/xzx/gc/user/vo/HeadProfitListVo.java
@@ -0,0 +1,37 @@
+package com.xzx.gc.user.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wzy
+ * @date 2021-07-14
+ **/
+@Data
+@ApiModel(value = "HeadProfitListVo", description = "我的收益接口返回参数类")
+public class HeadProfitListVo {
+
+    @ApiModelProperty(value = "订单编号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "会员名称")
+    private String name;
+
+    @ApiModelProperty(value = "订单金额")
+    private BigDecimal orderAmount;
+
+    @ApiModelProperty(value = "完成时间")
+    private String finishTime;
+
+    @ApiModelProperty(value = "回收类型")
+    private String type;
+
+    @ApiModelProperty(value = "环保币")
+    private BigDecimal amount;
+
+    @ApiModelProperty(value = "积分")
+    private BigDecimal score;
+}
diff --git a/gc-user/src/main/java/com/xzx/gc/user/vo/HeadTeamVo.java b/gc-user/src/main/java/com/xzx/gc/user/vo/HeadTeamVo.java
new file mode 100644
index 0000000..d1d321b
--- /dev/null
+++ b/gc-user/src/main/java/com/xzx/gc/user/vo/HeadTeamVo.java
@@ -0,0 +1,34 @@
+package com.xzx.gc.user.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wzy
+ * @date 2021-07-14
+ **/
+@Data
+@ApiModel(value = "HeadTeamVo", description = "我的团队返回参数类")
+public class HeadTeamVo {
+
+    @ApiModelProperty(value = "微信昵称")
+    private String name;
+
+    @ApiModelProperty(value = "头像")
+    private String avatar;
+
+    @ApiModelProperty(value = "绑定时间")
+    private String bindTime;
+
+    @ApiModelProperty(value = "最后下单时间")
+    private String lastOrderTime;
+
+    @ApiModelProperty(value = "积分")
+    private BigDecimal score;
+
+    @ApiModelProperty(value = "环保币")
+    private BigDecimal amount;
+}
diff --git a/gc-user/src/main/resources/mapper/user/UserHeadDetailsMapper.xml b/gc-user/src/main/resources/mapper/user/UserHeadDetailsMapper.xml
new file mode 100644
index 0000000..816e165
--- /dev/null
+++ b/gc-user/src/main/resources/mapper/user/UserHeadDetailsMapper.xml
@@ -0,0 +1,21 @@
+<?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.xzx.gc.user.mapper.UserHeadDetailsMapper">
+
+    <select id="selectHeadProfitListInPage" resultType="com.xzx.gc.user.vo.HeadProfitListVo">
+        select
+            a.order_no orderNo,
+            FROM_BASE64(d.nick_name) name,
+            a.score,
+            a.amount,
+            b.receiving_time finishTime,
+            "住宅" type,
+            sum(c.score) orderAmount
+        from xzx_user_head_details a
+         inner join xzx_jhy_order b on a.order_no=b.order_no
+         inner join xzx_jhy_order_items c on b.id=c.order_id
+         inner join xzx_user_info d on b.user_id = d.user_id
+        where head_user_id=#{userId}
+        group by a.order_no, d.nick_name, a.score, a.amount, b.receiving_time
+    </select>
+</mapper>
\ No newline at end of file
diff --git a/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml b/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml
index 0b0db58..8b05c8e 100644
--- a/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml
+++ b/gc-user/src/main/resources/mapper/user/UserHeadRelateMapper.xml
@@ -16,4 +16,17 @@
         where a.head_user_id=#{userId}
         group by a.head_user_id
     </select>
+
+    <select id="selectHeadTeamListInPage" resultType="com.xzx.gc.user.vo.HeadTeamVo">
+        select
+            from_base64(b.nick_name) name,
+            b.avatar,
+            date_format(a.CREATED_TIME, '%Y/%m/%d') bindTime,
+            a.score,
+            a.amount,
+            date_format((select c.CREATED_TIME from xzx_jhy_order c where b.user_id=c.user_id and c.status=3 order by id desc limit 1), '%Y/%m/%d') lastOrderTime
+        from xzx_user_head_relate a
+                 inner join xzx_user_info b on a.user_id=b.user_id
+        where a.head_user_id=#{userId}
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1