From 7a29e50e7e2eefe6c0e6e1deb53690147184e078 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 29 八月 2019 18:00:12 +0800
Subject: [PATCH] 队员首单 奖励上级金币

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java |   66 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 1 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java
index d89acc3..0a0e335 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralTaskRecordServiceImpl.java
@@ -14,6 +14,7 @@
 import org.yeshi.utils.DateUtil;
 
 import com.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper;
+import com.yeshi.fanli.dto.msg.MsgOtherRewardIntegralDTO;
 import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
 import com.yeshi.fanli.entity.integral.IntegralDetail;
 import com.yeshi.fanli.entity.integral.IntegralTask;
@@ -24,11 +25,14 @@
 import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
 import com.yeshi.fanli.exception.user.UserInfoExtraException;
 import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
 import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
 import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
 import com.yeshi.fanli.service.inter.integral.IntegralTaskService;
+import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
 import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
+import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
 
 @Service
@@ -48,6 +52,14 @@
 
 	@Resource
 	private IntegralTaskClassService integralTaskClassService;
+	
+	@Resource
+	private UserOtherMsgNotificationService userOtherMsgNotificationService;
+	
+	@Resource
+	private ConfigService configService;
+	
+	
 
 	@Override
 	public Integer getTotalGoldCoin(long uid, Long cid, Integer dateType) {
@@ -191,7 +203,7 @@
 		if (userInfoExtra == null) {
 			throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏");
 		}
-
+ 
 		Integer totalGoldCoin = 0;
 		for (Long id : idList) {
 			IntegralTaskRecord record = integralTaskRecordMapper.selectByPrimaryKey(id);
@@ -351,4 +363,56 @@
 	public List<IntegralTaskRecord> listByUidAndTaskId(Long uid, Long taskId, int page, int count) {
 		return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
 	}
+	
+	/**
+	 * 琚個璇蜂汉涓嬩簡棣栧崟锛堢涓�绗旇繑鍒╄鍗曪級 鐩存帴缁欓個璇蜂汉涓�绗旈噾甯�
+	 * @param uid
+	 */
+	@Override
+	public void firstOrderRewardInviter(Long uid, String beizu) {
+		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+		if (userInfoExtra == null) 
+			return;
+		
+		String reward = configService.get("first_order_reward_boss");
+		if (StringUtil.isNullOrEmpty(reward)) 
+			return;
+		
+		Integer goldCoin = userInfoExtra.getGoldCoin();
+		if (goldCoin == null)
+			goldCoin = 0;
+		
+		int addGoldCoin = Integer.parseInt(reward);
+		goldCoin = goldCoin + addGoldCoin;
+		
+		try {
+			// 澧炲姞閲戝竵
+			UserInfoExtra extra = new UserInfoExtra();
+			extra.setId(userInfoExtra.getId());
+			extra.setGoldCoin(goldCoin);
+			userInfoExtraService.saveUserInfoExtra(extra);
+		} catch (UserInfoExtraException e) {
+			e.printStackTrace();
+			return;
+		}
+
+		// 閲戝竵璇︽儏
+		IntegralDetail detail = new IntegralDetail();
+		detail.setTitle("闃熷憳棣栫瑪濂栧姳");
+		detail.setUid(uid);
+		detail.setMoney(addGoldCoin);
+		detail.setRemark(beizu);
+		detail.setCreateTime(new Date());
+		integralDetailService.insertSelective(detail);
+		
+		// 娑堟伅
+		MsgOtherRewardIntegralDTO msgOther = new MsgOtherRewardIntegralDTO();
+		msgOther.setTitle("閲戝竵濂栧姳");
+		msgOther.setSource("涓�绾ч槦鍛橀绗斾笅鍗曪紝绯荤粺濂栧姳閭�璇蜂汉閲戝竵");
+		msgOther.setNum(addGoldCoin + "閲戝竵");
+		msgOther.setTotal(goldCoin + "閲戝竵");
+		msgOther.setExplain("浠呬竴绾ч槦鍛橀绗斾笅鍗曞鍔憋紙宸插埌璐︼級");
+		userOtherMsgNotificationService.firstOrderRewardMsg(uid, "", msgOther);
+	}
+	
 }

--
Gitblit v1.8.0