From cd829cb2e9c0631638351f473467fc5ecfa14285 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 28 一月 2019 11:23:17 +0800
Subject: [PATCH] 邀请有奖添加邀请激活链接
---
fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java | 595 +++++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 471 insertions(+), 124 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
index 29647e6..b5f3d47 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserInfoController.java
@@ -1,22 +1,21 @@
package com.yeshi.fanli.controller.client;
import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
+import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
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;
@@ -26,6 +25,7 @@
import org.yeshi.utils.IPUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.NumberUtil;
+import org.yeshi.utils.taobao.TbImgUtil;
import org.yeshi.utils.tencentcloud.COSManager;
import com.google.gson.Gson;
@@ -34,16 +34,16 @@
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+import com.yeshi.fanli.dto.HongBaoDTO;
+import com.yeshi.fanli.entity.AppVersionInfo;
import com.yeshi.fanli.entity.accept.AcceptData;
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.HongBaoExtra;
-import com.yeshi.fanli.entity.bus.user.HongBaoMessage;
import com.yeshi.fanli.entity.bus.user.LostOrder;
import com.yeshi.fanli.entity.bus.user.MoneyRecord;
import com.yeshi.fanli.entity.bus.user.OrderItem;
@@ -54,24 +54,37 @@
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.common.AdminUser;
+import com.yeshi.fanli.entity.common.Config;
+import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
+import com.yeshi.fanli.entity.goods.CommonGoods;
+import com.yeshi.fanli.entity.money.UserMoneyDetail;
+import com.yeshi.fanli.entity.order.HongBaoOrder;
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.TaoKeApiException;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.exception.user.UserCustomSettingsException;
+import com.yeshi.fanli.exception.user.UserInfoExtraException;
import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.AdminUserService;
+import com.yeshi.fanli.service.inter.config.AppVersionService;
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.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleExtraInfoSerivce;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.service.inter.order.OrderItemServcie;
import com.yeshi.fanli.service.inter.order.OrderService;
-import com.yeshi.fanli.service.inter.user.AccountDetailsService;
import com.yeshi.fanli.service.inter.user.AccountMessageService;
import com.yeshi.fanli.service.inter.user.BindingAccountService;
import com.yeshi.fanli.service.inter.user.ExtractRecordService;
@@ -79,10 +92,16 @@
import com.yeshi.fanli.service.inter.user.MoneyRecordService;
import com.yeshi.fanli.service.inter.user.PassWordErrorRecordService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
+import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.UserAccountService;
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
+import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
+import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
+import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.service.inter.user.WxDownService;
+import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.GsonUtil;
import com.yeshi.fanli.util.HongBaoUtil;
@@ -92,8 +111,18 @@
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.account.UserUtil;
+import com.yeshi.fanli.util.email.MailSenderUtil;
+import com.yeshi.fanli.util.factory.AccountDetailsFactory;
+import com.yeshi.fanli.util.factory.HongBaoFactory;
+import com.yeshi.fanli.util.factory.OrderItemFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.wx.WXLoginUtil;
+import com.yeshi.fanli.vo.user.UserInfoExtraVO;
+import com.yeshi.fanli.vo.user.UserSettingsVO;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
@Controller
@RequestMapping("api/v1/customer")
@@ -127,14 +156,11 @@
private SystemService systemService;
@Resource
- private HongBaoMessageService hongBaoMessageService;
-
- @Resource
private ShamUserService shamUserService;
@Resource
private ThreeSaleSerivce threeSaleSerivce;
-
+
@Resource
private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
@@ -145,13 +171,8 @@
private OrderItemServcie orderItemServcie;
@Resource
- private AccountDetailsService accountDetailsService;
-
- @Resource
private AccountMessageService accountMessageService;
- @Resource
- private CollectionGoodsService collectionGoodsService;
@Resource
private HongBaoManageService hongBaoManageService;
@@ -169,6 +190,36 @@
@Resource
private UserActiveLogService userActiveLogService;
+
+ @Resource
+ private CollectionGoodsV2Service collectionGoodsV2Service;
+
+ @Resource
+ private AdminUserService adminUserService;
+
+ @Resource
+ private UserMoneyDetailService userMoneyDetailService;
+
+ @Resource
+ private HongBaoOrderService hongBaoOrderService;
+
+ @Resource
+ private HongBaoV2Service hongBaoV2Service;
+
+ @Resource
+ private SpreadUserImgService spreadUserImgService;
+
+ @Resource
+ private UserShareGoodsRecordService userShareGoodsRecordService;
+
+ @Resource
+ private UserCustomSettingsService userCustomSettingsService;
+
+ @Resource
+ private UserInfoExtraService userInfoExtraService;
+
+ @Resource
+ private AppVersionService appVersionService;
private static final String PASSWORD_MAX_ERROR = "password_max_error";
private static final String EXTRACT_MIN_MONEY = "extract_min_money";
@@ -458,18 +509,83 @@
BigDecimal fanliHB = user.getTotalHongBao();
user.setTotalHongBao(fanliHB);
+ UserInfo filterForClientUser = UserUtil.filterForClientUser(user);
+
+ // 1.5.0 鐗堟湰涔嬪悗杩斿洖鏂扮殑绛夌骇
+ String version = acceptData.getVersion();
+ if (version != null && version.trim().length() > 0) {
+ int versionCode = Integer.parseInt(version);
+ String platform = acceptData.getPlatform();
+
+ AppVersionInfo versionInfo = appVersionService.getByPlatformAndVersion(platform, "1.5.0");
+ if (versionInfo != null) {
+ int versionCode150 = versionInfo.getVersionCode();
+ if (versionCode >= versionCode150) {
+ UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
+ if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
+ String picture = userInfoExtra.getUserRank().getPicture();
+ String icon = userInfoExtra.getUserRank().getIcon();
+ filterForClientUser.setRankNamePicture(picture);
+ filterForClientUser.setRankIcon(icon);
+ }
+ }
+ }
+ }
+
GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
JSONObject data = new JSONObject();
- data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create()
- .toJson(UserUtil.filterForClientUser(user)));
+ data.put("user",
+ JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(filterForClientUser));
data.put("first", 0);
+ int spreadImgCount = spreadUserImgService.countUserSpreadImg(user.getId());
+ long shareCount = userShareGoodsRecordService.countShareRecordByUid(user.getId());
+
+ int showTiCheng = 1; // 涓嶆樉绀�
+ if ("ios".equalsIgnoreCase(acceptData.getPlatform())
+ && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
+ data.put("showTiCheng", false);
+ else {
+ data.put("showTiCheng", spreadImgCount + shareCount > 0);
+ if (spreadImgCount + shareCount > 0) {
+ showTiCheng = 0;
+ }
+ }
+
if ("ios".equalsIgnoreCase(acceptData.getPlatform())
&& configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html",
Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
else
data.put("inviteList", configService.get("team_list"));
+
+ // 鐣岄潰鐘舵��
+ UserSettingsVO mySettings = null;
+ try {
+ mySettings = userCustomSettingsService.getMySettings(user.getId());
+ } catch (UserCustomSettingsException e) {
+ mySettings = new UserSettingsVO();
+ e.printStackTrace();
+ }
+
+ if (mySettings.getCancelNotice() == null) {
+ mySettings.setCancelNotice(0);
+ }
+ if (mySettings.getNoBonusCount() == null) {
+ mySettings.setNoBonusCount(showTiCheng); // 鏍规嵁showTiCheng鏉ュ垽鏂�
+ }
+ if (mySettings.getNoNewsRedDot() == null) {
+ mySettings.setNoNewsRedDot(0);
+ }
+ if (mySettings.getNoShareRecordAndStorage() == null) {
+ mySettings.setNoShareRecordAndStorage(showTiCheng); // 鏍规嵁showTiCheng鏉ュ垽鏂�
+ }
+ if (mySettings.getNoInvitationBonus() == null) {
+ mySettings.setNoInvitationBonus(0);
+ }
+
+ data.put("moduleState", mySettings);
+
out.print(JsonUtil.loadTrueResult(data));
final UserInfo uuser = user;
ThreadUtil.run(new Runnable() {
@@ -479,6 +595,13 @@
uuser.setLastLoginTime(java.lang.System.currentTimeMillis());
userInfoService.updateLoginInfo(uuser);
wxDownService.save(device);
+ // 鏇存柊鐢ㄦ埛闄勫姞淇℃伅锛岃�佺敤鎴蜂笉瀛樺湪鐨勯渶瑕佹坊鍔�
+ try {
+ userInfoExtraService.updateUserRankByUid(uuser.getId());
+ } catch (UserInfoExtraException e) {
+ e.printStackTrace();
+ }
+
}
});
}
@@ -692,16 +815,9 @@
JSONObject data = new JSONObject();
data.put("user", user);
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
- String maxError = "5";
- maxError = configService.get(PASSWORD_MAX_ERROR); // 褰撴棩杈撻敊瀵嗙爜鏈�澶氭鏁�
- PassWordErrorRecord record = passWordErrorRecordService.getRecord(uid);
- int max = Integer.parseInt(maxError);
- if (record.getCount() >= max) {
- data.put("error", "1"); // 杈惧埌鏈�澶氶檺鍒�
- } else {
- data.put("error", "0");
- }
- data.put("maxError", maxError);
+
+ data.put("error", "0");
+ data.put("maxError", 1);
String minMoney = configService.get(EXTRACT_MIN_MONEY); // 鍗曠瑪鎻愮幇鐨勬渶灏忛噾棰�
String maxMoney = configService.get(EXTRACT_MAX_MONEY); // 鍗曠瑪鎻愮幇鐨勬渶澶ч噾棰�
int maxDayCount = Integer.parseInt(configService.get("extract_count_day"));
@@ -770,7 +886,7 @@
ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid);
boolean canExtract = true;
String errorMsg = "";
- if (extractRecord != null && extractRecord.getCount() + 1 >= maxDayCount) {
+ if (extractRecord != null && extractRecord.getCount() + 1 > maxDayCount) {
canExtract = false;
errorMsg = String.format("姣忔棩鏈�澶氭彁鐜�%s娆�", maxDayCount + "");
} else if (extractRecord != null
@@ -1233,6 +1349,30 @@
JSONObject data = new JSONObject();
data.put("id", extract.getId());
out.print(JsonUtil.loadTrueResult(data));
+ ThreadUtil.run(new Runnable() {
+
+ @Override
+ public void run() {
+ JSONObject json = new JSONObject();
+ json.put("timeStamp", java.lang.System.currentTimeMillis());
+ json.put("adminId", 4L);
+ String sign = AESUtil.encrypt(json.toString(), Constant.ADMINH5_AESKEY);
+ String url = "";
+ try {
+ url = String.format("%s?from=emailh5&sign=%s",
+ Constant.systemCommonConfig.getExtractNotifyUrl(), URLEncoder.encode(sign, "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ AdminUser adminUser = adminUserService.selectByPrimaryKey(4L);
+ Config config = configService.getConfig("extract_code_email_from");
+ String[] sts = config.getValue().split(",");
+ String account = sts[0];
+ String pwd = sts[1];
+ String msg = "鎻愮幇瀹℃牳閾炬帴:" + url;
+ boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "鏈夋柊鐨勬彁鐜板鏍�", msg);
+ }
+ });
return;
} else if (etype == 1) {
out.print(JsonUtil.loadFalseResult("宸茶秴杩囧綋鏃ユ彁鐜版鏁�"));
@@ -1300,14 +1440,6 @@
LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(request) + "] 鎵撳紑绾㈠寘[id=" + hid + "]鎴愬姛锛�");
}
- @RequestMapping(value = "getHongBaoMessages", method = RequestMethod.POST)
- public void getHongBaoMessages(AcceptData acceptData, PrintWriter out) {
- List<HongBaoMessage> list = shamUserService.getManyData();
- JSONObject data = new JSONObject();
- data.put("list", list);
- out.print(JsonUtil.loadTrueResult(data));
- }
-
@RequestMapping("findLostOrder")
public void findLostOrder(AcceptData acceptData, LostOrder lostOrder, PrintWriter out) {
boolean orderNum = true;
@@ -1344,15 +1476,20 @@
@RequestMapping("findOrderItemList")
public void findOrderItemList(AcceptData acceptData, long uid, int page, PrintWriter out) {
- List<OrderItem> list = orderItemServcie.findOrderItemList(uid, page);
- list.parallelStream().forEach(oi -> {
- oi.setDesc();
- });
- int count = orderItemServcie.getCount(uid);
+ List<HongBaoOrder> list = hongBaoOrderService.listFanLiOrder(uid, page, Constant.PAGE_SIZE);
+
+ List<OrderItem> orderList = new ArrayList<>();
+ for (HongBaoOrder oi : list) {
+ OrderItem orderItem = OrderItemFactory.create(oi);
+ orderItem.setDesc();
+ orderItem.setPicture(TbImgUtil.getTBSize220Img(orderItem.getPicture()));
+ orderList.add(orderItem);
+ }
+ long count = hongBaoOrderService.countFanLiOrder(uid);
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().create();
JSONObject data = new JSONObject();
- data.put("list", gson.toJson(list));
+ data.put("list", gson.toJson(orderList));
data.put("count", count);
out.print(JsonUtil.loadTrueResult(data));
}
@@ -1367,8 +1504,13 @@
*/
@RequestMapping("getTiChengOrderList")
public void getTiChengOrderList(AcceptData acceptData, long uid, int page, PrintWriter out) {
- List<HongBao> list = hongBaoService.getTiChengHongBaoList(uid, page);
- long count = hongBaoService.getTiChengHongBaoListCount(uid);
+ List<HongBaoDTO> hongBaoDTOList = hongBaoV2Service.listJiangJinByUid(uid, page, Constant.PAGE_SIZE);
+ List<HongBao> list = new ArrayList<>();
+ if (hongBaoDTOList != null)
+ for (HongBaoDTO dto : hongBaoDTOList) {
+ list.add(HongBaoFactory.createHongBao(dto));
+ }
+ long count = hongBaoV2Service.countJiangJinByUid(uid);
List<OrderItem> orderItemList = HongBaoUtil.convertToTiChengOrder(list);
Gson gson = JsonUtil.getApiCommonGson();
JSONObject data = new JSONObject();
@@ -1419,24 +1561,32 @@
@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()));
+ }
}
}
@@ -1459,39 +1609,97 @@
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);
- 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);
- goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day()));
- TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion,
- fcRate, "");
- taoBaoGoodsBriefExtra.setCreatetime(new Date(cg.getCreateTime()));
- list.add(taoBaoGoodsBriefExtra);
- });
+ List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page + 1,
+ Constant.PAGE_SIZE);
+
+ List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
+
+ long count = collectionGoodsV2Service.getCollectionGoodsCount(uid);
+ JSONObject data = new JSONObject();
+
+ List<TaoBaoGoodsBrief> listTaoKeGoods = new ArrayList<TaoBaoGoodsBrief>();
+ if (collectionGoodsList != null && collectionGoodsList.size() > 0) {
+
+ BigDecimal proportion = hongBaoManageService.getFanLiRate();
+
+ List<Long> listGid = new ArrayList<Long>();
+ for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
+ CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
+ if (commonGoods == null) {
+ continue;
+ }
+ listGid.add(commonGoods.getGoodsId());
+ }
+
+ try {
+ // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
+ listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+ } catch (TaoKeApiException e) {
+ e.printStackTrace();
+ } catch (TaobaoGoodsDownException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
+ CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
+ if (commonGoods == null) {
+ continue;
+ }
+
+ if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
+ int state = 1; // 榛樿鍋滃敭
+ Long goodsId = commonGoods.getGoodsId();
+ for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
+ Long auctionId = taoKeGoods.getAuctionId();
+ if (goodsId == auctionId || goodsId.equals(auctionId)) {
+ state = 0; // 鍦ㄥ敭
+ break;
+ }
+ }
+ commonGoods.setState(state);
+ }
+
+ TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
+ goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day()));
+ TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief,
+ proportion.toString(), "");
+ taoBaoGoodsBriefExtra.setCreatetime(collectionGoodsV2.getCreateTime());
+
+ list.add(taoBaoGoodsBriefExtra);
+ }
+
+ }
+
GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
@@ -1517,7 +1725,11 @@
} 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();
+ }
});
}
}
@@ -1526,7 +1738,12 @@
@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("鍒犻櫎鎴愬姛"));
}
@@ -1544,8 +1761,11 @@
@RequestMapping("findAccountDetailsList")
public void findAccountDetailsList(AcceptData acceptData, long uid, int page, PrintWriter out) {
- List<AccountDetails> list = accountDetailsService.findAccountDetailsList(uid, page);
- int count = accountDetailsService.getCount(uid);
+ List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE);
+ List<AccountDetails> list = new ArrayList<>();
+ for (UserMoneyDetail detail : detailList)
+ list.add(AccountDetailsFactory.create(detail));
+ long count = userMoneyDetailService.countByUidWithState(uid);
JSONObject data = new JSONObject();
data.put("list", GsonUtil.toJsonExpose(list));
data.put("count", count);
@@ -1553,9 +1773,21 @@
}
@RequestMapping("findAccountDetailsListV2")
- public void findAccountDetailsListNew(AcceptData acceptData, long uid, int page, PrintWriter out) {
- List<AccountDetails> list = accountDetailsService.findAccountDetailsListWithState(uid, page);
- long count = accountDetailsService.getCountWithState(uid);
+ public void findAccountDetailsListNew(AcceptData acceptData, Long uid, int page, PrintWriter out) {
+
+ if (uid == null) {
+ out.print(JsonUtil.loadFalseResult(1, "UID涓虹┖"));
+ return;
+ }
+
+ List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE);
+
+ List<AccountDetails> list = new ArrayList<>();
+ for (UserMoneyDetail detail : detailList)
+ list.add(AccountDetailsFactory.create(detail));
+
+ long count = userMoneyDetailService.countByUidWithState(uid);
+
JSONObject data = new JSONObject();
JSONArray array = new JSONArray();
for (AccountDetails ad : list) {
@@ -1590,50 +1822,50 @@
.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 = new JSONObject();
+
+ JSONObject bossData = null;
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));
}
-
+
String helpLink = configService.get("team_help_url");
if (helpLink == null) {
helpLink = "";
@@ -1645,44 +1877,41 @@
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 = new JSONObject();
ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
if (threeSale != null) {
-
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 = "";
@@ -1693,69 +1922,73 @@
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 閭�璇穒d
+ * @param inviteId
+ * 閭�璇穒d
* @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 閭�璇穒d
+ * @param inviteId
+ * 閭�璇穒d
* @param out
*/
@RequestMapping(value = "removethreesale", method = RequestMethod.POST)
@@ -1766,24 +1999,138 @@
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();
}
-
}
-
+
+ /**
+ * 璁剧疆鐣岄潰寮�鍏崇姸鎬�
+ *
+ * @param acceptData
+ * @param uid
+ * @param params
+ * @param out
+ */
+ @RequestMapping(value = "setModuleState", method = RequestMethod.POST)
+ public void setModuleState(AcceptData acceptData, Long uid, String params, PrintWriter out) {
+
+ if (uid == null) {
+ out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+ return;
+ }
+
+ try {
+ if (params == null || params.trim().length() == 0) {
+ out.print(JsonUtil.loadFalseResult("浼犻�掑弬鏁颁负绌�"));
+ return;
+ }
+
+ JSONObject json = JSONObject.fromObject(params);
+ Iterator<String> iterator = json.keys();
+ while (iterator.hasNext()) {
+ String type = (String) iterator.next();
+ int state = json.getInt(type);
+ userCustomSettingsService.saveModuleState(uid, type, state);
+ }
+ out.print(JsonUtil.loadTrueResult("璁剧疆鎴愬姛"));
+
+ } catch (UserCustomSettingsException e) {
+ out.print(JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("璁剧疆澶辫触"));
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 鑾峰彇绛夌骇淇℃伅
+ *
+ * @param acceptData
+ * @param uid
+ * @param out
+ */
+ @RequestMapping(value = "getRankInfo", method = RequestMethod.POST)
+ public void getRankInfo(AcceptData acceptData, Long uid, PrintWriter out) {
+
+ if (uid == null) {
+ out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+ return;
+ }
+
+ try {
+ UserInfoExtraVO rankInfo = userInfoExtraService.getRankInfo(uid);
+ GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
+ gsonBuilder.excludeFieldsWithoutExposeAnnotation();
+ Gson gson = gsonBuilder.setDateFormat("yyyy.MM.dd").create();
+
+ JSONObject resultData = new JSONObject();
+ resultData.put("rankInfo", gson.toJson(rankInfo));
+
+ out.print(JsonUtil.loadTrueResult(resultData));
+
+ } catch (UserInfoExtraException e) {
+ out.print(JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 鑾峰彇绛夌骇淇℃伅
+ *
+ * @param acceptData
+ * @param uid
+ * @param out
+ */
+ @RequestMapping(value = "getUserConfig", method = RequestMethod.POST)
+ public void getUserConfig(AcceptData acceptData, Long uid, PrintWriter out) {
+
+ if (uid == null) {
+ out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+ return;
+ }
+
+ try {
+
+ String inviteCode = userInfoExtraService.getUserInviteCode(uid);
+
+ JSONObject inviteData = new JSONObject();
+ if (inviteCode == null || inviteCode.trim().length() == 0) {
+ // 鏃犻個璇风爜
+ inviteData.put("content", "閭�璇锋縺娲�");
+ inviteData.put("link", configService.get("invite_activation_url"));
+ } else {
+ // 宸叉湁閭�璇风爜
+ inviteData.put("content", "閭�璇风爜");
+ inviteData.put("link", configService.get("invite_activation_success_url"));
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("invite", inviteData);
+
+ out.print(JsonUtil.loadTrueResult(data));
+
+ } catch (UserInfoExtraException e) {
+ out.print(JsonUtil.loadFalseResult(e.getMsg()));
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+ e.printStackTrace();
+ }
+ }
}
--
Gitblit v1.8.0