Commit 7b5faac3 authored by liaoanyuan's avatar liaoanyuan

修改添加vip客户功能

parent 0cfe090e
package cn.wisenergy.mapper; package cn.wisenergy.mapper;
import cn.wisenergy.model.app.Local; import cn.wisenergy.model.app.Local;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List; import java.util.List;
public interface LocalMapper { public interface LocalMapper extends BaseMapper<Local> {
/** /**
* 获取地区列表 * 获取地区列表
* @return 地区列表 * @return 地区列表
......
...@@ -24,7 +24,7 @@ public interface StaffMapper extends BaseMapper<Banner> { ...@@ -24,7 +24,7 @@ public interface StaffMapper extends BaseMapper<Banner> {
* @param map 查询信息 * @param map 查询信息
* @return 员工信息集合 * @return 员工信息集合
*/ */
List<StaffDto> getStaffList(Map<String, Object> map); List<Staff> getStaffList(Map<String, Object> map);
/** /**
* 编辑员工信息 * 编辑员工信息
......
...@@ -23,4 +23,6 @@ public interface VolunteerMapper extends BaseMapper<Volunteer> { ...@@ -23,4 +23,6 @@ public interface VolunteerMapper extends BaseMapper<Volunteer> {
List<Volunteer> getVolunteerList(Map<String,Object> map); List<Volunteer> getVolunteerList(Map<String,Object> map);
List<Volunteer> getVolunteerByType(@Param("type") Integer type); List<Volunteer> getVolunteerByType(@Param("type") Integer type);
List<Volunteer> getVolunteerListVip(Map<String,Object> map);
} }
<?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="cn.wisenergy.mapper.LocalMapper">
<resultMap id="localMap" type="cn.wisenergy.model.app.Local">
<id column="id" property="id"/>
<result column="local_name" property="localName"/>
<result column="is_delete" property="isDelete"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<sql id="table">
local
</sql>
<sql id="cols_all">
id,
<include refid="cols_exclude_id"/>
</sql>
<sql id="cols_exclude_id">
local_name,is_delete,create_time,update_time
</sql>
<sql id="vals">
#{localName},#{isDelete},now(),now()
</sql>
<sql id="updateCondition">
<if test="localName != null">local_name =#{localName},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
update_time =now()
</sql>
<sql id="criteria">
<if test="localName != null">and local_name =#{localName}</if>
<if test="isDelete != null">and is_delete = #{isDelete}</if>
<if test="createTime != null">and create_time >= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} >= update_time</if>
</sql>
<update id="edit" parameterType="cn.wisenergy.model.app.Graduation">
UPDATE
<include refid="table"/>
<set>
<include refid="updateCondition"/>
</set>
<where>
id = #{id}
</where>
</update>
<select id="getList" resultMap="localMap">
select
<include refid="cols_all"/>
from
<include refid="table"/>
</select>
</mapper>
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<result column="is_delete" property="isDelete"/> <result column="is_delete" property="isDelete"/>
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
<result column="is_vip" property="isVip"/>
</resultMap> </resultMap>
<sql id="table"> <sql id="table">
...@@ -28,12 +29,12 @@ ...@@ -28,12 +29,12 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
user_name,password, phone,uuid,head_image,sex,school, exam_type,source,is_delete,create_time,update_time user_name,password, phone,uuid,head_image,sex,school, exam_type,source,is_delete,create_time,update_time,is_vip
</sql> </sql>
<sql id="vals"> <sql id="vals">
#{userName},#{password},#{phone},#{uuid},#{headImage},#{sex},#{school},#{examType}, #{source}, #{userName},#{password},#{phone},#{uuid},#{headImage},#{sex},#{school},#{examType}, #{source},
#{isDelete},now(),now() #{isDelete},now(),now(),#{isVip}
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
...@@ -47,7 +48,8 @@ ...@@ -47,7 +48,8 @@
<if test="examType != null">exam_type = #{examType},</if> <if test="examType != null">exam_type = #{examType},</if>
<if test="source != null">source = #{source},</if> <if test="source != null">source = #{source},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if> <if test="isDelete != null">is_delete = #{isDelete},</if>
update_time =now() update_time =now(),
<if test="isVip != null">is_vip = #{isVip}</if>
</sql> </sql>
<sql id="criteria"> <sql id="criteria">
...@@ -64,6 +66,7 @@ ...@@ -64,6 +66,7 @@
<if test="isDelete != null">and is_delete = #{isDelete}</if> <if test="isDelete != null">and is_delete = #{isDelete}</if>
<if test="createTime != null">and create_time &gt;= #{createTime}</if> <if test="createTime != null">and create_time &gt;= #{createTime}</if>
<if test="updateTime != null">and #{updateTime} &gt;= update_time</if> <if test="updateTime != null">and #{updateTime} &gt;= update_time</if>
<if test="isVip != null">and is_vip = #{isVip}</if>
</sql> </sql>
<insert id="add" parameterType="cn.wisenergy.model.app.User" keyProperty="id" useGeneratedKeys="true"> <insert id="add" parameterType="cn.wisenergy.model.app.User" keyProperty="id" useGeneratedKeys="true">
......
...@@ -186,4 +186,30 @@ ...@@ -186,4 +186,30 @@
</where> </where>
</select> </select>
<select id="getVolunteerListVip" resultType="cn.wisenergy.model.app.Volunteer">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
is_delete =0
<if test="type != null">
and type =#{type}
</if>
<if test="total != null">
and lowest_mark=#{total}
</if>
<if test="local != null">
and nature LIKE CONCAT('%',#{local},'%')
</if>
<if test="professionNames != null">
and
<foreach collection="professionNames" index="index" item="id" separator="or" open="(" close=")">
major_name LIKE CONCAT('%',#{id},'%')
</foreach>
</if>
order by lowest_mark desc
</where>
</select>
</mapper> </mapper>
...@@ -97,4 +97,10 @@ public class User implements Serializable { ...@@ -97,4 +97,10 @@ public class User implements Serializable {
@ApiModelProperty(name = "updateTime", value = "修改时间") @ApiModelProperty(name = "updateTime", value = "修改时间")
private Date updateTime; private Date updateTime;
/**
* 用户是否为vip
*/
@ApiModelProperty(name = "isVip",value = "用户是否为vip 1:是 2:不是")
private Integer isVip;
} }
package cn.wisenergy.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("SchemeVipVo")
public class SchemeVipVo implements Serializable {
private static final long serialVersionUID = 1372044868981609886L;
/**
* 用户id
*/
@ApiModelProperty(value = "用户id", name = "userId")
private Integer userId;
/**
* 大专业名称
*/
@ApiModelProperty(value = "大专业名称:如 ‘法学、文学、外语’", name = "bigMajorNames")
private String bigMajorNames;
/**
* 专业ids
*/
@ApiModelProperty(value = "专业ids,如'1,2,3,4,5,6...'", name = "professionIds")
private String professionIds;
/**
* 文化课成绩
*/
@ApiModelProperty(value = "文化课成绩", name = "cultureGrade")
private String cultureGrade;
/**
* 专业课成绩
*/
@ApiModelProperty(value = "专业课成绩", name = "majorGrade")
private String majorGrade;
/**
* 地区
*/
@ApiModelProperty(value = "地区", name = "local")
private String local;
/**
* 综合成绩
*/
@ApiModelProperty(name = "total",value = "综合成绩")
private Integer total;
/**
* 是否展示全部 0:否 1:是
*/
@ApiModelProperty(value = "是否展示全部 0:否 1:是", name = "isShowAll")
private Integer isShowAll;
}
...@@ -3,6 +3,7 @@ package cn.wisenergy.service.app; ...@@ -3,6 +3,7 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.SchemeInfo; import cn.wisenergy.model.app.SchemeInfo;
import cn.wisenergy.model.vo.SchemeQueryVo; import cn.wisenergy.model.vo.SchemeQueryVo;
import cn.wisenergy.model.vo.SchemeVipVo;
import cn.wisenergy.model.vo.SchemeVo; import cn.wisenergy.model.vo.SchemeVo;
import cn.wisenergy.model.vo.VolunteerVo; import cn.wisenergy.model.vo.VolunteerVo;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -50,4 +51,12 @@ public interface SchemeService { ...@@ -50,4 +51,12 @@ public interface SchemeService {
R<String> download(Integer schemeId); R<String> download(Integer schemeId);
List<Integer> ceishi(Integer id); List<Integer> ceishi(Integer id);
/**
* 私人订制方案查询
*
* @param schemeVo 查询参数
* @return 方案查询结果列表
*/
R<VolunteerVo> getListVip(SchemeVipVo schemeVo);
} }
package cn.wisenergy.service.app; package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Local;
import cn.wisenergy.model.dto.UserInfoDto; import cn.wisenergy.model.dto.UserInfoDto;
import cn.wisenergy.model.vo.AccountLoginVo; import cn.wisenergy.model.vo.AccountLoginVo;
import cn.wisenergy.model.vo.UserVipCommitVo; import cn.wisenergy.model.vo.UserVipCommitVo;
import cn.wisenergy.model.vo.UserVipQueryVo; import cn.wisenergy.model.vo.UserVipQueryVo;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import java.util.List;
public interface StaffUserVipService { public interface StaffUserVipService {
/** /**
...@@ -24,13 +27,6 @@ public interface StaffUserVipService { ...@@ -24,13 +27,6 @@ public interface StaffUserVipService {
*/ */
R<PageInfo<UserInfoDto>> getList(UserVipQueryVo userVipQueryVo); R<PageInfo<UserInfoDto>> getList(UserVipQueryVo userVipQueryVo);
/**
* 添加员工和vip客户关系
* @param userVipCommitVo 添加信息
* @return true:成功 false:失败
*/
R<Boolean> addUserVip(UserVipCommitVo userVipCommitVo);
/** /**
* 添加员工和vip客户关系 * 添加员工和vip客户关系
* @param staffId 员工id * @param staffId 员工id
...@@ -39,5 +35,16 @@ public interface StaffUserVipService { ...@@ -39,5 +35,16 @@ public interface StaffUserVipService {
*/ */
R<Boolean> addUserByPhone(Integer staffId,String phone); R<Boolean> addUserByPhone(Integer staffId,String phone);
/**
* 获取地区列表
* @return 地区列表
*/
R<List<Local>> getLocal();
/**
* 保存vip客户和志愿关系
* @param ids id群
* @return true:成功 false:失败
*/
R<Boolean> addUserVolunteer(String ids,Integer userId,String name);
} }
\ No newline at end of file
...@@ -68,4 +68,12 @@ public interface UserLoginService { ...@@ -68,4 +68,12 @@ public interface UserLoginService {
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
R<Boolean> smsResetPassword(UserLoginVo userLoginVo); R<Boolean> smsResetPassword(UserLoginVo userLoginVo);
/**
* vip用户注册接口
*
* @param userRegisterVo 用户信息
* @return true 成功 false 失败
*/
R<UserInfoVo> registerVip(UserRegisterVo userRegisterVo);
} }
...@@ -7,6 +7,7 @@ import cn.wisenergy.model.dto.UserInfoDto; ...@@ -7,6 +7,7 @@ import cn.wisenergy.model.dto.UserInfoDto;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserQueryVo; import cn.wisenergy.model.vo.UserQueryVo;
import cn.wisenergy.model.vo.UserShowVo; import cn.wisenergy.model.vo.UserShowVo;
import cn.wisenergy.model.vo.UserVipCommitVo;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -77,6 +78,6 @@ public interface UserService { ...@@ -77,6 +78,6 @@ public interface UserService {
R<List<User>> test(); R<List<User>> test();
R<UserInfoVo> commitUserVipInfo(UserCommitDto userInfo); R<UserInfoVo> commitUserVipInfo(UserVipCommitVo userInfo);
} }
...@@ -15,6 +15,7 @@ import org.springframework.beans.BeanUtils; ...@@ -15,6 +15,7 @@ import org.springframework.beans.BeanUtils;
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 java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -82,13 +83,21 @@ public class StaffServiceImpl implements StaffService { ...@@ -82,13 +83,21 @@ public class StaffServiceImpl implements StaffService {
map.put("staffName", queryVo.getStaffName()); map.put("staffName", queryVo.getStaffName());
map.put("phone", queryVo.getPhone()); map.put("phone", queryVo.getPhone());
List<StaffDto> staffList = staffMapper.getStaffList(map); //查询vip客户信息
List<Staff> staffList = staffMapper.getStaffList(map);
//转移客户信息至返回类中
List<StaffDto> staffDtos = new ArrayList<>();
for (Staff staff : staffList) {
StaffDto staffDto = new StaffDto();
BeanUtils.copyProperties(staff,staffDto);
staffDtos.add(staffDto);
}
PageInfo<StaffDto> info = new PageInfo<>(); PageInfo<StaffDto> info = new PageInfo<>();
info.setPageSize(null==queryVo.getPageSize()?0:queryVo.getPageSize()); info.setPageSize(null==queryVo.getPageSize()?0:queryVo.getPageSize());
info.setPageNum(null==queryVo.getPageNo()?0:queryVo.getPageNo()); info.setPageNum(null==queryVo.getPageNo()?0:queryVo.getPageNo());
info.setTotal(staffList.size()); info.setTotal(staffList.size());
info.setList(staffList); info.setList(staffDtos);
return R.ok(0,info); return R.ok(0,info);
} }
...@@ -138,7 +147,7 @@ public class StaffServiceImpl implements StaffService { ...@@ -138,7 +147,7 @@ public class StaffServiceImpl implements StaffService {
//查询管理者信息 //查询管理者信息
Staff staff3 = staffMapper.getStaff(map); Staff staff3 = staffMapper.getStaff(map);
if (null!=staff) { if (null!=staff3) {
return R.error("用户已存在"); return R.error("用户已存在");
} }
......
...@@ -2,6 +2,7 @@ package cn.wisenergy.service.app.impl; ...@@ -2,6 +2,7 @@ package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.Md5Util; import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.StringUtil;
import cn.wisenergy.mapper.*; import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.dto.UserCommitDto; import cn.wisenergy.model.dto.UserCommitDto;
...@@ -15,6 +16,7 @@ import cn.wisenergy.service.app.StaffUserVipService; ...@@ -15,6 +16,7 @@ import cn.wisenergy.service.app.StaffUserVipService;
import cn.wisenergy.service.common.UserVipManager; import cn.wisenergy.service.common.UserVipManager;
import cn.wisenergy.service.common.VolunteerManager; import cn.wisenergy.service.common.VolunteerManager;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -31,7 +33,7 @@ import java.util.Map; ...@@ -31,7 +33,7 @@ import java.util.Map;
@Slf4j @Slf4j
@Service @Service
public class StaffUserVipServiceImpl implements StaffUserVipService { public class StaffUserVipServiceImpl extends ServiceImpl<LocalMapper, Local> implements StaffUserVipService {
@Autowired @Autowired
private StaffMapper staffMapper; private StaffMapper staffMapper;
...@@ -60,6 +62,9 @@ public class StaffUserVipServiceImpl implements StaffUserVipService { ...@@ -60,6 +62,9 @@ public class StaffUserVipServiceImpl implements StaffUserVipService {
@Autowired @Autowired
private UserVipManager userVipManager; private UserVipManager userVipManager;
@Autowired
private LocalMapper localMapper;
//初始密码 //初始密码
private static final String PASSWORD = "123456"; private static final String PASSWORD = "123456";
...@@ -182,42 +187,46 @@ public class StaffUserVipServiceImpl implements StaffUserVipService { ...@@ -182,42 +187,46 @@ public class StaffUserVipServiceImpl implements StaffUserVipService {
} }
@Override @Override
public R<Boolean> addUserVip(UserVipCommitVo userVipCommitVo) { public R<Boolean> addUserByPhone(Integer staffId, String phone) {
log.info("StaffUserVipServiceImpl[].addUserVip[].input.param:" + userVipCommitVo); log.info("StaffUserVipServiceImpl[].addUserByPhone[].input.param:" +staffId,phone);
if (null == userVipCommitVo || StringUtils.isBlank(userVipCommitVo.getPhone())||null==userVipCommitVo.getStaffId()) {
return addPhone(staffId,phone);
}
@Override
public R<List<Local>> getLocal() {
List<Local> list = localMapper.getList();
if (CollectionUtils.isEmpty(list)) {
return R.error("入参为空"); return R.error("入参为空");
} }
String phone = userVipCommitVo.getPhone(); return R.ok(0,list);
}
User bool = userVipManager.checkPhone(phone); @Override
if (null!=bool) { public R<Boolean> addUserVolunteer(String ids,Integer userId,String name) {
return R.error("该电话号码" + phone + "已被使用!"); log.info("StaffUserVipServiceImpl[].addUserVolunteer[].input.param:" +ids,userId);
}
userVipCommitVo.setFlag(1); if (StringUtils.isBlank(ids)||null==userId) {
R<Boolean> booleanR = userVipManager.CommitUserVip(userVipCommitVo); return R.error("入参为空");
User byPhone =userVipManager.checkPhone(phone);
//判断信息是否添加成功
if (booleanR.getCode()==1) {
usersMapper.delById(byPhone.getId());
return R.error("信息添加失败2");
} }
//进行vip客户和员工绑定 //通过id获取用户信息
if (null==byPhone) { User byId = usersMapper.getById(userId);
usersMapper.delById(byPhone.getId());
return R.error("信息添加失败3"); if (null==byId) {
return R.error("该用户不存在");
} }
return userVipManager.addPhone1(userVipCommitVo.getStaffId(),byPhone.getId()); ScoreInfo byUserId = scoreInfoMapper.getByUserId(userId);
}
@Override R<Boolean> booleanR = userVipManager.saveUserVolunteer(byId,ids,byUserId,name);
public R<Boolean> addUserByPhone(Integer staffId, String phone) {
log.info("StaffUserVipServiceImpl[].addUserByPhone[].input.param:" +staffId,phone);
return addPhone(staffId,phone); if (!booleanR.getData()) {
return R.error("保存失败");
}
return R.ok(0,true);
} }
...@@ -228,17 +237,13 @@ public class StaffUserVipServiceImpl implements StaffUserVipService { ...@@ -228,17 +237,13 @@ public class StaffUserVipServiceImpl implements StaffUserVipService {
//进行vip客户和员工绑定 //进行vip客户和员工绑定
User byPhone =userVipManager.checkPhone(phone); User byPhone =userVipManager.checkPhone(phone);
if (null==byPhone) { if (null==byPhone) {
return R.error("信息添加失败3"); return R.error("信息添加失败");
} }
R<Boolean> booleanR = userVipManager.addPhone1(staffId, byPhone);
StaffUserVip staffUserVip = new StaffUserVip();
staffUserVip.setStaffId(staffId);
staffUserVip.setUserVipId(byPhone.getId());
int add = staffUserVipMapper.add(staffUserVip);
//判断数据是否添加成功 //判断数据是否添加成功
if (add==0) { if (booleanR.getCode()!=0) {
return R.error("信息添加失败"); return R.error("关系绑定失败");
} }
return R.ok(0,true); return R.ok(0,true);
......
...@@ -50,6 +50,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme ...@@ -50,6 +50,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
@Autowired @Autowired
private VolunteerManager volunteerManager; private VolunteerManager volunteerManager;
//VIP客户初始密码
private static final String PASSWORD = "123456";
private static final int ERROR_CODE = 1; private static final int ERROR_CODE = 1;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -272,6 +275,27 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme ...@@ -272,6 +275,27 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
return R.ok(0, true); return R.ok(0, true);
} }
@Override
public R<UserInfoVo> registerVip(UserRegisterVo userVo) {
log.info("volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone())) {
return R.error("入参为空!");
}
String phone = userVo.getPhone();
//1.检查号码是否重复
Integer userId = null;
Boolean bool = checkPhone(phone, userId);
if (!bool) {
return R.error("该电话已存在,请确认电话号码" + phone + "是否正确!");
}
//3、给密码加密 加密规则,电话号码+明文密码
String secret = Md5Util.digestMD5(PASSWORD + phone);
return volunteerManager.saveUserAndLimit(phone, secret, userVo.getSource());
}
private Boolean checkPhone(String phone, Integer userId) { private Boolean checkPhone(String phone, Integer userId) {
//判断是注册还是编辑 //判断是注册还是编辑
//1、注册-新增 //1、注册-新增
......
...@@ -3,7 +3,9 @@ package cn.wisenergy.service.app.impl; ...@@ -3,7 +3,9 @@ package cn.wisenergy.service.app.impl;
import cn.hutool.system.UserInfo; import cn.hutool.system.UserInfo;
import cn.wisenergy.common.constant.CommonAttributes; import cn.wisenergy.common.constant.CommonAttributes;
import cn.wisenergy.common.utils.DateUtil; import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.StringUtil;
import cn.wisenergy.mapper.*; import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.*; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.dto.UserCommitDto; import cn.wisenergy.model.dto.UserCommitDto;
...@@ -12,6 +14,7 @@ import cn.wisenergy.model.dto.UserInfoDto; ...@@ -12,6 +14,7 @@ import cn.wisenergy.model.dto.UserInfoDto;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserQueryVo; import cn.wisenergy.model.vo.UserQueryVo;
import cn.wisenergy.model.vo.UserShowVo; import cn.wisenergy.model.vo.UserShowVo;
import cn.wisenergy.model.vo.UserVipCommitVo;
import cn.wisenergy.service.app.UserService; import cn.wisenergy.service.app.UserService;
import cn.wisenergy.service.common.VolunteerManager; import cn.wisenergy.service.common.VolunteerManager;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
...@@ -23,6 +26,7 @@ import org.springframework.beans.BeanUtils; ...@@ -23,6 +26,7 @@ import org.springframework.beans.BeanUtils;
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.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.*; import java.util.*;
...@@ -166,6 +170,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -166,6 +170,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
user.setExamType(userInfo.getStudentType()); user.setExamType(userInfo.getStudentType());
user.setUserName(userInfo.getUserName()); user.setUserName(userInfo.getUserName());
user.setIsDelete(0); user.setIsDelete(0);
user.setIsVip(2);
user.setSource(userInfo.getSource()); user.setSource(userInfo.getSource());
//3、要提交的用户的成绩信息 //3、要提交的用户的成绩信息
...@@ -372,9 +377,9 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -372,9 +377,9 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
} }
@Override @Override
public R<UserInfoVo> commitUserVipInfo(UserCommitDto userInfo) { public R<UserInfoVo> commitUserVipInfo(UserVipCommitVo userInfo) {
log.info("volunteer-service[]UserServiceImpl[]commitUserInfo[]input.param.userInfo:" + userInfo); log.info("volunteer-service[]UserServiceImpl[]commitUserVipInfo[]input.param.userInfo:" + userInfo);
if (null == userInfo) { if (null == userInfo||null==userInfo.getStaffId()|| null==userInfo.getSource()) {
return R.error("入参为空!"); return R.error("入参为空!");
} }
...@@ -385,6 +390,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -385,6 +390,7 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
user.setExamType(userInfo.getStudentType()); user.setExamType(userInfo.getStudentType());
user.setUserName(userInfo.getUserName()); user.setUserName(userInfo.getUserName());
user.setIsDelete(0); user.setIsDelete(0);
user.setIsVip(1);
user.setId(userInfo.getUserId()); user.setId(userInfo.getUserId());
user.setSource(userInfo.getSource()); user.setSource(userInfo.getSource());
...@@ -397,13 +403,16 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U ...@@ -397,13 +403,16 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
return R.error(checkScore.getMessage()); return R.error(checkScore.getMessage());
} }
//设置flag为添加用户
userInfo.setFlag(1);
//4、更新用户信息和保存用户成绩 //4、更新用户信息和保存用户成绩
boolean bool = volunteerManager.updateAndSaveUserInfo(user, scoreInfo,userInfo.getFlag()); boolean bool = volunteerManager.updateAndSaveUserVipInfo(user, scoreInfo,userInfo.getFlag(),userInfo.getStaffId());
if (!bool) { if (!bool) {
return R.error("添加用户信息失败!"); return R.error("添加用户信息失败!");
} }
//返回信息 //返回信息
UserInfoVo userInfoVo = new UserInfoVo(); UserInfoVo userInfoVo = new UserInfoVo();
userInfoVo.setUserId(userInfo.getUserId()); userInfoVo.setUserId(userInfo.getUserId());
......
...@@ -2,14 +2,16 @@ package cn.wisenergy.service.common; ...@@ -2,14 +2,16 @@ package cn.wisenergy.service.common;
import cn.wisenergy.common.utils.Md5Util; import cn.wisenergy.common.utils.Md5Util;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.StringUtil;
import cn.wisenergy.mapper.SchemeRecordMapper;
import cn.wisenergy.mapper.StaffUserVipMapper; import cn.wisenergy.mapper.StaffUserVipMapper;
import cn.wisenergy.mapper.UsersMapper; import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.StaffUserVip; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.app.User;
import cn.wisenergy.model.dto.UserCommitDto; import cn.wisenergy.model.dto.UserCommitDto;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserVipCommitVo; import cn.wisenergy.model.vo.UserVipCommitVo;
import cn.wisenergy.service.app.UserService; import cn.wisenergy.service.app.UserService;
import cn.wisenergy.service.app.UserVolunteerService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -19,14 +21,13 @@ import org.springframework.stereotype.Component; ...@@ -19,14 +21,13 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
public class UserVipManager { public class UserVipManager {
@Autowired
private UserService userService;
@Autowired
private VolunteerManager volunteerManager;
@Autowired @Autowired
private StaffUserVipMapper staffUserVipMapper; private StaffUserVipMapper staffUserVipMapper;
...@@ -34,49 +35,33 @@ public class UserVipManager { ...@@ -34,49 +35,33 @@ public class UserVipManager {
@Autowired @Autowired
private UsersMapper usersMapper; private UsersMapper usersMapper;
//初始密码 @Autowired
private static final String PASSWORD = "123456"; private SchemeRecordMapper schemeRecordMapper;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public R<Boolean> CommitUserVip(UserVipCommitVo userVipCommitVo){
//3、给密码加密 初始密码:123456
String secret = Md5Util.digestMD5(PASSWORD);
R<UserInfoVo> userInfoVoR = volunteerManager.saveUserAndLimit(userVipCommitVo.getPhone(), secret, userVipCommitVo.getSource());
if (null == userInfoVoR.getData()) {
return R.error("信息添加失败1");
}
User user = checkPhone(userVipCommitVo.getPhone());
//调用用户提交信息接口
UserCommitDto userCommitDto = new UserCommitDto();
BeanUtils.copyProperties(userVipCommitVo,userCommitDto);
userCommitDto.setUserId(user.getId());
R<UserInfoVo> userInfoVo = userService.commitUserVipInfo(userCommitDto);
if (null==userInfoVo.getData()) {
return R.ok(1,false);
}
return R.ok(0,true); @Autowired
} private UserVolunteerService userVolunteerService;
public R<Boolean> addPhone1(Integer staffId,Integer userId){ @Transactional
public R<Boolean> addPhone1(Integer staffId,User user){
StaffUserVip staffUserVip = new StaffUserVip(); StaffUserVip staffUserVip = new StaffUserVip();
staffUserVip.setStaffId(staffId); staffUserVip.setStaffId(staffId);
staffUserVip.setUserVipId(userId); staffUserVip.setUserVipId(user.getId());
staffUserVip.setIsDelete(0); staffUserVip.setIsDelete(0);
int add = staffUserVipMapper.add(staffUserVip); int add = staffUserVipMapper.add(staffUserVip);
//判断数据是否添加成功 //判断数据是否添加成功
if (add==0) { if (add==0) {
usersMapper.delById(userId);
return R.error("信息添加失败"); return R.error("信息添加失败");
} }
//将客户修改为vip
user.setIsVip(1);
int edit = usersMapper.edit(user);
if (edit==0) {
return R.error("信息修改失败");
}
return R.ok(0,true); return R.ok(0,true);
} }
...@@ -92,4 +77,50 @@ public class UserVipManager { ...@@ -92,4 +77,50 @@ public class UserVipManager {
} }
return null; return null;
} }
/**
* 保存方案查询记录和关联关系
*
* @return true 成功 false 失败
*/
@Transactional(rollbackFor = Exception.class)
public R<Boolean> saveUserVolunteer(User user, String ids, ScoreInfo scoreInfo, String name) {
//1、保存方案查询记录
SchemeQueryRecord schemeQueryRecord = new SchemeQueryRecord();
schemeQueryRecord.setMajorName(name);
schemeQueryRecord.setStudentType(user.getExamType());
schemeQueryRecord.setUserId(user.getId());
schemeQueryRecord.setIsDelete(0);
if (null == scoreInfo.getMajorGrade()) {
schemeQueryRecord.setMajorScore("0");
} else {
schemeQueryRecord.setMajorScore(scoreInfo.getMajorGrade().toString());
}
schemeQueryRecord.setScore(scoreInfo.getCultureGrade().toString());
//保存方案查询记录
int count = schemeRecordMapper.add(schemeQueryRecord);
if (count == 0) {
return R.error("保存方案查询记录失败!");
}
List<UserVolunteer> volunteerList = new ArrayList<>();
List<Integer> professionIds = StringUtil.strToArray(ids);
for (Integer id : professionIds) {
UserVolunteer userVolunteer = new UserVolunteer();
userVolunteer.setSchemeRecordId(schemeQueryRecord.getId());
userVolunteer.setUserId(user.getId());
userVolunteer.setVolunteerId(id);
volunteerList.add(userVolunteer);
}
//保存方案志愿关联关系
boolean bool = userVolunteerService.saveBatch(volunteerList);
if (!bool) {
return R.error("保存方案志愿关联关系失败!");
}
return R.ok(0,true);
}
} }
...@@ -51,6 +51,9 @@ public class VolunteerManager { ...@@ -51,6 +51,9 @@ public class VolunteerManager {
@Autowired @Autowired
private UsersMapper usersMapper; private UsersMapper usersMapper;
@Autowired
private StaffUserVipMapper staffUserVipMapper;
@Autowired @Autowired
private ScoreInfoMapper scoreInfoMapper; private ScoreInfoMapper scoreInfoMapper;
...@@ -219,6 +222,43 @@ public class VolunteerManager { ...@@ -219,6 +222,43 @@ public class VolunteerManager {
return R.ok(schemeQueryRecord.getId()); return R.ok(schemeQueryRecord.getId());
} }
/**
* 保存方案查询记录和关联关系
*
* @param user 用户信息
* @param list 志愿信息
* @return true 成功 false 失败
*/
@Transactional(rollbackFor = Exception.class)
public R<Integer> saveUserVolunteerVip(User user, List<Volunteer> list, ScoreInfo scoreInfo, String name) {
//1、保存方案查询记录
SchemeQueryRecord schemeQueryRecord = new SchemeQueryRecord();
schemeQueryRecord.setMajorName(name);
schemeQueryRecord.setStudentType(user.getExamType());
schemeQueryRecord.setUserId(user.getId());
schemeQueryRecord.setIsDelete(0);
if (null == scoreInfo.getMajorGrade()) {
schemeQueryRecord.setMajorScore("0");
} else {
schemeQueryRecord.setMajorScore(scoreInfo.getMajorGrade().toString());
}
schemeQueryRecord.setScore(scoreInfo.getCultureGrade().toString());
List<Integer> ids = list.stream().map(Volunteer::getId).collect(Collectors.toList());
//保存方案查询记录
int count = schemeRecordMapper.add(schemeQueryRecord);
if (count == 0) {
return R.error("保存方案查询记录失败!");
}
//调用扣减查询次数接口
R<Boolean> result = userLimitService.minusLimit(user.getId());
if (null != result && result.getCode() == ERROR_CODE) {
return R.error("扣减查询次数失败!");
}
return R.ok(schemeQueryRecord.getId());
}
/** /**
* 保存个人信息 * 保存个人信息
* *
...@@ -257,6 +297,57 @@ public class VolunteerManager { ...@@ -257,6 +297,57 @@ public class VolunteerManager {
return true; return true;
} }
/**
* 保存vip个人信息
*
* @param user 用户信息
* @param scoreInfo 成绩信息
* @return true or false
*/
@Transactional(rollbackFor = Exception.class)
public boolean updateAndSaveUserVipInfo(User user, ScoreInfo scoreInfo, Integer flag,Integer staffId) {
//添加vip客户信息
//1、更新用户信息
int count = usersMapper.edit(user);
if (count == 0) {
return false;
}
//2、保存用户成绩信息
if (null == scoreInfo.getMajorGrade()) {
scoreInfo.setMajorGrade(0.00);
}
//flag =1 添加
if (null != flag && flag == 1) {
int save = scoreInfoMapper.add(scoreInfo);
if (save == 0) {
return false;
}
}
//flag =2 编辑
if (null != flag && flag == 2) {
int edit = scoreInfoMapper.edit(scoreInfo);
if (edit == 0) {
return false;
}
}
//绑定vip客户与员工的关系
StaffUserVip staffUserVip = new StaffUserVip();
staffUserVip.setStaffId(staffId);
staffUserVip.setUserVipId(user.getId());
staffUserVip.setIsDelete(0);
int add = staffUserVipMapper.add(staffUserVip);
//判断数据是否添加成功
if (add==0) {
return false;
}
return true;
}
/** /**
* 编辑个人信息 * 编辑个人信息
* *
......
package cn.wisenergy.web.admin.controller.app; package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.Local;
import cn.wisenergy.model.dto.UserInfoDto; import cn.wisenergy.model.dto.UserInfoDto;
import cn.wisenergy.model.vo.AccountLoginVo; import cn.wisenergy.model.vo.*;
import cn.wisenergy.model.vo.UserVipCommitVo; import cn.wisenergy.service.app.SchemeService;
import cn.wisenergy.model.vo.UserVipQueryVo;
import cn.wisenergy.service.app.StaffUserVipService; import cn.wisenergy.service.app.StaffUserVipService;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@Api(tags = "员工端") @Api(tags = "员工端")
...@@ -23,6 +22,9 @@ public class StaffUserVipController { ...@@ -23,6 +22,9 @@ public class StaffUserVipController {
@Autowired @Autowired
private StaffUserVipService staffUserVipService; private StaffUserVipService staffUserVipService;
@Autowired
private SchemeService schemeService;
@ApiOperation(value = "员工登录",notes = "员工登录",httpMethod = "POST") @ApiOperation(value = "员工登录",notes = "员工登录",httpMethod = "POST")
@ApiModelProperty(name = "loginVo",value = "登录信息",dataType = "AccountLoginVo") @ApiModelProperty(name = "loginVo",value = "登录信息",dataType = "AccountLoginVo")
@PostMapping("/login") @PostMapping("/login")
...@@ -32,15 +34,6 @@ public class StaffUserVipController { ...@@ -32,15 +34,6 @@ public class StaffUserVipController {
return staffUserVipService.staffLogin(loginVo); return staffUserVipService.staffLogin(loginVo);
} }
@ApiOperation(value = "添加Vip客户",notes = "添加Vip客户",httpMethod = "POST")
@ApiModelProperty(name = "userVipCommitVo",value = "vip客户信息",dataType = "UserVipCommitVo")
@PostMapping("/add")
public R<Boolean> addUserVip(@RequestBody UserVipCommitVo userVipCommitVo){
log.info("StaffUserVipController[].addUserVip[].input.param:"+userVipCommitVo);
return staffUserVipService.addUserVip(userVipCommitVo);
}
@ApiOperation(value = "添加Vip客户(当客户已存在时)",notes = "添加Vip客户(当客户已存在时)",httpMethod = "POST") @ApiOperation(value = "添加Vip客户(当客户已存在时)",notes = "添加Vip客户(当客户已存在时)",httpMethod = "POST")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "staffId", value = "员工id", dataType = "int"), @ApiImplicitParam(name = "staffId", value = "员工id", dataType = "int"),
...@@ -62,4 +55,38 @@ public class StaffUserVipController { ...@@ -62,4 +55,38 @@ public class StaffUserVipController {
return staffUserVipService.getList(queryVo); return staffUserVipService.getList(queryVo);
} }
@ApiOperation(value = "查询地区",notes = "查询地区",httpMethod = "GET")
@GetMapping("/getLocal")
public R<List<Local>> getLocal(){
log.info("StaffUserVipController[].addUserVip[].input.param:");
return staffUserVipService.getLocal();
}
@ApiOperation(value = "vip客户方案查询", notes = "vip客户方案查询", httpMethod = "GET")
@ApiImplicitParam(name = "queryVo", value = "志愿查询参数", dataType = "SchemeVipVo")
@GetMapping("/getList")
public R<VolunteerVo> getList(SchemeVipVo queryVo) {
log.info("volunteer-service[]SchemeController[]getList[]input.param.queryVo:" + queryVo);
if (null == queryVo) {
return R.error("入参为空!");
}
return schemeService.getListVip(queryVo);
}
@ApiOperation(value = "vip客户方案保存", notes = "vip客户方案保存", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "志愿ids,如'1,2,3,4,5,6...", dataType = "string"),
@ApiImplicitParam(name = "userId", value = "vip客户id", dataType = "int"),
@ApiImplicitParam(name = "name", value = "所选专业名称", dataType = "string"),
}
)
@GetMapping("/addUserVoluteer")
public R<Boolean> addUserVoluteer(String ids,Integer userId,String name) {
log.info("volunteer-service[]addUserVoluteer[]getList[]input.param.queryVo:" + ids,userId,name);
return staffUserVipService.addUserVolunteer(ids,userId,name);
}
} }
...@@ -9,14 +9,12 @@ import cn.wisenergy.model.dto.UserInfoDto; ...@@ -9,14 +9,12 @@ import cn.wisenergy.model.dto.UserInfoDto;
import cn.wisenergy.model.vo.UserInfoVo; import cn.wisenergy.model.vo.UserInfoVo;
import cn.wisenergy.model.vo.UserQueryVo; import cn.wisenergy.model.vo.UserQueryVo;
import cn.wisenergy.model.vo.UserShowVo; import cn.wisenergy.model.vo.UserShowVo;
import cn.wisenergy.model.vo.UserVipCommitVo;
import cn.wisenergy.service.app.UserService; import cn.wisenergy.service.app.UserService;
import cn.wisenergy.web.config.JwtConfig; import cn.wisenergy.web.config.JwtConfig;
import cn.wisenergy.web.shiro.JwtUtil; import cn.wisenergy.web.shiro.JwtUtil;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -169,4 +167,13 @@ public class UserController { ...@@ -169,4 +167,13 @@ public class UserController {
return userService.createExcel(userQueryVo,response); return userService.createExcel(userQueryVo,response);
} }
@ApiOperation(value = "添加Vip客户",notes = "添加Vip客户",httpMethod = "POST")
@ApiModelProperty(name = "userVipCommitVo",value = "vip客户信息",dataType = "UserVipCommitVo")
@PostMapping("/add")
public R<UserInfoVo> addUserVip(@RequestBody UserVipCommitVo userVipCommitVo){
log.info("UserController[].addUserVip[].input.param:"+userVipCommitVo);
return userService.commitUserVipInfo(userVipCommitVo);
}
} }
...@@ -119,4 +119,18 @@ public class UserLoginController extends BaseController { ...@@ -119,4 +119,18 @@ public class UserLoginController extends BaseController {
return userLoginService.smsResetPassword(userVo); return userLoginService.smsResetPassword(userVo);
} }
@ApiOperation(value = "VIP用户注册", notes = "VIP用户注册", httpMethod = "POST")
@ApiImplicitParam(name = "userVo", value = "vip用户信息", dataType = "UserRegisterVo")
@PostMapping("/registerVip")
public R<UserInfoVo> registerVip(@RequestBody UserRegisterVo userVo) {
log.info("volunteer-service[]UserLongController[]registerVip[]input.param.userVo:" + userVo);
if (null == userVo || StringUtils.isBlank(userVo.getPhone()) ||
null == userVo.getSource() || null == userVo.getScene()) {
return R.error("入参为空!");
}
return userLoginService.registerVip(userVo);
}
} }
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