Commit 46abc3bc authored by xiamw's avatar xiamw
parents de94d9f1 f2e9f3c7
......@@ -68,6 +68,7 @@ public interface CustomerContactsMapper extends BaseMapperX<CustomerContactsDO>
"c.id as customer_id, ",
"c.name as customer_name, ",
"c.name_en as customer_name_en, ",
"c.number as customer_number, ",
"c.default_pay as default_pay, ",
"c.no_consignee as no_consignee, ",
"cc.* , ",
......@@ -110,6 +111,7 @@ public interface CustomerContactsMapper extends BaseMapperX<CustomerContactsDO>
"c.id as customer_id, ",
"c.name as customer_name, ",
"c.name_en as customer_name_en, ",
"c.number as customer_number, ",
"c.default_pay as default_pay, ",
"c.no_consignee as no_consignee, ",
"cc.* , ",
......
......@@ -13,6 +13,9 @@ public class CustomerContactsDto {
@ApiModelProperty(value = "客户联系人ID")
private Long customerContactsId;
@ApiModelProperty(value = "客户编码")
private String customerNumber;
@ApiModelProperty(value = "客户名称", required = true)
@NotNull(message = "客户名称不能为空")
private String customerName;
......
......@@ -82,6 +82,7 @@ public class CustomerFollowupServiceImpl extends AbstractService<CustomerFollowu
String newFollowupNumber = CodeUtils.getOddFollowupNumbers(event.getNumber());
CustomerFollowupNumberBackVO customerFollowupNumberBackVO =
new CustomerFollowupNumberBackVO()
.setNumber(newFollowupNumber)
.setNumberId(event.getId())
.setNumberVersion(event.getVersion());
......
......@@ -429,4 +429,5 @@ public interface ErrorCodeConstants {
// 该订单已经是非海外仓订单
ErrorCode ORDER_NOT_IS_OVERSEAS_WAREHOUSE_ORDER = new ErrorCode(1004001170, "order.not.is.overseas.warehouse.order");
ErrorCode ORDER_APPROVAL_IS_NOT_EXISTS = new ErrorCode(1004001171, "order.approval.is.not.exists");
ErrorCode FEE_APPLICATION_NOT_IS_ZERO = new ErrorCode(1004001172, "fee.application.not.is.zero");
}
......@@ -40,7 +40,6 @@ public enum OrderApprovalTypeEnum {
DISCOUNT_APPLY_BATCH(31, "批量优惠申请", Arrays.asList(1, 2, 6, 11, 14, 23, 28, 32)), // 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/优惠申请(当前商品有在途申请)/批量管理折扣申请(当前商品有在途申请)/管理优惠(当前商品有在途申请)
ADMIN_DISCOUNT_BATCH(32, "批量管理折扣申请", Arrays.asList(1, 2, 6, 11, 14, 23, 28, 31)), // 拆单申请/合单申请/订单修改/退仓/撤销拆单审批/优惠申请(当前商品有在途申请)/批量优惠申请(当前商品有在途申请)/管理优惠(当前商品有在途申请)
//分拣
sorting(50, "分拣审批", Arrays.asList(6, 11, 13, 14, 22, 23, 28)), // 自编号全部申请互斥,跟原本一致,不修改, 自编号下订单除拆单申请/合单申请/调仓申请/订单修改/入仓申请/退仓申请外,其他申请不受限制,允许封柜反审批
......
package cn.iocoder.yudao.module.order.service.order.impl;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderApprovalTypeCheckEvent;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
......@@ -21,6 +22,7 @@ import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderFeeApplication.OrderFeeApplicationDO;
import cn.iocoder.yudao.module.order.dal.mysql.orderFeeApplication.OrderFeeApplicationMapper;
import cn.iocoder.yudao.module.order.enums.ApprovalResultStatusEnum;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum;
import cn.iocoder.yudao.module.order.enums.OrderApprovalTypeResultEnum;
import cn.iocoder.yudao.module.order.service.approval.OrderApprovalService;
import cn.iocoder.yudao.module.order.service.order.OrderBusinessService;
......@@ -38,19 +40,23 @@ import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableCreateReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.FEE_APPLICATION_NOT_EXISTS;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.ORDER_FEE_APPLICATION_EXIST;
import static cn.iocoder.yudao.module.order.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.ORDER_UPDATE;
import static cn.iocoder.yudao.module.order.enums.OrderApprovalTypeEnum.expense_apply;
/**
* 订单费用申请 Service 实现类
......@@ -90,6 +96,8 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
private CurrencyService currencyService;
@Resource
private OrderApprovalService orderApprovalService;
@Resource
private ApplicationContext applicationContext;
@Transactional
@Override
......@@ -117,8 +125,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
//创建审批流
OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, createReqVO.getOrderId());
String bpmProcessId = bpmCreateServiceFactory.createBmp(userId, feeApplication.getId(), WorkFlowEmus.ORDER_FREE_APPLY.getKey(), orderDO.getOrderNo(), createReqVO.getCopyUserId());
Integer auditType = OrderApprovalTypeResultEnum.expense_apply_processing.getType();
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, auditType, OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, OrderApprovalTypeResultEnum.expense_apply_processing.getType(), OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
feeApplication.setBpmProcessId(bpmProcessId);
feeApplicationMapper.updateById(feeApplication);
DictDataRespDTO dictDataFromCache = DictFrameworkUtils.getDictDataFromCache(DictTypeConstants.RECEIVABLE_FEE_TYPE, String.valueOf(createReqVO.getFeeType()));
......@@ -143,12 +150,21 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
@Override
@Transactional
public void createFeeBatchApplication(OrderFeeBatchApplicationCreateReqVO createReqVO) {
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapperX<OrderApprovalDO>()
.eq(OrderApprovalDO::getOrderId, createReqVO.getOrderId())
.eq(OrderApprovalDO::getType, 41)
.eq(OrderApprovalDO::getStatus, ApprovalResultStatusEnum.processing.getValue());
if (orderApprovalService.count(lambdaQueryWrapper) > 0) {
throw exception(ORDER_FEE_APPLICATION_EXIST);
// OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
// if (orderDO.getAuditType() != 0) {
// throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
// }
// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapperX<OrderApprovalDO>()
// .eq(OrderApprovalDO::getOrderId, createReqVO.getOrderId())
// .eq(OrderApprovalDO::getType, expense_apply.getValue())
// .eq(OrderApprovalDO::getStatus, ApprovalResultStatusEnum.processing.getValue());
// if (orderApprovalService.count(lambdaQueryWrapper) > 0) {
// throw exception(ORDER_FEE_APPLICATION_EXIST);
// }
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(createReqVO.getOrderId(), null, expense_apply.getValue(), null, false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_IS_APPROVAL_IN_PROCESS);
}
// 批量插入费用
......@@ -166,7 +182,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
orderApprovalDO.setFollowUpSalesmanId(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
orderApprovalDO.setOrderId(createReqVO.getOrderId());
//批量费用申请
orderApprovalDO.setType(41);
orderApprovalDO.setType(expense_apply.getValue());
orderApprovalDO.setStatus(ApprovalResultStatusEnum.processing.getValue());
Long bpmProcessId = orderApprovalService.applyAndCreate(orderApprovalDO, WorkFlowEmus.ORDER_BATCH_FREE_APPLY, createReqVO.getCopyUserId());
......@@ -174,8 +190,7 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
//创建审批流
OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, createReqVO.getOrderId());
Integer auditType = OrderApprovalTypeResultEnum.expense_apply_processing.getType();
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, auditType, OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, OrderApprovalTypeResultEnum.expense_apply_processing.getType(), OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
//更新费用列表对应的流程申请ID
for (OrderFeeApplicationDO feeApplication : batchFeeList) {
......@@ -187,13 +202,21 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
@Override
public void updateFeeApplication(OrderFeeApplicationUpdateReqVO updateReqVO) {
// 校验存在
this.validateFeeApplicationExists(updateReqVO.getId());
OrderDO orderDO = orderService.getById(updateReqVO.getOrderId());
OrderApprovalTypeCheckEvent approvalTypeCheckEvent = new OrderApprovalTypeCheckEvent(updateReqVO.getOrderId(), null, expense_apply.getValue(), null, false);
applicationContext.publishEvent(approvalTypeCheckEvent);
if (approvalTypeCheckEvent.getResult()) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
}
OrderFeeApplicationDO orderFeeApplicationDOOld = feeApplicationMapper.selectById(updateReqVO.getId());
// 校验存在
if (orderFeeApplicationDOOld == null) {
throw exception(FEE_APPLICATION_NOT_EXISTS);
}
// 更新
OrderFeeApplicationDO updateObj = OrderFeeApplicationConvert.INSTANCE.convert(updateReqVO);
Long userId = SecurityFrameworkUtils.getLoginUserId();
OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, updateReqVO.getOrderId());
String bpmProcessId = bpmCreateServiceFactory.createBmp(userId, updateObj.getId(), WorkFlowEmus.ORDER_FREE_APPLY.getKey(), orderDO.getOrderNo(), updateReqVO.getCopyUserId());
Integer auditType = OrderApprovalTypeResultEnum.expense_apply_processing.getType();
orderService.updateStatus(orderDO.getOrderId(), null, null, null, null, null, auditType, OrderApprovalTypeResultEnum.expense_apply_processing.getDesc());
......@@ -224,10 +247,44 @@ public class OrderFeeApplicationServiceImpl extends AbstractService<OrderFeeAppl
@Override
public void deleteFeeApplication(Long id) {
OrderFeeApplicationDO orderFeeApplicationDO = feeApplicationMapper.selectById(id);
// 校验存在
this.validateFeeApplicationExists(id);
// 删除
if (orderFeeApplicationDO == null) {
throw exception(FEE_APPLICATION_NOT_EXISTS);
}
// 当费用金额为0时,可以不经审批直接删除
// 判断金额是否为0
if (orderFeeApplicationDO.getApplicationFee().compareTo(BigDecimal.ZERO) != 0){
throw exception(FEE_APPLICATION_NOT_IS_ZERO);
}
// 删除可能的应收单
if (orderFeeApplicationDO.getReceivableId() != null &&
orderFeeApplicationDO.getReceivableId() > 0) {
long idTemp = (long) orderFeeApplicationDO.getReceivableId();
ReceivableDO rDo = receivableService.getReceivable(idTemp);
if(Objects.nonNull(rDo)){
receivableService.removeById(rDo.getId());
}
}
// 删除费用申请记录
feeApplicationMapper.deleteById(id);
CurrencyDO currency = currencyService.getCurrency(orderFeeApplicationDO.getApplicationFeeCurrency());
String currencyName = Objects.nonNull(currency) ? (I18nMessage.getLang() == 0 ? currency.getTitleZh() : currency.getTitleEn()) : (I18nMessage.getLang() == 0 ? "未知" : "NUKNOWN");
DictDataRespDTO dictDataFromCache = DictFrameworkUtils.getDictDataFromCache(DictTypeConstants.RECEIVABLE_FEE_TYPE, String.valueOf(orderFeeApplicationDO.getFeeType()));
List<ApplyInfoVO> list = new ArrayList<>();
ApplyInfoVO applyInfoVO = new ApplyInfoVO();
applyInfoVO.setName("申请费用名称");
applyInfoVO.setNewValue(I18nMessage.getLang() == 0 ? dictDataFromCache.getLabel() : dictDataFromCache.getLabelEn());
list.add(applyInfoVO);
applyInfoVO = new ApplyInfoVO();
applyInfoVO.setName("金额");
applyInfoVO.setNewValue(String.valueOf(orderFeeApplicationDO.getApplicationFee().doubleValue()));
list.add(applyInfoVO);
applyInfoVO = new ApplyInfoVO();
applyInfoVO.setName("币种");
applyInfoVO.setNewValue(currencyName);
list.add(applyInfoVO);
orderBusinessService.addOrderOperateLog(orderFeeApplicationDO.getOrderId(), "订单操作", "费用申请删除", list);
}
private void validateFeeApplicationExists(Long id) {
......
......@@ -92,10 +92,6 @@ public class OrderFeeApplicationController {
return error(ORDER_FEE_APPLICATION_REPEAT_COMMIT);
}
redisHelper.expire(redisKey, 1, TimeUnit.MINUTES);
OrderDO orderDO = orderService.getById(createReqVO.getOrderId());
if (orderDO.getAuditType() != 0) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
}
feeApplicationService.createFeeBatchApplication(createReqVO);
redisHelper.delete(redisKey);
return success(true);
......@@ -123,13 +119,15 @@ public class OrderFeeApplicationController {
@PutMapping("/update")
@ApiOperation("更新订单费用申请")
public CommonResult<Boolean> updateFeeApplication(@Valid @RequestBody OrderFeeApplicationUpdateReqVO updateReqVO) {
if (!Objects.isNull(updateReqVO)) {
OrderDO orderDO = orderService.getById(updateReqVO.getOrderId());
if (orderDO.getAuditType() != 0) {
throw exception(ORDER_HAS_PROCESSING_APPROVAL, orderDO.getOrderNo());
}
String redisKey = MessageFormat.format(ORDER_FEE_APPLICATION_KEY, updateReqVO.getOrderId().toString());
Long count = redisHelper.incrBy(redisKey, 1);
if (count > 1){
return error(ORDER_FEE_APPLICATION_REPEAT_COMMIT);
}
redisHelper.expire(redisKey, 1, TimeUnit.MINUTES);
feeApplicationService.updateFeeApplication(updateReqVO);
redisHelper.delete(redisKey);
return success(true);
}
......
......@@ -306,4 +306,5 @@ order.not.is.overseas.warehouse.order=
area.code.not.null=
currency.id.not.null=
order.approval.is.not.exists=
\ No newline at end of file
order.approval.is.not.exists=
fee.application.not.is.zero=
\ No newline at end of file
......@@ -1120,4 +1120,5 @@ order.not.is.overseas.warehouse.order=This order is already a non overseas wareh
area.code.not.null=The national mobile phone area code cannot be empty
currency.id.not.null=The country ID cannot be empty
order.approval.is.not.exists=Order approval type does not exist
\ No newline at end of file
order.approval.is.not.exists=Order approval type does not exist
fee.application.not.is.zero=The expense application amount is not 0, and cannot be directly deleted
\ No newline at end of file
......@@ -1120,4 +1120,5 @@ order.not.is.overseas.warehouse.order=\u8be5\u8ba2\u5355\u5df2\u7ecf\u662f\u975e
area.code.not.null=\u56fd\u5bb6\u624b\u673a\u533a\u53f7\u4e0d\u80fd\u4e3a\u7a7a
currency.id.not.null=\u56fd\u5bb6id\u4e0d\u80fd\u4e3a\u7a7a
order.approval.is.not.exists=\u8ba2\u5355\u5ba1\u6279\u7c7b\u578b\u4e0d\u5b58\u5728
\ No newline at end of file
order.approval.is.not.exists=\u8ba2\u5355\u5ba1\u6279\u7c7b\u578b\u4e0d\u5b58\u5728
fee.application.not.is.zero=\u8d39\u7528\u7533\u8bf7\u91d1\u989d\u4e0d\u4e3a0\uff0c\u4e0d\u80fd\u8fdb\u884c\u76f4\u63a5\u5220\u9664
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment