From 37931d04e87cbae60cf833890c2c8432b389fa1a Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期五, 01 三月 2024 08:56:51 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/src/main/java/com/example/erp/service/sd/CustomerService.java |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/north-glass-erp/src/main/java/com/example/erp/service/sd/CustomerService.java b/north-glass-erp/src/main/java/com/example/erp/service/sd/CustomerService.java
new file mode 100644
index 0000000..9c04b4b
--- /dev/null
+++ b/north-glass-erp/src/main/java/com/example/erp/service/sd/CustomerService.java
@@ -0,0 +1,101 @@
+package com.example.erp.service.sd;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.example.erp.entity.sd.*;
+import com.example.erp.entity.userInfo.SysError;
+import com.example.erp.mapper.mm.FinishedGoodsInventoryMapper;
+import com.example.erp.mapper.sd.*;
+import com.example.erp.service.userInfo.SysErrorService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.util.*;
+
+@Service
+@DS("sd")
+@Transactional(rollbackFor = Exception.class)
+public class CustomerService {
+    @Autowired
+    CustomerMapper customerMapper;
+    @Autowired
+    SysErrorService sysErrorService;
+
+
+    public Map<String, Object> getseletCustomer(Integer pageNum, Integer pageSize, Customer customer) {
+        Integer offset = (pageNum - 1) * pageSize;
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", customerMapper.getseletCustomer(offset, pageSize, customer));
+        map.put("total", customerMapper.getseletCustomerPageTotal(offset, pageSize, customer));
+        return map;
+    }
+
+
+    public Boolean insertCustomer(Map<String,Object> object) {
+        boolean saveState = true;
+        //璁剧疆鍥炴粴鐐�
+        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+        try {
+            Customer customer = JSONObject.parseObject(JSONObject.toJSONString(object.get("customer")), Customer.class);
+           if(customer!=null){
+               if (customer.getId()!=null && customer.getId()!=0){
+                   System.out.println(111);
+                   customerMapper.updateCustomer(customer);
+               }else{
+                   System.out.println(222);
+                   customerMapper.insertCustomer(customer);
+               }
+
+           }
+
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+            //灏嗗紓甯镐紶鍏ユ暟鎹簱
+            SysError sysError = new SysError();
+            sysError.setError(e.toString());
+            sysError.setFunc("saveOrder");
+            sysErrorService.insert(sysError);
+            saveState = false;
+
+        }
+        return saveState;
+
+    }
+
+    public Boolean deleteCustomer(Map<String,Object> object) {
+        boolean saveState = true;
+        //璁剧疆鍥炴粴鐐�
+        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
+        try {
+            Customer customer = JSONObject.parseObject(JSONObject.toJSONString(object.get("customer")), Customer.class);
+            if(customer!=null){
+                if (customer.getId()!=null){
+                    customerMapper.deleteCustomer(customer);
+                }
+
+            }
+
+
+
+        } catch (Exception e) {
+            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
+            //灏嗗紓甯镐紶鍏ユ暟鎹簱
+            SysError sysError = new SysError();
+            sysError.setError(e.toString());
+            sysError.setFunc("saveOrder");
+            sysErrorService.insert(sysError);
+            saveState = false;
+
+        }
+        return saveState;
+
+    }
+
+
+}

--
Gitblit v1.8.0