张延森 3 年之前
父節點
當前提交
cd3098fc98
共有 40 個檔案被更改,包括 798 行新增184 行删除
  1. 9
    1
      src/main/java/com/yunzhi/nanyang/common/Constants.java
  2. 21
    5
      src/main/java/com/yunzhi/nanyang/controller/CommController.java
  3. 85
    21
      src/main/java/com/yunzhi/nanyang/controller/TaAddressController.java
  4. 24
    0
      src/main/java/com/yunzhi/nanyang/controller/TaBannerController.java
  5. 25
    29
      src/main/java/com/yunzhi/nanyang/controller/TaFeedbackController.java
  6. 68
    1
      src/main/java/com/yunzhi/nanyang/controller/TaMachineryController.java
  7. 46
    33
      src/main/java/com/yunzhi/nanyang/controller/TaOrderController.java
  8. 54
    5
      src/main/java/com/yunzhi/nanyang/controller/TaPersonController.java
  9. 6
    1
      src/main/java/com/yunzhi/nanyang/controller/TaRegionController.java
  10. 38
    54
      src/main/java/com/yunzhi/nanyang/controller/TaUserMachineryController.java
  11. 27
    1
      src/main/java/com/yunzhi/nanyang/controller/TdMachineryTypeController.java
  12. 18
    15
      src/main/java/com/yunzhi/nanyang/controller/WxMaController.java
  13. 3
    3
      src/main/java/com/yunzhi/nanyang/entity/TaAddress.java
  14. 9
    1
      src/main/java/com/yunzhi/nanyang/entity/TaFeedback.java
  15. 3
    0
      src/main/java/com/yunzhi/nanyang/entity/TaMachinery.java
  16. 13
    1
      src/main/java/com/yunzhi/nanyang/entity/TaOrder.java
  17. 4
    0
      src/main/java/com/yunzhi/nanyang/entity/TaUserMachinery.java
  18. 4
    0
      src/main/java/com/yunzhi/nanyang/mapper/SysUserMapper.java
  19. 6
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaExtendContentMapper.java
  20. 3
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaFeedbackMapper.java
  21. 18
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaMachineryMapper.java
  22. 4
    0
      src/main/java/com/yunzhi/nanyang/mapper/TaOrderMapper.java
  23. 5
    1
      src/main/java/com/yunzhi/nanyang/mapper/TaUserMachineryMapper.java
  24. 1
    0
      src/main/java/com/yunzhi/nanyang/service/ITaAddressService.java
  25. 2
    0
      src/main/java/com/yunzhi/nanyang/service/ITaFeedbackService.java
  26. 10
    1
      src/main/java/com/yunzhi/nanyang/service/ITaMachineryService.java
  27. 1
    0
      src/main/java/com/yunzhi/nanyang/service/ITaOrderService.java
  28. 2
    0
      src/main/java/com/yunzhi/nanyang/service/ITaPersonService.java
  29. 5
    1
      src/main/java/com/yunzhi/nanyang/service/ITaUserMachineryService.java
  30. 19
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaAddressServiceImpl.java
  31. 5
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaFeedbackServiceImpl.java
  32. 46
    9
      src/main/java/com/yunzhi/nanyang/service/impl/TaMachineryServiceImpl.java
  33. 12
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaOrderServiceImpl.java
  34. 25
    0
      src/main/java/com/yunzhi/nanyang/service/impl/TaPersonServiceImpl.java
  35. 28
    1
      src/main/java/com/yunzhi/nanyang/service/impl/TaUserMachineryServiceImpl.java
  36. 59
    0
      src/main/java/com/yunzhi/nanyang/vo/MachineSummary.java
  37. 3
    0
      src/main/resources/application.yml
  38. 19
    0
      src/main/resources/mapper/TaFeedbackMapper.xml
  39. 55
    0
      src/main/resources/mapper/TaMachineryMapper.xml
  40. 13
    0
      src/main/resources/mapper/TaUserMachineryMapper.xml

+ 9
- 1
src/main/java/com/yunzhi/nanyang/common/Constants.java 查看文件

@@ -7,11 +7,19 @@ public class Constants {
7 7
     public final static int STATUS_READY = 0;
8 8
     public final static int STATUS_NORMAL = 1;
9 9
 
10
-    //
10
+    // 客户端类型
11 11
     public final static String CLIENT_WORKER = "worker";    // 农机手
12 12
     public final static String CLIENT_FARMER = "farmer";    // 农户
13 13
 
14 14
     // 资源类型
15 15
     public final static String TARGET_MACHINERY = "machinery";  // 农机
16 16
     public final static String TARGET_NEWS = "news";    // 资讯
17
+
18
+    // 支付状态
19
+    public final static int PAY_READY = 0;  // 待支付
20
+    public final static int PAY_PAID = 1;  // 已支付
21
+    public final static int PAY_REFUND = -1;  // 已退款
22
+
23
+    // 工作状态
24
+    public final static int WORK_READY = 0;   // 预备中
17 25
 }

+ 21
- 5
src/main/java/com/yunzhi/nanyang/controller/CommController.java 查看文件

@@ -1,15 +1,13 @@
1 1
 package com.yunzhi.nanyang.controller;
2 2
 
3
-import com.yunzhi.nanyang.common.BaseController;
4
-import com.yunzhi.nanyang.common.OSSUtils;
5
-import com.yunzhi.nanyang.common.ResponseBean;
6
-import com.yunzhi.nanyang.common.SMSCaptcha;
3
+import com.yunzhi.nanyang.common.*;
7 4
 import com.yunzhi.nanyang.config.AliyunConfig;
8 5
 import com.yunzhi.nanyang.service.ITaOrderService;
9 6
 import io.swagger.annotations.Api;
10 7
 import io.swagger.annotations.ApiOperation;
11 8
 import io.swagger.annotations.ApiParam;
12 9
 import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.beans.factory.annotation.Value;
13 11
 import org.springframework.web.bind.annotation.*;
14 12
 import org.springframework.web.multipart.MultipartFile;
15 13
 
@@ -32,10 +30,28 @@ public class CommController extends BaseController {
32 30
     @Autowired
33 31
     SMSCaptcha smsCaptcha;
34 32
 
35
-
36 33
     @Autowired
37 34
     ITaOrderService taOrderService;
38 35
 
36
+    @Autowired
37
+    HttpUtils httpUtils;
38
+
39
+    @Value("${yz.amap.url}")
40
+    String amapBaseUrl;
41
+
42
+    @Value("${yz.amap.key}")
43
+    String amapWebKey;
44
+
45
+    @ApiOperation(value = "高德地图接口", notes = "高德地图接口")
46
+    @PostMapping("/{clientId}/amap")
47
+    public ResponseBean amapWeb(@ApiParam("客户端") @PathVariable String client,
48
+                                @ApiParam("客户端ID") @PathVariable String clientId,
49
+                                @ApiParam("接口路径") @RequestParam String path,
50
+                                @ApiParam("接口参数") @RequestParam String params) throws Exception {
51
+        String url = amapBaseUrl + path + "?key=" + amapWebKey + "&" + params;
52
+        String resp = httpUtils.get(url);
53
+        return ResponseBean.success(resp);
54
+    }
39 55
 
40 56
     /**
41 57
      * 图片

+ 85
- 21
src/main/java/com/yunzhi/nanyang/controller/TaAddressController.java 查看文件

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.Constants;
7 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
+import com.yunzhi.nanyang.entity.TaPerson;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
@@ -46,17 +48,23 @@ public class TaAddressController extends BaseController {
46 48
      * @param pageSize
47 49
      * @return
48 50
      */
49
-    @RequestMapping(value="/taAddress",method= RequestMethod.GET)
51
+    @RequestMapping(value="/{client}/{clientId}/address",method= RequestMethod.GET)
50 52
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taAddressList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+    public ResponseBean taAddressList(@ApiParam("客户端") @PathVariable String client,
54
+                                      @ApiParam("客户端ID") @PathVariable String clientId,
55
+                                      @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56
+                                      @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53 57
 
54
-		    IPage<TaAddress> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaAddress> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
58
+        TaPerson taPerson = currentPerson();
57 59
 
58
-            IPage<TaAddress> result = iTaAddressService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
60
+        IPage<TaAddress> pg = new Page<>(pageNum, pageSize);
61
+        QueryWrapper<TaAddress> queryWrapper = new QueryWrapper<>();
62
+        queryWrapper.eq("owner_type", clientId);
63
+        queryWrapper.eq("owner_id", taPerson.getPersonId());
64
+        queryWrapper.orderByAsc("sort_no");
65
+
66
+        IPage<TaAddress> result = iTaAddressService.page(pg, queryWrapper);
67
+        return ResponseBean.success(result);
60 68
     }
61 69
 
62 70
     /**
@@ -64,13 +72,21 @@ public class TaAddressController extends BaseController {
64 72
      * @param taAddress 实体对象
65 73
      * @return
66 74
      */
67
-    @RequestMapping(value="/taAddress",method= RequestMethod.POST)
75
+    @RequestMapping(value="/{client}/{clientId}/address",method= RequestMethod.POST)
68 76
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taAddressAdd(@ApiParam("保存内容") @RequestBody TaAddress taAddress) throws Exception{
77
+    public ResponseBean taAddressAdd(@ApiParam("客户端") @PathVariable String client,
78
+                                     @ApiParam("客户端ID") @PathVariable String clientId,
79
+                                     @ApiParam("保存内容") @RequestBody TaAddress taAddress) throws Exception{
80
+        TaPerson taPerson = currentPerson();
81
+
82
+        taAddress.setAddressId(null);
83
+        taAddress.setOwnerId(taPerson.getPersonId());
84
+        taAddress.setOwnerType(clientId);
85
+        taAddress.setStatus(Constants.STATUS_NORMAL);
70 86
 
71 87
         if (iTaAddressService.save(taAddress)){
72 88
             return ResponseBean.success(taAddress);
73
-        }else {
89
+        } else {
74 90
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75 91
         }
76 92
     }
@@ -79,9 +95,22 @@ public class TaAddressController extends BaseController {
79 95
      * 根据id删除对象
80 96
      * @param id  实体ID
81 97
      */
82
-    @RequestMapping(value="/taAddress/{id}", method= RequestMethod.DELETE)
98
+    @RequestMapping(value="/{client}/{clientId}/address/{id}", method= RequestMethod.DELETE)
83 99
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taAddressDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
100
+    public ResponseBean taAddressDelete(@ApiParam("客户端") @PathVariable String client,
101
+                                        @ApiParam("客户端ID") @PathVariable String clientId,
102
+                                        @ApiParam("对象ID") @PathVariable String id) throws Exception{
103
+        TaPerson current = currentPerson();
104
+        TaAddress taAddress = iTaAddressService.getById(id);
105
+
106
+        if (null == taAddress) {
107
+            return ResponseBean.error("未找到地址信息");
108
+        }
109
+
110
+        if (!clientId.equals(taAddress.getOwnerType()) || !current.getPersonId().equals(taAddress.getOwnerId())) {
111
+            return ResponseBean.error("无操作权限");
112
+        }
113
+
85 114
         if(iTaAddressService.removeById(id)){
86 115
             return ResponseBean.success("success");
87 116
         }else {
@@ -95,25 +124,60 @@ public class TaAddressController extends BaseController {
95 124
      * @param taAddress 实体对象
96 125
      * @return
97 126
      */
98
-    @RequestMapping(value="/taAddress/{id}",method= RequestMethod.PUT)
127
+    @RequestMapping(value="/{client}/{clientId}/address/{id}",method= RequestMethod.PUT)
99 128
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taAddressUpdate(@ApiParam("对象ID") @PathVariable Integer id,
129
+    public ResponseBean taAddressUpdate(@ApiParam("客户端") @PathVariable String client,
130
+                                        @ApiParam("客户端ID") @PathVariable String clientId,
131
+                                        @ApiParam("对象ID") @PathVariable String id,
101 132
                                         @ApiParam("更新内容") @RequestBody TaAddress taAddress) throws Exception{
102 133
 
134
+        TaPerson current = currentPerson();
135
+        TaAddress origin = iTaAddressService.getById(id);
136
+
137
+        if (null == origin) {
138
+            return ResponseBean.error("未找到地址信息");
139
+        }
140
+
141
+        if (!clientId.equals(origin.getOwnerType()) || !current.getPersonId().equals(origin.getOwnerId())) {
142
+            return ResponseBean.error("无操作权限");
143
+        }
144
+
145
+        taAddress.setAddressId(id);
146
+
103 147
         if (iTaAddressService.updateById(taAddress)){
104
-            return ResponseBean.success(iTaAddressService.getById(id));
148
+            return ResponseBean.success(taAddress);
105 149
         }else {
106 150
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 151
         }
108 152
     }
109 153
 
110 154
     /**
111
-     * 根据id查询对象
155
+     * 设置默认地址
112 156
      * @param id  实体ID
157
+     * @param taAddress 实体对象
158
+     * @return
113 159
      */
114
-    @RequestMapping(value="/taAddress/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taAddressGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaAddressService.getById(id));
160
+    @RequestMapping(value="/{client}/{clientId}/address/{id}/default",method= RequestMethod.PUT)
161
+    @ApiOperation(value="设置默认地址", notes = "设置默认地址", httpMethod = "PUT", response = ResponseBean.class)
162
+    public ResponseBean updateDefault(@ApiParam("客户端") @PathVariable String client,
163
+                                      @ApiParam("客户端ID") @PathVariable String clientId,
164
+                                      @ApiParam("对象ID") @PathVariable String id) throws Exception{
165
+
166
+        TaPerson current = currentPerson();
167
+        TaAddress origin = iTaAddressService.getById(id);
168
+
169
+        if (null == origin) {
170
+            return ResponseBean.error("未找到地址信息");
171
+        }
172
+
173
+        if (!clientId.equals(origin.getOwnerType()) || !current.getPersonId().equals(origin.getOwnerId())) {
174
+            return ResponseBean.error("无操作权限");
175
+        }
176
+
177
+        if (iTaAddressService.updateDefault(origin)){
178
+            return ResponseBean.success("success");
179
+        }else {
180
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
181
+        }
118 182
     }
119 183
 }

+ 24
- 0
src/main/java/com/yunzhi/nanyang/controller/TaBannerController.java 查看文件

@@ -23,6 +23,8 @@ import com.yunzhi.nanyang.service.ITaBannerService;
23 23
 import com.yunzhi.nanyang.entity.TaBanner;
24 24
 import org.springframework.web.bind.annotation.RestController;
25 25
 
26
+import java.util.List;
27
+
26 28
 /**
27 29
  * <p>
28 30
     * 轮播图表 前端控制器
@@ -67,6 +69,28 @@ public class TaBannerController extends BaseController {
67 69
         return ResponseBean.success(result);
68 70
     }
69 71
 
72
+
73
+    /**
74
+     * 分页查询列表
75
+     * @param client
76
+     * @param clientId
77
+     * @return
78
+     */
79
+    @RequestMapping(value="/{client}/{clientId}/banner",method= RequestMethod.GET)
80
+    @ApiOperation(value="移动端列表", notes = "移动端列表", httpMethod = "GET", response = ResponseBean.class)
81
+    public ResponseBean getList(@ApiParam("客户端") @PathVariable String client,
82
+                                @ApiParam("客户端ID") @PathVariable String clientId,
83
+                                @ApiParam("类型") @RequestParam(value ="position", required = false) String position) throws Exception{
84
+
85
+        QueryWrapper<TaBanner> queryWrapper = new QueryWrapper<>();
86
+        queryWrapper.eq(!StringUtils.isEmpty(position), "position", position);
87
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
88
+        queryWrapper.orderByDesc("create_date");
89
+
90
+        List<TaBanner> result = iTaBannerService.list(queryWrapper);
91
+        return ResponseBean.success(result);
92
+    }
93
+
70 94
     /**
71 95
      * 保存对象
72 96
      * @param taBanner 实体对象

+ 25
- 29
src/main/java/com/yunzhi/nanyang/controller/TaFeedbackController.java 查看文件

@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.Constants;
7 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
+import com.yunzhi.nanyang.common.StringUtils;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
13
+import org.apache.shiro.authz.annotation.RequiresPermissions;
11 14
 import org.slf4j.Logger;
12 15
 import org.slf4j.LoggerFactory;
13 16
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,17 +49,16 @@ public class TaFeedbackController extends BaseController {
46 49
      * @param pageSize
47 50
      * @return
48 51
      */
49
-    @RequestMapping(value="/taFeedback",method= RequestMethod.GET)
52
+    @RequestMapping(value="/admin/feedback",method= RequestMethod.GET)
50 53
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51 54
     public ResponseBean taFeedbackList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55
+                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
56
+                                       @ApiParam("姓名") @RequestParam(value ="nickName", required = false) String nickName,
57
+                                       @ApiParam("手机号") @RequestParam(value ="phone", required = false) String phone) throws Exception{
53 58
 
54
-		    IPage<TaFeedback> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaFeedback> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
57
-
58
-            IPage<TaFeedback> result = iTaFeedbackService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
59
+        IPage<TaFeedback> pg = new Page<>(pageNum, pageSize);
60
+        IPage<TaFeedback> result = iTaFeedbackService.getPageBy(pg, nickName, phone);
61
+        return ResponseBean.success(result);
60 62
     }
61 63
 
62 64
     /**
@@ -64,9 +66,15 @@ public class TaFeedbackController extends BaseController {
64 66
      * @param taFeedback 实体对象
65 67
      * @return
66 68
      */
67
-    @RequestMapping(value="/taFeedback",method= RequestMethod.POST)
69
+    @RequestMapping(value="/{client}/{clientId}/feedback",method= RequestMethod.POST)
68 70
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taFeedbackAdd(@ApiParam("保存内容") @RequestBody TaFeedback taFeedback) throws Exception{
71
+    public ResponseBean taFeedbackAdd(@ApiParam("客户端") @PathVariable String client,
72
+                                      @ApiParam("客户端ID") @PathVariable String clientId,
73
+                                      @ApiParam("保存内容") @RequestBody TaFeedback taFeedback) throws Exception{
74
+
75
+        taFeedback.setFromPerson(currentPerson().getPersonId());
76
+        taFeedback.setFromPort(clientId);
77
+        taFeedback.setStatus(Constants.STATUS_READY);
70 78
 
71 79
         if (iTaFeedbackService.save(taFeedback)){
72 80
             return ResponseBean.success(taFeedback);
@@ -75,31 +83,17 @@ public class TaFeedbackController extends BaseController {
75 83
         }
76 84
     }
77 85
 
78
-    /**
79
-     * 根据id删除对象
80
-     * @param id  实体ID
81
-     */
82
-    @RequestMapping(value="/taFeedback/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taFeedbackDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaFeedbackService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
-        }
90
-    }
91
-
92 86
     /**
93 87
      * 修改对象
94 88
      * @param id  实体ID
95 89
      * @param taFeedback 实体对象
96 90
      * @return
97 91
      */
98
-    @RequestMapping(value="/taFeedback/{id}",method= RequestMethod.PUT)
92
+    @RequestMapping(value="/admin/feedback/{id}",method= RequestMethod.PUT)
99 93
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taFeedbackUpdate(@ApiParam("对象ID") @PathVariable Integer id,
94
+    @RequiresPermissions("feedback:update")
95
+    public ResponseBean taFeedbackUpdate(@ApiParam("对象ID") @PathVariable String id,
101 96
                                         @ApiParam("更新内容") @RequestBody TaFeedback taFeedback) throws Exception{
102
-
103 97
         if (iTaFeedbackService.updateById(taFeedback)){
104 98
             return ResponseBean.success(iTaFeedbackService.getById(id));
105 99
         }else {
@@ -111,9 +105,11 @@ public class TaFeedbackController extends BaseController {
111 105
      * 根据id查询对象
112 106
      * @param id  实体ID
113 107
      */
114
-    @RequestMapping(value="/taFeedback/{id}",method= RequestMethod.GET)
108
+    @RequestMapping(value="/{client}/{clientId}/feedback/{id}",method= RequestMethod.GET)
115 109
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taFeedbackGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
110
+    public ResponseBean taFeedbackGet(@ApiParam("客户端") @PathVariable String client,
111
+                                      @ApiParam("客户端ID") @PathVariable String clientId,
112
+                                      @ApiParam("对象ID") @PathVariable String id) throws Exception{
117 113
         return ResponseBean.success(iTaFeedbackService.getById(id));
118 114
     }
119 115
 }

+ 68
- 1
src/main/java/com/yunzhi/nanyang/controller/TaMachineryController.java 查看文件

@@ -8,6 +8,9 @@ import com.yunzhi.nanyang.common.Constants;
8 8
 import com.yunzhi.nanyang.common.ResponseBean;
9 9
 import com.yunzhi.nanyang.common.StringUtils;
10 10
 import com.yunzhi.nanyang.entity.SysUser;
11
+import com.yunzhi.nanyang.entity.TaPerson;
12
+import com.yunzhi.nanyang.service.ISysUserService;
13
+import com.yunzhi.nanyang.vo.MachineSummary;
11 14
 import io.swagger.annotations.Api;
12 15
 import io.swagger.annotations.ApiOperation;
13 16
 import io.swagger.annotations.ApiParam;
@@ -43,6 +46,9 @@ public class TaMachineryController extends BaseController {
43 46
     @Autowired
44 47
     public ITaMachineryService iTaMachineryService;
45 48
 
49
+    @Autowired
50
+    public ISysUserService iSysUserService;
51
+
46 52
 
47 53
     /**
48 54
      * 分页查询列表
@@ -55,15 +61,23 @@ public class TaMachineryController extends BaseController {
55 61
     public ResponseBean taMachineryList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56 62
                                         @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
57 63
                                         @ApiParam("名称") @RequestParam(value ="name", required = false) String name,
58
-                                        @ApiParam("类型") @RequestParam(value ="typeId", required = false) String typeId) throws Exception{
64
+                                        @ApiParam("类型") @RequestParam(value ="typeId", required = false) String typeId,
65
+                                        @ApiParam("机构ID") @RequestParam(value ="orgId", required = false) String orgId) throws Exception{
59 66
         SysUser sysUser = currentUser();
60 67
         boolean isAdmin = Constants.ADMIN_ID.equals(sysUser.getUserId());
61 68
 
69
+        if (!StringUtils.isEmpty(orgId)) {
70
+            if (!checkOrgAccess(orgId, sysUser.getUserId())) {
71
+                return ResponseBean.error("无权限操作");
72
+            }
73
+        }
74
+
62 75
         IPage<TaMachinery> pg = new Page<>(pageNum, pageSize);
63 76
         QueryWrapper<TaMachinery> queryWrapper = new QueryWrapper<>();
64 77
         queryWrapper.like(!StringUtils.isEmpty(name), "name", "%" + name + "%");
65 78
         queryWrapper.eq(!StringUtils.isEmpty(typeId), "type_id", typeId);
66 79
         queryWrapper.in(!isAdmin, "org_id", getAccessOrgs(sysUser.getUserId()));
80
+        queryWrapper.eq(!StringUtils.isEmpty(orgId), "org_id", orgId);
67 81
         queryWrapper.gt("status", Constants.STATUS_DELETE);
68 82
         queryWrapper.orderByDesc("create_date");
69 83
 
@@ -71,6 +85,44 @@ public class TaMachineryController extends BaseController {
71 85
         return ResponseBean.success(result);
72 86
     }
73 87
 
88
+
89
+    /**
90
+     * 分页查询列表
91
+     * @param pageNum
92
+     * @param pageSize
93
+     * @return
94
+     */
95
+    @RequestMapping(value="/{client}/{clientId}/machinery",method= RequestMethod.GET)
96
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
97
+    public ResponseBean getSummaryList(@ApiParam("客户端") @PathVariable String client,
98
+                                       @ApiParam("客户端ID") @PathVariable String clientId,
99
+                                       @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
100
+                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
101
+                                       @ApiParam("当前位置") @RequestParam(value ="location") String location,
102
+                                       @ApiParam("分类") @RequestParam(value = "typeId", required = false) String typeId) throws Exception{
103
+
104
+        String orgId = null;
105
+        TaPerson current = currentPerson();
106
+        if (Constants.CLIENT_WORKER.equals(clientId)) {
107
+            // 农机手查询机器列表, 只能查询自己绑定的机器
108
+            if (StringUtils.isEmpty(current.getUserId())) {
109
+                return ResponseBean.error("未找到绑定农机手信息");
110
+            }
111
+
112
+            SysUser user = iSysUserService.getExistBy("user_id", current.getUserId(), false, true);
113
+            if (user == null) {
114
+                return ResponseBean.error("未找到绑定农机手信息");
115
+            }
116
+            orgId = user.getOrgId();
117
+        }
118
+
119
+
120
+        IPage<MachineSummary> pg = new Page<>(pageNum, pageSize);
121
+
122
+        IPage<MachineSummary> result = iTaMachineryService.getSummaryList(pg, location, typeId, orgId);
123
+        return ResponseBean.success(result);
124
+    }
125
+
74 126
     /**
75 127
      * 保存对象
76 128
      * @param taMachinery 实体对象
@@ -165,4 +217,19 @@ public class TaMachineryController extends BaseController {
165 217
     public ResponseBean taMachineryGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
166 218
         return ResponseBean.success(iTaMachineryService.getDetail(id));
167 219
     }
220
+
221
+
222
+    /**
223
+     * 根据id查询对象
224
+     * @param id  实体ID
225
+     */
226
+    @RequestMapping(value="/{client}/{clientId}/machinery-summary/{id}",method= RequestMethod.GET)
227
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
228
+    public ResponseBean getSummaryDetail(@ApiParam("客户端") @PathVariable String client,
229
+                                         @ApiParam("客户端ID") @PathVariable String clientId,
230
+                                         @ApiParam("对象ID") @PathVariable String id,
231
+                                         @ApiParam("当前位置") @RequestParam(value ="location") String location,
232
+                                         @ApiParam("是否查询附件") @RequestParam(value ="attached", defaultValue = "false") Boolean attached) throws Exception{
233
+        return ResponseBean.success(iTaMachineryService.getSummaryDetail(id, location, attached));
234
+    }
168 235
 }

+ 46
- 33
src/main/java/com/yunzhi/nanyang/controller/TaOrderController.java 查看文件

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7
+import com.yunzhi.nanyang.common.Constants;
7 8
 import com.yunzhi.nanyang.common.ResponseBean;
9
+import com.yunzhi.nanyang.entity.TaPerson;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
@@ -46,17 +48,21 @@ public class TaOrderController extends BaseController {
46 48
      * @param pageSize
47 49
      * @return
48 50
      */
49
-    @RequestMapping(value="/taOrder",method= RequestMethod.GET)
51
+    @RequestMapping(value="/{client}/{clientId}/order",method= RequestMethod.GET)
50 52
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51 53
     public ResponseBean taOrderList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
54
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
55
+                                    @ApiParam("我的") @RequestParam(value = "mine", defaultValue = "false") Boolean isMine) throws Exception{
56
+        TaPerson taPerson = currentPerson();
53 57
 
54
-		    IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaOrder> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
58
+        IPage<TaOrder> pg = new Page<>(pageNum, pageSize);
59
+        QueryWrapper<TaOrder> queryWrapper = new QueryWrapper<>();
60
+        queryWrapper.eq(isMine, "person_id", taPerson.getPersonId());
61
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
62
+        queryWrapper.orderByDesc("create_date");
57 63
 
58
-            IPage<TaOrder> result = iTaOrderService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
64
+        IPage<TaOrder> result = iTaOrderService.page(pg, queryWrapper);
65
+        return ResponseBean.success(result);
60 66
     }
61 67
 
62 68
     /**
@@ -64,9 +70,18 @@ public class TaOrderController extends BaseController {
64 70
      * @param taOrder 实体对象
65 71
      * @return
66 72
      */
67
-    @RequestMapping(value="/taOrder",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taOrderAdd(@ApiParam("保存内容") @RequestBody TaOrder taOrder) throws Exception{
73
+    @RequestMapping(value="/{client}/{clientId}/order",method= RequestMethod.POST)
74
+    @ApiOperation(value="生成订单", notes = "生成订单", httpMethod = "POST", response = ResponseBean.class)
75
+    public ResponseBean taOrderAdd(@ApiParam("客户端") @PathVariable String client,
76
+                                   @ApiParam("客户端ID") @PathVariable String clientId,
77
+                                   @ApiParam("保存内容") @RequestBody TaOrder taOrder) throws Exception{
78
+        TaPerson taPerson = currentPerson();
79
+
80
+        String orderNo = iTaOrderService.getNextOrderNO();
81
+
82
+        taOrder.setOrderId(null);
83
+        taOrder.setOrderNo(orderNo);
84
+        taOrder.setPersonId(taPerson.getPersonId());
70 85
 
71 86
         if (iTaOrderService.save(taOrder)){
72 87
             return ResponseBean.success(taOrder);
@@ -79,31 +94,29 @@ public class TaOrderController extends BaseController {
79 94
      * 根据id删除对象
80 95
      * @param id  实体ID
81 96
      */
82
-    @RequestMapping(value="/taOrder/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taOrderDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaOrderService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
97
+    @RequestMapping(value="/{client}/{clientId}/order/{id}", method= RequestMethod.DELETE)
98
+    @ApiOperation(value="取消订单", notes = "取消订单", httpMethod = "DELETE", response = ResponseBean.class)
99
+    public ResponseBean taOrderDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
100
+
101
+        TaPerson taPerson = currentPerson();
102
+        //
103
+        TaOrder taOrder = iTaOrderService.getById(id);
104
+        if (null == taOrder || taOrder.getStatus() == Constants.STATUS_DELETE) {
105
+            return ResponseBean.error("未找到订单信息");
89 106
         }
90
-    }
91 107
 
92
-    /**
93
-     * 修改对象
94
-     * @param id  实体ID
95
-     * @param taOrder 实体对象
96
-     * @return
97
-     */
98
-    @RequestMapping(value="/taOrder/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taOrderUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaOrder taOrder) throws Exception{
108
+        if (!taOrder.getPersonId().equals(taPerson.getPersonId())) {
109
+            return ResponseBean.error("无权操作");
110
+        }
102 111
 
103
-        if (iTaOrderService.updateById(taOrder)){
104
-            return ResponseBean.success(iTaOrderService.getById(id));
112
+        if (taOrder.getPayStatus() == Constants.PAY_PAID) {
113
+            return ResponseBean.error("订单已支付");
114
+        }
115
+
116
+        if(iTaOrderService.removeLogicById(id)){
117
+            return ResponseBean.success("success");
105 118
         }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
119
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 120
         }
108 121
     }
109 122
 
@@ -111,9 +124,9 @@ public class TaOrderController extends BaseController {
111 124
      * 根据id查询对象
112 125
      * @param id  实体ID
113 126
      */
114
-    @RequestMapping(value="/taOrder/{id}",method= RequestMethod.GET)
127
+    @RequestMapping(value="/{client}/{clientId}/order/{id}",method= RequestMethod.GET)
115 128
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taOrderGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
129
+    public ResponseBean taOrderGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
117 130
         return ResponseBean.success(iTaOrderService.getById(id));
118 131
     }
119 132
 }

+ 54
- 5
src/main/java/com/yunzhi/nanyang/controller/TaPersonController.java 查看文件

@@ -100,18 +100,67 @@ public class TaPersonController extends BaseController {
100 100
 //        }
101 101
 //    }
102 102
 //
103
+
104
+    /**
105
+     * 更新人员信息
106
+     * @param client  客户端
107
+     * @param clientId  客户端ID
108
+     * @param id  实体ID
109
+     * @param taPerson 实体对象
110
+     * @return
111
+     */
112
+    @RequestMapping(value="/{client}/{clientId}/person/{id}",method= RequestMethod.PUT)
113
+    @ApiOperation(value="更新人员信息", notes = "更新人员信息", httpMethod = "PUT", response = ResponseBean.class)
114
+    public ResponseBean taPersonUpdate(@ApiParam("客户端") @PathVariable String client,
115
+                                       @ApiParam("客户端ID") @PathVariable String clientId,
116
+                                       @ApiParam("对象ID") @PathVariable String id,
117
+                                       @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
118
+
119
+        TaPerson current = currentPerson();
120
+        if (!id.equals(current.getPersonId())) {
121
+            return ResponseBean.error("待更新人员ID不正确");
122
+        }
123
+
124
+        if (StringUtils.isEmpty(taPerson.getPhone())) {
125
+            return ResponseBean.error("手机号码为空");
126
+        }
127
+
128
+        if (StringUtils.isEmpty(taPerson.getNickName())) {
129
+            return ResponseBean.error("姓名为空");
130
+        }
131
+
132
+//        boolean isOk = smsCaptcha.validate(phoneParam.getPhone(), phoneParam.getCaptcha());
133
+//        if (!isOk) {
134
+//            return ResponseBean.error("验证码不正确或者已过期");
135
+//        }
136
+
137
+        taPerson.setPersonId(id);
138
+
139
+        // 关联系统人员
140
+        SysUser sysUser = iSysUserService.getExistBy("phone", taPerson.getPhone(), false, true);
141
+        if (sysUser != null && StringUtils.isEmpty(taPerson.getUserId())) {
142
+            taPerson.setUserId(sysUser.getUserId());
143
+        }
144
+
145
+        if (iTaPersonService.updateById(taPerson)){
146
+            return ResponseBean.success(taPerson);
147
+        }else {
148
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
149
+        }
150
+    }
151
+
103 152
     /**
104 153
      * 修改对象
105
-     * @param appid  实体ID
154
+     * @param clientId  客户端ID
106 155
      * @param id  实体ID
107 156
      * @param phoneParam 实体对象
108 157
      * @return
109 158
      */
110
-    @RequestMapping(value="/wx/{appid}/person/{id}/phone",method= RequestMethod.PUT)
159
+    @RequestMapping(value="/wx/{clientId}/person/{id}/phone",method= RequestMethod.PUT)
111 160
     @ApiOperation(value="更新电话", notes = "更新电话", httpMethod = "PUT", response = ResponseBean.class)
112
-    public ResponseBean taPersonUpdate(@ApiParam("小程序ID") @PathVariable String appid,
113
-                                       @ApiParam("对象ID") @PathVariable String id,
114
-                                       @ApiParam("更新内容") @RequestBody PhoneParam phoneParam) throws Exception{
161
+    public ResponseBean updatePhone(@ApiParam("客户端ID") @PathVariable String clientId,
162
+                                    @ApiParam("对象ID") @PathVariable String id,
163
+                                    @ApiParam("更新内容") @RequestBody PhoneParam phoneParam) throws Exception{
115 164
 
116 165
         TaPerson taPerson = currentPerson();
117 166
         if (!id.equals(taPerson.getPersonId())) {

+ 6
- 1
src/main/java/com/yunzhi/nanyang/controller/TaRegionController.java 查看文件

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 5
 import com.yunzhi.nanyang.common.BaseController;
6 6
 import com.yunzhi.nanyang.common.ResponseBean;
7 7
 import com.yunzhi.nanyang.common.StringUtils;
8
+import com.yunzhi.nanyang.service.ITaMachineryService;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiOperation;
10 11
 import io.swagger.annotations.ApiParam;
@@ -40,6 +41,9 @@ public class TaRegionController extends BaseController {
40 41
     @Autowired
41 42
     public ITaRegionService iTaRegionService;
42 43
 
44
+    @Autowired
45
+    public ITaMachineryService iTaMachineryService;
46
+
43 47
 
44 48
     /**
45 49
      * 分页查询列表
@@ -127,7 +131,8 @@ public class TaRegionController extends BaseController {
127 131
         }
128 132
 
129 133
         if (iTaRegionService.updateById(taRegion)){
130
-            return ResponseBean.success(iTaRegionService.getById(id));
134
+            iTaMachineryService.updateRegionName(taRegion.getRegionId(), taRegion.getName());
135
+            return ResponseBean.success(taRegion);
131 136
         }else {
132 137
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
133 138
         }

+ 38
- 54
src/main/java/com/yunzhi/nanyang/controller/TaUserMachineryController.java 查看文件

@@ -5,9 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.nanyang.common.BaseController;
7 7
 import com.yunzhi.nanyang.common.ResponseBean;
8
+import com.yunzhi.nanyang.entity.SysUser;
9
+import com.yunzhi.nanyang.entity.TaMachinery;
10
+import com.yunzhi.nanyang.service.ISysUserService;
8 11
 import io.swagger.annotations.Api;
9 12
 import io.swagger.annotations.ApiOperation;
10 13
 import io.swagger.annotations.ApiParam;
14
+import org.apache.shiro.authz.annotation.RequiresPermissions;
11 15
 import org.slf4j.Logger;
12 16
 import org.slf4j.LoggerFactory;
13 17
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +24,8 @@ import com.yunzhi.nanyang.service.ITaUserMachineryService;
20 24
 import com.yunzhi.nanyang.entity.TaUserMachinery;
21 25
 import org.springframework.web.bind.annotation.RestController;
22 26
 
27
+import java.util.List;
28
+
23 29
 /**
24 30
  * <p>
25 31
     * 农机绑定 前端控制器
@@ -39,81 +45,59 @@ public class TaUserMachineryController extends BaseController {
39 45
     @Autowired
40 46
     public ITaUserMachineryService iTaUserMachineryService;
41 47
 
48
+    @Autowired
49
+    public ISysUserService iSysUserService;
50
+
42 51
 
43 52
     /**
44 53
      * 分页查询列表
45
-     * @param pageNum
46
-     * @param pageSize
54
+     * @param userId
47 55
      * @return
48 56
      */
49
-    @RequestMapping(value="/taUserMachinery",method= RequestMethod.GET)
57
+    @RequestMapping(value="/admin/user-machinery",method= RequestMethod.GET)
50 58
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taUserMachineryList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
59
+    public ResponseBean taUserMachineryList(@ApiParam("用户ID") @RequestParam(value ="userId") String userId) throws Exception{
53 60
 
54
-		    IPage<TaUserMachinery> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaUserMachinery> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
61
+        SysUser sysUser = iSysUserService.getExistBy("user_id", userId, false, true);
62
+        if (null == sysUser) {
63
+            return ResponseBean.error("未找到指定人员");
64
+        }
57 65
 
58
-            IPage<TaUserMachinery> result = iTaUserMachineryService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
66
+        SysUser current = currentUser();
67
+        if (!checkOrgAccess(sysUser.getOrgId(), current.getUserId())) {
68
+            return ResponseBean.error("暂无权限");
69
+        }
70
+
71
+        List<TaUserMachinery> result = iTaUserMachineryService.getByUser(userId);
72
+        return ResponseBean.success(result);
60 73
     }
61 74
 
62 75
     /**
63 76
      * 保存对象
64
-     * @param taUserMachinery 实体对象
77
+     * @param userMachineryList 实体对象
65 78
      * @return
66 79
      */
67
-    @RequestMapping(value="/taUserMachinery",method= RequestMethod.POST)
80
+    @RequestMapping(value="/admin/user/{userId}/machinery",method= RequestMethod.POST)
68 81
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taUserMachineryAdd(@ApiParam("保存内容") @RequestBody TaUserMachinery taUserMachinery) throws Exception{
82
+    @RequiresPermissions("user:update")
83
+    public ResponseBean taUserMachineryAdd(@ApiParam("用户ID") @PathVariable String userId,
84
+                                           @ApiParam("保存内容") @RequestBody List<TaUserMachinery> userMachineryList) throws Exception{
70 85
 
71
-        if (iTaUserMachineryService.save(taUserMachinery)){
72
-            return ResponseBean.success(taUserMachinery);
73
-        }else {
74
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
86
+        SysUser sysUser = iSysUserService.getExistBy("user_id", userId, false, true);
87
+        if (null == sysUser) {
88
+            return ResponseBean.error("未找到指定人员");
75 89
         }
76
-    }
77 90
 
78
-    /**
79
-     * 根据id删除对象
80
-     * @param id  实体ID
81
-     */
82
-    @RequestMapping(value="/taUserMachinery/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taUserMachineryDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaUserMachineryService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
91
+        SysUser current = currentUser();
92
+        if (!checkOrgAccess(sysUser.getOrgId(), current.getUserId())) {
93
+            return ResponseBean.error("暂无权限");
89 94
         }
90
-    }
91 95
 
92
-    /**
93
-     * 修改对象
94
-     * @param id  实体ID
95
-     * @param taUserMachinery 实体对象
96
-     * @return
97
-     */
98
-    @RequestMapping(value="/taUserMachinery/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taUserMachineryUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TaUserMachinery taUserMachinery) throws Exception{
102
-
103
-        if (iTaUserMachineryService.updateById(taUserMachinery)){
104
-            return ResponseBean.success(iTaUserMachineryService.getById(id));
105
-        }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
96
+        if (iTaUserMachineryService.editWithUser(userId, userMachineryList)){
97
+            return ResponseBean.success(userMachineryList);
98
+        } else {
99
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 100
         }
108 101
     }
109 102
 
110
-    /**
111
-     * 根据id查询对象
112
-     * @param id  实体ID
113
-     */
114
-    @RequestMapping(value="/taUserMachinery/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taUserMachineryGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaUserMachineryService.getById(id));
118
-    }
119 103
 }

+ 27
- 1
src/main/java/com/yunzhi/nanyang/controller/TdMachineryTypeController.java 查看文件

@@ -69,6 +69,31 @@ public class TdMachineryTypeController extends BaseController {
69 69
         return ResponseBean.success(result);
70 70
     }
71 71
 
72
+
73
+    /**
74
+     * 移动端列表
75
+     * @param pageNum
76
+     * @param pageSize
77
+     * @return
78
+     */
79
+    @RequestMapping(value="/{client}/{clientId}/machinery-type",method= RequestMethod.GET)
80
+    @ApiOperation(value="移动端列表", notes = "移动端列表", httpMethod = "GET", response = ResponseBean.class)
81
+    public ResponseBean getList(@ApiParam("客户端") @PathVariable String client,
82
+                                @ApiParam("客户端ID") @PathVariable String clientId,
83
+                                @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
84
+                                @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
85
+                                @ApiParam("单页数据量") @RequestParam(value ="name", required = false) String name) throws Exception{
86
+
87
+        IPage<TdMachineryType> pg = new Page<>(pageNum, pageSize);
88
+        QueryWrapper<TdMachineryType> queryWrapper = new QueryWrapper<>();
89
+        queryWrapper.like(!StringUtils.isEmpty(name), "name", "%" + name + "%");
90
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
91
+        queryWrapper.orderByDesc("create_date");
92
+
93
+        IPage<TdMachineryType> result = iTdMachineryTypeService.page(pg, queryWrapper);
94
+        return ResponseBean.success(result);
95
+    }
96
+
72 97
     /**
73 98
      * 保存对象
74 99
      * @param tdMachineryType 实体对象
@@ -147,7 +172,8 @@ public class TdMachineryTypeController extends BaseController {
147 172
         }
148 173
 
149 174
         if (iTdMachineryTypeService.updateById(tdMachineryType)){
150
-            return ResponseBean.success(iTdMachineryTypeService.getById(id));
175
+            iTaMachineryService.updateTypeName(tdMachineryType.getTypeId(), tdMachineryType.getName());
176
+            return ResponseBean.success(tdMachineryType);
151 177
         }else {
152 178
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
153 179
         }

+ 18
- 15
src/main/java/com/yunzhi/nanyang/controller/WxMaController.java 查看文件

@@ -25,7 +25,7 @@ import java.util.Map;
25 25
 
26 26
 @Api(tags = "小程序登入/登出")
27 27
 @RestController
28
-@RequestMapping("/wx/{appid}")
28
+@RequestMapping("/wx/{clientId}")
29 29
 public class WxMaController extends BaseController {
30 30
 
31 31
     @Autowired
@@ -46,8 +46,8 @@ public class WxMaController extends BaseController {
46 46
                 && !StringUtils.isEmpty(loginParam.getPassword());
47 47
     }
48 48
 
49
-    private WxMaService getService(String appid) throws Exception {
50
-        SysMiniapp miniapp = iSysMiniappService.getById(appid);
49
+    private WxMaService getService(String clientId) throws Exception {
50
+        SysMiniapp miniapp = iSysMiniappService.getByClient(clientId);
51 51
         if (null == miniapp || miniapp.getStatus() != Constants.STATUS_NORMAL) {
52 52
             throw new Exception("未找到有效的小程序配置");
53 53
         }
@@ -57,11 +57,8 @@ public class WxMaController extends BaseController {
57 57
 
58 58
     @GetMapping("/preload")
59 59
     @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
60
-    public ResponseBean preload(@ApiParam("小程序ID") @PathVariable String appid,
60
+    public ResponseBean preload(@ApiParam("客户端ID") @PathVariable String clientId,
61 61
                                 @ApiParam("小程序预加载参数") @RequestParam WxMaPreload wxMaPreload) throws Exception {
62
-        if (!appid.equals(wxMaPreload.getAppid())) {
63
-            return ResponseBean.error("小程序预加载接口配置错误");
64
-        }
65 62
 
66 63
         return ResponseBean.success(null);
67 64
     }
@@ -74,29 +71,35 @@ public class WxMaController extends BaseController {
74 71
      */
75 72
     @PostMapping("/login")
76 73
     @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
77
-    public ResponseBean appLogin(@ApiParam("小程序ID") @PathVariable String appid,
74
+    public ResponseBean appLogin(@ApiParam("客户端ID") @PathVariable String clientId,
78 75
                                  @ApiParam("登录参数") @RequestBody LoginParam loginParam) throws Exception {
79 76
 
80 77
         if (StringUtils.isEmpty(loginParam.getCode())) {
81 78
             return ResponseBean.error("CODE 不能为空");
82 79
         }
83 80
 
84
-        WxMaService service = getService(appid);
81
+        SysMiniapp miniapp = iSysMiniappService.getByClient(clientId);
82
+        WxMaService service = getService(clientId);
85 83
 
86 84
         WxMaJscode2SessionResult sessionInfo = service.getUserService().getSessionInfo(loginParam.getCode());
87 85
         String openid = sessionInfo.getOpenid();
88 86
         String sessionKey = sessionInfo.getSessionKey();
89 87
 
90
-        TaPerson taPerson = iTaPersonService.getByOpenId(appid, openid);
88
+        TaPerson taPerson = iTaPersonService.getByOpenId(miniapp.getAppId(), openid);
91 89
         if (null == taPerson) {
92 90
             taPerson = new TaPerson();
93
-            taPerson.setAppId(appid);
91
+            taPerson.setAppId(miniapp.getAppId());
94 92
             taPerson.setOpenid(openid);
95 93
             taPerson.setStatus(Constants.STATUS_NORMAL);
96 94
             taPerson.setCreateDate(LocalDateTime.now());
97 95
             iTaPersonService.save(taPerson);
98 96
         }
99 97
 
98
+        // 如果是农机手
99
+        if (Constants.CLIENT_WORKER.equals(miniapp.getClient())) {
100
+            iTaPersonService.tryBindUser(taPerson);
101
+        }
102
+
100 103
         // 生成 token
101 104
         String token = JWTUtil.sign(taPerson.getPersonId(), taPerson.getPersonId());
102 105
 
@@ -111,9 +114,9 @@ public class WxMaController extends BaseController {
111 114
 
112 115
     @PutMapping("/auth-user")
113 116
     @ApiOperation(value="授权头像", notes = "授权头像", httpMethod = "PUT", response = TaPerson.class)
114
-    public ResponseBean updateUserInfo(@ApiParam("小程序ID") @PathVariable String appid,
117
+    public ResponseBean updateUserInfo(@ApiParam("客户端ID") @PathVariable String clientId,
115 118
                                        @ApiParam("授权头像的参数") @RequestBody WxMaAuthParam params) throws Exception {
116
-        WxMaService service = getService(appid);
119
+        WxMaService service = getService(clientId);
117 120
         checkAuthParams(service, params);
118 121
 
119 122
         // 解密用户信息
@@ -135,10 +138,10 @@ public class WxMaController extends BaseController {
135 138
 
136 139
     @ApiOperation(value="授权手机", notes = "授权手机", httpMethod = "PUT", response = TaPerson.class)
137 140
     @PutMapping("/auth-phone")
138
-    public ResponseBean updateUserPhone(@ApiParam("小程序ID") @PathVariable String appid,
141
+    public ResponseBean updateUserPhone(@ApiParam("客户端ID") @PathVariable String clientId,
139 142
                                         @ApiParam("授权手机的参数") @RequestBody WxMaAuthParam params) throws Exception {
140 143
 
141
-        WxMaService service = getService(appid);
144
+        WxMaService service = getService(clientId);
142 145
 
143 146
         // 解密
144 147
         WxMaPhoneNumberInfo phoneNoInfo = service.getUserService().getPhoneNoInfo(params.getSessionKey(), params.getEncryptedData(), params.getIv());

+ 3
- 3
src/main/java/com/yunzhi/nanyang/entity/TaAddress.java 查看文件

@@ -26,11 +26,11 @@ public class TaAddress implements Serializable {
26 26
     private static final long serialVersionUID = 1L;
27 27
 
28 28
     @ApiModelProperty(value = "地址ID")
29
-    @TableId(value = "address_id", type = IdType.INPUT)
29
+    @TableId(value = "address_id", type = IdType.UUID)
30 30
     private String addressId;
31 31
 
32 32
     @ApiModelProperty(value = "地址")
33
-    private Integer address;
33
+    private String address;
34 34
 
35 35
     @ApiModelProperty(value = "所属人类型")
36 36
     private String ownerType;
@@ -39,7 +39,7 @@ public class TaAddress implements Serializable {
39 39
     private String ownerId;
40 40
 
41 41
     @ApiModelProperty(value = "是否默认")
42
-    private Integer isDefault;
42
+    private Boolean isDefault;
43 43
 
44 44
     @ApiModelProperty(value = "排序")
45 45
     private Integer sortNo;

+ 9
- 1
src/main/java/com/yunzhi/nanyang/entity/TaFeedback.java 查看文件

@@ -2,6 +2,8 @@ package com.yunzhi.nanyang.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
7 9
 import io.swagger.annotations.ApiModel;
@@ -27,7 +29,7 @@ public class TaFeedback implements Serializable {
27 29
     private static final long serialVersionUID = 1L;
28 30
 
29 31
     @ApiModelProperty(value = "反馈ID")
30
-    @TableId(value = "feedback_id", type = IdType.INPUT)
32
+    @TableId(value = "feedback_id", type = IdType.UUID)
31 33
     private String feedbackId;
32 34
 
33 35
     @ApiModelProperty(value = "反馈端口")
@@ -48,5 +50,11 @@ public class TaFeedback implements Serializable {
48 50
     @ApiModelProperty(value = "创建时间")
49 51
     private LocalDateTime createDate;
50 52
 
53
+    @TableField(exist = false)
54
+    @ApiModelProperty(value = "名称")
55
+    private String nickName;
51 56
 
57
+    @TableField(exist = false)
58
+    @ApiModelProperty(value = "手机号")
59
+    private String phone;
52 60
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/entity/TaMachinery.java 查看文件

@@ -64,6 +64,9 @@ public class TaMachinery implements Serializable {
64 64
     @ApiModelProperty(value = "归属区域")
65 65
     private String regionName;
66 66
 
67
+    @ApiModelProperty(value = "当前位置")
68
+    private String location;
69
+
67 70
     @ApiModelProperty(value = "APP 注册状态")
68 71
     private String appStatus;
69 72
 

+ 13
- 1
src/main/java/com/yunzhi/nanyang/entity/TaOrder.java 查看文件

@@ -27,7 +27,7 @@ public class TaOrder implements Serializable {
27 27
     private static final long serialVersionUID = 1L;
28 28
 
29 29
     @ApiModelProperty(value = "订单Id")
30
-    @TableId(value = "order_id", type = IdType.INPUT)
30
+    @TableId(value = "order_id", type = IdType.UUID)
31 31
     private String orderId;
32 32
 
33 33
     @ApiModelProperty(value = "订单编号")
@@ -39,6 +39,18 @@ public class TaOrder implements Serializable {
39 39
     @ApiModelProperty(value = "费用")
40 40
     private Integer charges;
41 41
 
42
+    @ApiModelProperty(value = "单价")
43
+    private Integer price;
44
+
45
+    @ApiModelProperty(value = "作业面积")
46
+    private Integer amount;
47
+
48
+    @ApiModelProperty(value = "农机ID")
49
+    private String machineryId;
50
+
51
+    @ApiModelProperty(value = "农机名称")
52
+    private String machineryName;
53
+
42 54
     @ApiModelProperty(value = "农机类型")
43 55
     private String machineryType;
44 56
 

+ 4
- 0
src/main/java/com/yunzhi/nanyang/entity/TaUserMachinery.java 查看文件

@@ -1,6 +1,7 @@
1 1
 package com.yunzhi.nanyang.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import java.io.Serializable;
6 7
 import io.swagger.annotations.ApiModel;
@@ -35,5 +36,8 @@ public class TaUserMachinery implements Serializable {
35 36
     @ApiModelProperty(value = "农机ID")
36 37
     private String machineryId;
37 38
 
39
+    @TableField(exist = false)
40
+    @ApiModelProperty(value = "农机名称")
41
+    private String machineryName;
38 42
 
39 43
 }

+ 4
- 0
src/main/java/com/yunzhi/nanyang/mapper/SysUserMapper.java 查看文件

@@ -5,6 +5,7 @@ import com.yunzhi.nanyang.entity.SysUser;
5 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6 6
 import org.apache.ibatis.annotations.Mapper;
7 7
 import org.apache.ibatis.annotations.Param;
8
+import org.apache.ibatis.annotations.Select;
8 9
 
9 10
 /**
10 11
  * <p>
@@ -25,4 +26,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
25 26
                              @Param("orgId") String orgId,
26 27
                              @Param("name") String name,
27 28
                              @Param("phone") String phone);
29
+
30
+    @Select("select * from sys_user where phone = #{phone} and status > -1")
31
+    SysUser selectByPhone(@Param("phone") String phone);
28 32
 }

+ 6
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaExtendContentMapper.java 查看文件

@@ -3,6 +3,10 @@ package com.yunzhi.nanyang.mapper;
3 3
 import com.yunzhi.nanyang.entity.TaExtendContent;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Select;
8
+
9
+import java.util.List;
6 10
 
7 11
 /**
8 12
  * <p>
@@ -15,4 +19,6 @@ import org.apache.ibatis.annotations.Mapper;
15 19
 @Mapper
16 20
 public interface TaExtendContentMapper extends BaseMapper<TaExtendContent> {
17 21
 
22
+    @Select("SELECT * FROM ta_extend_content t WHERE t.target_type = #{targetType} AND t.target_id = #{targetId} ORDER BY t.sort ASC")
23
+    List<TaExtendContent> getByTarget(@Param("targetType") String targetType, @Param("targetId") String targetId);
18 24
 }

+ 3
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaFeedbackMapper.java 查看文件

@@ -1,8 +1,10 @@
1 1
 package com.yunzhi.nanyang.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaFeedback;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
6 8
 
7 9
 /**
8 10
  * <p>
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TaFeedbackMapper extends BaseMapper<TaFeedback> {
17 19
 
20
+    IPage<TaFeedback> getPageBy(IPage<TaFeedback> pg, @Param("nickName") String nickName, @Param("phone") String phone);
18 21
 }

+ 18
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaMachineryMapper.java 查看文件

@@ -1,8 +1,12 @@
1 1
 package com.yunzhi.nanyang.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaMachinery;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.nanyang.vo.MachineSummary;
5 7
 import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+import org.apache.ibatis.annotations.Update;
6 10
 
7 11
 /**
8 12
  * <p>
@@ -15,4 +19,18 @@ import org.apache.ibatis.annotations.Mapper;
15 19
 @Mapper
16 20
 public interface TaMachineryMapper extends BaseMapper<TaMachinery> {
17 21
 
22
+    @Update("UPDATE ta_machinery SET type_name = #{typeName} WHERE type_id = #{typeId}")
23
+    int updateTypeName(@Param("typeId") String typeId, @Param("typeName") String typeName);
24
+
25
+    @Update("UPDATE ta_machinery SET region_name = #{regionName} WHERE region_id = #{regionId}")
26
+    int updateRegionName(@Param("regionId") String regionId, @Param("regionName") String regionName);
27
+
28
+    IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg,
29
+                                         @Param("location") String location,
30
+                                         @Param("typeId") String typeId,
31
+                                         @Param("orgId") String orgId);
32
+
33
+    MachineSummary getSummaryDetail(@Param("machineryId") String machineryId, @Param("location") String location);
34
+
35
+    IPage<MachineSummary> getOneOfTypes(IPage<MachineSummary> pg, @Param("location") String location, @Param("typeId") String typeId);
18 36
 }

+ 4
- 0
src/main/java/com/yunzhi/nanyang/mapper/TaOrderMapper.java 查看文件

@@ -3,6 +3,8 @@ package com.yunzhi.nanyang.mapper;
3 3
 import com.yunzhi.nanyang.entity.TaOrder;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Select;
6 8
 
7 9
 /**
8 10
  * <p>
@@ -15,4 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TaOrderMapper extends BaseMapper<TaOrder> {
17 19
 
20
+    @Select("SELECT fn_nextval(#{name})")
21
+    int getNextOrderNO(@Param("name") String name);
18 22
 }

+ 5
- 1
src/main/java/com/yunzhi/nanyang/mapper/TaUserMachineryMapper.java 查看文件

@@ -1,8 +1,11 @@
1 1
 package com.yunzhi.nanyang.mapper;
2 2
 
3
-import com.yunzhi.nanyang.entity.TaUserMachinery;
4 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.yunzhi.nanyang.entity.TaUserMachinery;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
6 9
 
7 10
 /**
8 11
  * <p>
@@ -15,4 +18,5 @@ import org.apache.ibatis.annotations.Mapper;
15 18
 @Mapper
16 19
 public interface TaUserMachineryMapper extends BaseMapper<TaUserMachinery> {
17 20
 
21
+    List<TaUserMachinery> getByUser(@Param("userId") String userId);
18 22
 }

+ 1
- 0
src/main/java/com/yunzhi/nanyang/service/ITaAddressService.java 查看文件

@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 13
  */
14 14
 public interface ITaAddressService extends IBaseService<TaAddress> {
15 15
 
16
+    boolean updateDefault(TaAddress taAddress) throws Exception;
16 17
 }

+ 2
- 0
src/main/java/com/yunzhi/nanyang/service/ITaFeedbackService.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.nanyang.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaFeedback;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
5 6
 
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 14
  */
14 15
 public interface ITaFeedbackService extends IBaseService<TaFeedback> {
15 16
 
17
+    IPage<TaFeedback> getPageBy(IPage<TaFeedback> pg, String nickName, String phone);
16 18
 }

+ 10
- 1
src/main/java/com/yunzhi/nanyang/service/ITaMachineryService.java 查看文件

@@ -1,7 +1,8 @@
1 1
 package com.yunzhi.nanyang.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaMachinery;
4
-import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.nanyang.vo.MachineSummary;
5 6
 
6 7
 /**
7 8
  * <p>
@@ -18,4 +19,12 @@ public interface ITaMachineryService extends IBaseService<TaMachinery> {
18 19
     boolean updateAll(TaMachinery taMachinery)  throws Exception;
19 20
 
20 21
     TaMachinery getDetail(String machineryId);
22
+
23
+    boolean updateTypeName(String typeId, String typeName);
24
+
25
+    boolean updateRegionName(String regionId, String regionName);
26
+
27
+    IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg, String location, String typeId, String orgId);
28
+
29
+    MachineSummary getSummaryDetail(String machineryId, String location, Boolean attached);
21 30
 }

+ 1
- 0
src/main/java/com/yunzhi/nanyang/service/ITaOrderService.java 查看文件

@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 13
  */
14 14
 public interface ITaOrderService extends IBaseService<TaOrder> {
15 15
 
16
+    String getNextOrderNO();
16 17
 }

+ 2
- 0
src/main/java/com/yunzhi/nanyang/service/ITaPersonService.java 查看文件

@@ -14,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
14 14
 public interface ITaPersonService extends IBaseService<TaPerson> {
15 15
 
16 16
     TaPerson getByOpenId(String appid, String openid);
17
+
18
+    void tryBindUser(TaPerson taPerson);
17 19
 }

+ 5
- 1
src/main/java/com/yunzhi/nanyang/service/ITaUserMachineryService.java 查看文件

@@ -1,7 +1,8 @@
1 1
 package com.yunzhi.nanyang.service;
2 2
 
3 3
 import com.yunzhi.nanyang.entity.TaUserMachinery;
4
-import com.baomidou.mybatisplus.extension.service.IService;
4
+
5
+import java.util.List;
5 6
 
6 7
 /**
7 8
  * <p>
@@ -13,4 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 14
  */
14 15
 public interface ITaUserMachineryService extends IBaseService<TaUserMachinery> {
15 16
 
17
+    List<TaUserMachinery> getByUser(String userId);
18
+
19
+    boolean editWithUser(String userId, List<TaUserMachinery> userMachineryList) throws Exception;
16 20
 }

+ 19
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaAddressServiceImpl.java 查看文件

@@ -1,10 +1,12 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
3 4
 import com.yunzhi.nanyang.entity.TaAddress;
4 5
 import com.yunzhi.nanyang.mapper.TaAddressMapper;
5 6
 import com.yunzhi.nanyang.service.ITaAddressService;
6 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 8
 import org.springframework.stereotype.Service;
9
+import org.springframework.transaction.annotation.Transactional;
8 10
 
9 11
 /**
10 12
  * <p>
@@ -17,4 +19,21 @@ import org.springframework.stereotype.Service;
17 19
 @Service
18 20
 public class TaAddressServiceImpl extends BaseServiceImpl<TaAddressMapper, TaAddress> implements ITaAddressService {
19 21
 
22
+    @Transactional(rollbackFor = Exception.class)
23
+    @Override
24
+    public boolean updateDefault(TaAddress taAddress) throws Exception {
25
+
26
+        // 先清除所有
27
+        UpdateWrapper<TaAddress> updateWrapper = new UpdateWrapper<>();
28
+        updateWrapper.set("is_default", 0);
29
+        updateWrapper.eq("owner_type", taAddress.getOwnerType());
30
+        updateWrapper.eq("owner_id", taAddress.getOwnerId());
31
+        update(updateWrapper);
32
+
33
+        // 再更新当前
34
+        taAddress.setIsDefault(true);
35
+        taAddress.setSortNo(0);
36
+
37
+        return updateById(taAddress);
38
+    }
20 39
 }

+ 5
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaFeedbackServiceImpl.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.entity.TaFeedback;
4 5
 import com.yunzhi.nanyang.mapper.TaFeedbackMapper;
5 6
 import com.yunzhi.nanyang.service.ITaFeedbackService;
@@ -17,4 +18,8 @@ import org.springframework.stereotype.Service;
17 18
 @Service
18 19
 public class TaFeedbackServiceImpl extends BaseServiceImpl<TaFeedbackMapper, TaFeedback> implements ITaFeedbackService {
19 20
 
21
+    @Override
22
+    public IPage<TaFeedback> getPageBy(IPage<TaFeedback> pg, String nickName, String phone) {
23
+        return baseMapper.getPageBy(pg, nickName, phone);
24
+    }
20 25
 }

+ 46
- 9
src/main/java/com/yunzhi/nanyang/service/impl/TaMachineryServiceImpl.java 查看文件

@@ -1,17 +1,12 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.nanyang.common.Constants;
4 5
 import com.yunzhi.nanyang.common.StringUtils;
5
-import com.yunzhi.nanyang.entity.TaImages;
6
-import com.yunzhi.nanyang.entity.TaMachinery;
7
-import com.yunzhi.nanyang.entity.TaRegion;
8
-import com.yunzhi.nanyang.entity.TdMachineryType;
9
-import com.yunzhi.nanyang.mapper.TaImagesMapper;
10
-import com.yunzhi.nanyang.mapper.TaMachineryMapper;
11
-import com.yunzhi.nanyang.mapper.TaRegionMapper;
12
-import com.yunzhi.nanyang.mapper.TdMachineryTypeMapper;
6
+import com.yunzhi.nanyang.entity.*;
7
+import com.yunzhi.nanyang.mapper.*;
13 8
 import com.yunzhi.nanyang.service.ITaMachineryService;
14
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import com.yunzhi.nanyang.vo.MachineSummary;
15 10
 import org.springframework.beans.factory.annotation.Autowired;
16 11
 import org.springframework.stereotype.Service;
17 12
 import org.springframework.transaction.annotation.Transactional;
@@ -39,6 +34,9 @@ public class TaMachineryServiceImpl extends BaseServiceImpl<TaMachineryMapper, T
39 34
     @Autowired
40 35
     TaRegionMapper taRegionMapper;
41 36
 
37
+    @Autowired
38
+    TaExtendContentMapper taExtendContentMapper;
39
+
42 40
     @Transactional(rollbackFor = Exception.class)
43 41
     @Override
44 42
     public boolean saveAll(TaMachinery taMachinery) throws Exception {
@@ -87,6 +85,45 @@ public class TaMachineryServiceImpl extends BaseServiceImpl<TaMachineryMapper, T
87 85
         return taMachinery;
88 86
     }
89 87
 
88
+    @Override
89
+    public boolean updateTypeName(String typeId, String typeName) {
90
+        return baseMapper.updateTypeName(typeId, typeName) > 0;
91
+    }
92
+
93
+    @Override
94
+    public boolean updateRegionName(String regionId, String regionName) {
95
+        return baseMapper.updateRegionName(regionId, regionName) > 0;
96
+    }
97
+
98
+    @Override
99
+    public IPage<MachineSummary> getSummaryList(IPage<MachineSummary> pg, String location, String typeId, String orgId) {
100
+
101
+        // 有没有 orgId 实际上用来区分是否农机手端
102
+        if (StringUtils.isEmpty(orgId)) {
103
+            // 农户端, 实际上过滤的是所有组织下的所有分类的其中一个机器
104
+            return baseMapper.getOneOfTypes(pg, location, typeId);
105
+        } else {
106
+            // 农机手端
107
+            return baseMapper.getSummaryList(pg, location, typeId, orgId);
108
+        }
109
+
110
+    }
111
+
112
+    @Override
113
+    public MachineSummary getSummaryDetail(String machineryId, String location, Boolean attached) {
114
+        MachineSummary summaryDetail = baseMapper.getSummaryDetail(machineryId, location);
115
+
116
+        if (attached) {
117
+            List<TaExtendContent> extendContentList = taExtendContentMapper.getByTarget(Constants.TARGET_MACHINERY, machineryId);
118
+            summaryDetail.setContentList(extendContentList);
119
+
120
+            List<TaImages> images = taImagesMapper.getListBy(Constants.TARGET_MACHINERY, machineryId);
121
+            summaryDetail.setImagesList(images);
122
+        }
123
+
124
+        return summaryDetail;
125
+    }
126
+
90 127
     private void saveImages(TaMachinery taMachinery) {
91 128
         String machineryId = taMachinery.getMachineryId();
92 129
         // 先删除所有

+ 12
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaOrderServiceImpl.java 查看文件

@@ -1,11 +1,15 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.yunzhi.nanyang.common.DateUtils;
4
+import com.yunzhi.nanyang.common.StringUtils;
3 5
 import com.yunzhi.nanyang.entity.TaOrder;
4 6
 import com.yunzhi.nanyang.mapper.TaOrderMapper;
5 7
 import com.yunzhi.nanyang.service.ITaOrderService;
6 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 9
 import org.springframework.stereotype.Service;
8 10
 
11
+import java.time.LocalDateTime;
12
+
9 13
 /**
10 14
  * <p>
11 15
  * 订单表 服务实现类
@@ -17,4 +21,12 @@ import org.springframework.stereotype.Service;
17 21
 @Service
18 22
 public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder> implements ITaOrderService {
19 23
 
24
+    @Override
25
+    public String getNextOrderNO() {
26
+        String today = DateUtils.toString(LocalDateTime.now(), "yyyyMMdd");
27
+        String prefix = "M-" + today;
28
+
29
+        int next = baseMapper.getNextOrderNO(prefix);
30
+        return prefix + StringUtils.lpad(String.valueOf(next), "0", 6);
31
+    }
20 32
 }

+ 25
- 0
src/main/java/com/yunzhi/nanyang/service/impl/TaPersonServiceImpl.java 查看文件

@@ -1,9 +1,13 @@
1 1
 package com.yunzhi.nanyang.service.impl;
2 2
 
3
+import com.yunzhi.nanyang.common.StringUtils;
4
+import com.yunzhi.nanyang.entity.SysUser;
3 5
 import com.yunzhi.nanyang.entity.TaPerson;
6
+import com.yunzhi.nanyang.mapper.SysUserMapper;
4 7
 import com.yunzhi.nanyang.mapper.TaPersonMapper;
5 8
 import com.yunzhi.nanyang.service.ITaPersonService;
6 9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
+import org.springframework.beans.factory.annotation.Autowired;
7 11
 import org.springframework.stereotype.Service;
8 12
 
9 13
 /**
@@ -17,8 +21,29 @@ import org.springframework.stereotype.Service;
17 21
 @Service
18 22
 public class TaPersonServiceImpl extends BaseServiceImpl<TaPersonMapper, TaPerson> implements ITaPersonService {
19 23
 
24
+    @Autowired
25
+    SysUserMapper sysUserMapper;
26
+
20 27
     @Override
21 28
     public TaPerson getByOpenId(String appid, String openid) {
22 29
         return baseMapper.getByOpenId(appid, openid);
23 30
     }
31
+
32
+    @Override
33
+    public void tryBindUser(TaPerson taPerson) {
34
+        if (null == taPerson) return;
35
+
36
+        try {
37
+            if (!StringUtils.isEmpty(taPerson.getPhone()) && StringUtils.isEmpty(taPerson.getUserId())) {
38
+                // 尝试去绑定农机手人员
39
+                SysUser sysUser = sysUserMapper.selectByPhone(taPerson.getPhone());
40
+                if (null != sysUser) {
41
+                    taPerson.setUserId(sysUser.getUserId());
42
+                    updateById(taPerson);
43
+                }
44
+            }
45
+        } catch (Exception e) {
46
+            e.printStackTrace();
47
+        }
48
+    }
24 49
 }

+ 28
- 1
src/main/java/com/yunzhi/nanyang/service/impl/TaUserMachineryServiceImpl.java 查看文件

@@ -3,8 +3,11 @@ package com.yunzhi.nanyang.service.impl;
3 3
 import com.yunzhi.nanyang.entity.TaUserMachinery;
4 4
 import com.yunzhi.nanyang.mapper.TaUserMachineryMapper;
5 5
 import com.yunzhi.nanyang.service.ITaUserMachineryService;
6
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 6
 import org.springframework.stereotype.Service;
7
+import org.springframework.transaction.annotation.Transactional;
8
+
9
+import java.util.HashMap;
10
+import java.util.List;
8 11
 
9 12
 /**
10 13
  * <p>
@@ -17,4 +20,28 @@ import org.springframework.stereotype.Service;
17 20
 @Service
18 21
 public class TaUserMachineryServiceImpl extends BaseServiceImpl<TaUserMachineryMapper, TaUserMachinery> implements ITaUserMachineryService {
19 22
 
23
+    @Override
24
+    public List<TaUserMachinery> getByUser(String userId) {
25
+        return baseMapper.getByUser(userId);
26
+    }
27
+
28
+    @Transactional(rollbackFor = Exception.class)
29
+    @Override
30
+    public boolean editWithUser(String userId, List<TaUserMachinery> userMachineryList) throws Exception {
31
+
32
+        // 先删除所有
33
+        removeByMap(new HashMap<String, Object>(){{
34
+            put("user_id", userId);
35
+        }});
36
+
37
+        if (null == userMachineryList || userMachineryList.size() < 1) return true;
38
+
39
+        //
40
+        for (TaUserMachinery userMachinery : userMachineryList) {
41
+            userMachinery.setSerialNo(null);
42
+            userMachinery.setUserId(userId);
43
+        }
44
+
45
+        return saveBatch(userMachineryList);
46
+    }
20 47
 }

+ 59
- 0
src/main/java/com/yunzhi/nanyang/vo/MachineSummary.java 查看文件

@@ -0,0 +1,59 @@
1
+package com.yunzhi.nanyang.vo;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.yunzhi.nanyang.entity.TaExtendContent;
6
+import com.yunzhi.nanyang.entity.TaImages;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+
11
+import java.util.List;
12
+
13
+@Data
14
+@ApiModel(value="MachineSummary", description="农机列表")
15
+public class MachineSummary {
16
+
17
+    @ApiModelProperty(value = "农机Id")
18
+    @TableId(value = "machinery_id", type = IdType.UUID)
19
+    private String machineryId;
20
+
21
+    @ApiModelProperty(value = "名称")
22
+    private String name;
23
+
24
+    @ApiModelProperty(value = "农机类型")
25
+    private String typeId;
26
+
27
+    @ApiModelProperty(value = "类型名称")
28
+    private String typeName;
29
+
30
+    @ApiModelProperty(value = "农机价格")
31
+    private Integer price;
32
+
33
+    @ApiModelProperty(value = "主图")
34
+    private String thumb;
35
+
36
+    @ApiModelProperty(value = "当前位置")
37
+    private String location;
38
+
39
+    @ApiModelProperty(value = "距离")
40
+    private Float distance;
41
+
42
+    @ApiModelProperty(value = "机构ID")
43
+    private String orgId;
44
+
45
+    @ApiModelProperty(value = "机构名称")
46
+    private String orgName;
47
+
48
+    @ApiModelProperty(value = "工作状态")
49
+    private String jobStatus;
50
+
51
+    @ApiModelProperty(value = "状态")
52
+    private Integer status;
53
+
54
+    @ApiModelProperty(value = "内容详情")
55
+    List<TaExtendContent> contentList;
56
+
57
+    @ApiModelProperty(value = "图片列表")
58
+    List<TaImages> imagesList;
59
+}

+ 3
- 0
src/main/resources/application.yml 查看文件

@@ -41,6 +41,9 @@ yz:
41 41
     api: http://sms.njyunzhi.com/sms
42 42
     ## 帮助文档
43 43
     help: http://sms.njyunzhi.com/help
44
+  amap:
45
+    url: https://restapi.amap.com
46
+    key: 3be0a9567a794d2690d378476f057a6f
44 47
 
45 48
 ###
46 49
 aliyun:

+ 19
- 0
src/main/resources/mapper/TaFeedbackMapper.xml 查看文件

@@ -2,4 +2,23 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.nanyang.mapper.TaFeedbackMapper">
4 4
 
5
+    <select id="getPageBy" resultType="com.yunzhi.nanyang.entity.TaFeedback">
6
+        SELECT
7
+            t.*,
8
+            s.nick_name,
9
+            s.phone
10
+        FROM
11
+            ta_feedback t
12
+                INNER JOIN ta_person s ON s.person_id = t.from_person
13
+        WHERE
14
+            1 = 1
15
+          <if test="nickName != null and nickName != ''">
16
+              AND s.nick_name LIKE CONCAT( '%', #{nickName}, '%' )
17
+          </if>
18
+        <if test="phone != null and phone != ''">
19
+            AND s.phone LIKE CONCAT( '%', #{phone}, '%' )
20
+        </if>
21
+        ORDER BY
22
+            t.create_date DESC
23
+    </select>
5 24
 </mapper>

+ 55
- 0
src/main/resources/mapper/TaMachineryMapper.xml 查看文件

@@ -2,4 +2,59 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.nanyang.mapper.TaMachineryMapper">
4 4
 
5
+    <select id="getSummaryList" resultType="com.yunzhi.nanyang.vo.MachineSummary">
6
+        SELECT
7
+            *
8
+        FROM
9
+            ( SELECT
10
+                     t.*,
11
+                     fn_distance ( t.location, #{location} ) AS distance
12
+                FROM ta_machinery t
13
+                WHERE
14
+                      t.`status` = 1
15
+                <if test="orgId != null and orgId != ''">
16
+                    AND t.org_id = #{orgId}
17
+                </if>
18
+                <if test="typeId != null and typeId != ''">
19
+                    AND t.type_id = #{typeId}
20
+                </if>
21
+                ) AS a
22
+        ORDER BY
23
+            a.distance DESC
24
+    </select>
25
+    <select id="getSummaryDetail" resultType="com.yunzhi.nanyang.vo.MachineSummary">
26
+        SELECT
27
+            t.*,
28
+            s.`name` as org_name,
29
+            fn_distance(t.location, #{location}) as distance
30
+        FROM
31
+            ta_machinery t
32
+        INNER JOIN ta_org s on t.org_id = s.org_id
33
+        WHERE
34
+            t.machinery_id = #{machineryId}
35
+            AND t.`status` = 1
36
+    </select>
37
+    <select id="getOneOfTypes" resultType="com.yunzhi.nanyang.vo.MachineSummary">
38
+        SELECT
39
+            t.*,
40
+            fn_distance ( concat( m.lng, ',', m.lat ), #{location} ) AS distance,
41
+            count( * ) AS num
42
+        FROM
43
+            ta_machinery t
44
+        INNER JOIN ta_machinery s ON t.org_id = s.org_id
45
+            AND t.type_id = s.type_id
46
+        INNER JOIN ta_org m ON m.org_id = t.org_id
47
+        WHERE
48
+            t.machinery_id &lt; s.machinery_id
49
+        <if test="typeId != null and typeId != ''">
50
+            AND t.type_id = #{typeId}
51
+        </if>
52
+         GROUP BY
53
+            t.org_id,
54
+            t.machinery_id
55
+        HAVING
56
+            num &lt;= 1
57
+        ORDER BY
58
+            distance ASC
59
+    </select>
5 60
 </mapper>

+ 13
- 0
src/main/resources/mapper/TaUserMachineryMapper.xml 查看文件

@@ -2,4 +2,17 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.nanyang.mapper.TaUserMachineryMapper">
4 4
 
5
+    <select id="getByUser" resultType="com.yunzhi.nanyang.entity.TaUserMachinery">
6
+        SELECT
7
+            t.*,
8
+            s.`name` as machinery_name
9
+        FROM
10
+            ta_user_machinery t
11
+                INNER JOIN ta_machinery s ON t.machinery_id = s.machinery_id
12
+                AND s.`status` &gt; -1
13
+        WHERE
14
+            t.user_id = #{userId}
15
+        ORDER BY
16
+            t.serial_no
17
+    </select>
5 18
 </mapper>