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");
|
}
|
|
}
|
}
|