From 81da61b828e29b7745e1382dfbbaeb685dc083ef Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 23 一月 2024 17:17:55 +0800 Subject: [PATCH] 抖音转链修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinDetailServiceImpl.java | 476 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 238 insertions(+), 238 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinDetailServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinDetailServiceImpl.java index b053ef4..6e72149 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinDetailServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinDetailServiceImpl.java @@ -1,238 +1,238 @@ -package com.yeshi.fanli.service.impl.tlj; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; - -import com.yeshi.fanli.dao.mybatis.tlj.UserTaoLiJinDetailMapper; -import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail; -import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum; -import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin; -import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin.TaoLiJinOriginEnum; -import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService; -import org.yeshi.utils.TimeUtil; -import com.yeshi.fanli.vo.tlj.TaoLiJinDetailVO; -import com.yeshi.fanli.vo.tlj.TaoLiJinMonthVO; - -@Service -public class UserTaoLiJinDetailServiceImpl implements UserTaoLiJinDetailService{ - - @Resource - private UserTaoLiJinDetailMapper userTaoLiJinDetailMapper; - - - @Override - public void insertSelective(UserTaoLiJinDetail record) { - userTaoLiJinDetailMapper.insertSelective(record); - } - - @Override - public Long countDetail(long uid) { - return userTaoLiJinDetailMapper.countDetail(uid); - } - - - @Override - public BigDecimal countUseMoneyByDate(long uid, int dateType) { - return userTaoLiJinDetailMapper.countUseMoneyByDate(uid, dateType); - } - - - @Override - public List<TaoLiJinDetailVO> listUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) { - List<TaoLiJinDetailVO> finalList = new ArrayList<>(); - List<UserTaoLiJinDetail> list = null; - if (detailId == null) {// 棣栨璇锋眰 - if (maxTime == null)// 娌℃湁绛涢�夋椂闂� - { - list = userTaoLiJinDetailMapper.selectByMaxCreateTime(uid, - new Date(System.currentTimeMillis() + 1000 * 60 * 60L), 20); - } else {// 绛涢�変簡鏃堕棿 - list = userTaoLiJinDetailMapper.selectByMaxCreateTime(uid, maxTime, 20); - } - if (list != null && list.size() > 0) { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(list.get(0).getCreateTime().getTime()); - TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); - vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); - finalList.add(vo); - } else { - if (maxTime != null) {// - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(maxTime.getTime()); - TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); - vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); - vo.getMonth().setExpend("0"); - vo.getMonth().setIncome("0"); - finalList.add(vo); - } - } - - } else {// 浜屾璇锋眰 - - int size = 21; - List<UserTaoLiJinDetail> tempList = userTaoLiJinDetailMapper.selectByUidWithIndexId(uid, detailId, size); - Set<Date> dateSet = new HashSet<>();// 鐢ㄤ簬鍌ㄥ瓨鏄惁鍦ㄥ悓涓�鏃堕棿涓婇潰锛堢簿纭埌绉掞級 - if (tempList.size() > 0) { - for (UserTaoLiJinDetail umd : tempList) { - dateSet.add(umd.getCreateTime()); - } - - List<UserTaoLiJinDetail> tempList2 = new ArrayList<>(); - while (dateSet.size() == 1 && tempList2.size() != tempList.size() && size < 40) {// 鍙湁涓�涓椂闂寸偣鐨勬暟鎹� - tempList = tempList2; - size += 10; - tempList2 = userTaoLiJinDetailMapper.selectByUidWithIndexId(uid, detailId, size); - dateSet.clear(); - for (UserTaoLiJinDetail umd : tempList2) { - dateSet.add(umd.getCreateTime()); - } - } - if (tempList2.size() > 0) - tempList = tempList2; - } - - for (int i = 0; i < tempList.size(); i++) { - if (tempList.get(i).getId().longValue() == detailId) { - tempList.remove(i); - break; - } else { - tempList.remove(i); - i--; - } - } - list = tempList; - } - - if (list != null) { - if (detailId != null && list.size() > 0) { - UserTaoLiJinDetail umd = userTaoLiJinDetailMapper.selectByPrimaryKey(detailId); - if (!TimeUtil.getGernalTime(umd.getCreateTime().getTime(), "yyyy-MM") - .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(0).getCreateTime().getTime(), "yyyy-MM"))) { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(list.get(0).getCreateTime().getTime()); - TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); - vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); - finalList.add(vo); - } - - } - for (int i = 0; i < list.size(); i++) { - if (i > 0 && !TimeUtil.getGernalTime(list.get(i - 1).getCreateTime().getTime(), "yyyy-MM") - .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(i).getCreateTime().getTime(), "yyyy-MM"))) {// 鏈潯鏁版嵁涓庝笂鏉℃暟鎹笉鏄悓涓�鏈堝垯鎻掑叆鏈堜唤 - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(list.get(i).getCreateTime().getTime()); - TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); - vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); - finalList.add(vo); - } - TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); - vo.setDetail(list.get(i)); - finalList.add(vo); - } - } - - // 缁熻鏈堣祫閲� - - Map<Integer, TaoLiJinDetailVO> monthMap = new TreeMap<>(); - if (finalList.size() > 1) - for (int i = 0; i < finalList.size(); i++) { - if (finalList.get(i).getMonth() != null) - monthMap.put(i, finalList.get(i)); - } - - if (!monthMap.isEmpty()) { - List<String> dateFormat = new ArrayList<>(); - Iterator<Integer> keys = monthMap.keySet().iterator(); - while (keys.hasNext()) { - Integer key = keys.next(); - String date = ""; - date += monthMap.get(key).getMonth().getYear(); - date += "-"; - date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2 - ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth(); - dateFormat.add(date); - } - List<TaoLiJinMonthVO> voList = userTaoLiJinDetailMapper.selectMonthMoneyByUid(uid, dateFormat); - - int p = 0; - keys = monthMap.keySet().iterator(); - while (keys.hasNext()) { - Integer key = keys.next(); - - BigDecimal expend = new BigDecimal(voList.get(p).getExpend()); - BigDecimal income = new BigDecimal(voList.get(p).getIncome()); - - // 鍘婚櫎鏀嚭璐熷彿 - finalList.get(key).getMonth().setExpend(expend.setScale(2).toString().replace("-", "")); - finalList.get(key).getMonth().setIncome(income.setScale(2).toString()); - p++; - } - } - return finalList; - } - - - @Override - public long countUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) { - long monthCount = 0L; - long detailCount = 0L; - // 鏈�氳繃鏃堕棿绛涢�夛紝鏌ヨ鎵�鏈� - if (maxTime == null) { - detailCount = userTaoLiJinDetailMapper.selectCountByUid(uid); - // 鐢ㄤ簬琛ㄧず褰撳墠鎵�鏈� - monthCount = userTaoLiJinDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L)); - } else {// 閫氳繃鏃堕棿绛涢�変簡鐨勶紝闇�瑕佹煡璇㈡墍鏈� - detailCount = userTaoLiJinDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime); - monthCount = userTaoLiJinDetailMapper.selectMonthCountByUid(uid, maxTime); - } - - return monthCount + detailCount; - } - - - @Override - public void createAddDetail(UserTaoLiJinOrigin taoLiJinOrigin) { - UserTaoLiJinDetail detail = new UserTaoLiJinDetail(); - detail.setUid(taoLiJinOrigin.getUid()); - detail.setMoney(taoLiJinOrigin.getMoney()); - - // 绾㈠寘閫�鍥� - if (taoLiJinOrigin.getOrigin().equals(TaoLiJinOriginEnum.refund)) { - detail.setType(TaoLiJinDetailTypeEnum.refund); - detail.setTitle(TaoLiJinDetailTypeEnum.refund.getDesc()); - } else { - detail.setType(TaoLiJinDetailTypeEnum.add); - detail.setTitle(TaoLiJinDetailTypeEnum.add.getDesc()); - String desc = taoLiJinOrigin.getOrigin().getDesc(); - if (taoLiJinOrigin.getOrigin().equals(TaoLiJinOriginEnum.newbiesWin) && taoLiJinOrigin.getType() == 1) { - desc = "鍒嗕韩绾㈠寘"; // 鑰佺敤鎴风湅鍒扮殑鏄垎浜孩鍖� - } - detail.setDescInfo("鏉ユ簮锛�" + desc); - } - detail.setCreateTime(new Date()); - userTaoLiJinDetailMapper.insertSelective(detail); - } - - - @Override - public Long countNumByDay(String preDay) { - return userTaoLiJinDetailMapper.countNumByDay(preDay); - } - - @Override - public BigDecimal countMoneyByDay(String preDay) { - return userTaoLiJinDetailMapper.countMoneyByDay(preDay); - } -} +package com.yeshi.fanli.service.impl.tlj; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; + +import com.yeshi.fanli.dao.mybatis.tlj.UserTaoLiJinDetailMapper; +import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail; +import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum; +import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin; +import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin.TaoLiJinOriginEnum; +import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService; +import org.yeshi.utils.TimeUtil; +import com.yeshi.fanli.vo.tlj.TaoLiJinDetailVO; +import com.yeshi.fanli.vo.tlj.TaoLiJinMonthVO; + +@Service +public class UserTaoLiJinDetailServiceImpl implements UserTaoLiJinDetailService{ + + @Resource + private UserTaoLiJinDetailMapper userTaoLiJinDetailMapper; + + + @Override + public void insertSelective(UserTaoLiJinDetail record) { + userTaoLiJinDetailMapper.insertSelective(record); + } + + @Override + public Long countDetail(long uid) { + return userTaoLiJinDetailMapper.countDetail(uid); + } + + + @Override + public BigDecimal countUseMoneyByDate(long uid, int dateType) { + return userTaoLiJinDetailMapper.countUseMoneyByDate(uid, dateType); + } + + + @Override + public List<TaoLiJinDetailVO> listUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) { + List<TaoLiJinDetailVO> finalList = new ArrayList<>(); + List<UserTaoLiJinDetail> list = null; + if (detailId == null) {// 棣栨璇锋眰 + if (maxTime == null)// 娌℃湁绛涢�夋椂闂� + { + list = userTaoLiJinDetailMapper.selectByMaxCreateTime(uid, + new Date(System.currentTimeMillis() + 1000 * 60 * 60L), 20); + } else {// 绛涢�変簡鏃堕棿 + list = userTaoLiJinDetailMapper.selectByMaxCreateTime(uid, maxTime, 20); + } + if (list != null && list.size() > 0) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(list.get(0).getCreateTime().getTime()); + TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); + vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); + finalList.add(vo); + } else { + if (maxTime != null) {// + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(maxTime.getTime()); + TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); + vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); + vo.getMonth().setExpend("0"); + vo.getMonth().setIncome("0"); + finalList.add(vo); + } + } + + } else {// 浜屾璇锋眰 + + int size = 21; + List<UserTaoLiJinDetail> tempList = userTaoLiJinDetailMapper.selectByUidWithIndexId(uid, detailId, size); + Set<Date> dateSet = new HashSet<>();// 鐢ㄤ簬鍌ㄥ瓨鏄惁鍦ㄥ悓涓�鏃堕棿涓婇潰锛堢簿纭埌绉掞級 + if (tempList.size() > 0) { + for (UserTaoLiJinDetail umd : tempList) { + dateSet.add(umd.getCreateTime()); + } + + List<UserTaoLiJinDetail> tempList2 = new ArrayList<>(); + while (dateSet.size() == 1 && tempList2.size() != tempList.size() && size < 40) {// 鍙湁涓�涓椂闂寸偣鐨勬暟鎹� + tempList = tempList2; + size += 10; + tempList2 = userTaoLiJinDetailMapper.selectByUidWithIndexId(uid, detailId, size); + dateSet.clear(); + for (UserTaoLiJinDetail umd : tempList2) { + dateSet.add(umd.getCreateTime()); + } + } + if (tempList2.size() > 0) + tempList = tempList2; + } + + for (int i = 0; i < tempList.size(); i++) { + if (tempList.get(i).getId().longValue() == detailId) { + tempList.remove(i); + break; + } else { + tempList.remove(i); + i--; + } + } + list = tempList; + } + + if (list != null) { + if (detailId != null && list.size() > 0) { + UserTaoLiJinDetail umd = userTaoLiJinDetailMapper.selectByPrimaryKey(detailId); + if (!TimeUtil.getGernalTime(umd.getCreateTime().getTime(), "yyyy-MM") + .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(0).getCreateTime().getTime(), "yyyy-MM"))) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(list.get(0).getCreateTime().getTime()); + TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); + vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); + finalList.add(vo); + } + + } + for (int i = 0; i < list.size(); i++) { + if (i > 0 && !TimeUtil.getGernalTime(list.get(i - 1).getCreateTime().getTime(), "yyyy-MM") + .equalsIgnoreCase(TimeUtil.getGernalTime(list.get(i).getCreateTime().getTime(), "yyyy-MM"))) {// 鏈潯鏁版嵁涓庝笂鏉℃暟鎹笉鏄悓涓�鏈堝垯鎻掑叆鏈堜唤 + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(list.get(i).getCreateTime().getTime()); + TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); + vo.setMonth(new TaoLiJinMonthVO(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1)); + finalList.add(vo); + } + TaoLiJinDetailVO vo = new TaoLiJinDetailVO(); + vo.setDetail(list.get(i)); + finalList.add(vo); + } + } + + // 缁熻鏈堣祫閲� + + Map<Integer, TaoLiJinDetailVO> monthMap = new TreeMap<>(); + if (finalList.size() > 1) + for (int i = 0; i < finalList.size(); i++) { + if (finalList.get(i).getMonth() != null) + monthMap.put(i, finalList.get(i)); + } + + if (!monthMap.isEmpty()) { + List<String> dateFormat = new ArrayList<>(); + Iterator<Integer> keys = monthMap.keySet().iterator(); + while (keys.hasNext()) { + Integer key = keys.next(); + String date = ""; + date += monthMap.get(key).getMonth().getYear(); + date += "-"; + date += (monthMap.get(key).getMonth().getMonth() + "").length() < 2 + ? "0" + monthMap.get(key).getMonth().getMonth() : monthMap.get(key).getMonth().getMonth(); + dateFormat.add(date); + } + List<TaoLiJinMonthVO> voList = userTaoLiJinDetailMapper.selectMonthMoneyByUid(uid, dateFormat); + + int p = 0; + keys = monthMap.keySet().iterator(); + while (keys.hasNext()) { + Integer key = keys.next(); + + BigDecimal expend = new BigDecimal(voList.get(p).getExpend()); + BigDecimal income = new BigDecimal(voList.get(p).getIncome()); + + // 鍘婚櫎鏀嚭璐熷彿 + finalList.get(key).getMonth().setExpend(expend.setScale(2).toString().replace("-", "")); + finalList.get(key).getMonth().setIncome(income.setScale(2).toString()); + p++; + } + } + return finalList; + } + + + @Override + public long countUserMoneyDetailForClient(Long uid, Long detailId, Date maxTime) { + long monthCount = 0L; + long detailCount = 0L; + // 鏈�氳繃鏃堕棿绛涢�夛紝鏌ヨ鎵�鏈� + if (maxTime == null) { + detailCount = userTaoLiJinDetailMapper.selectCountByUid(uid); + // 鐢ㄤ簬琛ㄧず褰撳墠鎵�鏈� + monthCount = userTaoLiJinDetailMapper.selectMonthCountByUid(uid, new Date(System.currentTimeMillis() + 1000 * 60 * 60L)); + } else {// 閫氳繃鏃堕棿绛涢�変簡鐨勶紝闇�瑕佹煡璇㈡墍鏈� + detailCount = userTaoLiJinDetailMapper.selectCountByUidAndMaxCreateTime(uid, maxTime); + monthCount = userTaoLiJinDetailMapper.selectMonthCountByUid(uid, maxTime); + } + + return monthCount + detailCount; + } + + + @Override + public void createAddDetail(UserTaoLiJinOrigin taoLiJinOrigin) { + UserTaoLiJinDetail detail = new UserTaoLiJinDetail(); + detail.setUid(taoLiJinOrigin.getUid()); + detail.setMoney(taoLiJinOrigin.getMoney()); + + // 绾㈠寘閫�鍥� + if (taoLiJinOrigin.getOrigin().equals(TaoLiJinOriginEnum.refund)) { + detail.setType(TaoLiJinDetailTypeEnum.refund); + detail.setTitle(TaoLiJinDetailTypeEnum.refund.getDesc()); + } else { + detail.setType(TaoLiJinDetailTypeEnum.add); + detail.setTitle(TaoLiJinDetailTypeEnum.add.getDesc()); + String desc = taoLiJinOrigin.getOrigin().getDesc(); + if (taoLiJinOrigin.getOrigin().equals(TaoLiJinOriginEnum.newbiesWin) && taoLiJinOrigin.getType() == 1) { + desc = "鍒嗕韩绾㈠寘"; // 鑰佺敤鎴风湅鍒扮殑鏄垎浜孩鍖� + } + detail.setDescInfo("鏉ユ簮锛�" + desc); + } + detail.setCreateTime(new Date()); + userTaoLiJinDetailMapper.insertSelective(detail); + } + + + @Override + public Long countNumByDay(String preDay) { + return userTaoLiJinDetailMapper.countNumByDay(preDay); + } + + @Override + public BigDecimal countMoneyByDay(String preDay) { + return userTaoLiJinDetailMapper.countMoneyByDay(preDay); + } +} -- Gitblit v1.8.0