shish 4 gadi atpakaļ
vecāks
revīzija
88fd6f4f15

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

@@ -3,6 +3,7 @@
 namespace ghs\controllers;
 
 use biz\admin\classes\AdminClass;
+use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopAdminClass;
 use biz\shop\classes\ShopClass;
 use biz\shop\classes\ShopExtClass;
@@ -17,7 +18,7 @@ use common\components\util;
 class BaseController extends PublicController
 {
     public $admin, $adminId, $adminAvatar, $account;
-    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shop = [], $shopExt = [], $shopId = 0, $mainId = 0, $lookShopId = 0, $shopAdminId = 0, $shopAdmin = [];
+    public $sjId = 0, $sj = [], $sjExtend = [], $signPackage, $shop = [], $shopExt = [], $shopId = 0, $mainId = 0, $main = [], $lookShopId = 0, $shopAdminId = 0, $shopAdmin = [];
     public $appId;
     public $isWx = false;
     public $isLogin = false;
@@ -62,7 +63,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('没有资产信息'.$this->shopId);
+            }
+            $this->main = $main;
             $shopExt = ShopExtClass::getByCondition(['shopId' => $currentShopId], true);
             if (empty($shopExt)) {
                 util::fail('门店信息有问题,请联系管理员');

+ 5 - 4
app-ghs/controllers/MainController.php

@@ -185,9 +185,11 @@ class MainController extends BaseController
     //我的 ssh 2021.1.30
     public function actionMy()
     {
-        $shop = $this->shop;
-        $balance = $shop->balance ?? 0.00;
-        $txBalance = $shop->txBalance ?? 0.00;
+        $shop = $this->shop ?? null;
+        $main = $this->main ?? null;
+        $balance = $main->balance ?? 0.00;
+        $txBalance = $main->txBalance ?? 0.00;
+        $cashAccount = $main->cashAccount ?? '';
         $sj = isset($this->sj) && !empty($this->sj) ? $this->sj->attributes : [];
         $shopImg = Yii::$app->params['ghsImgHost'] . 'retail/default-img.png';
         $deadline = $sj['deadline'] ?? '';
@@ -197,7 +199,6 @@ class MainController extends BaseController
         $mobile = $relation['mobile'] ?? '';
         $sjName = $sj['name'] ?? '';
         $shopName = $shop->shopName ?? '';
-        $cashAccount = $shop->cashAccount ?? '';
         $data = [
             'balance' => $balance,
             'txBalance' => $txBalance,

+ 2 - 1
app-ghs/controllers/RechargeController.php

@@ -17,7 +17,7 @@ class RechargeController extends BaseController
     //充值记录 ssh 2021.2.21
     public function actionList()
     {
-        $where = ['shopId' => $this->shopId, 'payStatus' => RechargeClass::PAY_STATUS_HAS_PAY];
+        $where = ['mainId' => $this->mainId, 'payStatus' => RechargeClass::PAY_STATUS_HAS_PAY];
         $list = RechargeClass::getRechargeList($where);
         util::success($list);
     }
@@ -45,6 +45,7 @@ class RechargeController extends BaseController
             'sjId' => $this->sjId,
             'sjStyle' => SjClass::STYLE_RETAIL,
             'shopId' => $this->shopId,
+            'mainId' => $this->mainId,
             'modPrice' => 0,
             'remark' => '',
             'shopAdminId' => $this->shopAdminId,

+ 1 - 1
app-ghs/controllers/ShopAdminController.php

@@ -161,7 +161,7 @@ class ShopAdminController extends BaseController
     public function actionList()
     {
         $where = [];
-        $where['shopId'] = $this->shopId;
+        $where['mainId'] = $this->mainId;
         $where['delStatus'] = 0;
         $where['isPt'] = 0;
         $list = ShopAdminService::getAdminList($where);

+ 5 - 4
app-ghs/controllers/ShopController.php

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopAdminClass;
 use biz\sj\services\MerchantExtendService;
 use bizGhs\admin\classes\AdminClass;
@@ -24,8 +25,8 @@ class ShopController extends BaseController
     //获取当前门店信息 ssh 2021.3.27
     public function actionCurrentShop()
     {
-        $shop = $this->shop->attributes;
-        util::success($shop);
+        $main = $this->main;
+        util::success($main);
     }
 
     //门店列表 ssh 2021.1.14
@@ -206,11 +207,11 @@ class ShopController extends BaseController
             util::fail('请输入开户行');
         }
         $shopAdmin = $this->shopAdmin;
-        $shopId = $shopAdmin->shopId ?? 0;
+        $mainId = $shopAdmin->mainId ?? 0;
         if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
             util::fail('超管才能操作');
         }
-        ShopClass::updateById($shopId, ['cashAccount' => $cashAccount, 'cashName' => $cashName, 'cashBank' => $cashBank]);
+        MainClass::updateById($mainId, ['cashAccount' => $cashAccount, 'cashName' => $cashName, 'cashBank' => $cashBank]);
         util::complete();
     }
 

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

@@ -569,6 +569,8 @@ class OrderService extends BaseService
             }
         }
         $mainId = $shop->mainId ?? 0;
+        $sjId = $order->sjId ?? 0;
+        $shopId = $order->shopId ?? 0;
         $capital = [
             'capitalType' => $capitalType,
             'relateId' => $orderId,
@@ -578,6 +580,8 @@ class OrderService extends BaseService
             'payWay' => $payWay,
             'event' => $event,
             'mainId' => $mainId,
+            'sjId' => $sjId,
+            'shopId' => $shopId,
             'shopAdminId' => $shopAdminId,
             'shopAdminName' => $shopAdminName,
         ];
@@ -605,7 +609,7 @@ class OrderService extends BaseService
         $order->payTime = date("Y-m-d H:i:s");
         $order->save();
 
-        //入队列,花材统计
+        //新订单进入队列,用于花材统计
         OrderClass::newOrderAddQueue($order);
 
         //员工业绩、总业绩增加

+ 4 - 0
biz/pt/classes/PtAssetClass.php

@@ -96,6 +96,7 @@ class PtAssetClass extends BaseClass
 
         $id = $order->id;
         $event = "客户结帐给商家-{$sjName}(单号:{$order->orderSn})";
+        $mainId = $shop->mainId ?? 0;
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
@@ -111,6 +112,7 @@ class PtAssetClass extends BaseClass
             'ptStyle' => $ptStyle,
             'shopName' => $shop->shopName,
             'sjName' => $shop->merchantName,
+            'mainId' => $mainId,
         ];
         PtYeChangeClass::addChange($change, true);
     }
@@ -195,6 +197,7 @@ class PtAssetClass extends BaseClass
         }
 
         $id = $order->id;
+        $mainId = $shop->mainId ?? 0;
         $event = "【{$shop->merchantName} {$shop->shopName}】 充值{$amount}元 订单号:{$order->orderSn}";
         if ($order->shopAdminId == 0) {
             $event = "系统为【{$shop->merchantName} {$shop->shopName}】 充值{$amount}元 订单号:{$order->orderSn}";
@@ -210,6 +213,7 @@ class PtAssetClass extends BaseClass
             'event' => $event,
             'sjId' => $order->sjId,
             'shopId' => $order->shopId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $ptStyle,
             'shopName' => $shop->shopName,

+ 37 - 21
biz/shop/classes/ShopClass.php

@@ -193,11 +193,16 @@ class ShopClass extends BaseClass
     //客户结帐增加余额 shish 20210729
     public static function customClearAddBalance($shop, $order)
     {
-        $balance = bcadd($shop->balance, $order->actPrice, 2);
-        $txBalance = bcadd($shop->txBalance, $order->actPrice, 2);
-        $shop->balance = $balance;
-        $shop->txBalance = $txBalance;
-        $shop->save();
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有找到资产信息');
+        }
+        $balance = bcadd($main->balance, $order->actPrice, 2);
+        $txBalance = bcadd($main->txBalance, $order->actPrice, 2);
+        $main->balance = $balance;
+        $main->txBalance = $txBalance;
+        $main->save();
         $clearId = $order->id ?? 0;
         $tx = dict::getDict('yeTx', 'can');
         $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
@@ -220,6 +225,7 @@ class ShopClass extends BaseClass
             'shopId' => $shop->id,
             'tx' => $tx,
             'ptStyle' => $shop->ptStyle,
+            'mainId' => $mainId,
         ];
         ShopYeChangeClass::addChange($change, true);
 
@@ -268,14 +274,18 @@ class ShopClass extends BaseClass
     //客户下单引起的余额增加 shish 20210520
     public static function customKdAddBalance($shop, $amount, $order, $capitalType)
     {
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有找到资产信息');
+        }
         //门店余额增加
-        $currentBalance = bcadd($shop->balance, $amount, 2);
-        $shop->balance = $currentBalance;
-        $shop->totalRecharge = bcadd($shop->totalRecharge, $amount, 2);
+        $currentBalance = bcadd($main->balance, $amount, 2);
+        $main->balance = $currentBalance;
         //可提现余额同步增加
-        $currentTx = bcadd($shop->txBalance, $amount, 2);
-        $shop->txBalance = $currentTx;
-        $shop->save();
+        $currentTx = bcadd($main->txBalance, $amount, 2);
+        $main->txBalance = $currentTx;
+        $main->save();
 
         $ptStyle = $shop->ptStyle ?? dict::getDict('ptStyle', 'hd');
         $customName = '客户';
@@ -291,7 +301,6 @@ class ShopClass extends BaseClass
         $id = $order->id;
         $event = $customName . "下单{$amount}元";
         $tx = dict::getDict('yeTx', 'can');
-        $mainId = $shop->mainId ?? 0;
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
@@ -315,23 +324,29 @@ class ShopClass extends BaseClass
     //$fix = true 余额只能在指定门店使用
     public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)
     {
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有找到资产信息');
+        }
         //门店余额增加
-        $currentBalance = bcadd($shop->balance, $amount, 2);
-        $shop->balance = $currentBalance;
+        $currentBalance = bcadd($main->balance, $amount, 2);
+        $main->balance = $currentBalance;
         $currentTotalRecharge = bcadd($shop->totalRecharge, $amount, 2);
-        $shop->totalRecharge = $currentTotalRecharge;
+        $main->totalRecharge = $currentTotalRecharge;
         //定向消费余额
         if ($fix) {
-            $currentFix = bcadd($shop->fixBalance, $amount, 2);
-            $shop->fixBalance = $currentFix;
+            $currentFix = bcadd($main->fixBalance, $amount, 2);
+            $main->fixBalance = $currentFix;
         }
-        $currentTx = $shop->txBalance;
+        $currentTx = $main->txBalance;
         //提现余额
         if ($tx == dict::getDict('yeTx', 'can')) {
-            $currentTx = bcadd($shop->txBalance, $amount, 2);
-            $shop->txBalance = $currentTx;
+            $currentTx = bcadd($main->txBalance, $amount, 2);
+            $main->txBalance = $currentTx;
         }
-        $shop->save();
+        $main->save();
+
         $order->totalRecharge = $currentTotalRecharge;
         $order->save();
 
@@ -352,6 +367,7 @@ class ShopClass extends BaseClass
             'event' => $event,
             'sjId' => $order->sjId,
             'shopId' => $order->shopId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $shop->ptStyle,
         ];

+ 20 - 14
biz/sj/classes/CashClass.php

@@ -4,6 +4,7 @@ namespace biz\sj\classes;
 
 use biz\pt\classes\PtAssetClass;
 use biz\pt\classes\PtYeChangeClass;
+use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopClass;
 use biz\shop\classes\ShopYeChangeClass;
 use bizHd\base\classes\BaseClass;
@@ -65,22 +66,24 @@ class CashClass extends BaseClass
     {
         $sjId = $params['sjId'] ?? 0;
         $shopId = $params['shopId'] ?? 0;
+        $shop = ShopClass::getById($shopId, true);
         if (empty($shopId)) {
             util::fail('没有找到门店');
         }
-        $cashList = self::getByCondition(['shopId' => $shopId, 'status' => 1], true);
-        if (!empty($cashList)) {
-            util::fail('已提交过了');
+        $mainId = $shop->mainId ?? 0;
+        $main = MainClass::getLockById($mainId);
+        if (empty($main)) {
+            util::fail('没有找到余额');
         }
-        $shop = ShopClass::getLockById($shopId);
-        if (empty($shop)) {
-            util::fail('没有找到门店哦');
+        $cashList = self::getByCondition(['mainId' => $mainId, 'status' => 1], true);
+        if (!empty($cashList)) {
+            util::fail('已有提现审核待审核');
         }
-        $txBalance = $shop->txBalance ?? 0.00;
+        $txBalance = $main->txBalance ?? 0.00;
         if ($txBalance <= 0) {
             util::fail('可提现余额不足');
         }
-        if (bccomp($txBalance, $shop->balance) == 1) {
+        if (bccomp($txBalance, $main->balance) == 1) {
             util::fail('余额有问题,总余额比可提现余额还少');
         }
         $miniCashAmount = dict::getDict('miniCashAmount');
@@ -91,12 +94,12 @@ class CashClass extends BaseClass
         }
 
         //可提现余额减少,总余额减少,冻结金额增加
-        $currentTxBalance = bcsub($shop->txBalance, $txBalance, 2);
-        $shop->txBalance = $currentTxBalance;
-        $shop->freezeBalance = bcadd($shop->freezeBalance, $txBalance, 2);
-        $currentBalance = bcsub($shop->balance, $txBalance, 2);
-        $shop->balance = $currentBalance;
-        $shop->save();
+        $currentTxBalance = bcsub($main->txBalance, $txBalance, 2);
+        $main->txBalance = $currentTxBalance;
+        $main->freezeBalance = bcadd($main->freezeBalance, $txBalance, 2);
+        $currentBalance = bcsub($main->balance, $txBalance, 2);
+        $main->balance = $currentBalance;
+        $main->save();
 
         //应转金额
         $ptStyle = $shop->ptStyle;
@@ -118,6 +121,7 @@ class CashClass extends BaseClass
         $params['shopName'] = $shopName;
         $params['amount'] = $txBalance;
         $params['beAmount'] = $beAmount;
+        $params['mainId'] = $mainId;
         $return = self::add($params, true);
 
         $tx = dict::getDict('yeTx', 'can');
@@ -137,6 +141,7 @@ class CashClass extends BaseClass
             'shopId' => $shopId,
             'tx' => $tx,
             'ptStyle' => $ptStyle,
+            'mainId' => $mainId
         ];
         ShopYeChangeClass::addChange($change, true);
 
@@ -183,6 +188,7 @@ class CashClass extends BaseClass
             'ptStyle' => $ptStyle,
             'shopName' => $shop->shopName,
             'sjName' => $shop->merchantName,
+            'mainId' => $mainId
         ];
         PtYeChangeClass::addChange($change, true);
 

+ 19 - 1
sql.txt

@@ -12,6 +12,9 @@ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `totalSale` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计销售额',
   `totalStockIn` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计入库',
   `totalStockOut` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计出库',
+  `cashName` varchar(100) NOT NULL DEFAULT '' COMMENT '收款人姓名',
+  `cashAccount` varchar(50) NOT NULL DEFAULT '' COMMENT '银行卡号,银行帐号',
+  `cashBank` varchar(50) NOT NULL DEFAULT '' COMMENT '开户行',
   `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
   `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
 )COMMENT='中央,中控';
@@ -46,4 +49,19 @@ ALTER TABLE xhStatIncomeMonth ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央i
 === 资产相关表中央化 shish 20220313
 
 
-执行供货商资产中央化 ./yii init/ghs-center 【库存也要中央化处理,要加入时来】
+执行供货商资产中央化 ./yii init/ghs-center 【库存也要中央化处理,要加入时来】!!!!
+
+DROP TABLE IF EXISTS `xhStaffMap`;
+CREATE TABLE `xhStaffMap` (
+  `id` INT(11) NOT NULL AUTO_INCREMENT,
+  `staffId` INT(11) NOT NULL DEFAULT '0' COMMENT '员工id',
+  `sjId` INT(11) NOT NULL DEFAULT '0' COMMENT '商家id',
+  `shopId` INT(11) NOT NULL DEFAULT '0' COMMENT '门店id',
+  `ptStyle` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '所属平台 1花店 2供货商 请查看dict.php',
+  `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
+  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
+  PRIMARY KEY (`id`)
+) COMMENT='门店员工关系';
+ALTER TABLE xhStaff COMMENT '员工';
+
+==== 员工中央化 shish 20223013