Răsfoiți Sursa

推荐福利

shish 4 ani în urmă
părinte
comite
50136cd989

+ 54 - 0
app-ghs/controllers/TjFlController.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace ghs\controllers;
+
+use biz\market\classes\TjFlClass;
+use common\components\util;
+use Yii;
+
+class TjFlController extends BaseController
+{
+
+    public function actionDetail()
+    {
+        $list = TjFlClass::getAllByCondition(['shopId' => $this->shopId, 'delStatus' => 0], 'hbAmount DESC', '*');
+        $tjFl = $this->shop->tjFl ?? 0;
+        util::success(['list' => $list, 'tjFl' => $tjFl]);
+    }
+
+    //保存福利内容 shish 20210930
+    public function actionSaveFl()
+    {
+        $data = Yii::$app->request->post('data');
+        $arr = json_decode($data, true);
+        if (is_array($arr) == false) {
+            util::fail('数据错误');
+        }
+        TjFlClass::updateByCondition(['shopId' => $this->shopId], ['delStatus' => 1]);
+        foreach ($arr as $key => $item) {
+            $mini = $item['miniExpend'] ?? 0;
+            $hbAmount = $item['hbAmount'] ?? 0;
+            if ($mini <= $hbAmount) {
+                util::fail('最低消费金额要大于红包金额');
+            }
+            $valid = $item['valid'] ?? 0;
+            if (empty($valid)) {
+                util::fail('请填写红包有效期');
+            }
+            $num = $item['num'] ?? 0;
+            if ($num <= 0) {
+                util::fail('请填写红包数量');
+            }
+            $totalHb = bcmul($hbAmount, $num, 2);
+            $item['shopId'] = $this->shopId;
+            $item['sjId'] = $this->sjId;
+            $item['totalHb'] = $totalHb;
+            TjFlClass::add($item);
+        }
+        $tjFlSwitch = Yii::$app->request->post('tjFlSwitch', 0);
+        $this->shop->tjFl = $tjFlSwitch;
+        $this->shop->save();
+        util::complete('已保存');
+    }
+
+}

+ 0 - 1
app-ghs/controllers/XrFlController.php

@@ -3,7 +3,6 @@
 namespace ghs\controllers;
 
 use biz\market\classes\XrFlClass;
-use common\components\arrayUtil;
 use common\components\util;
 use Yii;