From 975888ed15a3326b824ebc6d28a769da56e3bcd8 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 21 Dec 2020 18:18:30 +0800
Subject: [PATCH] modify
---
zq-erp/src/main/java/com/matrix/system/api/action/UsersAction.java | 15 ++++
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml | 14 ++++
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java | 4 +
zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java | 46 ++++++++++++++-
zq-erp/src/main/java/com/matrix/system/api/vo/UserAchieveVo.java | 80 ++++++++++++++++++++++++++
zq-erp/src/main/java/com/matrix/system/hive/service/AchieveNewService.java | 3 +
6 files changed, 157 insertions(+), 5 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/api/action/UsersAction.java b/zq-erp/src/main/java/com/matrix/system/api/action/UsersAction.java
index fd7d50f..68402ca 100644
--- a/zq-erp/src/main/java/com/matrix/system/api/action/UsersAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/api/action/UsersAction.java
@@ -1,8 +1,13 @@
package com.matrix.system.api.action;
import com.matrix.core.pojo.AjaxResult;
+import com.matrix.system.api.vo.UserAchieveVo;
+import com.matrix.system.hive.service.AchieveNewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,12 +22,20 @@
@RequestMapping(value = "/api/user")
public class UsersAction {
+ @Autowired
+ private AchieveNewService achieveNewService;
@ApiOperation(value = "获取用户业绩接口 type 1-今日 2-昨天 3-本月 4-上月")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "ok", response = UserAchieveVo.class)
+ })
@GetMapping(value = "/findUserAchieve/{type}")
public AjaxResult findUserAchieve(@PathVariable("type") Integer type) {
- return null;
+ UserAchieveVo achieveVo = achieveNewService.findUserAchieveByTime(type);
+ AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功");
+ ajaxResult.putInMap("achieve", achieveVo);
+ return ajaxResult;
}
diff --git a/zq-erp/src/main/java/com/matrix/system/api/vo/UserAchieveVo.java b/zq-erp/src/main/java/com/matrix/system/api/vo/UserAchieveVo.java
new file mode 100644
index 0000000..a8cbaa9
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/api/vo/UserAchieveVo.java
@@ -0,0 +1,80 @@
+package com.matrix.system.api.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wzy
+ * @date 2020-12-21
+ **/
+@ApiModel(value = "UserAchieveVo", description = "员工业绩返回类")
+public class UserAchieveVo {
+
+ @ApiModelProperty(value = "总现金业绩")
+ private BigDecimal allCash;
+
+ @ApiModelProperty(value = "售卡业绩")
+ private BigDecimal card;
+
+ @ApiModelProperty(value = "项目业绩")
+ private BigDecimal project;
+
+ @ApiModelProperty(value = "产品业绩")
+ private BigDecimal product;
+
+ @ApiModelProperty(value = "余额划扣业绩")
+ private BigDecimal cardUse;
+
+ @ApiModelProperty(value = "服务提成")
+ private BigDecimal projCommission;
+
+ public BigDecimal getAllCash() {
+ return allCash;
+ }
+
+ public void setAllCash(BigDecimal allCash) {
+ this.allCash = allCash;
+ }
+
+ public BigDecimal getCard() {
+ return card;
+ }
+
+ public void setCard(BigDecimal card) {
+ this.card = card;
+ }
+
+ public BigDecimal getProject() {
+ return project;
+ }
+
+ public void setProject(BigDecimal project) {
+ this.project = project;
+ }
+
+ public BigDecimal getProduct() {
+ return product;
+ }
+
+ public void setProduct(BigDecimal product) {
+ this.product = product;
+ }
+
+ public BigDecimal getCardUse() {
+ return cardUse;
+ }
+
+ public void setCardUse(BigDecimal cardUse) {
+ this.cardUse = cardUse;
+ }
+
+ public BigDecimal getProjCommission() {
+ return projCommission;
+ }
+
+ public void setProjCommission(BigDecimal projCommission) {
+ this.projCommission = projCommission;
+ }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java b/zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java
index f39cd28..8695c69 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java
@@ -1,9 +1,11 @@
package com.matrix.system.hive.dao;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import com.matrix.core.pojo.PaginationVO;
+import com.matrix.system.api.vo.UserAchieveVo;
import com.matrix.system.hive.bean.AchieveNew;
import org.apache.ibatis.annotations.Param;
@@ -55,5 +57,7 @@
List<AchieveNew> selectVipConsumeStatisticsList(@Param("record") AchieveNew achieveNew, @Param("pageVo") PaginationVO pageVo);
int selectVipConsumeStatisticsTotal(@Param("record") AchieveNew achieveNew);
+
+ UserAchieveVo selectUserAchieveByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("userId") Long userId);
}
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/AchieveNewService.java b/zq-erp/src/main/java/com/matrix/system/hive/service/AchieveNewService.java
index 0b2ec73..05a4c25 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/AchieveNewService.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/AchieveNewService.java
@@ -2,6 +2,7 @@
import java.util.List;
+import com.matrix.system.api.vo.UserAchieveVo;
import com.matrix.system.hive.bean.AchieveNew;
import com.matrix.system.hive.bean.SysOrder;
import com.matrix.system.hive.bean.SysProjServices;
@@ -113,4 +114,6 @@
int findVipConsumeStatisticsTotal(AchieveNew achieveNew);
+ public UserAchieveVo findUserAchieveByTime(int type);
+
}
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java
index df7c66e..2209a1c 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java
@@ -1,9 +1,14 @@
package com.matrix.system.hive.service.imp;
+import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
+import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.ModelUtils;
import com.matrix.core.tools.StringUtils;
+import com.matrix.core.tools.WebUtil;
+import com.matrix.system.api.vo.UserAchieveVo;
+import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.dao.SysUsersDao;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.*;
@@ -16,10 +21,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* This field was generated by Zking.software.Codegen.
@@ -317,4 +319,40 @@
public int findVipConsumeStatisticsTotal(AchieveNew achieveNew) {
return achieveNewDao.selectVipConsumeStatisticsTotal(achieveNew);
}
+
+ @Override
+ public UserAchieveVo findUserAchieveByTime(int type) {
+ SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+ Calendar calendar = Calendar.getInstance();
+ Date startTime = calendar.getTime();
+ Date endTime = calendar.getTime();
+ switch (type) {
+ // 本日
+ case 1 :
+ break;
+ // 昨日
+ case 2:
+ startTime = DateUtil.previousNDate(startTime, 1);
+ endTime = startTime;
+ break;
+ // 本月
+ case 3:
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ startTime = calendar.getTime();
+ break;
+ // 上月
+ case 4:
+ calendar.add(Calendar.MONTH, -1);
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+ startTime = calendar.getTime();
+ calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+ endTime = calendar.getTime();
+ break;
+ default:
+ break;
+
+ }
+
+ return achieveNewDao.selectUserAchieveByTime(startTime, endTime, users.getSuId());
+ }
}
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
index c8ab5b1..a3a562c 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
@@ -923,4 +923,18 @@
and FIND_IN_SET(#{record.beaultId}, a.BEATUY_ID)
</if>
</select>
+
+
+ <select id="selectUserAchieveByTime" resultType="com.matrix.system.api.vo.UserAchieveVo">
+ select
+ sum(IFNULL(proj_cash,0) + IFNULL(goods_cash,0) + IFNULL(card_cash,0)) allCash,
+ sum(card_cash) card,
+ sum(proj_cash) project,
+ sum(goods_cash) product,
+ sum(consume) cardUse,
+ sum(proj_percentage) projCommission
+ from achieve_new
+ where sale_id=#{userId}
+ and (date_format(datatime, "%Y-%m-%d") >= #{startTime} or #{endTime} >= date_format(datatime, "%Y-%m-%d"))
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.1