Commit 4d746cf2 authored by 谢希宇's avatar 谢希宇

Aidea product update by Strive Date 2020-10-14

parent 76ab3098
......@@ -120,13 +120,13 @@ public class MobileOilController {
record.setType("0");
record.setDescription("机油大转盘");
String oilSum="0";
if(StringUtils.isNotBlank(member.getOilSum())){
oilSum=member.getOilSum();
}
BigDecimal a = new BigDecimal(oilSum);
BigDecimal b = new BigDecimal(obj.getString("amount"));
BigDecimal c = a.add(b);
member.setOilSum(c.toString());
// if(StringUtils.isNotBlank(member.getOilSum())){
// oilSum=member.getOilSum();
// }
// BigDecimal a = new BigDecimal(oilSum);
// BigDecimal b = new BigDecimal(obj.getString("amount"));
// BigDecimal c = a.add(b);
// member.setOilSum(c.toString());
oilRecordService.saveTran(record,member);
}
}
......
......@@ -17,6 +17,15 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cftech</groupId>
<artifactId>order-module</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cftech</groupId>
<artifactId>member-module</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -2,38 +2,57 @@ package com.cftech.consultsheet.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cftech.base.org.model.Qyuser;
import com.cftech.base.org.service.QyuserService;
import com.cftech.consultsheet.dao.ConsultSheetMapper;
import com.cftech.consultsheet.model.ConsultSheet;
import com.cftech.consultsheet.service.ConsultSheetService;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort;
import com.cftech.core.util.Constants;
import com.cftech.core.util.StringUtils;
import com.cftech.member.model.Member;
import com.cftech.member.service.MemberService;
import com.cftech.order.service.OrderService;
import com.cftech.sys.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 咨询单ServiceImpl
*
* @author Licc
* @date: 2020-09-22 12:06
*/
* 咨询单ServiceImpl
*
* @author Licc
* @date: 2020-09-22 12:06
*/
@Service("consultSheetService")
public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> implements ConsultSheetService {
@Autowired
@Qualifier("consultSheetMapper")
private ConsultSheetMapper consultSheetMapper;
@Autowired
@Qualifier("consultSheetMapper")
private ConsultSheetMapper consultSheetMapper;
@Override
public GenericDao<ConsultSheet> getGenericMapper() {
return consultSheetMapper;
}
@Autowired
private OrderService orderService;
@Autowired
private MemberService memberService;
@Autowired
private QyuserService qyuserService;
@Override
public GenericDao<ConsultSheet> getGenericMapper() {
return consultSheetMapper;
}
@Override
......@@ -43,16 +62,18 @@ return consultSheetMapper;
params.put("offset", page > 0 ? page : 0);
params.put("limit", pageSize > 0 ? pageSize : 0);
params.put("sort", sort);
params.put("id",id);
params.put("id", id);
return consultSheetMapper.fetchSearchByPage(params);
}
@Transactional
@Override
public JSONObject pollingConsultSheet(ConsultSheet consultSheet) {
JSONObject retObj = new JSONObject();
try {
if (consultSheetMapper.save(consultSheet) > 0) {
memberProcess(consultSheet.getOpenId(), consultSheet);
}
retObj.put("errerNo", 0);
retObj.put("data", 0);
} catch (Exception e) {
......@@ -63,4 +84,100 @@ return consultSheetMapper;
}
return retObj;
}
/**
* 咨询单分配流程
* 复购/首次分配
* @return
*/
private boolean memberProcess(String openid, ConsultSheet consultSheet) {
//1、查询用户是否复购
Conds conds = new Conds();
conds.equal("o.del_flag", Constants.DEL_FLAG_0);
conds.equal("o.openid", openid);
conds.in("o.status", new String[]{"2", "3", "4"});//2 待发货,3:待收货 4:待付款
int count = orderService.count(conds);
if (count > 0) { //复购
Conds memberConds = new Conds();
memberConds.equal("del_flag", Constants.DEL_FLAG_0);
memberConds.equal("open_id", openid);
Member member = memberService.fetchSearchByConds(conds);
String customerId = member.getCustomerId();
Conds userConds = new Conds();
userConds.equal("t.del_flag", Constants.DEL_FLAG_0);
userConds.equal("t.id", customerId);
Qyuser user = qyuserService.fetchSearchByConds(userConds);
if (user.getPeakVal() > 0) {//客服峰值大于0
consultSheet.setCustomerId(user.getId());
} else {//普通轮询
firstCustomerProcess(consultSheet);
}
String doctorId = member.getDoctorId();
userConds.equal("t.id", doctorId);
user = qyuserService.fetchSearchByConds(userConds);
if (user.getPeakVal() > 0) {//药师峰值大于0
consultSheet.setDoctorId(user.getId());
} else {//普通轮询
firstCustomerProcess(consultSheet);
}
} else {//首次购买
firstCustomerProcess(consultSheet);
}
return consultSheetMapper.update(consultSheet) > 0;
}
/**
* 咨询单首次购买流程
* @return
*/
private boolean firstCustomerProcess(ConsultSheet consultSheet) {
Conds conds = new Conds();
conds.equal("t.del_flag", Constants.DEL_FLAG_0);
conds.equal("t.user_type", "0");
conds.greatEqual("t.peak_val", 0);
Sort sort = new Sort("t.assigned", OrderType.ASC);
List<Qyuser> users = qyuserService.fetchSearchByPage(conds, sort, 0, 0);
if (users.size() == 1) {
consultSheet.setCustomerId(users.get(0).getId());
} else if (users.size() > 1) {
//当前分配
for (Qyuser user: users) {
if (user.getPeakVal() < user.getAssigned()) {
consultSheet.setCustomerId(user.getId());
//增加分配人数
user.setAssigned(user.getAssigned() + 1);
qyuserService.updateAssigned(user);
break;
}
}
//峰值已满
if (consultSheet.getCustomerId() == null) {
Conds unconds = new Conds();
unconds.equal("t.del_flag", Constants.DEL_FLAG_0);
unconds.equal("t.user_type", "0");
unconds.greatEqual("t.peak_val", 0);
Sort unsort = new Sort("t.un_assigned", OrderType.ASC);
users = qyuserService.fetchSearchByPage(conds, unsort, 0, 0);
if (users.size() > 0) {
Qyuser user = users.get(0);
consultSheet.setCustomerId(user.getId());
//增加分配人数
user.setAssigned(user.getAssigned() + 1);
qyuserService.updateAssigned(user);
} else {
consultSheet.setDescription("未有对应的咨询单处理人员");
}
}
} else {
consultSheet.setDescription("未有对应的咨询单处理人员");
}
return true;
}
}
\ No newline at end of file
......@@ -28,7 +28,7 @@
<result column="create_by" property="createBy"/>
<result column="update_by" property="updateBy"/>
<result column="confirm" property="confirm"/>
<result column="drugs_num" property="drugsNum"/>
<result column="drugs_num" property="drugsNum"/>
<result column="product_number" property="productNumber"/>
<result column="product_name" property="productName"/>
<result column="address" property="address"/>
......@@ -73,7 +73,6 @@
</resultMap>
<sql id="sqlWhere">
<if test="conds!=null">
<trim prefix="WHERE" prefixOverrides="AND|OR">
......@@ -226,14 +225,14 @@
<include refid="sqlColumnProduct"/>
from
t_order_details d
LEFT JOIN t_order o ON d.order_id =o.id
LEFT JOIN t_order o ON d.order_id =o.id
LEFT JOIN t_aidea_product t ON d.drugs_id = t.id
WHERE
d.order_id =#{id}
</select>
<select id="count" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM (select count(1) from t_order o
SELECT COUNT(1) FROM (select count(1) from t_order o
LEFT JOIN t_shipping_address s ON o.address_id = s.id
LEFT JOIN t_order_details d ON o.id = d.order_id
LEFT JOIN t_aidea_product t ON d.drugs_id = t.id
......@@ -241,7 +240,7 @@
LEFT JOIN area b ON s.city_id = b.areaid
LEFT JOIN area c ON s.area_id = c.areaid
<include refid="sqlWhere"/>
GROUP BY o.id
GROUP BY o.id
) b
</select>
......@@ -249,7 +248,7 @@
<select id="fetchSearchByPage" parameterType="java.util.Map" resultMap="resultMapList">
SELECT
<include refid="sqlColumns"/>
FROM t_order o
FROM t_order o
LEFT JOIN t_shipping_address s ON o.address_id = s.id
LEFT JOIN t_order_details d ON o.id = d.order_id
LEFT JOIN t_aidea_product t ON d.drugs_id = t.id
......@@ -259,7 +258,7 @@
LEFT JOIN t_qyuser q ON o.service_id = q.id AND o.doctor_id = q.id
LEFT JOIN `user` u ON u.userid = q.id
<include refid="sqlWhere"/>
<if test="id!=null"> ${id} = b.id </if>
<if test="id!=null">${id} = b.id</if>
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
......@@ -401,11 +400,11 @@
<update id="updateOrder" parameterType="java.util.Map">
update t_order
<set>
<if test="orderAmount!=null" >
<if test="orderAmount!=null">
order_amount = #{orderAmount}
</if>
</set>
where id= #{id}
where id= #{id}
</update>
</mapper>
\ No newline at end of file
......@@ -125,7 +125,7 @@
maxlength="200" placeholder="生日"
>
</div>
<div class="form-group form-md-line-input" id="other">
<div class="form-group form-md-line-input" id="email">
</div>
......
......@@ -10,7 +10,7 @@
<result column="phone" property="phone"/>
<result column="imageurl" property="imageurl"/>
<result column="cardid" property="cardid"/>
<result column="other" property="other"/>
<result column="email" property="email"/>
<result column="member_id" property="memberId"/>
<result column="accounts_id" property="accountsId"/>
<result column="del_flag" property="delFlag"/>
......@@ -25,11 +25,11 @@
<result column="level" property="level"/>
<result column="area" property="area"/>
<result column="fanss_store_id" property="fanssStoreId"/>
<result column="oilSum" property="oilSum"/>
<result column="doctor_id" property="doctorId"/>
<result column="invitcode" property="invitcode"/>
<result column="compan" property="compan"/>
<result column="position" property="position"/>
<result column="member_uid" property="member_uid"/>
<result column="customer_id" property="customerId"/>
</resultMap>
<resultMap id="resultMapDto" type="com.cftech.member.model.MemberDto">
......@@ -84,7 +84,7 @@
phone,
imageurl,
cardid,
other,
email,
member_id,
accounts_id,
del_flag,
......@@ -102,10 +102,10 @@
level,
area,
fanss_store_id,
oilSum,
doctor_id,
invitcode,
compan,
member_uid
customer_id
</sql>
......@@ -124,7 +124,7 @@
#{phone, jdbcType=VARCHAR},
#{imageurl, jdbcType=VARCHAR},
#{cardid, jdbcType=VARCHAR},
#{other, jdbcType=CLOB},
#{email, jdbcType=VARCHAR},
#{memberId, jdbcType=VARCHAR},
#{accountsId, jdbcType=BIGINT},
#{delFlag, jdbcType=TINYINT},
......@@ -142,10 +142,10 @@
#{level,jdbcType=VARCHAR},
#{area,jdbcType=VARCHAR},
#{fanssStoreId,jdbcType=BIGINT},
#{oilSum,jdbcType=VARCHAR},
#{doctorId,jdbcType=VARCHAR},
#{invitcode,jdbcType=VARCHAR},
#{compan,jdbcType=VARCHAR},
#{member_uid}
#{customer_id, jdbc=VARCHAR}
)
</insert>
......@@ -157,7 +157,7 @@
t.phone,
t.imageurl,
t.cardid,
t.other,
t.email,
t.member_id,
t.accounts_id,
t.del_flag,
......@@ -173,7 +173,7 @@
offline.sex,
t.level,
t.area,
t.fanss_store_id,oilSum,
t.fanss_store_id,t.doctor_id,
t.invitcode,t.compan,
offline.name memberName,
offline.phone memberPhone,
......@@ -227,7 +227,7 @@
member.invitcode,
member.compan,
member.sex,
member.member_uid
member.customer_id
FROM
wx_mp_member member
<include refid="sqlWhere"/>
......@@ -259,8 +259,8 @@
<if test="cardid != null">
cardid = #{cardid, jdbcType=VARCHAR},
</if>
<if test="other != null">
other = #{other, jdbcType=CLOB},
<if test="email != null">
email = #{email, jdbcType=VARCHAR},
</if>
<if test="memberId != null">
member_id = #{memberId, jdbcType=VARCHAR},
......@@ -310,8 +310,8 @@
<if test="fanssStoreId != null">
fanss_store_id = #{fanssStoreId, jdbcType=VARCHAR},
</if>
<if test="oilSum != null">
oilSum = #{oilSum, jdbcType=VARCHAR}
<if test="doctorId != null">
doctor_id = #{doctorId, jdbcType=VARCHAR}
</if>
<if test="invitcode != null">
invitcode = #{invitcode, jdbcType=VARCHAR}
......@@ -351,7 +351,7 @@
<include refid="sqlWhere"/>
</select>
<select id="memberFormation" parameterType="java.lang.Long" resultType="com.cftech.member.model.MemberVO">
SELECT CONCAT(surname,`name`) AS memberName,sex,birthday,imageurl,other AS mailbox,phone
SELECT CONCAT(surname,`name`) AS memberName,sex,birthday,imageurl,email AS mailbox,phone
FROM wx_mp_member WHERE id= #{id}
</select>
</mapper>
\ No newline at end of file
......@@ -64,6 +64,7 @@ public class Member implements Serializable {
/*微信openID*/
//@ExportConfig(value = "openId", width = 100)
private String openId;
private String position;
/**
......@@ -83,8 +84,8 @@ public class Member implements Serializable {
private String area;
/* 其他信息 */
//@ExportConfig(value = "完善信息", width = 100)
private String other;
@ExportConfig(value = "Email", width = 100)
private String email;
/**绑定的门店*/
private String storeid;
......@@ -94,10 +95,8 @@ public class Member implements Serializable {
* */
private Long fanssStoreId;
/**
* 机油总数
*/
protected String oilSum;
/**
*会员卡名字
......@@ -116,45 +115,31 @@ public class Member implements Serializable {
/**
* 会员邀请码
*/
@ExportConfig(value = "邀请码", width = 100,showLevel =1 )
private String invitcode;
private String compan;
/**
* 公司名称
* 所属客服id
*/
@ExportConfig(value = "公司名称", width = 100)
private String compan;
//private String member_uid;
private String customerId;
/**
* 所属药师id
*/
//private String oilSum;
private String doctorId;
/**
* 会员来源: 1:普通关注 2:医师二维码 3:客服二维码 4:医生二维码 5:组织二维码
*/
private String source;
//人员唯一识别号
private String member_uid;
// public void setCardid(String cardid) {
// if(StringUtils.isNotBlank(cardid)){
// int sexNumber = 0;
// String temStr="";
// if(cardid.length()==18){//二代身份证
// sexNumber= Integer.valueOf(cardid.substring(cardid.length()-2,cardid.length()-1));
// temStr = cardid.substring(6, 14);
// temStr = temStr.substring(0, 4) + "-" + temStr.substring(4, 6) + "-" + temStr.substring(6);
// }else if(cardid.length()==15){//老式一代身份证
// sexNumber= Integer.valueOf(cardid.substring(cardid.length()-1));
// temStr = cardid.substring(6, 12);
// temStr = "19" + temStr;
// temStr = temStr.substring(0, 4) + "-" + temStr.substring(4, 6) + "-" + temStr.substring(6);
// }
// if(sexNumber%2==0){
// this.sex="女";
// }else{
// this.sex="男";
// }
// this.birthday=temStr;
// }
//this.cardid = cardid;
// }
......
......@@ -138,7 +138,7 @@ public class MemberServiceImpl extends GenericServiceImpl<Member> implements Mem
List<Workshop> list = workshopService.selectworkshop(conds,sort,0,0);
if(list!=null&&list.size()>0){
for(Workshop workshop : list){
workshop.setMember_uid(member.getMember_uid());
//workshop.setMember_uid(member.getMember_uid());
workshopService.update(workshop);
}
}
......
......@@ -226,9 +226,9 @@ public class MemberController {
if(workshop!=null){
Member member = new Member();
member.setStatus("1");
member.setOilSum("0");
//member.setOilSum("0");
member.setNumber(codingruleUtils.getNumber(accountsId, Member.class.getName()));
member.setMember_uid(UUID.randomUUID().toString());
//member.setMember_uid(UUID.randomUUID().toString());
member.setSurname(workshop.getSurname());
member.setName(workshop.getFirst_name());
member.setPhone(workshop.getPhone());
......@@ -237,7 +237,7 @@ public class MemberController {
member.setInvitcode(code);
member.setAccountsId(accountsId);
memberService.save(member);
workshop.setMember_uid(member.getMember_uid());
//workshop.setMember_uid(member.getMember_uid());
workshop.setStatus("1");
workshopService.update(workshop);
}else{
......
......@@ -97,7 +97,7 @@ public class MobileWxJsController {
memberConds.equal("accounts_id", mpAccount.getId());
Member member = memberService.fetchSearchByConds(memberConds);
if(member!=null){ //已注册
rtnJson.put("memberUid",member.getMember_uid());
//rtnJson.put("memberUid",member.getMember_uid());
}else{//用户未注册
rtnJson.put("memberUid","");
rtnJson.put("errorCode", 1);
......
......@@ -79,6 +79,28 @@
</div>
</div>
<!-- 设置峰值弹出窗 -->
<div id="peakButtom" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">设置峰值</h4>
</div>
<!-- dialog body -->
<div class="modal-body">
<input type="number" class="form-control select2" id="peakVal" name="peakVal" placeholder="请输入一个正整数"></input>
<input type="hidden" id="peakId">
</div>
<div style="text-align: center;padding-bottom: 20px;">
<button style="width: 100px;" type="button" class="btn btn-primary" onclick="submitPeakVal()">确定</button>
<button style="width: 100px;" type="button" class="btn btn-default" data-dismiss="modal" aria-label="Close">取消</button>
</div>
<!-- dialog buttons -->
</div>
</div>
</div>
<!-- Main content -->
<section class="content">
......@@ -239,7 +261,7 @@
+ minute + ":" + second;
}
if($("#logText").html()!=null && $("#logText").html()!="" &&$("#logText").html()!="${text}"){
if($("#logText").html()!=null && $("#logText").html()!="" && $("#logText").html()!="${text}"){
$("#myModal").modal('show');
}
......@@ -350,20 +372,19 @@
"mRender": function (a, b, c, d) {//a表示id对应的值,c表示当前记录行对象
var html = '#if($shiro.hasPermission("sys:qyuser:edit"))';//
var html = '<div class="btn-group">\n' +
' <button type="button" class="btn btn-success btn-flat">操作</button>\n' +
' <button type="button" class="btn btn-success btn-flat dropdown-toggle" data-toggle="dropdown">\n' +
' <span class="caret"></span>\n' +
' <span class="sr-only">Toggle Dropdown</span>\n' +
' </button>\n' +
' <ul class="dropdown-menu" role="menu">\n';
'<button type="button" class="btn btn-success btn-flat">操作</button>\n' +
'<button type="button" class="btn btn-success btn-flat dropdown-toggle" data-toggle="dropdown">\n' +
'<span class="caret"></span>\n' +
'<span class="sr-only">Toggle Dropdown</span>\n' +
'</button>\n' +
'<ul class="dropdown-menu" role="menu">\n';
html += "<li><a href=#springUrl('/a/qyuser/form?id=" + a +"') >修改</a></li>";
if (c.userType == '0' || c.userType == '1' || c.userType == '2') {
html += "<li><a href='javascript:bindQrCode(" + a + ", "+ c.userType +")' >绑定二维码</a></li>";
html += "<li><a href='javascript:peakVal(" + a + ")' >设置患者分配峰值</a></li>";
if (c.qrcode != null)
html += "<li><a href='javascript:unBindQrCode(" + a + ", "+ c.userType +")' >取消绑定二维码</a></li>";
html += "<li><a href='javascript:peakVal(" + a + ")' data-target='#foo'>设置患者分配峰值</a></li>";
}
if (c.qrcode != null)
html += "<li><a href='javascript:unBindQrCode(" + a + ", "+ c.userType +")' >取消绑定二维码</a></li>";
html += '<li><a href="javascript:removeData(' + a + ')" >删除</a></li>#end';
html+= '</ul></div>';
return html;
......@@ -429,9 +450,14 @@
}
function peakVal(id) {
var setPeakValUrl = "#springUrl('/a/qyuser/unBindQrcode?type="+type+"')";
$("#peakButtom").modal('show');
$("#peakId").val(id);
}
function submitPeakVal() {
var setPeakValUrl = "#springUrl('/a/qyuser/setPeakVal')";
Cfapp.confirm({
message: "确定要解除二维码绑定吗",
message: "确认提交峰值?",
btnoktext: "确定",
btncanceltext: "取消",
success: function () {
......@@ -439,7 +465,7 @@
"type": "post",
"url": setPeakValUrl,
"dataType": "json",
"data": {userId: id,_csrf_header:csrfheader.value,_csrf:csrftoken.value}, //以json格式传递
"data": {id: $("#peakId").val(), peakVal: $("#peakVal").val(), _csrf_header:csrfheader.value, _csrf:csrftoken.value}, //以json格式传递
"success": function (data) {
if (data.errorNo == 0) {
Cfapp.alert({
......@@ -461,8 +487,7 @@
});
},
cancel: function () {
$(".modal-backdrop").fadeOut();
$("#peakButtom").modal('hide');
}
})
}
......
......@@ -66,4 +66,17 @@ public interface QyuserMapper extends GenericDao<Qyuser> {
List<Qyuser> getLogInfo(Map<String, Object> params);
/**
* 获取轮询的人员(药师、医生)且通过峰值排序
* @return
*/
List<Qyuser> fetchPollingData(String type);
/**
* 更新未超过峰值/超过峰值,分配咨询单数量
* @param user
* @return
*/
boolean updateAssigned(Qyuser user);
}
......@@ -28,6 +28,8 @@
<result column="update_by" property="updateBy" />
<result column="user_type" property="userType" />
<result column="peak_val" property="peakVal" />
<result column="assigned" property="assigned"/>
<result column="un_assigned" property="unAssigned"/>
</resultMap>
<resultMap id="resultMapVO" type="com.cftech.base.org.model.vo.QyuserVO">
......@@ -79,13 +81,13 @@
<sql id="sqlColumns">
id, name, qrcode, avatar, mobile, email, role, wxno, gender, accounts_id,
position_id, store_id, store_name, wxuser_id, org_id, tag_ids, status, create_time,
update_time, description, del_flag, create_by, update_by
update_time, description, del_flag, create_by, update_by, user_type, peak_val, assigned, un_assigned
</sql>
<sql id="sqlColumnsT">
t.id, t.name, t.qrcode, t.avatar, t.mobile, t.email,t.role, t.wxno, t.gender, t.accounts_id,
t.position_id, t.store_id, t.store_name, t.wxuser_id, t.org_id, t.tag_ids, t.status, t.create_time,
t.update_time, t.description, t.del_flag, t.create_by, t.update_by
t.update_time, t.description, t.del_flag, t.create_by, t.update_by, user_type, peak_val, assigned, un_assigned
</sql>
<insert id="save" parameterType="com.cftech.base.org.model.Qyuser"
......@@ -98,7 +100,7 @@
wxuser_id, org_id, tag_ids,
status, create_time, update_time,
description, del_flag, create_by,
update_by, user_type
update_by, user_type, peak_val, assigned, un_assigned
)
values
(
......@@ -115,7 +117,7 @@
#{status,
jdbcType=VARCHAR}, now(), now(), #{description, jdbcType=VARCHAR},
#{delFlag, jdbcType=TINYINT}, #{createBy, jdbcType=BIGINT},
#{updateBy, jdbcType=BIGINT}, #{userType, jdbcType=VARCHAR}
#{updateBy, jdbcType=BIGINT}, #{userType, jdbcType=VARCHAR}, #{peakVal, jdbcType=BIGINT}, #{assigned, jdbcType=BIGINT}, #{unAssigned, jdbcType=BIGINT}
)
</insert>
......@@ -123,7 +125,7 @@
SELECT
t.id, t.name, t.qrcode, t.avatar, t.mobile, t.email, t.role, t.wxno, t.gender, t.accounts_id,
t.store_id, t.store_name, t.wxuser_id, t.org_id, t.tag_ids, t.status, t.create_time,
t.update_time, t.description, t.del_flag, t.create_by, t.update_by,u.username loginName
t.update_time, t.description, t.del_flag, t.create_by, t.update_by,u.username loginName, t.user_type, t.peak_val, t.assigned, t.un_assigned
FROM t_qyuser t
left join user u on u.userid=t.id
WHERE t.id=#{id}
......@@ -144,7 +146,7 @@
SELECT
t.id, t.name, t.qrcode, t.avatar, t.mobile, t.email, t.role, t.wxno, t.gender, t.accounts_id,
t.store_id, t.store_name, t.wxuser_id, t.org_id, t.tag_ids, t.status, t.create_time,
t.update_time, t.description, t.del_flag, t.create_by, t.update_by,u.username loginName
t.update_time, t.description, t.del_flag, t.create_by, t.update_by,u.username loginName, t.user_type, t.peak_val, t.assigned, t.un_assigned
FROM t_qyuser t
left join t_orgunit o on o.id = t.org_id
left join user u on u.userid=t.id
......@@ -228,6 +230,18 @@
<if test="updateBy != null">
update_by = #{updateBy, jdbcType=BIGINT},
</if>
<if test="userType != null">
user_type = #{userType, jdbcType=VARCHAR},
</if>
<if test="peakVal != null">
peak_val = #{peakval, jdbcType=BIGINT},
</if>
<if test="assigned != null">
assigned = #{assigned, jdbcType=BIGINT},
</if>
<if test="unAssigned != null">
un_assigned = #{unAssigned, jdbcType=BIGINT},
</if>
</set>
where id=#{id,jdbcType=BIGINT}
</update>
......@@ -245,7 +259,7 @@
t.name name, t.mobile mobile, t.wxno wxno, t.email email,t.description,
t.wxuser_id
wxuser_id,
u.username loginName, t.user_type, t.gender, qrcode.ticket qrcode
u.username loginName, t.user_type, t.gender, qrcode.ticket qrcode, t.user_type, t.peak_val, t.assigned, t.un_assigned
FROM t_qyuser t
left join t_orgunit o on o.id = t.org_id
left join user u on u.userid = t.id
......@@ -339,6 +353,18 @@
<if test="updateBy != null">
update_by = #{updateBy, jdbcType=BIGINT},
</if>
<if test="userType != null">
user_type = #{userType, jdbcType=VARCHAR},
</if>
<if test="peakVal != null">
peak_val = #{peakval, jdbcType=BIGINT},
</if>
<if test="assigned != null">
assigned = #{assigned, jdbcType=BIGINT},
</if>
<if test="unAssigned != null">
un_assigned = #{unAssigned, jdbcType=BIGINT},
</if>
</set>
<include refid="sqlWhere" />
</update>
......@@ -457,15 +483,33 @@
</foreach>
</update>
<select id="getLogInfo" parameterType="java.util.Map" resultMap="resultMap">
select b.id,b.name,b.store_id, b.role,c.name store_name,b.qrcode from user a INNER JOIN t_qyuser b on b.id = a.userid
INNER JOIN t_dc_store c on c.id = b.store_id
where a.id = #{id} and a.delflag = '0'
</select>
<!-- 获取轮询的人员(药师、医生)且通过峰值排序 -->
<select id="fetchPollingData" parameterType="java.lang.String" resultMap="resultMap">
SELECT t.* FROM t_qyuser t
<if test="type=0">t.user_type = '0'</if>
<if test="type=1">t.user_type = '1'</if>
ORDER BY t.peak_val DESC
</select>
<update id="updateAssigned" parameterType="com.cftech.base.org.model.Qyuser">
update t_qyuser
<set>
<if test="peakVal != null">
peak_val = #{peakVal, jdbcType=BIGINT},
</if>
<if test="assigned != null">
assigned = #{assigned, jdbcType=BIGINT},
</if>
<if test="unAssigned != null">
un_assigned = #{unAssigned, jdbcType=BIGINT},
</if>
</set>
where id=#{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
......@@ -141,7 +141,11 @@ public class Qyuser implements Serializable {
*/
private String userType;
private String peakVal;
private Long peakVal;
private Long assigned;
private Long unAssigned;
public Qyuser() {
......
......@@ -97,4 +97,15 @@ public interface QyuserService extends GenericService<Qyuser> {
List<Qyuser> getLogInfo(Map<String, Object> params);
/**
* 获取轮询的人员(药师、医生)且通过峰值排序
*/
List<Qyuser> fetchPollingData(String type);
/**
* 更新未超过峰值/超过峰值,分配咨询单数量
* @param user
*/
boolean updateAssigned(Qyuser user);
}
......@@ -138,4 +138,15 @@ public class QyuserServiceImpl extends GenericServiceImpl<Qyuser> implements Qyu
{
return qyuserMapper.getLogInfo(params);
}
@Override
public List<Qyuser> fetchPollingData(String type) {
//判断是否为复购
return qyuserMapper.fetchPollingData(type);
}
@Override
public boolean updateAssigned(Qyuser user) {
return qyuserMapper.updateAssigned(user);
}
}
package com.cftech.core.util;
package com.cftech.base.org.utils;
import com.alibaba.fastjson.JSONArray;
import com.cftech.base.org.model.Qyuser;
import com.cftech.base.org.service.QyuserService;
import com.cftech.core.sql.Conds;
import com.cftech.core.util.Constants;
import com.cftech.core.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* redis 缓存类
* Created by 16444 on 2020/10/19.
......@@ -17,6 +25,9 @@ public class RedisCacheUtils {
@Autowired
private RedisTemplate<String, String> redisTemplates;
@Autowired
private QyuserService qyuserService;
private RedisTemplate<String, String> getConfig() {
StringRedisSerializer strSerializer = new StringRedisSerializer();
redisTemplates.setKeySerializer(strSerializer);
......@@ -37,7 +48,22 @@ public class RedisCacheUtils {
return "";
}
public String findPollingDoctor() {
public String findPollingDoctor(String accountsId) {
JSONArray doctors = null;
String doctorKey = "DOCTOR_QUEUE_" + accountsId;
if (getConfig().hasKey(doctorKey)) {
String userStr = getConfig().opsForValue().get(doctorKey).toString();
if (StringUtils.isBlank(userStr)) {
List<Qyuser> users = qyuserService.fetchPollingData("1");
StringBuffer ids = new StringBuffer();
users.stream().forEach(user -> ids.append(user.getId()+",") );
}
//doctors = JSONArray.parseArray(userArr);
}
return "";
}
......
......@@ -34,6 +34,7 @@ import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
......@@ -76,7 +77,7 @@ public class QyuserController {
//返回列表页面
@RequiresPermissions(value = PermissionSign.QYUSER_VIEW)
@RequestMapping(value = "/list",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
public String qyuserList(HttpServletRequest request, Model model) {
Long accountId = Long.parseLong(qyAccounts);
model.addAttribute("accountId", accountId);
......@@ -85,7 +86,7 @@ public class QyuserController {
//返回编辑页面(新增、修改)
@RequiresPermissions(value = PermissionSign.QYUSER_VIEW)
@RequestMapping(value = "/form",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/form", method = {RequestMethod.GET, RequestMethod.POST})
public String form(HttpServletRequest request, String id, Model model) {
Long accountId = Long.parseLong(qyAccounts);
if (!StringUtils.isEmpty(id)) {
......@@ -114,26 +115,26 @@ public class QyuserController {
//提交编辑页面(新增、修改)
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/formData",method = {RequestMethod.POST})
@RequestMapping(value = "/formData", method = {RequestMethod.POST})
@ResponseBody
public JSONObject qyuserListformData(Qyuser qyuser, Model model, HttpServletRequest request,String terminalIds,String passwordQyUser,String loginNameQyUser) {
public JSONObject qyuserListformData(Qyuser qyuser, Model model, HttpServletRequest request, String terminalIds, String passwordQyUser, String loginNameQyUser) {
Long accountId = Long.parseLong(qyAccounts);
JSONObject rtnJson = new JSONObject();
Long userId = UserUtils.getUser().getId();
Conds userConds = new Conds();
userConds.equal("t.userid",qyuser.getId());
userConds.equal("t.userid", qyuser.getId());
User user = userService.fetchSearchByConds(userConds);
try {
if (qyuser != null && qyuser.getId() != null) {
Conds conds = new Conds();
conds.equal("t.username",loginNameQyUser);
conds.equal("t.delflag",0);
conds.equal("t.state",0);
conds.notEqual("t.id",user.getId());
conds.equal("t.username", loginNameQyUser);
conds.equal("t.delflag", 0);
conds.equal("t.state", 0);
conds.notEqual("t.id", user.getId());
User userExits = userService.fetchSearchByConds(conds);
if(userExits!=null){
if (userExits != null) {
//登录账号重复
rtnJson.put("errorNo", 3);
return rtnJson;
......@@ -144,10 +145,10 @@ public class QyuserController {
// 2017-10-27 取消同步微信企业号标签操作
qyUserUtil.updateQyUser(qyuser);
qyuserService.update(qyuser);
if(!StringUtils.isEmpty(loginNameQyUser)){
if (!StringUtils.isEmpty(loginNameQyUser)) {
user.setUsername(loginNameQyUser);
}
if(!StringUtils.isEmpty(passwordQyUser)){
if (!StringUtils.isEmpty(passwordQyUser)) {
user.setPassword(passwordQyUser);
}
userService.update(user);
......@@ -157,10 +158,10 @@ public class QyuserController {
} else {
Conds conds = new Conds();
conds.equal("t.username", loginNameQyUser);
conds.equal("t.delflag",0);
conds.equal("t.state",0);
conds.equal("t.delflag", 0);
conds.equal("t.state", 0);
User userExits = userService.fetchSearchByConds(conds);
if(userExits!=null){
if (userExits != null) {
//登录账号重复
rtnJson.put("errorNo", 3);
return rtnJson;
......@@ -182,10 +183,10 @@ public class QyuserController {
user.setUserid(qyuser.getId());
user.setDefaultAccId(UserUtils.getmpaccounts(request));
userService.save(user);
//2017-10-27 取消同步微信企业号标签操作 qyTagUtil.syncTag(qyuser);
//2017-10-27 取消同步微信企业号标签操作 qyTagUtil.syncTag(qyuser);
rtnJson.put("errorNo", 2);
}
//取消终端
//取消终端
// String[] terminalStrs = terminalIds.split(",");
// terminalUserService.saveBatchTerminalCommodity(qyuser.getId(), terminalStrs,qyuser.getWxuserId());
} catch (Exception e) {
......@@ -196,7 +197,7 @@ public class QyuserController {
//获取列表数据
@RequiresPermissions(value = PermissionSign.QYUSER_VIEW)
@RequestMapping(value = "/listData",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/listData", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public JSONObject listData(int iDisplayStart, int iDisplayLength, Qyuser qyuser, HttpServletRequest request) {
Long accountId = Long.parseLong(qyAccounts);
......@@ -251,9 +252,9 @@ public class QyuserController {
* @return
*/
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/unBindQrcode",method = {RequestMethod.POST})
@RequestMapping(value = "/unBindQrcode", method = {RequestMethod.POST})
@ResponseBody
public JSONObject unBindQrcode(HttpServletRequest request,Long userId, String type) {
public JSONObject unBindQrcode(HttpServletRequest request, Long userId, String type) {
JSONObject retObj = new JSONObject();
Qyuser qyuser = qyuserService.fetchById(userId);
if (com.cftech.core.util.StringUtils.isNotBlank(qyuser.getQrcode())) {
......@@ -273,11 +274,11 @@ public class QyuserController {
retObj.put("errorNo", "0");
} else {
retObj.put("errorNo", "1");
retObj.put("errorMsg","没有找到绑定的二维码");
retObj.put("errorMsg", "没有找到绑定的二维码");
}
} else {
retObj.put("errorNo", "2");
retObj.put("errorMsg","并未绑定过二维码");
retObj.put("errorMsg", "并未绑定过二维码");
}
//做2方的更新操作
......@@ -293,12 +294,11 @@ public class QyuserController {
}
//删除数据
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/delete",method = {RequestMethod.POST})
@RequestMapping(value = "/delete", method = {RequestMethod.POST})
@ResponseBody
public JSONObject delete(HttpServletRequest request,String id) {
public JSONObject delete(HttpServletRequest request, String id) {
JSONObject rtnJosn = new JSONObject();
try {
Qyuser qyuser = qyuserService.fetchById(id);
......@@ -322,9 +322,9 @@ public class QyuserController {
}
}
Conds conds = new Conds();
conds.equal("userid",id);
conds.equal("userid", id);
User user = userService.fetchSearchByConds(conds);
if(user!=null){
if (user != null) {
user.setDelflag(1);
userService.update(user);
}
......@@ -335,7 +335,8 @@ public class QyuserController {
}
return rtnJosn;
}
@RequestMapping(value = "/exportExcel",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/exportExcel", method = {RequestMethod.GET, RequestMethod.POST})
@RequiresPermissions(value = PermissionSign.QYUSER_VIEW)
public void exportExcel(HttpServletRequest request, HttpServletResponse response, Qyuser qyuser) {
Long accountId = Long.parseLong(qyAccounts);
......@@ -384,14 +385,14 @@ public class QyuserController {
ExcelKit.$Export(QyuserVO.class, response).toExcel(qyusers, "企业人员信息");
}
@RequestMapping(value = "/templateExcel",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/templateExcel", method = {RequestMethod.GET, RequestMethod.POST})
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
public void templateExcel(HttpServletRequest request, HttpServletResponse response) {
// 生成Excel并使用浏览器下载
ExcelKit.$Export(QyuserVO.class, response).toExcel(null, "企业人员信息");
}
@RequestMapping(value = "/importExcel",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/importExcel", method = {RequestMethod.GET, RequestMethod.POST})
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
public String importExcel(HttpServletRequest request, MultipartFile file, Model model) {
Long accountId = Long.parseLong(qyAccounts);
......@@ -416,14 +417,14 @@ public class QyuserController {
Qyuser qyuser = new Qyuser();
qyuser.setAccountsId(accountId);
Conds isConds = new Conds();
isConds.equal("t.mobile",rowData.get(1));
isConds.equal("u.username",rowData.get(4));
isConds.equal("u.delflag",0);
isConds.equal("u.state",0);
isConds.equal("t.mobile", rowData.get(1));
isConds.equal("u.username", rowData.get(4));
isConds.equal("u.delflag", 0);
isConds.equal("u.state", 0);
Qyuser qyuserExits = qyuserService.fetchSearchByConds(isConds);
if(qyuserExits!=null){
stringBuffer.append("重复导入,"+rowData.toString()+"<br/>");
log.info("导入SA人员时出现重复账号,重复账号的行数据是:"+rowData.toString());
if (qyuserExits != null) {
stringBuffer.append("重复导入," + rowData.toString() + "<br/>");
log.info("导入SA人员时出现重复账号,重复账号的行数据是:" + rowData.toString());
return;
}
......@@ -434,12 +435,12 @@ public class QyuserController {
qyuser.setUserType(rowData.get(5));
qyuser.setGender(rowData.get(6));
if (!StringUtils.isEmpty(rowData.get(3).toString())){
if (!StringUtils.isEmpty(rowData.get(3).toString())) {
OrgUnit orgUnit = orgUnitService.findByAccountIdAndNumber(accountId, rowData.get(3).toString());
qyuser.setOrgId(orgUnit.getId());
} else {
stringBuffer.append("组织导入为空,"+rowData.toString()+"<br/>");
log.info("导入SA人员时出现重复账号,重复账号的行数据是:"+rowData.toString());
stringBuffer.append("组织导入为空," + rowData.toString() + "<br/>");
log.info("导入SA人员时出现重复账号,重复账号的行数据是:" + rowData.toString());
return;
}
......@@ -454,8 +455,8 @@ public class QyuserController {
user.setDelflag(0);
user.setUserid(qyuser.getId());
userService.save(user);
}else{
log.info("账号为空,"+rowData.toString()+"<br/>");
} else {
log.info("账号为空," + rowData.toString() + "<br/>");
}
});
} catch (IOException e) {
......@@ -463,13 +464,13 @@ public class QyuserController {
log.error(e.getMessage());
}
model.addAttribute("accountId", accountId);
model.addAttribute("text",stringBuffer.toString());
model.addAttribute("text", stringBuffer.toString());
return "managerqyuser/qyuserlist";
}
@RequiresPermissions(value = PermissionSign.QYUSER_VIEW)
@RequestMapping(value = "/listDataNoAuth",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/listDataNoAuth", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public JSONObject listDataNoAuth(int iDisplayStart, int iDisplayLength, Qyuser qyuser, HttpServletRequest request) {
Long accountId = Long.parseLong(qyAccounts);
......@@ -514,7 +515,7 @@ public class QyuserController {
return rtnJson;
}
@RequestMapping(value = "/sync",method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/sync", method = {RequestMethod.GET, RequestMethod.POST})
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@ResponseBody
public JSONObject sync(HttpServletRequest request, Model model) {
......@@ -528,15 +529,16 @@ public class QyuserController {
/**
* 绑定门店店长
*
* @param request
* @param storeId 门店Id
* @param storeId 门店Id
* @param managerId 店长Id
* @return
*/
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/bindManger",method = {RequestMethod.POST})
@RequestMapping(value = "/bindManger", method = {RequestMethod.POST})
@ResponseBody
public JSONObject bindManger(HttpServletRequest request,Long storeId, Long managerId) {
public JSONObject bindManger(HttpServletRequest request, Long storeId, Long managerId) {
JSONObject retObj = new JSONObject();
Qyuser qyuser = qyuserService.fetchById(managerId);
......@@ -594,11 +596,12 @@ public class QyuserController {
/**
* 绑定门店店长
*
* @param id 人员Id
* @return
*/
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/unBindStore",method = RequestMethod.POST)
@RequestMapping(value = "/unBindStore", method = RequestMethod.POST)
@ResponseBody
public JSONObject unBindStore(Long id) {
JSONObject retObj = new JSONObject();
......@@ -609,13 +612,15 @@ public class QyuserController {
return retObj;
}
/**
* 绑定门店店长
*
* @param employeeIds 人员Ids
* @return
*/
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/unBindEmployee",method = {RequestMethod.POST})
@RequestMapping(value = "/unBindEmployee", method = {RequestMethod.POST})
@ResponseBody
public JSONObject unBindEmployee(Long[] employeeIds) {
JSONObject retObj = new JSONObject();
......@@ -637,9 +642,9 @@ public class QyuserController {
* @return
*/
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/bindQrcode",method = RequestMethod.POST)
@RequestMapping(value = "/bindQrcode", method = RequestMethod.POST)
@ResponseBody
public JSONObject bindQrcode(HttpServletRequest request,Long id, Long wxQrcodeId) {
public JSONObject bindQrcode(HttpServletRequest request, Long id, Long wxQrcodeId) {
JSONObject retObj = new JSONObject();
Qyuser qyuser = qyuserService.fetchById(id);
if (!StringUtils.isEmpty(qyuser.getQrcode())) {
......@@ -678,4 +683,24 @@ public class QyuserController {
return retObj;
}
/**
* 设置对应、客服、药师峰值
* @return
*/
@RequiresPermissions(value = PermissionSign.QYUSER_EDIT)
@RequestMapping(value = "/setPeakVal", method = RequestMethod.POST)
@ResponseBody
public JSONObject setPeakVal(@RequestParam Long id, @RequestParam Long peakVal) {
JSONObject retObj = new JSONObject();
try {
Qyuser qyuser = qyuserService.fetchById(id);
qyuser.setPeakVal(peakVal);
qyuserService.updateAssigned(qyuser);
retObj.put("errorNo", 0);
} catch (Exception e) {
e.printStackTrace();
retObj.put("errorNo", 1);
}
return retObj;
}
}
\ No newline at end of file
package com.cftech.workshop.activ.web;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.LongArraySerializer;
import com.cftech.base.codingrule.utils.CodingruleUtils;
import com.cftech.core.util.SystemConfig;
import com.cftech.workshop.activ.model.Activ;
......
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