From 84df5cfafe7304ad179fa6a8639efa02464baf1a Mon Sep 17 00:00:00 2001
From: zhujie <leon.zhu@cloudroam.com.cn>
Date: 星期二, 08 四月 2025 23:59:25 +0800
Subject: [PATCH] init

---
 src/main/java/com/mzl/flower/service/customer/CustomerService.java |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/mzl/flower/service/customer/CustomerService.java b/src/main/java/com/mzl/flower/service/customer/CustomerService.java
index 1933dc4..1331f6e 100644
--- a/src/main/java/com/mzl/flower/service/customer/CustomerService.java
+++ b/src/main/java/com/mzl/flower/service/customer/CustomerService.java
@@ -13,6 +13,7 @@
 import com.mzl.flower.dto.request.menber.UserGrowthRecordDTO;
 import com.mzl.flower.dto.response.customer.CustomerDTO;
 import com.mzl.flower.dto.response.partner.PartnerDTO;
+import com.mzl.flower.dto.response.supplier.SupplierDTO;
 import com.mzl.flower.entity.customer.Customer;
 import com.mzl.flower.entity.partner.Partner;
 import com.mzl.flower.enums.TrueOrFalseEnum;
@@ -25,9 +26,12 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 
 @Service
@@ -252,4 +256,29 @@
         return null;
     }
 
+    public CustomerDTO findCustomerByPhone(String phone) {
+        CustomerDTO customerByPhone = customerMapper.findCustomerByPhone(phone);
+        if (customerByPhone != null && customerByPhone.getMemberOvertime() != null) {
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            customerByPhone.setMemberOverDate(customerByPhone.getMemberOvertime().format(formatter));
+        }
+        customerByPhone.setContactTel(phone);
+        return customerByPhone;
+    }
+    public Customer getByUserId(String userId) {
+        List<Customer> customers = customerMapper.selectList(new LambdaQueryWrapper<Customer>().eq(Customer::getUserId, userId).eq(Customer::getDeleted, TrueOrFalseEnum.FALSE.isFlag()));
+        if(!CollectionUtils.isEmpty(customers)){
+            return customers.get(0);
+        }
+        return null;
+    }
+
+    public void updateMemberInfo(Customer customer) {
+        customerMapper.updateById(customer);
+    }
+
+    public void checkVipExpireTime() {
+        // 获取当天日期之前,且is_member=1的用户,设置为is_member=0并且将member_overtime设置为null
+        customerMapper.checkVipExpireTime();
+    }
 }

--
Gitblit v1.9.3