抽奖 获取抽奖次数
This commit is contained in:
@@ -25,6 +25,7 @@ import com.sqx.modules.pay.wuyou.BaseResp;
|
||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -123,17 +124,34 @@ public class DiscSpinningController {
|
||||
return Result.success().put("data", discSpinningService.page(new Page<>(0, 8), new QueryWrapper<DiscSpinning>().orderByAsc("odds")));
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/app/discSpinning/drawCount")
|
||||
@ApiOperation("获取大转盘抽奖机会")
|
||||
@ApiModelProperty
|
||||
public Result drawCount(@RequestAttribute("userId") Long userId) {
|
||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||
int i = recordService.countDraw(userId);
|
||||
if (drawCount - i > 0) {
|
||||
return new Result().put("data", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
|
||||
} else {
|
||||
return new Result().put("data", 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/app/discSpinning/draw")
|
||||
@ApiOperation("抽取大转盘")
|
||||
public Result draw(Long orderId, @RequestAttribute("userId") Long userId) {
|
||||
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("当日可抽奖次数已超限");
|
||||
}
|
||||
Orders order = ordersService.selectOrderById(orderId);
|
||||
return new Result().put("data", draws(order.getPayMoney().doubleValue(), order.getOrdersId(), userId));
|
||||
Orders orders = ordersService.selectOrdersByDay(userId);
|
||||
if (orders == null) {
|
||||
return Result.error("无可抽奖机会");
|
||||
}
|
||||
return new Result().put("data", draws(orders.getPayMoney().doubleValue(), orders.getOrdersId(), userId));
|
||||
}
|
||||
|
||||
@PostMapping("/app/discSpinning/receive")
|
||||
@@ -145,7 +163,7 @@ public class DiscSpinningController {
|
||||
receive.setTarget("1");
|
||||
//提现
|
||||
withdraw(receive, receive.getUserId(), receive.getNumber().doubleValue());
|
||||
}else {
|
||||
} else {
|
||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||
userMoneyDetails.setClassify(5);
|
||||
userMoneyDetails.setMoney(receive.getNumber());
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.sqx.modules.discSpinning.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -29,6 +30,7 @@ public class DiscSpinningRecordController {
|
||||
return Result.success().put("data", discSpinningRecordService.getById(id));
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectDiscSpinningRecord")
|
||||
@ApiOperation("查询大转盘抽奖记录")
|
||||
public Result selectDiscSpinningRecord(Integer page, Integer limit,@RequestAttribute("userId") Long userId) {
|
||||
|
||||
@@ -36,4 +36,7 @@ public interface OrdersDao extends BaseMapper<Orders> {
|
||||
|
||||
Integer selectOrdersCountStatisticsByYear(Integer flag,String time,Integer status);
|
||||
|
||||
Integer selectOrdersCountStatisticsByDay(Long userId,Integer limit);
|
||||
Orders selectOrdersByDay(Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -49,5 +49,9 @@ public interface OrdersService extends IService<Orders> {
|
||||
|
||||
Integer selectOrdersCountStatisticsByYear(Integer flag,String time,Integer status);
|
||||
|
||||
Integer selectOrdersCountStatisticsByDay(Long userId,Integer limit);
|
||||
|
||||
Orders selectOrdersByDay(Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -549,5 +549,14 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
||||
return baseMapper.selectOrdersCountStatisticsByYear(flag, time, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer selectOrdersCountStatisticsByDay(Long userId,Integer limit) {
|
||||
return baseMapper.selectOrdersCountStatisticsByDay(userId,limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Orders selectOrdersByDay(Long userId) {
|
||||
return baseMapper.selectOrdersByDay(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
|
||||
|
||||
<select id="countDraw" resultType="int">
|
||||
SELECT count(1) FROM `disc_spinning_record` where user_id = 99 and draw_day = DATE_FORMAT(CURDATE(), '%Y-%m-%d');;
|
||||
SELECT count(1) FROM `disc_spinning_record` where user_id = 99 and draw_day = DATE_FORMAT(CURDATE(), '%Y-%m-%d');
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -278,4 +278,35 @@
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectOrdersCountStatisticsByDay" resultType="Integer">
|
||||
SELECT
|
||||
count(*)
|
||||
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 #{limit}
|
||||
</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>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user