yujian
2019-08-01 c22963a2ee796e59094524cadc5a78c450ed98f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.yeshi.fanli.controller.xcx;
 
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.wx.WXUtil;
import org.yeshi.utils.wx.XCXKeFuUtil;
 
import com.yeshi.fanli.entity.system.CustomerContent;
import com.yeshi.fanli.entity.xcx.XCXSettingConfig;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.CustomerContentService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("api/xcx/v1/XcxSystemclient")
public class XcxSystemMiniController {
 
    @Resource
    private SystemClientParamsService systemClientParamsService;
 
    @Resource
    private ConfigService configService;
    
    @Resource
    private CustomerContentService customerContentService;
 
    /**
     * 
     * 方法说明: 联系客服
     * 
     * @author mawurui createTime 2018年4月25日 下午5:09:52
     * @param out
     */
    @RequestMapping("contactCustomerService")
    public void contactCustomerService(PrintWriter out) {
        String title = "联系客服";
        List<CustomerContent> contentList = customerContentService.contactCustomerService(title);
        JSONObject data = new JSONObject();
        data.put("contentList", JsonUtil.getSimpleGsonWithDate().toJson(contentList));
        out.print(JsonUtil.loadTrueResult(data));
    }
 
    /**
     * 
     * 方法说明: 人工审核 直接返回 true false
     * 
     * @author mawurui createTime 2018年4月27日 下午3:40:44
     * @param out
     */
    @RequestMapping("isTrueOrFalse")
    public void isTrueOrFalse(String appid, Integer version, PrintWriter out) {
        JSONObject data = new JSONObject();
        boolean show = configService.xcxShow(appid, version);
        data.put("show", show);
        out.print(JsonUtil.loadTrueResult(data));
    }
 
    @RequestMapping("xcxkefu")
    public void xcxKeFu(HttpServletRequest request, PrintWriter out) {
        String echostr = request.getParameter("echostr");
        LogHelper.test("小程序消息接受:" + echostr);
        if (!StringUtil.isNullOrEmpty(echostr)) {
            out.print(echostr);
        } else {
            String content = WXUtil.getWXXMLBody(request);
            Map<String, String> map = WXUtil.parseXML(content);
            String ghId = map.get("ToUserName");
            if (ghId == null) {
                out.print("");
                return;
            }
            String fromUserName = map.get("FromUserName");
            // 设置
            XCXSettingConfig info = configService.getXCXInfoByGhId(ghId);
            if (info == null)
                return;
            String acessToken = WXUtil.getAcessToken(info.getAppId(), info.getAppSecret());
            XCXKeFuUtil.sendTextImageMsg(acessToken, fromUserName, "领券购物有返利,下载APP立即拥有",
                    String.format("不只能领券,还有返利哦,下载《%s》APP,体验一下就知道了", Constant.systemCommonConfig.getProjectChineseName()),
                    "http://a.app.qq.com/o/simple.jsp?pkgname=" + Constant.systemCommonConfig.getH5PackageName(),
                    "http://www.tq05.com/img/all_logo.png");
        }
 
    }
}