From 4fd3a2736011c69c8729f2b28902a5cd9d09fd2b Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期五, 21 七月 2023 09:19:40 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
src/main/java/com/zy/crm/manager/service/impl/OrderServiceImpl.java | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zy/crm/manager/service/impl/OrderServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/OrderServiceImpl.java
index 113123a..58bdc61 100644
--- a/src/main/java/com/zy/crm/manager/service/impl/OrderServiceImpl.java
+++ b/src/main/java/com/zy/crm/manager/service/impl/OrderServiceImpl.java
@@ -1,12 +1,61 @@
package com.zy.crm.manager.service.impl;
-import com.zy.crm.manager.mapper.OrderMapper;
-import com.zy.crm.manager.entity.Order;
-import com.zy.crm.manager.service.OrderService;
+import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.core.common.Cools;
+import com.zy.crm.manager.entity.Order;
+import com.zy.crm.manager.mapper.OrderMapper;
+import com.zy.crm.manager.service.OrderService;
import org.springframework.stereotype.Service;
@Service("orderService")
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
+ @Override
+ public Order selectByUuid(Long hostId, String uuid) {
+ return this.baseMapper.selectByUuid(hostId, uuid);
+ }
+
+ @Override
+ public Page<Order> getPage(Page<Order> page, Long hostId, String deptId, Long userId, String condition) {
+ return page.setRecords(baseMapper.listByPage(page, hostId, deptId, userId, condition));
+ }
+
+ @Override
+ public String getUuid(Long hostId) {
+ String uuid = null;
+ int times = 0;
+ while (Cools.isEmpty(uuid)) {
+ if (times > 100) { break; }
+ String nextUuid = getNextUuid(hostId);
+ if (selectByUuid(hostId, nextUuid) == null) {
+ uuid = nextUuid;
+ }
+ times ++;
+ }
+ return uuid;
+ }
+
+ private String getNextUuid(Long hostId) {
+ Order order = this.baseMapper.selectOrderByNewestUuid(hostId);
+ if (order == null) {
+ return "0001";
+ }
+ return zerofill(String.valueOf(Integer.parseInt(order.getUuid()) + 1), 4);
+ }
+
+ public static String zerofill(String msg, Integer count){
+ if (msg.length() == count){
+ return msg;
+ } else if (msg.length() > count){
+ return msg.substring(0, 16);
+ } else {
+ StringBuilder msgBuilder = new StringBuilder(msg);
+ for (int i = 0; i<count-msg.length(); i++){
+ msgBuilder.insert(0,"0");
+ }
+ return msgBuilder.toString();
+ }
+ }
+
}
--
Gitblit v1.9.1