| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.AccountDetails;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.CollectionGoods;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.entity.bus.user.ExtractRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.exception.BindingAccountException;
|
| | | import com.yeshi.fanli.exception.ObjectStateException;
|
| | | import com.yeshi.fanli.exception.goods.CollectionGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoMessageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | |
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v1/customer")
|
| | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
|
| | |
|
| | |
| | | @Resource
|
| | | private AccountMessageService accountMessageService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsService collectionGoodsService;
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | private static final String PASSWORD_MAX_ERROR = "password_max_error";
|
| | | private static final String EXTRACT_MIN_MONEY = "extract_min_money";
|
| | |
| | |
|
| | | @RequestMapping("collectionGoods")
|
| | | public void collectionGoods(AcceptData acceptData, long uid, long auctionId, int type, PrintWriter out) {
|
| | | CollectionGoods find = collectionGoodsService.findByUidAndAuctionId(uid, auctionId);
|
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId);
|
| | | if (type == 1) {
|
| | | if (find != null) {
|
| | | out.print(JsonUtil.loadFalseResult(""));
|
| | | return;
|
| | | }
|
| | | CollectionGoods cg = TaoBaoUtil.getCollectionGoods(auctionId, new UserInfo(uid));
|
| | | collectionGoodsService.save(cg);
|
| | | out.print(JsonUtil.loadTrueResult("收藏成功"));
|
| | | return;
|
| | | try {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief);
|
| | | out.print(JsonUtil.loadTrueResult("收藏成功"));
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架"));
|
| | | } catch (CollectionGoodsException e1) {
|
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg()));
|
| | | }
|
| | | } else {
|
| | | if (find == null) {
|
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | return;
|
| | | } else {
|
| | | collectionGoodsService.delete(find);
|
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | return;
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId);
|
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | } catch (CollectionGoodsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | CollectionGoods find = collectionGoodsService.findByUidAndAuctionId(uid, auctionId);
|
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId);
|
| | |
|
| | | if (find == null) {
|
| | | // 添加收藏
|
| | | CollectionGoods cg = TaoBaoUtil.getCollectionGoods(auctionId, new UserInfo(uid));
|
| | | collectionGoodsService.save(cg);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1));
|
| | | try {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1));
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | JsonUtil.printMode(out, callback, (JsonUtil.loadFalseResult(1, "商品已下架")));
|
| | | } catch (CollectionGoodsException e1) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg()));
|
| | | }
|
| | | } else {
|
| | | // 取消收藏
|
| | | collectionGoodsService.delete(find);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(0));
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | } catch (CollectionGoodsException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping("collectionGoodsList")
|
| | | public void collectionGoodsList(AcceptData acceptData, long uid, int page, PrintWriter out) {
|
| | | List<CollectionGoods> coList = collectionGoodsService.findCollectionGoods(uid, page + 1);
|
| | | int count = collectionGoodsService.getCount(uid);
|
| | |
|
| | | List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page + 1,
|
| | | Constant.PAGE_SIZE);
|
| | |
|
| | | // List<CollectionGoods> coList =
|
| | | // collectionGoodsService.findCollectionGoods(uid, page + 1);
|
| | | long count = collectionGoodsV2Service.getCollectionGoodsCount(uid);
|
| | | JSONObject data = new JSONObject();
|
| | | Map<String, String> map = hongBaoManageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | | List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | | coList.parallelStream().forEachOrdered(cg -> {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.getTaoBaoGoodsBrief(cg);
|
| | | collectionGoodsList.parallelStream().forEachOrdered(cg -> {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(cg.getCommonGoods());
|
| | | goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day()));
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion,
|
| | | fcRate, "");
|
| | | taoBaoGoodsBriefExtra.setCreatetime(new Date(cg.getCreateTime()));
|
| | |
|
| | | taoBaoGoodsBriefExtra.setCreatetime(cg.getCreateTime());
|
| | | list.add(taoBaoGoodsBriefExtra);
|
| | | });
|
| | | GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | |
| | | } else {
|
| | | if (!StringUtil.isNullOrEmpty(ids)) {
|
| | | Arrays.asList(ids.split(",")).parallelStream().forEach(auctionIdStr -> {
|
| | | collectionGoodsService.delete(Long.parseLong(auctionIdStr), uid);
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, Long.parseLong(auctionIdStr));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | @RequestMapping("clearConllectionGoods")
|
| | | public void clearConllectionGoods(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | collectionGoodsService.clear(uid);
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByUid(uid);
|
| | | } catch (CollectionGoodsException e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | |
|
| | |
| | | .loadTrueResult(String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl())));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户队员列表查询 1.4.1
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getMyTeam", method = RequestMethod.POST)
|
| | | public void getMyTeam(AcceptData acceptData, long page, long uid, long type, PrintWriter out) {
|
| | | |
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | | |
| | |
|
| | | JSONObject resultData = new JSONObject();
|
| | | if (type == 1) {
|
| | | resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid);
|
| | | } else if (type == 2) {
|
| | | resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid);
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | // 安卓系统返回所有数据
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equalsIgnoreCase(platform)) {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
|
| | | |
| | |
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | | |
| | |
|
| | | JSONObject bossData = null;
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | |
| | | bossData.put("nickName", boss.getNickName());
|
| | | bossData.put("portrait", boss.getPortrait());
|
| | | }
|
| | | |
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime));
|
| | | }
|
| | | |
| | |
|
| | | String helpLink = configService.get("team_help_url");
|
| | | if (helpLink == null) {
|
| | | helpLink = "";
|
| | |
| | | resultData.put("secondTeamTotal", secondTeamTotal);
|
| | | resultData.put("boss", bossData);
|
| | | }
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 用户队员统计 1.4.1
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
|
| | | public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | |
| | |
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
|
| | | |
| | |
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | | |
| | | JSONObject bossData = null;
|
| | | JSONObject bossData = new JSONObject();
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | bossData = new JSONObject();
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | if (boss != null) {
|
| | | bossData.put("nickName", boss.getNickName());
|
| | | bossData.put("portrait", boss.getPortrait());
|
| | | }
|
| | | |
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | JSONObject resultData = new JSONObject();
|
| | | |
| | |
|
| | | String helpLink = configService.get("team_help_url");
|
| | | if (helpLink == null) {
|
| | | helpLink = "";
|
| | |
| | | resultData.put("secondTeam", secondTeam);
|
| | | resultData.put("secondTeamTotal", secondTeamTotal);
|
| | | resultData.put("boss", bossData);
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 用户队员信息保存 1.4.1
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId 邀请id
|
| | | * @param inviteId
|
| | | * 邀请id
|
| | | * @param nickname
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "setextrainfo", method = RequestMethod.POST)
|
| | | public void setExtraInfo(AcceptData acceptData, long uid, long inviteId, String memoName, PrintWriter out) {
|
| | | |
| | |
|
| | | try {
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, null);
|
| | | if (listThreeSale == null || listThreeSale.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("该记录不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserInfo worker = listThreeSale.get(0).getWorker();
|
| | | if (worker == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该记录不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | List<ThreeSaleExtraInfo> list = threeSaleExtraInfoSerivce.listbyBossIdAndWorkerId(uid, worker.getId());
|
| | | if (list == null || list.size() == 0) {
|
| | | |
| | |
|
| | | ThreeSaleExtraInfo extraInfo = new ThreeSaleExtraInfo();
|
| | | extraInfo.setWorker(worker);
|
| | | extraInfo.setNickname(memoName);
|
| | | extraInfo.setCreateTime(new Date());
|
| | | extraInfo.setUpdateTime(new Date());
|
| | | |
| | |
|
| | | UserInfo boss = new UserInfo(uid);
|
| | | extraInfo.setBoss(boss);
|
| | | |
| | |
|
| | | threeSaleExtraInfoSerivce.insert(extraInfo);
|
| | | |
| | |
|
| | | } else {
|
| | | ThreeSaleExtraInfo extraInfo = list.get(0);
|
| | | extraInfo.setNickname(memoName);
|
| | | extraInfo.setUpdateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.updateByPrimaryKey(extraInfo);
|
| | | }
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("保存失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 删除队员关系
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId 邀请id
|
| | | * @param inviteId
|
| | | * 邀请id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "removethreesale", method = RequestMethod.POST)
|
| | |
| | | out.print(JsonUtil.loadFalseResult("操作数据无效"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserInfo worker = listThreeSale.get(0).getWorker();
|
| | | if (worker == null) {
|
| | | out.print(JsonUtil.loadFalseResult("操作数据无效"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 删除关系
|
| | | threeSaleSerivce.deleteByPrimaryKey(inviteId);
|
| | | // 删除备注
|
| | | threeSaleExtraInfoSerivce.deleteByBossIdAndWorkerId(uid, worker.getId());
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | |
| | |
|
| | | }
|