Commit 221616bf authored by licc's avatar licc

新增月度奖励实体类

parent a3a3d4ee
......@@ -40,6 +40,7 @@ public interface AccountMapper extends BaseMapper<AccountInfo> {
* @param userId 用户id
* @return 账户信息
*/
AccountInfo getByUserId(@Param("userId") Integer userId);
AccountInfo getByUserId(@Param("userId") String userId);
}
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.MonthAward;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 86187
*/
public interface MonthAwardMapper extends BaseMapper<MonthAward> {
int add(MonthAward monthAward);
int edit(MonthAward monthAward);
int delById(Integer id);
}
......@@ -53,6 +53,13 @@ public interface UsersMapper extends BaseMapper<User> {
* @param userId 用户id
* @return 用户信息
*/
User getByUserId(@Param("userId") Integer userId);
User getByUserId(@Param("userId") String userId);
/**
* 获取用户信息
* @param beInvitedCode 用户被邀请码
* @return 用户信息
*/
User getByBeInvitedCode(@Param("beInvitedCode") String beInvitedCode);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.mapper.MonthAwardMapper">
<resultMap id="monthMap" type="cn.wisenergy.model.app.MonthAward">
<id column="id" property="id"/>
<result column="month_manure_total" property="monthManureTotal"/>
<result column="month_award_pool" property="monthAwardPool"/>
<result column="month_manure_award" property="monthManureAward"/>
<result column="month_gold_award" property="monthGoldAward"/>
<result column="month_farmer_award" property="monthFarmerAward"/>
<result column="month_forest_start_award" property="monthForestStartAward"/>
<result column="month_partner_award" property="monthPartnerAward"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
month_award
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
month_manure_total,month_award_pool,month_manure_award,month_gold_award,month_farmer_award,
month_forest_start_award,month_partner_award,create_time,update_time
</sql>
<sql id="vals">
#{monthManureTotal},#{monthAwardPool},#{monthManureAward},#{monthGoldAward},#{monthFarmerAward},
#{monthForestStartAward}, #{monthPartnerAward},now(),now()
</sql>
<sql id="updateCondition">
<if test="monthManureTotal != null">month_manure_total = #{monthManureTotal},</if>
<if test="monthAwardPool != null">month_award_pool = #{monthAwardPool},</if>
<if test="monthManureAward != null">month_manure_award =#{monthManureAward},</if>
<if test="monthGoldAward != null">month_gold_award =#{monthGoldAward},</if>
<if test="monthFarmerAward != null">month_farmer_award =#{monthFarmerAward},</if>
<if test="monthForestStartAward != null">month_forest_start_award =#{monthForestStartAward},</if>
<if test="monthPartnerAward != null">month_partner_award =#{monthPartnerAward},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="id != null">id = #{id}</if>
<if test="monthManureTotal != null">and month_manure_total = #{monthManureTotal}</if>
<if test="monthAwardPool != null">and month_award_pool = #{monthAwardPool}</if>
<if test="monthManureAward != null">and month_manure_award =#{monthManureAward}</if>
<if test="monthGoldAward != null">and month_gold_award =#{monthGoldAward}</if>
<if test="monthFarmerAward != null">and month_farmer_award =#{monthFarmerAward}</if>
<if test="monthForestStartAward != null">and month_forest_start_award =#{monthForestStartAward}</if>
<if test="monthPartnerAward != null">and month_partner_award =#{monthPartnerAward}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
<insert id="add" parameterType="cn.wisenergy.model.app.MonthAward" keyProperty="id" useGeneratedKeys="true">
insert into
<include refid="table"/>
(<include refid="cols_exclude_id"/>)
value(
<include refid="vals"/>
)
</insert>
<update id="edit" parameterType="cn.wisenergy.model.app.MonthAward">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<delete id="delById" parameterType="java.lang.Integer">
delete from
<include refid="table"/>
where id = #{id}
</delete>
</mapper>
\ No newline at end of file
......@@ -156,6 +156,16 @@
select password from user where user_id = #{userId}
</select>
<select id="getByBeInvitedCode" resultType="cn.wisenergy.model.app.User">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
invite_code=#{beInvitedCode}
</where>
</select>
<!--用户添加-->
<insert id="save">
insert into user(user_id,password) value (#{userId},#{password})
......
package cn.wisenergy.model.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*@ Description: 月度奖励实体类
*@ Author : 86187
*@ Date : 2021/2/24 16:16
* @author 86187
*/
@Data
@ApiModel("MonthAward")
public class MonthAward implements Serializable {
private static final long serialVersionUID = 5823242406761516398L;
/**
* 主键id
*/
@ApiModelProperty(value = "主键id",name="id")
private Integer id;
/**
* 本月月度肥料总额
*/
@ApiModelProperty(value = "本月月度肥料总额",name="monthManureTotal")
private BigDecimal monthManureTotal;
/**
* 本月进步最大奖励池
*/
@ApiModelProperty(value = "本月进步最大奖励池",name="monthAwardPool")
private BigDecimal monthAwardPool;
/**
* 月度肥料奖励
*/
@ApiModelProperty(value = "月度肥料奖励",name="monthManureAward")
private BigDecimal monthManureAward;
/**
* 黄金树月奖励总额
*/
@ApiModelProperty(value = "黄金树月奖励总额",name="monthGoldAward")
private BigDecimal monthGoldAward;
/**
* 农场主月奖励总额
*/
@ApiModelProperty(value = "农场主月奖励总额",name="monthFarmerAward")
private BigDecimal monthFarmerAward;
/**
* 森林之星月奖励总额
*/
@ApiModelProperty(value = "森林之星月奖励总额",name="monthForestStartAward")
private BigDecimal monthForestStartAward;
/**
* 森田合伙人月奖励总额
*/
@ApiModelProperty(value = "森田合伙人月奖励总额",name="monthPartnerAward")
private BigDecimal monthPartnerAward;
private Date createTime;
private Date updateTime;
}
......@@ -106,7 +106,7 @@ public class OrderInfo {
private BigDecimal payment;
/**
* 返佣状态 0:未返佣 1: 返佣
* 返佣状态 0:未返佣 1:返佣
*/
@ApiModelProperty(name = "rebateStatus", value = "返佣状态")
private Integer rebateStatus;
......
......@@ -10,6 +10,7 @@ import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author 86187
......
......@@ -4,6 +4,7 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.OrderInfo;
import cn.wisenergy.model.app.User;
import java.util.List;
......@@ -14,6 +15,7 @@ public interface AccountService {
/**
* 订单返佣
*
* @param list 订单信息
* @return true or false
*/
......@@ -21,8 +23,19 @@ public interface AccountService {
/**
* 获取账户信息
*
* @param userId 用户id
* @return 账户信息
*/
R<AccountInfo> getByUserId(Integer userId);
R<AccountInfo> getByUserId(String userId);
/**
* 业绩统计
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
List<User> getByList(String userId);
}
......@@ -18,14 +18,14 @@ public interface UserService {
* @param userId 用户id
* @return 用户信息
*/
R<User> getById(Integer userId);
R<User> getById(String userId);
/**
* 获取用户信息
* @param userId 用户id
* @return 用户信息
*/
User getByUserId(Integer userId);
User getByUserId(String userId);
R<List<User>> test();
......
......@@ -13,10 +13,12 @@ import cn.wisenergy.service.common.AccountManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -78,8 +80,71 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
@Override
public R<AccountInfo> getByUserId(Integer userId) {
public R<AccountInfo> getByUserId(String userId) {
AccountInfo accountInfo = accountMapper.getByUserId(userId);
return R.ok(accountInfo);
}
@Override
public R<Boolean> performanceCount(List<OrderInfo> list) {
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
}
//遍历订单
for (OrderInfo orderInfo : list) {
//订单状态创建时间,小于当前时间
long createTime = orderInfo.getCreated().getTime();
long time = System.currentTimeMillis();
if (orderInfo.getMonthlyTaskStatus() == 0 && createTime <= time) {
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
continue;
}
//获取当前用户的上级用户列表
List<User> userList=getByList(user.getUserId());
if(CollectionUtils.isEmpty(userList)){
continue;
}
//获取账户信息
AccountInfo accountInfo = accountMapper.getByUserId(user.getUserId());
if (null == accountInfo) {
continue;
}
//修改订单状态为已返佣,账户可用金额增加
}
}
return R.ok(0, true);
}
/**
* 获取用户的商机信息
*
* @param userId 用户id
* @return
*/
@Override
public List<User> getByList(String userId) {
List<User> list = new ArrayList<>();
getUser(list, userId);
return list;
}
public void getUser(List<User> list, String userId) {
User user = usersMapper.getByUserId(userId);
list.add(user);
if (null != user && StringUtils.isBlank(user.getBeInvitedCode())) {
User userInfo = usersMapper.getByBeInvitedCode(user.getBeInvitedCode());
getUser(list, userInfo.getUserId());
}
}
}
......@@ -25,13 +25,13 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
private UsersMapper usersMapper;
@Override
public R<User> getById(Integer userId) {
public R<User> getById(String userId) {
return R.ok(usersMapper.getByUserId(userId));
}
@Override
public User getByUserId(Integer userId) {
public User getByUserId(String userId) {
return usersMapper.getByUserId(userId);
}
......
......@@ -7,7 +7,6 @@ import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.OrderInfo;
import cn.wisenergy.model.app.Rebate;
import cn.wisenergy.model.app.TradeRecord;
import io.undertow.security.idm.Account;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -41,6 +40,8 @@ public class AccountManager {
BigDecimal extractMoney = accountInfo.getExtractMoney().add(bigDecimal);
accountInfo.setExtractMoney(extractMoney);
BigDecimal performanceMonth = accountInfo.getPerformanceMonth().add(extractMoney);
accountInfo.setPerformanceMonth(performanceMonth);
//2、修改订单返佣状态:已返佣 1
orderInfo.setRebateStatus(1);
......
......@@ -2,6 +2,7 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AccountInfo;
import cn.wisenergy.model.app.User;
import cn.wisenergy.service.app.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -10,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author 86187
*/
......@@ -22,10 +25,17 @@ public class AccountController {
private AccountService accountService;
@ApiOperation(value = "获取账户信息", notes = "获取账户信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "int")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@GetMapping("/getByUserId")
public R<AccountInfo> getByUserId(Integer 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){
return accountService.getByList(userId);
}
}
......@@ -40,9 +40,9 @@ public class UserController extends BaseController {
private RedisTemplate<String, Object> redisTemplate;
@ApiOperation(value = "获取用户信息", notes = "获取用户信息", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "int")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String")
@GetMapping("/getByUserId")
public R<User> getByUserId(Integer userId){
public R<User> getByUserId(String userId){
return userService.getById(userId);
}
......@@ -53,7 +53,7 @@ public class UserController extends BaseController {
*/
@ApiOperation(value = "获取token接口", notes = "获取token接口", httpMethod = "POST")
@PostMapping(value = "/login")
public R<String> login(Integer id) {
public R<String> login(String id) {
if (null == id) {
return R.error("入参为空!");
}
......
......@@ -99,7 +99,7 @@ public class AuthRealm extends AuthorizingRealm {
throw new IncorrectCredentialsException(RespCodeEnum.TOKEN_IS_NOT_TIMEOUT.getMsg());
}*/
//查询用户信息
User user = authUserService.getByUserId(userEntity.getId());
User user = authUserService.getByUserId(userEntity.getUserId());
// 判断请求token与redis中是否相同,如果token被刷新,则不判断
if (!refreshFlag && !StringUtils.equals(accessToken, redisToken)) {
throw new IncorrectCredentialsException(RespCodeEnum.NO_AUTH_REQUEST.getMsg());
......
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