From 4f5a5b0a00c01491f009074351089f086f950d3e Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 01 六月 2021 19:09:48 +0800 Subject: [PATCH] 系统配置改为数据库 --- fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java | 401 ++++++++++++++++++++++++++------------------------------ 1 files changed, 188 insertions(+), 213 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java b/fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java index f32184c..b9b63bb 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/ClientJspController.java @@ -11,6 +11,7 @@ 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; @@ -54,262 +55,236 @@ /** * 瀹㈡埛绔綉椤垫帴鍙d笌寰俊缃戦〉鎺ュ彛 - * - * @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, long 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.getCouponPrice(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)); + } + } } -- Gitblit v1.8.0