Browse Source

价格管理

FEI 2 weeks ago
parent
commit
544400f184

+ 15
- 0
sto/src/main/java/com/shinsoft/sto/controller/main/CargoController.java View File

110
             return resultJSON;
110
             return resultJSON;
111
         }
111
         }
112
     }
112
     }
113
+
114
+    @RequestMapping(value = "/updateEnableStatus")
115
+    public ResultJSON updateEnableStatus(@RequestParam String id,
116
+                                         @RequestParam String enableStatus,
117
+                                         HttpServletRequest request) {
118
+        try {
119
+            String userId = (String) request.getHeader("userId");
120
+            resultJSON = cargoService.updateEnableStatus(userId, id, enableStatus);
121
+        } catch (Exception ex) {
122
+            ex.printStackTrace();
123
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
124
+        } finally {
125
+            return resultJSON;
126
+        }
127
+    }
113
 }
128
 }

+ 30
- 0
sto/src/main/java/com/shinsoft/sto/service/impl/main/CargoServiceImp.java View File

255
         }
255
         }
256
         return resultJSON;
256
         return resultJSON;
257
     }
257
     }
258
+
259
+    @Override
260
+    public ResultJSON updateEnableStatus(String userId, String id, String enableStatus) {
261
+        try {
262
+            Date date = new Date();
263
+            Cargo cargo = cargoMapper.selectById(id);
264
+            if (cargo == null) {
265
+                resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, "货权记录不存在");
266
+                return resultJSON;
267
+            }
268
+
269
+            // 如果要启用,检查可使用量是否大于0
270
+            if ("1".equals(enableStatus) &&
271
+                    (cargo.getSumWeight() == null || cargo.getSumWeight().compareTo(BigDecimal.ZERO) <= 0)) {
272
+                resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, "可使用量必须大于0才能启用");
273
+                return resultJSON;
274
+            }
275
+
276
+            cargo.setEnableStatus(enableStatus);
277
+            cargo.setModifyId(userId);
278
+            cargo.setModifyTime(date);
279
+            cargoMapper.updateById(cargo);
280
+
281
+            resultJSON = JSONTools.toResultJSON(cargo);
282
+        } catch (Exception ex) {
283
+            ex.printStackTrace();
284
+            resultJSON = JSONTools.toResultJSON(ResponseCodeMsg.CODE_EX, ex);
285
+        }
286
+        return resultJSON;
287
+    }
258
 }
288
 }

+ 2
- 0
sto/src/main/java/com/shinsoft/sto/service/main/CargoService.java View File

19
     ResultJSON remove(String userId, String id);
19
     ResultJSON remove(String userId, String id);
20
 
20
 
21
     ResultJSON removeBatch(String userId, String ids);
21
     ResultJSON removeBatch(String userId, String ids);
22
+
23
+    ResultJSON updateEnableStatus(String userId, String id, String enableStatus);
22
 }
24
 }

Loading…
Cancel
Save