补发任务奖励 任务
This commit is contained in:
@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -23,6 +24,8 @@ public interface InviteDao extends BaseMapper<Invite> {
|
||||
Integer selectInviteCount2(@Param("code") String code);
|
||||
Integer selectInviteSignCount(@Param("code") String code);
|
||||
|
||||
List<Long> selectInviteSignByUser(@Param("code") String code);
|
||||
|
||||
Double selectInviteSum(@Param("state") Integer state, @Param("userId") Long userId);
|
||||
|
||||
IPage<Map<String,Object>> selectInviteUser(Page<Map<String,Object>> page, @Param("userId") Long userId,@Param("state") Integer state,@Param("userType") Integer userType);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface InviteService {
|
||||
@@ -18,6 +19,8 @@ public interface InviteService {
|
||||
Integer selectInviteCount2(String code);
|
||||
Integer selectInviteSignCount(String code);
|
||||
|
||||
List<Long> selectInviteSignByUser(String code);
|
||||
|
||||
Double selectInviteSum(Integer state,Long userId);
|
||||
|
||||
int saveBody(Long userId, UserEntity userEntity);
|
||||
|
||||
@@ -31,10 +31,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 邀请记录
|
||||
@@ -131,6 +128,10 @@ public class InviteServiceImpl extends ServiceImpl<InviteDao, Invite> implements
|
||||
return inviteDao.selectInviteSum(state, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> selectInviteSignByUser(String code) {
|
||||
return inviteDao.selectInviteSignByUser(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBody(Long userId, UserEntity userEntity) {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.sqx.modules.job.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.invite.service.InviteService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("SupplyAgainSignRewardTask")
|
||||
public class SupplyAgainSignRewardTask implements ITask {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private InviteService inviteService;
|
||||
@Autowired
|
||||
private UserMoneyDetailsService userMoneyDetailsService;
|
||||
@Autowired
|
||||
private CommonInfoService commonRepository;
|
||||
@Autowired
|
||||
private UserMoneyService userMoneyService;
|
||||
|
||||
@Override
|
||||
public void run(String params) {
|
||||
if (StringUtils.isBlank(params)) {
|
||||
log.error("参数为空");
|
||||
}
|
||||
|
||||
Long userId = Long.parseLong(params);
|
||||
|
||||
UserEntity userEntity = userService.selectUserById(userId);
|
||||
if (userEntity == null) {
|
||||
log.error("用户不存在");
|
||||
}
|
||||
|
||||
List<Long> userIdList = inviteService.selectInviteSignByUser(userEntity.getInvitationCode());
|
||||
|
||||
if (userIdList == null || userIdList.isEmpty()) {
|
||||
log.error("没有邀请的用户 用户 ID {}", userId);
|
||||
}
|
||||
|
||||
String amount = commonRepository.findOne(912).getValue();
|
||||
for (Long inviteeUserId : userIdList) {
|
||||
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("classify", 6);
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("by_user_id", inviteeUserId);
|
||||
int count = userMoneyDetailsService.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
log.info("已经发放过奖励, 用户 ID {}, 邀请 ID {}", userId, inviteeUserId);
|
||||
continue;
|
||||
}
|
||||
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
userMoneyDetails.setClassify(6);
|
||||
userMoneyDetails.setMoney(new BigDecimal(amount));
|
||||
userMoneyDetails.setUserId(userId);
|
||||
userMoneyDetails.setByUserId(inviteeUserId);
|
||||
userMoneyDetails.setCreateTime(DateUtil.now());
|
||||
userMoneyDetails.setContent("分享达标奖励" + amount + "元");
|
||||
userMoneyDetails.setTitle("分享达标奖励");
|
||||
userMoneyDetails.setState(2);
|
||||
userMoneyDetails.setType(1);
|
||||
userMoneyDetails.setMoneyType(1);
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
//存入余额 钱
|
||||
userMoneyService.updateAmount(1, inviteeUserId, Double.parseDouble(amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,10 +175,12 @@ public class WuyouPay {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
payOrder("20221118123456794", "0.1", "Mozilla/5.0", "1230-98688", "h5");
|
||||
// payOrder("20221118123456794", "0.1", "Mozilla/5.0", "1230-98688", "h5");
|
||||
// queryOrder("20221118123456791", "0.1", "Mozilla/5.0");
|
||||
|
||||
// extractOrder("20221118123456793", "1", "1157756119@qq.com", "巩奕杰");
|
||||
// queryExtractOrder("20221118123456793", "1");
|
||||
|
||||
System.out.println(DateUtil.today()+ " 00:00:00");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,22 @@
|
||||
tu.inviter_code = #{code};
|
||||
</select>
|
||||
|
||||
<select id="selectInviteSignByUser" resultType="list">
|
||||
SELECT
|
||||
tu.user_id
|
||||
FROM
|
||||
tb_user tu
|
||||
LEFT JOIN
|
||||
(SELECT user_id
|
||||
FROM orders
|
||||
WHERE pay_way = 9
|
||||
AND `status` = 1
|
||||
GROUP BY user_id
|
||||
HAVING COUNT(*) >= 3) sub_orders ON tu.user_id = sub_orders.user_id
|
||||
WHERE
|
||||
tu.inviter_code = #{code};
|
||||
</select>
|
||||
|
||||
<select id="selectInviteSum" resultType="Double">
|
||||
select sum(money) from invite
|
||||
where user_id=#{userId}
|
||||
|
||||
Reference in New Issue
Block a user