|
|
@@ -1,6 +1,7 @@
|
|
|
package com.fs.patient.service.impl;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
@@ -18,6 +19,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.core.config.WxMaConfiguration;
|
|
|
+import com.fs.course.domain.FsCourseTrafficLog;
|
|
|
+import com.fs.course.domain.FsVideoResource;
|
|
|
+import com.fs.course.mapper.FsCourseTrafficLogMapper;
|
|
|
+import com.fs.course.mapper.FsVideoResourceMapper;
|
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.mapper.FsProjectRedDetailMapper;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
@@ -28,12 +33,12 @@ import com.fs.his.service.IFsDoctorService;
|
|
|
import com.fs.his.service.IFsProjectService;
|
|
|
import com.fs.his.service.IFsStorePaymentService;
|
|
|
import com.fs.his.service.IFsUserWxService;
|
|
|
-import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.FsPatientBaseInfoListDVO;
|
|
|
import com.fs.patient.domain.FsProjectRedPacketRecord;
|
|
|
import com.fs.patient.mapper.FsProjectRedPacketRecordMapper;
|
|
|
import com.fs.patient.param.BindPatientParam;
|
|
|
import com.fs.patient.param.FsProjectSendRewardUParam;
|
|
|
+import com.fs.patient.param.FsProjectVideoFinishUParam;
|
|
|
import com.fs.patient.vo.PatientBaseInfoVO;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.system.oss.CloudStorageService;
|
|
|
@@ -43,6 +48,8 @@ import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -62,6 +69,8 @@ import org.springframework.util.ObjectUtils;
|
|
|
@Service
|
|
|
public class FsPatientBaseInfoServiceImpl extends ServiceImpl<FsPatientBaseInfoMapper, FsPatientBaseInfo> implements IFsPatientBaseInfoService {
|
|
|
|
|
|
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
@@ -97,6 +106,12 @@ public class FsPatientBaseInfoServiceImpl extends ServiceImpl<FsPatientBaseInfoM
|
|
|
|
|
|
@Autowired
|
|
|
private QwExternalContactMapper qwExternalContactMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsVideoResourceMapper fsVideoResourceMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCourseTrafficLogMapper fsCourseTrafficLogMapper;
|
|
|
/**
|
|
|
* 查询患者基本信息
|
|
|
*
|
|
|
@@ -329,6 +344,10 @@ public class FsPatientBaseInfoServiceImpl extends ServiceImpl<FsPatientBaseInfoM
|
|
|
FsProject fsProject = projectService.selectFsProjectById(projectId);
|
|
|
if (fsProject != null) {
|
|
|
patientBaseInfoVO.setProject(fsProject);
|
|
|
+ FsVideoResource resource = fsVideoResourceMapper.selectVideoByVideoUrl(fsProject.getVideoUrl());
|
|
|
+ if (resource != null) {
|
|
|
+ patientBaseInfoVO.setDuration(resource.getDuration());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//红包配置信息
|
|
|
@@ -500,6 +519,40 @@ public class FsPatientBaseInfoServiceImpl extends ServiceImpl<FsPatientBaseInfoM
|
|
|
return fsPatientBaseInfoMapper.updateFsPatientBaseInfo(map);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R getInternetTraffic(FsProjectVideoFinishUParam param) {
|
|
|
+ try {
|
|
|
+ if (param.getBufferRate()==null){
|
|
|
+ logger.error("【缓冲值空】参数: {}",param);
|
|
|
+ return R.error("缓冲值空");
|
|
|
+ }
|
|
|
+ FsCourseTrafficLog trafficLog = new FsCourseTrafficLog();
|
|
|
+ trafficLog.setCreateTime(new Date());
|
|
|
+ BeanUtils.copyProperties(param, trafficLog);
|
|
|
+ FsVideoResource resource = fsVideoResourceMapper.selectVideoByVideoUrl(param.getVideoUrl());
|
|
|
+ if (resource == null) {
|
|
|
+ return R.error("视频源不存在");
|
|
|
+ }
|
|
|
+ // 计算流量
|
|
|
+ BigDecimal result = param.getBufferRate().divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal longAsBigDecimal = BigDecimal.valueOf(resource.getFileSize());
|
|
|
+ long roundedResult = result.multiply(longAsBigDecimal).setScale(0, RoundingMode.HALF_UP).longValue();
|
|
|
+ trafficLog.setInternetTraffic( Math.round(roundedResult * 1.4));
|
|
|
+
|
|
|
+ // 处理 UUID 为空的情况
|
|
|
+ if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
|
|
|
+ // 插入或更新
|
|
|
+ fsCourseTrafficLogMapper.insertOrUpdateTrafficLog(trafficLog);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ // 打印参数param和异常信息
|
|
|
+ logger.error("【插入或更新流量失败】参数: {}, 错误信息:{}", param, e.getMessage(), e);
|
|
|
+ return R.error();
|
|
|
+ }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private R sendProjectRedPacket(FsProjectSendRewardUParam param,FsUser user,CompanyUser companyUser){
|
|
|
//默认0.1红包数据
|