| 
					
				 | 
			
			
				@@ -48,6 +48,7 @@ import com.fs.his.mapper.FsUserIntegralLogsMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.mapper.FsUserMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.param.WxSendRedPacketParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.service.IFsStorePaymentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.his.service.IFsUserIntegralLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.service.IFsUserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.service.IFsUserWxService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.utils.ConfigUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -253,6 +254,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private BalanceRollbackErrorMapper balanceRollbackErrorMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IFsUserIntegralLogsService iFsUserIntegralLogsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3208,5 +3212,73 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return fsUserCourseVideoMapper.getChooseCourseVideoListByMap(params); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public R sendAppReward(FsCourseSendRewardUParam param) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (user==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return R.error("会员被停用,无权限,请联系客服!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FsCourseWatchLog log = courseWatchLogMapper.getWatchCourseVideo(param.getUserId(), param.getVideoId(), param.getQwUserId(), param.getQwExternalId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (log == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return R.error("无记录"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (log.getRewardType() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return R.error("奖励已发放"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取配置信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String json = configService.selectConfigByKey("course.config"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 更新用户积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FsUser userMap=new FsUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userMap.setUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Integer appAnswerIntegral = config.getAppAnswerIntegral(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (appAnswerIntegral == null ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            appAnswerIntegral = config.getAnswerIntegral(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userMap.setIntegral(user.getIntegral()+(appAnswerIntegral==null?0:appAnswerIntegral)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fsUserMapper.updateFsUser(userMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CompletableFuture.runAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsUserIntegralLogs integralLogs = new FsUserIntegralLogs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            integralLogs.setIntegral(config.getAppAnswerIntegral().longValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            integralLogs.setUserId(user.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            integralLogs.setBalance(userMap.getIntegral()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            integralLogs.setLogType(17); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            integralLogs.setBusinessId(StringUtils.isNotEmpty(log.getLogId().toString()) ? log.getLogId().toString() : null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            integralLogs.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            integralLogs.setNickName(user.getNickName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            integralLogs.setPhone(user.getPhone()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //integralLogs.setId(integralLogsService.getFsUserIntegralLogsInsertId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        fsUserIntegralLogsMapper.insertFsUserIntegralLogs(integralLogs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            iFsUserIntegralLogsService.insertFsUserIntegralLogsMySql(integralLogs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            iFsUserIntegralLogsService.insertFsUserIntegralLogs(integralLogs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //asyncAddIntegralLogs.saveLogAsync(integralLogs); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 更新观看记录的奖励类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.setRewardType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            courseWatchLogMapper.updateFsCourseWatchLog(log); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //转换红包 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setCourseId(param.getCourseId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setOutBatchNo(integralLogs.getId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setCompanyId(param.getCompanyId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setUserId(param.getUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setVideoId(param.getVideoId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setCompanyUserId(param.getCompanyUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setAmount(BigDecimal.valueOf(config.getAppAnswerIntegral()).divide(BigDecimal.valueOf(1000))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setRemark("点播答题领取积分转"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return R.ok("奖励发放成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |