Commit 5a5d8274 authored by codezwjava's avatar codezwjava

订单获取定时任务测试11

parent 99b25759
......@@ -52,4 +52,11 @@ public interface AccountMapper extends BaseMapper<AccountInfo> {
* @return 账户信息
*/
AccountInfo getByUserIdAndTime(@Param("userId") String userId, @Param("yearMonth") String yearMonth);
/**
* 修改用户的当月收益个累计收益
* @param accountInfo
* @return
*/
int updateEarningsMonthAndEarningsTotalByid(AccountInfo accountInfo);
}
......@@ -56,4 +56,6 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
* @return 订单列表
*/
List<OrderInfo> getByCreateTime(@Param("created") Date created);
List<OrderInfo> getByLevelStatus(int levelStatus);
}
......@@ -103,4 +103,15 @@
</where>
</select>
<update id="updateEarningsMonthAndEarningsTotalByid" parameterType="cn.wisenergy.model.app.AccountInfo">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
</mapper>
\ No newline at end of file
......@@ -17,6 +17,7 @@
<result column="success_time" property="successTime"/>
<result column="payment" property="payment"/>
<result column="rebate_status" property="rebateStatus"/>
<result column="level_status" property="levelStatus"/>
<result column="month_order_status" property="monthOrderStatus"/>
<result column="monthly_task_status" property="monthlyTaskStatus"/>
<result column="create_time" property="createTime"/>
......@@ -34,13 +35,13 @@
<sql id="cols_exclude_id">
buyer_id,item_id,pay_type,youzan_update_time,tid,created,team_type,pay_time,pay_type_str,close_type,refund_state,
success_time,payment,rebate_status,month_order_status,monthly_task_status,create_time,update_time
success_time,payment,rebate_status,level_status,month_order_status,monthly_task_status,create_time,update_time
</sql>
<sql id="vals">
#{buyerId},#{itemId},#{payType},#{youzanUpdateTime}, #{tid},#{created},#{teamType},#{payTime},#{payTypeStr},
#{closeType},#{refundState},#{successTime},#{payment},
#{rebateStatus},#{monthOrderStatus},#{monthlyTaskStatus},now(),now()
#{rebateStatus},#{levelStatus},#{monthOrderStatus},#{monthlyTaskStatus},now(),now()
</sql>
<sql id="updateCondition">
......@@ -58,6 +59,7 @@
<if test="successTime != null">success_time =#{successTime},</if>
<if test="payment != null">payment =#{payment},</if>
<if test="rebateStatus != null">rebate_status =#{rebateStatus},</if>
<if test="levelStatus != null">level_status =#{levelStatus},</if>
<if test="monthOrderStatus != null">month_order_status =#{monthOrderStatus},</if>
<if test="monthlyTaskStatus != null">monthly_task_status =#{monthlyTaskStatus},</if>
update_time =now()
......@@ -79,6 +81,7 @@
<if test="successTime != null">and success_time =#{successTime}</if>
<if test="payment != null">and payment =#{payment}</if>
<if test="rebateStatus != null">and rebate_status =#{rebateStatus}</if>
<if test="levelStatus != null">and level_status =#{levelStatus}</if>
<if test="monthOrderStatus != null">and month_order_status =#{monthOrderStatus}</if>
<if test="monthlyTaskStatus != null">and monthly_task_status =#{monthlyTaskStatus}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
......@@ -153,4 +156,14 @@
</where>
</select>
<select id="getByLevelStatus" resultType="cn.wisenergy.model.app.OrderInfo">
SELECT
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
level_status=#{levelStatus}
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -108,9 +108,10 @@
<select id="getByUserId" resultType="cn.wisenergy.model.app.User" parameterType="string">
select
<include refid="cols_all"/>
id,user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
be_invited_code,create_time,update_time
from
<include refid="table"/>
user_info
<where>
user_id=#{userId}
</where>
......
......@@ -110,6 +110,12 @@ public class OrderInfo {
@ApiModelProperty(name = "rebateStatus", value = "返佣状态")
private Integer rebateStatus;
/**
* 升级状态 0:该笔订单已做升级处理 1: 该笔订单未做升级处理
*/
@ApiModelProperty(name = "levelStatus",value = "升级状态")
private Integer levelStatus;
/**
* 当月订单处理状态 0: 未处理 1:处理
*/
......
......@@ -100,4 +100,12 @@ public class User extends Model<User> implements Serializable{
*/
@ApiModelProperty(name = "updateTime", value = "修改时间")
private Date updateTime;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
......@@ -2,4 +2,5 @@ package cn.wisenergy.service.app;
public interface UserLevelService {
void userLevelUpgrade(String userId);
void userLevelUp();
}
......@@ -5,6 +5,7 @@ import cn.wisenergy.model.app.*;
import cn.wisenergy.model.enums.TradeRecordEnum;
import cn.wisenergy.service.app.UserLevelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
......@@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
/**
* @author zw
......@@ -44,6 +46,26 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
@Autowired
private CultivatingPrizeInfoMapper cultivatingPrizeInfoMapper;
@Autowired
private OrderMapper orderMapper;
// public void
//获取订单
@XxlJob(value = "userLevelUpjobhandler")
@Override
public void userLevelUp(){
//1.获取数据库订单数据
List<OrderInfo> ordersByLevelStatus = orderMapper.getByLevelStatus(0);
for (OrderInfo orderInfo : ordersByLevelStatus) {
String buyerId = orderInfo.getBuyerId();
userLevelUpgrade(buyerId);
//当前订单升级状态置为1
orderInfo.setLevelStatus(1);
orderMapper.updateById(orderInfo);
}
}
@Override
@Transactional
public void userLevelUpgrade(String userId) {
......@@ -53,8 +75,8 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
RecommendUser recommendUser = recommendUserMapper.getByUserId(userId);
//当前用户团队信息表对象
TeamUserInfo teamUserInfoMapperByUserId = teamUserInfoMapper.getByUserId(userId);
//当前用户的跨境额度(业绩)
BigDecimal crossBorderLine = user.getCrossBorderLine();
//计算当前用户业绩
BigDecimal performanceByUserid = orderMapper.getPerformanceByUserid(userId);
//当前用户等级
Integer userLevel = user.getUserLevel();
//当前用户的邀请码
......@@ -72,9 +94,9 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//用户等级升级为幼苗 1
//若当前用户等级为0(普通用户)且跨境额度(业绩消费金额)>= 3980 进行升级0-->1
//todo:根据业绩去计算 查一次表获取业绩
if (userLevel == 0 && crossBorderLine.intValue() >= 3980) {
if (userLevel == 0 && performanceByUserid.intValue() >= 3980) {
user.setUserLevel(1);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户推荐人邀请码为 1 时 该用户没有邀请人
if ("1".equals(beInvitedCode)) {
return;
......@@ -105,7 +127,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
if (userLevel == 1 && recommendUser.getSeedlingNum() >= 5 && recommendUser.getSeedlingNum() < 20) {
//用户升级成功
user.setUserLevel(2);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户被邀请码为 1 时 该用户没有邀请人
if ("1".equals(user.getBeInvitedCode())) {
return;
......@@ -132,7 +154,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
//用户等级升级为白银树 3
if (userLevel == 2 && recommendUser.getSeedlingNum() >= 20 && recommendUser.getSeedlingNum() < 50) {
user.setUserLevel(3);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户被邀请码为 1 时 该用户没有邀请人
if ("1".equals(user.getBeInvitedCode())) {
return;
......@@ -164,7 +186,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
&& recommendUser.getSilverTreeNum() >= 4
&& teamUserInfoMapperByUserId.getBronzeTreeNum() >= 20) {
user.setUserLevel(4);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户被邀请码为 1 时 该用户没有邀请人
if ("1".equals(user.getBeInvitedCode())) {
return;
......@@ -195,7 +217,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
&& recommendUser.getGoldTreeNum() >= 5
&& teamUserInfoMapperByUserId.getSilverTreeNum() >= 40) {
user.setUserLevel(5);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户被邀请码为 1 时 该用户没有邀请人
if ("1".equals(user.getBeInvitedCode())) {
return;
......@@ -228,7 +250,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
&& teamUserInfoMapperByUserId.getSilverTreeNum() >= 70
&& teamUserInfoMapperByUserId.getGoldTreeNum() >= 30) {
user.setUserLevel(6);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户被邀请码为 1 时 该用户没有邀请人
if ("1".equals(user.getBeInvitedCode())) {
return;
......@@ -260,7 +282,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
&& teamUserInfoMapperByUserId.getSilverTreeNum() >= 90
&& teamUserInfoMapperByUserId.getFarmerNum() >= 30) {
user.setUserLevel(7);
usersMapper.edit(user);
usersMapper.updateById(user);
//用户被邀请码为 1 时 该用户没有邀请人
if ("1".equals(user.getBeInvitedCode())) {
return;
......@@ -299,7 +321,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User byUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = byUserId.getInviteCode();
String inviteCode = byUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -334,7 +356,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User byUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = byUserId.getInviteCode();
String inviteCode = byUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -370,7 +392,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User byUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = byUserId.getInviteCode();
String inviteCode = byUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -406,7 +428,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User byUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = byUserId.getInviteCode();
String inviteCode = byUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -442,7 +464,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User byUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = byUserId.getInviteCode();
String inviteCode = byUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -478,7 +500,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User byUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = byUserId.getInviteCode();
String inviteCode = byUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -514,7 +536,8 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
User intiveUserByUserId = usersMapper.getByUserId(teamNumInfoBuyId.getUserId());
String beinvitedCodeUserId = "";
String inviteCode = intiveUserByUserId.getInviteCode();
//邀请人的推荐人邀请码
String inviteCode = intiveUserByUserId.getBeInvitedCode();
if (!"1".equals(inviteCode)) {
//通过邀请人的用户信息获取邀请人的推荐人邀请码
beinvitedCodeUserId = usersMapper.getByBeInvitedCode(inviteCode).getUserId();
......@@ -561,7 +584,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......@@ -591,7 +614,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......@@ -620,7 +643,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......@@ -649,7 +672,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......@@ -678,7 +701,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......@@ -707,7 +730,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......@@ -736,7 +759,7 @@ public class UserLevelServiceImpl extends ServiceImpl<UsersMapper,User> implemen
BigDecimal earningsTotal = beIntivedUserAccount.getEarningsTotal();
earningsTotal = earningsTotal.add(cultivatingPrize);
beIntivedUserAccount.setEarningsTotal(earningsTotal);
accountMapper.updateById(beIntivedUserAccount);
accountMapper.updateEarningsMonthAndEarningsTotalByid(beIntivedUserAccount);
//2.交易流水新增一条数据
TradeRecord tradeRecord = new TradeRecord();
tradeRecord.setUserId(inviteUserId);
......
......@@ -75,6 +75,7 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/webSocket/**", "anon");//socket
filterChainDefinitionMap.put("/message/**", "anon");//消息推送接口
filterChainDefinitionMap.put("/**", "oauth2"); // 其他路径均需要身份认证,一般位于最下面,优先级最低
filterChainDefinitionMap.put("/userlevel/test","anon");
// 设置拦截器
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
......
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