Commit fc0e230d authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/master-tiande' into master-tiande

parents b117d683 9fd76c14
......@@ -14,6 +14,10 @@ import org.springframework.util.StringUtils;
public class UserMemberSaveDTO {
@ApiModelProperty(value = "会员导入Id")
private Integer id;
@ApiModelProperty(value = "手机号")
private String phone;
......
......@@ -3,6 +3,8 @@ package com.github.wxiaoqi.security.admin.entity;
import lombok.*;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
......@@ -20,6 +22,10 @@ import java.io.Serializable;
@ToString
public class BaseUserMemberExport implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "JDBC")//此处加上注解
private Integer id;
@Column(name = "user_id")
private Integer userId;
......
......@@ -70,6 +70,21 @@ public class BaseUserMemberLevel implements Serializable {
@ApiModelProperty(value = "折扣")
private Integer discount;
@Column(name = "share_amount")
@ApiModelProperty(value = "分红金额")
private BigDecimal shareAmount;
@Column(name = "is_share")
@ApiModelProperty(value = "是否分红:0-否;1-是")
private Integer isShare;
@Column(name = "is_show")
@ApiModelProperty(value = "是否显示:0-不显示;1-显示")
private Integer isShow;
//是否删除;0-正常;1-删除
@Column(name = "isdel")
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
......
......@@ -11,6 +11,7 @@ import com.github.wxiaoqi.security.admin.mapper.AppUserRelationMapper;
import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.admin.vo.InviteMemberVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
......@@ -168,6 +169,8 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
staffUserDTO.setUid(relation.getUserId());
staffUserBiz.addAppStaffUser(staffUserDTO);
}
}else {
throw new BaseException("该用户已有下线无法成为别人下线",ResultCode.FAILED_CODE);
}
}catch (Exception e){
log.info("网络异常===" + e.getMessage());
......@@ -175,6 +178,57 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
}
public void bindRelationV2(Integer userId,Integer parentId,Integer type){
if (userId.equals(parentId)){
log.info("----userId==="+userId+"----parentId===="+parentId+"----自己不能成为自己的上线");
throw new BaseException("自己不能成为自己的上线",ResultCode.FAILED_CODE);
}
AppUserVo appUserVo=userDetailBiz.getUserInfoById(parentId);
if (appUserVo==null){
log.info("----userId==="+userId+"----parentId===="+parentId+"----");
throw new BaseException("该上线用户不存在",ResultCode.FAILED_CODE);
}
AppUserRelation relation=getMyBiz().getRelationByUserId(parentId);
Long time=System.currentTimeMillis();
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(parentId);
relation.setBindType(type);
insertSelective(relation);
}
Long bindTime=time-validTime;
//判断用户是否有有效的下线
if (getCountByParentId(userId,bindTime)==0L){
relation=getMyBiz().getRelationByUserId(userId);
if(relation==null){
relation=new AppUserRelation();
relation.setUserId(userId);
relation.setParentId(parentId);
relation.setBindType(type);
relation.setBindTime(time);
insertSelective(relation);
}else {
//判断用户是否有有效的上线
log.info("----userId==="+userId+"----bindTime===="+bindTime+"----relation.getBindTime()==="+relation.getBindTime());
if(relation.getParentId()==null||relation.getParentId()==0||(relation.getIsForever()!=1&&validTime>0&&relation.getBindTime()<bindTime)){
relation.setParentId(parentId);
relation.setBindType(type);
relation.setBindTime(time);
getMyBiz().updRelation(relation);
}
}
if (relation != null){
AppStaffUserDTO staffUserDTO=new AppStaffUserDTO();
staffUserDTO.setSuId(relation.getParentId());
staffUserDTO.setUid(relation.getUserId());
staffUserBiz.addAppStaffUser(staffUserDTO);
}
}else {
throw new BaseException("该用户已有下线无法成为别人下线",ResultCode.FAILED_CODE);
}
}
//首页关系绑定
public ObjectRestResponse appBindRelation(Integer userId, String code) {
Integer parentId = 0;
......@@ -204,7 +258,7 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper, AppUserRe
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "该上级不存在");
}
Integer parentId = userLogin.getId();
getMyBiz().bindRelation(userId, parentId, 1);
bindRelationV2(userId, parentId, 1);
return ObjectRestResponse.succ();
}
......
......@@ -99,7 +99,14 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
if (log.isDebugEnabled()) {
log.debug("当前组装的数据:【{}】", memberExport);
}
Integer id=userMemberSaveDTO.getId() == null ? 0 : userMemberSaveDTO.getId();
if (id == 0){
mapper.insertSelective(memberExport);
}else {
memberExport.setId(id);
mapper.updateByPrimaryKeySelective(memberExport);
}
}
}
......
......@@ -33,6 +33,18 @@ public class UserMemberLevelBiz extends BaseBiz<BaseUserMemberLevelMapper,BaseUs
return mapper.selectByExample(example);
}
@Transactional
public List<BaseUserMemberLevel> getList(BaseUserMemberLevel baseUserMemberLevel) {
Example example=new Example(BaseUserMemberLevel.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isdel",0);
if (baseUserMemberLevel.getIsShow() != null){
criteria.andEqualTo("isShow",baseUserMemberLevel.getIsShow());
}
example.setOrderByClause(" level asc ");
return mapper.selectByExample(example);
}
public BaseUserMemberLevel getLevel(Integer level) {
Example example=new Example(BaseUserMemberLevel.class);
example.createCriteria().andEqualTo("isdel",0).andEqualTo("level",level);
......
......@@ -33,8 +33,9 @@ public class MemberLevelController extends BaseController<UserMemberLevelBiz, Ba
}
@RequestMapping(value = "/app/unauth/level/list", method = RequestMethod.GET)
public ObjectRestResponse<List<BaseUserMemberLevel>>list() throws Exception {
return ObjectRestResponse.succ(memberBiz.getLevesls());
public ObjectRestResponse<List<BaseUserMemberLevel>>list(BaseUserMemberLevel baseUserMemberLevel) throws Exception {
baseUserMemberLevel.setIsShow(1);
return ObjectRestResponse.succ(memberBiz.getList(baseUserMemberLevel));
}
@RequestMapping(value = "/app/unauth/level/{type}", method = RequestMethod.GET)
......
......@@ -17,12 +17,7 @@ public class AdminUserRelationController extends BaseController<AppUserRelationB
@RequestMapping(value = "/bind",method = RequestMethod.POST)
@ApiModelProperty("后台绑定")
public ObjectRestResponse bind(@RequestBody UserRelationDTO relationDTO){
try {
return baseBiz.adminBindRelation(relationDTO);
} catch (Exception e) {
e.printStackTrace();
throw new BaseException(e);
}
}
......
......@@ -281,6 +281,15 @@ public class AppUserRest {
}
@ApiModelProperty("注销")
@PostMapping("cancelUsername")
public ObjectRestResponse updUsername(@RequestParam(value = "mobilecode") String mobilecode,HttpServletRequest request)throws Exception{
IJWTInfo infoFromToken = authUtil.getInfoFromToken(userAuthConfig.getToken(request));
return appPermissionService.cancelUsername(Integer.parseInt(infoFromToken.getId()),mobilecode);
}
/*@GetMapping("/app/unauth/test")
@IgnoreUserToken
public ObjectRestResponse test(){
......
......@@ -1258,6 +1258,29 @@ public class AppPermissionService {
}
//注销
public ObjectRestResponse cancelUsername(Integer userId,String mobileCode){
if (StringUtils.isBlank(mobileCode) || userId == 0 || userId == null ){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
// 是否已存在
AppUserLogin user = appUserLoginBiz.selectById(userId);
if (user==null){
return ObjectRestResponse.createFailedResult(ResultCode.EXIST_CODE, "用户不存在");
}
if (StringUtils.isBlank(checkCodeByUsername(user.getUsername(),mobileCode))){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"验证码错误");
}
AppUserLogin userLogin=new AppUserLogin();
userLogin.setId(userId);
userLogin.setIsdel(1);
userLogin.setUsername(user.getUsername()+user.getId());
appUserLoginBiz.disable(userLogin);
return ObjectRestResponse.succ();
}
/**
* 注册用户
*
......
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