分享达标

大转盘 获取次数区分
抽奖 区分
统计 订单数统一接口
This commit is contained in:
2024-12-07 11:03:53 +08:00
parent a297859b47
commit 94159c174e
6 changed files with 116 additions and 41 deletions

View File

@@ -130,34 +130,45 @@ public class DiscSpinningController {
@ApiResponses({
@ApiResponse(code = 200, message = "{\"sum\":\"总抽奖次数\",\"count\":\"剩余抽奖次数\"}"),
})
public Result drawCount(@RequestAttribute("userId") Long userId) {
public Result drawCount(@RequestAttribute("userId") Long userId, @RequestBody Map maps) {
Map<String, Object> map = new HashMap<>();
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
map.put("sum", drawCount);
int i = recordService.countDraw(userId);
if (drawCount - i > 0) {
map.put("count", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
return Result.success(map);
if (maps.containsKey("source") && "task".equals(maps.get("source"))) {
//任务可抽奖次数
} else {
map.put("count", 0);
return Result.success(map);
int i = recordService.countDraw(userId);
if (drawCount - i > 0) {
map.put("count", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
} else {
map.put("count", 0);
}
}
return Result.success(map);
}
@Login
@GetMapping("/app/discSpinning/draw")
@ApiOperation("抽取大转盘")
public Result draw(@RequestAttribute("userId") Long userId) {
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
Integer i = recordService.countDraw(userId);
if (i != null && i > drawCount) {
return Result.error("当日可抽奖次数已超限");
public Result draw(@RequestAttribute("userId") Long userId, @RequestBody Map maps) {
double amount = 0;
Long orderId = null;
if (!maps.containsKey("source") && !"task".equals(maps.get("source"))) {
//任务抽奖
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
Integer i = recordService.countDraw(userId);
if (i != null && i > drawCount) {
return Result.error("当日可抽奖次数已超限");
}
Orders orders = ordersService.selectOrdersByDay(userId);
amount = orders.getPayMoney().doubleValue();
orderId = orders.getOrdersId();
if (orders == null) {
return Result.error("无可抽奖机会");
}
}
Orders orders = ordersService.selectOrdersByDay(userId);
if (orders == null) {
return Result.error("无可抽奖机会");
}
return new Result().put("data", draws(orders.getPayMoney().doubleValue(), orders.getOrdersId(), userId));
return new Result().put("data", draws(amount, orderId, userId));
}
@PostMapping("/app/discSpinning/receive")

View File

@@ -14,29 +14,32 @@ public interface OrdersDao extends BaseMapper<Orders> {
int insertOrders(Orders orders);
IPage<Orders> selectOrdersByOrdersNo(Page<Orders> pages, @Param("ordersNo") String ordersNo,@Param("status") Integer status,
@Param("userId") Long userId,@Param("courseId") Long courseId,@Param("flag") Integer flag,
IPage<Orders> selectOrdersByOrdersNo(Page<Orders> pages, @Param("ordersNo") String ordersNo, @Param("status") Integer status,
@Param("userId") Long userId, @Param("courseId") Long courseId, @Param("flag") Integer flag,
@Param("time") String time, @Param("userName") String userName, @Param("ordersType") Integer ordersType,
@Param("startTime") String startTime, @Param("endTime") String endTime,@Param("sysUserId") Long sysUserId,
@Param("qdCode") String qdCode,@Param("sysUserName") String sysUserName);
@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("sysUserId") Long sysUserId,
@Param("qdCode") String qdCode, @Param("sysUserName") String sysUserName);
int deleteOrders(String[] ids);
Double statisticsIncomeMoney(@Param("time") String time, @Param("flag") Integer flag, @Param("ordersType") Integer ordersType);
Orders selectOrdersByCourseIdAndUserId(Long userId,Long courseId);
Orders selectOrdersByCourseIdAndUserId(Long userId, Long courseId);
IPage<Orders> selectOrdersMoneyList(Page<Orders> page,Integer flag,String time);
IPage<Orders> selectOrdersMoneyList(Page<Orders> page, Integer flag, String time);
Integer selectOrdersCount(Integer status,Integer ordersType,Integer flag,String time,Long sysUserId);
Integer selectOrdersCount(Integer status, Integer ordersType, Integer flag, String time, Long sysUserId);
Double selectOrdersMoney(Integer status,Integer ordersType,Integer flag,String time,Long courseId,Long sysUserId);
Double selectOrdersMoney(Integer status, Integer ordersType, Integer flag, String time, Long courseId, Long sysUserId);
Double selectFenXiaoMoney(Integer type,Long sysUserId,Integer flag,String time);
Double selectFenXiaoMoney(Integer type, Long sysUserId, Integer flag, String time);
Integer selectOrdersCountStatisticsByYear(Integer flag,String time,Integer status);
Integer selectOrdersCountStatisticsByYear(Integer flag, String time, Integer status);
Integer selectOrdersCountStatisticsByDay(Long userId, Integer limit);
Integer selectOrdersCountStatisticsByDay(Long userId,Integer limit);
Orders selectOrdersByDay(Long userId);
Integer countOrderNum(Long userId, String time);
}

View File

@@ -53,5 +53,13 @@ public interface OrdersService extends IService<Orders> {
Orders selectOrdersByDay(Long userId);
/**
* 统计 用户成功订单笔数
* @param userId
* @param time 时间条件 不传为全部订单 格式 yyyy-MM-dd HH:mm:ss
* @return
*/
Integer countOrderNum(Long userId,String time);
}

View File

@@ -550,8 +550,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
}
@Override
public Integer selectOrdersCountStatisticsByDay(Long userId,Integer limit) {
return baseMapper.selectOrdersCountStatisticsByDay(userId,limit);
public Integer selectOrdersCountStatisticsByDay(Long userId, Integer limit) {
return baseMapper.selectOrdersCountStatisticsByDay(userId, limit);
}
@Override
@@ -559,4 +559,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
return baseMapper.selectOrdersByDay(userId);
}
@Override
public Integer countOrderNum(Long userId, String time) {
return baseMapper.countOrderNum(userId, time);
}
}

View File

@@ -9,6 +9,7 @@ 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 com.sqx.modules.orders.entity.Orders;
import com.sqx.modules.orders.service.OrdersService;
@@ -32,6 +33,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
/**
* @author GYJ
@@ -48,13 +50,13 @@ public class WuyouController {
private final InviteService inviteService;
private final UserMoneyService userMoneyService;
private final UserMoneyDetailsService userMoneyDetailsService;
private final CommonInfoService commonRepository;
private final CashOutDao cashOutDao;
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, UserService userService, InviteService inviteService, CashOutDao cashOutDao,
UserMoneyService userMoneyService, UserMoneyDetailsService userMoneyDetailsService) {
UserMoneyService userMoneyService, UserMoneyDetailsService userMoneyDetailsService, CommonInfoService commonRepository) {
this.ordersService = ordersService;
this.payDetailsDao = payDetailsDao;
this.userService = userService;
@@ -62,6 +64,7 @@ public class WuyouController {
this.cashOutDao = cashOutDao;
this.userMoneyService = userMoneyService;
this.userMoneyDetailsService = userMoneyDetailsService;
this.commonRepository = commonRepository;
}
@ApiOperation("支付订单")
@@ -202,7 +205,44 @@ public class WuyouController {
}
ordersService.updateById(order);
ordersService.insertOrders(order);
CompletableFuture.runAsync(() -> {
activities(user, byUser);
});
return "success";
}
public void activities(UserEntity user, UserEntity sourceUser) {
//分享达标
if (sourceUser != null && sourceUser.getUserId() != 1) {
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("classify", 7);
queryWrapper.eq("user_id", sourceUser.getUserId());
queryWrapper.eq("by_user_id", user.getUserId());
int count = userMoneyDetailsService.count(queryWrapper);
if (count == 0) {
//满3笔
Integer sumOrderNum = ordersService.countOrderNum(user.getUserId(), null);
if (sumOrderNum > Integer.parseInt(commonRepository.findOne(913).getValue())) {
String amount = commonRepository.findOne(912).getValue();
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
userMoneyDetails.setClassify(7);
userMoneyDetails.setMoney(new BigDecimal(amount));
userMoneyDetails.setUserId(sourceUser.getUserId());
userMoneyDetails.setByUserId(user.getUserId());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
userMoneyDetails.setContent("分享达标奖励" + amount + "");
userMoneyDetails.setTitle("分享达标奖励");
userMoneyDetails.setState(2);
userMoneyDetails.setType(1);
userMoneyDetailsService.save(userMoneyDetails);
//存入余额 钱
userMoneyService.updateAmount(1, sourceUser.getUserId(), Double.parseDouble(amount));
}
}
}
}
}

View File

@@ -295,18 +295,26 @@
</select>
<select id="selectOrdersByDay" resultType="com.sqx.modules.orders.entity.Orders">
SELECT orders.*
FROM orders
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.order_id
WHERE orders.user_id = #{userId}
AND orders.`status` = 1
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
AND record.order_id IS NULL
ORDER BY orders.create_time LIMIT 1
</select>
<select id="countOrderNum" resultType="Integer">
SELECT
orders.*
count(*)
FROM
orders
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.order_id
WHERE
orders.user_id = #{userId}
orders.user_id = #{userId}
AND orders.`status` = 1
AND orders.create_time > DATE_FORMAT( CURDATE(), '%Y-%m-%d 00:00:00' )
AND record.order_id IS NULL
ORDER BY
orders.create_time
LIMIT 1
<if test="time !=null and time != ''">
and create_time > #{time}
</if>
</select>
</mapper>