From d1c067339554c90fb74653748ccf224104d8c8e4 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 29 一月 2019 11:52:04 +0800
Subject: [PATCH] 加入系统消息
---
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java | 158 +++++++++++++++++++++++++++++-----------------------
1 files changed, 88 insertions(+), 70 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
index 6343410..640d21b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -22,6 +22,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import org.yeshi.utils.HttpUtil;
+import org.yeshi.utils.NumberUtil;
+import org.yeshi.utils.tencentcloud.COSManager;
import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.BindingAccountMapper;
@@ -37,8 +40,10 @@
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.WeiXinUser;
import com.yeshi.fanli.entity.system.System;
+import com.yeshi.fanli.exception.ThreeSaleException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
+import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.user.UserInfoService;
@@ -49,9 +54,6 @@
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.wx.WXLoginUtil;
-import org.yeshi.utils.HttpUtil;
-import org.yeshi.utils.NumberUtil;
-import org.yeshi.utils.tencentcloud.COSManager;
@Service
public class UserInfoServiceImpl implements UserInfoService {
@@ -73,22 +75,24 @@
@Resource
private UserInfoMapper userInfoMapper;
-
+
@Resource
private BindingAccountMapper bindingAccountMapper;
-
+
@Resource
private PayInfoMapper payInfoMapper;
-
+
@Resource
private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
-
+
@Resource
private ScanHistoryMapper scanHistoryMapper;
-
+
@Resource
private ShareMapper shareMapper;
+ @Resource
+ private HongBaoV2CountService hongBaoV2CountService;
public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) {
@@ -420,13 +424,15 @@
}
String wxUnionId = weiXinUser.getUnionid();
UserInfo find = getUserByLoginTypeAndOpenId(Constant.WEIXIN, wxUnionId, Constant.APPID);
+
if (find == null) {
find = new UserInfo();
find.setAppId(Constant.APPID);
find.setWxUnionId(weiXinUser.getUnionid());
- String wxHeadImg = COSManager.getInstance().uploadFile(
- HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
- Constant.WXHEADURL + UUID.randomUUID().toString()).getUrl();
+ String wxHeadImg = COSManager.getInstance()
+ .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
+ Constant.WXHEADURL + UUID.randomUUID().toString())
+ .getUrl();
find.setPortrait(wxHeadImg);
find.setWxPic(wxHeadImg);
find.setNickName(weiXinUser.getNickname());
@@ -437,17 +443,15 @@
System system = new System(Constant.FANLI);
system.setPlatform(1);
find.setSystem(system);
- UserInfo addUser = null;
- synchronized (UserInfo.class) {
- addUser = addUser(find, Constant.APPID);
- if (addUser != null && addUser.getId() > 1) {
- threeSaleSerivce.bind(find, inviter);
- return true;
- }
- }
}
- return false;
+ try {
+ threeSaleSerivce.bind(find, inviter);
+ return true;
+ } catch (ThreeSaleException e) {
+ e.printStackTrace();
+ return false;
+ }
}
@Transactional
@@ -552,7 +556,7 @@
List list = session
.createSQLQuery(
"SELECT u.id,u.`nick_name`,u.`portrait`,uu.state FROM (SELECT t.* FROM `yeshi_ec_threesale` t "
- + "WHERE t.`boss_id`=? AND (t.expire = 0 OR t.expire IS NULL) ORDER BY t.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
+ + "WHERE t.`boss_id`=? AND (t.expire = 0 OR t.expire IS NULL) ORDER BY t.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
.setParameter(0, id).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
return covertToInviteUserList(list);
}
@@ -564,7 +568,7 @@
List list = session
.createSQLQuery(
"SELECT u.id,u.`nick_name`,u.`portrait`,uu.state FROM (SELECT tt.* FROM `yeshi_ec_threesale` t LEFT JOIN yeshi_ec_threesale tt ON tt.`boss_id`=t.`worker_id` "
- + " WHERE t.`boss_id`=? AND tt.`id` IS NOT NULL AND (tt.expire = 0 OR tt.expire IS NULL) ORDER BY tt.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
+ + " WHERE t.`boss_id`=? AND tt.`id` IS NOT NULL AND (tt.expire = 0 OR tt.expire IS NULL) ORDER BY tt.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
.setParameter(0, id).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
return covertToInviteUserList(list);
}
@@ -598,8 +602,8 @@
@Override
public long getFriendsListCount(long id, int type) {
if (type == 1)
- return userInfoDao
- .getCountSQL("SELECT COUNT(t.`id`) FROM `yeshi_ec_threesale` t WHERE t.`boss_id`= " + id +" AND (t.expire = 0 OR t.expire IS NULL)");
+ return userInfoDao.getCountSQL("SELECT COUNT(t.`id`) FROM `yeshi_ec_threesale` t WHERE t.`boss_id`= " + id
+ + " AND (t.expire = 0 OR t.expire IS NULL)");
else
return userInfoDao.getCountSQL(
"SELECT COUNT(tt.id) FROM `yeshi_ec_threesale` t LEFT JOIN yeshi_ec_threesale tt ON tt.`boss_id`=t.`worker_id` WHERE t.`boss_id`="
@@ -622,15 +626,14 @@
return UserUtil.filterForClientUser(user);
}
-
@Override
- public List<UserInfoAdmin> query(long start, int count, String key, Integer userType,
- Integer days, String startTime, String endTime, Integer orderField,Integer orderMode) {
+ public List<UserInfoAdmin> query(long start, int count, String key, Integer userType, Integer days,
+ String startTime, String endTime, Integer orderField, Integer orderMode) {
List<UserInfoAdmin> adminList = new ArrayList<UserInfoAdmin>();
- List<UserInfo> userList = userInfoMapper.query(start, count, key, userType, days,
- startTime, endTime, orderField,orderMode);
+ List<UserInfo> userList = userInfoMapper.query(start, count, key, userType, days, startTime, endTime,
+ orderField, orderMode);
if (userList == null || userList.size() == 0) {
return null;
}
@@ -638,37 +641,34 @@
for (UserInfo userInfo : userList) {
UserInfoAdmin userInfoAdmin = new UserInfoAdmin();
-
+
Long lastLoginTime = userInfo.getLastLoginTime();
if (lastLoginTime == null) {
userInfo.setLastLoginTime(0L);
- }
-
-
+ }
+
userInfoAdmin.setUserInfo(userInfo);
-
+
String wxName = userInfo.getWxName();
if (StringUtil.isNullOrEmpty(wxName)) {
userInfoAdmin.setWxNameState(1);
} else {
userInfoAdmin.setWxNameState(2);
}
-
+
String phone = userInfo.getPhone();
if (StringUtil.isNullOrEmpty(phone)) {
userInfoAdmin.setPhoneState(1);
} else {
userInfoAdmin.setPhoneState(2);
}
-
+
String tbName = userInfo.getTbName();
if (StringUtil.isNullOrEmpty(tbName)) {
userInfoAdmin.setTbNameState(1);
} else {
userInfoAdmin.setTbNameState(2);
}
-
-
Long uid = userInfo.getId();
@@ -682,7 +682,7 @@
userInfoAdmin.setAccountAlipay(bindingAccount.getAccount());
userInfoAdmin.setAccountName(bindingAccount.getName());
userInfoAdmin.setAccountBindId(bindingAccount.getId());
-
+
} else if (type != null && type == 2) {
// 寰俊
userInfoAdmin.setAccountWX(bindingAccount.getAccount());
@@ -690,58 +690,66 @@
userInfoAdmin.setAccountBindIdWX(bindingAccount.getId());
}
}
-
-
+
// 鏈�鍚庝竴娆′笅鍗曟椂闂�
- Long lastOrderTime = hongBaoService.getLastOrderTime(uid);
+ Date lastOrderTime = hongBaoV2CountService.getLastHongBaoTime(uid);
if (lastOrderTime == null) {
userInfoAdmin.setLastOrderTime(0);
} else {
- userInfoAdmin.setLastOrderTime(lastOrderTime);
+ userInfoAdmin.setLastOrderTime(lastOrderTime.getTime());
}
-
-
+
// 鍘嗗彶鎬昏鍗�
- long totalOrder = hongBaoService.countByUidSelf(uid, null, null);
+ long totalOrder = hongBaoV2CountService.countValidNumberByUid(uid, null);
+
// 浠婃棩鎬昏鍗�
- long todayOrder = hongBaoService.countByUidSelf(uid, 1, null);
+ long todayOrder = hongBaoV2CountService.countValidNumberByUid(uid, 1);
// 鏈湀鎬昏鍗�
- long monthOrder = hongBaoService.countByUidSelf(uid, null, 1);
+ long monthOrder = hongBaoV2CountService.countValidNumberByUid(uid, 2);
userInfoAdmin.setTotalOrder(totalOrder);
userInfoAdmin.setTodayOrder(todayOrder);
userInfoAdmin.setMonthOrder(monthOrder);
+
+
+ // 鏈鍙栫孩鍖� 寰呭叆璐﹂噾棰�
+ BigDecimal unaccountedMoney = hongBaoV2CountService.countWillGetMoneyByUid(uid);
+ if (unaccountedMoney ==null) {
+ unaccountedMoney = new BigDecimal(0);
+ }
+ userInfoAdmin.setUnaccountedMoney(unaccountedMoney.toString());
+
+ // 鍘嗗彶鎬绘敹鐩�
+ BigDecimal totalMoneyHistory = hongBaoV2CountService.countMoneyByUidAndState(uid,3);
+ if (totalMoneyHistory ==null) {
+ totalMoneyHistory = new BigDecimal(0);
+ }
+ userInfoAdmin.setTotalMoneyHistory(totalMoneyHistory.toString());
+
+
+
// 鏀粯瀹濊处鍙� 绱杞处鎬婚噾棰�
double totalMoney = payInfoMapper.sumMoneyByUid(uid);
userInfoAdmin.setTotalMoney(totalMoney);
-
- // 绱鎻愮幇 (鏆傛湭璁″叆寰俊)
+
+ // 绱鎻愮幇 (鏆傛湭璁″叆寰俊)
userInfoAdmin.setTotalExtract(totalMoney);
- // 鏈鍙栫孩鍖� 寰呭叆璐﹂噾棰�
- double unaccountedMoney = hongBaoService.countForecastMoneysByUid(uid);
- userInfoAdmin.setUnaccountedMoney(unaccountedMoney);
-
- // 鍘嗗彶鎬绘敹鐩�
- double totalMoneyHistory = hongBaoService.countReceiveMoneysByUid(uid);
- userInfoAdmin.setTotalMoneyHistory(totalMoneyHistory);
-
-
// 缁熻鍒嗕韩涓暟
long countUserShares = userShareGoodsHistoryMapper.countUserShares(uid);
userInfoAdmin.setCountUserShares(countUserShares);
-
+
// 缁熻娴忚瓒宠抗
long countScanHistory = scanHistoryMapper.countUserScanHistory(uid);
userInfoAdmin.setCountScanHistory(countScanHistory);
-
+
// 涓�搴﹂槦鍛樻暟閲�
- int firstTeamCount = shareMapper.myFirstTeamCount(uid +"");
+ int firstTeamCount = shareMapper.myFirstTeamCount(uid + "");
userInfoAdmin.setCountLevelOne(firstTeamCount);
-
+
// 浜屽害闃熷憳鏁伴噺
- int secondTeamCount = shareMapper.mySecondTeamCount(uid +"");
+ int secondTeamCount = shareMapper.mySecondTeamCount(uid + "");
userInfoAdmin.setCountLevelTwo(secondTeamCount);
adminList.add(userInfoAdmin);
}
@@ -754,7 +762,7 @@
public long queryCount(String key, Integer userType, Integer days, String startTime, String endTime) {
return userInfoMapper.queryCount(key, userType, days, startTime, endTime);
}
-
+
@Override
public double querySumMoney(String key, Integer userType, Integer days, String startTime, String endTime) {
return userInfoMapper.querySumMoney(key, userType, days, startTime, endTime);
@@ -764,12 +772,12 @@
public UserInfo selectByPKey(Long id) {
return userInfoMapper.selectByPKey(id);
}
-
+
@Override
public int updateByPrimaryKeySelective(UserInfo record) {
return userInfoMapper.updateByPrimaryKeySelective(record);
}
-
+
@Override
@Transactional
public void deleteBindInfo(UserInfo user, int type) {
@@ -798,11 +806,21 @@
userInfoMapper.updateByPrimaryKeySelective(user);
}
-
-
+
@Override
- public List<Long> longTimeNoLogin(int daysNum, List<Long> list ) {
+ public List<Long> longTimeNoLogin(int daysNum, List<Long> list) {
return userInfoMapper.longTimeNoLogin(daysNum, list);
}
+ /**
+ * 鏍规嵁鐢佃瘽鍙风爜銆侀個璇风爜鑾峰彇閭�璇风敤鎴�
+ * @param phone
+ * @param inviteCode
+ * @return
+ */
+ @Override
+ public UserInfo getInfoByPhoneOrInviteCode(String phone, String inviteCode) {
+ return userInfoMapper.getInfoByPhoneOrInviteCode(phone, inviteCode);
+ }
+
}
--
Gitblit v1.8.0