From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java | 1064 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 532 insertions(+), 532 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java index 6e6eaf8..9d3bc3c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java @@ -1,532 +1,532 @@ -package com.yeshi.fanli.service.impl.count; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; -import org.yeshi.utils.DateUtil; - -import com.yeshi.fanli.dao.user.count.DailyCountUserDao; -import com.yeshi.fanli.entity.admin.count.DailyCountUser; -import com.yeshi.fanli.entity.admin.count.DailyCountUser.DailyCountUserEnum; -import com.yeshi.fanli.entity.bus.user.Extract; -import com.yeshi.fanli.entity.bus.user.UserInfoRegister; -import com.yeshi.fanli.entity.system.ChannelEnum; -import com.yeshi.fanli.service.inter.count.DailyCountUserService; -import com.yeshi.fanli.service.inter.money.extract.ExtractAuditRecordService; -import com.yeshi.fanli.service.inter.order.CommonOrderCountService; -import com.yeshi.fanli.service.inter.redpack.RedPackDetailService; -import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService; -import com.yeshi.fanli.service.inter.user.UserActiveLogService; -import com.yeshi.fanli.service.inter.user.UserInfoRegisterService; -import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService; -import com.yeshi.fanli.util.MoneyBigDecimalUtil; -import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.TimeUtil; - -@Service -public class DailyCountUserServiceImpl implements DailyCountUserService { - - @Resource - private DailyCountUserDao dailyCountUserDao; - - @Resource - private UserInfoRegisterService userInfoRegisterService; - - @Resource - private CommonOrderCountService commonOrderCountService; - - @Resource - private UserActiveLogService userActiveLogService; - - @Resource - private IntegralDetailService integralDetailService; - - @Resource - private RedPackDetailService redPackDetailService; - - @Resource - private UserTaoLiJinDetailService userTaoLiJinDetailService; - - @Resource - private ExtractAuditRecordService extractAuditRecordService; - - - @Override - public List<DailyCountUser> getDailyCountList(String type, Date startTime, Date endTime, String channel) throws Exception { - // 鏌ヨ绫诲瀷 - DailyCountUserEnum typeEnum = getTypeEnum(type); - if (typeEnum == null) { - return null; - } - - // 鍒濆鍖栨暟鎹� - initData(typeEnum); - - return dailyCountUserDao.query(typeEnum, startTime, endTime, channel); - } - - /** - * 鑾峰彇鏋氫妇绫诲瀷 - * @param type - * @return - */ - private DailyCountUserEnum getTypeEnum(String name) { - if (StringUtil.isNullOrEmpty(name)) { - return null; - } - - DailyCountUserEnum[] array = DailyCountUserEnum.values(); - for (int i = 0; i < array.length; i ++) { - if (array[i].name().equals(name)) { - return array[i]; - } - } - return null; - } - - - /** - * 鑾峰彇鏋氫妇绫诲瀷 - * @param type - * @return - */ - @Override - public String getTypeEnumDesc(String name) { - if (StringUtil.isNullOrEmpty(name)) { - return ""; - } - - DailyCountUserEnum[] array = DailyCountUserEnum.values(); - for (int i = 0; i < array.length; i ++) { - if (array[i].name().equals(name)) { - return array[i].getDesc(); - } - } - - return ""; - } - - - - /** - * 鍒濆鏁版嵁 - * @param typeEnum - * @throws Exception - */ - @Override - public void initData(DailyCountUserEnum typeEnum) throws Exception { - Date lastDate = null; - DailyCountUser lastRecord = dailyCountUserDao.getMaxDate(typeEnum); - if (lastRecord != null) { - lastDate = lastRecord.getUpdateDate(); - } else { - lastDate = TimeUtil.parse("2017-05-06"); - } - long min = DateUtil.dateDiffMin(lastDate, new Date()); - if (min <= 10) { // 10鍒嗛挓浠ュ唴涓嶇粺璁� - return; - } - - Date today = new Date(); - int betweenDays = DateUtil.daysBetween2(lastDate, today); - for (int i = 0; i <= betweenDays; i++) { - // 璁$畻鏃ユ湡 - String preDay = DateUtil.plusDay(i, lastDate); - // 缁熻鏁版嵁 - if (DailyCountUserEnum.newUserChannel == typeEnum) { - addNewUserChannel(preDay, typeEnum); - } else if (DailyCountUserEnum.newUserDownOrderDay == typeEnum) { - addNewUserDownOrderDay(preDay, typeEnum); - } else if (DailyCountUserEnum.newUserDownOrderWeek == typeEnum) { - addNewUserDownOrderWeek(preDay); - } else if (DailyCountUserEnum.newUserDownOrderWeek3 == typeEnum) { - addNewUserDownOrderWeek(preDay); - } else if (DailyCountUserEnum.activeAgain90 == typeEnum) { - addActiveAgain90(preDay, typeEnum); - } else if (DailyCountUserEnum.integralNum == typeEnum) { - addIntegralNum(preDay, typeEnum); - } else if (DailyCountUserEnum.newUserTljNum == typeEnum) { - addNewUserTljNum(preDay, typeEnum); - } else if (DailyCountUserEnum.newUserTljMoney == typeEnum) { - addNewUserTljMoney(preDay, typeEnum); - } else if (DailyCountUserEnum.redpackNum == typeEnum) { - addRedpackNum(preDay, typeEnum); - } else if (DailyCountUserEnum.redpackMoney == typeEnum) { - addRedpackMoney(preDay, typeEnum); - } else if (DailyCountUserEnum.extractApplyNumber == typeEnum) { - addExtractApplyNumber(preDay, typeEnum); - } else if (DailyCountUserEnum.extractApplyMoney == typeEnum) { - addExtractApplyMoney(preDay, typeEnum); - } else if (DailyCountUserEnum.extractAuditPass == typeEnum) { - addExtractAuditNum(preDay, Extract.STATE_PASS, typeEnum); - } else if (DailyCountUserEnum.extractAuditReject == typeEnum) { - addExtractAuditNum(preDay, Extract.STATE_REJECT, typeEnum); - } - } - } - - - /** - * 缁熻鍚勪釜娓犻亾鏂板鐢ㄦ埛鏁伴噺 - * @param preDay - */ - private void addNewUserChannel(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - ChannelEnum[] channels = ChannelEnum.values(); - for (int i = 0; i < channels.length; i++) { - Long count = userInfoRegisterService.countByChannelAndDay(channels[i].getVlaue(), preDay); - if (count == null) { - count = 0L; - } - DailyCountUser obj = new DailyCountUser(); - obj.setTotal(BigDecimal.valueOf(count)); - obj.setType(typeEnum); - obj.setChannel(channels[i].name()); - obj.setUpdateDate(new Date()); - obj.setDay(TimeUtil.parse(preDay)); - obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); - dailyCountUserDao.save(obj); - } - } - - - /** - * 缁熻鍚勪釜娓犻亾姣忔棩涓嬪崟杞寲鐜� - * @param preDay - * @throws Exception - */ - private void addNewUserDownOrderDay(String preDay, DailyCountUserEnum typeEnum) throws Exception { - // 缁熻褰撴棩鏈夋晥璁㈠崟 - List<Long> listOrder = commonOrderCountService.getUidByValidOrderByDay(preDay); - - // 鏌ヨ褰撴棩鏂版敞鍐岀敤鎴� - List<UserInfoRegister> listRegister = userInfoRegisterService.listByDay(preDay); - - ChannelEnum[] channels = ChannelEnum.values(); - for (int i = 0; i < channels.length; i++) { - long totalDay = 0; - long totalValid = 0; - String channelName = channels[i].getVlaue(); - - if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) { - for (UserInfoRegister register: listRegister) { - String channel = register.getChannel(); - if (channelName.equalsIgnoreCase(channel)) { - // 褰撴棩娓犻亾鐢ㄦ埛 - totalDay ++ ; - - Long id = register.getId(); - // 鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁浠婃棩涓嬪崟 - for (Long uid: listOrder) { - if (uid.longValue() == id.longValue()) { - totalValid ++; - break; - } - } - } - } - } - - // 璁$畻姣斾緥锛� 涓嬪崟鐢ㄦ埛鏁�/鏂板鐢ㄦ埛鏁� - BigDecimal total = new BigDecimal(0); - if (totalDay > 0 && totalValid > 0) { - total = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalValid),BigDecimal.valueOf(totalDay)); - total = MoneyBigDecimalUtil.mul(total, BigDecimal.valueOf(100)); - } - - DailyCountUser obj = new DailyCountUser(); - obj.setTotal(total); - obj.setRate(true); - obj.setTotalDay(BigDecimal.valueOf(totalDay)); - obj.setTotalValid(BigDecimal.valueOf(totalValid)); - - obj.setType(typeEnum); - obj.setChannel(channels[i].name()); - obj.setUpdateDate(new Date()); - obj.setDay(TimeUtil.parse(preDay)); - obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); - dailyCountUserDao.save(obj); - } - } - - /** - * 缁熻褰撳懆涓嬪崟鏁版嵁 - * @param preDay - * @throws Exception - */ - private void addNewUserDownOrderWeek(String preDay) throws Exception { - // 鍔犱笂6澶� -娉ㄥ唽涓�鍛ㄥ唴鏁版嵁 - Date startDay = new Date(TimeUtil.convertDateToTemp2(preDay + " 23:59:59")); - Date limitDay = DateUtil.plusDayDate(6, startDay); - - // 娓犻亾鏁版嵁 - ChannelEnum[] channels = ChannelEnum.values(); - for (int i = 0; i < channels.length; i++) { - long totalUser = 0; - long totalWeek = 0; - long totalWeek3 = 0; - - List<Long> listUid = new ArrayList<Long>(); - - // 鏌ヨ浠婃棩鏂板鐢ㄦ埛 - List<UserInfoRegister> list = userInfoRegisterService.listByChannelAndDay(channels[i].getVlaue(), preDay); - - - if (list != null && list.size() > 0) { - totalUser = list.size(); - for (UserInfoRegister user : list) { - listUid.add(user.getId()); - } - } - - if (listUid.size() > 0) { - List<Long> listUidDown = commonOrderCountService.getDownOrderUserByListUidAndDate(limitDay, listUid); - if (listUidDown != null && listUidDown.size() > 0) { - for (Long uid: listUid) { - int total = 0; - for (Long id: listUidDown) { - if (uid.longValue() == id.longValue()) { - total ++; - } - } - - if (total > 0) { - totalWeek ++; - } - - if (total >= 3) { - totalWeek3 ++; - } - } - } - } - - - // 璁$畻姣斾緥锛氬綋鍛� 涓嬪崟鐢ㄦ埛鏁�/鏂板鐢ㄦ埛鏁� - BigDecimal total = new BigDecimal(0); - if (totalUser > 0 && totalWeek > 0) { - total = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalWeek),BigDecimal.valueOf(totalUser)); - total = MoneyBigDecimalUtil.mul(total, BigDecimal.valueOf(100)); - } - DailyCountUser obj = new DailyCountUser(); - obj.setRate(true); - obj.setTotalDay(BigDecimal.valueOf(totalUser)); - obj.setTotalValid(BigDecimal.valueOf(totalWeek)); - obj.setTotal(total); - obj.setType(DailyCountUserEnum.newUserDownOrderWeek); - obj.setChannel(channels[i].name()); - obj.setUpdateDate(new Date()); - obj.setDay(TimeUtil.parse(preDay)); - obj.setId(StringUtil.Md5(preDay + channels[i].name() + DailyCountUserEnum.newUserDownOrderWeek.name())); - dailyCountUserDao.save(obj); - - - // 璁$畻姣斾緥锛� 涓�3鍗曠敤鎴锋暟/鏂板鐢ㄦ埛鏁� - BigDecimal total3 = new BigDecimal(0); - if (totalUser > 0 && totalWeek3 > 0) { - total3 = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalWeek3),BigDecimal.valueOf(totalUser)); - total3 = MoneyBigDecimalUtil.mul(total3, BigDecimal.valueOf(100)); - } - DailyCountUser obj3 = new DailyCountUser(); - obj3.setRate(true); - obj3.setTotalDay(BigDecimal.valueOf(totalUser)); - obj3.setTotalValid(BigDecimal.valueOf(totalWeek3)); - obj3.setTotal(total3); - obj3.setType(DailyCountUserEnum.newUserDownOrderWeek3); - obj3.setChannel(channels[i].name()); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + channels[i].name() + DailyCountUserEnum.newUserDownOrderWeek3.name())); - dailyCountUserDao.save(obj3); - } - } - - /** - * 缁熻90澶╁唴鍐嶆娲昏穬 - * @param preDay - * @throws Exception - */ - private void addActiveAgain90(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - long count = userActiveLogService.count90DaysLaterActiveNum(preDay); - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(BigDecimal.valueOf(count)); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - - /** - * 閲戝竵鏂板鏁伴噺 - * @param preDay - * @throws Exception - */ - private void addIntegralNum(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - Long count = integralDetailService.countNewAddByDate(preDay); - if (count == null) { - count = 0L; - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(BigDecimal.valueOf(count)); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - /** - * 绾㈠寘鏂板鏁伴噺 - * @param preDay - * @throws Exception - */ - private void addRedpackNum(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - Long total = redPackDetailService.countNumByDay(preDay); - if (total == null) { - total = 0L; - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(new BigDecimal(total)); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - - /** - * 绾㈠寘鏂板閲戦 - * @param preDay - * @throws Exception - */ - private void addRedpackMoney(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - BigDecimal total = redPackDetailService.countMoneyByDay(preDay); - if (total == null) { - total = new BigDecimal(0); - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(total); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - - /** - * 绾㈠寘鏂板鏁伴噺 - * @param preDay - * @throws Exception - */ - private void addNewUserTljNum(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - Long total = userTaoLiJinDetailService.countNumByDay(preDay); - if (total == null) { - total = 0L; - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(new BigDecimal(total)); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - - /** - * 绾㈠寘鏂板閲戦 - * @param preDay - * @throws Exception - */ - private void addNewUserTljMoney(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - BigDecimal total = userTaoLiJinDetailService.countMoneyByDay(preDay); - if (total == null) { - total = new BigDecimal(0); - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(total); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - - /** - * 鎻愮幇鐢宠鏁伴噺 - * @param preDay - * @throws Exception - */ - private void addExtractApplyNumber(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - Long total = extractAuditRecordService.countApplyNumberByDay(preDay); - if (total == null) { - total = 0L; - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(new BigDecimal(total)); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - - /** - * 鎻愮幇鐢宠閲戦 - * @param preDay - * @throws Exception - */ - private void addExtractApplyMoney(String preDay, DailyCountUserEnum typeEnum) throws Exception{ - BigDecimal total = extractAuditRecordService.countApplyMoneyByDay(preDay); - if (total == null) { - total = new BigDecimal(0); - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(total); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - /** - * 鎻愮幇瀹℃牳鏁伴噺 - * @param preDay - * @throws Exception - */ - private void addExtractAuditNum(String preDay, int state, DailyCountUserEnum typeEnum) throws Exception{ - Long total = extractAuditRecordService.countAuditNumberByDay(state, preDay); - if (total == null) { - total = 0L; - } - - DailyCountUser obj3 = new DailyCountUser(); - obj3.setTotal(new BigDecimal(total)); - obj3.setType(typeEnum); - obj3.setUpdateDate(new Date()); - obj3.setDay(TimeUtil.parse(preDay)); - obj3.setId(StringUtil.Md5(preDay + state + typeEnum.name())); - dailyCountUserDao.save(obj3); - } - - -} +package com.yeshi.fanli.service.impl.count; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.stereotype.Service; +import org.yeshi.utils.DateUtil; + +import com.yeshi.fanli.dao.user.count.DailyCountUserDao; +import com.yeshi.fanli.entity.admin.count.DailyCountUser; +import com.yeshi.fanli.entity.admin.count.DailyCountUser.DailyCountUserEnum; +import com.yeshi.fanli.entity.bus.user.Extract; +import com.yeshi.fanli.entity.bus.user.UserInfoRegister; +import com.yeshi.fanli.entity.system.ChannelEnum; +import com.yeshi.fanli.service.inter.count.DailyCountUserService; +import com.yeshi.fanli.service.inter.money.extract.ExtractAuditRecordService; +import com.yeshi.fanli.service.inter.order.CommonOrderCountService; +import com.yeshi.fanli.service.inter.redpack.RedPackDetailService; +import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService; +import com.yeshi.fanli.service.inter.user.UserActiveLogService; +import com.yeshi.fanli.service.inter.user.UserInfoRegisterService; +import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService; +import org.yeshi.utils.MoneyBigDecimalUtil; +import com.yeshi.fanli.util.StringUtil; +import org.yeshi.utils.TimeUtil; + +@Service +public class DailyCountUserServiceImpl implements DailyCountUserService { + + @Resource + private DailyCountUserDao dailyCountUserDao; + + @Resource + private UserInfoRegisterService userInfoRegisterService; + + @Resource + private CommonOrderCountService commonOrderCountService; + + @Resource + private UserActiveLogService userActiveLogService; + + @Resource + private IntegralDetailService integralDetailService; + + @Resource + private RedPackDetailService redPackDetailService; + + @Resource + private UserTaoLiJinDetailService userTaoLiJinDetailService; + + @Resource + private ExtractAuditRecordService extractAuditRecordService; + + + @Override + public List<DailyCountUser> getDailyCountList(String type, Date startTime, Date endTime, String channel) throws Exception { + // 鏌ヨ绫诲瀷 + DailyCountUserEnum typeEnum = getTypeEnum(type); + if (typeEnum == null) { + return null; + } + + // 鍒濆鍖栨暟鎹� + initData(typeEnum); + + return dailyCountUserDao.query(typeEnum, startTime, endTime, channel); + } + + /** + * 鑾峰彇鏋氫妇绫诲瀷 + * @param type + * @return + */ + private DailyCountUserEnum getTypeEnum(String name) { + if (StringUtil.isNullOrEmpty(name)) { + return null; + } + + DailyCountUserEnum[] array = DailyCountUserEnum.values(); + for (int i = 0; i < array.length; i ++) { + if (array[i].name().equals(name)) { + return array[i]; + } + } + return null; + } + + + /** + * 鑾峰彇鏋氫妇绫诲瀷 + * @param type + * @return + */ + @Override + public String getTypeEnumDesc(String name) { + if (StringUtil.isNullOrEmpty(name)) { + return ""; + } + + DailyCountUserEnum[] array = DailyCountUserEnum.values(); + for (int i = 0; i < array.length; i ++) { + if (array[i].name().equals(name)) { + return array[i].getDesc(); + } + } + + return ""; + } + + + + /** + * 鍒濆鏁版嵁 + * @param typeEnum + * @throws Exception + */ + @Override + public void initData(DailyCountUserEnum typeEnum) throws Exception { + Date lastDate = null; + DailyCountUser lastRecord = dailyCountUserDao.getMaxDate(typeEnum); + if (lastRecord != null) { + lastDate = lastRecord.getUpdateDate(); + } else { + lastDate = TimeUtil.parse("2017-05-06"); + } + long min = DateUtil.dateDiffMin(lastDate, new Date()); + if (min <= 10) { // 10鍒嗛挓浠ュ唴涓嶇粺璁� + return; + } + + Date today = new Date(); + int betweenDays = DateUtil.daysBetween2(lastDate, today); + for (int i = 0; i <= betweenDays; i++) { + // 璁$畻鏃ユ湡 + String preDay = DateUtil.plusDay(i, lastDate); + // 缁熻鏁版嵁 + if (DailyCountUserEnum.newUserChannel == typeEnum) { + addNewUserChannel(preDay, typeEnum); + } else if (DailyCountUserEnum.newUserDownOrderDay == typeEnum) { + addNewUserDownOrderDay(preDay, typeEnum); + } else if (DailyCountUserEnum.newUserDownOrderWeek == typeEnum) { + addNewUserDownOrderWeek(preDay); + } else if (DailyCountUserEnum.newUserDownOrderWeek3 == typeEnum) { + addNewUserDownOrderWeek(preDay); + } else if (DailyCountUserEnum.activeAgain90 == typeEnum) { + addActiveAgain90(preDay, typeEnum); + } else if (DailyCountUserEnum.integralNum == typeEnum) { + addIntegralNum(preDay, typeEnum); + } else if (DailyCountUserEnum.newUserTljNum == typeEnum) { + addNewUserTljNum(preDay, typeEnum); + } else if (DailyCountUserEnum.newUserTljMoney == typeEnum) { + addNewUserTljMoney(preDay, typeEnum); + } else if (DailyCountUserEnum.redpackNum == typeEnum) { + addRedpackNum(preDay, typeEnum); + } else if (DailyCountUserEnum.redpackMoney == typeEnum) { + addRedpackMoney(preDay, typeEnum); + } else if (DailyCountUserEnum.extractApplyNumber == typeEnum) { + addExtractApplyNumber(preDay, typeEnum); + } else if (DailyCountUserEnum.extractApplyMoney == typeEnum) { + addExtractApplyMoney(preDay, typeEnum); + } else if (DailyCountUserEnum.extractAuditPass == typeEnum) { + addExtractAuditNum(preDay, Extract.STATE_PASS, typeEnum); + } else if (DailyCountUserEnum.extractAuditReject == typeEnum) { + addExtractAuditNum(preDay, Extract.STATE_REJECT, typeEnum); + } + } + } + + + /** + * 缁熻鍚勪釜娓犻亾鏂板鐢ㄦ埛鏁伴噺 + * @param preDay + */ + private void addNewUserChannel(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + ChannelEnum[] channels = ChannelEnum.values(); + for (int i = 0; i < channels.length; i++) { + Long count = userInfoRegisterService.countByChannelAndDay(channels[i].getVlaue(), preDay); + if (count == null) { + count = 0L; + } + DailyCountUser obj = new DailyCountUser(); + obj.setTotal(BigDecimal.valueOf(count)); + obj.setType(typeEnum); + obj.setChannel(channels[i].name()); + obj.setUpdateDate(new Date()); + obj.setDay(TimeUtil.parse(preDay)); + obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); + dailyCountUserDao.save(obj); + } + } + + + /** + * 缁熻鍚勪釜娓犻亾姣忔棩涓嬪崟杞寲鐜� + * @param preDay + * @throws Exception + */ + private void addNewUserDownOrderDay(String preDay, DailyCountUserEnum typeEnum) throws Exception { + // 缁熻褰撴棩鏈夋晥璁㈠崟 + List<Long> listOrder = commonOrderCountService.getUidByValidOrderByDay(preDay); + + // 鏌ヨ褰撴棩鏂版敞鍐岀敤鎴� + List<UserInfoRegister> listRegister = userInfoRegisterService.listByDay(preDay); + + ChannelEnum[] channels = ChannelEnum.values(); + for (int i = 0; i < channels.length; i++) { + long totalDay = 0; + long totalValid = 0; + String channelName = channels[i].getVlaue(); + + if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) { + for (UserInfoRegister register: listRegister) { + String channel = register.getChannel(); + if (channelName.equalsIgnoreCase(channel)) { + // 褰撴棩娓犻亾鐢ㄦ埛 + totalDay ++ ; + + Long id = register.getId(); + // 鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁浠婃棩涓嬪崟 + for (Long uid: listOrder) { + if (uid.longValue() == id.longValue()) { + totalValid ++; + break; + } + } + } + } + } + + // 璁$畻姣斾緥锛� 涓嬪崟鐢ㄦ埛鏁�/鏂板鐢ㄦ埛鏁� + BigDecimal total = new BigDecimal(0); + if (totalDay > 0 && totalValid > 0) { + total = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalValid),BigDecimal.valueOf(totalDay)); + total = MoneyBigDecimalUtil.mul(total, BigDecimal.valueOf(100)); + } + + DailyCountUser obj = new DailyCountUser(); + obj.setTotal(total); + obj.setRate(true); + obj.setTotalDay(BigDecimal.valueOf(totalDay)); + obj.setTotalValid(BigDecimal.valueOf(totalValid)); + + obj.setType(typeEnum); + obj.setChannel(channels[i].name()); + obj.setUpdateDate(new Date()); + obj.setDay(TimeUtil.parse(preDay)); + obj.setId(StringUtil.Md5(preDay + channels[i].name() + typeEnum.name())); + dailyCountUserDao.save(obj); + } + } + + /** + * 缁熻褰撳懆涓嬪崟鏁版嵁 + * @param preDay + * @throws Exception + */ + private void addNewUserDownOrderWeek(String preDay) throws Exception { + // 鍔犱笂6澶� -娉ㄥ唽涓�鍛ㄥ唴鏁版嵁 + Date startDay = new Date(TimeUtil.convertDateToTemp2(preDay + " 23:59:59")); + Date limitDay = DateUtil.plusDayDate(6, startDay); + + // 娓犻亾鏁版嵁 + ChannelEnum[] channels = ChannelEnum.values(); + for (int i = 0; i < channels.length; i++) { + long totalUser = 0; + long totalWeek = 0; + long totalWeek3 = 0; + + List<Long> listUid = new ArrayList<Long>(); + + // 鏌ヨ浠婃棩鏂板鐢ㄦ埛 + List<UserInfoRegister> list = userInfoRegisterService.listByChannelAndDay(channels[i].getVlaue(), preDay); + + + if (list != null && list.size() > 0) { + totalUser = list.size(); + for (UserInfoRegister user : list) { + listUid.add(user.getId()); + } + } + + if (listUid.size() > 0) { + List<Long> listUidDown = commonOrderCountService.getDownOrderUserByListUidAndDate(limitDay, listUid); + if (listUidDown != null && listUidDown.size() > 0) { + for (Long uid: listUid) { + int total = 0; + for (Long id: listUidDown) { + if (uid.longValue() == id.longValue()) { + total ++; + } + } + + if (total > 0) { + totalWeek ++; + } + + if (total >= 3) { + totalWeek3 ++; + } + } + } + } + + + // 璁$畻姣斾緥锛氬綋鍛� 涓嬪崟鐢ㄦ埛鏁�/鏂板鐢ㄦ埛鏁� + BigDecimal total = new BigDecimal(0); + if (totalUser > 0 && totalWeek > 0) { + total = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalWeek),BigDecimal.valueOf(totalUser)); + total = MoneyBigDecimalUtil.mul(total, BigDecimal.valueOf(100)); + } + DailyCountUser obj = new DailyCountUser(); + obj.setRate(true); + obj.setTotalDay(BigDecimal.valueOf(totalUser)); + obj.setTotalValid(BigDecimal.valueOf(totalWeek)); + obj.setTotal(total); + obj.setType(DailyCountUserEnum.newUserDownOrderWeek); + obj.setChannel(channels[i].name()); + obj.setUpdateDate(new Date()); + obj.setDay(TimeUtil.parse(preDay)); + obj.setId(StringUtil.Md5(preDay + channels[i].name() + DailyCountUserEnum.newUserDownOrderWeek.name())); + dailyCountUserDao.save(obj); + + + // 璁$畻姣斾緥锛� 涓�3鍗曠敤鎴锋暟/鏂板鐢ㄦ埛鏁� + BigDecimal total3 = new BigDecimal(0); + if (totalUser > 0 && totalWeek3 > 0) { + total3 = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalWeek3),BigDecimal.valueOf(totalUser)); + total3 = MoneyBigDecimalUtil.mul(total3, BigDecimal.valueOf(100)); + } + DailyCountUser obj3 = new DailyCountUser(); + obj3.setRate(true); + obj3.setTotalDay(BigDecimal.valueOf(totalUser)); + obj3.setTotalValid(BigDecimal.valueOf(totalWeek3)); + obj3.setTotal(total3); + obj3.setType(DailyCountUserEnum.newUserDownOrderWeek3); + obj3.setChannel(channels[i].name()); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + channels[i].name() + DailyCountUserEnum.newUserDownOrderWeek3.name())); + dailyCountUserDao.save(obj3); + } + } + + /** + * 缁熻90澶╁唴鍐嶆娲昏穬 + * @param preDay + * @throws Exception + */ + private void addActiveAgain90(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + long count = userActiveLogService.count90DaysLaterActiveNum(preDay); + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(BigDecimal.valueOf(count)); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + + /** + * 閲戝竵鏂板鏁伴噺 + * @param preDay + * @throws Exception + */ + private void addIntegralNum(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + Long count = integralDetailService.countNewAddByDate(preDay); + if (count == null) { + count = 0L; + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(BigDecimal.valueOf(count)); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + /** + * 绾㈠寘鏂板鏁伴噺 + * @param preDay + * @throws Exception + */ + private void addRedpackNum(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + Long total = redPackDetailService.countNumByDay(preDay); + if (total == null) { + total = 0L; + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(new BigDecimal(total)); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + + /** + * 绾㈠寘鏂板閲戦 + * @param preDay + * @throws Exception + */ + private void addRedpackMoney(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + BigDecimal total = redPackDetailService.countMoneyByDay(preDay); + if (total == null) { + total = new BigDecimal(0); + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(total); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + + /** + * 绾㈠寘鏂板鏁伴噺 + * @param preDay + * @throws Exception + */ + private void addNewUserTljNum(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + Long total = userTaoLiJinDetailService.countNumByDay(preDay); + if (total == null) { + total = 0L; + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(new BigDecimal(total)); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + + /** + * 绾㈠寘鏂板閲戦 + * @param preDay + * @throws Exception + */ + private void addNewUserTljMoney(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + BigDecimal total = userTaoLiJinDetailService.countMoneyByDay(preDay); + if (total == null) { + total = new BigDecimal(0); + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(total); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + + /** + * 鎻愮幇鐢宠鏁伴噺 + * @param preDay + * @throws Exception + */ + private void addExtractApplyNumber(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + Long total = extractAuditRecordService.countApplyNumberByDay(preDay); + if (total == null) { + total = 0L; + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(new BigDecimal(total)); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + + /** + * 鎻愮幇鐢宠閲戦 + * @param preDay + * @throws Exception + */ + private void addExtractApplyMoney(String preDay, DailyCountUserEnum typeEnum) throws Exception{ + BigDecimal total = extractAuditRecordService.countApplyMoneyByDay(preDay); + if (total == null) { + total = new BigDecimal(0); + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(total); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + /** + * 鎻愮幇瀹℃牳鏁伴噺 + * @param preDay + * @throws Exception + */ + private void addExtractAuditNum(String preDay, int state, DailyCountUserEnum typeEnum) throws Exception{ + Long total = extractAuditRecordService.countAuditNumberByDay(state, preDay); + if (total == null) { + total = 0L; + } + + DailyCountUser obj3 = new DailyCountUser(); + obj3.setTotal(new BigDecimal(total)); + obj3.setType(typeEnum); + obj3.setUpdateDate(new Date()); + obj3.setDay(TimeUtil.parse(preDay)); + obj3.setId(StringUtil.Md5(preDay + state + typeEnum.name())); + dailyCountUserDao.save(obj3); + } + + +} -- Gitblit v1.8.0