Commit 8da9308c authored by licc's avatar licc

代码优化2

parent e47f419e
...@@ -4,6 +4,9 @@ import cn.wisenergy.model.app.ProgressPrize; ...@@ -4,6 +4,9 @@ import cn.wisenergy.model.app.ProgressPrize;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/** /**
* @author 86187 * @author 86187
*/ */
...@@ -14,4 +17,12 @@ public interface ProgressPrizeMapper extends BaseMapper<ProgressPrize> { ...@@ -14,4 +17,12 @@ public interface ProgressPrizeMapper extends BaseMapper<ProgressPrize> {
int edit(ProgressPrize progressPrize); int edit(ProgressPrize progressPrize);
int delById(@Param("id") Integer id); int delById(@Param("id") Integer id);
/**
* 根据 年月 获取月的最大进步奖用户列表
*
* @param yearMonth 年月
* @return 最大进步奖用户列表
*/
List<ProgressPrize> getByYearMonth(@Param("yearMonth") String yearMonth);
} }
...@@ -25,7 +25,7 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> { ...@@ -25,7 +25,7 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
* @param yearMonth 时间 * @param yearMonth 时间
* @return 用户月业绩 * @return 用户月业绩
*/ */
TeamPerformance getByUserIdAndTime(@Param("userId") String userId, @Param("yearMonth") Date yearMonth); TeamPerformance getByUserIdAndTime(@Param("userId") String userId, @Param("yearMonth") String yearMonth);
/** /**
* 统计 等级月业绩和 * 统计 等级月业绩和
...@@ -34,7 +34,7 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> { ...@@ -34,7 +34,7 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
* @param yearMonth 年月 * @param yearMonth 年月
* @return 等级总金额 * @return 等级总金额
*/ */
Double countTeamMoney(@Param("userLevel") Integer userLevel, @Param("yearMonth") Date yearMonth); Double countTeamMoney(@Param("userLevel") Integer userLevel, @Param("yearMonth") String yearMonth);
/** /**
* 获取时间前的 月业绩列表 * 获取时间前的 月业绩列表
...@@ -42,7 +42,7 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> { ...@@ -42,7 +42,7 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
* @param yearMonth 时间 * @param yearMonth 时间
* @return 月业绩列表 * @return 月业绩列表
*/ */
List<TeamPerformance> getByBeforeTime(@Param("yearMonth") Date yearMonth); List<TeamPerformance> getByBeforeTime(@Param("yearMonth") String yearMonth);
/** /**
* 根据时间统计 所有用户业绩和 * 根据时间统计 所有用户业绩和
...@@ -50,14 +50,14 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> { ...@@ -50,14 +50,14 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
* @param yearMonth 时间 * @param yearMonth 时间
* @return 所有用户业绩和 * @return 所有用户业绩和
*/ */
Double countByTime(@Param("yearMonth") Date yearMonth); Double countByTime(@Param("yearMonth") String yearMonth);
/** /**
* 月业绩排名前20人 业绩和 * 月业绩排名前20人 业绩和
* @param yearMonth 时间 * @param yearMonth 时间
* @return 业绩和 * @return 业绩和
*/ */
Double countTwenty(@Param("yearMonth") Date yearMonth); Double countTwenty(@Param("yearMonth") String yearMonth);
List<TeamPerformance> userTwenty(@Param("yearMonth") Date yearMonth); List<TeamPerformance> userTwenty(@Param("yearMonth") String yearMonth);
} }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</resultMap> </resultMap>
<sql id="table"> <sql id="table">
month_award progress_prize
</sql> </sql>
<sql id="cols_all"> <sql id="cols_all">
...@@ -72,4 +72,18 @@ ...@@ -72,4 +72,18 @@
where id = #{id} where id = #{id}
</delete> </delete>
<select id="getByYearMonth" resultType="cn.wisenergy.model.app.ProgressPrize">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="yearMonth != null">
AND(
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -40,7 +40,7 @@ public class AccountInfo implements Serializable { ...@@ -40,7 +40,7 @@ public class AccountInfo implements Serializable {
* 年月 * 年月
*/ */
@ApiModelProperty(name = "yearMonth", value = "年月") @ApiModelProperty(name = "yearMonth", value = "年月")
private Date yearMonth; private String yearMonth;
/** /**
......
...@@ -29,7 +29,7 @@ public class MonthAward implements Serializable { ...@@ -29,7 +29,7 @@ public class MonthAward implements Serializable {
* 年月 * 年月
*/ */
@ApiModelProperty(name = "yearMonth", value = "年月") @ApiModelProperty(name = "yearMonth", value = "年月")
private Date yearMonth; private String yearMonth;
/** /**
* 本月月度肥料总额 * 本月月度肥料总额
......
...@@ -8,10 +8,10 @@ import java.math.BigDecimal; ...@@ -8,10 +8,10 @@ import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
*@ Description: 每月进步奖实体类
*@ Author : 86187
*@ Date : 2021/3/1 9:31
* @author 86187 * @author 86187
* @ Description: 每月进步奖实体类
* @ Author : 86187
* @ Date : 2021/3/1 9:31
*/ */
@Data @Data
public class ProgressPrize implements Serializable { public class ProgressPrize implements Serializable {
...@@ -20,43 +20,43 @@ public class ProgressPrize implements Serializable { ...@@ -20,43 +20,43 @@ public class ProgressPrize implements Serializable {
/** /**
* 主键id * 主键id
*/ */
@ApiModelProperty(value = "主键id",name = "id") @ApiModelProperty(value = "主键id", name = "id")
private Integer id; private Integer id;
/** /**
* 用户id * 用户id
*/ */
@ApiModelProperty(value = "用户id",name = "userId") @ApiModelProperty(value = "用户id", name = "userId")
private String userId; private String userId;
/** /**
* 年月 * 年月
*/ */
@ApiModelProperty(value = "年月",name = "yearMonth") @ApiModelProperty(value = "年月", name = "yearMonth")
private Date yearMonth; private String yearMonth;
/** /**
* 本月增长率 * 本月增长率
*/ */
@ApiModelProperty(value = "本月增长率",name = "growthRate") @ApiModelProperty(value = "本月增长率", name = "growthRate")
private BigDecimal growthRate; private Double growthRate;
/** /**
* 进步奖奖金 * 进步奖奖金
*/ */
@ApiModelProperty(value = "进步奖奖金",name = "awardMoney") @ApiModelProperty(value = "进步奖奖金", name = "awardMoney")
private BigDecimal awardMoney; private Double awardMoney;
/** /**
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(value = "创建时间",name = "createTime") @ApiModelProperty(value = "创建时间", name = "createTime")
private Date createTime; private Date createTime;
/** /**
* 更新时间 * 更新时间
*/ */
@ApiModelProperty(value = "更新时间",name = "updateTime") @ApiModelProperty(value = "更新时间", name = "updateTime")
private Date updateTime; private Date updateTime;
} }
...@@ -41,7 +41,7 @@ public class TeamPerformance implements Serializable { ...@@ -41,7 +41,7 @@ public class TeamPerformance implements Serializable {
* 年-月 * 年-月
*/ */
@ApiModelProperty(value = "年-月", name = "yearMonth") @ApiModelProperty(value = "年-月", name = "yearMonth")
private Date yearMonth; private String yearMonth;
/** /**
* 本月团队业绩 * 本月团队业绩
......
...@@ -20,7 +20,9 @@ public enum TradeRecordEnum { ...@@ -20,7 +20,9 @@ public enum TradeRecordEnum {
CULTIVATING_PRIZE(5, "培育奖"), CULTIVATING_PRIZE(5, "培育奖"),
SALARY_REWARD(6, "工资奖励"); SALARY_REWARD(6, "工资奖励"),
PROGRESS_PRIZE(7, "最大进步奖");
private Integer code; private Integer code;
private String desc; private String desc;
......
...@@ -8,9 +8,23 @@ import lombok.Data; ...@@ -8,9 +8,23 @@ import lombok.Data;
*/ */
@Data @Data
public class TeamPerformanceSortVo { public class TeamPerformanceSortVo {
/**
* 增长率
*/
private Double growthRate; private Double growthRate;
/**
* 用户id
*/
private String userId;
/**
* 月团队业绩
*/
private Double monthPerformance; private Double monthPerformance;
/**
* 月团队业绩 类
*/
private TeamPerformance teamPerformance; private TeamPerformance teamPerformance;
} }
package cn.wisenergy.service.Manager; package cn.wisenergy.service.Manager;
import cn.wisenergy.mapper.AccountMapper; import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.mapper.OrderMapper; import cn.wisenergy.mapper.*;
import cn.wisenergy.mapper.TeamPerformanceMapper;
import cn.wisenergy.mapper.TradeRecordMapper;
import cn.wisenergy.model.app.*; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.RebateStatusEnum; import cn.wisenergy.model.enums.RebateStatusEnum;
import cn.wisenergy.model.enums.TradeRecordEnum; import cn.wisenergy.model.enums.TradeRecordEnum;
import cn.wisenergy.model.vo.TeamPerformanceSortVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -37,6 +39,15 @@ public class AccountManager { ...@@ -37,6 +39,15 @@ public class AccountManager {
@Autowired @Autowired
private TeamPerformanceMapper teamPerformanceMapper; private TeamPerformanceMapper teamPerformanceMapper;
@Autowired
private ProgressPrizeMapper progressPrizeMapper;
@Autowired
private TradeRecordMapper tradeRecordMapper;
private static final String PATTERN = "yyyy-MM";
/** /**
* 保存用户佣金 * 保存用户佣金
* *
...@@ -78,4 +89,26 @@ public class AccountManager { ...@@ -78,4 +89,26 @@ public class AccountManager {
teamPerformanceMapper.updateById(teamPerformance); teamPerformanceMapper.updateById(teamPerformance);
} }
} }
@Transactional(rollbackFor = Exception.class)
public void updateOrSavePrize(List<TeamPerformanceSortVo> listVo, List<AccountInfo> accountInfos, List<ProgressPrize> prizes) {
Date date = new Date();
String yearMonth = DateUtil.convertDateToStr(date, PATTERN);
//判断 prizes 是否为空集合,是新增
//新增
if (CollectionUtils.isEmpty(prizes)) {
for (TeamPerformanceSortVo sortVo : listVo) {
String userId = sortVo.getTeamPerformance().getUserId();
ProgressPrize progressPrize = new ProgressPrize();
progressPrize.setUserId(userId);
progressPrize.setGrowthRate(sortVo.getGrowthRate());
progressPrize.setAwardMoney(sortVo.getMonthPerformance());
progressPrize.setYearMonth(yearMonth);
progressPrizeMapper.add(progressPrize);
}
} else {
}
}
} }
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.FileUtils;
import cn.wisenergy.model.app.shopZx;
import cn.wisenergy.service.app.UploadService; import cn.wisenergy.service.app.UploadService;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
......
...@@ -18,6 +18,7 @@ import java.util.Map; ...@@ -18,6 +18,7 @@ import java.util.Map;
/** /**
* shiro配置类 * shiro配置类
* @author 86187
*/ */
@Configuration @Configuration
public class ShiroConfig { public class ShiroConfig {
......
...@@ -47,30 +47,3 @@ mybatis-plus: ...@@ -47,30 +47,3 @@ mybatis-plus:
cache-enabled: false cache-enabled: false
call-setters-on-nulls: true call-setters-on-nulls: true
jdbc-type-for-null: 'null' jdbc-type-for-null: 'null'
camera:
ysy: #萤石云
api:
appKey: 53ff83088a8b445ea1b30c0ba85f7653
appSecret: 0274e379003912b7ec1f3ef18a169624
isc: #海康威视
api:
host: 172.18.1.51:4443
#host: 111.203.232.172:4443
appKey: 23756916
appSecret: TDrCbqQXe9XSt7SimYDO
path: /artemis
absoluteImgPath: d://Pictures/img/
sonImgPath : d://img/
sms:
accessKeyId: LTAI4G6xmYPhjrS18Bxz5Kqu
secret: l3ZuSn2XjsFZXaB3yb8O5ASRJh3DDe
regionId: cn-hangzhou
domain: dysmsapi.aliyuncs.com
version: 2017-05-25
action: SendSms
signName: 西田森生物科技
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment