Bläddra i källkod

退款和库存

shish 4 år sedan
förälder
incheckning
e8f797bc22

+ 9 - 2
app-hd/controllers/BaseController.php

@@ -3,6 +3,7 @@
 namespace hd\controllers;
 
 use biz\admin\classes\AdminClass as ClassesAdminClass;
+use biz\shop\classes\MainClass;
 use biz\sj\classes\SjClass;
 use bizHd\admin\classes\AdminClass;
 use biz\shop\classes\ShopAdminClass;
@@ -18,7 +19,7 @@ class BaseController extends PublicController
 {
 
     public $admin, $adminId, $adminAvatar, $account, $customId = 0, $custom;
-    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0, $mainId = 0, $shop = [], $shopAdminId = 0, $shopAdmin = [];
+    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shopId = 0, $mainId = 0, $main = [], $shop = [], $shopAdminId = 0, $shopAdmin = [];
     public $appId;
     public $isWx = false;
     public $isLogin = false;
@@ -64,7 +65,13 @@ class BaseController extends PublicController
                 util::fail('没有找到店铺');
             }
             $this->shop = $shop;
-            $this->mainId = $shop->mainId ?? 0;
+            $mainId = $shop->mainId ?? 0;
+            $this->mainId = $mainId;
+            $main = MainClass::getById($mainId, true);
+            if (empty($main)) {
+                util::fail('没有找到main信息');
+            }
+            $this->main = $main;
             $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $currentShopId, 'adminId' => $adminId], true);
             if (empty($shopAdmin)) {
                 util::logout('没有找到员工信息');

+ 4 - 1
app-hd/controllers/CategoryController.php

@@ -90,7 +90,10 @@ class CategoryController extends BaseController
         $where = [];
         $where['mainId'] = $this->mainId;
         $where['cId'] = $catId;
-        $where['flower'] = $get['flower'] ?? 0;
+        $flower = $get['flower'] ?? '';
+        if (is_numeric($flower)) {
+            $where['flower'] = $flower;
+        }
         $where['delStatus'] = $get['delStatus'] ?? 0;
         $status = $get['status'] ?? '';
         if (is_numeric($status)) {

+ 4 - 3
app-hd/controllers/MainController.php

@@ -102,8 +102,9 @@ class MainController extends BaseController
     public function actionMy()
     {
         $shop = $this->shop;
-        $balance = $shop->balance ?? 0.00;
-        $txBalance = $shop->txBalance ?? 0.00;
+        $main = $this->main;
+        $balance = $main->balance ?? 0.00;
+        $txBalance = $main->txBalance ?? 0.00;
         $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
         $shopImg = Yii::$app->params['hdImgHost'] . 'retail/default-img.png';
         $deadline = $sj['deadline'] ?? '';
@@ -113,7 +114,7 @@ class MainController extends BaseController
         $mobile = $relation['mobile'] ?? '';
         $sjName = $sj['name'] ?? '';
         $shopName = $shop->shopName ?? '';
-        $cashAccount = $shop->cashAccount ?? '';
+        $cashAccount = $main->cashAccount ?? '';
         $data = [
             'balance' => $balance,
             'txBalance' => $txBalance,

+ 2 - 0
app-hd/controllers/OrderController.php

@@ -307,6 +307,8 @@ class OrderController extends BaseController
         //订单30分钟后过期
         $expireTime = $now + 1800;
         $post['deadline'] = $expireTime;
+        $post['staffId'] = $this->shopAdminId ?? 0;
+        $post['staffName'] = $this->shopAdmin->name ?? '';
         //商城
         $post['fromType'] = 1;
         //客户

+ 1 - 1
biz-ghs/order/services/OrderService.php

@@ -683,7 +683,7 @@ class OrderService extends BaseService
         $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
         $shopAdminId = $order->shopAdminId ?? 0;
         $shopAdminName = $order->shopAdminName ?? '';
-        $event = '单';
+        $event = '单';
         if ($isPurchase) {
             $event = '客户采购';
             if (isset($custom->name) && !empty($custom->name)) {

+ 5 - 3
biz-hd/order/classes/OrderGoodsClass.php

@@ -24,7 +24,7 @@ class OrderGoodsClass extends BaseClass
     const ACTION_WASTAGE = 'wastage'; //取消消耗花材
     const ACTION_WASTAGE_CANCEL = 'wastageCancel'; //取消消耗花材
 
-    public static function addData($data)
+    public static function addData($data, $custom)
     {
         $orderSn = $data['orderSn'] ?? '';
         $sjId = $data['sjId'] ?? 0;
@@ -32,8 +32,9 @@ class OrderGoodsClass extends BaseClass
         $mainId = $data['mainId'] ?? 0;
         $goodsId = $data['goodsId'] ?? 0;
         $num = $data['num'] ?? 0;
+        $customName = $custom['name'] ?? '';
         //减库存
-        self::changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $num);
+        self::changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $num, $customName);
         return self::add($data);
     }
 
@@ -214,7 +215,7 @@ class OrderGoodsClass extends BaseClass
     }
 
     //销售成品库存变更方法(减库存)
-    public static function changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum)
+    public static function changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum, $customName)
     {
         //减成品库存
         $respond = GoodsClass::decreaseStock($goodsId, $mainId, $goodsNum);
@@ -229,6 +230,7 @@ class OrderGoodsClass extends BaseClass
         $data['goodsNum'] = $goodsNum;
         $data['oldStock'] = $oldStock;
         $data['newStock'] = $newStock;
+        $data['relateName'] = $customName;
         GoodsStockRecordClass::sellGoods($data);
         return true;
     }

+ 3 - 1
biz-hd/order/services/OrderService.php

@@ -37,6 +37,8 @@ class OrderService extends BaseService
         $sjId = $data['sjId'] ?? 0;
         $shopId = $data['shopId'] ?? 0;
         $mainId = $data['mainId'] ?? 0;
+        $staffId = $data['staffId'] ?? 0;
+        $staffName = $data['staffName'] ?? '';
 
         $groupCover = '';
 
@@ -144,7 +146,7 @@ class OrderService extends BaseService
                     'mainId' => $mainId,
                 ];
                 //库存变化在这里
-                OrderGoodsClass::addData($currentGoodsData);
+                OrderGoodsClass::addData($currentGoodsData, $custom);
                 $groupGoodsData[] = [
                     'goodsId' => $currentId,
                     'num' => $num,