Commit 6271a375 zxt@theyeasy.com

Merge branch 'zxt'

2 个父辈 cc036477 fe545ed1
正在显示 106 个修改的文件 包含 391 行增加4335 行删除
target/
!.mvn/wrapper/maven-wrapper.jar
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms-4.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.8.0.xsd">
<!-- ActiveMQ 连接工厂 -->
<!-- 真正可以产生Connection的ConnectionFactory,由对应的 JMS服务厂商提供 -->
<!-- 如果连接网络:tcp://ip:61616;未连接网络:tcp://localhost:61616 以及用户名,密码 -->
<amq:connectionFactory id="amqConnectionFactory"
brokerURL="tcp://119.23.153.87:61616" userName="admin" password="admin" />
<!-- Spring Caching连接工厂 -->
<!-- Spring用于管理真正的ConnectionFactory的ConnectionFactory -->
<bean id="connectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<!-- 目标ConnectionFactory对应真实的可以产生JMS Connection的ConnectionFactory -->
<property name="targetConnectionFactory" ref="amqConnectionFactory"></property>
<!-- 同上,同理 -->
<!-- <constructor-arg ref="amqConnectionFactory" /> -->
<!-- Session缓存数量 -->
<property name="sessionCacheSize" value="100" />
</bean>
<!-- Spring JmsTemplate 的消息生产者 start -->
<!-- 定义JmsTemplate的Queue类型 -->
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<constructor-arg ref="connectionFactory" />
<property name="pubSubDomain" value="false" />
</bean>
<!-- 定义JmsTemplate的Topic类型 -->
<bean id="jmsTopicTemplate" class="org.springframework.jms.core.JmsTemplate">
<constructor-arg ref="connectionFactory" />
<property name="pubSubDomain" value="true" />
</bean>
<!-- 定义Topic监听器 -->
<jms:listener-container destination-type="topic"
container-type="default" connection-factory="connectionFactory"
acknowledge="auto">
<jms:listener destination="zzhnc.topic" ref="zzHncTopicReceiver" />
</jms:listener-container>
<!-- 消息消费者 end -->
</beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.w1hd.zzhnc.dao.FansPortraitDao">
<select id="findByKeyWord" resultType="com.w1hd.zzhnc.model.Fans">
SELECT * from fans
WHERE id IN (
SELECT fans_id FROM fans_portrait
WHERE sale_id = #{salesid}
AND (
remark_info LIKE concat('%',#{keyword},'%') or
remark_name LIKE concat('%',#{keyword},'%') or
concat('|',tag,'|') like concat('%|',#{keyword},'|%')
)
)
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.w1hd.zzhnc.dao.SalesDao">
<select id="getSalesList" resultType="com.w1hd.zzhnc.vo.Sales_Vo">
select a.*,b.name as projectname from sales a
LEFT JOIN projects b on
a.projectId=b.id
where a.deleted=0
<if test="projectid != null and projectid>0">
and a.projectid=#{projectid}
</if>
<if test="isvanker != null">
and a.isvanker=#{isvanker}
</if>
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%')
or
a.phone like CONCAT(CONCAT('%',#{keyword}),'%')
or b.name like
CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
order by a.updatedtime desc
limit #{0},#{1}
</select>
<select id="getSalesCount" resultType="java.lang.Integer">
select count(a.id) from sales a
LEFT JOIN projects b on
a.projectId=b.id
where a.deleted=0
<if test="projectid != null and projectid>0">
and a.projectid=#{projectid}
</if>
<if test="isvanker != null">
and a.isvanker=#{isvanker}
</if>
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%')
or
a.phone like CONCAT(CONCAT('%',#{keyword}),'%')
or b.name like
CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
</select>
<select id="getSalesReportList" resultType="com.w1hd.zzhnc.vo.SalesReport_Vo">
select a.id,a.name,e.name as projectname,
IFNULL(b.fanscount,0) as fanscount,
IFNULL(c.callcount,0)as callcount,
IFNULL(d.chatcount,0)as chatcount
from sales a
left join(
select count(id) as fanscount,salesid from fans group by salesId
) as b on a.id=b.salesid
left JOIN(
select count(id) callcount,salesid from calllog GROUP BY salesid
)as c on a.id=c.salesid
left join(
select count(id) chatcount,salesid from chatlog GROUP BY salesid
)as d on a.id=d.salesid
left join projects as e on a.projectId=e.id
where a.deleted=0
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
ORDER BY d.chatcount desc,b.fanscount desc
limit #{0},#{1}
</select>
<select id="getSalesReportCount" resultType="java.lang.Integer">
select count(a.id) from sales a
where a.deleted=0
<if test="keyword !=null and keyword!='' ">
and (a.name like CONCAT(CONCAT('%',#{keyword}),'%'))
</if>
</select>
</mapper>
\ No newline at end of file
package com.w1hd.zzhnc.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import com.w1hd.zzhnc.socket.PcWebSocketHandler;
import com.w1hd.zzhnc.util.RedisUtil;
@Configuration
@EnableWebMvc
@EnableWebSocket
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
// 万小二的socket地址
registry.addHandler(pcWebSocketHandler(), "/web/socket/**/0").setAllowedOrigins("*");
// 销售代表客服地址
registry.addHandler(pcWebSocketHandler(), "/web/socket/**/1").setAllowedOrigins("*");
}
@Bean
public WebSocketHandler pcWebSocketHandler() {
return new PcWebSocketHandler();
}
}
......@@ -24,6 +24,13 @@ public class ActivityController extends BaseController {
@Autowired
LotteryLogDao lotteryLogDao;
@RequestMapping("/activityList")
public ModelAndView activityList() {
ModelAndView mv = new ModelAndView("/pc/activity/activityindex");
return mv;
}
@RequestMapping("/activityindex")
public ModelAndView activityindex() {
ModelAndView mv = new ModelAndView("/pc/activity/activityindex");
......
package com.w1hd.zzhnc.controller.pc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/goods")
public class GoodsController {
@RequestMapping("/goodsList")
public ModelAndView goodsList() {
return new ModelAndView("");
}
}
package com.w1hd.zzhnc.controller.pc;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.w1hd.zzhnc.model.Postertemplet;
import com.w1hd.zzhnc.service.PosterService;
import com.w1hd.zzhnc.vo.Vo_msg;
@Controller
@RequestMapping("/poster")
public class PosterController extends BaseController{
PosterService posterService;
@RequestMapping("/coordinate")
public ModelAndView templetIndex(){
ModelAndView mv = new ModelAndView("/pc/poster/coordinate");
return mv;
}
@RequestMapping("/poster")
public ModelAndView poster(){
ModelAndView mv = new ModelAndView("/pc/poster/poster");
return mv;
}
@RequestMapping("/posterlist")
public ModelAndView posterlist(){
ModelAndView mv = new ModelAndView("/pc/poster/posterlist");
return mv;
}
//模板列表
@RequestMapping(value = "/templetList")
@ResponseBody
public Object templetList(Integer page) {
return new Vo_msg(0,posterService.getPosterList(page));
}
//添加模板
@RequestMapping(value = "/addtemplet")
@ResponseBody
public Object addtemplet(String name,String imgurl,int x,int y,int width,int height,int posttype) {
String result=posterService.addPoster(name, imgurl, x, y, width, height, posttype);
if(result.equals("ok")){
return new Vo_msg(0,"添加成功");
}else{
return new Vo_msg(-1,result);
}
}
//修改模板
@RequestMapping(value = "/updatetemplet")
@ResponseBody
public Object updatetemplet(HttpServletRequest request,Integer id,String name,String imgurl,int x,int y,int width,int height,int posttype) {
String result=posterService.updatePoster(id, name, imgurl, x, y, width, height, posttype);
if(result.equals("ok")){
return new Vo_msg(0,"修改成功");
}else{
return new Vo_msg(-1,result);
}
}
//删除模板
@RequestMapping(value = "/deletetemplet")
@ResponseBody
public Object deletetemplet(Integer id) {
String result=posterService.deletePoster(id);
if(result.equals("ok")){
return new Vo_msg(0,"删除成功");
}else{
return new Vo_msg(-1,result);
}
}
//获取
@RequestMapping(value = "/getPoster")
@ResponseBody
public Object getPoster(HttpServletRequest request,Integer id) {
Postertemplet templet=posterService.getPoster(id);
if(templet!=null){
return new Vo_msg(0,templet);
}else{
return new Vo_msg(-1,"获取失败,数据为空");
}
}
//海报模板下拉
@RequestMapping(value = "/getAllPostertemplet")
@ResponseBody
public Object getAllPostertemplet() {
return new Vo_msg(0,posterService.getAllPostertemplet());
}
}
\ No newline at end of file
package com.w1hd.zzhnc.controller.pc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/prize")
public class PrizeController {
@RequestMapping("/prizeList")
public ModelAndView prizeList() {
return new ModelAndView("");
}
}
package com.w1hd.zzhnc.controller.pc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.w1hd.zzhnc.model.Projects;
import com.w1hd.zzhnc.service.ProjectService;
import com.w1hd.zzhnc.vo.Vo_msg;
@Controller
@RequestMapping("/project")
public class ProjectsController extends BaseController{
@Autowired
ProjectService projectService;
@RequestMapping("/projectIndex")
public ModelAndView projectIndex(){
ModelAndView mv = new ModelAndView("/pc/project/projectlist");
return mv;
}
@RequestMapping("/projectEdit")
public ModelAndView projectEdit(Integer id){
ModelAndView mv = new ModelAndView("/pc/project/projectEdit");
mv.addObject("id",id);
return mv;
}
// 项目列表
@RequestMapping(value = "/getProjectList")
@ResponseBody
public Object getProjectList(Integer page,String keyword) {
return new Vo_msg(0,projectService.getProjectList(page, keyword));
}
//添加
@RequestMapping(value = "/addProject")
public @ResponseBody Object addProject(String name,String lng,String lat,Integer templetid) {
String result=projectService.addProject(name, lng, lat, templetid);
if(result.equals("ok")){
return new Vo_msg(0,"添加成功");
}else{
return new Vo_msg(-1,result);
}
}
//修改
@RequestMapping(value = "/updateProject")
@ResponseBody
public Object updateProject(Integer id,String name,String lng,String lat,Integer templetid) {
String result=projectService.updateProject(id, name, lng, lat, templetid);
if(result.equals("ok")){
return new Vo_msg(0,"修改成功");
}else{
return new Vo_msg(-1,result);
}
}
//删除
@RequestMapping(value = "/deleteProject")
@ResponseBody
public Object deleteProject(Integer id) {
String result=projectService.deleteProject(id);
if(result.equals("ok")){
return new Vo_msg(0,"添加成功");
}else{
return new Vo_msg(-1,result);
}
}
//获取项目
@RequestMapping(value = "/getProject")
@ResponseBody
public Object getProject(Integer id) {
Projects project=projectService.getProject(id);
if(project!=null){
return new Vo_msg(0,project);
}else{
return new Vo_msg(-1,"获取失败,数据为空");
}
}
//项目下拉
@RequestMapping(value = "/getAllProjects")
@ResponseBody
public Object getAllProjects() {
return new Vo_msg(0,projectService.getAllProjects());
}
}
\ No newline at end of file
......@@ -3,16 +3,11 @@ package com.w1hd.zzhnc.controller.pc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.servlet.ModelAndView;
import com.w1hd.zzhnc.service.ChatLogService;
import com.w1hd.zzhnc.service.FansService;
import com.w1hd.zzhnc.service.PosterService;
import com.w1hd.zzhnc.service.RemarksService;
import com.w1hd.zzhnc.service.SalesService;
import com.w1hd.zzhnc.vo.Vo_msg;
@Controller
......@@ -25,15 +20,12 @@ public class ReportController extends BaseController {
@Autowired
FansService fansService;
@Autowired
PosterService posterService;
@Autowired
SalesService saleService;
@Autowired
RemarksService remarkService;
@RequestMapping("/goods")
public ModelAndView goods() {
ModelAndView mv = new ModelAndView("/pc/report/goods");
return mv;
}
@RequestMapping("/chatrecord")
public ModelAndView chatrecord() {
ModelAndView mv = new ModelAndView("/pc/report/chatrecord");
......@@ -97,51 +89,5 @@ public class ReportController extends BaseController {
return new Vo_msg(0, chatlogService.getChatLogList(page, replytype, date1, date2, keyword));
}
// 粉丝记录
@RequestMapping(value = "/getFansList")
@ResponseBody
public Object getFansList(Integer page, String keyword) {
return new Vo_msg(0, fansService.getFansList(page, keyword));
}
// 海报记录
@RequestMapping(value = "/getPosterLog")
@ResponseBody
public Object getPosterLog(Integer page, String keyword, Integer postertype) {
return new Vo_msg(0, posterService.getPosterLog(page, keyword, postertype));
}
// 电话拨打记录
@RequestMapping(value = "/getCalllogList")
@ResponseBody
public Object getCalllogList(Integer page, String keyword) {
return new Vo_msg(0, fansService.getCalllogList(page, keyword));
}
// 销售报表
@RequestMapping(value = "/getSalesReportList")
@ResponseBody
public Object getSalesReportList(Integer page, String keyword) {
return new Vo_msg(0, saleService.getSalesReportList(page, keyword));
}
// 查询楼盘的评论信息
@RequestMapping(value = "/getRemarksList", method = RequestMethod.POST)
public @ResponseBody Object getRemarksList(Integer page, Integer pagesize, Integer estateid) {
return new Vo_msg(0, remarkService.getRemarksList(page, pagesize, estateid, "",null,null));
}
@RequestMapping(value = "/remarkAuditing", method = { RequestMethod.GET,RequestMethod.POST})
@ResponseBody
public Object remarkAuditing(@RequestParam("remarkId")Integer remarkId,@RequestParam("status") Integer status) {
return new Vo_msg(0, remarkService.upateRemarkStatus(remarkId, status));
}
}
\ No newline at end of file
package com.w1hd.zzhnc.controller.pc;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
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;
import org.springframework.web.servlet.ModelAndView;
import org.testng.util.Strings;
import org.theyeasy.weixin.util.WxMiniUtil;
import com.alibaba.fastjson.JSONObject;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.enums.ChatLogReplyType;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.FansPortrait;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.model.WebSockMsg;
import com.w1hd.zzhnc.service.ChatLogService;
import com.w1hd.zzhnc.service.FansPortraitService;
import com.w1hd.zzhnc.service.PosterService;
import com.w1hd.zzhnc.service.SalesService;
import com.w1hd.zzhnc.service.ZzhncSocketService;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.vo.Vo_msg;
@Controller
@RequestMapping("/sale")
public class SalesController extends BaseController {
@Autowired
SalesService saleService;
@Autowired
PosterService posterService;
@Autowired
ZzhncSocketService zzhncSocketService;
@RequestMapping("/saleIndex")
public ModelAndView salesIndex() {
ModelAndView mv = new ModelAndView("/pc/sale/sale");
return mv;
}
@Autowired
FansDao fansDao;
// 销售人员列表
@RequestMapping(value = "/getSalesList")
@ResponseBody
public Object salesList(Integer page, Integer pagesize, String keyword, Integer projectid, Boolean isvanker) {
// Boolean isvanker
return new Vo_msg(0, saleService.getSalesList(page, pagesize, keyword, projectid, isvanker));
}
// 添加销售
@RequestMapping(value = "/addsales")
@ResponseBody
public Object addsales(String name, String phone, Integer projectid, Boolean isValid, Boolean isVanker) {
String result = saleService.addSales(name, phone, projectid, isValid, isVanker);
if (result.equals("ok")) {
return new Vo_msg(0, null, "添加成功");
} else {
return new Vo_msg(-1, null, result);
}
}
// 修改销售
@RequestMapping(value = "/updatesales")
@ResponseBody
public Object updatesales(Integer id, String name, String phone, Integer projectid, Boolean isValid,
Boolean isVanker) {
String result = saleService.updateSales(id, name, phone, projectid, isValid, isVanker);
if (result.equals("ok")) {
return new Vo_msg(0, "修改成功");
} else {
return new Vo_msg(-1, result);
}
}
// 删除销售
@RequestMapping(value = "/deletesales")
@ResponseBody
public Object deletesales(Integer id) {
String result = saleService.deleteSales(id);
if (result.equals("ok")) {
return new Vo_msg(0, "删除成功");
} else {
return new Vo_msg(-1, result);
}
}
// 获取
@RequestMapping(value = "/getSales")
@ResponseBody
public Object getSales(Integer id) {
Sales sale = saleService.getSales(id);
if (sale != null) {
return new Vo_msg(0, sale);
} else {
return new Vo_msg(-1, "获取失败,数据为空");
}
}
// 导入
@RequestMapping(value = "/ExcelSales")
@ResponseBody
public Object ExcelSales(MultipartFile file) {
System.out.println("excel import begin");
if (file == null || file.isEmpty())
return new Vo_msg(-1, "导入失败,文件不能为空");
String originalFilename = file.getOriginalFilename();
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
String result = "";
try {
result = saleService.ExcelSales(suffix, file.getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
if (result.startsWith("ok")) {
return new Vo_msg(0, result);
} else {
return new Vo_msg(-1, "导入失败,数据异常");
}
}
@RequestMapping(value = "/regist")
public ModelAndView regist(Map<String, Object> model) {
ModelAndView view = new ModelAndView("/pc/sale/regist", model);
return view;
}
@Autowired
ChatLogService chatLogService;
@RequestMapping(value = "/test")
@ResponseBody
public Object test() {
return WxMiniUtil.sendCustoMiniprogrampage("oB3300KmPWcLZ1Xhc7heqHQBbKEc", "首页",
"/pages/floorlistCopy2/floorlistCopy2",
"http://mini.weiyisz.com/res/upload/posttemplet/20171120172538_496.jpg",
"HNRJmkZmfmdxGAAE4r9-yWs2ojKRdLyt5MSPpO_9sTWO4XKHzYrG30z1RJ0uXxlk");
}
@RequestMapping(value = "/chatlogList")
@ResponseBody
public Object chatLogList(HttpServletRequest request, HttpServletResponse response,
@RequestParam("salesId") Integer salesId,
@RequestParam(value = "fansId", defaultValue = "-1", required = false) Integer fansId,
@RequestParam("page") Integer page,
@RequestParam(value="pageSize", defaultValue = "100") Integer pageSize) {
if (null == page)
page = 1;
return chatLogService.getChatLogListBySalesId(salesId, fansId, page,pageSize);
}
@RequestMapping(value = "/cleanCatlogList")
@ResponseBody
public Object cleanCache(@RequestParam("salesId") Integer salesId, @RequestParam("fansId") Integer fansId) {
WebSockMsg msg = new WebSockMsg();
msg.setFansid(fansId);
msg.setSalesid(salesId);
zzhncSocketService.cleanCache(msg, true);
Fans fans = fansDao.selectByPrimaryKey(fansId);
fans.setReaded(true);
fansDao.updateByPrimaryKey(fans);
return new Vo_msg(0, true);
}
@RequestMapping(value = "/checkChatStatus")
@ResponseBody
public boolean checkChatStatus(@RequestParam("salesId") Integer salesId, @RequestParam("fansId") Integer fansId) {
return zzhncSocketService.checkChatStatus(salesId, fansId);
}
@RequestMapping(value = "/checkoutStatus")
@ResponseBody
public boolean checkoutStatus(@RequestParam("salesId") Integer salesId, @RequestParam("fansId") Integer fansId) {
if (zzhncSocketService.checkChatStatus(salesId, fansId)) {
zzhncSocketService.removeChatStatus(salesId, fansId);
new Thread(new Runnable() {
@Override
public void run() {
try {
WebSockMsg msg = new WebSockMsg();
msg.setSalesid(salesId);
msg.setFansid(fansId);
msg.setAskfrom(1);
msg.setAsktime(new Date());
Sales sales = saleService.getSales(salesId);
boolean nullOrEmpty = Strings.isNullOrEmpty(sales.getName());
String reply = nullOrEmpty ? "万小二" : sales.getName();
msg.setReply("亲,客服【" + reply + "】有事离开了,下面是万小二为您服务~[玫瑰][玫瑰]");
msg.setReadTime(new Date());
msg.setReplytype(ChatLogReplyType.自动回复.getIndex());
msg.setReaded(true);
msg.setNoticetime(new Date());
msg.setSalesid(salesId);
zzhncSocketService.recevice(msg);
} catch (Exception e) {
}
}
}).start();
return false;
} else {
zzhncSocketService.updateChatStatus(salesId, fansId);
Integer fansChatStatus = RedisUtil.getFansChatStatus(fansId);
if (fansChatStatus < 2) {
new Thread(new Runnable() {
@Override
public void run() {
try {
WebSockMsg msg = new WebSockMsg();
msg.setSalesid(salesId);
msg.setFansid(fansId);
msg.setAskfrom(1);
msg.setAsktime(new Date());
Sales sales = saleService.getSales(salesId);
boolean nullOrEmpty = Strings.isNullOrEmpty(sales.getName());
String reply = nullOrEmpty ? "万小二" : sales.getName();
msg.setReply("亲,下面是客服【" + reply + "】为您服务,万小二先退了[咖啡][咖啡]");
msg.setReadTime(new Date());
msg.setReplytype(ChatLogReplyType.自动回复.getIndex());
msg.setReaded(true);
msg.setNoticetime(new Date());
msg.setSalesid(salesId);
RedisUtil.setFansChatStatus(fansId, 2);
zzhncSocketService.recevice(msg);
} catch (Exception e) {
}
}
}).start();
}
return true;
}
}
@RequestMapping(value = "/transferSales2Sales", method = RequestMethod.POST)
@ResponseBody
public Object transferSales2Sales(@RequestParam("oldSalesId") Integer oldSalesId,
@RequestParam("salesId") Integer salesId, @RequestParam("fansId") Integer fansId) {
try {
saleService.transferSales2Sales(oldSalesId, salesId, fansId);
return new Vo_msg(0, true);
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
return new Vo_msg(-1, false);
}
@RequestMapping(value = "/sendProudct", method = RequestMethod.GET)
@ResponseBody
public Object sendProudct(@RequestParam("productId") Integer projectid, @RequestParam("fansId") Integer fansId) {
try {
String sendProudct = saleService.sendProudct(projectid, fansId);
JSONObject json = JSONObject.parseObject(sendProudct);
Integer integer = json.getInteger("errcode");
return new Vo_msg(integer, null);
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
return new Vo_msg(-1, false);
}
@Autowired
FansPortraitService fansPortraitService;
@RequestMapping(value = "/fansPortrait/{fansId}", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object fansPortrait(@RequestParam("saleId") Integer saleId, @PathVariable("fansId") Integer fansId) {
try {
FansPortrait fansPortrait = fansPortraitService.findBySaleIdAndFansId(saleId, fansId);
return new Vo_msg(0, fansPortrait);
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
return new Vo_msg(-1, false);
}
@RequestMapping(value = "/updatePortrait/{fansId}", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object updatePortrait(@RequestParam("saleId") Integer saleId, @PathVariable("fansId") Integer fansId,
@RequestParam("tag") String tag, @RequestParam("remarkName") String remarkName,
@RequestParam("phone") String phone, @RequestParam("remarkInfo") String remarkInfo) {
try {
FansPortrait fansPortrait = fansPortraitService.findBySaleIdAndFansId(saleId, fansId);
if (!Strings.isNullOrEmpty(remarkName)) {
fansPortrait.setRemarkName(remarkName);
}
if (!Strings.isNullOrEmpty(remarkInfo)) {
fansPortrait.setRemarkInfo(remarkInfo);
}
if (!Strings.isNullOrEmpty(tag)) {
fansPortrait.setTag(tag);
saleService.addTags(saleId, tag);
}
if (!Strings.isNullOrEmpty(phone)) {
fansPortrait.setPhone(phone);
}
int updateFansPortrait = fansPortraitService.updateFansPortrait(fansPortrait);
//更新fans的remarkName add by lcc 2017-12-17
Fans fans = fansDao.selectByPrimaryKey(fansId);
fans.setRemarkName(remarkName);
fansDao.updateByPrimaryKeySelective(fans);
return new Vo_msg(updateFansPortrait > 0 ? 0 : -1, fansPortrait);
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
return new Vo_msg(-1, false);
}
@RequestMapping(value = "/portrait/search", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object portraitSearch(@RequestParam("saleId") Integer saleId, @RequestParam("keywork") String keywork) {
try {
List<Fans> fans = fansPortraitService.findByKeyWord(saleId, keywork);
return new Vo_msg(0, fans);
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
return new Vo_msg(-1, false);
}
@RequestMapping(value = "/tags/{saleId}", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public Object tags(@PathVariable("saleId") Integer saleId) {
try {
Set<String> tags = fansPortraitService.tags(saleId);
return new Vo_msg(0, tags);
} catch (Exception e) {
logger.error(e.getMessage());
e.printStackTrace();
}
return new Vo_msg(-1, false);
}
}
package com.w1hd.zzhnc.controller.pc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/seller")
public class SellerController {
@RequestMapping("/sellerList")
public ModelAndView sellerList() {
return new ModelAndView("");
}
}
package com.w1hd.zzhnc.controller.pc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.w1hd.zzhnc.model.Vanker;
import com.w1hd.zzhnc.service.VankerService;
import com.w1hd.zzhnc.vo.Vo_msg;
@Controller
@RequestMapping("/vanker")
public class VankerController extends BaseController{
@Autowired
VankerService vankerService;
@RequestMapping("/vankerIndex")
public ModelAndView listView(){
ModelAndView mv = new ModelAndView("/pc/vanker/vanker");
return mv;
}
@RequestMapping("/getList")
public @ResponseBody Vo_msg getList(Integer page){
return new Vo_msg(0, vankerService.getList(page));
}
//添加
@RequestMapping(value = "/addvanker")
@ResponseBody
public Object addvanker(String name,String phone) {
String result=vankerService.addVanker(name, phone);
if(result.equals("ok")){
return new Vo_msg(0,"添加成功");
}else{
return new Vo_msg(-1,result);
}
}
//修改
@RequestMapping(value = "/updatevanker")
@ResponseBody
public Object updatevanker(Integer id,String name,String phone,Boolean isvalid) {
String result=vankerService.updateVanker(id,name, phone, isvalid);
if(result.equals("ok")){
return new Vo_msg(0,"修改成功");
}else{
return new Vo_msg(-1,result);
}
}
//删除
@RequestMapping(value = "/deletevanker")
@ResponseBody
public Object deletevanker(Integer id) {
String result=vankerService.deleteVanker(id);
if(result.equals("ok")){
return new Vo_msg(0,"删除成功");
}else{
return new Vo_msg(-1,result);
}
}
//删除
@RequestMapping(value = "/getVanker")
@ResponseBody
public Object getVanker(Integer id) {
Vanker vanker=vankerService.getVanker(id);
if(vanker!=null){
return new Vo_msg(0,vanker);
}else{
return new Vo_msg(-1,"获取失败,数据为空");
}
}
}
......@@ -20,20 +20,13 @@ import org.theyeasy.weixin.util.WXBizMsgCrypt;
import org.theyeasy.weixin.util.WxMessageUtil;
import com.w1hd.zzhnc.controller.pc.BaseController;
import com.w1hd.zzhnc.dao.SalesDao;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.service.FansService;
import com.w1hd.zzhnc.service.PosterService;
import com.w1hd.zzhnc.service.SalesService;
import com.w1hd.zzhnc.service.SysWxauthorizeService;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.vo.Vo_msg;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
@Controller
@RequestMapping("/wx")
......@@ -45,14 +38,6 @@ public class WxController extends BaseController {
@Autowired
SysWxauthorizeService sysWxauthorizeService;
@Autowired
SalesService salesService;
@Autowired
PosterService posterService;
@Autowired
SalesDao saleDao;
@Autowired
FansService fansService;
......@@ -119,7 +104,6 @@ public class WxController extends BaseController {
response.setCharacterEncoding("utf-8");
String msg = "success";
try {
String data = WxMessageUtil.readStrFromInputStream(request);
......@@ -151,79 +135,7 @@ public class WxController extends BaseController {
writer.close();
}
/* 销售人员绑定身份 */
@RequestMapping(value = "/regist")
public ModelAndView regist(Map<String, Object> model, @RequestParam(value = "code", required = false) String code, @RequestParam(value = "state", required = false) String state) {
model.put("wxMiniCode", state);// state中传入小程序的openid
model.put("wxCode", code);
// 判断是否已绑定
String linkurl = salesService.CheckBinding(state);
model.put("linkurl", linkurl);
ModelAndView view = new ModelAndView("/weixin/binding", model);
return view;
}
@RequestMapping(value = "/doRegist", method = RequestMethod.GET)
@ResponseBody
public Object doRegist(@RequestParam(value = "wxMiniCode") String wxMiniCode, @RequestParam(value = "wxCode") String wxCode, @RequestParam(value = "phone") String phone) {
String msg = "绑定成功";
try {
System.out.println("进入绑定");
WxMpOAuth2AccessToken accessToken = wxOpenService.getWxMpService(RedisUtil.getMpAppid()).oauth2getAccessToken(wxCode);
String openId = accessToken.getOpenId();
Vo_msg vo_msg = salesService.updateSalesOpenId(phone, openId, wxMiniCode);
return vo_msg;
} catch (Exception e) {
e.printStackTrace();
msg = "绑定失败,accesstoken异常";
}
return new Vo_msg(-1, null, msg);
}
@RequestMapping(value = "/chatListView")
public ModelAndView chatListView(@RequestParam("salesId") Integer salesId, @RequestParam("code") String code,@RequestParam("state") String state, Map<String, Object> model) {
WxMpOAuth2AccessToken accessToken;
String openId = "";
try {
if (code.equals("nmamtf18565803458")) {
Sales sale = saleDao.selectByPrimaryKey(salesId);
model.put("salesId", sale.getId());
model.put("isVanker", sale.getIsvanker());
model.put("fansId", 0);
return new ModelAndView("/weixin/chat", model);
}
accessToken = wxOpenService.getWxMpService(RedisUtil.getMpAppid()).oauth2getAccessToken(code);
openId = accessToken.getOpenId();
Sales sale = saleDao.selectByPrimaryKey(salesId);
int fansid=0;
if (null!=state && state.length()>0) //小程序面板的链接是不传miniopenid的,以便直接进到粉丝列表 add by lcc 17-12-17
{
Fans fans = fansService.getFansByMiniOpenid(state);
if (null!=fans) fansid=fans.getId();
}
// add by lcc 171110,打日志跟踪销售无法登录的问题。
if (sale != null) {
logger.info("销售[" + sale.getName() + "]登录:code->openid=" + openId + ", sale.openid=" + sale.getWxopenid());
} else {
logger.info("销售登录:id不存在,id=" + salesId);
}
if (sale != null && sale.getWxopenid().equals(openId)) {
model.put("salesId", sale.getId());
model.put("isVanker", sale.getIsvanker());
model.put("fansId", fansid);
return new ModelAndView("/weixin/chat", model);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
model.put("message", "访问失败!(请用销售本人微信访问该链接),openid=" + openId);
return new ModelAndView("/weixin/error", model);
}
//红包中奖页面
@RequestMapping(value = "/redpackage")
......
......@@ -21,23 +21,14 @@ import org.theyeasy.weixin.model.WxMiniSessionInfo;
import org.theyeasy.weixin.service.WxMiniService;
import org.theyeasy.weixin.util.WxMiniUtil;
import com.google.common.base.Strings;
import com.w1hd.zzhnc.controller.pc.BaseController;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.dao.PostertempletDao;
import com.w1hd.zzhnc.model.Articles;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Remarks;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.service.ActivityService;
import com.w1hd.zzhnc.service.ArticleService;
import com.w1hd.zzhnc.service.FansService;
import com.w1hd.zzhnc.service.PosterService;
import com.w1hd.zzhnc.service.RemarksService;
import com.w1hd.zzhnc.service.SalesService;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.util.StringUtil;
import com.w1hd.zzhnc.vo.Vo_msg;
@Controller
......@@ -46,17 +37,9 @@ public class WxMiniController extends BaseController {
@Autowired
FansService fansService;
@Autowired
PosterService posterService;
@Autowired
WxMiniService wxMiniService;
@Autowired
SalesService salesService;
@Autowired
RemarksService remarkService;
@Autowired
ArticleService articleService;
......@@ -67,8 +50,6 @@ public class WxMiniController extends BaseController {
@Autowired
FansDao fansDao;
@Autowired
PostertempletDao postertempletDao;
@RequestMapping("/wxmsg")
public void WxMsg(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
......@@ -120,23 +101,9 @@ public class WxMiniController extends BaseController {
Fans fans = fansService.addFans(sessionInfo, shareFansId, nickname, logo, saleId, lng, lat);
if (fans != null) {
String salephone = "4008718710";// 默认电话
if (!StringUtil.isZearoOrNull(fans.getSalesid())) {
Sales sale = salesService.getSales(fans.getSalesid());
if (sale != null && !Strings.isNullOrEmpty(sale.getPhone()))
{
salephone = sale.getPhone();
}
if (sale.getIsvanker())
{
salephone = "4008718710";
}
}
Map<String, Object> map = new HashMap<>();
map.put("fansid", fans.getId());
map.put("saleid", fans.getSalesid());
map.put("salephone", salephone);
map.put("miniOpenId", sessionInfo.getOpenid());
RedisUtil.setFansChatStatus(fans.getId(), 1);
return new Vo_msg(0, map);
......@@ -180,13 +147,6 @@ public class WxMiniController extends BaseController {
return WxMiniUtil.refreshToken();
}
// 生成海报
@RequestMapping(value = "/generatePoster", method ={ RequestMethod.POST, RequestMethod.GET})
public @ResponseBody Vo_msg generatePoster(Integer saleid) {
Vo_msg msg = posterService.GeneratePosterJPG(saleid);
return msg;
}
// 增加电话记录
@RequestMapping(value = "/addCallLog", method = { RequestMethod.POST, RequestMethod.GET})
public @ResponseBody Vo_msg addCallLog(Integer fansid, Integer saleid, String projectname) {
......@@ -198,32 +158,6 @@ public class WxMiniController extends BaseController {
}
}
// 添加楼盘评论
@RequestMapping(value = "/addRemark", method = RequestMethod.GET)
public @ResponseBody Vo_msg addRemark(Integer fansid, Integer estateid, String content) {
String result = remarkService.addRemark(fansid, content, estateid);
if (result.equals("ok")) {
return new Vo_msg(0, "保存成功");
} else {
return new Vo_msg(-1, result);
}
}
// 查询楼盘的评论信息
@RequestMapping(value = "/getRemarksList", method = RequestMethod.GET)
public @ResponseBody Object getRemarksList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "pagesize", defaultValue = "10") Integer pagesize,
@RequestParam(value = "estateid", required = false) Integer estateid,
@RequestParam(value = "fansId", required = false) Integer fansId) {
try {
PageResults<Remarks> remarksList = remarkService.getRemarksList(page, pagesize, estateid, "", 1, fansId);
return new Vo_msg(0,remarksList);
} catch (Exception e) {
e.printStackTrace();
return new Vo_msg(-1,null,e.getLocalizedMessage());
}
}
// 文章列表
@RequestMapping(value = "/getArticlesList")
......
package com.w1hd.zzhnc.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.FansPortrait;
import com.w1hd.zzhnc.util.MyMapper;
@Repository
public interface FansPortraitDao extends MyMapper<FansPortrait> {
List<Fans> findByKeyWord(@Param("salesid") Integer salesid, @Param("keyword") String keyword);
}
package com.w1hd.zzhnc.dao;
import com.w1hd.zzhnc.model.Posterlog;
import com.w1hd.zzhnc.util.MyMapper;
public interface PosterLogDao extends MyMapper<Posterlog> {
}
package com.w1hd.zzhnc.dao;
import com.w1hd.zzhnc.model.Postertemplet;
import com.w1hd.zzhnc.util.MyMapper;
public interface PostertempletDao extends MyMapper<Postertemplet> {
}
package com.w1hd.zzhnc.dao;
import com.w1hd.zzhnc.model.Projects;
import com.w1hd.zzhnc.util.MyMapper;
public interface ProjectDao extends MyMapper<Projects> {
}
package com.w1hd.zzhnc.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.w1hd.zzhnc.model.Remarks;
import com.w1hd.zzhnc.util.MyMapper;
public interface RemarksDao extends MyMapper<Remarks> {
List<Remarks> getRemarksList(Integer page,Integer pagesize,@Param("estateid") Integer estateid,
@Param("keyword")String keyword,@Param("status") Integer status,@Param("fansId") Integer fansId);
int getRemarksCount(@Param("estateid") Integer estateid,@Param("keyword")String keyword,@Param("status") Integer status,@Param("fansId") Integer fansId);
}
package com.w1hd.zzhnc.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.util.MyMapper;
import com.w1hd.zzhnc.vo.SalesReport_Vo;
import com.w1hd.zzhnc.vo.Sales_Vo;
public interface SalesDao extends MyMapper<Sales> {
List<Sales_Vo> getSalesList(int page,int pagesize,
@Param("projectid")Integer projectid,@Param("keyword")String keyword,
@Param("isvanker")Boolean isvanker);
int getSalesCount(@Param("projectid")Integer projectid,@Param("keyword")String keyword,
@Param("isvanker")Boolean isvanker);
List<SalesReport_Vo> getSalesReportList(int page,int pagesize,@Param("keyword")String keyword);
int getSalesReportCount(@Param("keyword")String keyword);
}
package com.w1hd.zzhnc.dao;
import com.w1hd.zzhnc.model.Vanker;
import com.w1hd.zzhnc.util.MyMapper;
public interface VankerDao extends MyMapper<Vanker> {
}
......@@ -20,7 +20,7 @@ public class Fans {
private Integer parentfansid;
private Integer salesid;
private Integer goodsId;
private Date createdtime;
......@@ -87,17 +87,16 @@ public class Fans {
public Integer getParentfansid() {
return parentfansid;
}
public void setParentfansid(Integer parentfansid) {
this.parentfansid = parentfansid;
}
public Integer getSalesid() {
return salesid;
public Integer getGoodsId() {
return goodsId;
}
public void setSalesid(Integer salesid) {
this.salesid = salesid;
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Date getCreatedtime() {
......@@ -206,16 +205,6 @@ public class Fans {
this.readed = readed;
}
@Override
public String toString() {
return "Fans [id=" + id + ", fanstype=" + fanstype + ", miniopenid=" + miniopenid + ", nickname=" + nickname
+ ", logo=" + logo + ", parentfansid=" + parentfansid + ", salesid=" + salesid + ", createdtime="
+ createdtime + ", lastlogintime=" + lastlogintime + ", lng=" + lng + ", lat=" + lat + ", province="
+ province + ", city=" + city + ", district=" + district + ", formattedAddress=" + formattedAddress
+ ",lastEnterTime=" + lastEnterTime + ",lastSendProgram=" + lastSendProgram + ",lastAskTime=" +lastAskTime
+ ",lastAskMsg=" + lastAskMsg + ",readed=" + readed +",remarkName=" + remarkName + "]";
}
public String getRemarkName() {
return remarkName;
}
......
package com.w1hd.zzhnc.model;
import java.util.Date;
import javax.persistence.Id;
import javax.persistence.Transient;
public class FansPortrait {
@Id
private Integer id;
private Integer saleId;
private Integer fansId;
private String remarkName;
private String phone;
private String tag;
private String remarkInfo;
private Date createDate;
private Date updateDate;
private boolean deleted;
@Transient
Fans fans;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSaleId() {
return saleId;
}
public void setSaleId(Integer saleId) {
this.saleId = saleId;
}
public Integer getFansId() {
return fansId;
}
public void setFansId(Integer fansId) {
this.fansId = fansId;
}
public String getRemarkName() {
return remarkName;
}
public void setRemarkName(String remarkName) {
this.remarkName = remarkName;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getRemarkInfo() {
return remarkInfo;
}
public void setRemarkInfo(String remarkInfo) {
this.remarkInfo = remarkInfo;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public boolean isDeleted() {
return deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public Fans getFans() {
return fans;
}
public void setFans(Fans fans) {
this.fans = fans;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
package com.w1hd.zzhnc.model;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Id;
public class Goods {
@Id
private Integer id;
private String name;
private String description;
private BigDecimal primePrice;
private BigDecimal price;
private String imageUrl;
private String bannerUrl;
private Date createtime;
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.name
*
* @return the value of goods.name
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public String getName() {
return name;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.name
*
* @param name
* the value for goods.name
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.description
*
* @return the value of goods.description
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public String getDescription() {
return description;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.description
*
* @param description
* the value for goods.description
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.prime_price
*
* @return the value of goods.prime_price
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public BigDecimal getPrimePrice() {
return primePrice;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.prime_price
*
* @param primePrice
* the value for goods.prime_price
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setPrimePrice(BigDecimal primePrice) {
this.primePrice = primePrice;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.price
*
* @return the value of goods.price
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public BigDecimal getPrice() {
return price;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.price
*
* @param price
* the value for goods.price
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setPrice(BigDecimal price) {
this.price = price;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.image_url
*
* @return the value of goods.image_url
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public String getImageUrl() {
return imageUrl;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.image_url
*
* @param imageUrl
* the value for goods.image_url
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl == null ? null : imageUrl.trim();
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.banner_url
*
* @return the value of goods.banner_url
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public String getBannerUrl() {
return bannerUrl;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.banner_url
*
* @param bannerUrl
* the value for goods.banner_url
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setBannerUrl(String bannerUrl) {
this.bannerUrl = bannerUrl == null ? null : bannerUrl.trim();
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.createtime
*
* @return the value of goods.createtime
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public Date getCreatetime() {
return createtime;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.createtime
*
* @param createtime
* the value for goods.createtime
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column goods.update_time
*
* @return the value of goods.update_time
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column goods.update_time
*
* @param updateTime
* the value for goods.update_time
*
* @mbggenerated Tue Dec 26 15:09:23 CST 2017
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.w1hd.zzhnc.model;
import java.util.Date;
public class Posterlog {
private Integer id;
private Integer postertype;
private Integer personid;
private String name;
private String imgurl;
private Integer posterid;
private Date updatedtime;
private Boolean deleted;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPostertype() {
return postertype;
}
public void setPostertype(Integer postertype) {
this.postertype = postertype;
}
public Integer getPersonid() {
return personid;
}
public void setPersonid(Integer personid) {
this.personid = personid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getImgurl() {
return imgurl;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl == null ? null : imgurl.trim();
}
public Integer getPosterid() {
return posterid;
}
public void setPosterid(Integer posterid) {
this.posterid = posterid;
}
public Date getUpdatedtime() {
return updatedtime;
}
public void setUpdatedtime(Date updatedtime) {
this.updatedtime = updatedtime;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
}
\ No newline at end of file
package com.w1hd.zzhnc.model;
import java.util.Date;
import javax.persistence.Id;
public class Postertemplet {
@Id
private Integer id;
private String name;
private String imgurl;
private Integer x;
private Integer y;
private Integer width;
private Integer height;
private Integer postertype;
private Date updatedtime;
private Boolean deleted;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getImgurl() {
return imgurl;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl == null ? null : imgurl.trim();
}
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
public Integer getY() {
return y;
}
public void setY(Integer y) {
this.y = y;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public Integer getPostertype() {
return postertype;
}
public void setPostertype(Integer postertype) {
this.postertype = postertype;
}
public Date getUpdatedtime() {
return updatedtime;
}
public void setUpdatedtime(Date updatedtime) {
this.updatedtime = updatedtime;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
}
\ No newline at end of file
package com.w1hd.zzhnc.model;
import java.util.Date;
import javax.persistence.Id;
public class Projects {
@Id
private Integer id;
private String name;
private String lng;
private String lat;
private Integer postertempletid;
private Date updatedtime;
private Boolean deleted;
private String picurl;
private String thumbMediaId;
private String imagePath;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng == null ? null : lng.trim();
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat == null ? null : lat.trim();
}
public Integer getPostertempletid() {
return postertempletid;
}
public void setPostertempletid(Integer postertempletid) {
this.postertempletid = postertempletid;
}
public Date getUpdatedtime() {
return updatedtime;
}
public void setUpdatedtime(Date updatedtime) {
this.updatedtime = updatedtime;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public String getPicurl() {
return picurl;
}
public void setPicurl(String picurl) {
this.picurl = picurl;
}
public String getThumbMediaId() {
return thumbMediaId;
}
public void setThumbMediaId(String thumbMediaId) {
this.thumbMediaId = thumbMediaId;
}
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
}
\ No newline at end of file
package com.w1hd.zzhnc.model;
import java.util.Date;
import javax.persistence.Id;
public class Remarks {
/**
* This field was generated by MyBatis Generator. This field corresponds to the
* database column remarks.id
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
@Id
private Integer id;
/**
* This field was generated by MyBatis Generator. This field corresponds to the
* database column remarks.fansid
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
private Integer fansid;
/**
* This field was generated by MyBatis Generator. This field corresponds to the
* database column remarks.content
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
private String content;
/**
* This field was generated by MyBatis Generator. This field corresponds to the
* database column remarks.estateid
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
private Integer estateid;
/**
* This field was generated by MyBatis Generator. This field corresponds to the
* database column remarks.createdtime
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
private Date createdtime;
/**
* This field was generated by MyBatis Generator. This field corresponds to the
* database column remarks.deleted
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
private Boolean deleted;
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column remarks.id
*
* @return the value of remarks.id
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
private Boolean status;
public Integer getId() {
return id;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column remarks.id
*
* @param id
* the value for remarks.id
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public void setId(Integer id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column remarks.fansid
*
* @return the value of remarks.fansid
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public Integer getFansid() {
return fansid;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column remarks.fansid
*
* @param fansid
* the value for remarks.fansid
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public void setFansid(Integer fansid) {
this.fansid = fansid;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column remarks.content
*
* @return the value of remarks.content
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public String getContent() {
return content;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column remarks.content
*
* @param content
* the value for remarks.content
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column remarks.estateid
*
* @return the value of remarks.estateid
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public Integer getEstateid() {
return estateid;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column remarks.estateid
*
* @param estateid
* the value for remarks.estateid
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public void setEstateid(Integer estateid) {
this.estateid = estateid;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column remarks.createdtime
*
* @return the value of remarks.createdtime
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public Date getCreatedtime() {
return createdtime;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column remarks.createdtime
*
* @param createdtime
* the value for remarks.createdtime
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public void setCreatedtime(Date createdtime) {
this.createdtime = createdtime;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
* of the database column remarks.deleted
*
* @return the value of remarks.deleted
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public Boolean getDeleted() {
return deleted;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
* the database column remarks.deleted
*
* @param deleted
* the value for remarks.deleted
*
* @mbggenerated Tue Nov 28 10:49:00 CST 2017
*/
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
}
\ No newline at end of file
package com.w1hd.zzhnc.model;
import java.util.Date;
import javax.persistence.Id;
public class Sales {
@Id
private Integer id;
private String name;
private String phone;
private Integer projectid;
private String miniopenid;
private String wxopenid;
private Date updatedtime;
private Date lastlogintime;
private Boolean deleted;
private Boolean isvanker;
private Boolean isvalid;
private String imgurl;
private String mediaid;
private String tags;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public Integer getProjectid() {
return projectid;
}
public void setProjectid(Integer projectid) {
this.projectid = projectid;
}
public String getMiniopenid() {
return miniopenid;
}
public void setMiniopenid(String miniopenid) {
this.miniopenid = miniopenid == null ? null : miniopenid.trim();
}
public String getWxopenid() {
return wxopenid;
}
public void setWxopenid(String wxopenid) {
this.wxopenid = wxopenid == null ? null : wxopenid.trim();
}
public Date getUpdatedtime() {
return updatedtime;
}
public void setUpdatedtime(Date updatedtime) {
this.updatedtime = updatedtime;
}
public Date getLastlogintime() {
return lastlogintime;
}
public void setLastlogintime(Date lastlogintime) {
this.lastlogintime = lastlogintime;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public Boolean getIsvanker() {
return isvanker;
}
public void setIsvanker(Boolean isvanker) {
this.isvanker = isvanker;
}
public Boolean getIsvalid() {
return isvalid;
}
public void setIsvalid(Boolean isvalid) {
this.isvalid = isvalid;
}
public String getImgurl() {
return imgurl;
}
public void setImgurl(String imgurl) {
this.imgurl = imgurl == null ? null : imgurl.trim();
}
public String getMediaid() {
return mediaid;
}
public void setMediaid(String mediaid) {
this.mediaid = mediaid == null ? null : mediaid.trim();
}
public String getTags() {
return tags;
}
public void setTags(String tags) {
this.tags = tags;
}
}
......@@ -4,95 +4,63 @@ import java.util.Date;
import javax.persistence.Id;
public class Vanker {
@Id
private Integer id;
public class Saller {
@Id
private Integer id;
private String name;
private String name;
private String address;
private String phone;
private String phone;
private String miniopenid;
private Date createtime;
private String wxopenid;
private String description;
private Date createdtime;
public Integer getId() {
return id;
}
private Date lastlogintime;
public void setId(Integer id) {
this.id = id;
}
private Boolean isvalid;
public String getName() {
return name;
}
private Boolean deleted;
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getAddress() {
return address;
}
public Integer getId() {
return id;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public void setId(Integer id) {
this.id = id;
}
public String getPhone() {
return phone;
}
public String getName() {
return name;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Date getCreatetime() {
return createtime;
}
public String getPhone() {
return phone;
}
public void setCreatetime(Date createtime) {
this.createtime = createtime;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public String getDescription() {
return description;
}
public String getMiniopenid() {
return miniopenid;
}
public void setMiniopenid(String miniopenid) {
this.miniopenid = miniopenid == null ? null : miniopenid.trim();
}
public String getWxopenid() {
return wxopenid;
}
public void setWxopenid(String wxopenid) {
this.wxopenid = wxopenid == null ? null : wxopenid.trim();
}
public Date getCreatedtime() {
return createdtime;
}
public void setCreatedtime(Date createdtime) {
this.createdtime = createdtime;
}
public Date getLastlogintime() {
return lastlogintime;
}
public void setLastlogintime(Date lastlogintime) {
this.lastlogintime = lastlogintime;
}
public Boolean getIsvalid() {
return isvalid;
}
public void setIsvalid(Boolean isvalid) {
this.isvalid = isvalid;
}
public Boolean getDeleted() {
return deleted;
}
public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
}
\ No newline at end of file
package com.w1hd.zzhnc.model;
import java.io.Serializable;
import com.w1hd.zzhnc.vo.Chatlog_Vo;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
public class WebSockMsg extends Chatlog_Vo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2872304385319676791L;
private String salelogo;
public String toJson() {
return WxGsonBuilder.create().toJson(this);
}
public static WebSockMsg fromJson(String json) {
try {
return WxGsonBuilder.create().fromJson(json, WebSockMsg.class);
} catch (Exception e) {
e.printStackTrace();
WebSockMsg msg = new WebSockMsg();
return msg;
}
}
}
......@@ -48,10 +48,8 @@ import org.testng.util.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.w1hd.zzhnc.service.ProjectService;
import com.w1hd.zzhnc.dao.AutoreplyDao;
import com.w1hd.zzhnc.model.Autoreply;
import com.w1hd.zzhnc.model.Projects;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.KeywordUtil;
import com.w1hd.zzhnc.util.PageResults;
......@@ -77,9 +75,6 @@ public class AutoreplyService {
@Autowired
AutoreplyDao autoreplyDao;
@Autowired
ProjectService projectService;
static List<RegexKeywordFilter> filterList = Lists.newArrayList();
static RegexKeywordFilter projectNameFilter = new RegexKeywordFilter();
static Map<String, Integer> projectNameMap = Maps.newHashMap();
......@@ -110,12 +105,8 @@ public class AutoreplyService {
filter.compile();
filterList.add(filter);
});
List<Projects> projects = projectService.getAllProjects();
projects.stream().forEach(project -> {
projectNameMap.put(project.getName(), project.getId());
projectNameFilter.add(project.getName());
});
projectNameMap.put("全部", 0);
projectNameFilter.add("全部");
projectNameFilter.compile();
inited = true;
}
......
......@@ -15,21 +15,12 @@ import com.beust.jcommander.internal.Lists;
import com.w1hd.zzhnc.dao.ChatlogDao;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.model.Chatlog;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.vo.ChatLog_DistinctFansIdVO;
import com.w1hd.zzhnc.vo.Chatlog_Vo;
import com.w1hd.zzhnc.vo.Vo_msg;
import tk.mybatis.mapper.entity.Example;
/**
* @ClassName ProjectServiceImpl
* @Description TODO(这里用一句话描述这个类的作用)
* @author hm
* @Date 2017年10月22日 下午5:53:36
* @version 1.0.0
*/
@Service
public class ChatLogService {
......@@ -37,12 +28,6 @@ public class ChatLogService {
ChatlogDao chatlogDao;
@Autowired
ZzhncSocketService zzhncSocketService;
@Autowired
SalesService salesService;
@Autowired
FansDao fansDao;
......@@ -76,31 +61,8 @@ public class ChatLogService {
}
public Vo_msg getChatListDistinctFansIdIn(int page,int pageRow,Integer salesId) {
Sales sales = salesService.getSales(salesId);
List<ChatLog_DistinctFansIdVO> data = Lists.newArrayList();
data = fansDao.getFansListForChat(page,pageRow,salesId);
// if (sales!=null && sales.getIsvanker())
// {
// data = chatlogDao.getFansListForVanker(salesId);
// }
// else {
// data = chatlogDao.getFansListForSale(salesId);
// }
/** 过滤粉丝
Set<Integer> set = Sets.newHashSet();
List<ChatLog_DistinctFansIdVO> result = Lists.newArrayList();
data.stream().forEach(vo -> {
boolean contains = set.contains(vo.getFansid());
if(!contains) {
if(salesId.equals(vo.getSalesid())) {
result.add(vo);
}
set.add(vo.getFansid());
}
} );
*/
return new Vo_msg(0, data);
}
......@@ -116,12 +78,8 @@ public class ChatLogService {
}
Map<String, Object> result = Maps.newHashMap();
Sales sales = salesService.getSales(fromId);
List<Integer> ids =Lists.newArrayList();
ids.add(fromId);
if (sales.getIsvanker()) {
ids.add(0);
}
List<Chatlog_Vo> chatLogs = Lists.newArrayList();
for (Integer integer : fansIds) {
List<Chatlog_Vo> logListBySalesId = chatlogDao.getChatLogListBySalesId((page - 1) * pageSize, pageSize, ids,
......
package com.w1hd.zzhnc.service;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.dao.FansPortraitDao;
import com.w1hd.zzhnc.dao.SalesDao;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.FansPortrait;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.util.StringUtil;
import tk.mybatis.mapper.entity.Example;
@Service
public class FansPortraitService {
@Autowired
FansPortraitDao fansPortraitDao;
@Autowired
FansDao fansDao;
@Autowired
SalesDao salesDao;
public List<FansPortrait> getAll() {
return fansPortraitDao.selectAll();
}
public int updateFansPortrait(FansPortrait arg0) {
if (arg0 != null && arg0.getId() != null) {
return fansPortraitDao.updateByPrimaryKeySelective(arg0);
} else {
arg0.setCreateDate(new Date(System.currentTimeMillis()));
return fansPortraitDao.insert(arg0);
}
}
public FansPortrait findBySaleIdAndFansId(Integer saleId, Integer fansId) {
Example example = new Example(FansPortrait.class);
if (StringUtil.isZearoOrNull(saleId) || StringUtil.isZearoOrNull(fansId)) {
return null;
}
example.createCriteria().andEqualTo("saleId", saleId).andEqualTo("fansId", fansId);
List<FansPortrait> fansPortraitList = fansPortraitDao.selectByExample(example);
FansPortrait fansPortrait = null;
if (fansPortraitList != null && !fansPortraitList.isEmpty()) {
fansPortrait = fansPortraitList.get(0);
} else {
fansPortrait = new FansPortrait();
fansPortrait.setFansId(fansId);
fansPortrait.setSaleId(saleId);
updateFansPortrait(fansPortrait);
}
Example fansExample = new Example(Fans.class);
fansExample.createCriteria().andEqualTo("id", fansId);
List<Fans> fansList = fansDao.selectByExample(fansExample);
if (fansList != null && !fansList.isEmpty()) {
Fans fans = fansList.get(0);
fansPortrait.setFans(fans);
}
return fansPortrait;
}
public List<Fans> findByKeyWord(Integer saleId, String keyWorkd) {
List<Fans> fansList = fansPortraitDao.findByKeyWord(saleId, keyWorkd);
return fansList;
}
public Set<String> tags(Integer saleId) {
Sales sales = salesDao.selectByPrimaryKey(saleId);
Set<String> set=new HashSet<String>();
if(sales!=null && sales.getTags()!=null) {
String tags = sales.getTags();
String[] tagList = tags.split("\\|");
for(String s:tagList) {
set.add(s);
}
}
return set;
}
}
......@@ -40,7 +40,6 @@ import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Strings;
import com.w1hd.zzhnc.dao.CalllogDao;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.dao.SalesDao;
import com.w1hd.zzhnc.model.Calllog;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.util.CommonUtil;
......@@ -67,11 +66,6 @@ public class FansService {
@Autowired
CalllogDao callLogDao;
@Autowired
SalesDao salesDao;
@Autowired
SalesService salesService;
public PageResults<Fans_Vo> getFansList(Integer page, String keyword) {
List<Fans_Vo> list = fansDao.getFansList((page - 1) * 10, 10, keyword);
......@@ -137,7 +131,6 @@ public class FansService {
fans.setLogo("");
fans.setNickname("");
fans.setParentfansid(0);
fans.setSalesid(0);
int flag = fansDao.insertSelective(fans);
return fans;// 插入成功后会返回新的id;
......@@ -155,9 +148,6 @@ public class FansService {
// 通过转发进来,获取转发者的销售id
if (!StringUtil.isZearoOrNull(shareFansId)) {
Fans sharefans = getFansById(shareFansId);
if (sharefans != null && !StringUtil.isZearoOrNull(sharefans.getSalesid())) {
salesid = sharefans.getSalesid();
}
}
......@@ -173,7 +163,6 @@ public class FansService {
fans.setLastlogintime(CommonUtil.getTime());
fans.setMiniopenid(info.getOpenid());
fans.setParentfansid(shareFansId);
fans.setSalesid(salesid);
fans.setLogo(logo);
fans.setNickname(nickname);
fans.setFanstype(1);
......@@ -191,7 +180,6 @@ public class FansService {
fans = new Fans();
fans.setId(myfans.getId());
fans.setLastlogintime(CommonUtil.getTime());
fans.setSalesid((StringUtil.isZearoOrNull(myfans.getSalesid()) ? salesid : myfans.getSalesid()));
fans.setNickname(nickname);
fans.setLogo(logo);
fans.setLng(lng);
......
/******************************************************************
*
* Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
*
* Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
* http://www.d-telemedia.com/
*
* Package: com.w1hd.zzhnc.service.impl
*
* Filename: ProjectServiceImpl.java
*
* Description: TODO(用一句话描述该文件做什么)
*
* Copyright: Copyright (c) 2017-2027
*
* Company: Theyeasy Telemedia Co.,Ltd
*
* @author: hm
*
* @version: 1.0.0
*
* Create at: 2017年10月22日 下午5:53:36
*
* Revision:
*
* 2017年10月22日 下午5:53:36
* - first revision
*
*****************************************************************/
package com.w1hd.zzhnc.service;
import java.io.File;
import java.net.URLEncoder;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.theyeasy.weixin.util.PictureHelper;
import org.theyeasy.weixin.util.WxMiniUtil;
import com.google.common.base.Strings;
import com.w1hd.zzhnc.dao.PosterLogDao;
import com.w1hd.zzhnc.dao.PostertempletDao;
import com.w1hd.zzhnc.dao.ProjectDao;
import com.w1hd.zzhnc.dao.SalesDao;
import com.w1hd.zzhnc.model.Posterlog;
import com.w1hd.zzhnc.model.Postertemplet;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.ImageUtil;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.StringUtil;
import com.w1hd.zzhnc.vo.Vo_msg;
import tk.mybatis.mapper.entity.Example;
/**
* @ClassName ProjectServiceImpl
* @Description TODO(这里用一句话描述这个类的作用)
* @author hm
* @Date 2017年10月22日 下午5:53:36
* @version 1.0.0
*/
@Service
public class PosterService {
@Autowired
PostertempletDao PostertempletDao;
@Autowired
PosterLogDao posterlogDao;
@Autowired
ProjectDao projectDao;
@Autowired
SalesDao saleDao;
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.PosterService#getPosterList(java.lang.Integer, java.lang.String)
*/
public PageResults<Postertemplet> getPosterList(Integer page) {
// TODO Auto-generated method stub
Example example = new Example(Postertemplet.class);
example.createCriteria().andEqualTo("deleted", false);
RowBounds row = new RowBounds((page - 1) * 10, 10);
example.setOrderByClause(" id desc ");
List<Postertemplet> list = PostertempletDao.selectByExampleAndRowBounds(example, row);
int total = PostertempletDao.selectCountByExample(example);
PageResults<Postertemplet> pageresult = new PageResults<>();
pageresult.setPage(page);
pageresult.setTotal(total);
pageresult.setRows(list);
pageresult.setPageSize(5);
return pageresult;
}
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.PosterService#addPoster(java.lang.String, java.lang.String, int, int, int, int,
* int)
*/
public String addPoster(String name, String imgurl, int x, int y, int width, int height, int posttype) {
// TODO Auto-generated method stub
Postertemplet poster = new Postertemplet();
poster.setName(name);
poster.setImgurl(imgurl);
poster.setX(x);
poster.setY(y);
poster.setWidth(width);
poster.setHeight(height);
poster.setPostertype(posttype);
poster.setDeleted(false);
poster.setUpdatedtime(CommonUtil.getTime());
int row = PostertempletDao.insertSelective(poster);
return row > 0 ? "ok" : "添加失败,数据异常";
}
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.PosterService#updatePoster(java.lang.Integer, java.lang.String,
* java.lang.String, int, int, int, int, int)
*/
public String updatePoster(Integer id, String name, String imgurl, int x, int y, int width, int height,
int posttype) {
Postertemplet poster = PostertempletDao.selectByPrimaryKey(id);
if (poster == null)
return "修改失败,数据异常";
boolean isclear = false;
if (!poster.getImgurl().equals(imgurl) || poster.getX() != x || poster.getY() != y
|| poster.getWidth() != width) {
isclear = true;
}
poster.setName(name);
poster.setImgurl(imgurl);
poster.setX(x);
poster.setY(y);
poster.setWidth(width);
poster.setHeight(height);
poster.setPostertype(posttype);
poster.setUpdatedtime(CommonUtil.getTime());
if (isclear) {
// 修改了模板信息则将生成的海报清空
System.out.println("清空历史生成海报记录");
ClearSalesImgurl(id);
}
int row = PostertempletDao.updateByPrimaryKeySelective(poster);
return row > 0 ? "ok" : "修改失败,数据异常";
}
void ClearSalesImgurl(Integer templetid) {
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("deleted", false);
List<Sales> saleslist = saleDao.selectByExample(example);
if (saleslist != null && saleslist.size() > 0) {
for (Sales sale : saleslist) {
Sales newsale = new Sales();
newsale.setId(sale.getId());
newsale.setImgurl("");
newsale.setMediaid("");
saleDao.updateByPrimaryKeySelective(newsale);
}
}
}
public String deletePoster(Integer id) {
Postertemplet poster = PostertempletDao.selectByPrimaryKey(id);
if (poster == null)
return "删除失败,数据异常";
poster.setDeleted(true);
int row = PostertempletDao.updateByPrimaryKeySelective(poster);
return row > 0 ? "ok" : "删除失败,数据异常";
}
public Postertemplet getPoster(Integer id) {
return PostertempletDao.selectByPrimaryKey(id);
}
public PageResults<Posterlog> getPosterLog(Integer page, String keyword, Integer postertype) {
Example example = new Example(Posterlog.class);
example.createCriteria().andEqualTo("deleted", false);
RowBounds row = new RowBounds((page - 1) * 10, 10);
if (!Strings.isNullOrEmpty(keyword)) {
example.createCriteria().andLike("name", "%" + keyword + "%");
}
if (!StringUtil.isZearoOrNull(postertype)) {
example.createCriteria().andEqualTo("postertype", postertype);
}
example.setOrderByClause(" id desc ");
List<Posterlog> list = posterlogDao.selectByExampleAndRowBounds(example, row);
int total = posterlogDao.selectCountByExample(example);
PageResults<Posterlog> pageresult = new PageResults<>();
pageresult.setPage(page);
pageresult.setTotal(total);
pageresult.setRows(list);
pageresult.setPageSize(5);
return pageresult;
}
public void addPosterLog(Integer postertype, Integer personid, String name, String imgurl, Integer posterid) {
Posterlog log = new Posterlog();
log.setImgurl(imgurl);
log.setName(name);
log.setPersonid(personid);
log.setPosterid(posterid);
log.setPostertype(postertype);
log.setDeleted(false);
log.setUpdatedtime(CommonUtil.getTime());
posterlogDao.insertSelective(log);
}
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.PosterService#GeneratePosterJPG(java.lang.Integer, java.lang.String)
*/
@Transactional
public Vo_msg GeneratePosterJPG(Integer saleid) {
Sales sale = saleDao.selectByPrimaryKey(saleid);
if (sale == null || (sale != null && Strings.isNullOrEmpty(sale.getWxopenid())))
return new Vo_msg(-1, "生成海报失败,不存在该销售人员");
// 如果存在则直接返回海报图片
if (!Strings.isNullOrEmpty(sale.getImgurl())) {
return new Vo_msg(0, sale.getImgurl());
}
// 获取项目模板信息
Postertemplet templet = null;
Example example = new Example(Postertemplet.class);
example.createCriteria().andEqualTo("deleted", false).andEqualTo("postertype", "2");
example.setOrderByClause(" id desc ");
List<Postertemplet> list = PostertempletDao.selectByExample(example);
if (list != null && list.size() > 0) {
templet = list.get(0);
}
if (templet == null || (templet != null && Strings.isNullOrEmpty(templet.getImgurl())))
return new Vo_msg(-1, "生成海报失败,项目海报模板不存在");
String qCodeUrl = "";// 小程序码路径
String scene = "";
String posterurl = "";// 海报模板
try {
scene = URLEncoder.encode(saleid + "", "utf-8");
// 获取小程序码
qCodeUrl = WxMiniUtil.getMiniCode2(scene, "", templet.getWidth(), true, 0, 255, 0);
System.out.println("qCodeUrl:" + qCodeUrl);
if (Strings.isNullOrEmpty(qCodeUrl)) {
return new Vo_msg(-1, "获取小程序码失败");
}
// 获取小程序码图片路径
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String realPath = request.getSession().getServletContext().getRealPath("/WEB-INF/");
File file = new File(realPath);
if (!file.exists()) {
file.mkdirs();
}
String newqrcodeUri = realPath + qCodeUrl;
//将小程序码转化成透明底。add By lcc 2017-12-13
PictureHelper.convertTransparent(newqrcodeUri);
System.out.println("newqrcodeUri:" + newqrcodeUri);
posterurl = ImageUtil.GenerateJPGImg(templet.getImgurl(), newqrcodeUri, templet.getX(), templet.getY(),
templet.getWidth());
System.out.println("posterurl:" + posterurl);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return new Vo_msg(-1, "生成海报失败" + e.getMessage());
}
// 修改销售的海报图片
sale.setImgurl(posterurl);
saleDao.updateByPrimaryKeySelective(sale);
return new Vo_msg(0, posterurl);
}
public List<Postertemplet> getAllPostertemplet() {
Example example = new Example(Postertemplet.class);
example.createCriteria().andEqualTo("deleted", false);
List<Postertemplet> list = PostertempletDao.selectByExample(example);
return list;
}
}
/******************************************************************
*
* Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
*
* Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
* http://www.d-telemedia.com/
*
* Package: com.w1hd.zzhnc.service.impl
*
* Filename: ProjectServiceImpl.java
*
* Description: TODO(用一句话描述该文件做什么)
*
* Copyright: Copyright (c) 2017-2027
*
* Company: Theyeasy Telemedia Co.,Ltd
*
* @author: hm
*
* @version: 1.0.0
*
* Create at: 2017年10月22日 下午5:53:36
*
* Revision:
*
* 2017年10月22日 下午5:53:36
* - first revision
*
*****************************************************************/
package com.w1hd.zzhnc.service;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.testng.util.Strings;
import com.w1hd.zzhnc.dao.ProjectDao;
import com.w1hd.zzhnc.model.Projects;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.StringUtil;
import tk.mybatis.mapper.entity.Example;
/**
* @ClassName ProjectServiceImpl
* @Description TODO(这里用一句话描述这个类的作用)
* @author hm
* @Date 2017年10月22日 下午5:53:36
* @version 1.0.0
*/
@Service
public class ProjectService {
@Autowired
ProjectDao projectDao;
public PageResults<Projects> getProjectList(Integer page,String keyword) {
Example example=new Example(Projects.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("deleted", false);
if(!Strings.isNullOrEmpty(keyword)){
criteria.andLike("name", "%"+keyword+"%");
}
RowBounds row=new RowBounds((page-1)*10,10);
example.setOrderByClause(" id desc ");
List<Projects> list=projectDao.selectByExampleAndRowBounds(example, row);
int total=projectDao.selectCountByExample(example);
PageResults<Projects> pageresult=new PageResults<>();
pageresult.setPage(page);
pageresult.setPageSize(10);
pageresult.setRows(list);
pageresult.setTotal(total);
return pageresult;
}
/* (非 Javadoc)
* Description:
* @see com.w1hd.zzhnc.service.ProjectService#addProject(java.lang.String, java.lang.String, java.lang.String, java.lang.Integer)
*/
public String addProject(String name, String lng, String lat, Integer templetid) {
if(Strings.isNullOrEmpty(name))
return "项目名称不能为空";
Projects project=new Projects();
project.setName(name);
project.setPostertempletid((templetid==null ? 0 :templetid));
project.setLat(lat);
project.setLng(lng);
project.setUpdatedtime(new Date());
project.setDeleted(false);
int row=projectDao.insertSelective(project);
return row>0?"ok":"添加失败";
}
/* (非 Javadoc)
* Description:
* @see com.w1hd.zzhnc.service.ProjectService#updateProject(java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer)
*/
public String updateProject(Integer id, String name, String lng, String lat, Integer templetid) {
if(StringUtil.isZearoOrNull(id))
return "id不能为空";
if(Strings.isNullOrEmpty(name))
return "项目名称不能为空";
if(StringUtil.isZearoOrNull(templetid))
return "项目海报模板不能为空";
Projects project=projectDao.selectByPrimaryKey(id);
if(project==null)
return "项目不存在";
project.setName(name);
project.setLat(lat);
project.setLng(lng);
project.setPostertempletid(templetid);
int row=projectDao.updateByPrimaryKeySelective(project);
return row>0?"ok":"修改失败";
}
/* (非 Javadoc)
* Description:
* @see com.w1hd.zzhnc.service.ProjectService#deleteProject(java.lang.Integer)
*/
public String deleteProject(Integer id) {
if(StringUtil.isZearoOrNull(id))
return "id不能为空";
Projects project=projectDao.selectByPrimaryKey(id);
if(project==null)
return "项目不存在";
project.setDeleted(true);
int row=projectDao.updateByPrimaryKeySelective(project);
return row>0?"ok":"删除失败";
}
/* (非 Javadoc)
* Description:
* @see com.w1hd.zzhnc.service.ProjectService#getProject(java.lang.Integer)
*/
public Projects getProject(Integer id) {
if(StringUtil.isZearoOrNull(id))
return null;
return projectDao.selectByPrimaryKey(id);
}
public List<Projects> getAllProjects() {
Example example=new Example(Projects.class);
example.createCriteria().andEqualTo("deleted",false);
example.setOrderByClause(" id desc ");
return projectDao.selectByExample(example);
}
}
/******************************************************************
*
* Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
*
* Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
* http://www.d-telemedia.com/
*
* Package: com.w1hd.zzhnc.service.impl
*
* Filename: RemarksServiceImpl.java
*
* Description: TODO(用一句话描述该文件做什么)
*
* Copyright: Copyright (c) 2017-2027
*
* Company: Theyeasy Telemedia Co.,Ltd
*
* @author: hm
*
* @version: 1.0.0
*
* Create at: 2017年11月28日 上午10:54:31
*
* Revision:
*
* 2017年11月28日 上午10:54:31
* - first revision
*
*****************************************************************/
package com.w1hd.zzhnc.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.w1hd.zzhnc.dao.RemarksDao;
import com.w1hd.zzhnc.model.Remarks;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.PageResults;
import tk.mybatis.mapper.entity.Example;
/**
* @ClassName RemarksServiceImpl
* @Description TODO(这里用一句话描述这个类的作用)
* @author hm
* @Date 2017年11月28日 上午10:54:31
* @version 1.0.0
*/
@Service
public class RemarksService {
@Autowired
RemarksDao remarkDao;
/*
* (非 Javadoc) Description:
*
* @see
* com.w1hd.zzhnc.service.RemarksService#getRemarksList(java.lang.Integer,
* java.lang.Integer, java.lang.Integer, java.lang.String)
*/
public PageResults<Remarks> getRemarksList(Integer page, Integer pagesize, Integer estateid, String keyword,Integer status,Integer fansId) {
PageResults<Remarks> pageResults = new PageResults<>();
List<Remarks> list = remarkDao.getRemarksList((page - 1) * pagesize, pagesize, estateid, keyword,status,fansId);
int total = remarkDao.getRemarksCount(estateid, keyword,status,fansId);
pageResults.setPage(page);
pageResults.setPageSize(pagesize);
pageResults.setRows(list);
pageResults.setTotal(total);
return pageResults;
}
public String addRemark(Integer fansid, String content, Integer estateid) {
Remarks remark = new Remarks();
remark.setContent(content);
remark.setFansid(fansid);
remark.setEstateid(estateid);
remark.setCreatedtime(CommonUtil.getTime());
remark.setDeleted(false);
int row = remarkDao.insertSelective(remark);
return row > 0 ? "ok" : "添加失败,数据异常";
}
public String deleteRemark(Integer id) {
Remarks remark = remarkDao.selectByPrimaryKey(id);
remark.setDeleted(true);
int row = remarkDao.updateByPrimaryKeySelective(remark);
return row > 0 ? "ok" : "删除失败,数据异常";
}
public Integer upateRemarkStatus(Integer id, Integer status) {
Remarks remark = new Remarks();
remark.setStatus(status > 0);
Example example = new Example(Remarks.class);
example.createCriteria().andEqualTo("id", id);
return remarkDao.updateByExampleSelective(remark, example);
}
}
/******************************************************************
*
* Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
*
* Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
* http://www.d-telemedia.com/
*
* Package: com.w1hd.zzhnc.service.impl
*
* Filename: ProjectServiceImpl.java
*
* Description: TODO(用一句话描述该文件做什么)
*
* Copyright: Copyright (c) 2017-2027
*
* Company: Theyeasy Telemedia Co.,Ltd
*
* @author: hm
*
* @version: 1.0.0
*
* Create at: 2017年10月22日 下午5:53:36
*
* Revision:
*
* 2017年10月22日 下午5:53:36
* - first revision
*
*****************************************************************/
package com.w1hd.zzhnc.service;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.theyeasy.weixin.service.WxOpenService;
import org.theyeasy.weixin.util.WxMiniUtil;
import com.google.common.base.Strings;
import com.w1hd.zzhnc.dao.ChatlogDao;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.dao.ProjectDao;
import com.w1hd.zzhnc.dao.SalesDao;
import com.w1hd.zzhnc.enums.ChatLogReplyType;
import com.w1hd.zzhnc.model.Chatlog;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Projects;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.ReadExcel;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.util.StringUtil;
import com.w1hd.zzhnc.vo.ExcelSales_Vo;
import com.w1hd.zzhnc.vo.SalesReport_Vo;
import com.w1hd.zzhnc.vo.Sales_Vo;
import com.w1hd.zzhnc.vo.Vo_msg;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.exception.WxErrorException;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
/**
* @ClassName ProjectServiceImpl
* @Description TODO(这里用一句话描述这个类的作用)
* @author hm
* @Date 2017年10月22日 下午5:53:36
* @version 1.0.0
*/
@Service
public class SalesService{
@Autowired
SalesDao saleDao;
@Autowired
ProjectDao projectDao;
@Autowired
ProjectService projectService;
@Autowired
PosterService posterService;
@Autowired
WxOpenService wxOpenService;
@Autowired
FansService fansService;
@Autowired
FansDao fansDao;
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#getSalesList(java.lang.Integer,
* java.lang.String)
*/
public PageResults<Sales_Vo> getSalesList(Integer page, Integer pagesize, String keyword, Integer projectid,
Boolean isvanker) {
if (StringUtil.isZearoOrNull(pagesize))
pagesize = 10;
List<Sales_Vo> list = saleDao.getSalesList((page - 1) * pagesize, pagesize, projectid, keyword, isvanker);
int total = saleDao.getSalesCount(projectid, keyword, isvanker);
PageResults<Sales_Vo> pageresult = new PageResults<>();
pageresult.setPage(page);
pageresult.setPageSize(pagesize);
pageresult.setRows(list);
pageresult.setTotal(total);
return pageresult;
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#addSales(java.lang.String,
* java.lang.String, java.lang.Integer)
*/
public String addSales(String name, String phone, Integer projectid, Boolean isValid, Boolean isVanker) {
// 判断销售是否已存在
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("phone", phone).andEqualTo("deleted", false);
if (saleDao.selectCountByExample(example) > 0)
return "添加失败,该销售人员手机已存在";
Sales sale = new Sales();
sale.setName(name);
sale.setPhone(phone);
sale.setProjectid(projectid);
sale.setDeleted(false);
sale.setUpdatedtime(CommonUtil.getTime());
sale.setIsvalid(isValid);
sale.setIsvanker(isVanker);
int row = saleDao.insertSelective(sale);
return row > 0 ? "ok" : "添加失败,数据异常";
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#updateSales(java.lang.Integer,
* java.lang.String, java.lang.String, java.lang.Integer)
*/
public String updateSales(Integer id, String name, String phone, Integer projectid, Boolean isValid,
Boolean isVanker) {
Sales sale = saleDao.selectByPrimaryKey(id);
if (sale == null)
return "修改失败,数据异常";
// 判断销售是否已存在
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("phone", phone).andEqualTo("deleted", false).andNotEqualTo("id", id);
if (saleDao.selectCountByExample(example) > 0)
return "修改失败,该销售人员手机已存在";
int originProjectId = sale.getProjectid();
sale.setName(name);
sale.setPhone(phone);
sale.setProjectid(projectid);
sale.setUpdatedtime(CommonUtil.getTime());
sale.setIsvalid(isValid);
sale.setIsvanker(isVanker);
if (originProjectId != projectid) {
sale.setImgurl("");
sale.setMediaid("");
}
int row = saleDao.updateByPrimaryKeySelective(sale);
return row > 0 ? "ok" : "修改失败,数据异常";
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#deleteSales(java.lang.Integer)
*/
public String deleteSales(Integer id) {
// TODO Auto-generated method stub
Sales sale = saleDao.selectByPrimaryKey(id);
if (sale == null)
return "数据不存在";
sale.setDeleted(true);
int row = saleDao.updateByPrimaryKeySelective(sale);
return row > 0 ? "ok" : "删除失败,数据异常";
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#getSales(java.lang.Integer)
*/
public Sales getSales(Integer id) {
// TODO Auto-generated method stub
return saleDao.selectByPrimaryKey(id);
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#ExcelSales(java.lang.String,
* java.io.InputStream)
*/
public String ExcelSales(String suffix, InputStream file) {
ReadExcel readexcel = new ReadExcel();
int row = 0;
try {
System.out.println("进入读取 excel");
// 读取excel 内容
List<ExcelSales_Vo> list = readexcel.readExcel(suffix, file);
System.out.println("list:" + list.size());
if (list != null && list.size() > 0) {
for (ExcelSales_Vo sale : list) {
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("deleted", false).andEqualTo("phone", sale.getPhone());
List<Sales> salelist = saleDao.selectByExample(example);
if (salelist != null && salelist.size() > 0) {
System.out.println("salelist:");
Sales mysale = saleDao.selectByPrimaryKey(salelist.get(0).getId());
mysale.setName(sale.getName());
mysale.setProjectid(getProjectIdByName(sale.getProjectname()));
saleDao.updateByPrimaryKeySelective(mysale);
} else {
Sales mysale = new Sales();
mysale.setName(sale.getName());
mysale.setPhone(sale.getPhone());
mysale.setDeleted(false);
mysale.setProjectid(getProjectIdByName(sale.getProjectname()));
mysale.setUpdatedtime(CommonUtil.getTime());
mysale.setIsvalid(true);
mysale.setIsvanker(false);
saleDao.insertSelective(mysale);
}
row++;
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("excelrows:" + row);
return "ok_" + row;
}
// 根据项目名称获取项目id
public Integer getProjectIdByName(String name) {
if (Strings.isNullOrEmpty(name))
return 0;
Example example = new Example(Projects.class);
example.createCriteria().andEqualTo("deleted", false).andEqualTo("name", name);
List<Projects> list = projectDao.selectByExample(example);
if (list != null && list.size() > 0) {
return list.get(0).getId();
} else {
Projects project = new Projects();
project.setName(name);
project.setPostertempletid(0);
project.setLat("");
project.setLng("");
project.setUpdatedtime(new Date());
project.setDeleted(false);
int row = projectDao.insertSelective(project);
if (row > 0) {
return project.getId();
}
}
return 0;
}
public Sales updateSalesOpenId(String phone, String openId) {
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("phone", phone);
Sales sales = new Sales();
sales.setWxopenid(openId);
saleDao.updateByExampleSelective(sales, example);
return sales;
}
/**
* 通过小程序openid获取销售,无效的或已删除的不会被获取。
*/
public Sales getSaleByMiniOpenId(String miniOpenid) {
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("deleted", false).andEqualTo("isvalid", 1).andEqualTo("miniopenid",
miniOpenid);
List<Sales> list = saleDao.selectByExample(example);
if (list.size() < 1)
return null;
return list.get(0);
}
public Vo_msg updateSalesOpenId(String phone, String openId, String wxMiniCode) {
Sales sales = null;
try {
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("phone", phone).andEqualTo("deleted", false);
List<Sales> list = saleDao.selectByExample(example);
if (list != null && list.size() > 0) {
sales = list.get(0);
sales.setWxopenid(openId);
sales.setMiniopenid(wxMiniCode);
int row = saleDao.updateByPrimaryKeySelective(sales);
// 生成海报图片
if (row > 0) {
// 绑定成功后将该销售的粉丝记录绑定的销售id清0
Fans fans = fansService.getFansByMiniOpenid(wxMiniCode);
if (fans != null) {
Fans newfans = new Fans();
newfans.setId(fans.getId());
newfans.setSalesid(sales.getId());
fansDao.updateByPrimaryKeySelective(newfans);
}
posterService.GeneratePosterJPG(sales.getId());
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return new Vo_msg(-1, "绑定失败,数据异常");
}
return new Vo_msg(0, sales);
}
public List<Sales> getVankers() {
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("deleted", false).andEqualTo("isvalid", true).andEqualTo("isvanker", true);
List<Sales> list = saleDao.selectByExample(example);
if (list.size() < 1)
return null;
return list;
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#CheckBinding(java.lang.String)
*/
public String CheckBinding(String miniopenid) {
System.out.println("miniopenid:" + miniopenid);
if (Strings.isNullOrEmpty(miniopenid))
return "";
Example example = new Example(Sales.class);
example.createCriteria().andEqualTo("deleted", false).andEqualTo("miniopenid", miniopenid);
List<Sales> list = saleDao.selectByExample(example);
String newurl = "";
try {
if (list != null && list.size() > 0) {
String url = "http://mini.weiyisz.com/wx/chatListView?salesId=" + list.get(0).getId();
newurl = wxOpenService.getWxMpService(RedisUtil.getMpAppid()).oauth2buildAuthorizationUrl(url,
WxConsts.OAUTH2_SCOPE_BASE, URLEncoder.encode(""));
}
} catch (WxErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("获取url异常");
}
System.out.println("已绑定的销售直接跳转客服面板:" + newurl);
return newurl;
}
/*
* (非 Javadoc) Description:
*
* @see com.w1hd.zzhnc.service.SalesService#getSalesReportList(int,
* java.lang.String)
*/
public PageResults<SalesReport_Vo> getSalesReportList(int page, String keyword) {
List<SalesReport_Vo> list = saleDao.getSalesReportList((page - 1) * 10, 10, keyword);
int total = saleDao.getSalesReportCount(keyword);
PageResults<SalesReport_Vo> pageResults = new PageResults<>();
pageResults.setPage(page);
pageResults.setRows(list);
pageResults.setTotal(total);
pageResults.setPageSize(10);
return pageResults;
}
@Autowired
ChatlogDao chatlogDao;
@Transactional
public void transferSales2Sales(int salesId, int newSalesId, int fansId) {
Example fansExample = new Example(Fans.class);
Criteria criteria = fansExample.createCriteria().andEqualTo("salesid", salesId);
if (fansId != 0) {
criteria.andEqualTo("id", fansId);
}
List<Fans> fanses = fansDao.selectByExample(fansExample);
Fans fans = new Fans();
fans.setSalesid(newSalesId);
fansDao.updateByExampleSelective(fans, fansExample);
Example example = new Example(Chatlog.class);
example.createCriteria().andEqualTo("salesid", salesId);
if (fansId != 0) {
example.createCriteria().andEqualTo("fansid", fansId);
}
Chatlog chatlog = new Chatlog();
chatlog.setSalesid(newSalesId);
chatlogDao.updateByExampleSelective(chatlog, example);
Sales sales = getSales(salesId);
Sales new_sales = getSales(newSalesId);
for (Fans f : fanses) {
chatlog = new Chatlog();
// "【粉丝:" + f.getNickname() + "】由" + "【销售人员:" + salesId + "】转移到【销售人员" +
// newSalesId + "】"
chatlog.setAsk("该粉丝从【" + sales.getName() + "】 转移至 【" + new_sales.getName() + "】");
chatlog.setAskfrom(1);
chatlog.setAsktime(new Date());
chatlog.setFansid(f.getId());
chatlog.setNoticetime(new Date());
chatlog.setReaded(true);
chatlog.setReadTime(new Date());
chatlog.setReplytime(new Date());
chatlog.setReplytype(ChatLogReplyType.提示信息.index);
chatlog.setSalesid(newSalesId);
chatlog.setVankerid(0);
chatlogDao.insert(chatlog);
}
}
public String sendProudct(Integer projectId, Integer fansId) {
Fans fans = fansService.getFansById(fansId);
Projects project = projectService.getProject(projectId);
Vo_msg imgMsg = WxMiniUtil.uploadImage(project.getImagePath(), true);
String media_id = imgMsg.data.toString();
System.out.println("发送卡片消息获取 media_id:" + media_id);
return WxMiniUtil.sendCustoMiniprogrampage(fans.getMiniopenid(), project.getName(),
"pages/index/index?id=" + projectId, project.getPicurl(), media_id);
}
public Sales nextVanker() {
Example example = new Example(Sales.class);
Criteria criteria = example.createCriteria();
String vankerId = RedisUtil.get("zzhnc_vanke");
if (vankerId != null) {
int id = Integer.parseInt(vankerId);
criteria.andGreaterThan("id", id++);
}
criteria.andEqualTo("isvanker", true);
criteria.andEqualTo("deleted", false);
criteria.andNotEqualTo("wxopenid", null); // 只分配给已经绑定过身份的 add by lcc 2017-12-10
List<Sales> selectByExample = saleDao.selectByExample(example);
if (selectByExample != null && selectByExample.size() > 0) {
Sales sales = selectByExample.get(0);
RedisUtil.set("zzhnc_vanke", sales.getId().toString());
return sales;
} else {
example.clear();
criteria = example.createCriteria();
criteria.andEqualTo("isvanker", true);
criteria.andEqualTo("deleted", false);
criteria.andNotEqualTo("wxopenid", null); // 只分配给已经绑定过身份的 add by lcc 2017-12-10
Sales sales = saleDao.selectByExample(example).get(0);
RedisUtil.set("zzhnc_vanke", sales.getId().toString());
return sales;
}
}
public void addTags(Integer saleId,String tag) {
Sales sales = saleDao.selectByPrimaryKey(saleId);
String tags = sales.getTags();
if(!Strings.isNullOrEmpty(tag)) {
String[] tagArr = tag.split("\\|");
if(tags == null) {
tags = tag;
}else {
for(String t:tagArr) {
if(tags.contains(tag)) {
}else{
tags+="|"+t+"";
System.out.println("销售新增【标签】"+tags);
};
}
}
}
sales.setTags(tags);
saleDao.updateByPrimaryKeySelective(sales);
}
}
package com.w1hd.zzhnc.service;
import java.util.List;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.common.base.Strings;
import com.w1hd.zzhnc.dao.VankerDao;
import com.w1hd.zzhnc.model.Vanker;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.StringUtil;
import tk.mybatis.mapper.entity.Example;
@Service
public class VankerService {
@Autowired
VankerDao vankerDao;
public PageResults<Vanker> getList(Integer page) {
Example example = new Example(Vanker.class);
example.setOrderByClause("id desc");
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("deleted", false);
RowBounds row=new RowBounds((page-1)*5,5);
List<Vanker> list = vankerDao.selectByExampleAndRowBounds(example,row);
int total=vankerDao.selectCountByExample(example);
PageResults<Vanker> pageresult = new PageResults<>();
pageresult.setPage(page);
pageresult.setPageSize(5);
pageresult.setRows(list);
pageresult.setTotal(total);
return pageresult;
}
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.VankerService#addVanker(java.lang.String, java.lang.String, boolean)
*/
public String addVanker(String name, String phone) {
// TODO Auto-generated method stub
if (Strings.isNullOrEmpty(name))
return "名称不能为空";
if (Strings.isNullOrEmpty(phone))
return "手机不能为空";
try {
Vanker vanker = new Vanker();
vanker.setDeleted(false);
vanker.setName(name);
vanker.setPhone(phone);
vanker.setCreatedtime(CommonUtil.getTime());
vanker.setIsvalid(true);
vankerDao.insertSelective(vanker);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "添加失败," + e.getMessage();
}
return "ok";
}
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.VankerService#deleteVanker(java.lang.Integer)
*/
public String deleteVanker(Integer id) {
// TODO Auto-generated method stub
if (StringUtil.isZearoOrNull(id))
return "id 不能为空";
Vanker vanker = vankerDao.selectByPrimaryKey(id);
if (vanker == null)
return "万小二不存在";
vanker.setDeleted(true);
int row = vankerDao.updateByPrimaryKey(vanker);
return row > 0 ? "ok" : "删除失败";
}
/*
* (非 Javadoc) Description:
* @see com.w1hd.zzhnc.service.VankerService#updateVanker(java.lang.Integer, java.lang.String,
* java.lang.String, boolean)
*/
public String updateVanker(Integer id, String name, String phone, Boolean isvalid) {
// TODO Auto-generated method stub
if (StringUtil.isZearoOrNull(id))
return "id 不能为空";
if (Strings.isNullOrEmpty(name))
return "名称不能为空";
if (Strings.isNullOrEmpty(phone))
return "手机不能为空";
Vanker vanker = vankerDao.selectByPrimaryKey(id);
if (vanker == null)
return "万小二不存在";
vanker.setName(name);
vanker.setPhone(phone);
vanker.setIsvalid(isvalid==null?true:false);
int row = vankerDao.updateByPrimaryKey(vanker);
return row > 0 ? "ok" : "修改失败";
}
/* (非 Javadoc)
* Description:
* @see com.w1hd.zzhnc.service.VankerService#getVanker(java.lang.Integer)
*/
public Vanker getVanker(Integer id) {
// TODO Auto-generated method stub
if (StringUtil.isZearoOrNull(id))
return null;
return vankerDao.selectByPrimaryKey(id);
}
}
package com.w1hd.zzhnc.service;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.math.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.testng.util.Strings;
import org.theyeasy.weixin.util.WxMiniUtil;
import com.alibaba.fastjson.JSONObject;
import com.w1hd.zzhnc.enums.ChatLogReplyType;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.WebSockMsg;
import com.w1hd.zzhnc.socket.TopicSender;
import com.w1hd.zzhnc.util.DateUtil;
import com.w1hd.zzhnc.util.QQFaceUtil;
import com.w1hd.zzhnc.vo.Vo_msg;
@Service
public class ZzhncSocketService {
private final static int CACHE_SIZE = 100;
private final static int CHATVIEW_SIZE = 20;
/** 记录未读消息key */
public static final String CHATLOG = "chatlog_";
/** 记录通讯状态 */
public static final String ChATSTATUS = "chat_status_";
/** 保存正在跟谁聊天的信息 */
public static final String CHATVIEWLIST = "chat_view_list_";
public static String KEY_VANKER = "chat_customer_vanker";
public static String KEY_SALES = "chat_customer_sales";
@Autowired
RedisTemplate<String, String> redisTemplate;
@Autowired
RedisTemplate<String, Integer> redisTemplate2;
@Autowired
TopicSender topicSender;
@Autowired
ChatLogService chatLogService;
@Autowired
FansService fansService;
@Autowired
SalesService salesService;
public void recevice(WebSockMsg msg) {
msg.setAsktime(new Date());
if (!msg.isReaded()) {
Fans fans = fansService.getFansById(msg.getFansid());
msg.setNickname(fans.getNickname());
msg.setLogo(fans.getLogo());
Integer replytype = msg.getReplytype();
if (replytype == null || replytype == 0) {
msg.setReplytype(ChatLogReplyType.客户文本.getIndex());
} else if (replytype == ChatLogReplyType.客户图片.getIndex()) {
msg.setImgurl(msg.getImgurl() + "?" + RandomUtils.nextInt());
}
try {
chatLogService.insertChatLog(msg);
} catch (Exception e) {
e.printStackTrace();
}
topicSender.send("zzhnc.topic", msg.toJson());
} else {
Fans fans = fansService.getFansById(msg.getFansid());
if (fans == null) {
msg.setReplytype(ChatLogReplyType.提示信息.getIndex());
msg.setReply("粉丝不存在");
topicSender.send("zzhnc.topic", msg.toJson());
return;
}
msg.setAsktime(new Date());
msg.setReadTime(new Date());
String sendCustomMsgText = null;
if (msg.getReplytype() == ChatLogReplyType.销售图片.getIndex()) {
String imgurl2 = msg.getImgurl2();
String string = imgurl2.replace("mini.weiyisz.com/zzhnc",
System.getProperty("user.dir") + "/webapps/zzhnc/WEB-INF");
System.out.println("图片绝对路径:" + string);
Vo_msg imgMsg = WxMiniUtil.uploadImage(string, true);
String media_id = imgMsg.data.toString();
fans.setLastAskMsg("【图片】");
sendCustomMsgText = WxMiniUtil.sendCustomMsgImg(fans.getMiniopenid(), media_id);
} else {
fans.setLastAskMsg(QQFaceUtil.unRegix(msg.getReply()));
sendCustomMsgText = WxMiniUtil.sendCustomMsgText(fans.getMiniopenid(),
QQFaceUtil.unRegix(msg.getReply()));
}
fans.setLastAskTime(new Date(System.currentTimeMillis()));
fans.setReaded(true);
fansService.updateFans(fans);
JSONObject json = JSONObject.parseObject(sendCustomMsgText);
Integer integer = json.getInteger("errcode");
if (integer != null && integer != 0) {
// 微信错误码返回
msg.setReplytype(integer);
msg.setReaded(false);
} else {
msg.setReplytype(ChatLogReplyType.人工客服.getIndex());
chatLogService.insertChatLog(msg);
cleanCache(msg, false);
}
topicSender.send("zzhnc.topic", msg.toJson());
}
}
private String createKey(WebSockMsg msg) {
return CHATLOG + msg.getFansid() + "-" + msg.getSalesid() + "@" + DateUtil.formatMonth(new Date());
}
/** 清除缓存信息 */
public void cleanCache(WebSockMsg msg, boolean hard) {
redisTemplate.delete(createKey(msg));
chatLogService.updateChatLogUnReaded(msg.getSalesid(), msg.getFansid());
}
public boolean handleProcess(String openId, String content, String imageUrl) {
Fans fans = fansService.getFansByMiniOpenid(openId);
WebSockMsg msg = new WebSockMsg();
if (!Strings.isNullOrEmpty(content)) {
msg.setAsk(QQFaceUtil.regix(content));
} else if (!Strings.isNullOrEmpty(imageUrl)) {
msg.setReplytype(ChatLogReplyType.客户图片.getIndex());
msg.setImgurl(imageUrl);
}
msg.setAsk(content);
msg.setAsktime(new Date(System.currentTimeMillis()));
if (fans != null) {
Integer salesid = fans.getSalesid();
msg.setFansid(fans.getId());
msg.setAskfrom((salesid == null || salesid == 0) ? 2 : 1);
msg.setLogo(Strings.isNullOrEmpty(fans.getLogo()) ? "" : fans.getLogo());
msg.setNickname(Strings.isNullOrEmpty(fans.getNickname()) ? "" : fans.getNickname());
// int connected = isConnected(salesid);
// if (connected > 0) {
msg.setSalesid(salesid);
// msg.setVankerid(connected);
boolean checkChatStatus = checkChatStatus(salesid, fans.getId());
if (checkChatStatus) {
recevice(msg);
}
return checkChatStatus;
// }
}
return false;
}
public int isConnected(Integer salesId) {
if (salesId == null) {
return -1;
}
Set<Integer> distinctRandomMembers = redisTemplate2.boundSetOps(ZzhncSocketService.KEY_SALES)
.distinctRandomMembers(redisTemplate.boundSetOps(KEY_SALES).size());
if (distinctRandomMembers == null || distinctRandomMembers.isEmpty()) {
return -1;
}
for (Integer i : distinctRandomMembers) {
if (salesId.equals(i)) {
return salesId;
}
}
return -1;
}
public boolean checkChatStatus(Integer salesId, Integer fansId) {
return !Strings.isNullOrEmpty(
redisTemplate.opsForValue().get(ChATSTATUS.concat("salesId-" + salesId + "@" + "fansId-" + fansId)));
}
public void updateChatStatus(Integer salesId, Integer fansId) {
redisTemplate.opsForValue().set(ChATSTATUS.concat("salesId-" + salesId + "@" + "fansId-" + fansId),
DateUtil.getCurrentDateTime4Str(), 10, TimeUnit.MINUTES);
}
public void removeChatStatus(Integer salesId, Integer fansId) {
redisTemplate.delete(ChATSTATUS.concat("salesId-" + salesId + "@" + "fansId-" + fansId));
}
}
package com.w1hd.zzhnc.socket;
import java.io.IOException;
import java.net.URI;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.w1hd.zzhnc.model.WebSockMsg;
import com.w1hd.zzhnc.service.ZzhncSocketService;
import com.w1hd.zzhnc.util.QQFaceUtil;
public class PcWebSocketHandler implements WebSocketHandler {
private static Logger log = LoggerFactory.getLogger(PcWebSocketHandler.class);
private static final Map<String, Map<Integer, WebSocketSession>> userMap;
@Autowired
ZzhncSocketService zzhncSocketService;
@Autowired
RedisTemplate<String, Integer> redisTemplate;
static {
userMap = new HashMap<String, Map<Integer, WebSocketSession>>();
}
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
String roomId = getRoomId(session);
Integer fromId = getFromId(session);
if (!Strings.isNullOrEmpty(roomId)) {
Map<Integer, WebSocketSession> userSocket = null;
if (userMap.containsKey(roomId)) {
userSocket = userMap.get(roomId);
} else {
userSocket = Maps.newHashMap();
}
userSocket.put(fromId, session);
userMap.put(roomId, userSocket);
}
if (roomId.equals("0")) {
redisTemplate.boundSetOps(zzhncSocketService.KEY_VANKER).add(fromId);
} else {
redisTemplate.boundSetOps(zzhncSocketService.KEY_SALES).add(fromId);
}
}
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
try {
String payload = ((TextMessage) message).getPayload();
final WebSockMsg msg = WebSockMsg.fromJson(payload);
if (msg.isReaded()) {
msg.setAsktime(new Date());
msg.setReply(QQFaceUtil.regix(msg.getReply()));
msg.setAsk(QQFaceUtil.regix(msg.getAsk()));
session.sendMessage(new TextMessage(msg.toJson()));
}
zzhncSocketService.recevice(msg);
} catch (Exception e) {
e.printStackTrace();
session.sendMessage(new TextMessage("消息处理异常"));
}
}
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
try {
webSocketSessionClosed(session, 1);
} catch (Exception e) {
e.printStackTrace();
}
}
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
try {
webSocketSessionClosed(session, 0);
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean supportsPartialMessages() {
return false;
}
/**
* 发消息给在线用户
*
* @param message
*/
public static void sendMessageToRandomVankor(TextMessage message, int idex) {
Map<Integer, WebSocketSession> map = userMap.get("0");
if (map == null || map.isEmpty()) {
return;
}
Set<Entry<Integer, WebSocketSession>> entrySet = map.entrySet();
Iterator<Entry<Integer, WebSocketSession>> iterator = entrySet.iterator();
WebSocketSession next = iterator.next().getValue();
if (next.isOpen()) {
try {
next.sendMessage(message);
} catch (IOException e1) {
e1.printStackTrace();
if (idex != 0) {
sendMessageToRandomVankor(message, idex--);
}
}
}
}
/**
* 发消息给某个用户
*/
public static void sendToOne(TextMessage message, String rid, Integer uid) {
Map<Integer, WebSocketSession> map = userMap.get(rid);
if (map != null)
map.forEach((K, V) -> {
if (K.intValue() == uid) {
if (V.isOpen()) {
try {
V.sendMessage(message);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
}
public static void sendMessage(WebSockMsg msg) {
TextMessage message = new TextMessage(msg.toJson());
try {
if (!msg.isReaded()) {
if (msg.getSalesid() == 0 || msg.getAskfrom() == 2) {
// PcWebSocketHandler.sendMessageToRandomVankor(message, 3);
} else {
PcWebSocketHandler.sendToOne(message, "1", msg.getSalesid());
PcWebSocketHandler.sendToOne(message, "0", msg.getSalesid());
}
} else {
log.info("【互动游戏】发送消息给{}{}", msg.isReaded() ? "粉丝" : "销售",
msg.isReaded() ? msg.getFansid() : msg.getSalesid());
PcWebSocketHandler.sendToOne(message, "1", msg.isReaded() ? msg.getFansid() : msg.getSalesid());
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取网址路径中的uniqueid
*
* @param uri
* 网址Uri
* @return
*/
private String getRoomId(WebSocketSession session) {
URI uri = session.getUri();
String path = uri.getPath();
if (!Strings.isNullOrEmpty(path)) {
String[] paths = path.split("/");
String uuid = paths[paths.length - 1];
return uuid;
} else {
return "";
}
}
private static Integer getFromId(WebSocketSession session) {
URI uri = session.getUri();
String path = uri.getPath();
try {
if (!Strings.isNullOrEmpty(path)) {
String[] paths = path.split("/");
String uid = paths[paths.length - 2];
return Integer.parseInt(uid);
}
} catch (Exception e) {
}
return 0;
}
/**
* 关闭WebSocketSession
*
* @param session
* @param type
* 1异常关闭 0 正常关闭
* @throws IOException
*/
private void webSocketSessionClosed(WebSocketSession session, int type) throws IOException {
if (type == 1) {
if (session.isOpen()) {
try {
session.close();
} catch (Exception e) {
}
}
}
if (getRoomId(session).equals("0")) {
redisTemplate.boundSetOps(zzhncSocketService.KEY_VANKER).remove(getFromId(session));
} else {
redisTemplate.boundSetOps(zzhncSocketService.KEY_SALES).remove(getFromId(session));
}
try {
String roomId = getRoomId(session);
Integer fromId = getFromId(session);
if (!Strings.isNullOrEmpty(roomId)) {
Map<Integer, WebSocketSession> userSocket = null;
if (userMap.containsKey(roomId)) {
userSocket = userMap.get(roomId);
userSocket.remove(fromId);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static Map<String, Map<Integer, WebSocketSession>> getUsermap() {
return userMap;
}
}
package com.w1hd.zzhnc.socket;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import com.w1hd.zzhnc.model.WebSockMsg;
/**
* 消息发送队列
*
* @author Administrator
*/
public class QueueMessage extends Thread {
private static Logger log = LoggerFactory.getLogger(QueueMessage.class);
private final static Queue<WebSockMsg> queue;
static {
queue = new LinkedList<WebSockMsg>();
}
public static void offerMessage(WebSockMsg msg) {
queue.offer(msg);
TextMessage message = new TextMessage(msg.toJson());
try {
if (!msg.isReaded()) {
if (msg.getSalesid() == 0 || msg.getAskfrom() == 2) {
PcWebSocketHandler.sendMessageToRandomVankor(message, 3);
} else {
PcWebSocketHandler.sendToOne(message, "1", msg.getSalesid());
PcWebSocketHandler.sendToOne(message, "0", msg.getSalesid());
}
} else {
log.info("【互动游戏】发送消息给{}{}", msg.isReaded() ? "粉丝" : "销售",
msg.isReaded() ? msg.getFansid() : msg.getSalesid());
PcWebSocketHandler.sendToOne(message, "1", msg.isReaded() ? msg.getFansid() : msg.getSalesid());
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void run() {
int i = 0;
int inx = 0;
while (true) {
i++;
if (i == 10000) {
try {
Thread.sleep(1000);
i = 0;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Map<String, Map<Integer, WebSocketSession>> usermap = PcWebSocketHandler.getUsermap();
WebSockMsg msg = null;
TextMessage textMessage = null;
try {
while ((msg = queue.poll()) != null) {
inx = 0;
Map<Integer, WebSocketSession> map = null;
if (msg.getAskfrom() == 2) {
map = usermap.get("0");
} else {
map = usermap.get("1");
}
if (map != null && map.size() != 0) {
map.forEach((k, v) -> {
if (v.isOpen()) {
try {
v.sendMessage(textMessage);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
if (inx <= 0) {
queue.offer(msg);
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
package com.w1hd.zzhnc.socket;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;
/**
*
* @author liang
* @description Topic生产者发送消息到Topic
*
*/
@Component("topicSender")
public class TopicSender {
@Autowired
@Qualifier("jmsTopicTemplate")
private JmsTemplate jmsTemplate;
/**
* 发送一条消息到指定的队列(目标)
* @param queueName 队列名称
* @param message 消息内容
*/
public void send(String topicName,final String message){
jmsTemplate.send(topicName, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(message);
}
});
}
}
/******************************************************************
*
* Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
*
* Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
* http://www.d-telemedia.com/
*
* Package: com.theyeasy.wykj.activemq.mq.consumer.topic
*
* Filename: GameTopicReceiver.java
*
* Description: TODO(用一句话描述该文件做什么)
*
* Copyright: Copyright (c) 2017-2027
*
* Company: Theyeasy Telemedia Co.,Ltd
*
* @author: zxt
*
* @version: 1.0.0
*
* Create at: 2017年7月27日 下午3:20:46
*
* Revision:
*
* 2017年7月27日 下午3:20:46
* - first revision
*
*****************************************************************/
package com.w1hd.zzhnc.socket;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.w1hd.zzhnc.model.WebSockMsg;
/**
* @author wykj-4
* 消费者
*/
@Component
public class ZzHncTopicReceiver implements MessageListener {
private Logger log = LoggerFactory.getLogger(getClass());
@Override
public void onMessage(Message msg) {
try {
WebSockMsg message = WebSockMsg.fromJson(((TextMessage) msg).getText());
log.info("接收到消息:message={},to={}", message.getAsk() + "," + message.getReply(), message.getFansid());
QueueMessage.offerMessage(WebSockMsg.fromJson(((TextMessage) msg).getText()));
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -12,7 +12,6 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xmlbeans.impl.piccolo.io.FileFormatException;
import com.w1hd.zzhnc.vo.ExcelSales_Vo;
import com.w1hd.zzhnc.vo.Sales_Vo;
public class ReadExcel {
......@@ -37,7 +36,6 @@ public class ReadExcel {
workbook = new XSSFWorkbook(is);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("read fail:"+e.getMessage());
}
......@@ -58,16 +56,8 @@ public class ReadExcel {
return true;
}
/**
* 读取excel文件内容
*
* @param filePath
* @throws Exception
* @throws FileFormatException
*/
public List<ExcelSales_Vo> readExcel(String suffix, InputStream is) {
// 获取workbook对象
Workbook workbook = null;
int row=0;
try {
......@@ -149,8 +139,6 @@ public class ReadExcel {
return "";
}
if (treatAsStr) {
// 虽然excel中设置的都是文本,但是数字文本还被读错,如“1”取成“1.0”
// 加上下面这句,临时把它当做文本来读取
cell.setCellType(Cell.CELL_TYPE_STRING);
}
if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
......
/******************************************************************
*
* Java Lib For JavaWeb, Powered By Shenzhen WEI YI KE JI .
*
* Copyright (c) 2017-2027 Digital Telemedia Co.,Ltd
* http://www.d-telemedia.com/
*
* Package: com.w1hd.zzhnc.vo
*
* Filename: Remarks_Vo.java
*
* Description: TODO(用一句话描述该文件做什么)
*
* Copyright: Copyright (c) 2017-2027
*
* Company: Theyeasy Telemedia Co.,Ltd
*
* @author: hm
*
* @version: 1.0.0
*
* Create at: 2017年11月28日 上午11:00:58
*
* Revision:
*
* 2017年11月28日 上午11:00:58
* - first revision
*
*****************************************************************/
package com.w1hd.zzhnc.vo;
import com.w1hd.zzhnc.model.Remarks;
/**
* @ClassName Remarks_Vo
* @Description TODO(这里用一句话描述这个类的作用)
* @author hm
* @Date 2017年11月28日 上午11:00:58
* @version 1.0.0
*/
public class Remarks_Vo extends Remarks{
private String nickname;
private String logo;
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
}
package com.w1hd.zzhnc.vo;
import com.w1hd.zzhnc.model.Sales;
public class Sales_Vo extends Sales{
private String projectname;
public String getProjectname() {
return projectname;
}
public void setProjectname(String projectname) {
this.projectname = projectname;
}
}
......@@ -4,7 +4,6 @@ import javax.servlet.http.HttpServletRequest;
import com.w1hd.zzhnc.enums.ChatLogReplyType;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.vo.Vo_msg;
public interface WxMiniService {
......@@ -61,14 +60,6 @@ public interface WxMiniService {
*/
public String sendLogin(int saleid,String wxMiniOpenId,String info);
/**
* 通过公众号给销售发送模板消息通知
* @param sale
* @param custMsg
* @param fromFans
* @return
*/
public Boolean SendTemplateToSale(Sales sale,String custMsg,Fans fromFans);
//从进入会话面板的参数sessionFrom中提取值
public String getSessionFromValue(String sessionFrom,int key);
......
......@@ -13,7 +13,6 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.RandomUtils;
import org.joda.time.DateTime;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.testng.util.Strings;
......@@ -21,16 +20,13 @@ import org.theyeasy.weixin.model.BaseMessage;
import org.theyeasy.weixin.service.WxMiniService;
import org.theyeasy.weixin.service.WxOpenService;
import org.theyeasy.weixin.service.WxPayService;
import org.theyeasy.weixin.util.BaiduAiHelper;
import org.theyeasy.weixin.util.WxMessageUtil;
import org.theyeasy.weixin.util.WxMiniUtil;
import org.theyeasy.weixin.util.WxMpUtil;
import com.alibaba.fastjson.JSONObject;
import com.w1hd.zzhnc.dao.AutoreplyDao;
import com.w1hd.zzhnc.dao.FansDao;
import com.w1hd.zzhnc.dao.LotteryLogDao;
import com.w1hd.zzhnc.dao.PostertempletDao;
import com.w1hd.zzhnc.enums.ActivityStatus;
import com.w1hd.zzhnc.enums.ChatLogReplyType;
import com.w1hd.zzhnc.model.Activity;
......@@ -38,17 +34,10 @@ import com.w1hd.zzhnc.model.Autoreply;
import com.w1hd.zzhnc.model.Chatlog;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Lotterylog;
import com.w1hd.zzhnc.model.Postertemplet;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.model.WebSockMsg;
import com.w1hd.zzhnc.service.ActivityService;
import com.w1hd.zzhnc.service.AutoreplyService;
import com.w1hd.zzhnc.service.ChatLogService;
import com.w1hd.zzhnc.service.FansService;
import com.w1hd.zzhnc.service.PosterService;
import com.w1hd.zzhnc.service.SalesService;
import com.w1hd.zzhnc.service.ZzhncSocketService;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.JsonMapper;
import com.w1hd.zzhnc.util.QQFaceUtil;
......@@ -62,8 +51,6 @@ import tk.mybatis.mapper.entity.Example.Criteria;
@Service
public class WxMiniServiceImpl implements WxMiniService {
@Autowired
ZzhncSocketService zzhncSocketService;
@Autowired
WxOpenService wxOpenService;
......@@ -72,12 +59,6 @@ public class WxMiniServiceImpl implements WxMiniService {
FansService fansService;
@Autowired
SalesService salesService;
@Autowired
PosterService posterService;
@Autowired
ChatLogService chatLogService;
@Autowired
......@@ -98,12 +79,6 @@ public class WxMiniServiceImpl implements WxMiniService {
@Autowired
WxPayService wxPayService;
@Autowired
PostertempletDao postertempletDao;
/*
* 处理微信推送过来的消息
*/
@Override
public String processRequest(HttpServletRequest request) {
String respMessage = "success";
......@@ -142,20 +117,13 @@ public class WxMiniServiceImpl implements WxMiniService {
fans = fansService.addFans(fromUserName);
System.out.println("会话事件中添加了粉丝,id=" + fans.getId());
}
int saleid = fans.getSalesid();
int saleid = fans.getGoodsId();
if (saleid < 1) // 没有销售的就分配一个万小二给他。
{
Sales sale = salesService.nextVanker();
fans.setSalesid(sale.getId());
fansDao.updateByPrimaryKeySelective(fans);
}
String sendResult = "";//
// 事件消息时cotent是null,如:CreateTime=1509166255,
// Event=user_enter_tempsession,
// ToUserName=gh_1392e9aeb921,
// FromUserName=oB3300IQDbub9yj1giLoO1DKDhd0,
// MsgType=event, SessionFrom=wxapp
if (msgType.equals(WxMessageUtil.REQ_MESSAGE_TYPE_TEXT)) {
String content = requestMap.get("Content").trim(); // 用户发送的内容
......@@ -166,8 +134,7 @@ public class WxMiniServiceImpl implements WxMiniService {
content = QQFaceUtil.regix(content);
Activity activitySetting = activityService.getActivitySetting();
if (activitySetting != null && activitySetting.getStatus() > ActivityStatus.UNSTART
.getIndex()
if (activitySetting != null && activitySetting.getStatus() > ActivityStatus.UNSTART.getIndex()
&& !content.equals("人工万小二")) {
String[] keywords = activitySetting.getKeyword().split("\\|");
boolean containKeyword = false;
......@@ -188,7 +155,7 @@ public class WxMiniServiceImpl implements WxMiniService {
// 抽奖活动已结束或红包预算已经发放完毕的回复.. add by lcc 171207
if (containKeyword && (activitySetting.getStatus() > 2 || compareTo < 0)) {
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getFinishReply());
saveChatLog(fans.getId(), content, activitySetting.getFinishReply(), fans.getSalesid(),
saveChatLog(fans.getId(), content, activitySetting.getFinishReply(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", "");
return respMessage;
}
......@@ -203,7 +170,7 @@ public class WxMiniServiceImpl implements WxMiniService {
String hasLottery = RedisUtil.get("zzhnc_lottery_fansid_" + fans.getId());
if (null != hasLottery && hasLottery.equals("1")) {
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getNoChanceReply());
saveChatLog(fans.getId(), content, activitySetting.getNoChanceReply(), fans.getSalesid(),
saveChatLog(fans.getId(), content, activitySetting.getNoChanceReply(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", "");
return respMessage;
}
......@@ -214,7 +181,7 @@ public class WxMiniServiceImpl implements WxMiniService {
int count = lotteryLogDao.selectCountByExample(example);
if (count >= 2) {
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getNoChanceReply());
saveChatLog(fans.getId(), content, activitySetting.getNoChanceReply(), fans.getSalesid(),
saveChatLog(fans.getId(), content, activitySetting.getNoChanceReply(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", "");
return respMessage;
}
......@@ -226,7 +193,7 @@ public class WxMiniServiceImpl implements WxMiniService {
int succeedCount = lotteryLogDao.selectCountByExample(example);
if (succeedCount > 0) {
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getNoChanceReply());
saveChatLog(fans.getId(), content, activitySetting.getNoChanceReply(), fans.getSalesid(),
saveChatLog(fans.getId(), content, activitySetting.getNoChanceReply(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", "");
return respMessage;
}
......@@ -247,12 +214,12 @@ public class WxMiniServiceImpl implements WxMiniService {
// if(null==fansCity || fansCity=="") msg="红包活动仅限【" + city + "】,您的省份【" +
// fansCity+ "】可能是您未授权,小二无法判断您是否在本次活动范围内,所以不能参与抽奖哦~~";
WxMiniUtil.sendCustomMsgText(fromUserName, msg);
saveChatLog(fans.getId(), content, msg, fans.getSalesid(), ChatLogReplyType.自动回复, "", "");
saveChatLog(fans.getId(), content, msg, fans.getGoodsId(), ChatLogReplyType.自动回复, "", "");
return respMessage;
}
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getReplyWait());
saveChatLog(fans.getId(), content, activitySetting.getReplyWait(), fans.getSalesid(),
saveChatLog(fans.getId(), content, activitySetting.getReplyWait(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", "");
Thread.sleep(1000);
......@@ -285,7 +252,7 @@ public class WxMiniServiceImpl implements WxMiniService {
RedisUtil.set("zzhnc_lottery_fansid_" + fans.getId(), "1", 10 * 60);
// 发送中奖提示语
WxMiniUtil.sendCustomMsgText(fromUserName, activitySetting.getReplySucceed());
saveChatLog(fans.getId(), content, activitySetting.getReplySucceed(), fans.getSalesid(),
saveChatLog(fans.getId(), content, activitySetting.getReplySucceed(), fans.getGoodsId(),
ChatLogReplyType.自动回复, "", "");
// 推送中奖链接
String url = "http://mini.weiyisz.com/zzhnc/wx/redpackage?mny=" + mny * 0.01;
......@@ -301,7 +268,7 @@ public class WxMiniServiceImpl implements WxMiniService {
String failedReply = count == 0 ? activitySetting.getUnLotteryReply()
: activitySetting.getReplyFailed2(); // 第一次和第二次未中奖的提示语有区别
WxMiniUtil.sendCustomMsgText(fromUserName, failedReply);
saveChatLog(fans.getId(), content, failedReply, fans.getSalesid(), ChatLogReplyType.自动回复,
saveChatLog(fans.getId(), content, failedReply, fans.getGoodsId(), ChatLogReplyType.自动回复,
"", "");
// 两次未中奖时推送小程序卡片
......@@ -313,66 +280,6 @@ public class WxMiniServiceImpl implements WxMiniService {
}
}
if (content.equals("我是销售") || content.equals("我是万小二"))// 发送销售人员身份认证的图文链接
{
Sales sale = salesService.getSaleByMiniOpenId(fromUserName);
if (sale == null) {
sendCustMsgIdentify(fromUserName, "身份认证");
} else {
sendLogin(sale.getId(), fromUserName, "万小二销售登录入口");
}
return respMessage;
}
if (content.equals("生成海报")) {
// 根据wxopenid确认是否销售
Sales sale = salesService.getSaleByMiniOpenId(fromUserName);
if (sale == null) // 提示先认证销售身份
{
sendCustMsgIdentify(fromUserName, "请先认证身份再生成海报");
return respMessage;
}
// 给小程序端推送该销售人员的海报
if (sale != null) {
String imgurl = sale.getImgurl();
if (null == imgurl || imgurl.length() < 1) // 销售的海报没有生成
{
Vo_msg posterMsg = posterService.GeneratePosterJPG(sale.getId());
if (posterMsg.code == 0)
imgurl = posterMsg.data.toString();
System.out.println("该销售[" + sale.getName() + "]没有生成过海报,执行了重新生成海报的方法,海报地址:" + imgurl
+ ", 生成海报方法的返回结果:" + posterMsg.toString());
}
if (null != imgurl && imgurl.length() > 0) { // 已经生成海报
Vo_msg imgMsg = WxMiniUtil.uploadImage(imgurl, false);
System.out.println("海报上传临时素材:" + imgMsg.toString());
if (imgMsg.code == 0) // 上传临时素材成功
{
String media_id = imgMsg.data.toString();
sendResult = WxMiniUtil.sendCustomMsgImg(fromUserName, media_id);
System.out.println("向粉丝推送海报图片:" + imgMsg.toString());
return respMessage;
}
}
}
}
// 判断是否人工客服接管中
boolean handle = false;
handle = zzhncSocketService.handleProcess(fromUserName, content, null);
System.out.println("客服接管状态:" + handle);
if (handle) {
// 更新fans的last_ask_time,以便最新在聊的粉丝在客服的聊天面板排在前列
fans.setLastAskTime(DateTime.now().toDate());
fans.setLastAskMsg(content);
fansDao.updateByPrimaryKey(fans);
return respMessage;
}
if (content.equals("客服"))
handle = zzhncSocketService.handleProcess(fromUserName, content, null);
// 人工客服未接管,但是与客服正在聊天,无论如何都要发模板消息
if (RedisUtil.getFansChatStatus(fans.getId()) > 1) {
nofitySalesIncludeVanker(saleid, content, fans);
......@@ -432,7 +339,6 @@ public class WxMiniServiceImpl implements WxMiniService {
String fansImgUrl = requestMap.get("PicUrl");
boolean handle = false;
handle = zzhncSocketService.handleProcess(fromUserName, "", fansImgUrl);
if (!handle) {
String imgReply = getImgReply();
WxMiniUtil.sendCustomMsgText(fromUserName, imgReply);// 还没办法自动回复图片
......@@ -462,14 +368,15 @@ public class WxMiniServiceImpl implements WxMiniService {
if (firstEnter) {
// 如果红包活动正在进行中,发送红包活动的提醒文字
Activity activitySetting = activityService.getActivitySetting();
if (activitySetting != null && activitySetting.getStatus() == ActivityStatus.RUNNING.getIndex()) {
if (activitySetting != null
&& activitySetting.getStatus() == ActivityStatus.RUNNING.getIndex()) {
welcome = activitySetting.getReplyWelcome();
}
}
sendResult = WxMiniUtil.sendCustomMsgText(fromUserName, welcome);
saveChatLog(fans.getId(), "进入会话:" + floorname, welcome, fans.getSalesid(), ChatLogReplyType.进入会话,
saveChatLog(fans.getId(), "进入会话:" + floorname, welcome, fans.getGoodsId(), ChatLogReplyType.进入会话,
"", "");
}
copyToWxkf = false; // 事件不要转发给客服系统。
......@@ -506,35 +413,24 @@ public class WxMiniServiceImpl implements WxMiniService {
return m.find();
}
@Override
// 发送模板消息给销售或万小二
public Boolean SendTemplateToSale(Sales sale, String custMsg, Fans fromFans) {
public Boolean SendTemplateToSale(String openId, String custMsg, Fans fromFans) {
System.out.println("SendTemplateToSale");
if (sale == null)
return false;
String wxOpenId = sale.getWxopenid();
if (wxOpenId == null || wxOpenId.length() < 5) {
System.out.println("SendTemplateToSale:saleid=" + sale.getId() + " 未绑定销售身份.");
return false;
}
if (fromFans.getSalesid() == 0) // 粉丝未绑定销售时,在此绑定对应销售(实际只在分配万小二时起作用) edit by lcc 2017-12-10
if (fromFans.getGoodsId() == 0) // 粉丝未绑定销售时,在此绑定对应销售(实际只在分配万小二时起作用) edit by lcc 2017-12-10
{
fromFans.setSalesid(sale.getId());
fansDao.updateByPrimaryKeySelective(fromFans);
}
String fansName = fromFans.getNickname();
if (null == fansName || fansName.equals(""))
fansName = "粉丝(id:" + fromFans.getId() + ")";
String url = "http://mini.weiyisz.com/wx/chatListView?salesId=" + sale.getId() + "&fansid=" + fromFans.getId();
String url = "http://www.baidu.com";
try {
String newurl = wxOpenService.getWxMpService(RedisUtil.getMpAppid()).oauth2buildAuthorizationUrl(url,
WxConsts.OAUTH2_SCOPE_BASE, URLEncoder.encode(fromFans.getMiniopenid()));
WxMpUtil.SendTemplate_Vanker(wxOpenId, custMsg, fansName, "无", DateTime.now().toString(), newurl);
WxMpUtil.SendTemplate_Vanker(openId, custMsg, fansName, "无", DateTime.now().toString(), newurl);
// 更新粉丝的最后触发时间
fromFans.setLastAskMsg(custMsg);
fromFans.setLastAskTime(DateTime.now().toDate());
......@@ -645,10 +541,6 @@ public class WxMiniServiceImpl implements WxMiniService {
log.setImgurl(fansImgUrl);
log.setImgurl2(replyImgurl);
WebSockMsg msg = new WebSockMsg();
BeanUtils.copyProperties(log, msg);
zzhncSocketService.recevice(msg);
return 1;
}
......@@ -713,16 +605,6 @@ public class WxMiniServiceImpl implements WxMiniService {
*/
@Override
public void nofitySalesIncludeVanker(int saleid, String content, Fans fans) {
Sales sale = new Sales();
if (saleid > 0) {
System.out.print("模板消息通知销售:" + saleid);
sale = salesService.getSales(saleid);
SendTemplateToSale(sale, content, fans); // 通知人工客服(销售)
} else {// 没有对应销售时找万小二
sale = salesService.nextVanker();
SendTemplateToSale(sale, content, fans);// 通知人工客服(万小二)
}
}
// 发送小程序卡片
......@@ -734,12 +616,12 @@ public class WxMiniServiceImpl implements WxMiniService {
// redis中如果不存在,则重新上传临时素材
if (null == media_id || media_id.length() < 1 || null == thumb_url || thumb_url.length() < 1) {
// 获取默认首页的海报
Example example = new Example(Postertemplet.class);
example.createCriteria().andEqualTo("postertype", 3).andEqualTo("deleted", false);
java.util.List<Postertemplet> posterList = postertempletDao.selectByExample(example);
if (posterList.size() < 1)
return new Vo_msg(-1, null, "小程序卡片对应的海报模板不存在");
thumb_url = posterList.get(0).getImgurl();
// Example example = new Example(Postertemplet.class);
// example.createCriteria().andEqualTo("postertype", 3).andEqualTo("deleted", false);
// java.util.List<Postertemplet> posterList = postertempletDao.selectByExample(example);
// if (posterList.size() < 1)
// return new Vo_msg(-1, null, "小程序卡片对应的海报模板不存在");
// thumb_url = posterList.get(0).getImgurl();
Vo_msg imgMsg = WxMiniUtil.uploadImage(thumb_url, false);
if (imgMsg.code != 0)
......
package org.theyeasy.weixin.util;
import java.sql.Date;
import java.util.HashMap;
import java.util.Map;
import me.chanjar.weixin.common.exception.WxErrorException;
import net.sf.json.JSONObject;
import org.apache.poi.hslf.util.SystemTimeUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
......@@ -18,14 +10,14 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import com.google.gson.Gson;
import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.model.Sales;
import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.RedisUtil;
import com.w1hd.zzhnc.vo.Vo_TemplateDataItem;
import com.w1hd.zzhnc.vo.Vo_Template_KHZXTZ;
import com.w1hd.zzhnc.vo.Vo_Template_Param;
import com.w1hd.zzhnc.vo.Vo_TemplateDataItem;
import me.chanjar.weixin.common.exception.WxErrorException;
import net.sf.json.JSONObject;
public class WxMpUtil {
// 添加消息模板 add by lcc 171027
......
Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
请先完成此消息的编辑!