|
@@ -26,7 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.Duration;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
@@ -168,30 +170,6 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public void addPatientIntegral(Long userId,Long patientId) {
|
|
|
- FsUser user = fsUserMapper.selectFsUserIsNew(userId);
|
|
|
- if (user!=null){
|
|
|
- FsUserIntegralLogs integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsAddPatient(userId);
|
|
|
- if (integralLogs==null){
|
|
|
- FsUser userMap=new FsUser();
|
|
|
- userMap.setUserId(user.getUserId());
|
|
|
- userMap.setIntegral(user.getIntegral()+1000L);
|
|
|
- fsUserMapper.updateFsUser(userMap);
|
|
|
- integralLogs = new FsUserIntegralLogs();
|
|
|
- integralLogs.setIntegral(1000L);
|
|
|
- integralLogs.setUserId(userId);
|
|
|
- integralLogs.setBalance(userMap.getIntegral());
|
|
|
- integralLogs.setLogType(11);
|
|
|
- integralLogs.setBusinessId(patientId.toString());
|
|
|
- integralLogs.setCreateTime(new Date());
|
|
|
- fsUserIntegralLogsMapper.insertFsUserIntegralLogs(integralLogs);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void addUserAddressIntegral(Long userId, Long addressId) {
|
|
@@ -269,16 +247,21 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
|
|
|
}
|
|
|
Integer integralNum = null;
|
|
|
FsUserIntegralLogTypeEnum logsType = null;
|
|
|
+ List<FsUserIntegralLogs> integralLogs;
|
|
|
switch (param.getLogType()){
|
|
|
// case 1: //签到
|
|
|
// integralNum = config.getIntegralInvite();
|
|
|
// logsType = FsUserIntegralLogTypeEnum.TYPE_1;
|
|
|
// break;
|
|
|
-// case 2: //消费获得积分
|
|
|
-// integralNum = config.getIntegralInvite();
|
|
|
-// logsType = FsUserIntegralLogTypeEnum.TYPE_2;
|
|
|
-// break;
|
|
|
+ case 2: //消费获得积分
|
|
|
+ integralNum = param.getAmount().multiply(BigDecimal.valueOf(config.getIntegralRatio())).intValue();
|
|
|
+ logsType = FsUserIntegralLogTypeEnum.TYPE_2;
|
|
|
+ break;
|
|
|
case 3: //分享获得积分
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), LocalDate.now());
|
|
|
+ if (integralLogs.size() >= 5){
|
|
|
+ return R.error("今日看课积分已达上限");
|
|
|
+ }
|
|
|
integralNum = config.getIntegralShare();
|
|
|
logsType = FsUserIntegralLogTypeEnum.TYPE_3;
|
|
|
break;
|
|
@@ -304,15 +287,29 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
|
|
|
// logsType = FsUserIntegralLogTypeEnum.TYPE_9;
|
|
|
// break;
|
|
|
case 10: //观看课程获取积分
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), LocalDate.now());
|
|
|
+ if (integralLogs.size() >= 3){
|
|
|
+ return R.error("今日看课积分已达上限");
|
|
|
+ }
|
|
|
integralNum = config.getIntegralCourse();
|
|
|
logsType = FsUserIntegralLogTypeEnum.TYPE_10;
|
|
|
break;
|
|
|
-// case 11: //新用户完善就诊人获得积分
|
|
|
-// logsType = FsUserIntegralLogTypeEnum.TYPE_11;
|
|
|
-// break;
|
|
|
-// case 12: //新用户填写收货地址获取积分
|
|
|
-// logsType = FsUserIntegralLogTypeEnum.TYPE_12;
|
|
|
-// break;
|
|
|
+ case 11: //新用户完善就诊人获得积分
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), null);
|
|
|
+ if (!integralLogs.isEmpty()){
|
|
|
+ return R.error("已领取过该积分");
|
|
|
+ }
|
|
|
+ integralNum = config.getIntegralAddPatient();
|
|
|
+ logsType = FsUserIntegralLogTypeEnum.TYPE_11;
|
|
|
+ break;
|
|
|
+ case 12: //新用户填写收货地址获取积分
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), null);
|
|
|
+ if (!integralLogs.isEmpty()){
|
|
|
+ return R.error("已领取过该积分");
|
|
|
+ }
|
|
|
+ integralNum = config.getIntegralAddUserAddress();
|
|
|
+ logsType = FsUserIntegralLogTypeEnum.TYPE_12;
|
|
|
+ break;
|
|
|
case 13: //浏览商品获得积分
|
|
|
integralNum = config.getIntegralProduct();
|
|
|
logsType = FsUserIntegralLogTypeEnum.TYPE_13;
|
|
@@ -333,9 +330,37 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
|
|
|
logsType = FsUserIntegralLogTypeEnum.TYPE_18;
|
|
|
break;
|
|
|
case 19: //填写邀请码获取积分
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), null);
|
|
|
+ if (!integralLogs.isEmpty()){
|
|
|
+ return R.error("已领取过该积分");
|
|
|
+ }
|
|
|
integralNum = config.getIntegralInvited();
|
|
|
logsType = FsUserIntegralLogTypeEnum.TYPE_19;
|
|
|
break;
|
|
|
+ case 20: //完成手机号绑定注册
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), null);
|
|
|
+ if (!integralLogs.isEmpty()){
|
|
|
+ return R.error("已领取过该积分");
|
|
|
+ }
|
|
|
+ integralNum = config.getIntegralRegister();
|
|
|
+ logsType = FsUserIntegralLogTypeEnum.TYPE_20;
|
|
|
+ break;
|
|
|
+ case 21: //完成专家咨询
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), null);
|
|
|
+ if (!integralLogs.isEmpty()){
|
|
|
+ return R.error("已领取过该积分");
|
|
|
+ }
|
|
|
+ integralNum = config.getIntegralFinishConsultation();
|
|
|
+ logsType = FsUserIntegralLogTypeEnum.TYPE_21;
|
|
|
+ break;
|
|
|
+ case 22: //完成首次积分商城下单
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(param.getUserId(),param.getLogType(), null);
|
|
|
+ if (!integralLogs.isEmpty()){
|
|
|
+ return R.error("已领取过该积分");
|
|
|
+ }
|
|
|
+ integralNum = config.getIntegralFirstOrderPoint();
|
|
|
+ logsType = FsUserIntegralLogTypeEnum.TYPE_22;
|
|
|
+ break;
|
|
|
default:
|
|
|
return R.error("积分类型错误,联系管理员");
|
|
|
}
|
|
@@ -445,6 +470,8 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
|
|
|
int taskFour = 0;
|
|
|
int taskFive = 0;
|
|
|
int isNewUser = 0;
|
|
|
+ int isFinishConsultation = 0;
|
|
|
+ int isFinishFirstOrderPoint = 0;
|
|
|
// long expireDays = 0;
|
|
|
Date createTime = null;
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserIsNew(userId);
|
|
@@ -479,12 +506,27 @@ public class FsUserIntegralLogsServiceImpl implements IFsUserIntegralLogsService
|
|
|
if (logs2!=null){
|
|
|
taskFive = 1;
|
|
|
}
|
|
|
+
|
|
|
+ // 完成专家咨询
|
|
|
+ List<FsUserIntegralLogs> integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(userId, FsUserIntegralLogTypeEnum.TYPE_21.getValue(), null);
|
|
|
+ if (!integralLogs.isEmpty()) {
|
|
|
+ isFinishConsultation = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 完成首次积分商城下单
|
|
|
+ integralLogs = fsUserIntegralLogsMapper.selectFsUserIntegralLogsByUserIdAndLogType(userId, FsUserIntegralLogTypeEnum.TYPE_22.getValue(), null);
|
|
|
+ if (!integralLogs.isEmpty()) {
|
|
|
+ isFinishFirstOrderPoint = 1;
|
|
|
+ }
|
|
|
+
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("taskOne",taskOne);
|
|
|
map.put("taskTwo",taskTwo);
|
|
|
map.put("taskThree",taskThree);
|
|
|
map.put("taskFour",taskFour);
|
|
|
map.put("taskFive",taskFive);
|
|
|
+ map.put("isFinishConsultation", isFinishConsultation);
|
|
|
+ map.put("isFinishFirstOrderPoint", isFinishFirstOrderPoint);
|
|
|
return R.ok().put("data",map).put("isNewUser",isNewUser).put("createTime",createTime);
|
|
|
}
|
|
|
}
|