LiuJ 4 days ago
parent
commit
cc96786810
1 changed files with 6 additions and 0 deletions
  1. 6 0
      app/JsonRpc/NewsService.php

+ 6 - 0
app/JsonRpc/NewsService.php

@@ -1902,6 +1902,9 @@ class NewsService implements NewsServiceInterface
         $data['cat_arr_id'] = isset($data['cat_arr_id']) ? json_encode($data['cat_arr_id']) : '';
         $data['imgurl'] = isset($data['imgurl']) ? json_encode($data['imgurl']) : '';
         unset($data['imgUrl']);
+        if (isset($data['price']) && $data['price'] == '') {
+            $data['price'] =  0;
+        }
         $result = Good::insert($data);
         if (empty($result)) {
             return Result::error("添加失败", 0);
@@ -1918,6 +1921,9 @@ class NewsService implements NewsServiceInterface
         //设置东八区
         date_default_timezone_set('Asia/Shanghai');
         $data['updated_at'] = date('Y-m-d H:i:s');
+        if (isset($data['price']) && $data['price'] == '') {
+            $data['price'] =  0;
+        }
         $result = Good::where('id', $data['id'])->update($data);
         if (empty($result)) {
             return Result::error("更新失败", 0);