Commit 83167f2b authored by codezwjava's avatar codezwjava

专属客服功能升级

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