| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | import com.google.gson.GsonBuilder;
|
| | | 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.ConfigKeyEnum;
|
| | | 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.SearchFilter;
|
| | | 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.share.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | 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.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.GoodsSecondClassService;
|
| | | 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.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.ShamUserService;
|
| | | 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;
|
| | |
| | |
|
| | | @Resource
|
| | | private GoodsSecondClassService goodsSecondClassService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoCouponService taoBaoCouponService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteRecordService userInviteRecordService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Resource
|
| | | private CustomerNameService customerNameService;
|
| | |
|
| | | @Resource
|
| | | private CustomerContentService customerContentService;
|
| | |
|
| | | private static final String DOWNURL = "http://sj.qq.com/myapp/detail.htm?apkName="
|
| | | + Constant.systemCommonConfig.getAndroidPackageName();
|
| | |
| | | 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);
|
| | |
| | |
|
| | | @RequestMapping("share")
|
| | | public String getShare(Model model, String uid) {
|
| | | String value = configService.get("share_message");
|
| | | String value = configService.get(ConfigKeyEnum.shareMessage.getKey());
|
| | | try {
|
| | | if (uid == null) {
|
| | | uid = "0";
|
| | |
| | |
|
| | | @RequestMapping("shares")
|
| | | public String getShares(Model model, String uid) {
|
| | | String value = configService.get("share_message");
|
| | | String value = configService.get(ConfigKeyEnum.shareMessage.getKey());
|
| | | try {
|
| | | if (uid == null) {
|
| | | uid = "0";
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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("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";
|
| | |
| | | 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);
|
| | | SearchFilter sf = new SearchFilter();
|
| | | sf.setPage(1);
|
| | | sf.setPageSize(5);
|
| | | sf.setKey(content);
|
| | | sf.setQuan(1);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
|
| | | if (result == null || result.getTaoBaoGoodsBriefs() == null
|
| | | || result.getTaoBaoGoodsBriefs().size() <= 0) {
|
| | | Map<String, String> parmas = new HashMap<>();
|
| | |
| | | }
|
| | | 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>")));
|
| | | }
|
| | |
|