Browse Source

预售管理

shish 3 years ago
parent
commit
9c04aac548
1 changed files with 16 additions and 14 deletions
  1. 16 14
      app-ghs/controllers/ProductController.php

+ 16 - 14
app-ghs/controllers/ProductController.php

@@ -7,7 +7,6 @@
 namespace ghs\controllers;
 
 use biz\admin\classes\AdminRoleClass;
-use biz\ghs\classes\GhsClass;
 use biz\item\classes\PtItemClass;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\item\classes\ItemClassClass;
@@ -36,20 +35,23 @@ class ProductController extends BaseController
         ProductClass::check($info, $this->mainId);
         $str = $post['date'] ?? '';
         $presell = $post['presell'] ?? 0;
-        if (empty($str)) {
-            util::fail('请填写预售日期');
-        }
-        $arr = json_decode($str, true);
-        if (empty($arr)) {
-            util::fail('请填写预售日期');
-        }
-        $new = [];
-        foreach ($arr as $date) {
-            $new[] = strtotime($date);
+        $newStr = '';
+        if ($presell == 1) {
+            if (empty($str)) {
+                util::fail('请填写预售日期');
+            }
+            $arr = json_decode($str, true);
+            if (empty($arr)) {
+                util::fail('请填写预售日期');
+            }
+            $new = [];
+            foreach ($arr as $date) {
+                $new[] = strtotime($date);
+            }
+            $new = array_unique(array_filter($new));
+            asort($new);
+            $newStr = implode(',', $new);
         }
-        $new = array_unique(array_filter($new));
-        asort($new);
-        $newStr = implode(',', $new);
         $info->presell = $presell;
         $info->presellDate = $newStr;
         $info->discountPrice = 0;