|
@@ -1,5 +1,8 @@
|
|
|
package com.gree.mall.manager.logic.workorder;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -8,6 +11,7 @@ import com.gree.mall.manager.bean.workorder.PgAppraiseApplyBean;
|
|
|
import com.gree.mall.manager.bean.workorder.PgAppraiseApplyVO;
|
|
|
import com.gree.mall.manager.bean.workorder.PgAppraiseCategoryVO;
|
|
|
import com.gree.mall.manager.commonmapper.CommonMapper;
|
|
|
+import com.gree.mall.manager.enums.workorder.AppraiseApplyStatusEnum;
|
|
|
import com.gree.mall.manager.enums.workorder.AppraiseConfigTypeEnum;
|
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
@@ -179,6 +183,7 @@ public class AppraiseRelaLogic {
|
|
|
@Transactional
|
|
|
public void applySubmit(PgAppraiseApplyBean bean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ boolean isAdd = StringUtils.isBlank(bean.getId());
|
|
|
if (StringUtils.isBlank(bean.getOrderBaseId())) {
|
|
|
throw new RemoteServiceException("工单编号不能为空");
|
|
|
}
|
|
@@ -210,27 +215,60 @@ public class AppraiseRelaLogic {
|
|
|
|
|
|
// 有驳回可重诉人忽略申诉配置
|
|
|
if (superCount == 0) {
|
|
|
+ Date overTime = Objects.nonNull(orderBase.getOverTime()) ? orderBase.getOverTime() : orderBase.getWebsitOverTime();
|
|
|
+ DateTime endTime;
|
|
|
// 1、完工时间超过配置时间的,不可再提交;
|
|
|
- if (applyCount == 0) {
|
|
|
- // 首次申诉
|
|
|
- final PgAppraiseConfig config = pgAppraiseConfigService.lambdaQuery()
|
|
|
- .eq(PgAppraiseConfig::getCompanyWechatId, orderBase.getCompanyWechatId())
|
|
|
- .eq(PgAppraiseConfig::getType, AppraiseConfigTypeEnum.FIRST_A.getKey())
|
|
|
- .one();
|
|
|
+ // 申诉配置
|
|
|
+ final PgAppraiseConfig config = pgAppraiseConfigService.lambdaQuery()
|
|
|
+ .eq(PgAppraiseConfig::getCompanyWechatId, orderBase.getCompanyWechatId())
|
|
|
+ .eq(PgAppraiseConfig::getType, applyCount == 0 ? AppraiseConfigTypeEnum.FIRST_A.getKey() : AppraiseConfigTypeEnum.SECOND_A.getKey())
|
|
|
+ .one();
|
|
|
+
|
|
|
+ final int val = Integer.parseInt(config.getVal());
|
|
|
+ endTime = DateUtil.offsetHour(overTime, val);
|
|
|
+
|
|
|
+ String str = applyCount == 0 ? "首次" : "二次";
|
|
|
+ if (DateUtil.date().after(endTime)) {
|
|
|
+ throw new RemoteServiceException("已超" + str + "申诉时间, 提交失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //2、该工单已有中差评申诉数据的,不可再提交;(已申诉、待审核状态的,均不可再创建申诉)
|
|
|
+ Integer waitCount = pgAppraiseApplyService.lambdaQuery()
|
|
|
+ .eq(PgAppraiseApply::getOrderBaseId, bean.getOrderBaseId())
|
|
|
+ .in(PgAppraiseApply::getStatus, AppraiseApplyStatusEnum.WAIT.getKey(), AppraiseApplyStatusEnum.WAIT_CENTER.getKey())
|
|
|
+ .ne(!isAdd, PgAppraiseApply::getId, bean.getId())
|
|
|
+ .count();
|
|
|
+ if (waitCount > 0) {
|
|
|
+ throw new RemoteServiceException("已有中差评申诉记录, 提交失败");
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ waitCount = pgAppraiseApplyService.lambdaQuery()
|
|
|
+ .eq(PgAppraiseApply::getOrderBaseId, bean.getOrderBaseId())
|
|
|
+ .eq(PgAppraiseApply::getStatus, AppraiseApplyStatusEnum.OK.getKey())
|
|
|
+ .ne(!isAdd, PgAppraiseApply::getId, bean.getId())
|
|
|
+ .count();
|
|
|
+ if (waitCount > 0) {
|
|
|
+ throw new RemoteServiceException("已有中差评申诉“审核通过”记录, 提交失败");
|
|
|
}
|
|
|
-// pgOrderBaseService.lambdaQuery()
|
|
|
-// .eq()
|
|
|
|
|
|
- //2、该工单已有中差评申诉数据的,不可再提交;(含待申诉、已申诉、待审核状态的,均不可再创建申诉)
|
|
|
- //
|
|
|
- //
|
|
|
-// pgAppraiseApplyService.lambdaQuery()
|
|
|
-// .eq(Pg)
|
|
|
-// .eq()
|
|
|
-// .count()
|
|
|
+ if (isAdd) {
|
|
|
+ bean.insert();
|
|
|
+ } else {
|
|
|
+ bean.updateById();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isAdd) {
|
|
|
+ // 非新增清空明细
|
|
|
+ pgAppraiseApplyItemService.lambdaUpdate()
|
|
|
+ .eq(PgAppraiseApplyItem::getPgAppraiseApplyId, bean.getId())
|
|
|
+ .remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(bean.getItems())) {
|
|
|
+ List<PgAppraiseApplyItem> itemList = bean.getItems().stream().peek(v -> v.setPgAppraiseApplyId(bean.getId())).collect(Collectors.toList());
|
|
|
+ pgAppraiseApplyItemService.saveBatch(itemList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void applyConfirm(PgAppraiseApplyBean bean) {
|