抽奖金额修改
订单笔数统计 只统计支付宝支付 增加 一次性任务 新人福利 领取1元
This commit is contained in:
@@ -15,7 +15,9 @@ import com.sqx.modules.app.service.UserService;
|
|||||||
import com.sqx.modules.common.entity.CommonInfo;
|
import com.sqx.modules.common.entity.CommonInfo;
|
||||||
import com.sqx.modules.common.service.CommonInfoService;
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
import com.sqx.modules.discSpinning.entity.DiscSpinning;
|
import com.sqx.modules.discSpinning.entity.DiscSpinning;
|
||||||
|
import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
||||||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||||
|
import com.sqx.modules.discSpinning.service.DiscSpinningAmountService;
|
||||||
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||||
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
||||||
import com.sqx.modules.orders.entity.Orders;
|
import com.sqx.modules.orders.entity.Orders;
|
||||||
@@ -47,9 +49,10 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class DiscSpinningController {
|
public class DiscSpinningController {
|
||||||
|
|
||||||
private final DiscSpinningService discSpinningService;
|
private final DiscSpinningService discSpinningService;
|
||||||
|
private final DiscSpinningRecordService recordService;
|
||||||
|
private final DiscSpinningAmountService amountService;
|
||||||
private final CommonInfoService commonRepository;
|
private final CommonInfoService commonRepository;
|
||||||
private final OrdersService ordersService;
|
private final OrdersService ordersService;
|
||||||
private final DiscSpinningRecordService recordService;
|
|
||||||
private final UserMoneyService userMoneyService;
|
private final UserMoneyService userMoneyService;
|
||||||
private final UserMoneyDetailsService userMoneyDetailsService;
|
private final UserMoneyDetailsService userMoneyDetailsService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
@@ -62,10 +65,11 @@ public class DiscSpinningController {
|
|||||||
UserMoneyDetailsService userMoneyDetailsService, CashOutService cashOutService,
|
UserMoneyDetailsService userMoneyDetailsService, CashOutService cashOutService,
|
||||||
OrdersService ordersService, DiscSpinningRecordService recordService,
|
OrdersService ordersService, DiscSpinningRecordService recordService,
|
||||||
UserMoneyService userMoneyService, UserService userService,
|
UserMoneyService userMoneyService, UserService userService,
|
||||||
TaskCenterService taskCenterService
|
TaskCenterService taskCenterService, DiscSpinningAmountService amountService
|
||||||
) {
|
) {
|
||||||
this.commonRepository = commonRepository;
|
this.commonRepository = commonRepository;
|
||||||
this.discSpinningService = discSpinningService;
|
this.discSpinningService = discSpinningService;
|
||||||
|
this.amountService = amountService;
|
||||||
this.ordersService = ordersService;
|
this.ordersService = ordersService;
|
||||||
this.recordService = recordService;
|
this.recordService = recordService;
|
||||||
this.userMoneyService = userMoneyService;
|
this.userMoneyService = userMoneyService;
|
||||||
@@ -273,34 +277,22 @@ public class DiscSpinningController {
|
|||||||
randomDouble = random.nextDouble();
|
randomDouble = random.nextDouble();
|
||||||
} while (randomDouble == 0);
|
} while (randomDouble == 0);
|
||||||
BigDecimal randomNum = new BigDecimal(randomDouble).multiply(new BigDecimal(10000)).divide(new BigDecimal(100));
|
BigDecimal randomNum = new BigDecimal(randomDouble).multiply(new BigDecimal(10000)).divide(new BigDecimal(100));
|
||||||
|
List<DiscSpinningAmount> amounts = amountService.list(new QueryWrapper<DiscSpinningAmount>().eq("status",1).orderByAsc("max_amount"));
|
||||||
for (DiscSpinning prize : prizes) {
|
for (DiscSpinning prize : prizes) {
|
||||||
if (randomNum.compareTo(prize.getNumber()) < 0) {
|
if (randomNum.compareTo(prize.getNumber()) < 0) {
|
||||||
if (prize.getType() == 2) {
|
if (prize.getType() == 2) {
|
||||||
int maxAmount = Integer.parseInt(commonRepository.findOne(900).getValue());
|
int maxAmount = Integer.parseInt(commonRepository.findOne(900).getValue());
|
||||||
double resultAmount = 0;
|
double resultAmount = 0;
|
||||||
//从0 到 80-amount 直接 取 多个区间 数值越小 概率越大
|
|
||||||
if (prize.getType() == 2) {
|
if (prize.getType() == 2) {
|
||||||
double baseRandom = random.nextDouble();
|
double baseRandom = random.nextDouble();
|
||||||
if (baseRandom < 0.8) {
|
double baseAmount = 0;
|
||||||
// 0.8到0.82范围内概率最大(这里示例以当前订单金额为基础,模拟类似0.8的情况)
|
for (DiscSpinningAmount amount : amounts) {
|
||||||
resultAmount = random.nextDouble() * 0.02;
|
if (baseRandom < amount.getRandom()) {
|
||||||
} else if (baseRandom < 0.9) {
|
resultAmount = baseAmount + random.nextDouble() * (amount.getMaxAmont() - baseAmount);
|
||||||
// 0.82 - 0.85范围概率小一些
|
|
||||||
resultAmount = 0.02 + (random.nextDouble() * 0.03);
|
|
||||||
} else if (baseRandom < 0.95) {
|
|
||||||
// 0.85 - 0.9概率更小
|
|
||||||
resultAmount = 0.05 + (random.nextDouble() * 0.05);
|
|
||||||
} else if (baseRandom < 0.97) {
|
|
||||||
// 0.9 - 1概率更小
|
|
||||||
resultAmount = 0.1 + (random.nextDouble() * 0.1);
|
|
||||||
} else if (baseRandom < 0.99) {
|
|
||||||
//1 - 1.3 概率更小
|
|
||||||
resultAmount = 0.2 + (random.nextDouble() * 0.3);
|
|
||||||
}
|
}
|
||||||
// else {
|
baseAmount = amount.getMaxAmont();
|
||||||
// // 1.3 - 控制最大金额为80
|
}
|
||||||
// resultAmount = 1 + (random.nextDouble() * (maxAmount - 1));
|
|
||||||
// }
|
|
||||||
if (resultAmount == 0) {
|
if (resultAmount == 0) {
|
||||||
resultAmount = 0.01;
|
resultAmount = 0.01;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.sqx.modules.discSpinning.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DiscSpinningAmountDao extends BaseMapper<DiscSpinningAmount> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.sqx.modules.discSpinning.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 现金红包 抽奖配置(DiscSpinningAmount)表实体类
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @since 2024-12-11 14:59:01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("disc_spinning_amount")
|
||||||
|
@ApiModel(value = "现金红包 抽奖配置 实体类")
|
||||||
|
public class DiscSpinningAmount extends Model<DiscSpinningAmount> {
|
||||||
|
@ApiModelProperty("主键id")
|
||||||
|
private Long id;
|
||||||
|
@ApiModelProperty("描述")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("0-1 小于 多少为该奖励")
|
||||||
|
private Double random;
|
||||||
|
@ApiModelProperty("最大金额")
|
||||||
|
private Double maxAmont;
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.sqx.modules.discSpinning.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface DiscSpinningAmountService extends IService<DiscSpinningAmount> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.sqx.modules.discSpinning.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.modules.discSpinning.dao.DiscSpinningAmountDao;
|
||||||
|
import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
||||||
|
import com.sqx.modules.discSpinning.service.DiscSpinningAmountService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DiscSpinningAmountServiceImpl extends ServiceImpl<DiscSpinningAmountDao, DiscSpinningAmount> implements DiscSpinningAmountService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -6,6 +6,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TaskCenterRecordDao extends BaseMapper<TaskCenterRecord> {
|
public interface TaskCenterRecordDao extends BaseMapper<TaskCenterRecord> {
|
||||||
|
Integer countTaskNum(Long userId, Long taskId, String time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
package com.sqx.modules.taskCenter.entity;
|
package com.sqx.modules.taskCenter.entity;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class TaskCenterRecordServiceImpl extends ServiceImpl<TaskCenterRecordDao
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer countTaskNum(Long userId, Long taskId, String time) {
|
public Integer countTaskNum(Long userId, Long taskId, String time) {
|
||||||
return baseMapper.selectCount(new QueryWrapper<TaskCenterRecord>().eq("user_id", userId).eq("task_id", taskId).gt("create_time", time));
|
return baseMapper.countTaskNum(userId, taskId, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,9 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||||||
signWrapper.orderByAsc("create_time");
|
signWrapper.orderByAsc("create_time");
|
||||||
List<UserSignRecord> signRecordList = signRecordService.list(signWrapper);
|
List<UserSignRecord> signRecordList = signRecordService.list(signWrapper);
|
||||||
for (TaskCenter s : taskPage.getRecords()) {
|
for (TaskCenter s : taskPage.getRecords()) {
|
||||||
|
switch (s.getType()) {
|
||||||
//签到任务
|
//签到任务
|
||||||
if (s.getType() == 2) {
|
case 2:
|
||||||
if (s.getNumber().equals(1)) {
|
if (s.getNumber().equals(1)) {
|
||||||
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
Integer dayOrderNum = ordersService.countOrderNum(userId, DateUtil.today() + " 00:00:00");
|
||||||
if (dayOrderNum < 3) {
|
if (dayOrderNum < 3) {
|
||||||
@@ -98,6 +99,21 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
//一次性任务
|
||||||
|
case 3:
|
||||||
|
if (s.getId().equals(1)) {
|
||||||
|
Integer sumOrderNum = ordersService.countOrderNum(userId, null);
|
||||||
|
if (sumOrderNum != null && sumOrderNum < s.getNumber()) {
|
||||||
|
s.setDiscNumber(sumOrderNum);
|
||||||
|
s.setNumber(s.getNumber());
|
||||||
|
} else if (recordService.countTaskNum(userId, s.getId(), null) > 0) {
|
||||||
|
s.setButtonTitle("已领取");
|
||||||
|
s.setDisabled(false);
|
||||||
|
s.setNumber(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Result.success().put("data", taskPage);
|
return Result.success().put("data", taskPage);
|
||||||
@@ -152,6 +168,13 @@ public class TaskCenterServiceImpl extends ServiceImpl<TaskCenterDao, TaskCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (taskCenter.getType().equals(3) && taskCenter.getId() == 1) {
|
||||||
|
Integer sumOrderNum = ordersService.countOrderNum(userId, null);
|
||||||
|
if (sumOrderNum != null && sumOrderNum < taskCenter.getNumber()) {
|
||||||
|
return Result.error("领取失败,未达成领取条件");
|
||||||
|
} else if (recordService.countTaskNum(userId, taskCenter.getId(), null) > 0) {
|
||||||
|
return Result.error("不可重复领取");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<TaskCenterRecord> records = new ArrayList<>();
|
List<TaskCenterRecord> records = new ArrayList<>();
|
||||||
Long targetId = null;
|
Long targetId = null;
|
||||||
|
|||||||
@@ -314,6 +314,7 @@
|
|||||||
WHERE
|
WHERE
|
||||||
orders.user_id = #{userId}
|
orders.user_id = #{userId}
|
||||||
AND orders.`status` = 1
|
AND orders.`status` = 1
|
||||||
|
AND orders.`pay_way` = 9
|
||||||
<if test="time !=null and time != ''">
|
<if test="time !=null and time != ''">
|
||||||
and create_time > #{time}
|
and create_time > #{time}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
19
src/main/resources/mapper/tashCenter/TaskCenterRecordDto.xml
Normal file
19
src/main/resources/mapper/tashCenter/TaskCenterRecordDto.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?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="com.sqx.modules.taskCenter.dao.TaskCenterRecordDao">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="countTaskNum" resultType="Integer">
|
||||||
|
SELECT
|
||||||
|
count(*)
|
||||||
|
FROM
|
||||||
|
task_center_record record
|
||||||
|
WHERE
|
||||||
|
record.user_id = #{userId}
|
||||||
|
AND record.task_id = #{taskId}
|
||||||
|
<if test="time !=null and time != ''">
|
||||||
|
and create_time > #{time}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user