123
This commit is contained in:
@@ -40,6 +40,10 @@ CREATE TABLE `cai_prize_online`
|
|||||||
DEFAULT CHARSET = utf8mb4 COMMENT ='已发布奖品表';
|
DEFAULT CHARSET = utf8mb4 COMMENT ='已发布奖品表';
|
||||||
|
|
||||||
|
|
||||||
|
alter table `cai_point_change_log`
|
||||||
|
ADD COLUMN remark varchar(200) null comment '备注';
|
||||||
|
|
||||||
|
|
||||||
-- 菜单 SQL
|
-- 菜单 SQL
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values(2003344862891581442, '抽奖奖品', '1738072642014617602', '1', 'prizeInfo', 'cai/prizeInfo/index', 1, 0, 'C', '0', '0', 'cai:prizeInfo:list', '#', 'admin', sysdate(), '', null, '抽奖奖品菜单');
|
values(2003344862891581442, '抽奖奖品', '1738072642014617602', '1', 'prizeInfo', 'cai/prizeInfo/index', 1, 0, 'C', '0', '0', 'cai:prizeInfo:list', '#', 'admin', sysdate(), '', null, '抽奖奖品菜单');
|
||||||
@@ -56,3 +60,29 @@ values(2003344862891581445, '抽奖奖品修改', 2003344862891581442, '3', '#'
|
|||||||
|
|
||||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||||
values(2003344862891581446, '抽奖奖品删除', 2003344862891581442, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:prizeInfo:remove', '#', 'admin', sysdate(), '', null, '');
|
values(2003344862891581446, '抽奖奖品删除', 2003344862891581442, '4', '#', '', 1, 0, 'F', '0', '0', 'cai:prizeInfo:remove', '#', 'admin', sysdate(), '', null, '');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `cai_prize_winning_record`
|
||||||
|
(
|
||||||
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '奖品ID',
|
||||||
|
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||||||
|
`use_point` bigint(20) NOT NULL COMMENT '抽奖消耗',
|
||||||
|
`prize_id` bigint NOT NULL COMMENT '奖品ID',
|
||||||
|
`prize_name` varchar(100) NOT NULL COMMENT '奖品名称',
|
||||||
|
`prize_desc` varchar(500) DEFAULT '' COMMENT '奖品描述',
|
||||||
|
`prize_img` varchar(255) DEFAULT '' COMMENT '奖品图片地址',
|
||||||
|
`win_probability` decimal(5, 4) NOT NULL COMMENT '中奖率(0-1,如0.0100表示1%)',
|
||||||
|
`guarantee_draws` int NOT NULL DEFAULT 0 COMMENT '保底抽数(0表示无保底,谢谢惠顾奖无效)',
|
||||||
|
`min_win_draws` int NOT NULL DEFAULT 0 COMMENT '最低中奖抽数(0表示无限制,谢谢惠顾奖无效)',
|
||||||
|
`stock` int NOT NULL DEFAULT 0 COMMENT '奖品库存(谢谢惠顾奖填0,不校验)',
|
||||||
|
`prize_type` tinyint not null comment '奖品类型 1-谢谢惠顾 2-普通奖 3-大奖',
|
||||||
|
`prize_price` bigint(20) not null default 0 comment '奖品价值估算',
|
||||||
|
`auto_give` tinyint not null default 0 comment '是否自动兑奖',
|
||||||
|
`give_status` tinyint not null default 0 comment '奖品兑换情况 0-未兑换 1-已兑换',
|
||||||
|
`give_remark` varchar(100) not null default 0 comment '兑奖备注说明',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4 COMMENT ='中奖记录';
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.ruoyi.web.controller.cai.app;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.cai.domain.PrizeOnline;
|
||||||
|
import com.ruoyi.cai.domain.PrizeWinningRecord;
|
||||||
|
import com.ruoyi.cai.dto.app.draw.resp.*;
|
||||||
|
import com.ruoyi.cai.lottery.DrawService;
|
||||||
|
import com.ruoyi.cai.service.PrizeOnlineService;
|
||||||
|
import com.ruoyi.cai.service.PrizeWinningRecordService;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
|
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/draw")
|
||||||
|
@Tag(name = "抽奖相关接口")
|
||||||
|
public class DrawController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DrawService drawService;
|
||||||
|
@Autowired
|
||||||
|
private PrizeOnlineService prizeOnlineService;
|
||||||
|
@Autowired
|
||||||
|
private PrizeWinningRecordService prizeWinningRecordService;
|
||||||
|
|
||||||
|
@GetMapping("/baseConfig")
|
||||||
|
@Operation(summary = "获取抽奖相关的基础信息")
|
||||||
|
public R<DrawBaseConfigResp> baseConfig(){
|
||||||
|
DrawBaseConfigResp resp = drawService.baseConfig();
|
||||||
|
return R.ok(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/points/logs")
|
||||||
|
@Operation(summary = "获取积分记录")
|
||||||
|
public R<List<PointLogsResp>> pointsLogs(PageQuery page){
|
||||||
|
List<PointLogsResp> resp = drawService.pointsLogs(page);
|
||||||
|
return R.ok(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/winning/record")
|
||||||
|
@Operation(summary = "获取自己的中奖记录")
|
||||||
|
public R<List<UserWinningRecordResp>> winningRecord(PageQuery page){
|
||||||
|
Page<PrizeWinningRecord> page1 = prizeWinningRecordService.page(page.build(), Wrappers.lambdaQuery(PrizeWinningRecord.class)
|
||||||
|
.eq(PrizeWinningRecord::getUserId, LoginHelper.getUserId())
|
||||||
|
.orderByDesc(PrizeWinningRecord::getCreateTime)
|
||||||
|
);
|
||||||
|
List<UserWinningRecordResp> resps = BeanConvertUtil.convertListTo(page1.getRecords(), UserWinningRecordResp::new);
|
||||||
|
return R.ok(resps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/prize/up")
|
||||||
|
@Operation(summary = "获取奖品列表")
|
||||||
|
public R<List<PrizeOnlineResp>> prizeUp(){
|
||||||
|
List<PrizeOnline> prizeOnlines = prizeOnlineService.prizeUp();
|
||||||
|
List<PrizeOnlineResp> resp = BeanConvertUtil.convertListTo(prizeOnlines, PrizeOnlineResp::new);
|
||||||
|
return R.ok(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/winning/center")
|
||||||
|
@Operation(summary = "全局中奖记录")
|
||||||
|
public R<List<CenterWinningRecordResp>> winningCenter(){
|
||||||
|
List<PrizeWinningRecord> list = prizeWinningRecordService.list(Wrappers.lambdaQuery(PrizeWinningRecord.class)
|
||||||
|
.orderByDesc(PrizeWinningRecord::getCreateTime));
|
||||||
|
List<CenterWinningRecordResp> resps = BeanConvertUtil.convertListTo(list, CenterWinningRecordResp::new);
|
||||||
|
resps.forEach(i -> i.setUserName("****"));
|
||||||
|
return R.ok(resps);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/lottery")
|
||||||
|
@Operation(summary = "抽奖接口")
|
||||||
|
public R<Void> lottery(){
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.ruoyi.cai.controller;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.cai.domain.PrizeWinningRecord;
|
||||||
|
import com.ruoyi.cai.service.PrizeWinningRecordService;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.core.validate.AddGroup;
|
||||||
|
import com.ruoyi.common.core.validate.EditGroup;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中奖记录
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-08
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/cai/prizeWinningRecord")
|
||||||
|
public class PrizeWinningRecordController extends BaseController {
|
||||||
|
|
||||||
|
private final PrizeWinningRecordService prizeWinningRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询中奖记录列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("cai:prizeWinningRecord:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<PrizeWinningRecord> list(PrizeWinningRecord bo, PageQuery pageQuery) {
|
||||||
|
Page<PrizeWinningRecord> page = prizeWinningRecordService.page(pageQuery.build(), Wrappers.lambdaQuery(bo));
|
||||||
|
return TableDataInfo.build(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取中奖记录详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("cai:prizeWinningRecord:query")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<PrizeWinningRecord> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long id) {
|
||||||
|
return R.ok(prizeWinningRecordService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增中奖记录
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("cai:prizeWinningRecord:add")
|
||||||
|
@Log(title = "中奖记录", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody PrizeWinningRecord bo) {
|
||||||
|
return toAjax(prizeWinningRecordService.save(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改中奖记录
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("cai:prizeWinningRecord:edit")
|
||||||
|
@Log(title = "中奖记录", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody PrizeWinningRecord bo) {
|
||||||
|
return toAjax(prizeWinningRecordService.updateById(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除中奖记录
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("cai:prizeWinningRecord:remove")
|
||||||
|
@Log(title = "中奖记录", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] ids) {
|
||||||
|
return toAjax(prizeWinningRecordService.removeBatchByIds(Arrays.asList(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,6 +86,7 @@ public class PointChangeLog implements Serializable {
|
|||||||
* 是否兑换
|
* 是否兑换
|
||||||
*/
|
*/
|
||||||
private Integer giveFlag;
|
private Integer giveFlag;
|
||||||
|
private String remark;
|
||||||
/**
|
/**
|
||||||
* 兑换时间
|
* 兑换时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package com.ruoyi.cai.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中奖记录对象 cai_prize_winning_record
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-08
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cai_prize_winning_record")
|
||||||
|
public class PrizeWinningRecord implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 奖品ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 抽奖消耗
|
||||||
|
*/
|
||||||
|
private Long usePoint;
|
||||||
|
/**
|
||||||
|
* 奖品ID
|
||||||
|
*/
|
||||||
|
private Long prizeId;
|
||||||
|
/**
|
||||||
|
* 奖品名称
|
||||||
|
*/
|
||||||
|
private String prizeName;
|
||||||
|
/**
|
||||||
|
* 奖品描述
|
||||||
|
*/
|
||||||
|
private String prizeDesc;
|
||||||
|
/**
|
||||||
|
* 奖品图片地址
|
||||||
|
*/
|
||||||
|
private String prizeImg;
|
||||||
|
/**
|
||||||
|
* 中奖率(0-1,如0.0100表示1%)
|
||||||
|
*/
|
||||||
|
private BigDecimal winProbability;
|
||||||
|
/**
|
||||||
|
* 保底抽数(0表示无保底,谢谢惠顾奖无效)
|
||||||
|
*/
|
||||||
|
private Long guaranteeDraws;
|
||||||
|
/**
|
||||||
|
* 最低中奖抽数(0表示无限制,谢谢惠顾奖无效)
|
||||||
|
*/
|
||||||
|
private Long minWinDraws;
|
||||||
|
/**
|
||||||
|
* 奖品库存(谢谢惠顾奖填0,不校验)
|
||||||
|
*/
|
||||||
|
private Long stock;
|
||||||
|
/**
|
||||||
|
* 奖品类型 1-谢谢惠顾 2-普通奖 3-大奖
|
||||||
|
*/
|
||||||
|
private Integer prizeType;
|
||||||
|
/**
|
||||||
|
* 奖品价值估算
|
||||||
|
*/
|
||||||
|
private Long prizePrice;
|
||||||
|
/**
|
||||||
|
* 是否自动兑奖
|
||||||
|
*/
|
||||||
|
private Boolean autoGive;
|
||||||
|
/**
|
||||||
|
* 奖品兑换情况 0-未兑换 1-已兑换
|
||||||
|
*/
|
||||||
|
private Integer giveStatus;
|
||||||
|
/**
|
||||||
|
* 兑奖备注说明
|
||||||
|
*/
|
||||||
|
private String giveRemark;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.draw.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CenterWinningRecordResp {
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 抽奖消耗
|
||||||
|
*/
|
||||||
|
private Long usePoint;
|
||||||
|
/**
|
||||||
|
* 奖品名称
|
||||||
|
*/
|
||||||
|
private String prizeName;
|
||||||
|
private String prizeDesc;
|
||||||
|
/**
|
||||||
|
* 奖品图片地址
|
||||||
|
*/
|
||||||
|
private String prizeImg;
|
||||||
|
/**
|
||||||
|
* 奖品兑换情况 0-未兑换 1-已兑换
|
||||||
|
*/
|
||||||
|
private Integer giveStatus;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.draw.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DrawBaseConfigResp {
|
||||||
|
private boolean openDraw;
|
||||||
|
private Integer drawPoint;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.draw.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PointLogsResp {
|
||||||
|
// 1-充值 2-系统调整 3-分销 4-抽奖
|
||||||
|
private String actionType;
|
||||||
|
private String message;
|
||||||
|
private String tarImg;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.draw.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PrizeOnlineResp {
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 奖品名称
|
||||||
|
*/
|
||||||
|
private String prizeName;
|
||||||
|
/**
|
||||||
|
* 奖品描述
|
||||||
|
*/
|
||||||
|
private String prizeDesc;
|
||||||
|
/**
|
||||||
|
* 奖品图片地址
|
||||||
|
*/
|
||||||
|
private String prizeImg;
|
||||||
|
/**
|
||||||
|
* 奖品类型 1-谢谢惠顾 2-普通奖 3-大奖
|
||||||
|
*/
|
||||||
|
private Integer prizeType;
|
||||||
|
/**
|
||||||
|
* 奖品价值估算
|
||||||
|
*/
|
||||||
|
private Long prizePrice;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.draw.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserWinningRecordResp {
|
||||||
|
/**
|
||||||
|
* 中奖记录ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 抽奖消耗
|
||||||
|
*/
|
||||||
|
private Long usePoint;
|
||||||
|
/**
|
||||||
|
* 奖品名称
|
||||||
|
*/
|
||||||
|
private String prizeName;
|
||||||
|
private String prizeDesc;
|
||||||
|
/**
|
||||||
|
* 奖品图片地址
|
||||||
|
*/
|
||||||
|
private String prizeImg;
|
||||||
|
/**
|
||||||
|
* 奖品兑换情况 0-未兑换 1-已兑换
|
||||||
|
*/
|
||||||
|
private Integer giveStatus;
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -22,4 +22,6 @@ public class UserAccountVo {
|
|||||||
@Schema(description = "收益的紫贝")
|
@Schema(description = "收益的紫贝")
|
||||||
private Long incomeCoin;
|
private Long incomeCoin;
|
||||||
|
|
||||||
|
private Long points;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.ruoyi.cai.lottery;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.cai.domain.PointChangeLog;
|
||||||
|
import com.ruoyi.cai.dto.app.draw.resp.DrawBaseConfigResp;
|
||||||
|
import com.ruoyi.cai.dto.app.draw.resp.PointLogsResp;
|
||||||
|
import com.ruoyi.cai.dto.commom.user.MinUser;
|
||||||
|
import com.ruoyi.cai.enums.GenderEnum;
|
||||||
|
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||||
|
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||||
|
import com.ruoyi.cai.service.PointChangeLogService;
|
||||||
|
import com.ruoyi.cai.service.UserService;
|
||||||
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
|
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DrawService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemConfigManager systemConfigManager;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@Autowired
|
||||||
|
private PointChangeLogService pointChangeLogService;
|
||||||
|
|
||||||
|
public DrawBaseConfigResp baseConfig() {
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
MinUser minUser = userService.getMinUserById(userId);
|
||||||
|
DrawBaseConfigResp resp = new DrawBaseConfigResp();
|
||||||
|
boolean openDraw = getOpenDraw(minUser.getGender());
|
||||||
|
resp.setOpenDraw(openDraw);
|
||||||
|
Integer drawPoint = this.getDrawPoint(minUser.getGender());
|
||||||
|
resp.setDrawPoint(drawPoint);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getDrawPoint(Integer gender){
|
||||||
|
if(GenderEnum.WOMEN.getCode().equals(gender)){
|
||||||
|
Integer womenDrawPoint = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.WOMEN_DRAW_POINT);
|
||||||
|
return womenDrawPoint;
|
||||||
|
}
|
||||||
|
return systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.MEN_DRAW_POINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean getOpenDraw(Integer gender){
|
||||||
|
if(GenderEnum.WOMEN.getCode().equals(gender)){
|
||||||
|
return systemConfigManager.getSystemConfigOfBool(SystemConfigEnum.OPEN_DRAW_WOMEN);
|
||||||
|
}else if(GenderEnum.MAN.getCode().equals(gender)){
|
||||||
|
return systemConfigManager.getSystemConfigOfBool(SystemConfigEnum.OPEN_DRAW_MAN);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PointLogsResp> pointsLogs(PageQuery pageQuery) {
|
||||||
|
Page<PointChangeLog> page = pointChangeLogService.page(pageQuery.build(), Wrappers.lambdaQuery(PointChangeLog.class)
|
||||||
|
.eq(PointChangeLog::getUserId, LoginHelper.getUserId())
|
||||||
|
.orderByDesc(PointChangeLog::getCreateTime));
|
||||||
|
List<PointChangeLog> records = page.getRecords();
|
||||||
|
List<PointLogsResp> pointLogsResps = BeanConvertUtil.convertListTo(records, PointLogsResp::new);
|
||||||
|
return pointLogsResps;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.ruoyi.cai.domain.PointChangeLog;
|
|||||||
import com.ruoyi.cai.domain.PrizeOnline;
|
import com.ruoyi.cai.domain.PrizeOnline;
|
||||||
import com.ruoyi.cai.domain.User;
|
import com.ruoyi.cai.domain.User;
|
||||||
import com.ruoyi.cai.enums.GenderEnum;
|
import com.ruoyi.cai.enums.GenderEnum;
|
||||||
|
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||||
import com.ruoyi.cai.manager.IdManager;
|
import com.ruoyi.cai.manager.IdManager;
|
||||||
import com.ruoyi.cai.manager.SystemConfigManager;
|
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||||
import com.ruoyi.cai.service.AccountService;
|
import com.ruoyi.cai.service.AccountService;
|
||||||
@@ -52,24 +53,10 @@ public class LotteryService {
|
|||||||
private AccountService accountService;
|
private AccountService accountService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemConfigManager systemConfigManager;
|
private SystemConfigManager systemConfigManager;
|
||||||
|
@Autowired
|
||||||
private Integer getDrawPoint(Integer gender){
|
private PointManager pointManager;
|
||||||
if(GenderEnum.WOMEN.getCode().equals(gender)){
|
@Autowired
|
||||||
Integer womenDrawPoint = systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.WOMEN_DRAW_POINT);
|
private DrawService drawService;
|
||||||
return womenDrawPoint;
|
|
||||||
}
|
|
||||||
return systemConfigManager.getSystemConfigOfInt(SystemConfigEnum.MEN_DRAW_POINT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean getOpenDraw(Integer gender){
|
|
||||||
if(GenderEnum.WOMEN.getCode().equals(gender)){
|
|
||||||
return systemConfigManager.getSystemConfigOfBool(SystemConfigEnum.OPEN_DRAW_WOMEN);
|
|
||||||
}else if(GenderEnum.MAN.getCode().equals(gender)){
|
|
||||||
return systemConfigManager.getSystemConfigOfBool(SystemConfigEnum.OPEN_DRAW_MAN);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户抽奖(核心方法,优化后)
|
* 用户抽奖(核心方法,优化后)
|
||||||
@@ -81,7 +68,7 @@ public class LotteryService {
|
|||||||
if(user == null){
|
if(user == null){
|
||||||
throw new ServiceException("用户不存在");
|
throw new ServiceException("用户不存在");
|
||||||
}
|
}
|
||||||
boolean openDraw = this.getOpenDraw(user.getGender());
|
boolean openDraw = drawService.getOpenDraw(user.getGender());
|
||||||
if(!openDraw){
|
if(!openDraw){
|
||||||
throw new ServiceException("暂未开启积分抽奖,请等待活动通知");
|
throw new ServiceException("暂未开启积分抽奖,请等待活动通知");
|
||||||
}
|
}
|
||||||
@@ -90,7 +77,7 @@ public class LotteryService {
|
|||||||
throw new ServiceException("请选择性别后在抽奖");
|
throw new ServiceException("请选择性别后在抽奖");
|
||||||
}
|
}
|
||||||
Account account = accountService.getByUserId(user.getId());
|
Account account = accountService.getByUserId(user.getId());
|
||||||
Integer drawPoint = getDrawPoint(user.getGender());
|
Integer drawPoint = drawService.getDrawPoint(user.getGender());
|
||||||
if(account.getPoints() < drawPoint){
|
if(account.getPoints() < drawPoint){
|
||||||
throw new ServiceException("积分不足");
|
throw new ServiceException("积分不足");
|
||||||
}
|
}
|
||||||
@@ -264,7 +251,7 @@ public class LotteryService {
|
|||||||
public void winPrizeAfter(PrizeOnline prizeOnline, User user,Integer drawPoint, int continuousDraws) {
|
public void winPrizeAfter(PrizeOnline prizeOnline, User user,Integer drawPoint, int continuousDraws) {
|
||||||
// 扣减积分
|
// 扣减积分
|
||||||
String traceId = IdManager.nextIdStr();
|
String traceId = IdManager.nextIdStr();
|
||||||
PointChangeLog pointChangeLog = accountService.drawPoint(prizeOnline, user, drawPoint, traceId);
|
PointChangeLog pointChangeLog = pointManager.drawPoint(prizeOnline, user, drawPoint, traceId);
|
||||||
// 记录用户抽奖记录
|
// 记录用户抽奖记录
|
||||||
// UserDrawRecord record = new UserDrawRecord();
|
// UserDrawRecord record = new UserDrawRecord();
|
||||||
// record.setUserId(userId);
|
// record.setUserId(userId);
|
||||||
|
|||||||
207
ruoyi-cai/src/main/java/com/ruoyi/cai/lottery/PointManager.java
Normal file
207
ruoyi-cai/src/main/java/com/ruoyi/cai/lottery/PointManager.java
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
package com.ruoyi.cai.lottery;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.domain.*;
|
||||||
|
import com.ruoyi.cai.enums.SystemConfigEnum;
|
||||||
|
import com.ruoyi.cai.enums.point.PointChangeLogActionTypeEnum;
|
||||||
|
import com.ruoyi.cai.enums.point.PointChangeTraceTypeEnum;
|
||||||
|
import com.ruoyi.cai.manager.SystemConfigManager;
|
||||||
|
import com.ruoyi.cai.mapper.AccountMapper;
|
||||||
|
import com.ruoyi.cai.service.PointChangeLogService;
|
||||||
|
import com.ruoyi.cai.service.PointRecordLogService;
|
||||||
|
import com.ruoyi.cai.service.UserService;
|
||||||
|
import com.ruoyi.cai.ws.constant.RedisConstant;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.ServletUtils;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.redisson.api.RAtomicLong;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class PointManager {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemConfigManager systemConfigManager;
|
||||||
|
@Autowired
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
@Resource
|
||||||
|
private AccountMapper accountMapper;
|
||||||
|
@Autowired
|
||||||
|
private PointChangeLogService pointChangeLogService;
|
||||||
|
@Autowired
|
||||||
|
private PointRecordLogService pointRecordLogService;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
public String getRedisKey(Long userId){
|
||||||
|
LocalDate date = LocalDate.now();
|
||||||
|
String dateStr = date.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||||
|
return String.format(RedisConstant.POINT_DAYS_USER, dateStr, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class CheckPointIncr{
|
||||||
|
private boolean allowPoint;
|
||||||
|
private Long givePoint;
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckPointIncr checkPointIncr(Long userId,Long givePoint){
|
||||||
|
CheckPointIncr result = new CheckPointIncr();
|
||||||
|
Long maxPointDays = systemConfigManager.getSystemConfigOfLong(SystemConfigEnum.MAX_POINT_DAY);
|
||||||
|
if(maxPointDays == null || maxPointDays <= 0){ // 未开启
|
||||||
|
result.setAllowPoint(true);
|
||||||
|
result.setGivePoint(givePoint);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
String redisKey = getRedisKey(userId);
|
||||||
|
RAtomicLong atomicLong = redissonClient.getAtomicLong(redisKey);
|
||||||
|
Long userDaysPoint = atomicLong.get();
|
||||||
|
if(userDaysPoint >= maxPointDays){ // 今日获取积分已超过每日最大积分
|
||||||
|
result.setAllowPoint(false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if(givePoint + userDaysPoint >= maxPointDays) { // 算上这次已经超过每日最大积分
|
||||||
|
Long currentGivePoint = maxPointDays - userDaysPoint;
|
||||||
|
String remark = String.format("实际需赠送%s,今日已超过上限%s,只需赠送%s", givePoint,maxPointDays,currentGivePoint);
|
||||||
|
result.setAllowPoint(true);
|
||||||
|
result.setGivePoint(currentGivePoint);
|
||||||
|
result.setRemark(remark);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result.setAllowPoint(true);
|
||||||
|
result.setGivePoint(givePoint);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void adminChange(Long userId, Long givePoint){
|
||||||
|
accountMapper.incrPoint(userId, givePoint);
|
||||||
|
User user = userService.getById(userId);
|
||||||
|
PointChangeLog pointChangeLog = new PointChangeLog();
|
||||||
|
pointChangeLog.setUserId(userId);
|
||||||
|
pointChangeLog.setUsercode(user.getUsercode());
|
||||||
|
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.SYSTEM.getCode());
|
||||||
|
String message = String.format("系统调整:%s%s积分", givePoint > 0 ? "新增" : "减少", givePoint);
|
||||||
|
pointChangeLog.setMessage(message);
|
||||||
|
pointChangeLog.setChangeValue(givePoint);
|
||||||
|
pointChangeLog.setIsAdmin(true);
|
||||||
|
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.SYSTEM.getCode());
|
||||||
|
pointChangeLogService.save(pointChangeLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void adminInvite(Long userId, Long givePoint, Long inviteUserId, String traceId){
|
||||||
|
CheckPointIncr checkPointIncr = this.checkPointIncr(userId, givePoint);
|
||||||
|
if(checkPointIncr.isAllowPoint()){
|
||||||
|
User user = userService.getById(userId);
|
||||||
|
User inviteUser = userService.getById(inviteUserId);
|
||||||
|
PointChangeLog pointChangeLog = new PointChangeLog();
|
||||||
|
pointChangeLog.setUserId(userId);
|
||||||
|
pointChangeLog.setUsercode(user.getUsercode());
|
||||||
|
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.SYSTEM.getCode());
|
||||||
|
String message = String.format("从【%s】的充值中获得%s积分", inviteUser.getNickname(), givePoint);
|
||||||
|
pointChangeLog.setMessage(message);
|
||||||
|
pointChangeLog.setTarUserId(inviteUser.getId());
|
||||||
|
pointChangeLog.setTarUsercode(inviteUser.getUsercode());
|
||||||
|
pointChangeLog.setTarName(inviteUser.getNickname());
|
||||||
|
pointChangeLog.setTarImg(inviteUser.getAvatar());
|
||||||
|
pointChangeLog.setChangeValue(givePoint);
|
||||||
|
pointChangeLog.setIsAdmin(true);
|
||||||
|
pointChangeLog.setRemark(checkPointIncr.getRemark());
|
||||||
|
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.INVITE.getCode());
|
||||||
|
pointChangeLog.setTraceId(traceId);
|
||||||
|
pointChangeLogService.save(pointChangeLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public PointRecordLog rechargePoint(RechargeOrder rechargeOrder, User user){
|
||||||
|
if(rechargeOrder.getGivePoint() == null || rechargeOrder.getGivePoint() == 0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
log.info("开始赠送积分 orderNo={}", rechargeOrder.getOrderNo());
|
||||||
|
CheckPointIncr checkPointIncr = this.checkPointIncr(user.getId(), rechargeOrder.getGivePoint());
|
||||||
|
if(!checkPointIncr.isAllowPoint()){ // 不参与分销
|
||||||
|
PointRecordLog pointRecordLog = pointRecordLogService.initOrder(rechargeOrder, user);
|
||||||
|
return pointRecordLog;
|
||||||
|
}
|
||||||
|
accountMapper.incrPoint(user.getId(), checkPointIncr.getGivePoint());
|
||||||
|
PointChangeLog pointChangeLog = new PointChangeLog();
|
||||||
|
pointChangeLog.setUserId(user.getId());
|
||||||
|
pointChangeLog.setUsercode(user.getUsercode());
|
||||||
|
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.PAY.getCode());
|
||||||
|
pointChangeLog.setMessage("充值赠送"+checkPointIncr.getGivePoint()+"积分");
|
||||||
|
pointChangeLog.setChangeValue(checkPointIncr.getGivePoint());
|
||||||
|
pointChangeLog.setIsAdmin(false);
|
||||||
|
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.PAY.getCode());
|
||||||
|
pointChangeLog.setTraceId(rechargeOrder.getOrderNo());
|
||||||
|
pointChangeLogService.save(pointChangeLog);
|
||||||
|
PointRecordLog pointRecordLog = pointRecordLogService.initOrder(rechargeOrder, user);
|
||||||
|
String redisKey = getRedisKey(user.getId());
|
||||||
|
RAtomicLong atomicLong = redissonClient.getAtomicLong(redisKey);
|
||||||
|
atomicLong.addAndGet(checkPointIncr.getGivePoint());
|
||||||
|
return pointRecordLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单分销分成
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void rechargeOrderInviteChange(Long userId, Long givePoint, Long inviteUserId, String traceId){
|
||||||
|
CheckPointIncr checkPointIncr = this.checkPointIncr(userId, givePoint);
|
||||||
|
if(checkPointIncr.isAllowPoint()){ // 参与积分
|
||||||
|
User user = userService.getById(userId);
|
||||||
|
User inviteUser = userService.getById(inviteUserId);
|
||||||
|
PointChangeLog pointChangeLog = new PointChangeLog();
|
||||||
|
pointChangeLog.setUserId(userId);
|
||||||
|
pointChangeLog.setUsercode(user.getUsercode());
|
||||||
|
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.INVITE.getCode());
|
||||||
|
String message = String.format("从【%s】中充值分成新增%s积分", inviteUser.getNickname(), givePoint);
|
||||||
|
pointChangeLog.setMessage(message);
|
||||||
|
pointChangeLog.setTarUserId(inviteUser.getId());
|
||||||
|
pointChangeLog.setTarUsercode(inviteUser.getUsercode());
|
||||||
|
pointChangeLog.setTarName(inviteUser.getNickname());
|
||||||
|
pointChangeLog.setTarImg(inviteUser.getAvatar());
|
||||||
|
pointChangeLog.setChangeValue(givePoint);
|
||||||
|
pointChangeLog.setRemark(checkPointIncr.getRemark());
|
||||||
|
pointChangeLog.setIsAdmin(false);
|
||||||
|
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.INVITE.getCode());
|
||||||
|
pointChangeLog.setTraceId(traceId);
|
||||||
|
pointChangeLogService.save(pointChangeLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public PointChangeLog drawPoint(PrizeOnline prizeOnline, User user, Integer drawPoint, String traceId){
|
||||||
|
boolean bb = accountMapper.decrPoint(user.getId(), Long.valueOf(drawPoint));
|
||||||
|
if(!bb){
|
||||||
|
throw new ServiceException("积分不足");
|
||||||
|
}
|
||||||
|
PointChangeLog pointChangeLog = new PointChangeLog();
|
||||||
|
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.USE.getCode());
|
||||||
|
pointChangeLog.setUserId(user.getId());
|
||||||
|
pointChangeLog.setUsercode(user.getUsercode());
|
||||||
|
String message = String.format("抽中【%s】", prizeOnline.getPrizeName());
|
||||||
|
pointChangeLog.setMessage(message);
|
||||||
|
pointChangeLog.setChangeValue(Long.valueOf(drawPoint));
|
||||||
|
pointChangeLog.setOperateIp(ServletUtils.getClientIP());
|
||||||
|
pointChangeLog.setIsAdmin(false);
|
||||||
|
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.USE.getCode());
|
||||||
|
pointChangeLog.setTraceId(traceId);
|
||||||
|
pointChangeLogService.save(pointChangeLog);
|
||||||
|
return pointChangeLog;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.cai.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.ruoyi.cai.domain.PrizeWinningRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中奖记录Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-08
|
||||||
|
*/
|
||||||
|
public interface PrizeWinningRecordMapper extends BaseMapper<PrizeWinningRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,10 @@ package com.ruoyi.cai.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.cai.domain.*;
|
import com.ruoyi.cai.domain.Account;
|
||||||
|
import com.ruoyi.cai.domain.ConsumeLog;
|
||||||
|
import com.ruoyi.cai.domain.Gift;
|
||||||
|
import com.ruoyi.cai.domain.User;
|
||||||
import com.ruoyi.cai.dto.admin.vo.AccountAdminVo;
|
import com.ruoyi.cai.dto.admin.vo.AccountAdminVo;
|
||||||
import com.ruoyi.cai.dto.video.VideoSettleResp;
|
import com.ruoyi.cai.dto.video.VideoSettleResp;
|
||||||
import com.ruoyi.cai.dto.video.WithholdingFeeUserResp;
|
import com.ruoyi.cai.dto.video.WithholdingFeeUserResp;
|
||||||
@@ -10,7 +13,6 @@ import com.ruoyi.cai.enums.ConsumeLogType;
|
|||||||
import com.ruoyi.cai.enums.account.AccountChangeCodeEnum;
|
import com.ruoyi.cai.enums.account.AccountChangeCodeEnum;
|
||||||
import com.ruoyi.cai.ws.bean.Room;
|
import com.ruoyi.cai.ws.bean.Room;
|
||||||
import com.ruoyi.common.core.domain.PageQuery;
|
import com.ruoyi.common.core.domain.PageQuery;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账户Service接口
|
* 用户账户Service接口
|
||||||
@@ -32,11 +34,6 @@ public interface AccountService extends IService<Account> {
|
|||||||
|
|
||||||
void withdrawFail(Long userId, Long incomeCoin, Long traceId);
|
void withdrawFail(Long userId, Long incomeCoin, Long traceId);
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
PointChangeLog drawPoint(PrizeOnline prizeOnline, User user, Integer drawPoint, String traceId);
|
|
||||||
|
|
||||||
PointRecordLog rechargePoint(RechargeOrder rechargeOrder, User user);
|
|
||||||
|
|
||||||
void recharge(ConsumeLog consumeLog);
|
void recharge(ConsumeLog consumeLog);
|
||||||
|
|
||||||
void rechargeAdminIgnoreAccount(ConsumeLog consumeLog);
|
void rechargeAdminIgnoreAccount(ConsumeLog consumeLog);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.ruoyi.cai.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.cai.domain.PointChangeLog;
|
import com.ruoyi.cai.domain.PointChangeLog;
|
||||||
import com.ruoyi.cai.domain.PrizeOnline;
|
|
||||||
import com.ruoyi.cai.domain.User;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分记录Service接口
|
* 积分记录Service接口
|
||||||
@@ -13,13 +11,4 @@ import com.ruoyi.cai.domain.User;
|
|||||||
*/
|
*/
|
||||||
public interface PointChangeLogService extends IService<PointChangeLog> {
|
public interface PointChangeLogService extends IService<PointChangeLog> {
|
||||||
|
|
||||||
void rechargeOrderChange(String orderNo, Long userId, Long givePoint);
|
|
||||||
|
|
||||||
void rechargeOrderInviteChange(Long userId, Long givePoint, Long inviteUserId, String traceId);
|
|
||||||
|
|
||||||
void adminChange(Long userId, Long givePoint);
|
|
||||||
|
|
||||||
void adminInvite(Long userId, Long givePoint, Long inviteUserId, String traceId);
|
|
||||||
|
|
||||||
PointChangeLog drawPoint(PrizeOnline prizeOnline, User user, Integer drawPoint, String traceId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,7 @@ public interface PrizeOnlineService extends IService<PrizeOnline> {
|
|||||||
List<PrizeOnline> selectPrizeOnlineList(Integer gender);
|
List<PrizeOnline> selectPrizeOnlineList(Integer gender);
|
||||||
|
|
||||||
void reset(Integer gender, List<PrizeOnline> bo);
|
void reset(Integer gender, List<PrizeOnline> bo);
|
||||||
|
|
||||||
|
List<PrizeOnline> prizeUp();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.cai.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.cai.domain.PrizeWinningRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中奖记录Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-08
|
||||||
|
*/
|
||||||
|
public interface PrizeWinningRecordService extends IService<PrizeWinningRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -217,34 +217,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
accountChangeLogService.saveLogNoAdmin(user.getId(),user.getUsercode(), AccountChangeCodeEnum.WITHDRAW_FAIL,incomeCoin,traceId);
|
accountChangeLogService.saveLogNoAdmin(user.getId(),user.getUsercode(), AccountChangeCodeEnum.WITHDRAW_FAIL,incomeCoin,traceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PointRecordLogService pointRecordLogService;
|
|
||||||
@Autowired
|
|
||||||
private PointChangeLogService pointChangeLogService;
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public PointChangeLog drawPoint(PrizeOnline prizeOnline, User user, Integer drawPoint, String traceId){
|
|
||||||
boolean bb = baseMapper.decrPoint(user.getId(), Long.valueOf(drawPoint));
|
|
||||||
if(!bb){
|
|
||||||
throw new ServiceException("积分不足");
|
|
||||||
}
|
|
||||||
PointChangeLog pointChangeLog = pointChangeLogService.drawPoint(prizeOnline, user, drawPoint, traceId);
|
|
||||||
return pointChangeLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public PointRecordLog rechargePoint(RechargeOrder rechargeOrder, User user){
|
|
||||||
if(rechargeOrder.getGivePoint() == null || rechargeOrder.getGivePoint() == 0){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
log.info("开始赠送积分 orderNo={}", rechargeOrder.getOrderNo());
|
|
||||||
baseMapper.incrPoint(rechargeOrder.getUserId(), rechargeOrder.getGivePoint());
|
|
||||||
pointChangeLogService.rechargeOrderChange(rechargeOrder.getOrderNo(), rechargeOrder.getUserId(),rechargeOrder.getGivePoint());
|
|
||||||
PointRecordLog pointRecordLog = pointRecordLogService.initOrder(rechargeOrder, user);
|
|
||||||
return pointRecordLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|||||||
@@ -23,105 +23,6 @@ import javax.annotation.Resource;
|
|||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-12-10
|
* @date 2025-12-10
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Service
|
@Service
|
||||||
public class PointChangeLogServiceImpl extends ServiceImpl<PointChangeLogMapper,PointChangeLog> implements PointChangeLogService {
|
public class PointChangeLogServiceImpl extends ServiceImpl<PointChangeLogMapper,PointChangeLog> implements PointChangeLogService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
@Resource
|
|
||||||
private AccountMapper accountMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rechargeOrderChange(String orderNo, Long userId, Long givePoint){
|
|
||||||
accountMapper.incrPoint(userId, givePoint);
|
|
||||||
User user = userService.getById(userId);
|
|
||||||
PointChangeLog pointChangeLog = new PointChangeLog();
|
|
||||||
pointChangeLog.setUserId(userId);
|
|
||||||
pointChangeLog.setUsercode(user.getUsercode());
|
|
||||||
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.PAY.getCode());
|
|
||||||
pointChangeLog.setMessage("充值赠送"+givePoint+"积分");
|
|
||||||
pointChangeLog.setChangeValue(givePoint);
|
|
||||||
pointChangeLog.setIsAdmin(false);
|
|
||||||
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.PAY.getCode());
|
|
||||||
pointChangeLog.setTraceId(orderNo);
|
|
||||||
this.save(pointChangeLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rechargeOrderInviteChange(Long userId, Long givePoint, Long inviteUserId, String traceId){
|
|
||||||
accountMapper.incrPoint(userId, givePoint);
|
|
||||||
User user = userService.getById(userId);
|
|
||||||
User inviteUser = userService.getById(inviteUserId);
|
|
||||||
PointChangeLog pointChangeLog = new PointChangeLog();
|
|
||||||
pointChangeLog.setUserId(userId);
|
|
||||||
pointChangeLog.setUsercode(user.getUsercode());
|
|
||||||
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.INVITE.getCode());
|
|
||||||
String message = String.format("从【%s】中充值分成新增%s积分", inviteUser.getNickname(), givePoint);
|
|
||||||
pointChangeLog.setMessage(message);
|
|
||||||
pointChangeLog.setTarUserId(inviteUser.getId());
|
|
||||||
pointChangeLog.setTarUsercode(inviteUser.getUsercode());
|
|
||||||
pointChangeLog.setTarName(inviteUser.getNickname());
|
|
||||||
pointChangeLog.setTarImg(inviteUser.getAvatar());
|
|
||||||
pointChangeLog.setChangeValue(givePoint);
|
|
||||||
pointChangeLog.setIsAdmin(false);
|
|
||||||
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.INVITE.getCode());
|
|
||||||
pointChangeLog.setTraceId(traceId);
|
|
||||||
this.save(pointChangeLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adminChange(Long userId, Long givePoint){
|
|
||||||
accountMapper.incrPoint(userId, givePoint);
|
|
||||||
User user = userService.getById(userId);
|
|
||||||
PointChangeLog pointChangeLog = new PointChangeLog();
|
|
||||||
pointChangeLog.setUserId(userId);
|
|
||||||
pointChangeLog.setUsercode(user.getUsercode());
|
|
||||||
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.SYSTEM.getCode());
|
|
||||||
String message = String.format("系统调整:%s%s积分", givePoint > 0 ? "新增" : "减少", givePoint);
|
|
||||||
pointChangeLog.setMessage(message);
|
|
||||||
pointChangeLog.setChangeValue(givePoint);
|
|
||||||
pointChangeLog.setIsAdmin(true);
|
|
||||||
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.SYSTEM.getCode());
|
|
||||||
this.save(pointChangeLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adminInvite(Long userId, Long givePoint, Long inviteUserId, String traceId){
|
|
||||||
accountMapper.incrPoint(userId, givePoint);
|
|
||||||
User user = userService.getById(userId);
|
|
||||||
User inviteUser = userService.getById(inviteUserId);
|
|
||||||
PointChangeLog pointChangeLog = new PointChangeLog();
|
|
||||||
pointChangeLog.setUserId(userId);
|
|
||||||
pointChangeLog.setUsercode(user.getUsercode());
|
|
||||||
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.SYSTEM.getCode());
|
|
||||||
String message = String.format("从【%s】的充值中获得%s积分", inviteUser.getNickname(), givePoint);
|
|
||||||
pointChangeLog.setMessage(message);
|
|
||||||
pointChangeLog.setTarUserId(inviteUser.getId());
|
|
||||||
pointChangeLog.setTarUsercode(inviteUser.getUsercode());
|
|
||||||
pointChangeLog.setTarName(inviteUser.getNickname());
|
|
||||||
pointChangeLog.setTarImg(inviteUser.getAvatar());
|
|
||||||
pointChangeLog.setChangeValue(givePoint);
|
|
||||||
pointChangeLog.setIsAdmin(true);
|
|
||||||
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.INVITE.getCode());
|
|
||||||
pointChangeLog.setTraceId(traceId);
|
|
||||||
this.save(pointChangeLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PointChangeLog drawPoint(PrizeOnline prizeOnline, User user, Integer drawPoint, String traceId) {
|
|
||||||
PointChangeLog pointChangeLog = new PointChangeLog();
|
|
||||||
pointChangeLog.setActionType(PointChangeLogActionTypeEnum.USE.getCode());
|
|
||||||
pointChangeLog.setUserId(user.getId());
|
|
||||||
pointChangeLog.setUsercode(user.getUsercode());
|
|
||||||
String message = String.format("抽中【%s】", prizeOnline.getPrizeName());
|
|
||||||
pointChangeLog.setMessage(message);
|
|
||||||
pointChangeLog.setChangeValue(Long.valueOf(drawPoint));
|
|
||||||
pointChangeLog.setOperateIp(ServletUtils.getClientIP());
|
|
||||||
pointChangeLog.setIsAdmin(false);
|
|
||||||
pointChangeLog.setTraceLinkType(PointChangeTraceTypeEnum.USE.getCode());
|
|
||||||
pointChangeLog.setTraceId(traceId);
|
|
||||||
this.save(pointChangeLog);
|
|
||||||
return pointChangeLog;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.ruoyi.cai.domain.*;
|
|||||||
import com.ruoyi.cai.dto.AddPointAdminDto;
|
import com.ruoyi.cai.dto.AddPointAdminDto;
|
||||||
import com.ruoyi.cai.enums.ConsumeLogStatus;
|
import com.ruoyi.cai.enums.ConsumeLogStatus;
|
||||||
import com.ruoyi.cai.enums.PointLogType;
|
import com.ruoyi.cai.enums.PointLogType;
|
||||||
|
import com.ruoyi.cai.lottery.PointManager;
|
||||||
import com.ruoyi.cai.manager.IdManager;
|
import com.ruoyi.cai.manager.IdManager;
|
||||||
import com.ruoyi.cai.mapper.AccountMapper;
|
import com.ruoyi.cai.mapper.AccountMapper;
|
||||||
import com.ruoyi.cai.mapper.PointRecordLogMapper;
|
import com.ruoyi.cai.mapper.PointRecordLogMapper;
|
||||||
@@ -39,6 +40,8 @@ public class PointRecordLogServiceImpl extends ServiceImpl<PointRecordLogMapper,
|
|||||||
private AccountMapper accountMapper;
|
private AccountMapper accountMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PointChangeLogService pointChangeLogService;
|
private PointChangeLogService pointChangeLogService;
|
||||||
|
@Autowired
|
||||||
|
private PointManager pointManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -53,7 +56,7 @@ public class PointRecordLogServiceImpl extends ServiceImpl<PointRecordLogMapper,
|
|||||||
throw new ServiceException("开启分销情况下,无法调整积分为负数");
|
throw new ServiceException("开启分销情况下,无法调整积分为负数");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pointChangeLogService.adminChange(user.getId(),dto.getChangePoints());
|
pointManager.adminChange(user.getId(),dto.getChangePoints());
|
||||||
PointRecordLog pointLog = new PointRecordLog();
|
PointRecordLog pointLog = new PointRecordLog();
|
||||||
pointLog.setPoints(dto.getChangePoints());
|
pointLog.setPoints(dto.getChangePoints());
|
||||||
pointLog.setSourceUserId(user.getId());
|
pointLog.setSourceUserId(user.getId());
|
||||||
@@ -76,7 +79,7 @@ public class PointRecordLogServiceImpl extends ServiceImpl<PointRecordLogMapper,
|
|||||||
pointLog.setStatus(ConsumeLogStatus.ALREADY.getCode());
|
pointLog.setStatus(ConsumeLogStatus.ALREADY.getCode());
|
||||||
if(pointLog.getOnePoints() >= 0 && pointLog.getOneUserId() != null && pointLog.getOneJoin()){
|
if(pointLog.getOnePoints() >= 0 && pointLog.getOneUserId() != null && pointLog.getOneJoin()){
|
||||||
String traceId = IdManager.nextIdStr();
|
String traceId = IdManager.nextIdStr();
|
||||||
pointChangeLogService.adminInvite(pointLog.getOneUserId(),pointLog.getOnePoints(),pointLog.getSourceUserId(),traceId);
|
pointManager.adminInvite(pointLog.getOneUserId(),pointLog.getOnePoints(),pointLog.getSourceUserId(),traceId);
|
||||||
pointLog.setTraceId(traceId);
|
pointLog.setTraceId(traceId);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -141,8 +144,9 @@ public class PointRecordLogServiceImpl extends ServiceImpl<PointRecordLogMapper,
|
|||||||
if(!pointRecordLog.getOneJoin()){
|
if(!pointRecordLog.getOneJoin()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pointChangeLogService.rechargeOrderInviteChange(pointRecordLog.getOneUserId(),pointRecordLog.getOnePoints(),pointRecordLog.getSourceUserId(),traceId);
|
pointManager.rechargeOrderInviteChange(pointRecordLog.getOneUserId(),pointRecordLog.getOnePoints(),pointRecordLog.getSourceUserId(),traceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ package com.ruoyi.cai.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.cai.domain.PrizeOnline;
|
import com.ruoyi.cai.domain.PrizeOnline;
|
||||||
|
import com.ruoyi.cai.dto.commom.user.MinUser;
|
||||||
|
import com.ruoyi.cai.enums.GenderEnum;
|
||||||
import com.ruoyi.cai.enums.prize.PrizeTypeEnum;
|
import com.ruoyi.cai.enums.prize.PrizeTypeEnum;
|
||||||
import com.ruoyi.cai.mapper.PrizeOnlineMapper;
|
import com.ruoyi.cai.mapper.PrizeOnlineMapper;
|
||||||
import com.ruoyi.cai.service.PrizeOnlineService;
|
import com.ruoyi.cai.service.PrizeOnlineService;
|
||||||
|
import com.ruoyi.cai.service.UserService;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -25,6 +30,9 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
public class PrizeOnlineServiceImpl extends ServiceImpl<PrizeOnlineMapper,PrizeOnline> implements PrizeOnlineService {
|
public class PrizeOnlineServiceImpl extends ServiceImpl<PrizeOnlineMapper,PrizeOnline> implements PrizeOnlineService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PrizeOnline> selectPrizeOnlineList(Integer gender){
|
public List<PrizeOnline> selectPrizeOnlineList(Integer gender){
|
||||||
return this.list(Wrappers.lambdaQuery(PrizeOnline.class).eq(PrizeOnline::getGender, gender));
|
return this.list(Wrappers.lambdaQuery(PrizeOnline.class).eq(PrizeOnline::getGender, gender));
|
||||||
@@ -63,4 +71,16 @@ public class PrizeOnlineServiceImpl extends ServiceImpl<PrizeOnlineMapper,PrizeO
|
|||||||
this.removeByIds(dbIds);
|
this.removeByIds(dbIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PrizeOnline> prizeUp() {
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
MinUser minUser = userService.getMinUserById(userId);
|
||||||
|
GenderEnum genderEnum = GenderEnum.getByCode(minUser.getGender());
|
||||||
|
if(genderEnum == null || genderEnum == GenderEnum.NONE){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<PrizeOnline> prizeOnlines = this.selectPrizeOnlineList(genderEnum.getCode());
|
||||||
|
return prizeOnlines;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.cai.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.cai.domain.PrizeWinningRecord;
|
||||||
|
import com.ruoyi.cai.mapper.PrizeWinningRecordMapper;
|
||||||
|
import com.ruoyi.cai.service.PrizeWinningRecordService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中奖记录Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-08
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PrizeWinningRecordServiceImpl extends ServiceImpl<PrizeWinningRecordMapper,PrizeWinningRecord> implements PrizeWinningRecordService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import com.ruoyi.cai.dto.commom.consumer.RechargeConsumerResp;
|
|||||||
import com.ruoyi.cai.enums.ConsumeLogType;
|
import com.ruoyi.cai.enums.ConsumeLogType;
|
||||||
import com.ruoyi.cai.enums.account.AccountChangeCodeEnum;
|
import com.ruoyi.cai.enums.account.AccountChangeCodeEnum;
|
||||||
import com.ruoyi.cai.enums.account.AccountTypeEnum;
|
import com.ruoyi.cai.enums.account.AccountTypeEnum;
|
||||||
|
import com.ruoyi.cai.lottery.PointManager;
|
||||||
import com.ruoyi.cai.manager.IdManager;
|
import com.ruoyi.cai.manager.IdManager;
|
||||||
import com.ruoyi.cai.mapper.AccountMapper;
|
import com.ruoyi.cai.mapper.AccountMapper;
|
||||||
import com.ruoyi.cai.mapper.RechargeOrderMapper;
|
import com.ruoyi.cai.mapper.RechargeOrderMapper;
|
||||||
@@ -55,6 +56,8 @@ public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper,Re
|
|||||||
private AccountMapper accountMapper;
|
private AccountMapper accountMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AccountChangeLogService accountChangeLogService;
|
private AccountChangeLogService accountChangeLogService;
|
||||||
|
@Autowired
|
||||||
|
private PointManager pointManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RechargeOrder getByOrderNo(String orderNo){
|
public RechargeOrder getByOrderNo(String orderNo){
|
||||||
@@ -127,7 +130,7 @@ public class RechargeOrderServiceImpl extends ServiceImpl<RechargeOrderMapper,Re
|
|||||||
consumeLog.setType(ConsumeLogType.RECHARGE.getCode());
|
consumeLog.setType(ConsumeLogType.RECHARGE.getCode());
|
||||||
consumeLog.setAmount(rechargeOrder.getRechargeCoin());
|
consumeLog.setAmount(rechargeOrder.getRechargeCoin());
|
||||||
accountService.recharge(consumeLog);
|
accountService.recharge(consumeLog);
|
||||||
PointRecordLog pointRecordLog = accountService.rechargePoint(rechargeOrder, user); // 处理充值积分
|
PointRecordLog pointRecordLog = pointManager.rechargePoint(rechargeOrder, user); // 处理充值积分
|
||||||
RechargeConsumerResp resp = new RechargeConsumerResp();
|
RechargeConsumerResp resp = new RechargeConsumerResp();
|
||||||
resp.setSuccess(true);
|
resp.setSuccess(true);
|
||||||
resp.setConsumeLogId(consumeLog.getId());
|
resp.setConsumeLogId(consumeLog.getId());
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ public class RedisConstant {
|
|||||||
public static final String INIT_ROOM_LOCK = REDIS_P + "lock:initRoom:%s-%s";
|
public static final String INIT_ROOM_LOCK = REDIS_P + "lock:initRoom:%s-%s";
|
||||||
public static final String Y4X_REDIS_CACHE = REDIS_P + "shareUrl:y4x:%s";
|
public static final String Y4X_REDIS_CACHE = REDIS_P + "shareUrl:y4x:%s";
|
||||||
public static final String START_SEND_MESSAGE_CACHE = REDIS_P + "starSendMessage:%s";
|
public static final String START_SEND_MESSAGE_CACHE = REDIS_P + "starSendMessage:%s";
|
||||||
|
public static final String POINT_DAYS_USER = REDIS_P + "pointDaysUser:%s:%s";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?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.ruoyi.cai.mapper.PrizeWinningRecordMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.cai.domain.PrizeWinningRecord" id="PrizeWinningRecordResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="userId" column="user_id"/>
|
||||||
|
<result property="usePoint" column="use_point"/>
|
||||||
|
<result property="prizeId" column="prize_id"/>
|
||||||
|
<result property="prizeName" column="prize_name"/>
|
||||||
|
<result property="prizeDesc" column="prize_desc"/>
|
||||||
|
<result property="prizeImg" column="prize_img"/>
|
||||||
|
<result property="winProbability" column="win_probability"/>
|
||||||
|
<result property="guaranteeDraws" column="guarantee_draws"/>
|
||||||
|
<result property="minWinDraws" column="min_win_draws"/>
|
||||||
|
<result property="stock" column="stock"/>
|
||||||
|
<result property="prizeType" column="prize_type"/>
|
||||||
|
<result property="prizePrice" column="prize_price"/>
|
||||||
|
<result property="autoGive" column="auto_give"/>
|
||||||
|
<result property="giveStatus" column="give_status"/>
|
||||||
|
<result property="giveRemark" column="give_remark"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user