shish 1 jaar geleden
bovenliggende
commit
8e23a70872

+ 34 - 2
app-ghs/controllers/CustomBalanceChangeController.php

@@ -16,16 +16,48 @@ class CustomBalanceChangeController extends BaseController
     public function actionList()
     {
         $get = Yii::$app->request->get();
+        $export = $get['export'] ?? 0;
         $where = [];
         $where['mainId'] = $this->mainId;
+        $searchTime = $get['searchTime'] ?? '';
+        if (!empty($searchTime)) {
+            $startTime = $get['startTime'] ?? '';
+            $endTime = $get['endTime'] ?? '';
+            $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
+            $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
+        } else {
+            if ($export == 1) {
+                util::fail('请选择时间');
+            }
+        }
+        if ($export == 1) {
+            ini_set('memory_limit', '2045M');
+            set_time_limit(0);
+            if (isset($where['addTime']) == false) {
+                util::fail('请选时间段');
+            }
+            $start = $where['addTime'][1][0];
+            $end = $where['addTime'][1][1];
+            $monthTime = bcmul(31, 86400);
+            $startArea = strtotime($start);
+            $endArea = strtotime($end);
+            $diff = bcsub($endArea, $startArea);
+            if ($diff > $monthTime) {
+                util::fail('最长可导出一个月');
+            }
+        }
+
         $customId = $get['customId'] ?? 0;
         if (!empty($customId)) {
             $custom = CustomClass::getById($customId);
             CustomClass::valid($custom, $this->shopId);
             $where['customId'] = $customId;
         }
-        $list = CustomBalanceChangeClass::getChangeList($where);
-        util::success($list);
+        $respond = CustomBalanceChangeClass::getChangeList($where);
+        if ($export == 1) {
+            CustomBalanceChangeClass::exportData($respond, $this->mainId);
+        }
+        util::success($respond);
     }
 
 }

+ 8 - 0
biz-ghs/custom/classes/CustomBalanceChangeClass.php

@@ -19,4 +19,12 @@ class CustomBalanceChangeClass extends BaseClass
         return $data;
     }
 
+    public static function exportData($respond, $mainId)
+    {
+        $orderList = $respond['list'] ?? [];
+        if (empty($orderList)) {
+            util::fail('没有数据需要导出');
+        }
+    }
+
 }

+ 3 - 0
biz-ghs/custom/classes/CustomClass.php

@@ -82,6 +82,7 @@ class CustomClass extends BaseClass
     public static function clearConsumeBalance($amount, $custom, $ghs, $shop, $staff, $clear)
     {
         $customId = $custom->id ?? 0;
+        $customName = $custom->name ?? '';
         $ghsId = $ghs->id ?? 0;
         $relateId = $clear->id ?? 0;
         $staffId = $staff->id ?? 0;
@@ -110,6 +111,7 @@ class CustomClass extends BaseClass
         $fromType = dict::getDict('fromType', 'shop');
         $cbData = [
             'customId' => $customId,
+            'customName' => $customName,
             'relateId' => $relateId,
             'onlinePay' => 1,
             'ptStyle' => 2,
@@ -229,6 +231,7 @@ class CustomClass extends BaseClass
         $fromType = dict::getDict('fromType', 'shop');
         $cbData = [
             'customId' => $customId,
+            'customName' => $customName,
             'relateId' => $cRechargeId,
             'onlinePay' => 1,
             'ptStyle' => 2,