From 0e9b6603d4ae9d11c1fbc90257ce816c5807b8ff Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 28 十月 2022 16:55:02 +0800 Subject: [PATCH] 批量添加结算消息 --- app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java | 142 ++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 127 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java b/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java index e7369e0..2478b0f 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java +++ b/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java @@ -3,15 +3,26 @@ import java.lang.Exception; import javax.annotation.Resource; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yeshi.makemoney.app.entity.SystemEnum; +import com.yeshi.makemoney.app.entity.config.SystemConfigKey; +import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType; +import com.yeshi.makemoney.app.entity.goldcorn.GoldCornPriceCountType; +import com.yeshi.makemoney.app.entity.user.UserInfo; +import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetPriceException; +import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; +import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; -import java.util.Date; +import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.util.*; import org.yeshi.utils.StringUtil; import org.yeshi.utils.TimeUtil; import org.yeshi.utils.bean.BeanUtil; - -import java.util.List; import com.yeshi.makemoney.app.dao.goldcorn.GoldCornGetPriceDao; import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetPrice; @@ -28,16 +39,18 @@ @Resource private GoldCornGetPriceDao goldCornGetPriceDao; + @Resource + private SystemConfigService systemConfigService; + + @Resource + private TeamInviteRelationService teamInviteRelationService; + @Override public List<GoldCornGetPrice> list(GoldCornGetPriceQuery goldCornGetPriceQuery, int page, int pageSize) { DaoQuery daoQuery = new DaoQuery(); daoQuery.type = goldCornGetPriceQuery.getType(); - if (!StringUtil.isNullOrEmpty(goldCornGetPriceQuery.getStartTime())) { - daoQuery.minValidateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetPriceQuery.getStartTime(), "yyyy-MM-dd")); - } - if (!StringUtil.isNullOrEmpty(goldCornGetPriceQuery.getEndTime())) { - daoQuery.maxValidateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetPriceQuery.getEndTime(), "yyyy-MM-dd") + 1000 * 60 * 60 * 24L); - } + daoQuery.minValidateTime = goldCornGetPriceQuery.toStartTime(); + daoQuery.maxValidateTime = goldCornGetPriceQuery.toEndTime(); daoQuery.start = (page - 1) * pageSize; @@ -49,12 +62,8 @@ public long count(GoldCornGetPriceQuery goldCornGetPriceQuery) { DaoQuery daoQuery = new DaoQuery(); daoQuery.type = goldCornGetPriceQuery.getType(); - if (!StringUtil.isNullOrEmpty(goldCornGetPriceQuery.getStartTime())) { - daoQuery.minValidateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetPriceQuery.getStartTime(), "yyyy-MM-dd")); - } - if (!StringUtil.isNullOrEmpty(goldCornGetPriceQuery.getEndTime())) { - daoQuery.maxValidateTime = new Date(TimeUtil.convertToTimeTemp(goldCornGetPriceQuery.getEndTime(), "yyyy-MM-dd") + 1000 * 60 * 60 * 24L); - } + daoQuery.minValidateTime = goldCornGetPriceQuery.toStartTime(); + daoQuery.maxValidateTime = goldCornGetPriceQuery.toEndTime(); return goldCornGetPriceDao.count(daoQuery); } @@ -101,5 +110,108 @@ } } + @Override + public GoldCornGetPrice getPrice(SystemEnum system, GoldCornGetType type, Date date) { + DaoQuery daoQuery = new DaoQuery(); + daoQuery.maxValidateTime = date; + daoQuery.system = system; + daoQuery.type = type; + daoQuery.sortList = Arrays.asList(new Sort.Order[]{Sort.Order.desc("validateTime")}); + daoQuery.count = 1; + + List<GoldCornGetPrice> list = goldCornGetPriceDao.list(daoQuery); + if (list != null && list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + public Integer getPriceCornNum(SystemEnum system, GoldCornGetType type, Date date, boolean hasBoss) { + GoldCornGetPrice price = getPrice(system, type, date); + if (price == null) { + return null; + } + return new BigDecimal(price.getCornNum()).multiply(new BigDecimal(1).add(price.getTeamGainRate())).intValue(); + } + + @Override + public Integer getSingInPrice(SystemEnum system, int continueDay) { + List<Integer> list = getSingInPriceList(system); + if (list == null) { + return null; + } + + if (continueDay >= list.size()) { + return list.get(list.size() - 1); + } + + if (continueDay <= 0) { + return list.get(0); + } + + return list.get(continueDay - 1); + } + + @Override + public List<Integer> getSingInPriceList(SystemEnum system) { + String value = systemConfigService.getValueCache(system, SystemConfigKey.signInGoldCorn); + if (StringUtil.isNullOrEmpty(value)) { + return null; + } + Type type = new TypeToken<List<Integer>>() { + }.getType(); + return new Gson().fromJson(value, type); + } + + @Override + public Integer getCountPrice(GoldCornGetType type, UserInfo user, SystemEnum system, Date date, long eventCount) throws GoldCornGetPriceException { + GoldCornGetPrice getPrice = getPrice(system, type, date); + if (getPrice == null) { + throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "浠锋牸淇℃伅缂哄け"); + } + + int goldCorn; + if (getPrice.getCountType() == GoldCornPriceCountType.time) { + goldCorn = (int) (eventCount * getPrice.getCornNum() / 60.0f); + + } else { + goldCorn = (int) (eventCount * getPrice.getCornNum()); + } + + //鍔犱笂鍥㈤槦澧炵泭姣斾緥 + if (user != null && teamInviteRelationService.getBossUid(user.getId()) != null) { + goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); + } + return goldCorn; + } + + @Override + public Map<GoldCornGetType, GoldCornGetPrice> getCountPrice(List<GoldCornGetType> typeList, UserInfo user, SystemEnum system, Date date) { + Map<GoldCornGetType, GoldCornGetPrice> map = new HashMap(); + for (GoldCornGetType type : typeList) { + GoldCornGetPrice getPrice = getPrice(system, type, date); + if (getPrice == null) { + continue; + } + int goldCorn = getPrice.getCornNum(); + //鍔犱笂鍥㈤槦澧炵泭姣斾緥 + if (user != null && teamInviteRelationService.getBossUid(user.getId()) != null) { + goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); + } + getPrice.setCornNum(goldCorn); + map.put(type, getPrice); + } + return map; + } + + @Override + public GoldCornGetPrice getCountPrice(GoldCornGetType type, UserInfo user, SystemEnum system, Date date) { + + Map<GoldCornGetType, GoldCornGetPrice> map = getCountPrice(Arrays.asList(new GoldCornGetType[]{type}), user, system, date); + + return map.get(type); + } + } \ No newline at end of file -- Gitblit v1.8.0