ソースを参照

结账和充值

shish 1 年間 前
コミット
029bd40d87

+ 36 - 0
app-mall/controllers/BalanceChangeController.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace mall\controllers;
+
+use bizMall\balance\classes\BalanceChangeClass;
+use common\components\dateUtil;
+use common\components\util;
+use Yii;
+
+class BalanceChangeController extends BaseController
+{
+
+    public $guestAccess = [];
+
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $hdId = $get['hdId'] ?? 0;
+        if (!empty($hdId)) {
+            //在BaseController已经判断了是否本人的花店
+            $where['hdId'] = $hdId;
+        }
+        $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']]];
+        }
+        $respond = BalanceChangeClass::getChangeList($where);
+        util::success($respond);
+    }
+
+}

+ 34 - 38
app-mall/controllers/BaseController.php

@@ -32,49 +32,45 @@ class BaseController extends PublicController
         Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'mall');
         $this->isWx = util::isWx();
         $userId = jwt::getLoginId();
-        if (!empty($userId)) {
-            $this->userId = $userId;
-            $user = UserClass::getById($userId, true);
-            if (empty($user)) {
-                if (!in_array($action->id, $this->guestAccess)){
-                    util::fail('请先登录');
-                }
+        if (empty($userId)) {
+            if (!in_array($action->id, $this->guestAccess)) {
+                util::fail('请先登录');
+            }
+        }
+        $this->userId = $userId;
+        $user = UserClass::getById($userId, true);
+        if (empty($user)) {
+            if (!in_array($action->id, $this->guestAccess)) {
+                util::fail('请先登录');
             }
-            $this->user = $user;
-            $shopId = Yii::$app->request->get('account', 0);
-            if (!empty($shopId)) {
-                $this->shopId = $shopId;
-                $shop = ShopClass::getById($shopId, true);
-                if (!empty($shop)) {
-                    $this->shop = $shop;
-                    $mainId = $shop->mainId ?? 0;
-                    $main = MainClass::getById($mainId, true);
-                    $this->main = $main;
-                    $this->mainId = $mainId;
-                    $hdId = Yii::$app->request->get('hdId', 0);
-                    $hd = HdClass::getById($hdId, true);
-                    if (!empty($hd)) {
-                        if ($hd->userId != $this->userId) {
-                            util::fail('不是你的花店,无法访问哦');
-                        }
-                        if ($shopId != $hd->shopId) {
-                            util::fail('花店信息有问题哦');
-                        }
-                        $this->hd = $hd;
-                        $customId = $hd->customId ?? 0;
-                        $custom = CustomClass::getById($customId, true);
-                        $this->custom = $custom;
-                    } else {
-                        $respond = CustomClass::buildRelation($shop, $user);
-                        $hd = $respond['hd'];
-                        $custom = $respond['custom'];
-                        $this->hd = $hd;
-                        $this->custom = $custom;
+        }
+        $this->user = $user;
+        $shopId = Yii::$app->request->get('account', 0);
+        if (!empty($shopId)) {
+            $this->shopId = $shopId;
+            $shop = ShopClass::getById($shopId, true);
+            if (!empty($shop)) {
+                $this->shop = $shop;
+                $mainId = $shop->mainId ?? 0;
+                $main = MainClass::getById($mainId, true);
+                $this->main = $main;
+                $this->mainId = $mainId;
+                $hdId = Yii::$app->request->get('hdId', 0);
+                $hd = HdClass::getById($hdId, true);
+                if (!empty($hd)) {
+                    if ($hd->userId != $this->userId) {
+                        util::fail('不是你的花店,无法访问哦');
+                    }
+                    if ($shopId != $hd->shopId) {
+                        util::fail('花店信息有问题哦');
                     }
+                    $this->hd = $hd;
+                    $customId = $hd->customId ?? 0;
+                    $custom = CustomClass::getById($customId, true);
+                    $this->custom = $custom;
                 }
             }
         }
-
         return parent::beforeAction($action);
     }
 

+ 1 - 8
app-mall/controllers/MemberChangeController.php

@@ -29,14 +29,7 @@ class MemberChangeController extends BaseController
         }
         $hdId = $get['hdId'] ?? 0;
         if (!empty($hdId)) {
-            $hdInfo = HdClass::getById($hdId, true);
-            if (empty($hdInfo)) {
-                util::fail('找不到门店');
-            }
-            $shopId = $this->shopId;
-            if ($hdInfo->shopId != $shopId) {
-                util::fail('不是你的门店');
-            }
+            //BaseController已经有判断花店id是不是本人的
             $where['hdId'] = $hdId;
         }
         $respond = MemberChangeClass::getChangeList($where);

+ 0 - 3
app-mall/controllers/OrderController.php

@@ -753,9 +753,6 @@ class OrderController extends BaseController
     public function actionList()
     {
         $userId = $this->userId;
-        if (empty($userId)) {
-            util::success(['list' => [], 'moreData' => 0, 'totalNum' => 0, 'totalPage' => 0]);
-        }
         $where = ['userId' => $userId];
         $list = OrderService::getOrderList($where);
         util::success($list);

+ 36 - 0
app-mall/controllers/SettleController.php

@@ -18,6 +18,42 @@ class SettleController extends BaseController
 
     public $guestAccess = [];
 
+    public function actionGetDetail()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $settle = SettleClass::getById($id);
+        if ($settle['customUserId'] != $this->userId) {
+            util::fail('不是你的账单');
+        }
+        $respond = SettleClass::getMyDetail($settle);
+        util::success($respond);
+    }
+
+    public function actionCancelSettle()
+    {
+        util::fail('开发中');
+    }
+
+    public function actionGetList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        if (isset($get['status']) && is_numeric($get['status'])) {
+            $where['status'] = $get['status'];
+        }
+        $hdId = $get['hdId'] ?? 0;
+        if (!empty($hdId)) {
+            //BaseController文件有判断是否本人花店,这里不需要再判断
+            $where['hdId'] = $hdId;
+        }
+        $where['shopId'] = $this->shopId;
+        $list = \bizMall\settle\classes\SettleClass::getSettleList($where);
+        $totalAmount = SettleClass::sum(['shopId' => $this->shopId, 'status' => 2, 'hdId' => $hdId], 'actPrice');
+        $list['totalAmount'] = floatval($totalAmount);
+        util::success($list);
+    }
+
     //创建结账和充值单 ssh 20250709
     public function actionCreateOrder()
     {

+ 30 - 0
biz-mall/balance/classes/BalanceChangeClass.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace bizMall\balance\classes;
+
+use Yii;
+use bizMall\base\classes\BaseClass;
+
+class BalanceChangeClass extends BaseClass
+{
+
+    public static $baseFile = '\bizMall\balance\models\BalanceChange';
+
+    public static function getChangeList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
+        if (!empty($data['list'])) {
+            foreach ($data['list'] as $k => $v) {
+                $settleAmount = $v['settleAmount'] ?? 0;
+                $orderAmount = $v['orderAmount'] ?? 0;
+                $sum = bcadd($settleAmount, $orderAmount, 2);
+                $amount = $v['amount'] ?? 0;
+                $becomeBalance = bcsub($amount, $sum, 2);
+                $becomeBalance = floatval($becomeBalance);
+                $data['list'][$k]['becomeBalance'] = $becomeBalance;
+            }
+        }
+        return $data;
+    }
+
+}

+ 13 - 0
biz-mall/balance/models/BalanceChange.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizMall\balance\models;
+use bizMall\base\models\Base;
+
+class BalanceChange extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhBalanceChange';
+    }
+
+}

+ 12 - 0
biz-mall/balance/services/BalanceChangeService.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizMall\balance\services;
+
+use bizMall\base\services\BaseService;
+
+class BalanceChangeService extends BaseService
+{
+
+    public static $baseFile = '\bizMall\balance\classes\BalanceChangeClass';
+
+}

+ 1 - 2
biz-mall/member/classes/MemberChangeClass.php

@@ -12,8 +12,7 @@ class MemberChangeClass extends BaseClass
 
     public static function getChangeList($where)
     {
-        $data = self::getList('*', $where, 'addTime DESC,id DESC');
-        return $data;
+        return self::getList('*', $where, 'addTime DESC,id DESC');
     }
 
 }

+ 12 - 12
biz-mall/order/services/OrderService.php

@@ -15,6 +15,7 @@ use bizMall\promote\services\CouponService;
 use bizMall\shop\classes\ShopClass;
 use bizMall\user\classes\UserAssetClass;
 use common\components\dict;
+use common\components\imgUtil;
 use common\components\orderSn;
 use common\components\stringUtil;
 use common\components\util;
@@ -25,7 +26,7 @@ class OrderService extends BaseService
 
     public static $baseFile = '\bizMall\order\classes\OrderClass';
 
-    public static function createOrder($data,$custom)
+    public static function createOrder($data, $custom)
     {
         $customId = $data['customId'] ?? 0;
         $hdId = $data['hdId'] ?? 0;
@@ -229,25 +230,24 @@ class OrderService extends BaseService
         if (empty($data['list'])) {
             return $data;
         }
-        $orderSns = array_column($data['list'], 'orderSn');
+        $list = $data['list'];
+        $orderSns = array_column($list, 'orderSn');
         $goodsList = OrderGoodsService::getGoodsListByOrderSns($orderSns);
-        $sjIdList = array_column($data['list'], 'sjId');
-        $sjIdList = array_filter(array_unique($sjIdList));
-        $merchantList = MerchantService::getByIds($sjIdList, null, 'id');
         $periodData = [0 => '上午', 1 => '下午', 2 => '晚上'];
         foreach ($data['list'] as $key => $val) {
             $id = $val['id'];
-            $data['list'][$key]['goodsInfoList'] = isset($goodsList[$id]) ? $goodsList[$id] : [];
-            $sjId = $val['sjId'];
-            $data['list'][$key]['name'] = isset($merchantList[$sjId]['name']) ? $merchantList[$sjId]['name'] : '';
-            $data['list'][$key]['reachTime'] = OrderClass::getReachTime($val);
-            $requireReachTime = '';
+            $goodsInfoList = isset($goodsList[$id]) ? $goodsList[$id] : [];
+            $data['list'][$key]['goodsInfoList'] = $goodsInfoList;
+            $reachTime = OrderClass::getReachTime($val);
+            $data['list'][$key]['reachTime'] = $reachTime;
+            $requireTime = '';
             if ($val['reachDate'] != '0000-00-00') {
                 $reachPeriodId = $val['reachPeriod'];
                 $reachPeriod = isset($periodData[$reachPeriodId]) ? $periodData[$reachPeriodId] : '上午';
-                $requireReachTime = date("m-d", strtotime($val['reachDate'])) . ' ' . $reachPeriod;
+                $requireTime = date("m-d", strtotime($val['reachDate'])) . ' ' . $reachPeriod;
             }
-            $data['list'][$key]['requireReachTime'] = $requireReachTime;
+            $data['list'][$key]['requireReachTime'] = $requireTime;
+            $data['list'][$key]['smallHdAvatar'] = imgUtil::groupImg('') . "?x-oss-process=image/resize,m_fill,h_80,w_80";
         }
         return $data;
     }

+ 25 - 0
biz-mall/settle/classes/SettleClass.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace bizMall\settle\classes;
+
+use common\components\imgUtil;
+use Yii;
+use bizMall\base\classes\BaseClass;
+
+class SettleClass extends BaseClass
+{
+
+    public static $baseFile = '\bizMall\settle\models\Settle';
+
+    public static function getSettleList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        if (!empty($data['list'])) {
+            foreach ($data['list'] as $k => $v) {
+                $data['list'][$k]['smallHdAvatar'] = imgUtil::groupImg('') . "?x-oss-process=image/resize,m_fill,h_80,w_80";
+            }
+        }
+        return $data;
+    }
+
+}

+ 13 - 0
biz-mall/settle/models/Settle.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizMall\settle\models;
+use bizMall\base\models\Base;
+
+class Settle extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhSettle';
+    }
+
+}

+ 12 - 0
biz-mall/settle/services/SettleService.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizMall\settle\services;
+
+use bizMall\base\services\BaseService;
+
+class SettleService extends BaseService
+{
+
+    public static $baseFile = '\bizMall\settle\classes\SettleClass';
+
+}