|
|
|
@ -11,6 +11,7 @@ import com.zh.project0512.service.*;
|
|
|
|
|
import com.zh.project0512.utils.ExcelUtil;
|
|
|
|
|
import com.zh.project0512.utils.HttpUtil;
|
|
|
|
|
import com.zh.project0512.utils.MybatisPlusUtil;
|
|
|
|
|
import com.zh.project0512.utils.result.HttpStatusEnum;
|
|
|
|
|
import com.zh.project0512.utils.result.Result;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
@ -18,6 +19,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
@ -137,9 +139,29 @@ public class UserController {
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改积分")
|
|
|
|
|
@PostMapping("/pointsTran")
|
|
|
|
|
@Transactional
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result pointsTran(@Validated @RequestBody PTParam param) {
|
|
|
|
|
UserPointsRecords userPointsRecords = new UserPointsRecords();
|
|
|
|
|
Integer userId = param.getUserId();
|
|
|
|
|
Integer points = param.getPoints();
|
|
|
|
|
Integer settlementMethod = param.getSettlementMethod();
|
|
|
|
|
User user = userService.getById(userId);
|
|
|
|
|
if (null == user) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "未找到用户");
|
|
|
|
|
}
|
|
|
|
|
Integer pointsCur = user.getPoints();
|
|
|
|
|
if (pointsCur < points) {
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "积分不足");
|
|
|
|
|
}
|
|
|
|
|
UpdateWrapper<User> up = new UpdateWrapper<>();
|
|
|
|
|
up.eq("id", userId);
|
|
|
|
|
if (settlementMethod == 1) {
|
|
|
|
|
up.set("points", pointsCur + points).set("historyPoints", user.getHistoryPoints() + points);
|
|
|
|
|
} else if (settlementMethod == 2) {
|
|
|
|
|
up.set("points", pointsCur - points);
|
|
|
|
|
}
|
|
|
|
|
userService.update(up);
|
|
|
|
|
userPointsRecordsService.save(userPointsRecords.setPoints(param.getPoints()).setUserId(param.getUserId()).setSettlementMethod(param.getSettlementMethod()).setRemarks(param.getRemarks()).setCreateDate(LocalDateTime.now()));
|
|
|
|
|
return Result.success(null, "操作完成");
|
|
|
|
|
}
|
|
|
|
|