Commit 777d4661 authored by 黎聪聪's avatar 黎聪聪

会员管理

parent 85cba2f2
...@@ -262,15 +262,23 @@ ...@@ -262,15 +262,23 @@
"aTargets": [1], "aTargets": [1],
"mData": "consultId", "mData": "consultId",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
if(a){
return a;
}else{
return null;
}
return a;
} }
}, },
{ {
"aTargets": [2], "aTargets": [2],
"mData": "userName", "mData": "userName",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
{ {
...@@ -289,7 +297,11 @@ ...@@ -289,7 +297,11 @@
"aTargets": [4], "aTargets": [4],
"mData": "iphone", "mData": "iphone",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
...@@ -297,7 +309,11 @@ ...@@ -297,7 +309,11 @@
"aTargets": [5], "aTargets": [5],
"mData": "pastRecords", "mData": "pastRecords",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
{ {
...@@ -313,28 +329,44 @@ ...@@ -313,28 +329,44 @@
"aTargets": [7], "aTargets": [7],
"mData": "illness", "mData": "illness",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
if(a){
return a; return a;
}else{
return null;
}
} }
}, },
{ {
"aTargets": [8], "aTargets": [8],
"mData": "allergy", "mData": "allergy",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
{ {
"aTargets": [9], "aTargets": [9],
"mData": "doctorName", "mData": "doctorName",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
{ {
"aTargets": [10], "aTargets": [10],
"mData": "customerName", "mData": "customerName",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
{ {
...@@ -354,7 +386,11 @@ ...@@ -354,7 +386,11 @@
"aTargets": [12], "aTargets": [12],
"mData": "description", "mData": "description",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; if(a){
return a;
}else{
return null;
}
} }
}, },
{ {
......
...@@ -12,16 +12,14 @@ import com.cftech.core.sql.Conds; ...@@ -12,16 +12,14 @@ import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort; import com.cftech.core.sql.Sort;
import com.cftech.core.util.Constants; import com.cftech.core.util.Constants;
import com.cftech.sys.security.UserUtils; import com.cftech.sys.security.UserUtils;
import com.sun.deploy.util.StringUtils; import org.springframework.util.StringUtils;
import jdk.nashorn.internal.ir.ReturnNode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.util.SystemOutLogger;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
......
...@@ -97,26 +97,26 @@ ...@@ -97,26 +97,26 @@
<form id="seachTableForm" action="#springUrl('/a/member/exportExcel')" method="get" onkeydown="if(event.keyCode==13){return false;}"> <form id="seachTableForm" action="#springUrl('/a/member/exportExcel')" method="get" onkeydown="if(event.keyCode==13){return false;}">
<div class="col-xs-2"> <div class="col-xs-2">
<input type="text" class="form-control required" <input type="text" class="form-control required"
name="name" placeholder="名"> name="phone" placeholder="手机号">
</div> </div>
<div class="col-xs-2"> <div class="col-xs-2">
<input type="text" class="form-control required" <input type="text" class="form-control required"
name="compan" placeholder="公司名称"> name="name" placeholder="会员名称">
</div>
<div class="col-xs-2">
<select name="status" class="form-control">
<option value="0">请选择会员状态</option>
<option value="1">会员注册</option>
<option value="2">虚拟会员</option>
</select>
</div> </div>
<!-- <div class="col-xs-2">-->
<!-- <select name="status" class="form-control">-->
<!-- <option value="0">请选择会员状态</option>-->
<!-- <option value="1">会员注册</option>-->
<!-- <option value="2">虚拟会员</option>-->
<!-- </select>-->
<!-- </div>-->
<div class="col-xs-5"> <div class="col-xs-5">
<a href="javascript:void(0)" class="btn btn-primary search">搜索</a> <a href="javascript:void(0)" class="btn btn-primary search">搜索</a>
#if($shiro.hasPermission("qy:member:edit")) #if($shiro.hasPermission("qy:member:edit"))
<!-- <a href="#springUrl('/a/member/form')" class="btn btn-primary">新增</a>--> <!-- <a href="#springUrl('/a/member/form')" class="btn btn-primary">新增</a>-->
#end #end
<button class="btn btn-primary">导出</button> <button class="btn btn-primary">导出</button>
<a href="javascript:void(0)" onclick="addMemer()" class="btn btn-primary">添加虚拟会员</a> <!-- <a href="javascript:void(0)" onclick="addMemer()" class="btn btn-primary">添加虚拟会员</a>-->
</div> </div>
</form> </form>
</div><!-- /.box-header --> </div><!-- /.box-header -->
...@@ -127,15 +127,16 @@ ...@@ -127,15 +127,16 @@
<td hidden="true">Id</td> <td hidden="true">Id</td>
<th>头像</th> <th>头像</th>
<th>性别</th> <th>性别</th>
<th></th> <!-- <th>姓</th>-->
<th></th> <!-- <th>名</th>-->
<th>微信OPENID</th> <th>微信OPENID</th>
<th>手机号码</th> <th>联系方式</th>
<th>公司名称</th> <th>会员名称</th>
<th>邀请码</th> <th>来源</th>
<th>客户分类</th> <!-- <th>邀请码</th>-->
<th>名片</th> <!-- <th>客户分类</th>-->
<th>状态</th> <!-- <th>名片</th>-->
<th>创建日期</th>
</tr> </tr>
</thead> </thead>
<tbody id="tablebody"> <tbody id="tablebody">
...@@ -228,26 +229,23 @@ ...@@ -228,26 +229,23 @@
}, },
{ {
"mData": "sex" "mData": "sex"
},{ },
"mData":"surname" {
},{
"mData":"name"
},{
"mData": "open_id" "mData": "open_id"
},{ },
{
"mData":"phone" "mData":"phone"
},{
"mData": "compan"
}, },
{ {
"mData": "invitcode" "mData":"name"
},{ },
"mData":"peopletype" {
},{ "mData":"source"
"mData":"storeid" },
},{ {
"mData":"status" "mData":"createTime"
}], }
],
"aoColumnDefs": [ "aoColumnDefs": [
{ // set default column settings { // set default column settings
'visible': false, 'visible': false,
...@@ -282,34 +280,52 @@ ...@@ -282,34 +280,52 @@
return formatDates(a, "yyyy-MM-dd HH:mm:ss"); return formatDates(a, "yyyy-MM-dd HH:mm:ss");
} }
},*/ },*/
// {
// "aTargets": [3],
// "mData": "surname",
// "mRender": function (a, b, c, d) {
// return a;
// }
// },
{ {
"aTargets": [3], "aTargets": [3],
"mData": "surname", "mData": "open_id",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return a; return a;
} }
}, },{
{ "aTargets":[4],
"aTargets": [4], "mData":"phone",
"mData": "surname", "mRender":function(a,b,c,d){
"mRender": function (a, b, c, d) {
return a; return a;
} }
},{ },{
"aTargets":[10], "aTargets":[5],
"mData":"storeid", "mData":"name",
"mRender":function(a,b,c,d){ "mRender":function(a,b,c,d){
return '<img src="'+a+'" style="width:80px;height:80px;">'; return a;
} }
},{ },{
"aTargets":[11], "aTargets":[6],
"mData":"status", "mData":"source",
"mRender":function(a,b,c,d){ "mRender":function(a,b,c,d){
if(a==1){ if (a==1){
return "虚拟会员"; return "普通关注";
}else if (a==2){
return "医师二维码";
}else if (a==3){
return "客服二维码";
}else{ }else{
return "会员注册"; return "";
} }
}
}
,{
"aTargets":[7],
"mData":"createTime",
"mRender":function(a,b,c,d){
return formatDates(a, "yyyy-MM-dd HH:mm:ss");
} }
} }
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
<result column="open_id" property="open_id"/> <result column="open_id" property="open_id"/>
<result column="storeid" property="storeid"/> <result column="storeid" property="storeid"/>
<result column="status" property="status"/> <result column="status" property="status"/>
<result column="create_time" property="createTime"/>
<result column="source" property="source"/>
</resultMap> </resultMap>
<sql id="sqlWhere"> <sql id="sqlWhere">
...@@ -327,20 +329,16 @@ ...@@ -327,20 +329,16 @@
<select id="selectmemberDto" parameterType="java.util.Map" resultMap="resultMapDto"> <select id="selectmemberDto" parameterType="java.util.Map" resultMap="resultMapDto">
SELECT SELECT
m.id,
m.imageurl, m.imageurl,
m.sex, m.sex,
m.surname, m.name,
m.`name`,
m.phone, m.phone,
m.compan,
m.invitcode,
m.open_id, m.open_id,
w.peopletype, m.create_time,
m.storeid, m.source
m.status
FROM FROM
wx_mp_member m wx_mp_member m
LEFT JOIN wx_mp_workshop w ON w.invitcode = m.invitcode
<include refid="sqlWhere"/> <include refid="sqlWhere"/>
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if> <if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if> <if test="limit>0">limit #{offset},#{limit}</if>
...@@ -350,7 +348,6 @@ ...@@ -350,7 +348,6 @@
COUNT(1) COUNT(1)
FROM FROM
wx_mp_member m wx_mp_member m
LEFT JOIN wx_mp_workshop w ON w.invitcode = m.invitcode
<include refid="sqlWhere"/> <include refid="sqlWhere"/>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
package com.cftech.member.model; package com.cftech.member.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.cftech.core.poi.ExportConfig; import com.cftech.core.poi.ExportConfig;
import lombok.Data; import lombok.Data;
import java.util.Date;
/** /**
* Created by Ago on 2018/8/7. * Created by Ago on 2018/8/7.
*/ */
...@@ -13,22 +16,19 @@ public class MemberDto { ...@@ -13,22 +16,19 @@ public class MemberDto {
private String imageurl; private String imageurl;
@ExportConfig(value = "会员性别",width = 100) @ExportConfig(value = "会员性别",width = 100)
private String sex; private String sex;
@ExportConfig(value = "会员姓",width = 100) @ExportConfig(value = "微信OPENID",width = 100)
private String surname; private String open_id;
@ExportConfig(value = "会员名",width = 100) @ExportConfig(value = "会员名",width = 100)
private String name; private String name;
@ExportConfig(value = "会员手机",width = 100) @ExportConfig(value = "会员手机",width = 100)
private String phone; private String phone;
@ExportConfig(value = "会员公司",width = 100) /* 来源 */
private String compan; @ExportConfig(value = "会员手机",width = 100)
@ExportConfig(value = "邀请码",width = 100) private String source;
private String invitcode;
@ExportConfig(value = "微信OPENID",width = 100) /*创建时间*/
private String open_id;
@ExportConfig(value = "客户分类",width = 100) @ExportConfig(value = "创建时间",width = 100)
private String peopletype; private String createTime;
@ExportConfig(value = "名片",width = 100)
private String storeid;
@ExportConfig(value = "状态",width = 100)
private String status;
} }
package com.cftech.member.web; package com.cftech.member.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cftech.base.codingrule.utils.CodingruleUtils; import com.cftech.base.codingrule.utils.CodingruleUtils;
import com.cftech.core.annotation.CSRFTokenRef; import com.cftech.core.annotation.CSRFTokenRef;
...@@ -35,6 +36,9 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -35,6 +36,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -161,17 +165,21 @@ public class MemberController { ...@@ -161,17 +165,21 @@ public class MemberController {
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("m.del_flag", Constants.DEL_FLAG_0); conds.equal("m.del_flag", Constants.DEL_FLAG_0);
conds.equal("m.accounts_id", accountsId); conds.equal("m.accounts_id", accountsId);
if(member.getStatus().equals("1")){ //注册会员 // if(member.getStatus().equals("1")){ //注册会员
conds.isNull("m.status"); // conds.isNull("m.status");
}else if(member.getStatus().equals("2")){ //虚拟会员 // }else if(member.getStatus().equals("2")){ //虚拟会员
conds.equal("m.status",1); // conds.equal("m.status",1);
} // }
if (!StringUtils.isEmpty(member.getCompan())) { // if (!StringUtils.isEmpty(member.getCompan())) {
conds.like("m.compan", member.getCompan()); // conds.like("m.compan", member.getCompan());
} // }
if (!StringUtils.isEmpty(member.getName())) { if (!StringUtils.isEmpty(member.getName())) {
conds.like("m.name", member.getName()); conds.like("m.name", member.getName());
} }
if (!StringUtils.isEmpty(member.getPhone())){
conds.like("m.phone",member.getPhone());
}
Sort sort = new Sort("m.create_time", OrderType.DESC); Sort sort = new Sort("m.create_time", OrderType.DESC);
...@@ -248,45 +256,58 @@ public class MemberController { ...@@ -248,45 +256,58 @@ public class MemberController {
@RequestMapping("/exportExcel") @RequestMapping("/exportExcel")
@RequiresPermissions(value = MEMBER_VIEW) @RequiresPermissions(value = MEMBER_VIEW)
public void exportExcel(HttpServletRequest request, HttpServletResponse response,Member member) { public void exportExcel(HttpServletRequest request, HttpServletResponse response,Member member) throws ParseException {
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("m.del_flag", Constants.DEL_FLAG_0); conds.equal("m.del_flag", Constants.DEL_FLAG_0);
conds.equal("m.accounts_id", accountsId); conds.equal("m.accounts_id", accountsId);
if(member.getStatus().equals("1")){ //注册会员 // if(member.getStatus().equals("1")){ //注册会员
conds.isNull("m.status"); // conds.isNull("m.status");
}else if(member.getStatus().equals("2")){ //虚拟会员 // }else if(member.getStatus().equals("2")){ //虚拟会员
conds.equal("m.status",1); // conds.equal("m.status",1);
} // }
if (!StringUtils.isEmpty(member.getCompan())) { // if (!StringUtils.isEmpty(member.getCompan())) {
conds.like("m.compan", member.getCompan()); // conds.like("m.compan", member.getCompan());
} // }
if (!StringUtils.isEmpty(member.getName())) { // if (!StringUtils.isEmpty(member.getName())) {
conds.like("m.name", member.getName()); // conds.like("m.name", member.getName());
} // }
Sort sort = new Sort("m.create_time", OrderType.DESC); Sort sort = new Sort("m.create_time", OrderType.DESC);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
List<MemberDto> list = memberService.selectmemberDto(conds, sort, 0, 0); List<MemberDto> list = memberService.selectmemberDto(conds, sort, 0, 0);
if(list.size()>0){ if (list.size() > 0) {
for(MemberDto memberDto:list){ for (MemberDto memberDto : list) {
if(memberDto.getStatus()==null){ // if(memberDto.get==null){
memberDto.setStatus("注册会员"); // memberDto.setStatus("注册会员");
if(memberDto.getSex().equals("1")){ // if(memberDto.getSex().equals("1")){
memberDto.setSex("男"); // memberDto.setSex("男");
}else if(memberDto.getSex().equals("0")){ // }else if(memberDto.getSex().equals("0")){
memberDto.setSex("女"); // memberDto.setSex("女");
} // }
}else{ // }else{
memberDto.setStatus("虚拟会员"); // memberDto.setStatus("虚拟会员");
// }
if ("1".equals(memberDto.getSex())) {
memberDto.setSex("男");
} else if ("0".equals(memberDto.getSex())) {
memberDto.setSex("女");
}
if ("1".equals(memberDto.getSource())) {
memberDto.setSource("普通关注");
} else if ("2".equals(memberDto.getSource())) {
memberDto.setSource("药师二维码");
} else if ("3".equals(memberDto.getSource())) {
memberDto.setSource("客服二维码");
} }
Date parse = simpleDateFormat.parse(memberDto.getCreateTime());
memberDto.setCreateTime(simpleDateFormat.format(parse));
} }
}
// 生成Excel并使用浏览器下载 // 生成Excel并使用浏览器下载
ExcelKit.$Export(MemberDto.class, response).toExcel(list, "会员信息"); ExcelKit.$Export(MemberDto.class, response).toExcel(list, "会员信息");
}
} }
} }
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
onkeydown="if(event.keyCode==13){return false;}"> onkeydown="if(event.keyCode==13){return false;}">
<div class="col-xs-1"> <div class="col-xs-1">
<input type="text" class="form-control required" <input type="text" class="form-control required"
placeholder="粉丝昵称" name="nickname" placeholder="昵称" name="nickname"
value="$!{mpFanssEntity.nickname}"> value="$!{mpFanssEntity.nickname}">
</div> </div>
<div class="col-xs-1"> <div class="col-xs-1">
...@@ -195,10 +195,10 @@ ...@@ -195,10 +195,10 @@
href="javascript:void(0)" onclick="syn(this)" href="javascript:void(0)" onclick="syn(this)"
class="btn bg-olive">同步粉丝</a> class="btn bg-olive">同步粉丝</a>
#end #end
#if($shiro.hasPermission("mp:fanss:edit")) <a id="batchFanssTag" <!-- #if($shiro.hasPermission("mp:fanss:edit")) <a id="batchFanssTag"-->
href="javascript:void(0)" <!-- href="javascript:void(0)"-->
class="btn bg-olive">批量打标签</a> <!-- class="btn bg-olive">批量打标签</a>-->
#end <!-- #end-->
<button style="width: 100px;" type="submit" <button style="width: 100px;" type="submit"
class="btn btn-primary" id="export">导出 class="btn btn-primary" id="export">导出
</button> </button>
...@@ -217,10 +217,10 @@ ...@@ -217,10 +217,10 @@
<th>省份</th> <th>省份</th>
<th>城市</th> <th>城市</th>
<th>昵称</th> <th>昵称</th>
<th>标签</th> <!-- <th>标签</th>-->
<th>粉丝来源</th> <th>粉丝来源</th>
<th>关注日期</th> <th>关注日期</th>
<th>操作</th> <!-- <th>操作</th>-->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -365,29 +365,31 @@ ...@@ -365,29 +365,31 @@
// $("#downloadtemplate").click(function(){//下载导入模板 // $("#downloadtemplate").click(function(){//下载导入模板
// var host = "http://"+window.location.host; // var host = "http://"+window.location.host;
// var url=host+"/cfwechat/static/batchfanss.xlsx"; // var url=host+"/cfwechat/static/batchfanss.xlsx";
// window.location.href=url; // window.location.href=url;
// }) // })
url = "#springUrl('/a/fanssgroup/fetchdata')"; // url = "#springUrl('/a/fanssgroup/fetchdata')";
$.ajax({ // $.ajax({
"type": "get", // "type": "get",
"contentType": "application/json", // "contentType": "application/json",
"url": url, // "url": url,
"dataType": "json", // "dataType": "json",
"data": { // "data": {
iDisplayStart: 0, // iDisplayStart: 0,
iDisplayLength: 0 // iDisplayLength: 0
}, // },
"success": function (data) { // "success": function (data) {
data = data.aaData; // data = data.aaData;
for (var i = 0; i < data.length; i++) { // for (var i = 0; i < data.length; i++) {
$("#addlabel").append('<option value="' + data[i].groupid + '" data-attr="">' + data[i].name + '</option>') // $("#addlabel").append('<option value="' + data[i].groupid + '" data-attr="">' + data[i].name + '</option>')
} // }
} // }
}); // });
$("#tagCacel").click(function () { $("#tagCacel").click(function () {
$("#addlabelModal").modal('hide'); $("#addlabelModal").modal('hide');
...@@ -404,18 +406,18 @@ ...@@ -404,18 +406,18 @@
var importExcelUrl = "#springUrl('/a/managefanss/batchFanss')?_csrf_header=" + csrfheader.value + "&_csrf=" + csrftoken.value; var importExcelUrl = "#springUrl('/a/managefanss/batchFanss')?_csrf_header=" + csrfheader.value + "&_csrf=" + csrftoken.value;
Cfapp.importExcel({ // Cfapp.importExcel({
title: '批量打标签', // title: '批量打标签',
importurl: importExcelUrl, // importurl: importExcelUrl,
templateurl: templateExcelUrl, // templateurl: templateExcelUrl,
cancel: function () { // cancel: function () {
//
}, // },
success: function () { // success: function () {
//alert(data.retJson.errorNo) // //alert(data.retJson.errorNo)
location.href = "#springUrl('/a/managefanss/fansslist')"; // location.href = "#springUrl('/a/managefanss/fansslist')";
} // }
}); // });
} }
...@@ -473,52 +475,13 @@ ...@@ -473,52 +475,13 @@
{"mData": "headimgurl"}, {"mData": "headimgurl"},
{"mData": "sex"}, {"mData": "sex"},
{"mData": "openid"}, {"mData": "openid"},
{ {"mData": "province"},
"mData": "province", {"mData": "city"},
"mRender": function (a, b, c, d) {//a表示id对应的值,c表示当前记录行对象
if (a) {
return a;
} else {
return "";
}
}
},
{
"mData": "city",
"mRender": function (a, b, c, d) {//a表示id对应的值,c表示当前记录行对象
if (a) {
return a;
} else {
return "";
}
}
},
{"mData": "nickname"}, {"mData": "nickname"},
{ {"mData": "source"},
"mData": "tags", {"mData": "subscribetime"}
"mRender": function (a, b, c, d) {//a表示id对应的值,c表示当前记录行对象 ],
if (a) {
return a;
} else {
return "";
}
}
},
{
"mData": "source",
"mRender": function (a, b, c, d) {//a表示id对应的值,c表示当前记录行对象
if (a == '1') {
return "研讨会二维码";
} else if (a == '2') {
return "展会二维码";
} else if (a == '3') {
return "活动车辆";
} else {
return "普通关注";
}
}
}
],
"aoColumnDefs": [ "aoColumnDefs": [
{ // set default column settings { // set default column settings
'visible': false, 'visible': false,
...@@ -527,7 +490,6 @@ ...@@ -527,7 +490,6 @@
{ {
"targets": [1], "targets": [1],
"mData": "headimgurl", "mData": "headimgurl",
"className": "piccenter",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
//a表示id对应的值,c表示当前记录行对象 //a表示id对应的值,c表示当前记录行对象
return '<img width="45px" height="45px" src="' + a + '" />'; return '<img width="45px" height="45px" src="' + a + '" />';
...@@ -558,18 +520,50 @@ ...@@ -558,18 +520,50 @@
} }
}, },
{ {
"aTargets": [9], "targets": [3],
"mData": "subscribetime", "mData": "openid",
"mRender": function (a, b, c, d) {//a表示id对应的值,c表示当前记录行对象
return a;
}
},
{
"aTargets": [4],
"mData": "province",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
return a;
}
}, {
"aTargets": [5],
"mData": "city",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
return a;
}
}
, {
"aTargets": [6],
"mData": "nickname",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象 "mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
return formatDates(a, "yyyy-MM-dd hh:mm:ss"); return a;
}
}
, {
"aTargets": [7],
"mData": "source",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
if (a==1){
return "普通关注";
}else if (a==2){
return "医师二维码";
}else if (a==3){
return "客服二维码";
}
} }
}, { }, {
"aTargets": [10], "aTargets": [8],
"mData": "id", "mData": "subscribetime",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象 "mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
console.log(c); return formatDates(a, "yyyy-MM-dd HH:mm:ss");
return '#if($shiro.hasPermission("mp:fanss:edit"))' + '<a href="javascript:void(0)"; data-attr="' + c.id + '" data-tag="' + c.taglist + '" onclick="addlabel(this)" class="btn red">修改标签</a>' +
'#else <a href="javascript:void(0)"; data-attr="' + c.id + '" data-tag="' + c.taglist + '" class="btn red">修改标签</a>#end';
} }
}]//, }]//,
// { // {
......
package com.cftech.mp.fans.controller; package com.cftech.mp.fans.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cftech.accounts.service.MpAccountsService; import com.cftech.accounts.service.MpAccountsService;
import com.cftech.core.poi.ExcelKit;
import com.cftech.core.scope.OrderType; import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Conds; import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort; import com.cftech.core.sql.Sort;
import com.cftech.core.util.*; import com.cftech.core.util.*;
import com.cftech.mp.fans.model.Fanssgroup; import com.cftech.mp.fans.model.Fanssgroup;
import com.cftech.mp.fans.model.MpFanssEntity; import com.cftech.mp.fans.model.MpFanssEntity;
import com.cftech.mp.fans.model.MpFanssVO;
import com.cftech.mp.fans.service.FanssgroupService; import com.cftech.mp.fans.service.FanssgroupService;
import com.cftech.mp.fans.service.MpFanssService; import com.cftech.mp.fans.service.MpFanssService;
import com.cftech.sys.security.PermissionSign; import com.cftech.sys.security.PermissionSign;
import com.cftech.sys.security.UserUtils; import com.cftech.sys.security.UserUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.velocity.runtime.directive.Foreach;
import org.mp.api.core.exception.WexinReqException; import org.mp.api.core.exception.WexinReqException;
import org.mp.api.core.req.model.user.BatchUserTag; import org.mp.api.core.req.model.user.BatchUserTag;
import org.mp.api.wxuser.tag.JwTagAPI; import org.mp.api.wxuser.tag.JwTagAPI;
...@@ -31,323 +35,337 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -31,323 +35,337 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
/** /**
*
* @author lisw * @author lisw
*
*/ */
@Controller @Controller
@RequestMapping(value = "/a/managefanss") @RequestMapping(value = "/a/managefanss")
public class MpFanssController { public class MpFanssController {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory
.getLogger(MpFanssController.class); .getLogger(MpFanssController.class);
@Autowired @Autowired
private MpFanssService mpAccountsService; private MpFanssService mpAccountsService;
@Autowired @Autowired
private MpAccountsService mpAccountService; private MpAccountsService mpAccountService;
@Autowired @Autowired
private FanssgroupService fanssGroupService; private FanssgroupService fanssGroupService;
@Autowired @Autowired
private MpTokenUtil tokenUtil; private MpTokenUtil tokenUtil;
// 管理后台用户列表 // 管理后台用户列表
@RequestMapping(value = "/fansslist",method = {RequestMethod.POST,RequestMethod.GET}) @RequestMapping(value = "/fansslist", method = {RequestMethod.POST, RequestMethod.GET})
public String useradd(HttpServletRequest request, public String useradd(HttpServletRequest request,
HttpServletResponse response, MpFanssEntity mpFanssEntity, HttpServletResponse response, MpFanssEntity mpFanssEntity,
String areaname, String startTime, String endTime, Model model) { String areaname, String startTime, String endTime, Model model) {
model.addAttribute("areaname", areaname); model.addAttribute("areaname", areaname);
model.addAttribute("startTime", startTime); model.addAttribute("startTime", startTime);
model.addAttribute("endTime", endTime); model.addAttribute("endTime", endTime);
model.addAttribute("mpFanssEntity", mpFanssEntity); model.addAttribute("mpFanssEntity", mpFanssEntity);
return "managefans/fansslist"; return "managefans/fansslist";
} }
// 管理后台用户列表 // 管理后台用户列表
@RequestMapping(value = "/accountsaddform",method = {RequestMethod.POST,RequestMethod.GET}) @RequestMapping(value = "/accountsaddform", method = {RequestMethod.POST, RequestMethod.GET})
public String accountsaddform(HttpServletRequest request, public String accountsaddform(HttpServletRequest request,
HttpServletResponse response) { HttpServletResponse response) {
return "manageaccounts/accountsadd"; return "manageaccounts/accountsadd";
} }
// 获取数据 // 获取数据
@RequestMapping(value = "/fanss/fetchdata",method = {RequestMethod.POST,RequestMethod.GET}) @RequestMapping(value = "/fanss/fetchdata", method = {RequestMethod.POST, RequestMethod.GET})
@ResponseBody @ResponseBody
public JSONObject getUsers(int iDisplayStart, int iDisplayLength, public JSONObject getUsers(int iDisplayStart, int iDisplayLength,
HttpServletResponse response, HttpServletRequest request, HttpServletResponse response, HttpServletRequest request,
String areaname, String startTime, String endTime, String areaname, String startTime, String endTime,
MpFanssEntity mpFanssEntity) { MpFanssEntity mpFanssEntity) {
Long id = UserUtils.getmpaccounts(request); Long id = UserUtils.getmpaccounts(request);
Sort sort = new Sort("subscribetime", OrderType.DESC); Sort sort = new Sort("subscribetime", OrderType.DESC);
Conds conds = new Conds(); Conds conds = new Conds();
if (StringUtils.isNotBlank(mpFanssEntity.getSource())) { if (StringUtils.isNotBlank(mpFanssEntity.getSource())) {
conds.equal("source", mpFanssEntity.getSource()); conds.equal("source", mpFanssEntity.getSource());
} }
if (StringUtils.isNotBlank(mpFanssEntity.getNickname())) { if (StringUtils.isNotBlank(mpFanssEntity.getNickname())) {
conds.like("nickname", mpFanssEntity.getNickname()); conds.like("nickname", mpFanssEntity.getNickname());
} }
if (StringUtils.isNotBlank(startTime)) { if (StringUtils.isNotBlank(startTime)) {
conds.greatEqual("subscribetime", startTime); conds.greatEqual("subscribetime", startTime);
} }
if (StringUtils.isNotBlank(endTime)) { if (StringUtils.isNotBlank(endTime)) {
conds.lessEqual("subscribetime", endTime); conds.lessEqual("subscribetime", endTime);
} }
conds.equal("mpaccountid", id); conds.equal("mpaccountid", id);
conds.equal("delflag", Constants.DEL_FLAG_0); conds.equal("delflag", Constants.DEL_FLAG_0);
JSONObject returnObj = new JSONObject(); JSONObject returnObj = new JSONObject();
List<MpFanssEntity> users = null; List<MpFanssEntity> users = null;
int userCounts = 0; int userCounts = 0;
if (StringUtils.isNoneBlank(areaname)) { if (StringUtils.isNoneBlank(areaname)) {
users = mpAccountsService.fetchSearchByPage(conds, sort, users = mpAccountsService.fetchSearchByPage(conds, sort,
iDisplayStart, iDisplayLength, areaname); iDisplayStart, iDisplayLength, areaname);
userCounts = mpAccountsService.count(conds, areaname); userCounts = mpAccountsService.count(conds, areaname);
} else { } else {
users = mpAccountsService.fetchSearchByPage(conds, sort, users = mpAccountsService.fetchSearchByPage(conds, sort,
iDisplayStart, iDisplayLength); iDisplayStart, iDisplayLength);
userCounts = mpAccountsService.count(conds); userCounts = mpAccountsService.count(conds);
} }
returnObj.put("iTotalRecords", userCounts); returnObj.put("iTotalRecords", userCounts);
returnObj.put("iTotalDisplayRecords", userCounts); returnObj.put("iTotalDisplayRecords", userCounts);
returnObj.put("aaData",users); returnObj.put("aaData", users);
return returnObj; return returnObj;
// OutputJSONUtil.convertoJSONStream(response, returnObj.toString()); // OutputJSONUtil.convertoJSONStream(response, returnObj.toString());
} }
// 粉丝列表导出 // 粉丝列表导出
@RequestMapping(value = "/fanss/export",method = {RequestMethod.POST,RequestMethod.GET}) @RequestMapping(value = "/fanss/export", method = {RequestMethod.POST, RequestMethod.GET})
public void export(HttpServletResponse response, public void export(HttpServletResponse response,
HttpServletRequest request, MpFanssEntity mpFanssEntity, HttpServletRequest request, MpFanssEntity mpFanssEntity,
String areaname, String startTime, String endTime) { String areaname, String startTime, String endTime) {
Long id = UserUtils.getmpaccounts(request); Long id = UserUtils.getmpaccounts(request);
Sort sort = new Sort("t.subscribetime", OrderType.DESC); Sort sort = new Sort("t.subscribetime", OrderType.DESC);
Conds conds = new Conds(); Conds conds = new Conds();
if (StringUtils.isNotBlank(mpFanssEntity.getNickname())) { if (StringUtils.isNotBlank(mpFanssEntity.getNickname())) {
conds.like("t.nickname", mpFanssEntity.getNickname()); conds.like("t.nickname", mpFanssEntity.getNickname());
} }
if (StringUtils.isNotBlank(startTime)) { if (StringUtils.isNotBlank(startTime)) {
conds.greatEqual("t.subscribetime", startTime); conds.greatEqual("t.subscribetime", startTime);
} }
if (StringUtils.isNotBlank(endTime)) { if (StringUtils.isNotBlank(endTime)) {
conds.lessEqual("t.subscribetime", endTime); conds.lessEqual("t.subscribetime", endTime);
} }
conds.equal("mpaccountid", id); conds.equal("mpaccountid", id);
conds.equal("delflag", Constants.DEL_FLAG_0); conds.equal("delflag", Constants.DEL_FLAG_0);
try { try {
List<MpFanssEntity> users = null; List<MpFanssEntity> users = mpAccountsService.fetchSearchByPageStore(conds, sort, 0, 0,
if (StringUtils.isNoneBlank(areaname)) { null);
users = mpAccountsService.fetchSearchByPageStore(conds, sort, 0, 0, LinkedList<MpFanssVO> list = new LinkedList<>();
areaname); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
} else { for ( MpFanssEntity fanssEntity : users) {
users = mpAccountsService.fetchSearchByPageStore(conds, sort, 0, 0, MpFanssVO mpFanssVO = new MpFanssVO();
null); mpFanssVO.setHeadimgurl(fanssEntity.getHeadimgurl());
} mpFanssVO.setSex(fanssEntity.getSex().equals(1) ? "男" : "女");
// 参数 mpFanssVO.setOpenid(fanssEntity.getOpenid());
ExcelUtils.export(request, response, mpFanssVO.setProvince(fanssEntity.getProvince());
"粉丝列表-" + DateUtils.formatDate(new Date(), "yyyy-MM-dd"), mpFanssVO.setCity(fanssEntity.getCity());
users, "fans"); mpFanssVO.setNickname(fanssEntity.getNickname());
} catch (Exception e) { mpFanssVO.setSource(fanssEntity.getSource().equals("1") ? "普通关注" : fanssEntity.getSource().equals("2") ? "医师二维码" : "客服二维码");
e.printStackTrace(); mpFanssVO.setSubscribetime( simpleDateFormat.format(fanssEntity.getSubscribetime()));
} list.add(mpFanssVO);
}
// 修改账户 }
@RequestMapping(value = "/updateaccounts",method = {RequestMethod.POST}) ExcelKit.$Export(MpFanssVO.class,response).toExcel(list,"粉丝列表");
public JSONObject updateaccounts(MpFanssEntity accounts, // if (StringUtils.isNoneBlank(areaname)) {
HttpServletResponse response) { // users = mpAccountsService.fetchSearchByPageStore(conds, sort, 0, 0,
JSONObject returnObj = new JSONObject(); // areaname);
accounts.setUpdatetime(new Date()); // } else {
returnObj.put("errorCode", 0); // users = mpAccountsService.fetchSearchByPageStore(conds, sort, 0, 0,
mpAccountsService.updateByPrimaryKey(accounts); // null);
// }
// 参数
} catch (Exception e) {
e.printStackTrace();
}
}
// 修改账户
@RequestMapping(value = "/updateaccounts", method = {RequestMethod.POST})
public JSONObject updateaccounts(MpFanssEntity accounts,
HttpServletResponse response) {
JSONObject returnObj = new JSONObject();
accounts.setUpdatetime(new Date());
returnObj.put("errorCode", 0);
mpAccountsService.updateByPrimaryKey(accounts);
// OutputJSONUtil.convertoJSONStream(response, returnObj.toString()); // OutputJSONUtil.convertoJSONStream(response, returnObj.toString());
return returnObj; return returnObj;
} }
// 修改账户 // 修改账户
@RequestMapping(value = "/deleteaccounts",method = {RequestMethod.POST}) @RequestMapping(value = "/deleteaccounts", method = {RequestMethod.POST})
public JSONObject deleteaccounts(MpFanssEntity accounts, public JSONObject deleteaccounts(MpFanssEntity accounts,
HttpServletResponse response) { HttpServletResponse response) {
JSONObject returnObj = new JSONObject(); JSONObject returnObj = new JSONObject();
returnObj.put("errorCode", 0); returnObj.put("errorCode", 0);
mpAccountsService.deleteByPrimaryKey(accounts.getId()); mpAccountsService.deleteByPrimaryKey(accounts.getId());
// OutputJSONUtil.convertoJSONStream(response, returnObj.toString()); // OutputJSONUtil.convertoJSONStream(response, returnObj.toString());
return returnObj; return returnObj;
} }
// 获取详细信息 // 获取详细信息
@RequestMapping(value = "/getaccountdetail",method = {RequestMethod.POST,RequestMethod.GET}) @RequestMapping(value = "/getaccountdetail", method = {RequestMethod.POST, RequestMethod.GET})
public String getaccountdetail(Long id, HttpServletResponse response, public String getaccountdetail(Long id, HttpServletResponse response,
Model model) { Model model) {
MpFanssEntity accountsEntity = mpAccountsService.getDetail(id); MpFanssEntity accountsEntity = mpAccountsService.getDetail(id);
model.addAttribute("accountsEntity", accountsEntity); model.addAttribute("accountsEntity", accountsEntity);
return "manageaccounts/detail"; return "manageaccounts/detail";
} }
// 根据当前微信公众号, 同步所有用户 // 根据当前微信公众号, 同步所有用户
@ResponseBody @ResponseBody
@RequestMapping(value = "/synAllFans",method = {RequestMethod.POST}) @RequestMapping(value = "/synAllFans", method = {RequestMethod.POST})
public JSONObject synAllFans(HttpServletRequest request) public JSONObject synAllFans(HttpServletRequest request)
throws WexinReqException { throws WexinReqException {
JSONObject rtnJosn = new JSONObject(); JSONObject rtnJosn = new JSONObject();
try { try {
Long id = UserUtils.getmpaccounts(request); Long id = UserUtils.getmpaccounts(request);
String accessToken = tokenUtil.getToken(id); String accessToken = tokenUtil.getToken(id);
// 根据账号查询所有粉丝 // 根据账号查询所有粉丝
if (id != null) { if (id != null) {
List<Wxuser> users = JwUserAPI.getAllWxuser(accessToken, null);// 得到微信官方实际的关注粉丝 List<Wxuser> users = JwUserAPI.getAllWxuser(accessToken, null);// 得到微信官方实际的关注粉丝
MpFanssEntity fannsIsexits = null; MpFanssEntity fannsIsexits = null;
List<String> fanssList = mpAccountsService.getAllWxUser(id List<String> fanssList = mpAccountsService.getAllWxUser(id
.toString()); .toString());
for (Wxuser user : users) { for (Wxuser user : users) {
try { try {
MpFanssEntity fannsEntity = new MpFanssEntity(); MpFanssEntity fannsEntity = new MpFanssEntity();
fannsEntity.setHeadimgurl(user.getHeadimgurl()); fannsEntity.setHeadimgurl(user.getHeadimgurl());
fannsEntity.setCity(user.getCity()); fannsEntity.setCity(user.getCity());
fannsEntity.setProvince(user.getProvince()); fannsEntity.setProvince(user.getProvince());
fannsEntity.setNickname(user.getNickname()); fannsEntity.setNickname(user.getNickname());
fannsEntity.setMpaccountid(id); fannsEntity.setMpaccountid(id);
fannsEntity.setOpenid(user.getOpenid()); fannsEntity.setOpenid(user.getOpenid());
fannsEntity.setSex(user.getSex()); fannsEntity.setSex(user.getSex());
fannsEntity.setSubscribetime(new Date(Long fannsEntity.setSubscribetime(new Date(Long
.parseLong(user.getSubscribe_time()) * 1000)); .parseLong(user.getSubscribe_time()) * 1000));
fannsEntity.setUnionid(user.getUnionid()); fannsEntity.setUnionid(user.getUnionid());
String tags = ""; String tags = "";
if(user.getTagid_list()!=null && user.getTagid_list().size()>0){ if (user.getTagid_list() != null && user.getTagid_list().size() > 0) {
tags=StringUtils.join(user.getTagid_list(), ",")+","; tags = StringUtils.join(user.getTagid_list(), ",") + ",";
} }
fannsEntity.setTaglist(tags); fannsEntity.setTaglist(tags);
fannsIsexits = mpAccountsService.getWxUser(user.getOpenid()); fannsIsexits = mpAccountsService.getWxUser(user.getOpenid());
if (fannsIsexits != null) {// 修改 if (fannsIsexits != null) {// 修改
mpAccountsService.updateByOpenId(fannsEntity); mpAccountsService.updateByOpenId(fannsEntity);
fanssList.remove(user.getOpenid()); fanssList.remove(user.getOpenid());
} else {// 插入 } else {// 插入
fannsEntity.setSource("0"); fannsEntity.setSource("0");
mpAccountsService.insert(fannsEntity); mpAccountsService.insert(fannsEntity);
fanssList.remove(user.getOpenid()); fanssList.remove(user.getOpenid());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info(user.getNickname()); logger.info(user.getNickname());
} }
} }
// 如果存在取消关注的粉丝,则删除数据库中的粉丝 // 如果存在取消关注的粉丝,则删除数据库中的粉丝
if (fanssList != null && !fanssList.isEmpty()) { if (fanssList != null && !fanssList.isEmpty()) {
for (String s : fanssList) { for (String s : fanssList) {
mpAccountsService.deleteByOpenId(s); mpAccountsService.deleteByOpenId(s);
} }
} }
} }
rtnJosn.put("errorCode", 0); rtnJosn.put("errorCode", 0);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
rtnJosn.put("errorCode", 1); rtnJosn.put("errorCode", 1);
} }
return rtnJosn; return rtnJosn;
} }
@RequestMapping(value="/batchFanss",method=RequestMethod.POST) @RequestMapping(value = "/batchFanss", method = RequestMethod.POST)
@ResponseBody @ResponseBody
public JSONObject batchFanss(MultipartFile file,HttpServletRequest request){ public JSONObject batchFanss(MultipartFile file, HttpServletRequest request) {
JSONObject rtnJson = new JSONObject(); JSONObject rtnJson = new JSONObject();
StringBuffer errorBuffer = new StringBuffer(); StringBuffer errorBuffer = new StringBuffer();
if(file!=null){ if (file != null) {
try { try {
List<List<Object>> list = ImportExcelUtil.getBankListByExcel(file.getInputStream(),file.getOriginalFilename()); List<List<Object>> list = ImportExcelUtil.getBankListByExcel(file.getInputStream(), file.getOriginalFilename());
for(int i =0;i<list.size();i++){ for (int i = 0; i < list.size(); i++) {
List<Object> objList = list.get(i); List<Object> objList = list.get(i);
String openId=null; String openId = null;
String tag=null; String tag = null;
if(objList==null || objList.size()==0)errorBuffer.append("第"+(i+1)+"条数据为空"); if (objList == null || objList.size() == 0) errorBuffer.append("第" + (i + 1) + "条数据为空");
if(objList.get(0)==null || StringUtils.isBlank(objList.get(0).toString())){//openid为空 if (objList.get(0) == null || StringUtils.isBlank(objList.get(0).toString())) {//openid为空
errorBuffer.append("第"+(i+1)+"条数据,粉丝openId为空"); errorBuffer.append("第" + (i + 1) + "条数据,粉丝openId为空");
continue; continue;
}else{ } else {
openId=objList.get(0).toString(); openId = objList.get(0).toString();
} }
if(objList.get(1)==null || StringUtils.isBlank(objList.get(1).toString())){//标签为空 if (objList.get(1) == null || StringUtils.isBlank(objList.get(1).toString())) {//标签为空
errorBuffer.append("第"+(i+1)+"条数据,标签为空"); errorBuffer.append("第" + (i + 1) + "条数据,标签为空");
continue; continue;
}else{ } else {
tag=objList.get(1).toString(); tag = objList.get(1).toString();
} }
String [] newtags = tag.split(",");//新标签 String[] newtags = tag.split(",");//新标签
Conds fanssConds = new Conds(); Conds fanssConds = new Conds();
fanssConds.equal("delflag", 0); fanssConds.equal("delflag", 0);
fanssConds.equal("openid", openId); fanssConds.equal("openid", openId);
fanssConds.equal("mpaccountid", UserUtils.getmpaccounts(request)); fanssConds.equal("mpaccountid", UserUtils.getmpaccounts(request));
MpFanssEntity fanss=mpAccountsService.fetchSearchByConds(fanssConds); MpFanssEntity fanss = mpAccountsService.fetchSearchByConds(fanssConds);
if(fanss!=null){ if (fanss != null) {
if(fanss.getTaglist()==null){ if (fanss.getTaglist() == null) {
fanss.setTaglist(""); fanss.setTaglist("");
} }
String [] tags = fanss.getTaglist().split(",");//此粉丝旧标签 String[] tags = fanss.getTaglist().split(",");//此粉丝旧标签
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("delflag", 0); conds.equal("delflag", 0);
conds.equal("accountsid", UserUtils.getmpaccounts(request)); conds.equal("accountsid", UserUtils.getmpaccounts(request));
conds.in("name", newtags); conds.in("name", newtags);
List<Fanssgroup> groupList = fanssGroupService.fetchSearchByPage(conds, null, 0, 0); List<Fanssgroup> groupList = fanssGroupService.fetchSearchByPage(conds, null, 0, 0);
String groups=""; String groups = "";
for(Fanssgroup g : groupList){ for (Fanssgroup g : groupList) {
groups+=g.getGroupid()+","; groups += g.getGroupid() + ",";
} }
if((tags.length+newtags.length)>20){ if ((tags.length + newtags.length) > 20) {
// fanss.setTaglist(groups); // fanss.setTaglist(groups);
errorBuffer.append("第"+(i+1)+"条数据,粉丝标签超过20,openId为:"+openId); errorBuffer.append("第" + (i + 1) + "条数据,粉丝标签超过20,openId为:" + openId);
continue; continue;
}else{//如果此粉丝标签加上本次的新标签未超过20个,追加旧标签 } else {//如果此粉丝标签加上本次的新标签未超过20个,追加旧标签
groups=fanss.getTaglist()+groups; groups = fanss.getTaglist() + groups;
} }
List<String> result = Arrays.asList(groups.split(",")); List<String> result = Arrays.asList(groups.split(","));
Set<String> set = new HashSet<String>(); Set<String> set = new HashSet<String>();
set.addAll(result); set.addAll(result);
groups = StringUtils.join(set, ",")+","; groups = StringUtils.join(set, ",") + ",";
Map<String,Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("openid", openId); params.put("openid", openId);
params.put("taglist", groups); params.put("taglist", groups);
params.put("accountsId", UserUtils.getmpaccounts(request)); params.put("accountsId", UserUtils.getmpaccounts(request));
try { try {
mpAccountsService.updateLabelByid(params); mpAccountsService.updateLabelByid(params);
errorBuffer.append("第"+(i+1)+"条数据导入成功,openId:"+openId+",标签:"+tag); errorBuffer.append("第" + (i + 1) + "条数据导入成功,openId:" + openId + ",标签:" + tag);
} catch (Exception e) { } catch (Exception e) {
errorBuffer.append("第"+(i+1)+"条数据发生异常,异常信息:"+e.getMessage()); errorBuffer.append("第" + (i + 1) + "条数据发生异常,异常信息:" + e.getMessage());
continue; continue;
} }
}else{ } else {
errorBuffer.append("第"+(i+1)+"条数据,OpenId为找到粉丝信息"); errorBuffer.append("第" + (i + 1) + "条数据,OpenId为找到粉丝信息");
} }
//fanssGroupService //fanssGroupService
} }
System.out.println(list); System.out.println(list);
} catch (IOException e) { } catch (IOException e) {
rtnJson.put("errorNo","2");//未找到文件 rtnJson.put("errorNo", "2");//未找到文件
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
return rtnJson; return rtnJson;
} catch (Exception e) { } catch (Exception e) {
rtnJson.put("errorNo","2");//未找到文件 rtnJson.put("errorNo", "2");//未找到文件
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
return rtnJson; return rtnJson;
} }
}else{ } else {
rtnJson.put("errorNo","2");//未找到文件 rtnJson.put("errorNo", "2");//未找到文件
return rtnJson; return rtnJson;
} }
rtnJson.put("errorNo","0"); rtnJson.put("errorNo", "0");
rtnJson.put("errorMsg", "导入成功"); rtnJson.put("errorMsg", "导入成功");
logger.info(errorBuffer.toString()); logger.info(errorBuffer.toString());
return rtnJson; return rtnJson;
} }
// //
// @RequestMapping(value = "/batchFanssNew", method = RequestMethod.POST) // @RequestMapping(value = "/batchFanssNew", method = RequestMethod.POST)
...@@ -431,20 +449,20 @@ public class MpFanssController { ...@@ -431,20 +449,20 @@ public class MpFanssController {
// return rtnJson; // return rtnJson;
// } // }
//改变粉丝标签 //改变粉丝标签
@RequestMapping(value = "/editlabel",method = {RequestMethod.POST}) @RequestMapping(value = "/editlabel", method = {RequestMethod.POST})
@RequiresPermissions(value = PermissionSign.FANSS_EDIT) @RequiresPermissions(value = PermissionSign.FANSS_EDIT)
@ResponseBody @ResponseBody
public JSONObject addlabel(HttpServletRequest request, public JSONObject addlabel(HttpServletRequest request,
HttpServletResponse response, Model model,String taglist,Long id){ HttpServletResponse response, Model model, String taglist, Long id) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("errorNo",1); result.put("errorNo", 1);
Map<String,Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
map.put("taglist", taglist+","); map.put("taglist", taglist + ",");
map.put("accountsId", accountsId); map.put("accountsId", accountsId);
//String openid = mpAccountsService.findopenidById(id); //String openid = mpAccountsService.findopenidById(id);
MpFanssEntity fanssEntity = mpAccountsService.getDetail(id); MpFanssEntity fanssEntity = mpAccountsService.getDetail(id);
// if(fanssEntity.getTaglist()!=null){ // if(fanssEntity.getTaglist()!=null){
// String [] tags = fanssEntity.getTaglist().split(","); // String [] tags = fanssEntity.getTaglist().split(",");
// for(String str : tags){ // for(String str : tags){
...@@ -456,18 +474,18 @@ public class MpFanssController { ...@@ -456,18 +474,18 @@ public class MpFanssController {
// } // }
// } // }
// } // }
map.put("openid", fanssEntity.getOpenid()); map.put("openid", fanssEntity.getOpenid());
try { try {
if(fanssEntity.getOpenid()!=null){ if (fanssEntity.getOpenid() != null) {
boolean flag = mpAccountsService.updateLabelByid(map); boolean flag = mpAccountsService.updateLabelByid(map);
if(flag){ if (flag) {
result.put("errorNo",0); result.put("errorNo", 0);
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
result.put("errorNo",1); result.put("errorNo", 1);
} }
return result; return result;
} }
} }
package com.cftech.mp.fans.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.cftech.core.poi.ExportConfig;
import lombok.Data;
import java.util.Date;
/**
* @author :licc
* @date :Created in 2020/9/25 17:07
* @description:
*/
@Data
public class MpFanssVO {
/* 粉丝头像 */
@ExportConfig(value = "粉丝头像", width = 100, showLevel = 1)
private String headimgurl;
/* 性别 */
@ExportConfig(value = "性别", width = 100, showLevel = 1)
private String sex;
/* openid */
@ExportConfig(value = "openid", width = 100, showLevel = 1)
private String openid;
/* 省份 */
@ExportConfig(value = "省份", width = 100, showLevel = 1)
private String province;
/* 城市 */
@ExportConfig(value="城市",width = 100, showLevel = 1)
private String city;
/* 昵称 */
@ExportConfig(value="昵称",width = 100, showLevel = 1)
private String nickname;
/* 粉丝来源 */
@ExportConfig(value="粉丝来源",width = 100, showLevel = 1)
private String source;
/* 关注日期 */
@ExportConfig(value="关注日期",width = 100, showLevel = 1)
private String subscribetime;
}
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