|
|
@@ -3,7 +3,6 @@ package com.sckw.manage.service;
|
|
|
import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
@@ -32,6 +31,8 @@ import com.sckw.manage.model.vo.req.FindCooperateByEntReqVo;
|
|
|
import com.sckw.manage.model.vo.req.FindEntCooperateReqVo;
|
|
|
import com.sckw.manage.model.vo.res.*;
|
|
|
import com.sckw.payment.api.model.constant.OrderEnum;
|
|
|
+import com.sckw.stream.enums.MessageEnum;
|
|
|
+import com.sckw.stream.model.UserInfo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
import com.sckw.transport.api.dubbo.TransportDubboService;
|
|
|
@@ -40,10 +41,10 @@ import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import javax.json.JsonObject;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -77,6 +78,8 @@ public class KwmCooperateManageService {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private PaymentDubboService paymentDubboService;
|
|
|
|
|
|
+ @Value(value = "${}")
|
|
|
+ private String cooperateManageUrl;
|
|
|
|
|
|
/**
|
|
|
* @param reqVo 分页入参
|
|
|
@@ -198,20 +201,80 @@ public class KwmCooperateManageService {
|
|
|
}
|
|
|
Long userId = LoginUserHolder.getUserId();
|
|
|
Date date = new Date();
|
|
|
+ //校验解除限制
|
|
|
+ checkLimit(kwmCooperates);
|
|
|
+ kwmCooperates.forEach(item -> {
|
|
|
+ //运营端可以操作任意状态,企业端只能操作合作中的数据
|
|
|
+ if (SystemTypeEnum.MANAGE.getCode().equals(LoginUserHolder.getSystemType())) {
|
|
|
+ if (!item.getStatus().equals(CooperateStatusEnum.OK.getCode()) && type.equals(CooperateStatusEnum.PASS.getCode())) {
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_012);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!item.getStatus().equals(CooperateStatusEnum.PASS.getCode()) && type.equals(CooperateStatusEnum.OK.getCode())) {
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_012);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setStatus(type);
|
|
|
+ item.setUpdateBy(userId);
|
|
|
+ item.setUpdateTime(date);
|
|
|
+ if (kwmCooperateMapper.updateById(item) <= 0) {
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>(Global.NUMERICAL_FOUR);
|
|
|
+ for (KwmCooperate kwmCooperate : kwmCooperates) {
|
|
|
+ Long targetEntId = kwmCooperate.getEntId().equals(LoginUserHolder.getEntId()) ? kwmCooperate.getInviteeEntId() : kwmCooperate.getInviterEntId();
|
|
|
+ Long entId = kwmCooperate.getEntId().equals(LoginUserHolder.getEntId()) ? kwmCooperate.getInviterEntId() : kwmCooperate.getInviteeEntId();
|
|
|
+ EntCacheResDto targetEntCacheResDto = remoteSystemService.queryEntCacheById(targetEntId);
|
|
|
+ EntCacheResDto targetEntTreeCacheResDto = remoteSystemService.queryEntTreeById(targetEntId);
|
|
|
+ EntCacheResDto ourEntCacheResDto = remoteSystemService.queryEntCacheById(entId);
|
|
|
+ EntCacheResDto ourEntTopCacheResDto = remoteSystemService.queryEntCacheById(kwmCooperate.getEntId());
|
|
|
+ if (type.equals(CooperateStatusEnum.PASS.getCode())) {
|
|
|
+ map.put("entName", targetEntCacheResDto.getFirmName());
|
|
|
+ map.put("createByName", LoginUserHolder.getUserName());
|
|
|
+ commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(ourEntTopCacheResDto.getContactsId()).setEntId(ourEntTopCacheResDto.getId())),
|
|
|
+ MessageEnum.COOPERATE_DISSOLVE,
|
|
|
+ map,
|
|
|
+ cooperateManageUrl);
|
|
|
+
|
|
|
+ map.put("entName", ourEntCacheResDto.getFirmName());
|
|
|
+ commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(targetEntTreeCacheResDto.getContactsId()).setEntId(targetEntTreeCacheResDto.getId())),
|
|
|
+ MessageEnum.COOPERATE_DISSOLVED,
|
|
|
+ map,
|
|
|
+ cooperateManageUrl);
|
|
|
+ } else {
|
|
|
+ map.put("entName", targetEntCacheResDto.getFirmName());
|
|
|
+ map.put("createByName", LoginUserHolder.getUserName());
|
|
|
+ commonBusinessService.sendSystemMessage(Collections.singletonList(new UserInfo().setUserId(ourEntTopCacheResDto.getContactsId()).setEntId(ourEntTopCacheResDto.getId())),
|
|
|
+ MessageEnum.COOPERATE_RESTORE,
|
|
|
+ map,
|
|
|
+ cooperateManageUrl);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param kwmCooperates 实体
|
|
|
+ * @desc: 解除的校验限制
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/9/7
|
|
|
+ */
|
|
|
+ private void checkLimit(List<KwmCooperate> kwmCooperates) {
|
|
|
//判断是否可以解除-销售订单
|
|
|
KwmCooperate kwmCooperate = kwmCooperates.get(0);
|
|
|
- Boolean order = tradeOrderInfoService.associateEnt(kwmCooperate.getInviteeEntId(), kwmCooperate.getInviterEntId());
|
|
|
- if (order) {
|
|
|
+ if (tradeOrderInfoService.associateEnt(kwmCooperate.getInviteeEntId(), kwmCooperate.getInviterEntId())) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_031);
|
|
|
}
|
|
|
-
|
|
|
//判断是否可以解除-托运和承运
|
|
|
HttpResult response = transportDubboService.checkLogisticsOrderIsFinishByEntId(kwmCooperate.getInviteeEntId(), kwmCooperate.getInviterEntId());
|
|
|
- log.info("getInviteeEntId-{}", kwmCooperate.getInviteeEntId());
|
|
|
- log.info("getInviterEntId-{}", kwmCooperate.getInviterEntId());
|
|
|
- log.info("aaaaa-{}", JSONObject.toJSONString(response));
|
|
|
- Integer receivedResult = response.getCode();
|
|
|
- if (!receivedResult.toString().equals(String.valueOf(HttpStatus.SUCCESS_CODE))) {
|
|
|
+ int receivedResult = response.getCode();
|
|
|
+ if (!Integer.toString(receivedResult).equals(String.valueOf(HttpStatus.SUCCESS_CODE))) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_032);
|
|
|
}
|
|
|
Map<OrderEnum, List<String>> ledgerMap = paymentDubboService.checkLedger(kwmCooperate.getInviteeEntId(), kwmCooperate.getInviterEntId());
|
|
|
@@ -228,26 +291,6 @@ public class KwmCooperateManageService {
|
|
|
if (!CollectionUtils.isEmpty(settlementMap.get(OrderEnum.TRADE))) {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_034);
|
|
|
}
|
|
|
- kwmCooperates.forEach(item -> {
|
|
|
- //运营端可以操作任意状态,企业端只能操作合作中的数据
|
|
|
- if (SystemTypeEnum.MANAGE.getCode().equals(LoginUserHolder.getSystemType())) {
|
|
|
- if (!item.getStatus().equals(CooperateStatusEnum.OK.getCode()) && type.equals(CooperateStatusEnum.PASS.getCode())) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_012);
|
|
|
- }
|
|
|
-
|
|
|
- if (!item.getStatus().equals(CooperateStatusEnum.PASS.getCode()) && type.equals(CooperateStatusEnum.OK.getCode())) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_012);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- item.setStatus(type);
|
|
|
- item.setUpdateBy(userId);
|
|
|
- item.setUpdateTime(date);
|
|
|
- if (kwmCooperateMapper.updateById(item) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -258,7 +301,7 @@ public class KwmCooperateManageService {
|
|
|
* @date: 2023/7/11
|
|
|
*/
|
|
|
private boolean checkUserPermission(int status) {
|
|
|
- return status != CooperateStatusEnum.OK.getCode() && !LoginUserHolder.getSystemType().equals(SystemTypeEnum.MANAGE.getCode());
|
|
|
+ return status != CooperateStatusEnum.OK.getCode() && !Objects.equals(LoginUserHolder.getSystemType(), SystemTypeEnum.MANAGE.getCode());
|
|
|
}
|
|
|
|
|
|
/**
|