| | |
| | | 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 java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer getWatchVideoPrice(UserInfo user, Date date, int timeSeconds) throws GoldCornGetPriceException { |
| | | |
| | | //获取价格 |
| | | GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.watchVideo, date); |
| | | 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 = (int) (timeSeconds * getPrice.getCornNum() / 60.0f); |
| | | int goldCorn; |
| | | if (getPrice.getCountType() == GoldCornPriceCountType.time) { |
| | | goldCorn = (int) (eventCount * getPrice.getCornNum() / 60.0f); |
| | | |
| | | //加上团队增益比例 |
| | | if (teamInviteRelationService.getBossUid(user.getId()) != null) { |
| | | goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); |
| | | } 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 Integer getReadNovelPrice(UserInfo user, Date date, int timeSeconds) throws GoldCornGetPriceException { |
| | | |
| | | //获取价格 |
| | | GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.readNovel, date); |
| | | if (getPrice == null) { |
| | | throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "价格信息缺失"); |
| | | 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); |
| | | } |
| | | |
| | | int goldCorn = (int) (timeSeconds * getPrice.getCornNum() / 60.0f); |
| | | |
| | | //加上团队增益比例 |
| | | if (teamInviteRelationService.getBossUid(user.getId()) != null) { |
| | | goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); |
| | | } |
| | | |
| | | return goldCorn; |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public Integer getScanNewsPrice(UserInfo user, Date date, int num) throws GoldCornGetPriceException { |
| | | //获取价格 |
| | | GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.scanNews, date); |
| | | if (getPrice == null) { |
| | | throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "价格信息缺失"); |
| | | } |
| | | public GoldCornGetPrice getCountPrice(GoldCornGetType type, UserInfo user, SystemEnum system, Date date) { |
| | | |
| | | int goldCorn = num * getPrice.getCornNum(); |
| | | Map<GoldCornGetType, GoldCornGetPrice> map = getCountPrice(Arrays.asList(new GoldCornGetType[]{type}), user, system, date); |
| | | |
| | | //加上团队增益比例 |
| | | if (teamInviteRelationService.getBossUid(user.getId()) != null) { |
| | | goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); |
| | | } |
| | | |
| | | return goldCorn; |
| | | return map.get(type); |
| | | } |
| | | |
| | | |