记得上下班打卡 | git大法好,push需谨慎

Commit e0f80058 authored by 姜秀龙's avatar 姜秀龙

积分过期脚本

parent 46a09ccb
......@@ -18,6 +18,6 @@ import java.util.List;
*/
public interface StoneScoreLogsMapper extends BaseMapper<StoneScoreLogs> {
List<StoneInvalidDto> getInvalidScore(@Param("st") LocalDate st, @Param("et") LocalDate et,@Param("strTime") String strTime);
List<StoneInvalidDto> getInvalidScore(@Param("et") LocalDate et);
}
......@@ -8,11 +8,17 @@
</resultMap>
<select id="getInvalidScore" resultMap="StoneScoreListDtoResult">
SELECT uid,sum(score) as 'invalid_score' from stone_score_logs
WHERE
(created_at <![CDATA[>=]]> #{st} and created_at <![CDATA[<]]> #{et})
OR
content = #{strTime}
SELECT uid,
(
SUM(CASE WHEN score > 0 AND overdue_at <![CDATA[<=]]> #{et} THEN score ELSE 0 END)
+
SUM(CASE WHEN score <![CDATA[<]]> 0 THEN score ELSE 0 END)
) as 'invalid_score'
from stone_score_logs
<where>
AND 1 = 1
-- AND uid = '3955717574002769928338009'
</where>
GROUP BY uid
HAVING invalid_score <![CDATA[>]]> 0
ORDER BY uid
......
......@@ -29,10 +29,11 @@ public class InnerController {
@PostMapping("refreshScore")
@ApiOperation("积分过期")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "time", value = "格式[2022-12-01]", example = "2022-12-01"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "time", value = "格式[2025-12-27]", example = "2025-12-27"),
})
public void refreshScore(@RequestParam("time") String time) {
data.refreshScore(time);
public ResponseDto<Boolean> refreshScore(@RequestParam("time") String time) {
boolean res = data.refreshScore(time);
return ResponseDto.success(res);
}
}
......@@ -21,7 +21,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@Service
@Slf4j
public class StoneServerImpl {
......@@ -38,30 +37,31 @@ public class StoneServerImpl {
@Autowired
TempScoreMapper tempScoreMapper;
public boolean refreshScore(String time) {
//获取需要跑积分的用户
// 获取需要跑积分的用户
LocalDate et = LocalDate.parse(time);
LocalDate st = et.minusYears(1);
int year = et.getYear();
String strTime = year + "年积分过期";
List<StoneInvalidDto> logsList = stoneScoreLogsMapper.getInvalidScore(st, et, strTime);
List<StoneInvalidDto> logsList = stoneScoreLogsMapper.getInvalidScore(et);
for (StoneInvalidDto logs : logsList) {
stoneIntegralClient.de2111(logs.getUid(), new BigDecimal(logs.getInvalidScore() + "").intValue(), strTime);
stoneIntegralClient.de2111(logs.getUid(), logs.getInvalidScore(), strTime);
}
return true;
}
public boolean initScore(String uid) {
try {
TempScore dataBean = tempScoreMapper.selectOne(Wrappers.lambdaQuery(TempScore.class).eq(TempScore::getUid, uid));
TempScore dataBean = tempScoreMapper
.selectOne(Wrappers.lambdaQuery(TempScore.class).eq(TempScore::getUid, uid));
int score = dataBean.getPriceCost().intValue();
int isLog = stoneScoreLogsMapper.selectCount(Wrappers.lambdaQuery(StoneScoreLogs.class).eq(StoneScoreLogs::getUid, uid).eq(StoneScoreLogs::getContent, "历史积分"));
int isLog = stoneScoreLogsMapper.selectCount(Wrappers.lambdaQuery(StoneScoreLogs.class)
.eq(StoneScoreLogs::getUid, uid).eq(StoneScoreLogs::getContent, "历史积分"));
if (isLog > 0) {
return true;
}
//创建 用户积分数据
int isExists = stoneScoreUserMapper.selectCount(Wrappers.lambdaQuery(StoneScoreUser.class).eq(StoneScoreUser::getUid, uid));
// 创建 用户积分数据
int isExists = stoneScoreUserMapper
.selectCount(Wrappers.lambdaQuery(StoneScoreUser.class).eq(StoneScoreUser::getUid, uid));
if (isExists <= 0) {
StoneScoreUser data = StoneScoreUser.getNew();
data.setStatus(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment