提交 b7640683 作者: 刘明祎-运维用途

Merge branch 'develop'

...@@ -15,10 +15,7 @@ import com.mmc.iuav.user.service.userpoints.UserPointsService; ...@@ -15,10 +15,7 @@ import com.mmc.iuav.user.service.userpoints.UserPointsService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
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; import javax.servlet.http.HttpServletRequest;
...@@ -74,4 +71,10 @@ public class UserPointsController extends BaseController { ...@@ -74,4 +71,10 @@ public class UserPointsController extends BaseController {
} }
@ApiOperation(value = "积分变动接口")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/changeUserPoints")
public ResultBody changeUserPoints(HttpServletRequest request,@RequestParam("id") Integer id) {
return userPointsService.changeUserPoints(this.getUserLoginInfoFromRedis(request).getUserAccountId(), id);
}
} }
package com.mmc.iuav.user.dao.userpoints; package com.mmc.iuav.user.dao.userpoints;
import com.mmc.iuav.user.entity.userpoints.UserPointChangeTypeDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails; 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.AppPointsDetailsQO;
import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO; import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
...@@ -23,4 +24,11 @@ public interface UserPointsDetailsDao { ...@@ -23,4 +24,11 @@ public interface UserPointsDetailsDao {
List<UserPointsDetails> appDetailPoint(AppPointsDetailsQO param); List<UserPointsDetails> appDetailPoint(AppPointsDetailsQO param);
int appDetailPointCount(AppPointsDetailsQO param); int appDetailPointCount(AppPointsDetailsQO param);
/**
* 查找积分变动类型表 user_points_change_type
* @param id 积分变动表id
* @return {@link UserPointChangeTypeDO}
*/
UserPointChangeTypeDO selectChangePoint(Integer id);
} }
package com.mmc.iuav.user.entity.userpoints;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Admin
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserPointChangeTypeDO {
@ApiModelProperty(value = "积分变动类型id")
private Integer id;
@ApiModelProperty(value = "变动多少积分")
private Integer changePoint;
@ApiModelProperty(value = "变动积分说明")
private String pointSource;
}
...@@ -94,6 +94,7 @@ public class AuthServiceImpl implements AuthService { ...@@ -94,6 +94,7 @@ public class AuthServiceImpl implements AuthService {
String unionId; String unionId;
String openId; String openId;
String sessionKey; String sessionKey;
log.info("上级推荐人:{}", wxLoginVO.getRcdUserId());
if (wxLoginVO.getFromPort().toString().equals(WxConstant.APP.toString())) { if (wxLoginVO.getFromPort().toString().equals(WxConstant.APP.toString())) {
//调用小程序登录接口,里面包含unionId //调用小程序登录接口,里面包含unionId
String appWxJson = wxService.appLogin(wxLoginVO); String appWxJson = wxService.appLogin(wxLoginVO);
...@@ -134,6 +135,7 @@ public class AuthServiceImpl implements AuthService { ...@@ -134,6 +135,7 @@ public class AuthServiceImpl implements AuthService {
nameAuthByUnionId.setId(null); nameAuthByUnionId.setId(null);
realNameAuthDao.addRealNameAuth(nameAuthByUnionId); realNameAuthDao.addRealNameAuth(nameAuthByUnionId);
} }
log.info("用户的id是=====》{}",userAccountDO.getId());
} else { } else {
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountVO.getId()); CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountVO.getId());
companyAuthStatus = companyAuthDO == null ? 0 : 1; companyAuthStatus = companyAuthDO == null ? 0 : 1;
...@@ -142,7 +144,7 @@ public class AuthServiceImpl implements AuthService { ...@@ -142,7 +144,7 @@ public class AuthServiceImpl implements AuthService {
AppUserSucVO appUserSucVO = authHandler.addAppLoginCache(userAccountVO); AppUserSucVO appUserSucVO = authHandler.addAppLoginCache(userAccountVO);
appUserSucVO.setAuthStatus(companyAuthStatus); appUserSucVO.setAuthStatus(companyAuthStatus);
appUserSucVO.setSessionKey(sessionKey); appUserSucVO.setSessionKey(sessionKey);
log.info("判断是不是新用户 =====》 {}",isNewPilot);
//判断是不是新用户只有新用户才会执行添加积分代码 //判断是不是新用户只有新用户才会执行添加积分代码
if(!isNewPilot) { if(!isNewPilot) {
return ResultBody.success(appUserSucVO); return ResultBody.success(appUserSucVO);
......
...@@ -22,4 +22,13 @@ public interface UserPointsService { ...@@ -22,4 +22,13 @@ public interface UserPointsService {
ResultBody change(ChangeUserPointVO changePoint); ResultBody change(ChangeUserPointVO changePoint);
ResultBody listChangeType(); ResultBody listChangeType();
/**
* 改变用户积分,
* @param userId 用户id
* @param pointChangeTypeId 根据这个id去user_points_change_type表中查找需要修改多少积分
* @return {@link ResultBody}
*/
ResultBody changeUserPoints(Integer userId,Integer pointChangeTypeId);
} }
...@@ -5,6 +5,7 @@ import com.mmc.iuav.response.ResultBody; ...@@ -5,6 +5,7 @@ import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.controller.userpoints.config.UserPointsEnum; import com.mmc.iuav.user.controller.userpoints.config.UserPointsEnum;
import com.mmc.iuav.user.dao.userpoints.UserPointsDao; import com.mmc.iuav.user.dao.userpoints.UserPointsDao;
import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao; import com.mmc.iuav.user.dao.userpoints.UserPointsDetailsDao;
import com.mmc.iuav.user.entity.userpoints.UserPointChangeTypeDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDO; import com.mmc.iuav.user.entity.userpoints.UserPointsDO;
import com.mmc.iuav.user.entity.userpoints.UserPointsDetails; 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.UserPointsDTO;
...@@ -15,6 +16,7 @@ import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO; ...@@ -15,6 +16,7 @@ import com.mmc.iuav.user.model.qo.userpoints.UserPointsDetailsQO;
import com.mmc.iuav.user.model.vo.userpoints.ChangeUserPointVO; import com.mmc.iuav.user.model.vo.userpoints.ChangeUserPointVO;
import com.mmc.iuav.user.model.vo.userpoints.PointTypeVO; import com.mmc.iuav.user.model.vo.userpoints.PointTypeVO;
import com.mmc.iuav.user.service.userpoints.UserPointsService; import com.mmc.iuav.user.service.userpoints.UserPointsService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; 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;
...@@ -110,4 +112,33 @@ public class UserPointsServiceImpl implements UserPointsService { ...@@ -110,4 +112,33 @@ public class UserPointsServiceImpl implements UserPointsService {
} }
return ResultBody.success(types); return ResultBody.success(types);
} }
@Override
public ResultBody changeUserPoints(Integer userId, Integer pointChangeTypeId) {
//先根据积分变动id pointChangeTypeId 去找到积分变动类型信息
UserPointChangeTypeDO userPointChangeTypeDO = userPointsDetailsDao.selectChangePoint(pointChangeTypeId);
if(userPointChangeTypeDO == null) {
return ResultBody.error("扣除积分类型不存在");
}
UserPointsDO userPointsDO = userPointsDao.selectUserPoints(userId);
if(userPointsDO == null) {
userPointsDO.setUserAccountId(userId);
userPointsDO.setTotalPoints(0);
userPointsDao.insertPoints(userPointsDO);
}
//用户更改完积分后如果小于0就代表积分不够 大于0就去修改数据库用户总积分
//改变的积分
Integer changePoint = userPointChangeTypeDO.getChangePoint();
//改变后的用户总积分
Integer userNowPoints = userPointsDO.getTotalPoints() + changePoint;
if(userNowPoints < 0) {
return ResultBody.error("积分不足,请先去赚取积分");
}
userPointsDO.setTotalPoints(userNowPoints);
userPointsDao.updatePoints(userPointsDO);
//添加一条积分变动记录
UserPointsDetails userPointsDetails = new UserPointsDetails(userId,changePoint,userPointChangeTypeDO.getPointSource());
userPointsDetailsDao.insertPointsDetails(userPointsDetails);
return ResultBody.success();
}
} }
...@@ -74,4 +74,7 @@ ...@@ -74,4 +74,7 @@
WHERE ua.`disable` = 0 WHERE ua.`disable` = 0
AND upd.user_account_id = #{userAccountId} AND upd.user_account_id = #{userAccountId}
</select> </select>
<select id="selectChangePoint" resultType="com.mmc.iuav.user.entity.userpoints.UserPointChangeTypeDO">
select id,change_point,point_source from user_points_change_type where id = #{id}
</select>
</mapper> </mapper>
...@@ -18,4 +18,4 @@ patches: ...@@ -18,4 +18,4 @@ patches:
images: images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG - name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: d57e7944a98a52f3d842cf3d6b315a427710f632 newTag: 45a89ad3beb8e63b5547d02f6e1e55724193c8a6
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论