From 299e3b3ae10786a5b00124333a3e732009f83295 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期三, 21 八月 2019 14:39:35 +0800 Subject: [PATCH] Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java | 84 ++++++++++++++++++++++++++++++++--------- 1 files changed, 65 insertions(+), 19 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java index 1cca4d4..8d9442d 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java @@ -1,40 +1,86 @@ package com.yeshi.fanli.service.impl.integral; +import java.util.Date; + +import javax.annotation.Resource; + import org.springframework.stereotype.Service; +import com.yeshi.fanli.entity.integral.IntegralTask; +import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum; +import com.yeshi.fanli.entity.integral.IntegralTaskRecord; import com.yeshi.fanli.exception.integral.IntegralGetException; +import com.yeshi.fanli.exception.integral.IntegralTaskRecordException; import com.yeshi.fanli.service.inter.integral.IntegralGetService; +import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService; +import com.yeshi.fanli.service.inter.integral.IntegralTaskService; import net.sf.json.JSONObject; @Service public class IntegralGetServiceImpl implements IntegralGetService { + @Resource + private IntegralTaskService integralTaskService; + + @Resource + private IntegralTaskRecordService integralTaskRecordService; + @Override - public void addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException { - switch (event) { - case "recommendSearch": - break; - case "shareInvite": - break; - case "inShop": - break; - case "scanPush": - break; - case "scanGoods": - break; - case "scanHomeBanner": - break; - case "scanSpecial": - break; - case "scanTBCart": - break; + public IntegralTaskRecord addEventStatistic(Long uid, String event, JSONObject params) throws IntegralGetException { + Date nowDate = new Date(); + IntegralTask task = integralTaskService.getByCidAndUniqueKey(null, event); + if (task == null) + throw new IntegralGetException(1, "浜嬩欢绫诲瀷涓嶅瓨鍦�"); + if (task.getFrequency() == FrequencyEnum.everyday) { + int count = integralTaskRecordService.countGetCountByTaskIdAndDay(task.getId(), uid, nowDate); + if (count >= task.getUpperLimit()) + throw new IntegralGetException(2, "浜嬩欢瑙﹀彂杈惧埌涓婇檺"); + } else if (task.getFrequency() == FrequencyEnum.onlyOne) { + int count = integralTaskRecordService.countGetCountByTaskIdAndDay(task.getId(), uid, null); + if (count > 0) + throw new IntegralGetException(2, "浜嬩欢瑙﹀彂杈惧埌涓婇檺"); } + + int goldCoin = task.getGoldCoin(); + if (task.getDoubleNum() != null && task.getDoubleNum() > 0) + goldCoin = task.getDoubleNum() * goldCoin; + + IntegralTaskRecord record = new IntegralTaskRecord(); + record.setCid(task.getTaskClass().getId()); + record.setGoldCoin(goldCoin); + record.setState(IntegralTaskRecord.STATE_WAITING_RECIEVE); + record.setTaskId(task.getId()); + record.setUid(uid); + + try { + return integralTaskRecordService.addRecord(record); + } catch (IntegralTaskRecordException e) { + throw new IntegralGetException(3, "娣诲姞璁板綍澶辫触"); + } + + // switch (event) { + // case "recommendSearch": + // break; + // case "shareInvite": + // break; + // case "inShop": + // break; + // case "scanPush": + // break; + // case "scanGoods": + // break; + // case "scanHomeBanner": + // break; + // case "scanSpecial": + // break; + // case "scanTBCart": + // break; + // } } @Override public void addRecommendSearch(Long uid) throws IntegralGetException { - // TODO Auto-generated method stub } -- Gitblit v1.8.0