Commit 97ae8a64 authored by liqin's avatar liqin 💬

bug fixed

parents f69c8700 945d6307
......@@ -35,4 +35,6 @@ public class BaseException extends RuntimeException {
this.msg = msg;
this.code = code;
}
}
......@@ -85,4 +85,24 @@ public class Constants {
public static String TOKEN_PRIFIX="token";
public static String BANK_PRIFIX="bank";
}
/**
* redis常量
*/
public static class Redis{
/**
* 项目公共 前缀
*/
public final static String PREFIX = "xts";
/**
* 短信相关
*/
public final static String PREFIX_SMS = "sms:";
/**
* token相关
*/
public final static String PREFIX_TOKEN = "token:";
}
}
package cn.wisenergy.common.utils;
/**
* redis key工具类
* m1991
*/
public class RedisKeyUtils {
/**
* 根据出入的参数创建一个Redis key
* @return 如果参数为空,那么返回null
*/
public static String formatKeys(String ... args){
if (args != null && args.length > 0){
StringBuilder key = new StringBuilder();
for (String s: args){
key.append(s).append(Constants.Connnector.UNDERLINE);
}
return key.toString();
}
return null;
}
/**
* 根据出入的参数创建一个Redis key,自动拼接前缀
* @return 如果参数为空,那么返回null
*/
public static String formatKeyWithPrefix(String ... args){
if (args != null && args.length > 0){
StringBuilder key = new StringBuilder(Constants.Redis.PREFIX).append(Constants.Connnector.UNDERLINE);
for (String s: args){
key.append(s).append(Constants.Connnector.UNDERLINE);
}
return key.toString();
}
return null;
}
}
\ No newline at end of file
......@@ -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);
}
......@@ -49,4 +49,13 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
* @return 订单列表
*/
List<OrderInfo> getListBySuccessTime(@Param("successTime") Date successTime);
/**
* 更据创建订单时间获取订单列表
* @param created 创建订单时间
* @return 订单列表
*/
List<OrderInfo> getByCreateTime(@Param("created") Date created);
List<OrderInfo> getByLevelStatus(int levelStatus);
}
......@@ -27,4 +27,19 @@ public interface ShopZxMapper extends BaseMapper<shopZx> {
* 查询资讯数据
*/
List<zxUserDto> selectPage(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);
/**
* 点赞接口专用
*/
shopZx selectByzxid(@Param("zxid") Integer zxid);
int updateByzxid(@Param("zxid")Integer zxid,@Param("zxLikes") Integer zxLikes);
/**
* 资讯审核
* @param zxid
* @param ZxToExamine
* @return
*/
int updateZxToExaminezxid(@Param("zxid")Integer zxid,@Param("ZxToExamine") Integer ZxToExamine);
}
......@@ -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);
......
......@@ -125,6 +125,8 @@ public interface UsersMapper extends BaseMapper<User> {
Integer getuserIdById(@Param("userId") String userId);
Integer getById(@Param("userId") String userId);
Integer BYQMById(@Param("userId") String userId);
/**
......
......@@ -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
......@@ -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>
......
......@@ -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>
......@@ -140,4 +143,27 @@
</where>
</select>
<select id="getByCreateTime" resultType="cn.wisenergy.model.app.OrderInfo">
SELECT
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
<if test="created != null ">
YEAR(created) = YEAR(#{created})
AND MONTH(created) = MONTH(#{created})
</if>
</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
......@@ -27,6 +27,11 @@
<sql id="vals">
#{zxUrl},#{zxField},#{zxAddress},#{inviteCode},#{zxDate}
</sql>
<sql id="updateCondition">
<if test="zxLikes != null">zx_likes = #{zxLikes},</if>
</sql>
<!--资讯内容插入-->
<insert id="zxadd" parameterType="cn.wisenergy.model.app.shopZx">
insert into
......@@ -50,12 +55,39 @@
a.user_id as userId,
a.head_image as headImage
from shop_zx b inner join user_info a ON a.invite_code=b.invite_code
WHERE zx_to_examine != 1
WHERE zx_to_examine != 0
order by zxid desc limit #{pageNum},#{pageSize}
</select>
<!--资讯总记录数查询-->
<select id="selectAllNum" parameterType="cn.wisenergy.model.app.shopZx" >
select count (*) from shop_zx
</select>
<!--资讯点赞专用sql-->
<select id="selectByzxid" parameterType="java.lang.Integer" resultType="cn.wisenergy.model.app.shopZx">
select * from shop_zx where zx_id=#{zxid}
</select>
<update id="updateByzxid">
UPDATE
<include refid="table"/>
<set>
zx_likes = #{zxLikes}
</set>
<where>
zx_id = #{zxid}
</where>
</update>
<!--资讯审核-->
<update id="updateZxToExaminezxid">
UPDATE
<include refid="table"/>
<set>
zx_to_examine = #{ZxToExamine}
</set>
<where>
zx_id = #{zxid}
</where>
</update>
</mapper>
\ No newline at end of file
......@@ -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
......
......@@ -83,9 +83,6 @@
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<delete id="delById" parameterType="java.lang.Integer">
......@@ -121,9 +118,19 @@
<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>
</select>
<select id="getById" resultType="java.lang.Integer" parameterType="string">
select
userId
from
user_info
<where>
user_id=#{userId}
</where>
......@@ -216,7 +223,7 @@
select
id
from
<include refid="table"/>
user_info
<where>
user_id=#{userId}
</where>
......@@ -250,7 +257,6 @@
select id as id,
user_id as userId,
password as password,
userName as userName,
user_level as userLevel,
cross_border_line as crossBorderLine,
id_card_number as idCardNumber,
......@@ -273,9 +279,7 @@
<if test="salt != null and salt!=''">
and userLevel=#{userLevel}
</if>
<if test="userName != null and userName!=''">
and crossBorderLine=#{crossBorderLine}
</if>
<if test="sex != null">
and idCardNumber=#{idCardNumber}
</if>
......
......@@ -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;
}
}
......@@ -9,8 +9,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
......@@ -46,6 +44,15 @@ public class shopZx extends Model<shopZx> implements Serializable {
@ApiModelProperty(name = "zx_likes", value = "获赞数")
private Integer zxLikes;
public Integer getZxToExamine() {
return zxToExamine;
}
public Integer setZxToExamine(Integer zxToExamine) {
this.zxToExamine = zxToExamine;
return zxToExamine;
}
/**
* 审核字段
*/
......@@ -56,6 +63,16 @@ public class shopZx extends Model<shopZx> implements Serializable {
*/
@ApiModelProperty(name = "zx_field", value = "资讯文字输入字段")
private String zxField;
public Integer getZxLikes() {
return zxLikes;
}
public Integer setZxLikes(Integer zxLikes) {
this.zxLikes = zxLikes;
return zxLikes;
}
/**
* 用户发布地址
*/
......
......@@ -43,12 +43,6 @@ public class zxUserDto {
@ApiModelProperty(name = "zx_likes", value = "获赞数")
private Integer zxLikes;
/**
* 审核字段
*/
@TableField(exist = false)
@ApiModelProperty(name = "zx_to_examine", value = "审核字段")
private Integer zxToExamine;
/**
* 资讯文字输入字段
*/
......
This diff is collapsed.
......@@ -94,10 +94,28 @@ public class AccountManager {
}
@Transactional(rollbackFor = Exception.class)
public void updateAccountPerformanceMonth(List<TeamPerformance> list) {
for (TeamPerformance teamPerformance : list) {
teamPerformanceMapper.updateById(teamPerformance);
public Boolean updateAccountPerformanceMonth(List<TeamPerformance> addList, List<TeamPerformance> updateList) {
//1、新增
if (!CollectionUtils.isEmpty(addList)) {
for (TeamPerformance teamPerformance : addList) {
int count = teamPerformanceMapper.add(teamPerformance);
if (count == 0) {
return false;
}
}
}
//2、更新
if (!CollectionUtils.isEmpty(updateList)) {
for (TeamPerformance teamPerformance : updateList) {
int count = teamPerformanceMapper.edit(teamPerformance);
if (count == 0) {
return false;
}
}
}
return true;
}
/**
......
......@@ -29,11 +29,9 @@ public interface AccountService {
/**
* 收益和业绩统计(月度肥料 -日)
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
R<Boolean> performanceCount();
/**
* 获取用户的商机信息
......
package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.OrderInfo;
import java.util.List;
/**
*@ Description: 月定时任务接口定义
......@@ -13,19 +10,12 @@ import java.util.List;
*/
public interface MonthTaskService {
/**
* 订单返佣-月任务
* @return true or false
*/
R<Boolean> orderRebate();
/**
* 收益和业绩统计(月度肥料)-月任务
*
* @param list 订单信息
* @return true or false
*/
R<Boolean> performanceCount(List<OrderInfo> list);
R<Boolean> performanceCount();
/**
* 进步奖收益统计(最大进步奖) -月任务
......
......@@ -53,5 +53,19 @@ public interface UploadService {
*/
Map selectPage(Integer pageNum, Integer pageSize);
/**
* TODO 资讯点赞
* @param zxid
* @return
*/
Map Ilike(Integer zxid);
/**
* TODO 资讯审核
* @param zxid
* @return
*/
Map toExamine(Integer zxid);
}
......@@ -2,4 +2,5 @@ package cn.wisenergy.service.app;
public interface UserLevelService {
void userLevelUpgrade(String userId);
void userLevelUp();
}
......@@ -51,6 +51,12 @@ public interface UserService {
*/
Map userByZx(String userId, String beInvitedCode);
/**
* 用户登出
* @param token
* @return
*/
int logout(String token);
Integer getUserIdById(String userId);
......
......@@ -14,6 +14,7 @@ import cn.wisenergy.service.Manager.PublicManager;
import cn.wisenergy.service.app.AccountService;
import cn.wisenergy.service.Manager.AccountManager;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -23,6 +24,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -66,10 +68,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
private static final Integer TWENTY = 20;
@XxlJob(value = "orderRebateDayTask")
@Override
public R<Boolean> orderRebate() {
//获取返佣订单
log.info("订单返佣接口定时-日任务");
// //获取返佣订单
List<OrderInfo> list = orderMapper.getListBySuccessTime(new Date());
log.info("shop-mall[]AccountServiceImpl[]orderRebate[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
......@@ -112,8 +115,12 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
return R.ok(accountInfo);
}
@XxlJob(value = "monthManureDayTask")
@Override
public R<Boolean> performanceCount(List<OrderInfo> list) {
public R<Boolean> performanceCount() {
//获取本月订单
log.info("月度肥料定时-日任务");
List<OrderInfo> list = orderMapper.getByCreateTime(new Date());
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
return R.ok(0, true);
......@@ -124,60 +131,85 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
//计算当月所有订单成交额
BigDecimal totalMoney = new BigDecimal(0);
for (OrderInfo orderInfo : list) {
//判断是否是本月
boolean bool = publicManager.isThisMonth(orderInfo.getCreateTime(), PATTERN);
if (bool && orderInfo.getMonthlyTaskStatus() == 0) {
totalMoney = totalMoney.add(orderInfo.getPayment());
}
}
//遍历订单 订单状态创建时间,当月时间小于当前时间
//统计出出每个用户当月订单成交额 key:userId value:用户当月订单成交额
Map<String, Double> map = new HashMap<>();
for (OrderInfo orderInfo : list) {
long createTime = orderInfo.getCreated().getTime();
long time = System.currentTimeMillis();
if (createTime <= time) {
//获取用户信息
User user = usersMapper.selectById(orderInfo.getBuyerId());
if (null == user) {
continue;
}
String userId = orderInfo.getBuyerId();
double payMoney = orderInfo.getPayment().doubleValue();
List<TeamPerformance> teamPerformances = new ArrayList<>();
//key 存在 累加订单金额 到 value
if (map.containsKey(userId)) {
double money = payMoney + map.get(orderInfo.getBuyerId());
map.put(orderInfo.getBuyerId(), money);
} else {
//key 不存在,加入集合
map.put(userId, payMoney);
}
//获取团队业绩信息
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(user.getUserId(), yearMonth);
if (null == teamPerformance) {
continue;
}
//累加订单成交额
totalMoney = totalMoney.add(orderInfo.getPayment());
}
//1、统计当前用户月度业绩
BigDecimal userCount = teamPerformance.getMonthTeamPerformance().add(orderInfo.getPayment());
teamPerformance.setMonthTeamPerformance(userCount);
teamPerformances.add(teamPerformance);
//累计用户和上级用户-团队业绩
Map<String, Double> tempMap = new HashMap<>();
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List<User> userList = getByList(user.getUserId());
if (CollectionUtils.isEmpty(userList)) {
continue;
}
//遍历订单
for (Map.Entry<String, Double> entity : map.entrySet()) {
String userId = entity.getKey();
//1)、统计当前用户月度业绩
double userCount = entity.getValue();
tempMap.put(userId, userCount);
for (User userInfo : userList) {
//3、统计当前用户上级月度绩效
TeamPerformance team = teamPerformanceMapper.getByUserIdAndTime(userInfo.getUserId(), yearMonth);
if (null == team) {
continue;
}
//1、统计当前用户月度绩效
BigDecimal monthCount = team.getMonthTeamPerformance().add(orderInfo.getPayment());
team.setMonthTeamPerformance(monthCount);
teamPerformances.add(team);
//2)、获取当前用户的上级用户列表
List<User> userList = getByList(userId);
if (CollectionUtils.isEmpty(userList)) {
continue;
}
for (User userInfo : userList) {
//3)、统计当前用户的上级用户团队绩效
//key 存在 当前用户团队绩效 + 上级用户团队绩效
if (tempMap.containsKey(userInfo.getUserId())) {
double teamMoney = userCount + map.get(userInfo.getUserId());
map.put(userInfo.getUserId(), teamMoney);
} else {
//key 不存在,加入集合 当前用户团队绩效
map.put(userInfo.getUserId(), userCount);
}
}
}
//4、更新账户月度绩效
accountManager.updateAccountPerformanceMonth(teamPerformances);
//3、获取用户当月绩效信息 新增 or 更新
List<TeamPerformance> addList = new ArrayList<>();
List<TeamPerformance> updateList = new ArrayList<>();
for (Map.Entry<String, Double> entity : tempMap.entrySet()) {
//获取团队业绩信息
TeamPerformance teamPerformance = teamPerformanceMapper.getByUserIdAndTime(entity.getKey(), yearMonth);
if (null == teamPerformance) {
//获取用户信息
User user = usersMapper.getByUserId(entity.getKey());
//添加用户团队业绩信息
TeamPerformance performance = new TeamPerformance();
performance.setUserId(user.getUserId());
performance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
performance.setUserLevel(user.getUserLevel());
performance.setYearMonth(yearMonth);
teamPerformanceMapper.add(performance);
addList.add(performance);
} else {
teamPerformance.setMonthTeamPerformance(BigDecimal.valueOf(entity.getValue()));
updateList.add(teamPerformance);
}
}
//4、更新账户月度绩效
boolean updateBool = accountManager.updateAccountPerformanceMonth(addList, updateList);
if (!updateBool) {
return R.ok(1, false);
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List<User> userList = usersMapper.getAllGoldUser();
if (CollectionUtils.isEmpty(userList)) {
......@@ -201,12 +233,14 @@ 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;
}
@XxlJob(value = "growthAwardDayTask")
@Override
public R<Boolean> progressPrizeCount() {
log.info("shop-mall[]AccountServiceImpl[]performanceCount[]input.method");
......@@ -296,9 +330,11 @@ 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());
getUser(list, userInfo.getUserId());
if (null != userInfo) {
getUser(list, userInfo.getUserId());
}
}
}
......
......@@ -40,12 +40,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
private OrderMapper orderMapper;
//有赞客户端
DefaultYZClient yzClient = new DefaultYZClient();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startCreatedDate = null;
Date endCreatedDate = null;
Date startUpdateDate = null;
Date endUpdateDate = null;
Date date = new Date();
// Date date = new Date();
/**
* 根据订单的创建时间获取有赞的订单数据 插入本地数据库
*
......@@ -55,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();
//创建参数对象,并设置参数
......@@ -64,9 +66,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
// startCreatedDate = sdf.parse("2021-01-28 11:04:01");
// endCreatedDate = sdf.parse("2021-03-1 16:39:59");
//当前时间的前1分钟
startCreatedDate = sdf.parse(sdf.format(new Date(date.getTime()-(long) 80*24*60*60*1000)));
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) {
e.printStackTrace();
......@@ -135,8 +139,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
* @return
* @throws SDKException
*/
@XxlJob(value = "YouZanOrdersForUpdateTimejobhandler")
@Override
public void getYouZanOrdersForUpdateTime() throws SDKException {
Date date = new Date();
Token token = youzanToken();
YouzanTradesSoldGet youzanTradesSoldGet = new YouzanTradesSoldGet();
//创建参数对象,并设置参数
......@@ -145,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) 80*24*60*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));
......
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.expection.BaseException;
import cn.wisenergy.common.utils.*;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.shopZx;
import cn.wisenergy.model.app.zxUserDto;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.stereotype.Service;
......@@ -167,11 +168,9 @@ public class UploadServiceImpl implements UploadService {
if (file.isEmpty()) {
System.out.println("上传图片为空,请重新上传");
}
//判断上传文件格式
String fileType = file.getContentType();
if (fileType.equals("image/jpeg") || fileType.equals("image/png")) {
//上传后保存的文件名(需要防止图片重名导致的文件覆盖)
//获取文件名
fileName1 = file.getOriginalFilename();
......@@ -182,21 +181,18 @@ public class UploadServiceImpl implements UploadService {
//设置文件存储路径,可以存放在你想要指定的路径里面
String Path="/opt/upload/video/"; //上传图片存放位置
zxUrl+=localPath+fileName+",";
if (FileUtils.upload(file,Path, fileName)) {
//文件存放的相对路径(一般存放在数据库用于img标签的src)
String relativePath ="用于判断是否图片上传成功,返回值有:"+fileName;
result.put("relativePath", relativePath);//前端根据是否存在该字段来判断上传是否成功
result_msg = "图片上传成功";
result.put("zxUrl", zxUrl);
} else {
result_msg = "图片上传失败";
}
} else {
result_msg = "图片格式不正确";
}
}
result.put("result_msg", result_msg);
root.add(result);
......@@ -242,11 +238,9 @@ public class UploadServiceImpl implements UploadService {
if(fileName.contains("..")) {
throw new FileException("Sorry! Filename contains invalid path sequence " + fileName);
}
// Copy file to the target location (Replacing existing file with the same name)
Path targetLocation = this.fileStorageLocation.resolve(fileName);
Files.copy(file.getInputStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING);
return fileName;
} catch (IOException ex) {
throw new FileException("Could not store file " + fileName + ". Please try again!", ex);
......@@ -274,6 +268,7 @@ public class UploadServiceImpl implements UploadService {
@Override
public Map selectPage(Integer pageNum, Integer pageSize) {
Map map = new HashMap();
pageNum=pageNum-1;
List<zxUserDto> shopZxList = shopZxMapper.selectPage(pageNum,pageSize);
for (zxUserDto shopZx : shopZxList) {
String zxUrl = shopZx.getZxUrl();
......@@ -289,4 +284,49 @@ public class UploadServiceImpl implements UploadService {
return map;
}
/**
* 资讯点赞实现
* @param zxid
* @return
*/
@Override
public Map Ilike(Integer zxid) {
Map map = new HashMap();
try {
shopZx shopZx = shopZxMapper.selectByzxid(zxid);
int a = shopZx.getZxLikes();
Integer zxLikes=shopZx.setZxLikes(a + 1);
shopZxMapper.updateByzxid(zxid,zxLikes);
map.put("code",0);
map.put("msg","点赞成功!");
}catch ( BaseException e){
map.put("code",1);
map.put("msg","点赞失败!");
};
return map;
}
/**
* 资讯审核
* @param zxid
* @return
*/
@Override
public Map toExamine(Integer zxid) {
Map map = new HashMap();
try {
shopZx shopZx = shopZxMapper.selectByzxid(zxid);
if(null!=shopZx){
Integer ZxToExamine=shopZx.setZxToExamine(1);
shopZxMapper.updateZxToExaminezxid(zxid,ZxToExamine);
}
map.put("code",0);
map.put("msg","审核通过!");
}catch ( BaseException e){
map.put("code",1);
map.put("msg","审核失败!");
};
return map;
}
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.RedisKeyUtils;
import cn.wisenergy.common.utils.ShareCodeUtil;
import cn.wisenergy.mapper.RecommendUserMapper;
import cn.wisenergy.mapper.TeamUserInfoMapper;
......@@ -39,6 +40,9 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
@Autowired
private TeamUserInfoMapper teamUserInfoMapper;
@Autowired
private RedisUtils redisUtils;
@Override
public User getById(String userId) {
return usersMapper.getByUserId(userId);
......@@ -81,7 +85,6 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
@Override
public Map userByZx(String userId, String beInvitedCode) {
//查询数据库,看看是否存在该用户
// Integer yh=usersMapper.getuserIdById(userId);
User byUserId = usersMapper.getByUserId(userId);
if (null != byUserId) {
R.error(0, "该用户已存在!请直接登录!");
......@@ -91,12 +94,12 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
return map;
}
/**
* 判断用户推荐人的邀请码是否为空,空的话填写1
* 判断用户推荐人的邀请码是否为空,空的话填写1 || "" == beInvitedCode
*/
if (null == beInvitedCode || "" == beInvitedCode) {
if ("".equals(beInvitedCode) || null==beInvitedCode) {
beInvitedCode = "1";
// 插入用户手机号与推荐人邀请码
//插入用户手机号与推荐人邀请码
usersMapper.insertbyint(userId, beInvitedCode);
} else if ("1".equals(beInvitedCode)) {
//用户的被邀请码,查询到推荐人用户,根据推荐人用户的邀请码查询/修改
......@@ -131,7 +134,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
byUserId1.setInviteCode(inviteCode);
byUserId1.setUserLevel(0);
usersMapper.edit(byUserId1);
usersMapper.updateById(byUserId1);
String BYQM = String.valueOf(usersMapper.BYQMById(userId));
......@@ -286,4 +289,19 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
teamgg(beInvitedCode);
return R.ok("团队表普通用户数量+1成功!", 0);
}
/**
* 用户登出
* @param token
* @return
*/
@Override
public int logout(String token) {
int succ = 0;
String key = RedisKeyUtils.formatKeyWithPrefix(token);
redisUtils.delete(key);
if(redisUtils.getValue(key) == null){
succ = 1;
}
return succ;
}
}
......@@ -19,7 +19,7 @@ import java.util.List;
/**
* @author 86187
*/
@Api(tags = "账户管")
@Api(tags = "账户管")
@RestController
@RequestMapping("/account")
@Slf4j
......@@ -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();
}
}
......@@ -2,6 +2,7 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.service.app.AccountService;
import cn.wisenergy.service.app.MonthTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
......@@ -20,11 +21,11 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class LastAccountController {
@Autowired
private AccountService accountService;
private MonthTaskService monthTaskService;
// @ApiOperation(value = "复制表-结构和数据", notes = "复制表-结构和数据", httpMethod = "PUT")
// @PutMapping("/add")
// public void copyTable(){
// accountService.mirrorImage();
// }
@ApiOperation(value = "复制表-结构和数据", notes = "复制表-结构和数据", httpMethod = "PUT")
@PutMapping("/add")
public void copyTable() {
monthTaskService.mirrorImage();
}
}
......@@ -2,6 +2,7 @@ package cn.wisenergy.web.admin.controller.app;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import cn.wisenergy.common.enums.ResultEnum;
import cn.wisenergy.common.utils.*;
import cn.wisenergy.model.app.User;
import cn.wisenergy.model.app.UsersDto;
......@@ -42,6 +43,9 @@ import java.util.Map;
@RequestMapping("api/user")
@RestController
public class LoginController {
@Autowired
private RedisUtils redisUtils;
......@@ -121,11 +125,9 @@ public class LoginController {
map.put("code","2001");
map.put("msg","未登录");
return map;
///throw new BaseException(ResultEnum.FILE_NOT_LOGIN);
}
UsersDto usersDto=JSONObject.parseObject(userDtoJson,UsersDto.class);
usersDto.setPassword(null);
return (Map) ResultUtils.returnDataSuccess(userDtoJson);
}
......@@ -168,34 +170,46 @@ public class LoginController {
String key= StringUtil.formatKeyWithPrefix(Constants.RedisKey.PROJECT_PRIFIX,Constants.RedisKey.SMS_PRIFIX,userId,Constants.Sms.CodeType.LOGIN_OR_REGISTER+"");
String redisCode=redisUtils.getValue(key);
if(StringUtil.isBlank(redisCode) || !sms.equals(redisCode)){
// try {
// throw new BaseException(ResultEnum.FAIL_VERIFY);
//
// } catch (BaseException e) {
Map map=new HashMap();
map.put("code","1003");
map.put("msg","验证码错误");
// throw new BaseException(ResultEnum.FAIL_VERIFY);
return map;
// }
}
redisUtils.delete(key);
//判断phone是否符合输入类型
if(!userId.matches(Constants.RegConstant.PHONE_REGSTR)){
// try {
// throw new BaseException(ResultEnum.PHONE_ERROR);
// } catch (BaseException e) {
// e.printStackTrace();
Map map=new HashMap();
map.put("code","1008");
map.put("msg","手机号码格式不正确");
// throw new BaseException(ResultEnum.FAIL_VERIFY);
return map;
// }
}
return usersService.userByZx(userId,beInvitedCode);
}
/**
* 退出登录
* @param request
* @return
*/
@ApiOperation(value = "退出登录", produces = "application/json", notes = "退出登录")
@ApiImplicitParam(paramType = "header",name = "token", value = "用户token", required = true, dataType = "String")
@PostMapping("/logout")
public Result logout(HttpServletRequest request) {
log.info("退出登录");
Result result = ResultUtils.returnFail();
String token = request.getHeader("token");
String key = RedisKeyUtils.formatKeyWithPrefix(Constants.Redis.PREFIX_TOKEN, token);
if(redisUtils.getValue(key) == null){
log.info("要退出登录的用户未登录");
return ResultUtils.returnResult(ResultEnum.FILE_NOT_LOGIN);
}
int succ = usersService.logout(token);
if (succ > 0) {
result = ResultUtils.returnSuccess();
}
return result;
}
}
......@@ -59,7 +59,7 @@ public class UploadController {
}
/**
* TODO 单图片文件上传
* TODO 用户头像上传
*
* @param request
* @return
......@@ -110,4 +110,23 @@ public class UploadController {
return uploadService.selectPage(pageNum,pageSize);
}
/**
* 点赞接口
*/
@ApiImplicitParam(name = "zxid", value = "资讯ID", required = true,dataType = "integer")
@RequestMapping(method = RequestMethod.POST, value = "/thumbUp")
public Map like(int zxid){
return uploadService.Ilike(zxid);
}
/**
* 审核接口
*/
@ApiImplicitParam(name = "zxid", value = "资讯ID", required = true,dataType = "integer")
@RequestMapping(method = RequestMethod.POST, value = "/toExamine")
public Map ToExamine(int zxid){
return uploadService.toExamine(zxid);
}
}
\ No newline at end of file
......@@ -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);
......
......@@ -12,6 +12,7 @@ import org.apache.shiro.authz.UnauthorizedException;
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
......@@ -59,15 +60,10 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
*/
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
if (isLoginAttempt(request, response)) {
//if (!isLoginAttempt(request, response) || !executeLogin(request,response)) {
try {
executeLogin(request, response);
} catch (UnauthorizedException | AuthenticationException e) {
return false;
}
if (((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())) {
return true;
}
return true;
return false;
}
/**
......
......@@ -51,6 +51,7 @@ mybatis-plus:
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
xxl:
job:
......
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