分享达标
大转盘 获取次数区分 抽奖 区分 统计 订单数统一接口
This commit is contained in:
@@ -130,34 +130,45 @@ public class DiscSpinningController {
|
|||||||
@ApiResponses({
|
@ApiResponses({
|
||||||
@ApiResponse(code = 200, message = "{\"sum\":\"总抽奖次数\",\"count\":\"剩余抽奖次数\"}"),
|
@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<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
||||||
map.put("sum", drawCount);
|
map.put("sum", drawCount);
|
||||||
int i = recordService.countDraw(userId);
|
if (maps.containsKey("source") && "task".equals(maps.get("source"))) {
|
||||||
if (drawCount - i > 0) {
|
//任务可抽奖次数
|
||||||
map.put("count", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
|
|
||||||
return Result.success(map);
|
|
||||||
} else {
|
} else {
|
||||||
map.put("count", 0);
|
int i = recordService.countDraw(userId);
|
||||||
return Result.success(map);
|
if (drawCount - i > 0) {
|
||||||
|
map.put("count", ordersService.selectOrdersCountStatisticsByDay(userId, drawCount - i));
|
||||||
|
} else {
|
||||||
|
map.put("count", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return Result.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
@GetMapping("/app/discSpinning/draw")
|
@GetMapping("/app/discSpinning/draw")
|
||||||
@ApiOperation("抽取大转盘")
|
@ApiOperation("抽取大转盘")
|
||||||
public Result draw(@RequestAttribute("userId") Long userId) {
|
public Result draw(@RequestAttribute("userId") Long userId, @RequestBody Map maps) {
|
||||||
int drawCount = Integer.parseInt(commonRepository.findOne(901).getValue());
|
double amount = 0;
|
||||||
Integer i = recordService.countDraw(userId);
|
Long orderId = null;
|
||||||
if (i != null && i > drawCount) {
|
if (!maps.containsKey("source") && !"task".equals(maps.get("source"))) {
|
||||||
return Result.error("当日可抽奖次数已超限");
|
//任务抽奖
|
||||||
|
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);
|
return new Result().put("data", draws(amount, orderId, userId));
|
||||||
if (orders == null) {
|
|
||||||
return Result.error("无可抽奖机会");
|
|
||||||
}
|
|
||||||
return new Result().put("data", draws(orders.getPayMoney().doubleValue(), orders.getOrdersId(), userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/app/discSpinning/receive")
|
@PostMapping("/app/discSpinning/receive")
|
||||||
|
|||||||
@@ -14,29 +14,32 @@ public interface OrdersDao extends BaseMapper<Orders> {
|
|||||||
|
|
||||||
int insertOrders(Orders orders);
|
int insertOrders(Orders orders);
|
||||||
|
|
||||||
IPage<Orders> selectOrdersByOrdersNo(Page<Orders> pages, @Param("ordersNo") String ordersNo,@Param("status") Integer status,
|
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("userId") Long userId, @Param("courseId") Long courseId, @Param("flag") Integer flag,
|
||||||
@Param("time") String time, @Param("userName") String userName, @Param("ordersType") Integer ordersType,
|
@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("startTime") String startTime, @Param("endTime") String endTime, @Param("sysUserId") Long sysUserId,
|
||||||
@Param("qdCode") String qdCode,@Param("sysUserName") String sysUserName);
|
@Param("qdCode") String qdCode, @Param("sysUserName") String sysUserName);
|
||||||
|
|
||||||
int deleteOrders(String[] ids);
|
int deleteOrders(String[] ids);
|
||||||
|
|
||||||
Double statisticsIncomeMoney(@Param("time") String time, @Param("flag") Integer flag, @Param("ordersType") Integer ordersType);
|
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);
|
Orders selectOrdersByDay(Long userId);
|
||||||
|
|
||||||
|
Integer countOrderNum(Long userId, String time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,5 +53,13 @@ public interface OrdersService extends IService<Orders> {
|
|||||||
|
|
||||||
Orders selectOrdersByDay(Long userId);
|
Orders selectOrdersByDay(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计 用户成功订单笔数
|
||||||
|
* @param userId
|
||||||
|
* @param time 时间条件 不传为全部订单 格式 yyyy-MM-dd HH:mm:ss
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer countOrderNum(Long userId,String time);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -550,8 +550,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer selectOrdersCountStatisticsByDay(Long userId,Integer limit) {
|
public Integer selectOrdersCountStatisticsByDay(Long userId, Integer limit) {
|
||||||
return baseMapper.selectOrdersCountStatisticsByDay(userId,limit);
|
return baseMapper.selectOrdersCountStatisticsByDay(userId, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -559,4 +559,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
return baseMapper.selectOrdersByDay(userId);
|
return baseMapper.selectOrdersByDay(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer countOrderNum(Long userId, String time) {
|
||||||
|
return baseMapper.countOrderNum(userId, time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.sqx.modules.app.entity.UserMoneyDetails;
|
|||||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||||
import com.sqx.modules.app.service.UserMoneyService;
|
import com.sqx.modules.app.service.UserMoneyService;
|
||||||
import com.sqx.modules.app.service.UserService;
|
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.invite.service.InviteService;
|
||||||
import com.sqx.modules.orders.entity.Orders;
|
import com.sqx.modules.orders.entity.Orders;
|
||||||
import com.sqx.modules.orders.service.OrdersService;
|
import com.sqx.modules.orders.service.OrdersService;
|
||||||
@@ -32,6 +33,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author GYJ
|
* @author GYJ
|
||||||
@@ -48,13 +50,13 @@ public class WuyouController {
|
|||||||
private final InviteService inviteService;
|
private final InviteService inviteService;
|
||||||
private final UserMoneyService userMoneyService;
|
private final UserMoneyService userMoneyService;
|
||||||
private final UserMoneyDetailsService userMoneyDetailsService;
|
private final UserMoneyDetailsService userMoneyDetailsService;
|
||||||
|
private final CommonInfoService commonRepository;
|
||||||
private final CashOutDao cashOutDao;
|
private final CashOutDao cashOutDao;
|
||||||
|
|
||||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, UserService userService, InviteService inviteService, CashOutDao cashOutDao,
|
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.ordersService = ordersService;
|
||||||
this.payDetailsDao = payDetailsDao;
|
this.payDetailsDao = payDetailsDao;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
@@ -62,6 +64,7 @@ public class WuyouController {
|
|||||||
this.cashOutDao = cashOutDao;
|
this.cashOutDao = cashOutDao;
|
||||||
this.userMoneyService = userMoneyService;
|
this.userMoneyService = userMoneyService;
|
||||||
this.userMoneyDetailsService = userMoneyDetailsService;
|
this.userMoneyDetailsService = userMoneyDetailsService;
|
||||||
|
this.commonRepository = commonRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("支付订单")
|
@ApiOperation("支付订单")
|
||||||
@@ -202,7 +205,44 @@ public class WuyouController {
|
|||||||
}
|
}
|
||||||
ordersService.updateById(order);
|
ordersService.updateById(order);
|
||||||
ordersService.insertOrders(order);
|
ordersService.insertOrders(order);
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
activities(user, byUser);
|
||||||
|
});
|
||||||
return "success";
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,18 +295,26 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectOrdersByDay" resultType="com.sqx.modules.orders.entity.Orders">
|
<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
|
SELECT
|
||||||
orders.*
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
orders
|
orders
|
||||||
LEFT JOIN disc_spinning_record record ON orders.orders_id = record.order_id
|
|
||||||
WHERE
|
WHERE
|
||||||
orders.user_id = #{userId}
|
orders.user_id = #{userId}
|
||||||
AND orders.`status` = 1
|
AND orders.`status` = 1
|
||||||
AND orders.create_time > DATE_FORMAT( CURDATE(), '%Y-%m-%d 00:00:00' )
|
<if test="time !=null and time != ''">
|
||||||
AND record.order_id IS NULL
|
and create_time > #{time}
|
||||||
ORDER BY
|
</if>
|
||||||
orders.create_time
|
|
||||||
LIMIT 1
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user