Commit 83167f2b authored by codezwjava's avatar codezwjava

专属客服功能升级

parent 1ecc72e4
...@@ -2,6 +2,7 @@ package cn.wisenergy.mapper; ...@@ -2,6 +2,7 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.CustomerService; import cn.wisenergy.model.app.CustomerService;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 专属客服对应表 * 专属客服对应表
...@@ -14,4 +15,11 @@ public interface CustomerServiceMapper extends BaseMapper<CustomerService> { ...@@ -14,4 +15,11 @@ public interface CustomerServiceMapper extends BaseMapper<CustomerService> {
* @return * @return
*/ */
CustomerService randService(); CustomerService randService();
/**
* 根据wechatId查询专属客服
* @param customerServiceId
* @return
*/
CustomerService selectbyWeChatId(@Param("customerServiceId") String customerServiceId);
} }
...@@ -48,4 +48,14 @@ ...@@ -48,4 +48,14 @@
order by rand() limit 1 order by rand() limit 1
</select> </select>
<select id="selectbyWeChatId" parameterType="string" resultType="cn.wisenergy.model.app.CustomerService">
select
<include refid="cols_all"/>
from
<include refid="table"/>
<where>
wechat_id = #{customerServiceId}
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<result column="fans_id" property="fansId"/> <result column="fans_id" property="fansId"/>
<result column="invite_code" property="inviteCode"/> <result column="invite_code" property="inviteCode"/>
<result column="be_invited_code" property="beInvitedCode"/> <result column="be_invited_code" property="beInvitedCode"/>
<result column="customer_service_id" property="customerServiceId"/>
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
</resultMap> </resultMap>
...@@ -29,12 +30,12 @@ ...@@ -29,12 +30,12 @@
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code, user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
be_invited_code,create_time,update_time be_invited_code,customer_service_id,create_time,update_time
</sql> </sql>
<sql id="vals"> <sql id="vals">
#{userId},#{password},#{headImage},#{userLevel},#{crossBorderLine},#{idCardNumber},#{fansNickname},#{fansId},#{inviteCode}, #{userId},#{password},#{headImage},#{userLevel},#{crossBorderLine},#{idCardNumber},#{fansNickname},#{fansId},#{inviteCode},
#{beInvitedCode},now(),now() #{beInvitedCode},#{customerServiceId},now(),now()
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
...@@ -48,6 +49,7 @@ ...@@ -48,6 +49,7 @@
<if test="fansId != null">fans_id =#{fansId},</if> <if test="fansId != null">fans_id =#{fansId},</if>
<if test="inviteCode != null">invite_code =#{inviteCode},</if> <if test="inviteCode != null">invite_code =#{inviteCode},</if>
<if test="beInvitedCode != null">be_invited_code = #{beInvitedCode},</if> <if test="beInvitedCode != null">be_invited_code = #{beInvitedCode},</if>
<if test="customerServiceId != null">customer_service_id = #{customerServiceId},</if>
update_time =now() update_time =now()
</sql> </sql>
...@@ -63,6 +65,7 @@ ...@@ -63,6 +65,7 @@
<if test="fansId != null">and fans_id =#{fansId}</if> <if test="fansId != null">and fans_id =#{fansId}</if>
<if test="inviteCode != null">and invite_code =#{inviteCode}</if> <if test="inviteCode != null">and invite_code =#{inviteCode}</if>
<if test="beInvitedCode != null">and be_invited_code = #{beInvitedCode}</if> <if test="beInvitedCode != null">and be_invited_code = #{beInvitedCode}</if>
<if test="customerServiceId != null">and customer_service_id = #{customerServiceId}</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>
</sql> </sql>
...@@ -122,7 +125,7 @@ ...@@ -122,7 +125,7 @@
<select id="getByUserId" resultType="cn.wisenergy.model.app.User" parameterType="string"> <select id="getByUserId" resultType="cn.wisenergy.model.app.User" parameterType="string">
select select
id,user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code, id,user_id,password,head_image,user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
be_invited_code,create_time,update_time be_invited_code,customer_service_id,create_time,update_time
from from
user_info user_info
<where> <where>
......
...@@ -21,7 +21,7 @@ public class CustomerService implements Serializable { ...@@ -21,7 +21,7 @@ public class CustomerService implements Serializable {
@ApiModelProperty(name = "id", value = "主键id") @ApiModelProperty(name = "id", value = "主键id")
private int id; private int id;
/**wechatImgUrl /**
* 专属客服id(微信号) * 专属客服id(微信号)
*/ */
@ApiModelProperty(name = "wechatId", value = "专属客服id(微信号)") @ApiModelProperty(name = "wechatId", value = "专属客服id(微信号)")
......
...@@ -90,6 +90,12 @@ public class User implements Serializable{ ...@@ -90,6 +90,12 @@ public class User implements Serializable{
@ApiModelProperty(name = "be_invited_code", value = "推荐人邀请码") @ApiModelProperty(name = "be_invited_code", value = "推荐人邀请码")
private String beInvitedCode; private String beInvitedCode;
/**
* 专属客服id
*/
@ApiModelProperty(name = "customerServiceId", value ="专属客服id" )
private String customerServiceId;
/** /**
* 创建时间 * 创建时间
*/ */
......
...@@ -9,7 +9,11 @@ import java.io.IOException; ...@@ -9,7 +9,11 @@ import java.io.IOException;
import java.util.Map; import java.util.Map;
public interface CustomerServiceService { public interface CustomerServiceService {
CustomerService getServiceByRand(); /**
* 获取专属客服
* @return
*/
CustomerService getServiceByRand(String userId);
void setWeChatQRImg(String wechatId, String file); void setWeChatQRImg(String wechatId, String file);
......
...@@ -2,13 +2,17 @@ package cn.wisenergy.service.app.impl; ...@@ -2,13 +2,17 @@ package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R; import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.CustomerServiceMapper; import cn.wisenergy.mapper.CustomerServiceMapper;
import cn.wisenergy.mapper.UsersMapper;
import cn.wisenergy.model.app.CustomerService; import cn.wisenergy.model.app.CustomerService;
import cn.wisenergy.model.app.User;
import cn.wisenergy.service.app.CustomerServiceService; import cn.wisenergy.service.app.CustomerServiceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.yaml.snakeyaml.events.Event;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
...@@ -24,12 +28,29 @@ public class CustomerServiceServiceImpl implements CustomerServiceService { ...@@ -24,12 +28,29 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
@Autowired @Autowired
private CustomerServiceMapper customerServiceMapper; private CustomerServiceMapper customerServiceMapper;
@Autowired
private UsersMapper usersMapper;
@Value("${uploadFile.location}") @Value("${uploadFile.location}")
private String uploadQRImagesLocation; private String uploadQRImagesLocation;
@Override @Override
public CustomerService getServiceByRand(){ public CustomerService getServiceByRand(String userId){
return customerServiceMapper.randService();
User byUserId = usersMapper.getByUserId(userId);
String customerServiceId = byUserId.getCustomerServiceId();
if (null == customerServiceId){
CustomerService customerService = customerServiceMapper.randService();
String wechatImgUrl = customerService.getWechatId();
byUserId.setCustomerServiceId(wechatImgUrl);
usersMapper.updateById(byUserId);
return customerService;
}else {
CustomerService customerService = customerServiceMapper.selectbyWeChatId(customerServiceId);
return customerService;
}
} }
@Override @Override
......
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.mapper.UsersMapper;
import cn.wisenergy.model.app.CustomerService; import cn.wisenergy.model.app.CustomerService;
import cn.wisenergy.service.app.CustomerServiceService; import cn.wisenergy.service.app.CustomerServiceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -27,9 +28,9 @@ public class CustomerServiceController { ...@@ -27,9 +28,9 @@ public class CustomerServiceController {
@ApiOperation(value = "获取专属客服", notes = "获取专属客服") @ApiOperation(value = "获取专属客服", notes = "获取专属客服")
@GetMapping("/service") @GetMapping("/service")
public R getServiceByRand(){ public R getServiceByRand(String userId){
try { try {
CustomerService serviceByRand = customerServiceService.getServiceByRand(); CustomerService serviceByRand = customerServiceService.getServiceByRand(userId);
String wechatImgUrl = serviceByRand.getWechatImgUrl(); String wechatImgUrl = serviceByRand.getWechatImgUrl();
return R.ok(wechatImgUrl); return R.ok(wechatImgUrl);
}catch (Exception e){ }catch (Exception e){
......
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