Commit d23ffc5d authored by m1991's avatar m1991

Merge remote-tracking branch 'origin/master'

parents 6eaf4672 62967cae
...@@ -52,8 +52,8 @@ public interface OrderMapper extends BaseMapper<OrderInfo> { ...@@ -52,8 +52,8 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
/** /**
* 更据创建订单时间获取订单列表 * 更据创建订单时间获取订单列表
* @param createTime 创建订单时间 * @param created 创建订单时间
* @return 订单列表 * @return 订单列表
*/ */
List<OrderInfo> getByCreateTime(@Param("createTime") Date createTime); List<OrderInfo> getByCreateTime(@Param("created") Date created);
} }
...@@ -14,6 +14,11 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> { ...@@ -14,6 +14,11 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
int add(TeamPerformance teamPerformance); int add(TeamPerformance teamPerformance);
/**
* 编辑
* @param teamPerformance 团队业绩
* @return 1
*/
int edit(TeamPerformance teamPerformance); int edit(TeamPerformance teamPerformance);
int delById(@Param("id") Integer id); int delById(@Param("id") Integer id);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
year_month,manure_award,create_time,update_time `year_month`,manure_award,create_time,update_time
</sql> </sql>
<sql id="vals"> <sql id="vals">
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
<if test="yearMonth != null">year_month =#{yearMonth},</if> <if test="yearMonth != null">`year_month` =#{yearMonth},</if>
<if test="manureAward != null">manure_award = #{manureAward},</if> <if test="manureAward != null">manure_award = #{manureAward},</if>
update_time =now() update_time =now()
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
<if test="id != null">id = #{id}</if> <if test="id != null">id = #{id}</if>
<if test="yearMonth != null">and year_month =#{yearMonth}</if> <if test="yearMonth != null">and `year_month` =#{yearMonth}</if>
<if test="manureAward != null">and manure_award = #{manureAward}</if> <if test="manureAward != null">and manure_award = #{manureAward}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if> <if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if> <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="yearMonth != null and yearMonth != ''"> <if test="yearMonth != null and yearMonth != ''">
year_month=#{yearMonth} `year_month`=#{yearMonth}
</if> </if>
</where> </where>
</select> </select>
......
...@@ -146,9 +146,9 @@ ...@@ -146,9 +146,9 @@
from from
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="successTime != null "> <if test="created != null ">
YEAR(create_time) = YEAR(#{successTime}) YEAR(created) = YEAR(#{created})
AND MONTH(create_time) = MONTH(#{successTime}) AND MONTH(created) = MONTH(#{created})
</if> </if>
</where> </where>
</select> </select>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
user_id,user_level,year_month,month_team_performance,create_time,update_time user_id,user_level,`year_month`,month_team_performance,create_time,update_time
</sql> </sql>
<sql id="vals"> <sql id="vals">
...@@ -29,18 +29,18 @@ ...@@ -29,18 +29,18 @@
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
<if test="userId != null">month_manure_total = #{userId},</if> <if test="userId != null">user_id = #{userId},</if>
<if test="userLevel != null">user_level = #{userLevel},</if> <if test="userLevel != null">user_level = #{userLevel},</if>
<if test="yearMonth != null">year_month =#{yearMonth},</if> <if test="yearMonth != null">`year_month` =#{yearMonth},</if>
<if test="monthTeamPerformance != null">month_team_performance =#{monthTeamPerformance},</if> <if test="monthTeamPerformance != null">month_team_performance =#{monthTeamPerformance},</if>
update_time =now() update_time =now()
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
<if test="id != null">id = #{id}</if> <if test="id != null">id = #{id}</if>
<if test="userId != null">and month_manure_total = #{userId}</if> <if test="userId != null">and user_id = #{userId}</if>
<if test="userLevel != null">and user_level = #{userLevel}</if> <if test="userLevel != null">and user_level = #{userLevel}</if>
<if test="yearMonth != null">and year_month =#{yearMonth}</if> <if test="yearMonth != null">and `year_month` =#{yearMonth}</if>
<if test="monthTeamPerformance != null">and month_team_performance =#{monthTeamPerformance}</if> <if test="monthTeamPerformance != null">and month_team_performance =#{monthTeamPerformance}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if> <if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if> <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
...@@ -82,9 +82,7 @@ ...@@ -82,9 +82,7 @@
user_id = #{userId} user_id = #{userId}
</if> </if>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( and `year_month`=#{yearMonth}
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if> </if>
</where> </where>
</select> </select>
...@@ -99,9 +97,7 @@ ...@@ -99,9 +97,7 @@
user_level = #{userLevel} user_level = #{userLevel}
</if> </if>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( and `year_month` = #{yearMonth}
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if> </if>
</where> </where>
</select> </select>
...@@ -113,7 +109,7 @@ ...@@ -113,7 +109,7 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="yearMonth != null"> <if test="yearMonth != null">
year_month &lt; #{yearMonth} `year_month` &lt; #{yearMonth}
</if> </if>
</where> </where>
</select> </select>
...@@ -125,9 +121,7 @@ ...@@ -125,9 +121,7 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( `year_month` = #{yearMonth}
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if> </if>
</where> </where>
</select> </select>
...@@ -139,9 +133,7 @@ ...@@ -139,9 +133,7 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( `year_month` = #{yearMonth}
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if> </if>
order by month_team_performance desc order by month_team_performance desc
limit 20 limit 20
...@@ -155,9 +147,7 @@ ...@@ -155,9 +147,7 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="yearMonth != null"> <if test="yearMonth != null">
AND( `year_month` = #{yearMonth}
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if> </if>
order by month_team_performance desc order by month_team_performance desc
limit 20 limit 20
......
...@@ -96,7 +96,7 @@ public class AccountManager { ...@@ -96,7 +96,7 @@ public class AccountManager {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateAccountPerformanceMonth(List<TeamPerformance> list) { public void updateAccountPerformanceMonth(List<TeamPerformance> list) {
for (TeamPerformance teamPerformance : list) { for (TeamPerformance teamPerformance : list) {
teamPerformanceMapper.updateById(teamPerformance); teamPerformanceMapper.edit(teamPerformance);
} }
} }
......
...@@ -24,6 +24,7 @@ import org.springframework.util.CollectionUtils; ...@@ -24,6 +24,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
...@@ -130,27 +131,36 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -130,27 +131,36 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//计算当月所有订单成交额 //计算当月所有订单成交额
BigDecimal totalMoney = new BigDecimal(0); BigDecimal totalMoney = new BigDecimal(0);
//统计出出每个用户当月订单成交额 key:userId value:用户当月订单成交额
Map<String, Double> map = new HashMap<>();
for (OrderInfo orderInfo : list) { for (OrderInfo orderInfo : list) {
//判断是否是本月 String userId = orderInfo.getBuyerId();
boolean bool = publicManager.isThisMonth(orderInfo.getCreateTime(), PATTERN); double payMoney = orderInfo.getPayment().doubleValue();
if (bool && orderInfo.getMonthlyTaskStatus() == 0) {
totalMoney = totalMoney.add(orderInfo.getPayment()); //key 存在 累加订单金额 到 value
if (map.containsKey(userId)) {
double money = payMoney + map.get(orderInfo.getBuyerId());
map.put(orderInfo.getBuyerId(), money);
} else {
//key 不存在,加入集合
map.put(userId, payMoney);
} }
//累加所以订单成交额
totalMoney = totalMoney.add(orderInfo.getPayment());
} }
//遍历订单 订单状态创建时间,当月时间小于当前时间
for (OrderInfo orderInfo : list) { //遍历订单
long createTime = orderInfo.getCreated().getTime(); for (Map.Entry<String, Double> entity : map.entrySet()) {
long time = System.currentTimeMillis(); List<TeamPerformance> teamPerformances = new ArrayList<>();
if (createTime <= time) {
//获取用户信息 //获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId()); User user = usersMapper.getByUserId(entity.getKey());
if (null == user) { if (null == user) {
continue; continue;
} }
List<TeamPerformance> teamPerformances = new ArrayList<>();
//获取团队业绩信息 //获取团队业绩信息
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth); TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if (null == teamPerformance) { if (null == teamPerformance) {
...@@ -158,13 +168,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -158,13 +168,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
} }
//1、统计当前用户月度业绩 //1、统计当前用户月度业绩
BigDecimal userCount = teamPerformance.getMonthTeamPerformance().add(orderInfo.getPayment()); BigDecimal userCount = BigDecimal.valueOf(entity.getValue());
teamPerformance.setMonthTeamPerformance(userCount); teamPerformance.setMonthTeamPerformance(userCount);
teamPerformances.add(teamPerformance); teamPerformances.add(teamPerformance);
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777 //2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List<User> userList = getByList(user.getUserId()); List<User> userList = getByList(user.getUserId());
if (CollectionUtils.isEmpty(userList)) { if (CollectionUtils.isEmpty(userList)) {
//更新当前用户月度业绩
accountManager.updateAccountPerformanceMonth(teamPerformances);
continue; continue;
} }
...@@ -175,7 +187,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -175,7 +187,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
continue; continue;
} }
//1、统计当前用户月度绩效 //1、统计当前用户月度绩效
BigDecimal monthCount = team.getMonthTeamPerformance().add(orderInfo.getPayment()); BigDecimal monthCount = team.getMonthTeamPerformance().add(userCount);
log.info("当前用户月度绩效:" + monthCount);
team.setMonthTeamPerformance(monthCount); team.setMonthTeamPerformance(monthCount);
teamPerformances.add(team); teamPerformances.add(team);
} }
...@@ -183,7 +196,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -183,7 +196,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//4、更新账户月度绩效 //4、更新账户月度绩效
accountManager.updateAccountPerformanceMonth(teamPerformances); accountManager.updateAccountPerformanceMonth(teamPerformances);
} }
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益 //5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser(); List<User> userList = usersMapper.getAllGoldUser();
if (CollectionUtils.isEmpty(userList)) { if (CollectionUtils.isEmpty(userList)) {
...@@ -207,9 +219,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -207,9 +219,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
@Override @Override
public List<User> getByList(String userId) { public List<User> getByList(String userId) {
List<User> list = new ArrayList<>(); List<User> list = new ArrayList<>();
User user = usersMapper.getByUserId(userId);
getUser(list, userId); getUser(list, userId);
//去除本身
list.remove(user);
return list; return list;
} }
...@@ -303,11 +316,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo> ...@@ -303,11 +316,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
public void getUser(List<User> list, String userId) { public void getUser(List<User> list, String userId) {
User user = usersMapper.getByUserId(userId); User user = usersMapper.getByUserId(userId);
list.add(user); list.add(user);
if (null != user && StringUtils.isBlank(user.getBeInvitedCode())) { if (null != user && !StringUtils.isBlank(user.getBeInvitedCode())) {
User userInfo = usersMapper.getByBeInvitedCode(user.getBeInvitedCode()); User userInfo = usersMapper.getByBeInvitedCode(user.getBeInvitedCode());
if (null != userInfo) {
getUser(list, userInfo.getUserId()); getUser(list, userInfo.getUserId());
} }
} }
}
/** /**
* 如果会员等级是黄金以上,计算月度收益 * 如果会员等级是黄金以上,计算月度收益
......
...@@ -45,7 +45,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem ...@@ -45,7 +45,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
Date endCreatedDate = null; Date endCreatedDate = null;
Date startUpdateDate = null; Date startUpdateDate = null;
Date endUpdateDate = null; Date endUpdateDate = null;
Date date = new Date(); // Date date = new Date();
/** /**
* 根据订单的创建时间获取有赞的订单数据 插入本地数据库 * 根据订单的创建时间获取有赞的订单数据 插入本地数据库
...@@ -56,6 +56,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem ...@@ -56,6 +56,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
@XxlJob(value = "YouZanOrdersjobhandler") @XxlJob(value = "YouZanOrdersjobhandler")
@Override @Override
public void getYouZanOrdersForCreateTime() throws SDKException { public void getYouZanOrdersForCreateTime() throws SDKException {
Date date = new Date();
Token token = youzanToken(); Token token = youzanToken();
YouzanTradesSoldGet youzanTradesSoldGet = new YouzanTradesSoldGet(); YouzanTradesSoldGet youzanTradesSoldGet = new YouzanTradesSoldGet();
//创建参数对象,并设置参数 //创建参数对象,并设置参数
...@@ -68,6 +69,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem ...@@ -68,6 +69,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
startCreatedDate = sdf.parse(sdf.format(new Date(date.getTime()-(long) 5*60*1000))); startCreatedDate = sdf.parse(sdf.format(new Date(date.getTime()-(long) 5*60*1000)));
log.info("订单创建开始时间"+sdf.format(startCreatedDate)); log.info("订单创建开始时间"+sdf.format(startCreatedDate));
endCreatedDate = sdf.parse(sdf.format(date)); endCreatedDate = sdf.parse(sdf.format(date));
String format = sdf.format(date); String format = sdf.format(date);
log.info("订单创建结束时间"+sdf.format(endCreatedDate)); log.info("订单创建结束时间"+sdf.format(endCreatedDate));
} catch (ParseException e) { } catch (ParseException e) {
...@@ -140,6 +142,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem ...@@ -140,6 +142,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
@XxlJob(value = "YouZanOrdersForUpdateTimejobhandler") @XxlJob(value = "YouZanOrdersForUpdateTimejobhandler")
@Override @Override
public void getYouZanOrdersForUpdateTime() throws SDKException { public void getYouZanOrdersForUpdateTime() throws SDKException {
Date date = new Date();
Token token = youzanToken(); Token token = youzanToken();
YouzanTradesSoldGet youzanTradesSoldGet = new YouzanTradesSoldGet(); YouzanTradesSoldGet youzanTradesSoldGet = new YouzanTradesSoldGet();
//创建参数对象,并设置参数 //创建参数对象,并设置参数
...@@ -148,7 +151,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem ...@@ -148,7 +151,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
try { try {
// startUpdateDate = sdf.parse("2021-02-28 11:04:01"); // startUpdateDate = sdf.parse("2021-02-28 11:04:01");
// endUpdateDate = sdf.parse("2021-03-2 16:39:59"); // endUpdateDate = sdf.parse("2021-03-2 16:39:59");
startUpdateDate = sdf.parse(sdf.format(new Date(date.getTime()-(long) 60*1000))); startUpdateDate = sdf.parse(sdf.format(new Date(date.getTime()-(long) 5*60*1000)));
log.info("订单修改开始时间"+sdf.format(startUpdateDate)); log.info("订单修改开始时间"+sdf.format(startUpdateDate));
endUpdateDate = sdf.parse(sdf.format(date)); endUpdateDate = sdf.parse(sdf.format(date));
log.info("订单修改结束时间"+sdf.format(endUpdateDate)); log.info("订单修改结束时间"+sdf.format(endUpdateDate));
......
...@@ -30,20 +30,34 @@ public class AccountController extends BaseController { ...@@ -30,20 +30,34 @@ public class AccountController extends BaseController {
@ApiOperation(value = "获取账户信息", notes = "获取账户信息", httpMethod = "GET") @ApiOperation(value = "获取账户信息", notes = "获取账户信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String") @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@GetMapping("/getByUserId") @GetMapping("/getByUserId")
public R<AccountInfo> getByUserId(String userId){ public R<AccountInfo> getByUserId(String userId) {
return accountService.getByUserId(userId); return accountService.getByUserId(userId);
} }
@ApiOperation(value = "获取账户列表信息", notes = "获取账户列表信息", httpMethod = "GET") @ApiOperation(value = "获取账户列表信息", notes = "获取账户列表信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String") @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@GetMapping("/getByList") @GetMapping("/getByList")
public List<User> getByList(String userId){ public List<User> getByList(String userId) {
return accountService.getByList(userId); return accountService.getByList(userId);
} }
@ApiOperation(value = "订单佣金", notes = "订单佣金", httpMethod = "GET") @ApiOperation(value = "订单佣金", notes = "订单佣金", httpMethod = "GET")
@GetMapping("/orderRebate") @GetMapping("/orderRebate")
public R<Boolean> orderRebate(){ public R<Boolean> orderRebate() {
return accountService.orderRebate(); return accountService.orderRebate();
} }
@ApiOperation(value = "月度肥料", notes = "月度肥料", httpMethod = "GET")
@GetMapping("/monthManure")
public R<Boolean> monthManure() {
return accountService.performanceCount();
}
@ApiOperation(value = "最大进步奖", notes = "最大进步奖", httpMethod = "GET")
@GetMapping("/growAward")
public R<Boolean> growAward() {
return accountService.progressPrizeCount();
}
} }
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