From 90c668cdf182bf64713b01471dadfc88b1828388 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 02 九月 2019 15:23:25 +0800
Subject: [PATCH] 领取状态判断
---
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java | 122 +++++++++++++++++++++++++++++++++-------
1 files changed, 100 insertions(+), 22 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
index a8c6ff9..4624520 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -16,7 +16,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import org.yeshi.utils.NumberUtil;
+import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
@@ -64,6 +66,7 @@
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
@@ -227,8 +230,9 @@
@Override
public void fanli() {
+ LogHelper.test("澶勭悊杩斿埄鍒拌处");
// 鑾峰彇涓荤孩鍖�
- List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBao.TYPE_TAOBAO, 1000);
+ List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBaoV2.TYPE_ZIGOU, 1000);
//
// /**
// * 闇�瑕佸疄鏃舵洿鏂板緟杩斿埄鐨勮鍗�
@@ -292,6 +296,11 @@
public void fanli(HongBaoV2 hb1) throws TaoBaoWeiQuanException {
// 鏌ヨ鏈�鏂扮殑绾㈠寘鏁版嵁
hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
+ // 姝e父鐢ㄦ埛鎵嶈兘鍒拌处
+ UserInfo mainUser = userInfoMapper.selectByPrimaryKey(hb1.getUserInfo().getId());
+ if (mainUser == null || mainUser.getState() != UserInfo.STATE_NORMAL) {
+ return;
+ }
// 鏌ヨ绾㈠寘鐩稿叧鑱旂殑璁㈠崟
HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hb1.getId());
if (hongBaoOrder == null) {
@@ -299,12 +308,20 @@
return;
}
- // 鐏板害娴嬭瘯涓紝浜笢/鎷煎澶氫笉杩斿埄
- if (hongBaoOrder.getCommonOrder() == null
- || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD
- || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD) {
+ if (hongBaoOrder.getCommonOrder() == null) {// ||
+ // hongBaoOrder.getCommonOrder().getSourceType()
+ // ==
+ // Constant.SOURCE_TYPE_JD
+ // || hongBaoOrder.getCommonOrder().getSourceType() ==
+ // Constant.SOURCE_TYPE_PDD
return;
}
+
+ // 濡傛灉鏄嫾澶氬/浜笢缁存潈鍒欒繑鍥烇紝涓嶉渶瑕佽繑鍒�
+ if ((hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD
+ || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD)
+ && hongBaoOrder.getCommonOrder().getState() == CommonOrder.STATE_WQ)
+ return;
if (hongBaoOrder.getCommonOrder() != null
&& hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO) {
@@ -396,6 +413,11 @@
// 娣诲姞璧勯噾鏄庣粏涓庣孩鍖呯殑鏄犲皠鍏崇郴
for (HongBaoV2 v2 : userHongBao.get(uid)) {
accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId());
+ try {
+ HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId());
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e);
+ }
}
// 绔欏唴淇�+鎺ㄩ��
@@ -426,10 +448,12 @@
if (olist != null && olist.size() > 0) {
long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
olist = TaoKeOrderApiUtil.getTaoBaoAllOrder(TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"),
- TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+ TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
+ TaoKeOrderApiUtil.TK_STATUS_ALL);
List<TaoBaoOrder> thirdOList = TaoKeOrderApiUtil.getTaoBaoThirdAllOrder(
TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"), 30, 1,
- TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+ TaoKeOrderApiUtil.TK_STATUS_ALL, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
+ TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
if (thirdOList != null && thirdOList.size() > 0)
olist.addAll(thirdOList);
@@ -456,8 +480,12 @@
public void weiQuanOrder(List<TaoBaoWeiQuanOrder> orderList) {
if (orderList != null)
for (TaoBaoWeiQuanOrder order : orderList) {
- if (order.getState().contains("缁存潈鎴愬姛")) {
- CMQManager.getInstance().addWeiQuanOrderMsg(order);
+ try {
+ if (order.getState().contains("缁存潈鎴愬姛")) {
+ CMQManager.getInstance().addWeiQuanOrderMsg(order);
+ }
+ } catch (Exception e) {
+ LogHelper.error("缁存潈璁㈠崟鍔犲叆鍒伴槦鍒楀嚭閿�:" + order != null ? new Gson().toJson(order) : null);
}
}
}
@@ -553,6 +581,7 @@
@Override
@Transactional
public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
+ List<Long> recieveHongBaoIds = new ArrayList<>();
/**
* 澶勭悊閭�璇疯禋璁㈠崟
*/
@@ -560,7 +589,16 @@
List<Integer> types = new ArrayList<>();
types.add(HongBaoV2.TYPE_YIJI);
types.add(HongBaoV2.TYPE_ERJI);
- List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 1000);
+ long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid);
+ List<HongBaoV2> hongBaoList = new ArrayList<>();
+ // 1000鏉℃暟鎹负1椤�
+ int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1);
+ for (int i = 0; i < page; i++) {
+ List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, i * 1000,
+ 1000);
+ if (tempHongBaoList != null && tempHongBaoList.size() > 0)
+ hongBaoList.addAll(tempHongBaoList);
+ }
// 鐏板害娴嬭瘯涓紝浜笢/鎷煎澶氳鍗曞垎浜�/閭�璇疯鍗曚笉杩斿埄
for (int i = 0; i < hongBaoList.size(); i++) {
HongBaoV2 item = hongBaoList.get(i);
@@ -572,11 +610,13 @@
HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getId());
if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
CommonOrder co = hongBaoOrder.getCommonOrder();
- if (co.getSourceType() == Constant.SOURCE_TYPE_JD
- || co.getSourceType() == Constant.SOURCE_TYPE_PDD) {
+ // 涓婄骇鐢ㄦ埛涓嶆槸姝e父鐢ㄦ埛锛岃鍗曞潎涓嶈兘鍒拌处
+ UserInfo userInfo = userInfoMapper.selectByPrimaryKey(co.getUserInfo().getId());
+ if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
hongBaoList.remove(i);
i--;
}
+
}
}
}
@@ -631,7 +671,8 @@
types.clear();
types.add(HongBaoV2.TYPE_SHARE_YIJI);
types.add(HongBaoV2.TYPE_SHARE_ERJI);
- List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000);
+ // TODO 闇�瑕佸鐞嗚秴杩�1w鏉℃暟鎹殑璁㈠崟
+ List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000);
if (hbList != null && hbList.size() > 0)
totalHongBaoList.addAll(hbList);
@@ -676,11 +717,9 @@
minDate, maxDate);
long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
minDate, maxDate);
- long invalidCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX,
- minDate, maxDate);
UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
- (int) validCount, (int) weiQuanCount, (int) invalidCount, invitemoney, new Date());
+ (int) validCount, (int) weiQuanCount, invitemoney, new Date());
// 澧炲姞璧勯噾
userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
@@ -701,7 +740,8 @@
for (String orderId : drawBackOrders)
taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
}
-
+ if (hbIdList.size() > 0)
+ recieveHongBaoIds.addAll(hbIdList);
hbIdList.clear();
drawBackOrders.clear();
@@ -715,7 +755,8 @@
// 鏌ヨUID鐨勫垎浜禋璁㈠崟
types.clear();
types.add(HongBaoV2.TYPE_SHARE_GOODS);
- List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000);
+ // TODO 闇�瑕佸鐞嗚秴杩�10000鏉℃暟鎹殑璁㈠崟
+ List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000);
for (HongBaoV2 hongBao : hongBaoShareList) {
hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
hongBao = filterWeiQuanINGHongBao(hongBao);
@@ -770,12 +811,14 @@
minDate, maxDate);
UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
- (int) validCount, (int) weiQuanCount, (int) invalidCount, sharemoney, new Date());
+ (int) validCount, (int) weiQuanCount, sharemoney, new Date());
// 娣诲姞璧勯噾
userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
// 娣诲姞鍒扮孩鍖呰繑鍒╄褰曢泦鍚�
accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
+ if (hbIdList.size() > 0)
+ recieveHongBaoIds.addAll(hbIdList);
} catch (UserMoneyDetailException e) {
try {
LogHelper.errorDetailInfo(e);
@@ -790,6 +833,16 @@
for (String orderId : drawBackOrders)
taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
+ }
+
+ // 鎵�鏈夌殑杩斿埄鍒拌处绾㈠寘ID
+ for (Long hongBaoId : recieveHongBaoIds) {
+ try {
+ HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e);
+ }
+
}
}
@@ -960,9 +1013,14 @@
public void processJDOrder(JDOrder order) {
if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
return;
+
+ // 鎷嗗崟鐨勪笉鍋氬鐞�
+ if (order.getValidCode() == 2)
+ return;
+
String uidStr = order.getExt1();
Long uid = null;
- if (!StringUtil.isNullOrEmpty(uidStr))
+ if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr))
uid = Long.parseLong(uidStr);
Long positionId = order.getOrderItemList().get(0).getPositionId();
if (positionId == JDApiUtil.POSITION_FANLI)// 杩斿埄璁㈠崟
@@ -1005,7 +1063,7 @@
// 鍔犲叆璁㈠崟
Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(jdOrder.getOrderId() + "",
Constant.SOURCE_TYPE_JD);
- if (uid == null && oldOrder.getBeizhu().contains("琛ュ崟"))
+ if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("琛ュ崟"))
uid = oldOrder.getUserInfo().getId();
if (uid == null)
@@ -1120,7 +1178,7 @@
// 鍔犲叆璁㈠崟
Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD);
- if (uid == null && oldOrder.getBeizhu().contains("琛ュ崟"))
+ if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("琛ュ崟"))
uid = oldOrder.getUserInfo().getId();
if (uid == null)
@@ -1194,4 +1252,24 @@
}
}
}
+
+ @Override
+ public void repairCommonOrderByByTaoBaoOrder(String orderId) {
+ // 鏍规嵁璁㈠崟鍙锋煡璇㈡窐瀹濊鍗�
+ List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
+ if (orderList != null)
+ for (TaoBaoOrder order : orderList) {
+ // 鏍规嵁浜ゆ槗ID鏌ヨ甯歌璁㈠崟
+ CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
+ order.getTradeId());
+ // 淇orderby
+ if (commonOrder != null) {
+ CommonOrder update = new CommonOrder(commonOrder.getId());
+ update.setOrderBy(order.getOrderBy());
+ update.setUpdateTime(new Date());
+ commonOrderService.updateByPrimaryKeySelective(update);
+ }
+ }
+
+ }
}
--
Gitblit v1.8.0