| | |
| | | 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 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.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.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.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.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | |
| | | 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) {
|
| | |
| | | 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");
|
| | |
| | | if ("2".equalsIgnoreCase(ios)) {
|
| | | down = DOWNURL;
|
| | | }
|
| | | if (!state.equals(wxState)) {// 不是微信返回的!
|
| | | if (state == null || !state.equals(wxState)) {// 不是微信返回的!
|
| | | // request.setAttribute("error", "1");
|
| | | return "redirect:" + down;
|
| | | }
|
| | | |
| | | if (code == null) {// 用户取消了登陆!
|
| | | return "redirect:" + down;
|
| | | }
|
| | |
| | | // 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(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;
|
| | |
| | | }
|
| | | 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();
|
| | | }
|
| | | 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));
|
| | | }
|
| | |
|
| | | /**
|