Java奖励代码_SpringBoot签到奖励实现⽅案的⽰例代码前⾔
性88XXX最近在做社交业务,⽤户进⼊APP后有签到功能,签到成功后获取相应的奖励:
项⽬状况:前期尝试业务阶段;
特点:
快速实现(不需要做太重,满⾜初期推⼴运营即可)
快速投⼊市场去运营
⽤户签到:
⽤户在每次启动时查询签到记录(规则:连续7⽇签到从0开始,签到过程中有断签从0开始)
如果今⽇未签到则提⽰⽤户可以进⾏签到
⽤户签到获取相应的奖励
提到签到,脑海中⾸先浮现特点:
需要记录每位⽤户每天的签到情况
查询时根据规则进⾏签到记录情况
需求&流程设计&技术实现⽅案
需求原型图
查询签到记录
进⾏签到
乳贴怎么用
技术实现⽅案
SpringBoot
MySQL
数据库表结构
签到记录最新表
CREATE TABLE `zh_sign_in` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`bu_no` varchar(32) DEFAULT NULL COMMENT '业务编码',
`customer_id` varchar(32) DEFAULT NULL COMMENT '签到⽤户编码',中省
`sign_in_date` datetime DEFAULT NULL COMMENT '签到⽇期(单位精确到⽇)',
`reward_money` int(11) DEFAULT NULL COMMENT '本次签到奖励⾦币个数',
`continuite_day` int(2) DEFAULT '1' COMMENT '连续签到天数(A:7天内如果有断签从0开始 B:7天签满从0开始)', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
元宵手抄报`param1` int(2) DEFAULT NULL COMMENT '预留字段1',
`param2` int(4) DEFAULT NULL COMMENT '预留字段2',
`param3` int(11) DEFAULT NULL COMMENT '预留字段3',
`param4` varchar(20) DEFAULT NULL COMMENT '预留字段4',
`param5` varchar(32) DEFAULT NULL COMMENT '预留字段5',
`param6` varchar(64) DEFAULT NULL COMMENT '预留字段6',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_zh_sign_in_buno` (`bu_no`),
UNIQUE KEY `uk_zh_sign_in_cid_signindate` (`customer_id`,`sign_in_date`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='⽤户签到表';
签到记录历史表
胡公子
CREATE TABLE `zh_sign_in_hist` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`bu_no` varchar(32) DEFAULT NULL COMMENT '业务编码',
`customer_id` varchar(32) DEFAULT NULL COMMENT '签到⽤户编码',
`sign_in_date` datetime NULL DEFAULT NULL COMMENT '签到⽇期(单位精确到⽇)',
`reward_money` int(11) DEFAULT NULL COMMENT '本次签到奖励⾦币个数',
`continuite_day` int(2) DEFAULT '1' COMMENT '连续签到天数(A:7天内如果有断签从0开始 B:7天签满从0开始)', `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
赛螃蟹做法`update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`param1` int(2) DEFAULT NULL COMMENT '预留字段1',
`param2` int(4) DEFAULT NULL COMMENT '预留字段2',
`param3` int(11) DEFAULT NULL COMMENT '预留字段3',
`param4` varchar(20) DEFAULT NULL COMMENT '预留字段4',
`param5` varchar(32) DEFAULT NULL COMMENT '预留字段5',
`param6` varchar(64) DEFAULT NULL COMMENT '预留字段6',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_zh_sign_in_hist_cid_signindate` (`customer_id`,`sign_in_date`) USING BTREE,
KEY `key_zh_sign_in_hist_buno` (`bu_no`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='⽤户签到历史表';
代码实现
完整代码(GitHub,欢迎⼤家Star,Fork,Watch)
主要代码展⽰
Controller
/
*
* Copyright (c) 2020. zhanghan_ All Rights Rerved.
* 项⽬名称:Spring Boot实战:签到奖励实现⽅案
* 类名称:SignInController.java
* 创建⼈:张晗
* 联系⽅式:zhanghan_
*/
package com.ller;
import com.quest.PostSignInRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
太中大夫
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.quest.ListSignInDetailRequest;
import com.zhanghan.zhsignin.rvice.SignInService;
@RestController
public class SignInController {
@Autowired
private SignInService signInService;
/**
* 查询签到记录英语时间表达法
*/
@RequestMapping(value = "/list/sign/in/detail", method = RequestMethod.POST)
public Object listSignInDetail(@RequestBody @Validated ListSignInDetailRequest listSignInDetailRequest) {
return signInService.listSignInDetail(listSignInDetailRequest);
}
/**
* ⽤户进⾏签到
*/
@RequestMapping(value = "/post/sign/in", method = RequestMethod.POST)
public Object postSignIn(@RequestBody @Validated PostSignInRequest postSignInRequest) { return signInService.postSignIn(postSignInRequest);
}
}
rvice
/*
* Copyright (c) 2020. zhanghan_ All Rights Rerved.
* 项⽬名称:Spring Boot实战:签到奖励实现⽅案
* 类名称:SignInServiceImpl.java
* 创建⼈:张晗
* 联系⽅式:zhanghan_
*/
package com.zhanghan.zhsignin.rvice.impl;
import util.IdUtil;
import com.fig.SignInRewardMoneyListConfig;
import com.stant.SignInConstant;
import com.quest.ListSignInDetailRequest;
import com.quest.PostSignInRequest;
import com.spon.ListSignInDetailRespon;
import com.ity.XZhSignInEntity;
import com.ity.XZhSignInHistEntity;
import com.batis.mapper.XZhSignInHistMapper;
import com.batis.mapper.XZhSignInMapper;
import com.zhanghan.zhsignin.rvice.SignInService;
import com.zhanghan.zhsignin.util.DateUtils;
import com.zhanghan.zhsignin.util.wrapper.WrapMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;