| | |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.config.SystemConfigKeyEnum; |
| | | import com.yeshi.fanli.util.wx.MyWXLoginUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | |
| | | |
| | | /** |
| | | * 客户端网页接口与微信网页接口 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | |
| | | @Controller |
| | | @RequestMapping("/client") |
| | | public class ClientJspController { |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private GoodsSecondClassService goodsSecondClassService; |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | |
| | | @Resource |
| | | private ShamUserService shamUserService; |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | |
| | | @Resource |
| | | private TaoBaoCouponService taoBaoCouponService; |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | @Resource |
| | | private UserInviteRecordService userInviteRecordService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | @Resource |
| | | private CustomerNameService customerNameService; |
| | | |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | @Resource |
| | | private CustomerContentService customerContentService; |
| | | |
| | | @Resource |
| | | private ShareGoodsService shareGoodsService; |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | private static final String DOWNURL2 = "http://121.42.200.138/apk/fanliquan20180124.apk"; |
| | | |
| | | @Resource |
| | | private UserInviteRecordService userInviteRecordService; |
| | | @RequestMapping(value = "/new/{uid}") |
| | | public String threeShareRepNew(@PathVariable String uid, String code, String state, String packages, |
| | | String platform, String ios, HttpSession httpSession, HttpServletRequest request) { |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages, SystemEnum.blks); |
| | | String wxState = (String) httpSession.getAttribute("wxState"); |
| | | // 通过配置参数获取 |
| | | String down = DOWNURL2; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "download_app_url"); |
| | | if (params != null) |
| | | down = params.getValue(); |
| | | |
| | | @Resource |
| | | private CustomerNameService customerNameService; |
| | | if (state != null && !state.equals(wxState)) {// 不是微信返回的! |
| | | // request.setAttribute("error", "1"); |
| | | return "redirect:" + down; |
| | | } |
| | | |
| | | @Resource |
| | | private CustomerContentService customerContentService; |
| | | // 保存邀请记录 |
| | | userInviteRecordService.saveInviteRecord(code, uid); |
| | | |
| | | private static final String DOWNURL = "http://sj.qq.com/myapp/detail.htm?apkName=" |
| | | + Constant.systemCommonConfig.getAndroidPackageName(); |
| | | return "redirect:" + down; |
| | | } |
| | | |
| | | private static final String DOWNURL2 = "http://121.42.200.138/apk/fanliquan20180124.apk"; |
| | | // 新版分享 |
| | | @RequestMapping("threeShareNew") |
| | | public String threeShareNew(HttpServletRequest request, HttpSession session, HttpServletResponse response, |
| | | long uid) { |
| | | UserInfo userInfo = userInfoService.getUserById(uid); |
| | | if (userInfo == null) { |
| | | return "share/error"; |
| | | } |
| | | |
| | | @RequestMapping(value = "/new/{uid}") |
| | | public String threeShareRepNew(@PathVariable String uid, String code, String state, String packages, |
| | | String platform, String ios, HttpSession httpSession, HttpServletRequest request) { |
| | | try { |
| | | String header = request.getHeader("User-Agent");// MicroMessenger:微信浏览器 |
| | | String ios = "ios=1"; |
| | | if (header.contains("iPhone")) { |
| | | ios = "ios=2"; |
| | | } |
| | | String redirect_uri = "http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | + Constant.systemCommonConfig.getProjectName() + "/client/new/" + uid + "?packages=" |
| | | + systemConfigService.getValueCache(SystemConfigKeyEnum.androidPackageNames, userInfo.getSystem()) + "&platform=ANDROID&" + ios; |
| | | redirect_uri = URLEncoder.encode(redirect_uri, "utf-8"); |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages, SystemEnum.blks); |
| | | String wxState = (String) httpSession.getAttribute("wxState"); |
| | | // 通过配置参数获取 |
| | | String down = DOWNURL2; |
| | | long currentTimeMillis = java.lang.System.currentTimeMillis(); |
| | | String md5 = StringUtil.Md5(currentTimeMillis + ""); |
| | | session.setAttribute("wxState", md5); |
| | | String baseUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + systemConfigService.getValueCache(SystemConfigKeyEnum.wxGZAppId, userInfo.getSystem()) |
| | | + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=" + md5 |
| | | + "#wechat_redirect"; |
| | | response.sendRedirect(baseUrl); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "download_app_url"); |
| | | if (params != null) |
| | | down = params.getValue(); |
| | | return "share2/yaoqing"; |
| | | } |
| | | |
| | | if (state!=null&&!state.equals(wxState)) {// 不是微信返回的! |
| | | // request.setAttribute("error", "1"); |
| | | return "redirect:" + down; |
| | | } |
| | | @RequestMapping("getShareGoodsInfo") |
| | | public void getShareGoodsInfo(HttpServletRequest request, long uid, String id, String sign, PrintWriter out) { |
| | | |
| | | // 保存邀请记录 |
| | | userInviteRecordService.saveInviteRecord(code, uid); |
| | | if (!StringUtil.Md5("" + uid + id + Constant.WEBPAGE_SIGN_KEY).equalsIgnoreCase(sign)) { |
| | | out.print(JsonUtil.loadFalseResult(-1, "签名错误")); |
| | | return; |
| | | } |
| | | |
| | | return "redirect:" + down; |
| | | } |
| | | // 添加分享 |
| | | try { |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | UserShareGoodsHistory userShareGoodsHistory = shareGoodsService.addShareGoodsHistory(uid, id); |
| | | LogHelper.test("生成分享图的总耗时为:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | |
| | | // 新版分享 |
| | | @RequestMapping("threeShareNew") |
| | | public String threeShareNew(HttpServletRequest request, HttpSession session, HttpServletResponse response, |
| | | long uid) { |
| | | UserInfo userInfo = userInfoService.getUserById(uid); |
| | | if (userInfo == null) { |
| | | return "share/error"; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | JSONObject shareData = new JSONObject(); |
| | | JSONArray imgArr = new JSONArray(); |
| | | String pictures = userShareGoodsHistory.getPictures(); |
| | | JSONArray pictureArray = JSONArray.fromObject(pictures); |
| | | for (int i = 0; i < pictureArray.size(); i++) { |
| | | imgArr.add(pictureArray.optString(i)); |
| | | } |
| | | |
| | | try { |
| | | String header = request.getHeader("User-Agent");// MicroMessenger:微信浏览器 |
| | | String ios = "ios=1"; |
| | | if (header.contains("iPhone")) { |
| | | ios = "ios=2"; |
| | | } |
| | | String redirect_uri = "http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | + Constant.systemCommonConfig.getProjectName() + "/client/new/" + uid + "?packages=" |
| | | + Constant.systemCommonConfig.getAndroidPackageName() + "&platform=ANDROID&" + ios; |
| | | redirect_uri = URLEncoder.encode(redirect_uri, "utf-8"); |
| | | TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(userShareGoodsHistory.getGoodsId()); |
| | | |
| | | long currentTimeMillis = java.lang.System.currentTimeMillis(); |
| | | String md5 = StringUtil.Md5(currentTimeMillis + ""); |
| | | session.setAttribute("wxState", md5); |
| | | String baseUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + MyWXLoginUtil.WEXIN_APPID |
| | | + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=" + md5 |
| | | + "#wechat_redirect"; |
| | | response.sendRedirect(baseUrl); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | shareData.put("type", "2"); |
| | | shareData.put("title", goods.getTitle()); |
| | | shareData.put("description", goods.getTitle()); |
| | | shareData.put("imgs", imgArr); |
| | | try { |
| | | data.put("wx", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("wxcircle", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("tkcode", StringUtil.getBase64String(userShareGoodsHistory.getTkCode())); |
| | | data.put("qq", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("qqzone", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("sina", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("tishi", StringUtil.getBase64String("分享中...")); |
| | | data.put("shareGoods", JsonUtil.getSimpleGson().toJson(userShareGoodsHistory)); |
| | | JSONObject goodsJSON = new JSONObject(); |
| | | goodsJSON.put("title", goods.getTitle()); |
| | | goodsJSON.put("zkPrice", goods.getZkPrice()); |
| | | // 有券 |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | |
| | | return "share2/yaoqing"; |
| | | } |
| | | goodsJSON.put("finalPrice", TaoBaoUtil.getCouponPrice(goods)); |
| | | } |
| | | data.put("goods", goodsJSON); |
| | | |
| | | @RequestMapping("getShareGoodsInfo") |
| | | public void getShareGoodsInfo(HttpServletRequest request, long uid, long id, String sign, PrintWriter out) { |
| | | String link = String.format("http://%s/%s/client/html/sharegoods/share_detail.html?uid=%s&goodsId=%s", |
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName(), |
| | | AESUtil.encrypt(uid + ""), id + ""); |
| | | try { |
| | | String shortLink = HttpUtil.getShortLink(link); |
| | | data.put("link", shortLink); |
| | | } catch (Exception e) { |
| | | data.put("link", link); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JSONObject rdata = new JSONObject(); |
| | | rdata.put("uid", uid); |
| | | rdata.put("id", id); |
| | | LogHelper.errorDetailInfo(e, rdata.toString(), request.getRequestURI()); |
| | | out.print(JsonUtil.loadFalseResult(1001, "未知错误")); |
| | | } |
| | | |
| | | if (!StringUtil.Md5("" + uid + id + Constant.WEBPAGE_SIGN_KEY).equalsIgnoreCase(sign)) { |
| | | out.print(JsonUtil.loadFalseResult(-1, "签名错误")); |
| | | return; |
| | | } |
| | | } catch (ShareGoodsException e1) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("uid", uid); |
| | | data.put("id", id); |
| | | LogHelper.errorDetailInfo(e1, data.toString(), request.getRequestURI()); |
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg())); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | // 添加分享 |
| | | try { |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | UserShareGoodsHistory userShareGoodsHistory = shareGoodsService.addShareGoodsHistory(uid, id); |
| | | LogHelper.test("生成分享图的总耗时为:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | JSONObject shareData = new JSONObject(); |
| | | JSONArray imgArr = new JSONArray(); |
| | | String pictures = userShareGoodsHistory.getPictures(); |
| | | JSONArray pictureArray = JSONArray.fromObject(pictures); |
| | | for (int i = 0; i < pictureArray.size(); i++) { |
| | | imgArr.add(pictureArray.optString(i)); |
| | | } |
| | | // 获取帮助中心列表 |
| | | |
| | | TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(userShareGoodsHistory.getGoodsId()); |
| | | @RequestMapping("getHelpList") |
| | | public void getHelpList(PrintWriter out) { |
| | | List<CustomerName> totalList = new ArrayList<>(); |
| | | int page = 0; |
| | | List<CustomerName> customerNameList = customerNameService.customerNameList(page, "", 1); |
| | | if (customerNameList != null && customerNameList.size() > 0) |
| | | totalList.addAll(customerNameList); |
| | | |
| | | shareData.put("type", "2"); |
| | | shareData.put("title", goods.getTitle()); |
| | | shareData.put("description", goods.getTitle()); |
| | | shareData.put("imgs", imgArr); |
| | | try { |
| | | data.put("wx", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("wxcircle", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("tkcode", StringUtil.getBase64String(userShareGoodsHistory.getTkCode())); |
| | | data.put("qq", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("qqzone", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("sina", StringUtil.getBase64String(shareData.toString())); |
| | | data.put("tishi", StringUtil.getBase64String("分享中...")); |
| | | data.put("shareGoods", JsonUtil.getSimpleGson().toJson(userShareGoodsHistory)); |
| | | JSONObject goodsJSON = new JSONObject(); |
| | | goodsJSON.put("title", goods.getTitle()); |
| | | goodsJSON.put("zkPrice", goods.getZkPrice()); |
| | | // 有券 |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | while (customerNameList != null && customerNameList.size() == Constant.PAGE_SIZE) { |
| | | page++; |
| | | customerNameList = customerNameService.customerNameList(page, "", 1); |
| | | if (customerNameList != null && customerNameList.size() > 0) |
| | | totalList.addAll(customerNameList); |
| | | } |
| | | |
| | | goodsJSON.put("finalPrice", TaoBaoUtil.getAfterUseCouplePrice(goods)); |
| | | } |
| | | data.put("goods", goodsJSON); |
| | | // 获取每个下面的详情 |
| | | for (CustomerName cn : totalList) { |
| | | List<CustomerContent> contentList = customerContentService.getSecondProblemList(0, "", cn.getId()); |
| | | cn.setCustomerContentList(contentList); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(totalList))); |
| | | } |
| | | |
| | | String link = String.format("http://%s/%s/client/html/sharegoods/share_detail.html?uid=%s&goodsId=%s", |
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName(), |
| | | AESUtil.encrypt(uid + ""), id + ""); |
| | | try { |
| | | String shortLink = HttpUtil.getShortLink(link); |
| | | data.put("link", shortLink); |
| | | } catch (Exception e) { |
| | | data.put("link", link); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | JSONObject rdata = new JSONObject(); |
| | | rdata.put("uid", uid); |
| | | rdata.put("id", id); |
| | | LogHelper.errorDetailInfo(e, rdata.toString(), request.getRequestURI()); |
| | | out.print(JsonUtil.loadFalseResult(1001, "未知错误")); |
| | | } |
| | | @RequestMapping("getHelpDetail") |
| | | public void getHelpDetail(long id, PrintWriter out) { |
| | | List<CustomerName> totalList = new ArrayList<>(); |
| | | CustomerContent customerContent = customerContentService.getCustomerContent(id); |
| | | out.print(JsonUtil.loadTrueResult(customerContent.getContent().replace("\n", "<br>"))); |
| | | } |
| | | |
| | | } catch (ShareGoodsException e1) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("uid", uid); |
| | | data.put("id", id); |
| | | LogHelper.errorDetailInfo(e1, data.toString(), request.getRequestURI()); |
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg())); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 获取帮助中心列表 |
| | | |
| | | @RequestMapping("getHelpList") |
| | | public void getHelpList(PrintWriter out) { |
| | | List<CustomerName> totalList = new ArrayList<>(); |
| | | int page = 0; |
| | | List<CustomerName> customerNameList = customerNameService.customerNameList(page, "", 1); |
| | | if (customerNameList != null && customerNameList.size() > 0) |
| | | totalList.addAll(customerNameList); |
| | | |
| | | while (customerNameList != null && customerNameList.size() == Constant.PAGE_SIZE) { |
| | | page++; |
| | | customerNameList = customerNameService.customerNameList(page, "", 1); |
| | | if (customerNameList != null && customerNameList.size() > 0) |
| | | totalList.addAll(customerNameList); |
| | | } |
| | | |
| | | // 获取每个下面的详情 |
| | | for (CustomerName cn : totalList) { |
| | | List<CustomerContent> contentList = customerContentService.getSecondProblemList(0, "", cn.getId()); |
| | | cn.setCustomerContentList(contentList); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(totalList))); |
| | | } |
| | | |
| | | @RequestMapping("getHelpDetail") |
| | | public void getHelpDetail(long id, PrintWriter out) { |
| | | List<CustomerName> totalList = new ArrayList<>(); |
| | | CustomerContent customerContent = customerContentService.getCustomerContent(id); |
| | | out.print(JsonUtil.loadTrueResult(customerContent.getContent().replace("\n", "<br>"))); |
| | | } |
| | | |
| | | /** |
| | | * 获取邀请有奖的规则 |
| | | * |
| | | * @param callback |
| | | * @param out |
| | | */ |
| | | @RequestMapping("getinviteactivityrules") |
| | | public void getInviteActivityRules(String callback, PrintWriter out) { |
| | | String key = "activityRules"; // key值 |
| | | com.yeshi.fanli.entity.system.BusinessSystem system = new BusinessSystem(); |
| | | system.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | system.setPlatform(1); |
| | | system.setId(4L); |
| | | SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key); |
| | | // 转换换行符 给前端 |
| | | String valueN = values.getValue(); |
| | | String valueBr = valueN.replace("\n", "<br><br>"); |
| | | if (!StringUtil.isNullOrEmpty(callback)) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(valueBr))); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueResult(valueBr)); |
| | | } |
| | | } |
| | | /** |
| | | * 获取邀请有奖的规则 |
| | | * |
| | | * @param callback |
| | | * @param out |
| | | */ |
| | | @RequestMapping("getinviteactivityrules") |
| | | public void getInviteActivityRules(String callback, PrintWriter out) { |
| | | String key = "activityRules"; // key值 |
| | | com.yeshi.fanli.entity.system.BusinessSystem system = new BusinessSystem(); |
| | | system.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | system.setPlatform(1); |
| | | system.setId(4L); |
| | | SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key); |
| | | // 转换换行符 给前端 |
| | | String valueN = values.getValue(); |
| | | String valueBr = valueN.replace("\n", "<br><br>"); |
| | | if (!StringUtil.isNullOrEmpty(callback)) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(valueBr))); |
| | | } else { |
| | | out.print(JsonUtil.loadTrueResult(valueBr)); |
| | | } |
| | | } |
| | | |
| | | } |