新增免费量表量测记录
This commit is contained in:
parent
128018c9f2
commit
4b747e0e86
|
@ -61,14 +61,24 @@ public class WxEvaluationController extends BaseController {
|
|||
return evaluationService.queryEvaluationRecord(status, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增量测记录
|
||||
*/
|
||||
@Log(title = "新增量测记录", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/record/create/{scaleId}")
|
||||
public R<Void> newRecord(@NotNull(message = "主键不能为空") @PathVariable Long scaleId) {
|
||||
return toAjax(evaluationService.newRecord(scaleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 量测开始记录
|
||||
*/
|
||||
@Log(title = "量测开始记录", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/record/{id}")
|
||||
public R<Void> addRecord(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return toAjax(evaluationService.newRecord(id));
|
||||
public R<Void> checkRecord(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return toAjax(evaluationService.checkRecord(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,5 +20,8 @@ public interface IEvaluationService {
|
|||
|
||||
Boolean newRecord(Long recordId);
|
||||
|
||||
Boolean checkRecord(Long recordId);
|
||||
|
||||
|
||||
Map<String,Object> submitAnswer(SubmitAnswerBo bo);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.dromara.common.core.utils.MapstructUtils;
|
|||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.scale.constant.*;
|
||||
import org.dromara.scale.domain.*;
|
||||
import org.dromara.scale.domain.bo.SubmitAnswerBo;
|
||||
|
@ -101,12 +102,31 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean newRecord(Long recordId) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userType = loginUser.getUserType();
|
||||
// if (!UserType.STUDENT.getName().equals(userType)) {
|
||||
// throw new ServiceException("只有学生账户才能测评");
|
||||
// }
|
||||
public Boolean newRecord(Long scaleId) {
|
||||
Long userId = LoginHelper.getUserId();
|
||||
SysScale sysScale = scaleMapper.selectById(scaleId);
|
||||
if (StatusEnum.DISABLED.getValue().equals(sysScale.getFreeFlag())) {
|
||||
throw new ServiceException("此量表为收费量表");
|
||||
}
|
||||
Long l = recordMapper.selectCount(new LambdaQueryWrapper<SysEvaluationRecord>()
|
||||
.eq(SysEvaluationRecord::getScaleId, scaleId)
|
||||
.eq(SysEvaluationRecord::getUserId, userId)
|
||||
.eq(SysEvaluationRecord::getStatus, 0));
|
||||
if (l > 0) {
|
||||
throw new ServiceException("此免费量表有未测评记录,请测评后再申请新的测评");
|
||||
}
|
||||
//初始量测记录
|
||||
SysEvaluationRecord record = new SysEvaluationRecord();
|
||||
record.setUserId(userId);
|
||||
record.setScaleId(scaleId);
|
||||
record.setStatus(0);
|
||||
record.setCreateBy(userId);
|
||||
record.setUpdateBy(userId);
|
||||
return recordMapper.insert(record) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkRecord(Long recordId) {
|
||||
SysEvaluationRecord evaluationRecord = recordMapper.selectById(recordId);
|
||||
if (evaluationRecord == null) {
|
||||
throw new ServiceException("未查询到需要测试的记录,请联系管理员");
|
||||
|
@ -119,7 +139,7 @@ public class EvaluationServiceImpl implements IEvaluationService {
|
|||
}
|
||||
SysEvaluationRecord update = new SysEvaluationRecord();
|
||||
update.setRecordId(recordId);
|
||||
update.setStatus(StatusEnum.DISABLED.getValue());
|
||||
//update.setStatus(StatusEnum.DISABLED.getValue());
|
||||
update.setCreateTime(new Date());
|
||||
return recordMapper.updateById(update) > 0;
|
||||
}
|
||||
|
|
|
@ -104,24 +104,24 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
|||
Long userId = LoginHelper.getUserId();
|
||||
SysScaleOrder add = MapstructUtils.convert(bo, SysScaleOrder.class);
|
||||
Long scaleId = add.getScaleId();
|
||||
SysScale sysScale = sysScaleMapper.selectById(scaleId);
|
||||
BigDecimal price = sysScale.getPrice();
|
||||
add.setActualPrice(price);
|
||||
add.setOrderPrice(price);
|
||||
add.setUseStatus(StatusEnum.DISABLED.getValue());
|
||||
add.setOrderStatus(StatusEnum.DISABLED.getValue());
|
||||
validEntityBeforeSave(add);
|
||||
baseMapper.insert(add);
|
||||
//初始量测记录
|
||||
SysEvaluationRecord record = new SysEvaluationRecord();
|
||||
record.setUserId(userId);
|
||||
//个人测评订单号就是批次号
|
||||
record.setBatchNo(add.getId());
|
||||
record.setScaleId(scaleId);
|
||||
record.setStatus(-1);
|
||||
record.setCreateBy(userId);
|
||||
record.setUpdateBy(userId);
|
||||
recordMapper.insert(record);
|
||||
//初始订单
|
||||
SysScale sysScale = sysScaleMapper.selectById(scaleId);
|
||||
BigDecimal price = sysScale.getPrice();
|
||||
add.setActualPrice(price);
|
||||
add.setOrderPrice(price);
|
||||
add.setRecordId(record.getRecordId());
|
||||
add.setUseStatus(StatusEnum.DISABLED.getValue());
|
||||
add.setOrderStatus(StatusEnum.DISABLED.getValue());
|
||||
validEntityBeforeSave(add);
|
||||
baseMapper.insert(add);
|
||||
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
||||
orderRequest.setBody("墨者科技-量表支付");
|
||||
orderRequest.setOutTradeNo(add.getId().toString());
|
||||
|
@ -151,8 +151,9 @@ public class SysScaleOrderServiceImpl implements ISysScaleOrderService {
|
|||
//初始量测记录
|
||||
SysEvaluationRecord record = new SysEvaluationRecord();
|
||||
record.setRecordId(recordId);
|
||||
//个人测评订单号就是批次号
|
||||
record.setStatus(0);
|
||||
//个人测评订单号就是批次号
|
||||
record.setBatchNo(id);
|
||||
record.setUpdateBy(userId);
|
||||
boolean recordFlag = recordMapper.updateById(record) > 0;
|
||||
//更新订单状态
|
||||
|
|
Loading…
Reference in New Issue