| | |
| | | package com.yeshi.fanli.controller;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.text.MessageFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.ui.Model;
|
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.taobao.api.ApiException;
|
| | | import com.yeshi.fanli.entity.admin.InviteGetMoney;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSecondClass;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendDetails;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSectionDetail;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSectionGoods;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.InviteUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.CustomerContent;
|
| | | import com.yeshi.fanli.entity.system.CustomerName;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.RelateGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoCoupon;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.share.ShareGoodsException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
|
| | | import com.yeshi.fanli.service.inter.config.CustomerContentService;
|
| | | import com.yeshi.fanli.service.inter.config.CustomerNameService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.ClassRecommendGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsSecondClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendDetailsService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionDetailService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.RecommendSectionService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoCouponService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleRankService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.ScanHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.ShareManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInviteRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.Utils;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | private GoodsSecondClassService goodsSecondClassService;
|
| | |
|
| | | @Resource
|
| | | private ClassRecommendGoodsService classRecommendGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ScanHistoryService scanHistoryService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private ShareManageService shareManageService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
| | | private TaoBaoCouponService taoBaoCouponService;
|
| | |
|
| | | @Resource
|
| | | private RecommendDetailsService recommendDetailsService;
|
| | | @Resource
|
| | | private RecommendSectionService recommendSectionService;
|
| | |
|
| | | @Resource
|
| | | private RecommendSectionGoodsService recommendSectionGoodsService;
|
| | |
|
| | | @Resource
|
| | | private RecommendSectionDetailService recommendSectionDetailService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleRankService threeSaleRankService;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteRecordService userInviteRecordService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private InviteGetMoneyService inviteGetMoneyService;
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | | private CustomerNameService customerNameService;
|
| | |
|
| | | @Resource
|
| | | private CustomerContentService customerContentService;
|
| | |
|
| | | private static final String DOWNURL = "http://sj.qq.com/myapp/detail.htm?apkName="
|
| | | + Constant.systemCommonConfig.getAndroidPackageName();
|
| | |
|
| | | private static final String DOWNURL2 = "http://121.42.200.138/apk/fanliquan20180124.apk";
|
| | |
|
| | | @RequestMapping("classify")
|
| | | public String setClassify(long id, String key, String title, Model model) {
|
| | | String decodeKey = "";
|
| | | String decodeName = "";
|
| | | try {
|
| | | decodeKey = new String(key.getBytes("iso8859-1"), "UTF-8");
|
| | | decodeName = new String(title.getBytes("iso8859-1"), "UTF-8");
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | decodeKey = key;
|
| | | decodeName = title;
|
| | | e.printStackTrace();
|
| | | }
|
| | | List<GoodsSecondClass> goodsSecondClassList = goodsSecondClassService.getGoodsSecondClassByGoodsClassId(id);
|
| | | List<TaoBaoGoodsBriefExtra> taoBaoGoodsBriefExtraList = scanHistoryService
|
| | | .getHotTaoBaoGoodsBriefExtras(decodeKey, 1);
|
| | | model.addAttribute("goodsSecondClassList", goodsSecondClassList);
|
| | | model.addAttribute("taoBaoGoodsBriefExtraList", taoBaoGoodsBriefExtraList);
|
| | | model.addAttribute("title", decodeName);
|
| | | return "classify";
|
| | | }
|
| | |
|
| | | @RequestMapping("coupon")
|
| | | public String conpon(Model model) {
|
| | | List<TaoBaoCoupon> couponList = taoBaoCouponService.getTaoBaoCouponList("", 1);
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | String jsonArr = Utils.imgListSize(JsonUtil.getApiCommonGson().toJson(couponList));
|
| | | JSONArray jsonArray = JSONArray.fromObject(jsonArr);
|
| | | List<TaoBaoCoupon> collection = (List<TaoBaoCoupon>) JSONArray.toCollection(jsonArray, TaoBaoCoupon.class);
|
| | | model.addAttribute("couponList", collection);
|
| | | model.addAttribute("proportion", proportion);
|
| | | return "coupon";
|
| | | }
|
| | |
|
| | | @RequestMapping("findThreeFriendsCount")
|
| | | public void findThreeFriendsCount(long id, String callback, PrintWriter out) {
|
| | | int count1 = userInfoService.findFriendsCount(id, 1);
|
| | | int count2 = userInfoService.findFriendsCount(id, 2);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count1", count1);
|
| | | data.put("count2", count2);
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("findThreeFriends")
|
| | | public void findThreeFriends(long id, int type, int page, String callback, PrintWriter out) {
|
| | | int pageSize = 30;
|
| | | List<InviteUser> list = userInfoService.getFriendsList(id, type, page, pageSize);
|
| | | JSONArray array = new JSONArray();
|
| | | for (InviteUser user : list) {
|
| | | JSONObject item = JSONObject.fromObject(new GsonBuilder().create().toJson(user.getUserInfo()));
|
| | | item.put("valid", user.isValid());
|
| | | array.add(item);
|
| | | }
|
| | |
|
| | | long count = userInfoService.getFriendsListCount(id, type);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", array);
|
| | | data.put("pages", count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getConpon", method = RequestMethod.POST)
|
| | | public void getConpon(int page, PrintWriter out) {
|
| | | List<TaoBaoCoupon> taoBaoCouponList = taoBaoCouponService.getTaoBaoCouponList("", page);
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("taoBaoCouponList", Utils.imgListSize(JsonUtil.getApiCommonGson().toJson(taoBaoCouponList)));
|
| | | data.put("proportion", proportion);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getHotGoods", method = RequestMethod.POST)
|
| | | public void getHotGoods(String key, int page, PrintWriter out) {
|
| | | List<TaoBaoGoodsBriefExtra> taoBaoGoodsBriefExtraList = scanHistoryService.getHotTaoBaoGoodsBriefExtras(key,
|
| | | page);
|
| | | if (taoBaoGoodsBriefExtraList.size() > 0) {
|
| | | out.append(JsonUtil.loadTrueResult(taoBaoGoodsBriefExtraList));
|
| | | } else {
|
| | | out.append(JsonUtil.loadFalseResult("没有更多商品"));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("share")
|
| | | public String getShare(Model model, String uid) {
|
| | | String value = configService.get("share_message");
|
| | | try {
|
| | | if (uid == null) {
|
| | | uid = "0";
|
| | | }
|
| | | String base64String = StringUtil.getBase64String(uid + "");
|
| | | String format = MessageFormat.format(value, base64String);
|
| | | model.addAttribute("share", format);
|
| | | model.addAttribute("down",
|
| | | "http://file.sovideo.cn/buxinjie/weixinfriendinvite/index.html?yqm=" + base64String);
|
| | | model.addAttribute("shareCode", "邀请码:" + base64String);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return "getcash";
|
| | | }
|
| | |
|
| | | @RequestMapping("shares")
|
| | | public String getShares(Model model, String uid) {
|
| | | String value = configService.get("share_message");
|
| | | try {
|
| | | if (uid == null) {
|
| | | uid = "0";
|
| | | }
|
| | | String base64String = StringUtil.getBase64String(uid + "");
|
| | | String format = MessageFormat.format(value, base64String);
|
| | | model.addAttribute("share", format);
|
| | | model.addAttribute("uid", uid);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return "invite";
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/{uid}")
|
| | | public String threeShareRep(@PathVariable String uid, String code, String state, String packages, String platform,
|
| | | String ios, HttpSession httpSession, HttpServletRequest request) {
|
| | |
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages);
|
| | | String wxState = (String) httpSession.getAttribute("wxState");
|
| | | // 通过配置参数获取
|
| | | String down = DOWNURL2;
|
| | |
|
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
|
| | | "fenxiao_download_apk_url");
|
| | | if (params != null)
|
| | | down = params.getValue();
|
| | | if ("2".equalsIgnoreCase(ios)) {
|
| | | down = DOWNURL;
|
| | | }
|
| | | if (!state.equals(wxState)) {// 不是微信返回的!
|
| | | // request.setAttribute("error", "1");
|
| | | return "redirect:" + down;
|
| | | }
|
| | | if (code == null) {// 用户取消了登陆!
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
|
| | | UserInfo inviter = userInfoService.getUserById(Long.parseLong(uid));
|
| | | if (inviter == null) {// 没得这个人
|
| | | return "redirect:" + down;
|
| | | }
|
| | | boolean b = userInfoService.inviteWXUserInfo(code, inviter);
|
| | | if (!b) { // 绑定失败
|
| | | // request.setAttribute("msg", "非常遗憾,你已领取过红包,请勿再次领取。");
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "/new/{uid}")
|
| | | public String threeShareRepNew(@PathVariable String uid, String code, String state, String packages,
|
| | |
| | | if (params != null)
|
| | | down = params.getValue();
|
| | |
|
| | | if (!state.equals(wxState)) {// 不是微信返回的!
|
| | | if (state!=null&&!state.equals(wxState)) {// 不是微信返回的!
|
| | | // request.setAttribute("error", "1");
|
| | | return "redirect:" + down;
|
| | | }
|
| | | if (code == null) {// 用户取消了登陆!
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
|
| | | UserInfo inviter = userInfoService.getUserById(Long.parseLong(uid));
|
| | | if (inviter == null) {// 没得这个人
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
|
| | | boolean b = userInfoService.inviteWXUserInfo(code, inviter);
|
| | | if (!b) { // 绑定失败
|
| | | // request.setAttribute("msg", "非常遗憾,你已领取过红包,请勿再次领取。");
|
| | | return "redirect:" + down;
|
| | | }
|
| | | // 保存邀请记录
|
| | | userInviteRecordService.saveInviteRecord(code, uid);
|
| | |
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
|
| | | @RequestMapping("threeShare")
|
| | | public String threeShare(HttpServletRequest request, HttpSession session, long uid) {
|
| | | String serverName = request.getServerName();
|
| | | String contextPath = request.getContextPath();
|
| | | UserInfo userInfo = userInfoService.getUserById(uid);
|
| | | if (userInfo == null) {
|
| | | return "share/error";
|
| | | }
|
| | |
|
| | | try {
|
| | | String header = request.getHeader("User-Agent");// MicroMessenger:微信浏览器
|
| | | String ios = "ios=1";
|
| | | if (header.contains("iPhone")) {
|
| | | ios = "ios=2";
|
| | | }
|
| | | String redirect_uri = "http://" + serverName + contextPath + "/client/" + uid + "?packages="
|
| | | + Constant.systemCommonConfig.getAndroidPackageName() + "&platform=ANDROID&" + ios;
|
| | | redirect_uri = URLEncoder.encode(redirect_uri, "utf-8");
|
| | | 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=" + WXLoginUtil.WEXIN_APPID
|
| | | + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=" + md5
|
| | | + "#wechat_redirect";
|
| | | // List<HongBaoMessage> list =
|
| | | // shamUserService.findShamThreeSaleInfo();
|
| | | request.setAttribute("jumpUrl", baseUrl);
|
| | | request.setAttribute("name", userInfo.getNickName());
|
| | | request.setAttribute("picture", userInfo.getPortrait());
|
| | | // request.setAttribute("list", list);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return "share2/yaoqing";
|
| | | }
|
| | |
|
| | | // 新版分享
|
| | | @RequestMapping("threeShareNew")
|
| | | public String threeShareNew(HttpServletRequest request, HttpSession session, HttpServletResponse response,
|
| | | long uid) {
|
| | | String serverName = request.getServerName();
|
| | | String contextPath = request.getContextPath();
|
| | | UserInfo userInfo = userInfoService.getUserById(uid);
|
| | | if (userInfo == null) {
|
| | | return "share/error";
|
| | |
| | | }
|
| | |
|
| | | return "share2/yaoqing";
|
| | | }
|
| | |
|
| | | @RequestMapping("callBack")
|
| | | public void callBack(HttpServletRequest request, PrintWriter out) {
|
| | | if (!StringUtil.isNullOrEmpty(request.getParameter("echostr"))) {
|
| | | out.print(request.getParameter("echostr"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Map<String, String> map = WXUtil.parseXML(request);
|
| | | String ghId = map.get("ToUserName");
|
| | | if (ghId == null) {
|
| | | out.print("");
|
| | | return;
|
| | | }
|
| | | String type = map.get("MsgType");
|
| | | if ("event".equalsIgnoreCase(type)) {
|
| | | String event = map.get("Event");
|
| | | if (event.equalsIgnoreCase("subscribe")) {// 关注
|
| | | Map<String, String> parmas = new HashMap<>();
|
| | | parmas.put("ToUserName", map.get("FromUserName"));
|
| | | parmas.put("FromUserName", ghId);
|
| | | parmas.put("CreateTime", java.lang.System.currentTimeMillis() / 1000 + "");
|
| | | parmas.put("MsgType", "text");
|
| | | parmas.put("Content", Constant.wxGZConfig.getWelcomeMsg());
|
| | | out.print(WXUtil.loadWXMessage(parmas));
|
| | | }
|
| | | } else if ("text".equalsIgnoreCase(type)) {
|
| | | String content = map.get("Content");
|
| | | if (!StringUtil.isNullOrEmpty(content)) {
|
| | | try {
|
| | | if (request.getSession().getAttribute("search-quan-" + map.get("FromUserName")) == null) {
|
| | | request.getSession().setAttribute("search-quan-" + map.get("FromUserName"), "1");
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.searchCouple(content, null, 1, 5);
|
| | | if (result == null || result.getTaoBaoGoodsBriefs() == null
|
| | | || result.getTaoBaoGoodsBriefs().size() <= 0) {
|
| | | Map<String, String> parmas = new HashMap<>();
|
| | | parmas.put("ToUserName", map.get("FromUserName"));
|
| | | parmas.put("FromUserName", ghId);
|
| | | parmas.put("CreateTime", java.lang.System.currentTimeMillis() / 1000 + "");
|
| | | parmas.put("MsgType", "text");
|
| | | parmas.put("Content", String.format("[微笑]抱歉,没有能为你找到关于【%s】的优惠券,[机智]你可以试试其他关键词", content));
|
| | | out.print(WXUtil.loadWXMessage(parmas));
|
| | | } else {
|
| | | String host = HttpUtil.getHost(Constant.wxGZConfig.getH5Url());
|
| | | String url = HttpUtil.getShortLink("http://" + host + "/search.html?key=" + content);
|
| | | String text = String.format("[得意]已经为你找到了关于【%s】的优惠券 \n 👉 %s", content, url);
|
| | | Map<String, String> parmas = new HashMap<>();
|
| | | parmas.put("ToUserName", map.get("FromUserName"));
|
| | | parmas.put("FromUserName", ghId);
|
| | | parmas.put("CreateTime", java.lang.System.currentTimeMillis() / 1000 + "");
|
| | | parmas.put("MsgType", "text");
|
| | | parmas.put("Content", text);
|
| | | out.print(WXUtil.loadWXMessage(parmas));
|
| | | }
|
| | | }
|
| | |
|
| | | } finally {
|
| | | request.getSession().removeAttribute("search-quan-" + map.get("FromUserName"));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "shareSubmit", method = RequestMethod.POST)
|
| | | public void getShareSubmit(long uid, String share, PrintWriter out) {
|
| | | String uidStr = StringUtil.getFromBase64(share);
|
| | | boolean b = NumberUtil.isNumeric(uidStr);
|
| | | if (!b) {
|
| | | out.print(JsonUtil.loadTrueResult("0")); // 不存在该邀请码
|
| | | return;
|
| | | }
|
| | | long inviterId = Long.parseLong(uidStr);
|
| | | int type = shareManageService.addShareManage(inviterId, uid);
|
| | | if (type == -1) {
|
| | | out.print(JsonUtil.loadTrueResult("-1")); // 邀请者与被邀请者不能相同
|
| | | return;
|
| | | } else if (type == 0) {
|
| | | out.print(JsonUtil.loadTrueResult("0")); // 不存在该邀请码
|
| | | return;
|
| | | } else if (type == 2) {
|
| | | out.print(JsonUtil.loadTrueResult("2")); // 被邀请者不是新用户
|
| | | return;
|
| | | } else if (type == 3) {
|
| | | out.print(JsonUtil.loadTrueResult("3")); // 被邀请者已存在
|
| | | return;
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult("1")); // 添加成功
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("details")
|
| | | public String getRecommendDetails(long drid, Model model) {
|
| | | RecommendDetails recommendDetails = recommendDetailsService.getRecommendDetails(drid, 0);
|
| | | if (recommendDetails == null) {
|
| | | return "";
|
| | | }
|
| | | model.addAttribute("recommendDetails", recommendDetails);
|
| | | try {
|
| | | List<RelateGoods> list = TaoKeApiUtil
|
| | | .getRelateGoodsList(Long.parseLong(recommendDetails.getDynamicRecommend().getAuctionId()));
|
| | | String upicUrls = recommendDetails.getDynamicRecommend().getuPicUrl();
|
| | | String[] imgs = upicUrls.split(",");
|
| | | List<String> tbImg = Arrays.asList(imgs);
|
| | | // List<String> tbImg =
|
| | | // TaoBaoUtil.getTbImg(recommendDetails.getDynamicRecommend().getAuctionId());
|
| | | model.addAttribute("tbImgs", tbImg);
|
| | | model.addAttribute("relateGoodsList", list);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return "tuijian";
|
| | | }
|
| | |
|
| | | @RequestMapping("getRecommendSectionDetail")
|
| | | public void getRecommendSectionDetail(long id, PrintWriter out) {
|
| | | RecommendSectionDetail recommendSectionDetail = recommendSectionDetailService
|
| | | .getRecommendSectionDetailByRsId(id);
|
| | | if (recommendSectionDetail == null) {
|
| | | out.println(JsonUtil.loadFalseResult("recommendSectionDetail不能为空"));
|
| | | return;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("picUrl", recommendSectionDetail.getPicUrl());
|
| | | data.put("html", recommendSectionDetail.getHtmlCode());
|
| | | out.println(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("getRecommendSectionGoodsList")
|
| | | public void getRecommendSectionGoodsList(long id, PrintWriter out) {
|
| | | List<RecommendSectionGoods> recommendSectionGoodsList = recommendSectionGoodsService
|
| | | .getRecommendSectionGoods(id, Integer.MAX_VALUE);
|
| | | if (recommendSectionGoodsList == null) {
|
| | | JsonUtil.loadFalseResult("商品为空!");
|
| | | return;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | for (RecommendSectionGoods recommendSectionGoods : recommendSectionGoodsList) {
|
| | | list.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(recommendSectionGoods.getTaoBaoGoodsBrief(),
|
| | | proportion.toString(), ""));
|
| | | }
|
| | |
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | data.put("goodsList", gson.toJson(list));
|
| | | out.println(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("shareGoods")
|
| | | public void shareGoods(String auctionId, PrintWriter out) {
|
| | | TaoBaoGoodsBrief alimama = null;
|
| | | try {
|
| | | alimama = redisManager.getTaoBaoGoodsBrief(Long.parseLong(auctionId));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (alimama != null) {
|
| | | List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | TaoBaoGoodsBrief tb = null;
|
| | | try {
|
| | | tb = redisManager.getTaoBaoGoodsBrief(Long.parseLong(auctionId));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(tb, config.get(0));
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("tb", GsonUtil.toJsonExpose(taoBaoGoodsBriefExtra));
|
| | | if ("1".equalsIgnoreCase(tb.getTkMktStatus())) {// 营销计划
|
| | | data.put("yxjh", 1);
|
| | | } else
|
| | | data.put("yxjh", 0);
|
| | |
|
| | | out.println(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | | JsonUtil.loadFalseResult("商品已下架!");
|
| | | }
|
| | |
|
| | | @RequestMapping("getShareGoodsInfo")
|
| | |
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | JSONObject rdata = new JSONObject();
|
| | | rdata.put("uid", uid);
|
| | | rdata.put("id", id);
|
| | | LogHelper.errorDetailInfo(e, rdata.toString(), request.getRequestURI());
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | JSONObject rdata = new JSONObject();
|
| | | rdata.put("uid", uid);
|
| | | rdata.put("id", id);
|
| | | LogHelper.errorDetailInfo(e, rdata.toString(), request.getRequestURI());
|
| | | out.print(JsonUtil.loadFalseResult(1001, "未知错误"));
|
| | | }
|
| | |
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("uid", uid);
|
| | | data.put("id", id);
|
| | |
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1, data.toString(), request.getRequestURI());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | LogHelper.errorDetailInfo(e1, data.toString(), request.getRequestURI());
|
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg()));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping("getShareGoodsDetail")
|
| | | public void getShareGoodsDetail(String uid, long id, String sign, PrintWriter out) {
|
| | | // 添加分享
|
| | | uid = AESUtil.decrypt(uid);
|
| | | if (StringUtil.isNullOrEmpty(uid)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | UserShareGoodsHistory userShareGoodsHistory = shareGoodsService
|
| | | .getShareGoodsHistoryDetail(Long.parseLong(uid), id);
|
| | | if (userShareGoodsHistory == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = redisManager.getTaoBaoGoodsBrief(userShareGoodsHistory.getGoodsId());
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | JSONObject data = JSONObject.fromObject(JsonUtil.getSimpleGson().toJson(userShareGoodsHistory));
|
| | | JSONObject goodsJSON = new JSONObject();
|
| | | goodsJSON.put("title", goods.getTitle());
|
| | | goodsJSON.put("zkPrice", goods.getZkPrice());
|
| | | // 有券
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
|
| | | BigDecimal finalPrice = goods.getZkPrice();
|
| | | if (goods.getCouponStartFee().compareTo(goods.getZkPrice()) <= 0
|
| | | && goods.getZkPrice().compareTo(goods.getCouponAmount()) >= 0) {
|
| | | finalPrice = goods.getZkPrice().subtract(goods.getCouponAmount());
|
| | | }
|
| | | goodsJSON.put("finalPrice", finalPrice);
|
| | | }
|
| | | data.put("goods", goodsJSON);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (ShareGoodsException e1) {
|
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg()));
|
| | |
|
| | | e1.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public void getHelpList(PrintWriter out) {
|
| | | List<CustomerName> totalList = new ArrayList<>();
|
| | | int page = 0;
|
| | | List<CustomerName> customerNameList = systemClientParamsService.customerNameList(page, "", 1);
|
| | | 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 = systemClientParamsService.customerNameList(page, "", 1);
|
| | | customerNameList = customerNameService.customerNameList(page, "", 1);
|
| | | if (customerNameList != null && customerNameList.size() > 0)
|
| | | totalList.addAll(customerNameList);
|
| | | }
|
| | |
|
| | | // 获取每个下面的详情
|
| | | for (CustomerName cn : totalList) {
|
| | | List<CustomerContent> contentList = systemClientParamsService.getSecondProblemList(0, "", cn.getId());
|
| | | 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 = systemClientParamsService.getCustomerContent(id);
|
| | | CustomerContent customerContent = customerContentService.getCustomerContent(id);
|
| | | out.print(JsonUtil.loadTrueResult(customerContent.getContent().replace("\n", "<br>")));
|
| | | }
|
| | |
|
| | | @RequestMapping("getInviteInfo")
|
| | | public void getInviteInfo(PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | String key = "activityRules";
|
| | | 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;
|
| | |
|
| | | String[] sts = valueBr.split("\n");
|
| | | JSONArray array = new JSONArray();
|
| | | for (String st : sts)
|
| | | array.add(st);
|
| | |
|
| | | data.put("activityRules", array);
|
| | |
|
| | | List<InviteGetMoney> inviteGetMoneyList = inviteGetMoneyService.inviteGetMoneyList(0, "");
|
| | |
|
| | | // 名字*处理
|
| | | for (InviteGetMoney inviteGetMoney : inviteGetMoneyList) {
|
| | |
|
| | | String name = inviteGetMoney.getName();
|
| | | if (name != null) {
|
| | | if (name.length() > 2) {
|
| | | name = Utils.getStarString(name, 1, name.length() - 1);
|
| | | } else {
|
| | | name = name.substring(0, 1) + "**" + name.substring(name.length() - 1);
|
| | | }
|
| | | }
|
| | | inviteGetMoney.setName(name);
|
| | | }
|
| | |
|
| | | data.put("inviteGetMoneyList", JsonUtil.getSimpleGsonWithDate().toJson(inviteGetMoneyList));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|