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