Commit a170c801 authored by m1991's avatar m1991

Merge remote-tracking branch 'origin/master'

parents a4c5661e 05d51a6e
......@@ -5,8 +5,6 @@ import cn.wisenergy.model.app.AccountInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* @author 86187
*/
......
......@@ -40,5 +40,5 @@ public interface MonthAwardMapper extends BaseMapper<MonthAward> {
* @param yearMonth 年月
* @return 月度奖金
*/
MonthAward getByTime(@Param("yearMonth")Date yearMonth);
MonthAward getByTime(@Param("yearMonth") String yearMonth);
}
......@@ -11,6 +11,7 @@
<result column="farmer_award" property="farmerAward"/>
<result column="forest_start_award" property="forestStartAward"/>
<result column="partner_award" property="partnerAward"/>
<result column="year_month" property="yearMonth"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
......@@ -26,12 +27,12 @@
<sql id="cols_exclude_id">
growth_award,award_total,month_award_total,month_increased,gold_award,farmer_award, forest_start_award,
partner_award,create_time,update_time
partner_award,year_month,create_time,update_time
</sql>
<sql id="vals">
#{growthAward},#{awardTotal},#{monthAwardTotal},#{monthIncreased},#{goldAward},#{farmerAward},
#{forestStartAward}, #{partnerAward},now(),now()
#{forestStartAward}, #{partnerAward},#{yearMonth},now(),now()
</sql>
<sql id="updateCondition">
......@@ -43,6 +44,7 @@
<if test="farmerAward != null">farmer_award =#{farmerAward},</if>
<if test="forestStartAward != null">forest_start_award =#{forestStartAward},</if>
<if test="partnerAward != null">partner_award =#{partnerAward},</if>
<if test="yearMonth != null">year_month =#{yearMonth},</if>
update_time =now()
</sql>
......@@ -56,6 +58,7 @@
<if test="farmerAward != null">and farmer_award =#{farmerAward}</if>
<if test="forestStartAward != null">and forest_start_award =#{forestStartAward}</if>
<if test="partnerAward != null">and partner_award =#{partnerAward}</if>
<if test="yearMonth != null">and year_month =#{yearMonth}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
</sql>
......@@ -93,12 +96,11 @@
<include refid="table"/>
<where>
<if test="yearMonth != null">
YEAR(create_time) = YEAR(#{yearMonth})
AND MONTH(create_time) = MONTH(#{yearMonth})
year_month=#{yearMonth}
</if>
</where>
order by create_time desc
limit 1
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -73,6 +73,11 @@ public class MonthAward implements Serializable {
@ApiModelProperty(value = "森田合伙人月奖励总额",name="partnerAward")
private Double partnerAward;
/**
* 时间 :yyyy-MM
*/
@ApiModelProperty(value = "时间 :yyyy-MM",name="yearMonth")
private String yearMonth;
private Date createTime;
......
package cn.wisenergy.service.app;
import org.springframework.stereotype.Service;
/**
* @author 86187
*/
public interface AerialDeliveryUserService {
/**
* 空投池用户随机分配推荐人邀请码
......
......@@ -16,7 +16,7 @@ public interface TradeRecordService {
*
* @return true or false
*/
Boolean monthAwardCount();
R<Boolean> monthAwardCount();
/**
* 交易流水列表查询
......
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.MonthAwardMapper;
import cn.wisenergy.mapper.TradeRecordMapper;
......@@ -33,8 +34,9 @@ public class MonthAwardServiceImpl extends ServiceImpl<MonthAwardMapper, MonthAw
}
//获取本月最新的一条数据
String yearMonth = DateUtil.convertDateToStr(new Date(), "yyyy-MM");
MonthAwardVo monthAwardVo = new MonthAwardVo();
MonthAward monthAward = baseMapper.getByTime(new Date());
MonthAward monthAward = baseMapper.getByTime(yearMonth);
if (null == monthAward) {
return R.ok(monthAwardVo);
}
......
......@@ -39,7 +39,7 @@ public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, Trade
private TradeRecordMapper tradeRecordMapper;
@Override
public Boolean monthAwardCount() {
public R<Boolean> monthAwardCount() {
MonthAward result = new MonthAward();
//1、获取本月新增奖金
Double monthGrow = baseMapper.queryMonthGrow(new Date());
......@@ -63,9 +63,15 @@ public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, Trade
result.setMonthAwardTotal(monthAwardTotal);
//4、较上月增长奖金 本月累计奖金-上月累计奖金
//获取上月 累计奖金
//本月
String currentMonth=DateUtil.convertDateToStr(new Date(),"yyyy-MM");
Date lastDate=DateUtil.getLastMonth(new Date());
String lastMonth=DateUtil.convertDateToStr(lastDate,"yyyy-MM");
Double growthAward;
MonthAward monthAward = monthAwardMapper.getByTime(date);
//获取上月 累计奖金
MonthAward monthAward = monthAwardMapper.getByTime(lastMonth);
if (null == monthAward) {
growthAward = monthAwardTotal;
} else {
......@@ -75,29 +81,51 @@ public class TradeRecordServiceImpl extends ServiceImpl<TradeRecordMapper, Trade
//5、获取黄金树本月奖金
Double goldAward = baseMapper.queryByUserLevel(UserLevelEnum.GOLD_TREE.getCode(), new Date());
if (null == goldAward) {
result.setGoldAward(0.00);
} else {
result.setGoldAward(goldAward);
}
//6、获取农场主本月奖金
Double farmerAward = baseMapper.queryByUserLevel(UserLevelEnum.FARMER.getCode(), new Date());
if (null == farmerAward) {
result.setFarmerAward(0.00);
} else {
result.setFarmerAward(farmerAward);
}
//7、森林之星月奖金
Double startAward = baseMapper.queryByUserLevel(UserLevelEnum.FOREST_START.getCode(), new Date());
if (null == startAward) {
result.setForestStartAward(0.00);
} else {
result.setForestStartAward(startAward);
}
//8、森田合伙人月奖金
Double partnerAward = baseMapper.queryByUserLevel(UserLevelEnum.PARTNER.getCode(), new Date());
if (null == partnerAward) {
result.setPartnerAward(0.00);
} else {
result.setPartnerAward(partnerAward);
}
//9、 判断是否有本月奖金这条数据,没有,新增,有更新值
MonthAward currentMonth = monthAwardMapper.getByTime(new Date());
if (null == currentMonth) {
MonthAward currentMonthAward = monthAwardMapper.getByTime(currentMonth);
if (null == currentMonthAward) {
int count = monthAwardMapper.add(result);
return count != 0;
if (count == 0) {
return R.ok(1, false);
}
} else {
int count = monthAwardMapper.edit(result);
return count != 0;
if (count == 0) {
return R.ok(1, false);
}
}
return R.ok(0, true);
}
@Override
......
......@@ -8,7 +8,6 @@ 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;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......
......@@ -7,6 +7,7 @@ import cn.wisenergy.model.app.UsersDto;
import cn.wisenergy.model.vo.AerialDeliveryVo;
import cn.wisenergy.model.vo.UserPoolVo;
import cn.wisenergy.service.Manager.RegistUserMoudleInitManager;
import cn.wisenergy.service.app.AerialDeliveryUserService;
import cn.wisenergy.service.app.UserLevelService;
import cn.wisenergy.service.app.UserService;
import com.alibaba.fastjson.JSONObject;
......@@ -47,6 +48,9 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
@Autowired
private RegistUserMoudleInitManager registUserMoudleInit;
@Autowired
private AerialDeliveryUserService aerialDeliveryUserService;
@Autowired
private RedisUtils redisUtils;
......@@ -124,18 +128,18 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
String inviteCode = "0";
beInvitedCode = "1";
int userLevel = 0;
int frozen=0;
int frozen = 0;
String headImage = Constants.Common.HEAD_POTRAIT;
usersMapper.insertbyint(userId, inviteCode, beInvitedCode, userLevel, headImage,frozen);
usersMapper.insertbyint(userId, inviteCode, beInvitedCode, userLevel, headImage, frozen);
//初始化六张表
registUserMoudleInit.registUserMoudleInit(userId);
} else {
//插入用户手机号与推荐人邀请码
String inviteCode = "0";
int userLevel = 0;
int frozen=0;
int frozen = 0;
String headImage = Constants.Common.HEAD_POTRAIT;
usersMapper.insertbyint(userId, inviteCode, beInvitedCode, userLevel, headImage,frozen);
usersMapper.insertbyint(userId, inviteCode, beInvitedCode, userLevel, headImage, frozen);
//初始化六张表
registUserMoudleInit.registUserMoudleInit(userId);
//用户的被邀请码,查询到推荐人用户,根据推荐人用户的邀请码查询/修改
......@@ -159,8 +163,8 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
int idbc = Integer.valueOf(idb);
//获取注册用户的id
User use= usersMapper.getByUserId(userId);
int ida =use.getId();
User use = usersMapper.getByUserId(userId);
int ida = use.getId();
//判断被邀请用户的创建时间是否比推荐人的用户时间晚
if (idbc > ida) {
......@@ -178,14 +182,14 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
//根据插入的用户手机号,查询用户唯一ID
if(null== usersMapper.getuserIdById(userId)|| "".equals(usersMapper.getuserIdById(userId))){
Map map =new HashMap();
map.put("code",1);
map.put("msg","该用户不存在!");
if (null == usersMapper.getuserIdById(userId) || "".equals(usersMapper.getuserIdById(userId))) {
Map map = new HashMap();
map.put("code", 1);
map.put("msg", "该用户不存在!");
return map;
}
long yqm=usersMapper.getuserIdById(userId);
long yqm = usersMapper.getuserIdById(userId);
//用户唯一ID调用生成6位邀请码
String inviteCode = ShareCodeUtil.idToCode(yqm);
Integer userLevel = 0;
......@@ -213,15 +217,17 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
if (null == userIdByIntive) {
R.error(1, "用户推荐人邀请码不存在,请填写正确的邀请码");
} else {
//上级用户的直推信息 普通用户数量+1
RecommendUser recommendUserMapperByUserId = recommendUserMapper.getByUserId(userIdByIntive);
Integer normalUserNum = recommendUserMapperByUserId.getNormalUserNum();
recommendUserMapperByUserId.setNormalUserNum(normalUserNum + 1);
recommendUserMapper.updateById(recommendUserMapperByUserId);
// //上级用户的直推信息 普通用户数量+1
// RecommendUser recommendUserMapperByUserId = recommendUserMapper.getByUserId(userIdByIntive);
// Integer normalUserNum = recommendUserMapperByUserId.getNormalUserNum();
// recommendUserMapperByUserId.setNormalUserNum(normalUserNum + 1);
// recommendUserMapper.updateById(recommendUserMapperByUserId);
//通过用户的userid和推荐人邀请码 设置当前用户的上级直推数据和当前用户所在团队的团队数据
aerialDeliveryUserService.userSetBeinviteCode(userId,beInvitedCode);
}
//递归向上修改团队用户信息表
teamUserInfo(beInvitedCode);
// teamUserInfo(beInvitedCode);
Map map = new HashMap();
R.ok("注册成功!", 0);
map.put("code", 0);
......@@ -317,7 +323,10 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
return R.error("推荐人不能是自己!");
}
//4、设置用户被邀请码
//更新推荐用户的等级或者直推人数
aerialDeliveryUserService.userSetBeinviteCode(userId, userCode.getUserId());
//5、设置用户被邀请码
user.setBeInvitedCode(inviteCode);
int count = usersMapper.edit(user);
if (count == 0) {
......
......@@ -12,7 +12,6 @@ import cn.wisenergy.model.vo.UserLoginVo;
import cn.wisenergy.model.vo.UserRegisterVo;
import cn.wisenergy.service.app.LoginService;
import cn.wisenergy.service.app.UserService;
import cn.wisenergy.web.config.JwtConfig;
import cn.wisenergy.web.shiro.JwtUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
......
......@@ -3,7 +3,6 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.TradeRecord;
import cn.wisenergy.model.dto.TradeRecordQuery;
import cn.wisenergy.model.vo.TaxRateVo;
import cn.wisenergy.service.app.TradeRecordService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
......@@ -12,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -33,4 +33,12 @@ public class TradeRecordController {
log.info("shop-mall[]TradeRecordController[]queryList[]input.param.query:" + query);
return tradeRecordService.queryList(query);
}
@ApiOperation(value = "统计月度奖金", notes = "统计月度奖金", httpMethod = "POST")
@PostMapping("/monthAwardCount")
public R<Boolean> monthAwardCount() {
log.info("shop-mall[]TradeRecordController[]monthAwardCount[]input.method");
return tradeRecordService.monthAwardCount();
}
}
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