|
|
@@ -1,10 +1,120 @@
|
|
1
|
1
|
package com.shinsoft.sto.service.main.impl;
|
|
2
|
2
|
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
4
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
3
|
5
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
4
|
6
|
import com.shinsoft.sto.mapper.main.CustomerMapper;
|
|
5
|
7
|
import com.shinsoft.sto.model.main.Customer;
|
|
6
|
8
|
import com.shinsoft.sto.service.main.CustomerService;
|
|
|
9
|
+import com.shinsoft.tools.JSONTools;
|
|
|
10
|
+import com.shinsoft.tools.model.common.ResultJSON;
|
|
|
11
|
+import com.alibaba.fastjson.JSON;
|
|
|
12
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
13
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
14
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
15
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
16
|
+import org.springframework.stereotype.Service;
|
|
|
17
|
+import org.springframework.util.ObjectUtils;
|
|
7
|
18
|
|
|
|
19
|
+import java.util.Date;
|
|
|
20
|
+import java.util.List;
|
|
|
21
|
+import java.util.Map;
|
|
|
22
|
+
|
|
|
23
|
+/**
|
|
|
24
|
+ * <p>
|
|
|
25
|
+ * 仓库客户 服务实现类
|
|
|
26
|
+ * </p>
|
|
|
27
|
+ *
|
|
|
28
|
+ * @author system
|
|
|
29
|
+ * @since 2024-10-15
|
|
|
30
|
+ */
|
|
|
31
|
+@Service
|
|
8
|
32
|
public class CustomerServiceImp extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
|
|
9
|
33
|
|
|
|
34
|
+ ResultJSON resultJSON;
|
|
|
35
|
+
|
|
|
36
|
+ @Autowired
|
|
|
37
|
+ CustomerMapper customerMapper;
|
|
|
38
|
+
|
|
|
39
|
+ @Override
|
|
|
40
|
+ public ResultJSON query(int page, int rows, String params, Map<String, Object> map) {
|
|
|
41
|
+ Page<Customer> customerPage = new Page<>(page, rows);
|
|
|
42
|
+ QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
|
|
|
43
|
+ queryWrapper.eq("cancel_flag", "0");
|
|
|
44
|
+ queryWrapper.orderByDesc("add_time");
|
|
|
45
|
+
|
|
|
46
|
+ // 解析查询参数
|
|
|
47
|
+ if (!ObjectUtils.isEmpty(params)) {
|
|
|
48
|
+ JSONObject jsonObject = JSON.parseObject(params);
|
|
|
49
|
+ if (!ObjectUtils.isEmpty(jsonObject.get("customerNm"))) {
|
|
|
50
|
+ queryWrapper.like("customer_nm", jsonObject.getString("customerNm"));
|
|
|
51
|
+ }
|
|
|
52
|
+ if (!ObjectUtils.isEmpty(jsonObject.get("customerShortNm"))) {
|
|
|
53
|
+ queryWrapper.like("customer_short_nm", jsonObject.getString("customerShortNm"));
|
|
|
54
|
+ }
|
|
|
55
|
+ if (!ObjectUtils.isEmpty(jsonObject.get("contactPerson"))) {
|
|
|
56
|
+ queryWrapper.like("contact_person", jsonObject.getString("contactPerson"));
|
|
|
57
|
+ }
|
|
|
58
|
+ }
|
|
|
59
|
+
|
|
|
60
|
+ Page<Customer> list = customerMapper.selectPage(customerPage, queryWrapper);
|
|
|
61
|
+ resultJSON = JSONTools.toResultJSON(list);
|
|
|
62
|
+ return resultJSON;
|
|
|
63
|
+ }
|
|
|
64
|
+
|
|
|
65
|
+ @Override
|
|
|
66
|
+ public ResultJSON queryByPK(String id) {
|
|
|
67
|
+ Customer customer = customerMapper.selectById(id);
|
|
|
68
|
+ resultJSON = JSONTools.toResultJSON(customer);
|
|
|
69
|
+ return resultJSON;
|
|
|
70
|
+ }
|
|
|
71
|
+
|
|
|
72
|
+ @Override
|
|
|
73
|
+ public ResultJSON save(String userId, String json) {
|
|
|
74
|
+ Date date = new Date();
|
|
|
75
|
+ Customer customer = JSON.parseObject(json, new TypeReference<Customer>() {
|
|
|
76
|
+ });
|
|
|
77
|
+ if (StringUtils.isEmpty(customer.getId())) {
|
|
|
78
|
+ customer.setCancelFlag("0");
|
|
|
79
|
+ customer.setAddId(userId);
|
|
|
80
|
+ customer.setAddTime(date.toString());
|
|
|
81
|
+ customerMapper.insert(customer);
|
|
|
82
|
+ } else {
|
|
|
83
|
+ customer.setModifyId(userId);
|
|
|
84
|
+ customer.setModifyTime(date.toString());
|
|
|
85
|
+ customerMapper.updateById(customer);
|
|
|
86
|
+ }
|
|
|
87
|
+
|
|
|
88
|
+ resultJSON = JSONTools.toResultJSON(customer);
|
|
|
89
|
+ return resultJSON;
|
|
|
90
|
+ }
|
|
|
91
|
+
|
|
|
92
|
+ @Override
|
|
|
93
|
+ public ResultJSON remove(String userId, String id) {
|
|
|
94
|
+ Date date = new Date();
|
|
|
95
|
+ Customer customer = customerMapper.selectById(id);
|
|
|
96
|
+ customer.setCancelFlag("1");
|
|
|
97
|
+ customer.setModifyId(userId);
|
|
|
98
|
+ customer.setModifyTime(date.toString());
|
|
|
99
|
+ customerMapper.updateById(customer);
|
|
|
100
|
+ resultJSON = JSONTools.toResultJSON("");
|
|
|
101
|
+ return resultJSON;
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
|
104
|
+ @Override
|
|
|
105
|
+ public ResultJSON removeBatch(String userId, String ids) {
|
|
|
106
|
+ Date date = new Date();
|
|
|
107
|
+ List<String> list = JSON.parseObject(ids, new TypeReference<List<String>>() {
|
|
|
108
|
+ });
|
|
|
109
|
+ Customer customer;
|
|
|
110
|
+ for (String id : list) {
|
|
|
111
|
+ customer = customerMapper.selectById(id);
|
|
|
112
|
+ customer.setCancelFlag("1");
|
|
|
113
|
+ customer.setModifyId(userId);
|
|
|
114
|
+ customer.setModifyTime(date.toString());
|
|
|
115
|
+ customerMapper.updateById(customer);
|
|
|
116
|
+ }
|
|
|
117
|
+ resultJSON = JSONTools.toResultJSON("");
|
|
|
118
|
+ return resultJSON;
|
|
|
119
|
+ }
|
|
10
|
120
|
}
|