提交 2262ace3 作者: 张小凤

UserPoints(update)

上级 9ca3605e
package com.mmc.iuav.user.model.dto.userpoints;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author small
* @Date 2023/8/5 16:33
* @Version 1.0
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class UserPointsDTO {
@ApiModelProperty(value = "积分id", example = "1")
private Integer id;
@ApiModelProperty(value = "微信昵称", example = "张三")
private String nickName;
@ApiModelProperty(value = "手机号", example = "189213123312")
private String phoneNum;
@ApiModelProperty(value = "用户id", example = "1")
private Integer userAccountId;
@ApiModelProperty(value = "积分总额", example = "3")
private Integer totalPoints;
@ApiModelProperty(value = "创建时间", example = "2023-08-05 16:25:02")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "2023-08-05 16:25:02")
private Date updateTime;
}
package com.mmc.iuav.user.model.dto.userpoints;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author small
* @Date 2023/8/7 11:23
* @Version 1.0
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class UserPointsDetailsDTO {
@ApiModelProperty(value = "id不能为空", example = "1")
private Integer id;
@ApiModelProperty(value = "用户id", example = "1")
private Integer userAccountId;
@ApiModelProperty(value = "积分", example = "1")
private Integer point;
@ApiModelProperty(value = "积分来源", example = "1")
private String pointSource;
@ApiModelProperty(value = "积分发放时间", example = "1")
private Date timeOfRelease;
@ApiModelProperty(value = "创建时间", example = "2023-08-05 16:25:02")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "2023-08-05 16:25:02")
private Date updateTime;
@ApiModelProperty(value = "微信昵称", example = "张三")
private String nickName;
@ApiModelProperty(value = "手机号", example = "189893132")
private String phoneNum;
}
package com.mmc.iuav.user.model.qo.userpoints;
import com.mmc.iuav.group.Freeze;
import com.mmc.iuav.group.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/8/7 13:51
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AppPointsDetailsQO {
@ApiModelProperty(value = "当前页", required = true, example = "1")
@NotNull(message = "当前页不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "页大小", required = true, example = "10")
@NotNull(message = "页大小不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
@ApiModelProperty(value = "用户id", example = "26", hidden = true)
private Integer userAccountId;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.iuav.user.model.qo.userpoints;
import com.mmc.iuav.group.Freeze;
import com.mmc.iuav.group.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/8/5 16:40
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserPointQO {
@ApiModelProperty(value = "当前页", required = true, example = "1")
@NotNull(message = "当前页不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "页大小", required = true, example = "10")
@NotNull(message = "页大小不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
@ApiModelProperty(value = "手机号", example = "189213123312")
private String phoneNum;
@ApiModelProperty(value = "微信昵称", example = "张三")
private String nickName;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.iuav.user.model.qo.userpoints;
import com.mmc.iuav.group.Freeze;
import com.mmc.iuav.group.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/8/7 13:45
* @Version 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserPointsDetailsQO {
@ApiModelProperty(value = "当前页", required = true, example = "1")
@NotNull(message = "当前页不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "页大小", required = true, example = "10")
@NotNull(message = "页大小不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
@ApiModelProperty(value = "用户id", example = "26", required = true)
private Integer userAccountId;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
......@@ -71,4 +71,6 @@ public class UserAccountVO implements Serializable {
private Integer realNameAuthStatus;
@ApiModelProperty(value = "飞手审核 0审核中 1审核通过 2审核不通过 null不是飞手")
private Integer auditStatus;
@ApiModelProperty(value = "总积分 null表示无积分")
private Integer totalPoints;
}
package com.mmc.iuav.user.model.vo.userpoints;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author small
* @Date 2023/8/5 15:15
* @Version 1.0
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserPointsVO {
@ApiModelProperty(value = "id不能为空", example = "1")
private Integer id;
@ApiModelProperty(value = "用户id", example = "1")
private Integer userAccountId;
@ApiModelProperty(value = "积分总额", example = "10")
private Integer totalPoints;
public UserPointsVO(Integer userAccountId, Integer totalPoints) {
this.userAccountId = userAccountId;
this.totalPoints = totalPoints;
}
}
package com.mmc.iuav.user.controller.userpoints;
import com.mmc.iuav.group.Page;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.controller.BaseController;
import com.mmc.iuav.user.model.dto.dronepilot.PilotCertificationDTO;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDTO;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDetailsDTO;
import com.mmc.iuav.user.model.qo.userpoints.AppPointsDetailsQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
import com.mmc.iuav.user.service.userpoints.UserPointsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @Author small
* @Date 2023/8/5 16:28
* @Version 1.0
*/
@Api(tags = "积分")
@RequestMapping("/userPoint")
@RestController
public class UserPointsController extends BaseController {
@Autowired
private UserPointsService userPointsService;
@ApiOperation(value = "后台管理——积分列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = PilotCertificationDTO.class)})
@PostMapping("/userPointList")
public ResultBody<UserPointsDTO> userPointList(HttpServletRequest request,
@Validated(value = {Page.class}) @ApiParam(value = "积分查询", required = true) @RequestBody UserPointQO param) {
return ResultBody.success(userPointsService.userPointList(param));
}
@ApiOperation(value = "后台管理——积分详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = PilotCertificationDTO.class)})
@PostMapping("/detailPoint")
public ResultBody<UserPointsDetailsDTO> detailPoint(HttpServletRequest request,
@Validated(value = {Page.class}) @ApiParam(value = "积分查询", required = true) @RequestBody UserPointsDetailsQO param) {
return ResultBody.success(userPointsService.detailPoint(param));
}
@ApiOperation(value = "小程序用户——积分详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = PilotCertificationDTO.class)})
@PostMapping("/appDetailPoint")
public ResultBody<UserPointsDetailsDTO> appDetailPoint(HttpServletRequest request, @Validated(value = {Page.class}) @ApiParam(value = "积分查询", required = true) @RequestBody AppPointsDetailsQO param) {
return ResultBody.success(userPointsService.appDetailPoint(this.getUserLoginInfoFromRedis(request).getUserAccountId(), param));
}
}
package com.mmc.iuav.user.controller.userpoints.config;
/**
* @Author small
* @Date 2023/8/5 16:20
* @Version 1.0
*/
public enum NumberOfUserPoints {
//注册
REGISTER(0, 5),
//实名认证
REAL_NAME_AUTHENTICATION(1, 10),
//飞手认证
PILOT_CERTIFICATION(2, 20);
private int code;
private int message;
private NumberOfUserPoints(int code, int message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public int getMessage() {
return message;
}
public void setMessage(int message) {
this.message = message;
}
public static NumberOfUserPoints match(int key) {
NumberOfUserPoints result = null;
for (NumberOfUserPoints s : values()) {
if (s.getCode() == key) {
result = s;
break;
}
}
return result;
}
}
package com.mmc.iuav.user.controller.userpoints.config;
/**
* @Author small
* @Date 2023/8/5 11:14
* @Version 1.0
*/
public enum UserPointsEnum {
REGISTER(0, "注册"),
REAL_NAME_AUTHENTICATION(1, "实名认证"),
PILOT_CERTIFICATION(2, "飞手认证");
private int code;
private String message;
private UserPointsEnum(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static UserPointsEnum match(int key) {
UserPointsEnum result = null;
for (UserPointsEnum s : values()) {
if (s.getCode() == key) {
result = s;
break;
}
}
return result;
}
}
package com.mmc.iuav.user.dao.userpoints;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointQO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author small
* @Date 2023/8/5 13:20
* @Version 1.0
*/
@Mapper
public interface UserPointsDao {
UserPointsDO selectUserPoints(Integer id);
void updatePoints(UserPointsDO userPointsDO);
void insertPoints(UserPointsDO userPointsDO);
List<UserPointsDO> userPointList(UserPointQO param);
int count(UserPointQO param);
}
package com.mmc.iuav.user.dao.userpoints;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails;
import com.mmc.iuav.user.model.qo.userpoints.AppPointsDetailsQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author small
* @Date 2023/8/5 13:21
* @Version 1.0
*/
@Mapper
public interface UserPointsDetailsDao {
void insertPointsDetails(UserPointsDetails userPointsDetails);
List<UserPointsDetails> detailPoint(UserPointsDetailsQO param);
int detailPointCount(UserPointsDetailsQO param);
List<UserPointsDetails> appDetailPoint(AppPointsDetailsQO param);
int appDetailPointCount(AppPointsDetailsQO param);
}
......@@ -75,6 +75,8 @@ public class UserAccountDO implements Serializable {
*/
private Integer auditStatus;
private Integer totalPoints;
public UserAccountDO(UserAccountVO userAccountVO) {
this.id = userAccountVO.getId();
this.phoneNum = userAccountVO.getPhoneNum();
......@@ -110,6 +112,7 @@ public class UserAccountDO implements Serializable {
.leader(this.leader)
.realNameAuthStatus(this.realNameAuthStatus)
.auditStatus(this.auditStatus)
.totalPoints(this.totalPoints)
.build();
}
......
package com.mmc.iuav.user.entity.userpoints;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDTO;
import com.mmc.iuav.user.model.vo.userpoints.UserPointsVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author small
* @Date 2023/8/5 13:14
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserPointsDO {
@ApiModelProperty(value = "id不能为空", example = "1")
private Integer id;
@ApiModelProperty(value = "用户id", example = "1")
private Integer userAccountId;
@ApiModelProperty(value = "积分总额", example = "10")
private Integer totalPoints;
@ApiModelProperty(value = "创建时间", example = "2023-08-05 16:25:02")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "2023-08-05 16:25:02")
private Date updateTime;
@ApiModelProperty(value = "微信昵称", example = "张三")
private String nickName;
@ApiModelProperty(value = "手机号", example = "189231321")
private String phoneNum;
public UserPointsDO(UserPointsVO userPointsVO) {
this.id = userPointsVO.getId();
this.userAccountId = userPointsVO.getUserAccountId();
this.totalPoints = userPointsVO.getTotalPoints();
}
public UserPointsDTO buildUserPointsDTO() {
return UserPointsDTO.builder()
.id(this.id)
.userAccountId(this.userAccountId)
.totalPoints(this.totalPoints)
.createTime(this.createTime)
.updateTime(this.updateTime)
.nickName(this.nickName)
.phoneNum(this.phoneNum)
.build();
}
}
package com.mmc.iuav.user.entity.userpoints;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDetailsDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @Author small
* @Date 2023/8/5 13:18
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserPointsDetails {
@ApiModelProperty(value = "id不能为空", example = "1")
private Integer id;
@ApiModelProperty(value = "用户id", example = "1")
private Integer userAccountId;
@ApiModelProperty(value = "积分", example = "5")
private Integer point;
@ApiModelProperty(value = "积分来源", example = "注册")
private String pointSource;
@ApiModelProperty(value = "积分发放时间", example = "2023-08-05 16:25:02")
private Date timeOfRelease;
@ApiModelProperty(value = "创建时间", example = "2023-08-05 16:25:02")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "2023-08-05 16:25:02")
private Date updateTime;
@ApiModelProperty(value = "微信昵称", example = "张三")
private String nickName;
@ApiModelProperty(value = "手机号", example = "189893132")
private String phoneNum;
public UserPointsDetails(Integer userAccountId, Integer point, String message) {
this.userAccountId = userAccountId;
this.point = point;
this.pointSource = message;
}
public UserPointsDetailsDTO buildPoint() {
return UserPointsDetailsDTO.builder()
.id(this.id)
.userAccountId(this.userAccountId)
.point(this.point)
.pointSource(this.pointSource)
.timeOfRelease(this.timeOfRelease)
.createTime(this.createTime)
.updateTime(this.updateTime)
.nickName(this.nickName)
.phoneNum(this.phoneNum)
.build();
}
}
......@@ -7,10 +7,16 @@ import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.constant.UserSystemConstant;
import com.mmc.iuav.user.constant.WxConstant;
import com.mmc.iuav.user.controller.userpoints.config.NumberOfUserPoints;
import com.mmc.iuav.user.controller.userpoints.config.UserPointsEnum;
import com.mmc.iuav.user.controller.wx.*;
import com.mmc.iuav.user.dao.dronepilot.PilotCertificationDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.dronepilot.*;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.dto.dronepilot.PilotAbilityDTO;
import com.mmc.iuav.user.model.dto.dronepilot.PilotCertificationDTO;
......@@ -22,6 +28,7 @@ import com.mmc.iuav.user.model.qo.dronepilot.PilotCertificationQO;
import com.mmc.iuav.user.model.qo.dronepilot.PilotRemarkQO;
import com.mmc.iuav.user.model.vo.dronepilot.PilotAbilityVO;
import com.mmc.iuav.user.model.vo.dronepilot.PilotCertificationVO;
import com.mmc.iuav.user.model.vo.userpoints.UserPointsVO;
import com.mmc.iuav.user.service.dronepilot.PilotCertificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
......@@ -50,6 +57,12 @@ public class PilotCertificationServiceImpl implements PilotCertificationService
@Autowired
private UserSystemConstant userSystemConstant;
@Autowired
private UserPointsDao userPointsDao;
@Autowired
private UserPointsDetailsDao userPointsDetailsDao;
@Override
public ResultBody insertPilot(PilotCertificationVO certificationVO, LoginSuccessDTO userLoginInfoFromRedis) {
......@@ -70,9 +83,31 @@ public class PilotCertificationServiceImpl implements PilotCertificationService
certificationDao.insertAbility(pilotAbility);
PilotCertificationLogDO pilotCertificationLog = new PilotCertificationLogDO(pilotCertificationDO, CertificationMessage.match(0));
certificationDao.insertPilotLog(pilotCertificationLog);
//积分
extracted(pilotCertificationDO.getUserAccountId());
return ResultBody.success();
}
private void extracted(Integer id) {
UserPointsVO userPointsVO = new UserPointsVO(id, NumberOfUserPoints.match(2).getMessage());
//积分
UserPointsDO pointsDO = userPointsDao.selectUserPoints(userPointsVO.getUserAccountId());
UserPointsDO points = null;
if (pointsDO != null) {
Integer totalPoints = userPointsVO.getTotalPoints();
Integer totalPoints1 = pointsDO.getTotalPoints();
totalPoints += totalPoints1;
userPointsVO.setTotalPoints(totalPoints);
points = new UserPointsDO(userPointsVO);
userPointsDao.updatePoints(points);
} else if (pointsDO == null) {
points = new UserPointsDO(userPointsVO);
userPointsDao.insertPoints(points);
}
UserPointsDetails userPointsDetails = new UserPointsDetails(id, NumberOfUserPoints.match(2).getMessage(), UserPointsEnum.match(2).getMessage());
userPointsDetailsDao.insertPointsDetails(userPointsDetails);
}
@Override
public ResultBody<PilotAbilityDTO> abilityList() {
List<PilotAbilityDO> abilityDOList = certificationDao.abilityList();
......
......@@ -4,12 +4,19 @@ import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.controller.userpoints.config.NumberOfUserPoints;
import com.mmc.iuav.user.controller.userpoints.config.UserPointsEnum;
import com.mmc.iuav.user.dao.RealNameAuthDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao;
import com.mmc.iuav.user.entity.RealNameAuthDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails;
import com.mmc.iuav.user.model.dto.RealNameAuthDTO;
import com.mmc.iuav.user.model.dto.RealNameAuthDetailDTO;
import com.mmc.iuav.user.model.qo.RealNameAuthQO;
import com.mmc.iuav.user.model.vo.RealNameAuthVO;
import com.mmc.iuav.user.model.vo.userpoints.UserPointsVO;
import com.mmc.iuav.user.service.RealNameAuthService;
import com.mmc.iuav.user.util.RealNameAuthUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -31,6 +38,12 @@ public class RealNameAuthServiceImpl implements RealNameAuthService {
@Autowired
private RealNameAuthDao realNameAuthDao;
@Autowired
private UserPointsDao userPointsDao;
@Autowired
private UserPointsDetailsDao userPointsDetailsDao;
@Override
public ResultBody add(RealNameAuthVO realNameAuthVO) {
RealNameAuthDO realNameAuthDO0 = realNameAuthDao.getRealNameAuthByUId(realNameAuthVO.getUserAccountId());
......@@ -108,12 +121,36 @@ public class RealNameAuthServiceImpl implements RealNameAuthService {
realNameAuthDO.setId(beforeRealNameAuthDO.getId());
realNameAuthDao.updateRealNameAuth(realNameAuthDO);
}
//积分 todo
extracted(realNameAuthDO.getUserAccountId());
return ResultBody.success();
} else {
return ResultBody.error(ResultEnum.PHOTO_FORMAT_ERROR);
}
}
private void extracted(Integer id) {
UserPointsVO userPointsVO = new UserPointsVO(id, NumberOfUserPoints.match(1).getMessage());
//积分
UserPointsDO pointsDO = userPointsDao.selectUserPoints(userPointsVO.getUserAccountId());
UserPointsDO points = null;
if (pointsDO != null) {
Integer totalPoints = userPointsVO.getTotalPoints();
Integer totalPoints1 = pointsDO.getTotalPoints();
totalPoints += totalPoints1;
userPointsVO.setTotalPoints(totalPoints);
points = new UserPointsDO(userPointsVO);
userPointsDao.updatePoints(points);
} else if (pointsDO == null) {
points = new UserPointsDO(userPointsVO);
userPointsDao.insertPoints(points);
}
UserPointsDetails userPointsDetails = new UserPointsDetails(id, NumberOfUserPoints.match(1).getMessage(), UserPointsEnum.match(1).getMessage());
userPointsDetailsDao.insertPointsDetails(userPointsDetails);
}
@Override
public ResultBody<RealNameAuthDetailDTO> detail(Integer id) {
RealNameAuthDO realNameAuthDO = realNameAuthDao.getRealNameAuthById(id);
......
......@@ -4,11 +4,17 @@ import com.mmc.iuav.general.CodeUtil;
import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.controller.userpoints.config.NumberOfUserPoints;
import com.mmc.iuav.user.controller.userpoints.config.UserPointsEnum;
import com.mmc.iuav.user.dao.CooperationDao;
import com.mmc.iuav.user.dao.UserServiceDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao;
import com.mmc.iuav.user.entity.CooperationTagDO;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.entity.UserRcdDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails;
import com.mmc.iuav.user.model.dto.LoginSuccessDTO;
import com.mmc.iuav.user.model.dto.RealNameAuthDTO;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
......@@ -18,6 +24,7 @@ import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.TopInviteVO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.model.vo.userpoints.UserPointsVO;
import com.mmc.iuav.user.mq.MqProducer;
import com.mmc.iuav.user.service.CompanyAuthService;
import com.mmc.iuav.user.service.RealNameAuthService;
......@@ -58,6 +65,13 @@ public class UserAccountServiceImpl implements UserAccountService {
@Autowired
private MqProducer mqProducer;
@Autowired
private UserPointsDao userPointsDao;
@Autowired
private UserPointsDetailsDao userPointsDetailsDao;
@Override
public UserAccountVO getUserAccountInfoByUnionId(String unionId) {
UserAccountDO userAccountDO = userServiceDao.getUserAccountInfoByUnionId(unionId);
......@@ -178,9 +192,36 @@ public class UserAccountServiceImpl implements UserAccountService {
userRcd.setRcdUserId(rcdUserId);
userServiceDao.insertUserRcd(userRcd);
}
/**
* 积分
*/
extracted(id);
return ResultBody.success();
}
private void extracted(Integer id) {
UserPointsVO userPointsVO = new UserPointsVO(id, NumberOfUserPoints.match(0).getMessage());
//积分
UserPointsDO pointsDO = userPointsDao.selectUserPoints(userPointsVO.getUserAccountId());
UserPointsDO points = null;
if (pointsDO != null) {
Integer totalPoints = userPointsVO.getTotalPoints();
Integer totalPoints1 = pointsDO.getTotalPoints();
totalPoints += totalPoints1;
userPointsVO.setTotalPoints(totalPoints);
points = new UserPointsDO(userPointsVO);
userPointsDao.updatePoints(points);
} else if (pointsDO == null) {
points = new UserPointsDO(userPointsVO);
userPointsDao.insertPoints(points);
}
UserPointsDetails userPointsDetails = new UserPointsDetails(id, NumberOfUserPoints.match(0).getMessage(), UserPointsEnum.match(0).getMessage());
userPointsDetailsDao.insertPointsDetails(userPointsDetails);
}
@Override
public List<UserAccountSimpleDTO> feignListUserAccountByIds(List<Integer> ids) {
List<UserAccountDO> userAccountDOS = userServiceDao.listUserAccountByIds(ids);
......
package com.mmc.iuav.user.service.userpoints;
import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.user.model.qo.userpoints.AppPointsDetailsQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
/**
* @Author small
* @Date 2023/8/5 16:31
* @Version 1.0
*/
public interface UserPointsService {
PageResult userPointList(UserPointQO param);
PageResult detailPoint(UserPointsDetailsQO param);
PageResult appDetailPoint(Integer userAccountId, AppPointsDetailsQO param);
}
package com.mmc.iuav.user.service.userpoints.impl;
import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.user.dao.userpoints.UserPointsDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDTO;
import com.mmc.iuav.user.model.dto.userpoints.UserPointsDetailsDTO;
import com.mmc.iuav.user.model.qo.userpoints.AppPointsDetailsQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
import com.mmc.iuav.user.service.userpoints.UserPointsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author small
* @Date 2023/8/5 16:31
* @Version 1.0
*/
@Service
public class UserPointsServiceImpl implements UserPointsService {
@Autowired
private UserPointsDao userPointsDao;
@Autowired
private UserPointsDetailsDao userPointsDetailsDao;
@Override
public PageResult userPointList(UserPointQO param) {
int count = userPointsDao.count(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<UserPointsDO> userPointList = userPointsDao.userPointList(param);
List<UserPointsDTO> collect = userPointList.stream().map(UserPointsDO::buildUserPointsDTO).collect(Collectors.toList());
return PageResult.buildPage(pageNo, param.getPageSize(), count, collect);
}
@Override
public PageResult detailPoint(UserPointsDetailsQO param) {
int count = userPointsDetailsDao.detailPointCount(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<UserPointsDetails> userPointsDetails = userPointsDetailsDao.detailPoint(param);
List<UserPointsDetailsDTO> collect = userPointsDetails.stream().map(UserPointsDetails::buildPoint).collect(Collectors.toList());
return PageResult.buildPage(pageNo, param.getPageSize(), count, collect);
}
@Override
public PageResult appDetailPoint(Integer userAccountId, AppPointsDetailsQO param) {
param.setUserAccountId(userAccountId);
int count = userPointsDetailsDao.appDetailPointCount(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<UserPointsDetails> userPointsDetails = userPointsDetailsDao.appDetailPoint(param);
List<UserPointsDetailsDTO> collect = userPointsDetails.stream().map(UserPointsDetails::buildPoint).collect(Collectors.toList());
return PageResult.buildPage(pageNo, param.getPageSize(), count, collect);
}
}
......@@ -139,10 +139,12 @@
ua.`DISABLE`,
ua.create_time,
ua.update_time,
pc.audit_status
pc.audit_status,
up.total_points
FROM user_account ua
LEFT JOIN pilot_certification pc ON pc.user_account_id = ua.id
WHERE ua.id = #{id}
LEFT JOIN user_points up ON up.user_account_id = ua.id
WHERE ua.id = ua.id = #{id}
</select>
<select id="listUserAccountIdsByDistrictCode" resultType="java.lang.Integer">
......
<?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.mmc.iuav.user.dao.userpoints.UserPointsDao">
<resultMap id="pointList" type="com.mmc.iuav.user.entity.userpoints.UserPointsDO">
<result property="id" column="id"/>
<result property="userAccountId" column="user_account_id"/>
<result property="totalPoints" column="total_points"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="nickName" column="nick_name"/>
<result property="phoneNum" column="phone_num"/>
</resultMap>
<select id="selectUserPoints" resultType="com.mmc.iuav.user.entity.userpoints.UserPointsDO">
select id, user_account_id, total_points
from user_points
where user_account_id = #{id}
</select>
<update id="updatePoints" parameterType="com.mmc.iuav.user.entity.userpoints.UserPointsDO">
UPDATE user_points
<set>
total_points = #{totalPoints},
update_time=NOW()
</set>
where user_account_id = #{userAccountId}
</update>
<insert id="insertPoints" parameterType="com.mmc.iuav.user.entity.userpoints.UserPointsDO">
insert into user_points(total_points, user_account_id, create_time,
update_time)
values (#{totalPoints}, #{userAccountId}, NOW(), NOW())
</insert>
<select id="userPointList" resultMap="pointList" parameterType="com.mmc.iuav.user.model.qo.userpoints.UserPointQO">
SELECT up.id,
up.user_account_id,
up.total_points,
up.create_time,
up.update_time,
ua.nick_name,
ua.phone_num
FROM user_points up
INNER JOIN user_account ua ON up.user_account_id = ua.id
WHERE ua.`disable` = 0
<if test=" phoneNum != null and phoneNum != '' ">
and ua.phone_num like CONCAT("%",#{phoneNum},"%")
</if>
<if test=" nickName != null and nickName != '' ">
and ua.nick_name like CONCAT("%",#{nickName},"%")
</if>
order by up.create_time desc
limit #{pageNo}, #{pageSize}
</select>
<select id="count" resultType="java.lang.Integer">
SELECT count(*)
FROM user_points up
INNER JOIN user_account ua ON up.user_account_id = ua.id
WHERE ua.`disable` = 0
<if test=" phoneNum != null and phoneNum != '' ">
and ua.phone_num like CONCAT("%",#{phoneNum},"%")
</if>
<if test=" nickName != null and nickName != '' ">
and ua.nick_name like CONCAT("%",#{nickName},"%")
</if>
</select>
</mapper>
<?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.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao">
<resultMap id="detailPointList" type="com.mmc.iuav.user.entity.userpoints.UserPointsDetails">
<result property="id" column="id"/>
<result property="userAccountId" column="user_account_id"/>
<result property="point" column="point"/>
<result property="pointSource" column="point_source"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="timeOfRelease" column="time_of_release"/>
<result property="nickName" column="nick_name"/>
<result property="phoneNum" column="phone_num"/>
</resultMap>
<insert id="insertPointsDetails" parameterType="com.mmc.iuav.user.entity.userpoints.UserPointsDetails">
insert into user_points_details(point, user_account_id, create_time,
update_time, point_source, time_of_release)
values (#{point}, #{userAccountId}, NOW(), NOW(), #{pointSource}, NOW())
</insert>
<select id="detailPoint" resultMap="detailPointList">
SELECT upd.id,
upd.user_account_id,
upd.point,
upd.point_source,
upd.create_time,
upd.update_time,
upd.time_of_release,
ua.nick_name,
ua.phone_num
FROM user_points_details upd
INNER JOIN user_account ua ON upd.user_account_id = ua.id
WHERE ua.`disable` = 0
AND upd.user_account_id = #{userAccountId}
order by upd.create_time desc
limit #{pageNo}, #{pageSize}
</select>
<select id="detailPointCount" resultType="java.lang.Integer">
SELECT count(*)
FROM user_points_details upd
INNER JOIN user_account ua ON upd.user_account_id = ua.id
WHERE ua.`disable` = 0
AND upd.user_account_id = #{userAccountId}
</select>
<select id="appDetailPoint" resultMap="detailPointList">
SELECT upd.id,
upd.user_account_id,
upd.point,
upd.point_source,
upd.create_time,
upd.update_time,
upd.time_of_release,
ua.nick_name,
ua.phone_num
FROM user_points_details upd
INNER JOIN user_account ua ON upd.user_account_id = ua.id
WHERE ua.`disable` = 0
AND upd.user_account_id = #{userAccountId}
order by upd.create_time desc
limit #{pageNo}, #{pageSize}
</select>
<select id="appDetailPointCount" resultType="java.lang.Integer">
SELECT count(*)
FROM user_points_details upd
INNER JOIN user_account ua ON upd.user_account_id = ua.id
WHERE ua.`disable` = 0
AND upd.user_account_id = #{userAccountId}
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论