shish 4 سال پیش
والد
کامیت
eec271a222

+ 2 - 12
app-ghs/controllers/ConsoleController.php

@@ -33,10 +33,6 @@ class ConsoleController extends BaseController
             }
         }
 
-        //今天客户与粉丝数
-        $userData = StatUserService::getTodayNum($this->mainId);
-        $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
-
         //今天销售
         $sale = StatSaleClass::getByCondition(['mainId' => $this->mainId, 'time' => date('Ymd')]);
         $todaySale = $sale['amount'] ?? 0;
@@ -49,7 +45,7 @@ class ConsoleController extends BaseController
         //访客数
         $visitCustom = StatVisitClass::getVisitNum($this->mainId);
 
-        $todayData = ['income' => $todaySale, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom];
+        $todayData = ['income' => $todaySale, 'order' => $orderNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom];
 
         $incomeStat = [];
 
@@ -80,13 +76,7 @@ class ConsoleController extends BaseController
             ];
         }
 
-        util::success([
-            'asset' => $shopInfo,
-            'notice' => $notice,
-            'todayData' => $todayData,
-            'incomeStat' => $incomeStat,
-            'menu' => $menu,
-        ]);
+        util::success(['asset' => $shopInfo,'notice' => $notice,'todayData' => $todayData,'incomeStat' => $incomeStat,'menu' => $menu,]);
     }
 
     //常用初始化

+ 3 - 31
app-hd/controllers/ConsoleController.php

@@ -39,26 +39,16 @@ class ConsoleController extends BaseController
                     $num = ceil($remain / 86400);
                     $title = "您的试用期还有{$num}天,点此免费续期";
                 }
-                //暂时关闭续期提示
-                //$notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/admin/recharge/renew']]);
             } else {
-                $title = '您的试用期已结束,请及时续费';
                 if ($remain > 0) {
                     $num = ceil($remain / 86400);
                     $title = "您的试用期还有{$num}天,请及时续费";
                 }
-                //暂时关闭续期提示
-                //$notice = array_merge($notice, [['title' => $title, 'action' => '续期', 'page' => '/pagesClient/official/renewal']]);
             }
         }
 
         //引导关注公众号
         $admin = $this->admin;
-        $subscribe = $admin['subscribe'] ?? 0;
-        if ($subscribe == 0) {
-            //$notice = array_merge($notice, [['title' => '开启提醒,批发店花材做特价及时通知您', 'action' => '开启', 'page' => '/pagesClient/official/warn']]);
-        }
-
         if ($isMini == 1 && !empty($admin)) {
             $miniOpenId = $admin['miniOpenId'] ?? '';
             if (empty($miniOpenId)) {
@@ -70,36 +60,18 @@ class ConsoleController extends BaseController
             //今天访客
             $todayVisit = 0;
             //今天开单
-            $orderData = StatOrderService::getTodayNum($this->shopId);
+            $orderData = StatOrderService::getTodayNum($this->mainId);
             $todayOrder = isset($orderData['riseNum']) ? $orderData['riseNum'] : 0;
             //今天收入
-            $incomeData = StatIncomeService::getTodayNum($this->shopId);
+            $incomeData = StatIncomeService::getTodayNum($this->mainId);
             $todayIncome = isset($incomeData['amount']) ? $incomeData['amount'] : 0;
-            //今天新学员数
-            $newStudent = StatStudentClass::getTodayNum($this->shop);
-            //今日概况
         } else {
             $todayVisit = 0;
             $todayIncome = 0.00;
             $todayOrder = 0;
-            $newStudent = 0;
         }
-        $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => $newStudent];
+        $todayData = ['visit' => $todayVisit, 'income' => $todayIncome, 'order' => $todayOrder, 'newStudent' => 0];
         $incomeStat = [];
-        if (httpUtil::isMiniProgram() == false) {
-            //当月的收入
-            $currentMonthIncome = StatIncomeMonthService::getCurrentMonthIncome($this->shopId);
-            //上个月收入
-            $previousMonthIncome = StatIncomeMonthService::getPreviousMonthIncome($this->shopId);
-            //最近7天收入变化趋势
-            $latestIncome = StatIncomeService::getLatestSevenDay($this->shopId);
-            $incomeStat = [
-                'month' => $currentMonthIncome,
-                'week' => 999,
-                'previousMonth' => $previousMonthIncome,
-                'list' => $latestIncome,
-            ];
-        }
         $visitStat = [
             'month' => 1999,
             'week' => 999,

+ 14 - 9
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -3,6 +3,7 @@
 namespace bizGhs\order\classes;
 
 use biz\ghs\classes\GhsClass;
+use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopCapitalClass;
 use biz\shop\classes\ShopClass;
 use biz\stat\classes\StatCgClass;
@@ -243,17 +244,22 @@ class PurchaseOrderClass extends BaseClass
             if (empty($shop)) {
                 util::fail('没有找到门店');
             }
+            $mainId = $shop->mainId ?? 0;
+            $main = MainClass::getLockById($mainId);
+            if (empty($main)) {
+                util::fail('没有资产信息');
+            }
             //支出增加
-            $currentTotalExpend = bcadd($shop->totalExpend, $currentPrice, 2);
-            $shop->totalExpend = $currentTotalExpend;
+            $currentTotalExpend = bcadd($main->totalExpend, $currentPrice, 2);
+            $main->totalExpend = $currentTotalExpend;
+            $main->save();
+
             //采购增加
             $shop->cgFinish += 1;
             $shop->totalPurchaseOrder += 1;
             $currentTotalPurchase = bcadd($shop->totalPurchase, $currentPrice, 2);
             $shop->totalPurchase = $currentTotalPurchase;
-            //应付供货商增加
-            $currentMayPay = bcadd($shop->mayPay, $currentPrice, 2);
-            $shop->mayPay = $currentMayPay;
+            $shop->save();
 
             //供应商资产增加
             $ghsId = $data['ghsId'] ?? 0;
@@ -263,10 +269,7 @@ class PurchaseOrderClass extends BaseClass
             }
             $ghs->debt = GhsClass::DEBT_YES;
             $ghs->debtAmount = bcadd($ghs->debtAmount, $currentPrice, 2);
-            if ($ghs->debtNum == 0) {
-                $shop->mayPayNum += 1;
-            }
-            $shop->save();
+
             $ghs->debtNum += 1;
             $ghs->expendAmount = bcadd($ghs->expendAmount, $currentPrice, 2);
             $ghs->expendNum += 1;
@@ -308,6 +311,7 @@ class PurchaseOrderClass extends BaseClass
             $sjId = $order->sjId ?? 0;
             $shopId = $order->shopId ?? 0;
             $event = '采购';
+            $mainId = $shop->mainId ?? 0;
             $capitalData = [
                 'capitalType' => $capitalType,
                 'io' => 0,
@@ -317,6 +321,7 @@ class PurchaseOrderClass extends BaseClass
                 'sjId' => $sjId,
                 'shopId' => $shopId,
                 'event' => $event,
+                'mainId' => $mainId
             ];
             ShopCapitalClass::addCapital($capitalData);
 

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

@@ -559,8 +559,6 @@ class OrderService extends BaseService
         $orderId = $order->id;
         $orderSn = $order->orderSn;
         $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
-        $sjId = $order->sjId ?? 0;
-        $shopId = $order->shopId ?? 0;
         $shopAdminId = $order->shopAdminId ?? 0;
         $shopAdminName = $order->shopAdminName ?? '';
         $event = '开单';
@@ -570,6 +568,7 @@ class OrderService extends BaseService
                 $event = $custom->name . '采购';
             }
         }
+        $mainId = $shop->mainId ?? 0;
         $capital = [
             'capitalType' => $capitalType,
             'relateId' => $orderId,
@@ -578,8 +577,7 @@ class OrderService extends BaseService
             'totalIncome' => $currentTotalIncome,
             'payWay' => $payWay,
             'event' => $event,
-            'sjId' => $sjId,
-            'shopId' => $shopId,
+            'mainId' => $mainId,
             'shopAdminId' => $shopAdminId,
             'shopAdminName' => $shopAdminName,
         ];
@@ -621,7 +619,7 @@ class OrderService extends BaseService
 
         /**客户资产变化**/
         if ($payWay == dict::getDict('payWay', 'debtPay')) {
-            CustomClass::cgDebtAmountAdd($custom,$order);
+            CustomClass::cgDebtAmountAdd($custom, $order);
         }
         $custom->buyNum += 1;
         $custom->buyAmount = bcadd($custom->buyAmount, $amount, 2);

+ 3 - 13
biz-hd/stat/classes/StatIncomeClass.php

@@ -18,21 +18,11 @@ class StatIncomeClass extends BaseClass
     public static function updateOrInsert($shop, $amount)
     {
         $time = date('Ymd');
-        $shopId = $shop->id;
-        $where = [
-            'shopId' => $shopId,
-            'time' => $time,
-        ];
+        $mainId = $shop->mainId ?? 0;
+        $where = ['mainId' => $mainId, 'time' => $time];
         $model = self::getByCondition($where, true);
         if (empty($model)) {
-            $data = [
-                'shopId' => $shopId,
-                'sjId' => $shop->sjId,
-                'time' => $time,
-                'amount' => 0,
-                'totalAmount' => $shop->totalIncome,
-                'createTime' => date('Y-m-d H:i:s'),
-            ];
+            $data = ['mainId' => $mainId, 'time' => $time, 'amount' => 0, 'totalAmount' => $shop->totalIncome, 'createTime' => date('Y-m-d H:i:s')];
             $model = self::add($data, true);
         }
         $id = $model->id;

+ 3 - 13
biz-hd/stat/classes/StatIncomeMonthClass.php

@@ -14,21 +14,11 @@ class StatIncomeMonthClass extends BaseClass
     public static function updateOrInsert($shop, $amount)
     {
         $time = date('Ym');
-        $shopId = $shop->id;
-        $where = [
-            'shopId' => $shopId,
-            'time' => $time,
-        ];
+        $mainId = $shop->mainId ?? 0;
+        $where = ['mainId' => $mainId, 'time' => $time,];
         $model = self::getByCondition($where, true);
         if (empty($model)) {
-            $data = [
-                'shopId' => $shopId,
-                'sjId' => $shop->sjId,
-                'time' => $time,
-                'amount' => 0,
-                'totalAmount' => $shop->totalIncome,
-                'createTime' => date('Y-m-d H:i:s'),
-            ];
+            $data = ['mainId' => $mainId, 'time' => $time, 'amount' => 0, 'totalAmount' => $shop->totalIncome, 'createTime' => date('Y-m-d H:i:s')];
             $model = self::add($data, true);
         }
         $id = $model->id;

+ 3 - 7
biz-hd/stat/classes/StatOrderClass.php

@@ -14,15 +14,11 @@ class StatOrderClass extends BaseClass
     public static function updateOrInsert($shop)
     {
         $time = date('Ymd');
-        $shopId = $shop->id;
-        $sjId = $shop->sjId;
-        $where = [
-            'shopId' => $shopId,
-            'time' => $time,
-        ];
+        $mainId = $shop->mainId ?? 0;
+        $where = ['mainId' => $mainId, 'time' => $time];
         $model = self::getByCondition($where, true);
         if (empty($model)) {
-            $model = self::add(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
+            $model = self::add(['mainId' => $mainId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
         }
         $id = $model->id;
         //查id行级锁

+ 3 - 7
biz-hd/stat/classes/StatOrderMonthClass.php

@@ -27,15 +27,11 @@ class StatOrderMonthClass extends BaseClass
     public static function updateOrInsert($shop)
     {
         $time = date('Ym');
-        $shopId = $shop->id;
-        $sjId = $shop->sjId;
-        $where = [
-            'shopId' => $shopId,
-            'time' => $time,
-        ];
+        $mainId = $shop->mainId ?? 0;
+        $where = ['mainId' => $mainId, 'time' => $time];
         $model = self::getByCondition($where, true);
         if (empty($model)) {
-            $model = self::add(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
+            $model = self::add(['mainId' => $mainId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
         }
         $id = $model->id;
         //查id行级锁

+ 2 - 2
biz-hd/stat/services/StatIncomeService.php

@@ -14,10 +14,10 @@ class StatIncomeService extends BaseService
     public static $baseFile = '\bizHd\stat\classes\StatIncomeClass';
 
     //取今天的数据 ssh 2019.9.8
-    public static function getTodayNum($shopId)
+    public static function getTodayNum($mainId)
     {
         $today = date("Ymd");
-        return StatIncomeClass::getByCondition(['time' => $today, 'shopId' => $shopId]);
+        return StatIncomeClass::getByCondition(['time' => $today, 'mainId' => $mainId]);
     }
 
     public static function checkUp($id, $sjId)

+ 2 - 2
biz-hd/stat/services/StatOrderService.php

@@ -11,10 +11,10 @@ class StatOrderService extends BaseService
 
     public static $baseFile = '\bizHd\stat\classes\StatOrderClass';
 
-    public static function getTodayNum($shopId)
+    public static function getTodayNum($id)
     {
         $today = date("Ymd");
-        return StatOrderClass::getByCondition(['time' => $today,'shopId'=>$shopId]);
+        return StatOrderClass::getByCondition(['time' => $today, 'mainId' => $id]);
     }
 
 }

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

@@ -40,6 +40,7 @@ class PtAssetClass extends BaseClass
         $txAsset->save();
 
         $id = $order->id;
+        $mainId = $shop->mainId ?? 0;
         $event = "【{$shop->merchantName} {$shop->shopName}】的客户下单购买 {$amount}元 订单号:{$order->orderSn}";
         $change = [
             'relateId' => $id,
@@ -50,8 +51,7 @@ class PtAssetClass extends BaseClass
             'io' => 1,
             'payWay' => $order->payWay,
             'event' => $event,
-            'sjId' => $order->sjId,
-            'shopId' => $order->shopId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $ptStyle,
             'shopName' => $shop->shopName,
@@ -145,6 +145,7 @@ class PtAssetClass extends BaseClass
         $txAsset->save();
 
         $id = $order->id;
+        $mainId = $shop->mainId ?? 0;
         $event = "【{$shop->merchantName} {$shop->shopName}】的客户下单(使用平台优惠券{$amount}元) 订单号:{$order->orderSn}";
         $change = [
             'relateId' => $id,
@@ -155,8 +156,7 @@ class PtAssetClass extends BaseClass
             'io' => 1,
             'payWay' => $order->payWay,
             'event' => $event,
-            'sjId' => $order->sjId,
-            'shopId' => $order->shopId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $ptStyle,
             'shopName' => $shop->shopName,

+ 2 - 2
biz/shop/classes/MainIdClass.php → biz/shop/classes/MainClass.php

@@ -6,9 +6,9 @@ use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
-class MainIdClass extends BaseClass
+class MainClass extends BaseClass
 {
 
-    public static $baseFile = '\biz\shop\models\MainId';
+    public static $baseFile = '\biz\shop\models\Main';
 
 }

+ 4 - 4
biz/shop/classes/ShopClass.php

@@ -245,6 +245,7 @@ class ShopClass extends BaseClass
         $id = $order->id;
         $event = "客户下单(使用平台优惠券{$amount}元)";
         $tx = dict::getDict('yeTx', 'can');
+        $mainId = $shop->mainId ?? 0;
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
@@ -254,8 +255,7 @@ class ShopClass extends BaseClass
             'io' => 1,
             'payWay' => $order->payWay,
             'event' => $event,
-            'sjId' => $order->sjId,
-            'shopId' => $order->shopId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $shop->ptStyle,
         ];
@@ -291,6 +291,7 @@ class ShopClass extends BaseClass
         $id = $order->id;
         $event = $customName . "下单{$amount}元";
         $tx = dict::getDict('yeTx', 'can');
+        $mainId = $shop->mainId ?? 0;
         $change = [
             'relateId' => $id,
             'capitalType' => $capitalType,
@@ -300,8 +301,7 @@ class ShopClass extends BaseClass
             'io' => 1,
             'payWay' => $order->payWay,
             'event' => $event,
-            'sjId' => $order->sjId,
-            'shopId' => $order->shopId,
+            'mainId' => $mainId,
             'tx' => $tx,
             'ptStyle' => $shop->ptStyle,
         ];

+ 2 - 2
biz/shop/models/MainId.php → biz/shop/models/Main.php

@@ -2,12 +2,12 @@
 namespace biz\shop\models;
 use biz\base\models\Base;
 
-class MainId extends Base
+class Main extends Base
 {
 
 	public static function tableName()
 	{
-		return 'xhMainId';
+		return 'xhMain';
 	}
 
 }

+ 4 - 5
biz/stat/classes/StatCgClass.php

@@ -14,19 +14,18 @@ class StatCgClass extends BaseClass
     //获取总和 shish 20210829
     public static function getSum($where)
     {
-        $amount = self::sum($where,'amount');
+        $amount = self::sum($where, 'amount');
         return empty($amount) ? 0 : $amount;
     }
 
     //采购统计 shish 2021-528
     public static function replace($shop, $amount)
     {
-        $sjId = $shop->sjId;
-        $shopId = $shop->id;
+        $mainId = $shop->mainId ?? 0;
         $time = date('Ymd');
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'num' => 0], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time, 'num' => 0], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatCgMonthClass.php

@@ -16,11 +16,10 @@ class StatCgMonthClass extends BaseClass
         $time = date('Ym');
         $year = date('Y');
         $month = date('m');
-        $sjId = $shop->sjId;
-        $shopId = $shop->id;
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $mainId = $shop->mainId ?? 0;
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month, 'num' => 1], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time, 'year' => $year, 'month' => $month, 'num' => 1], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatKdClass.php

@@ -15,12 +15,11 @@ class StatKdClass extends BaseClass
     //每日花材统计 shish 2021012
     public static function replace($shop, $amount, $payWay, $date = null)
     {
-        $sjId = $shop->sjId ?? 0;
-        $shopId = $shop->id ?? 0;
+        $mainId = $shop->mainId ?? 0;
         $time = $date == null ? date('Ymd') : $date;
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatKdMonthClass.php

@@ -25,11 +25,10 @@ class StatKdMonthClass extends BaseClass
             $year = date('Y', $timestamp);
             $month = date('m', $timestamp);
         }
-        $sjId = $shop->sjId ?? 0;
-        $shopId = $shop->id ?? 0;
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $mainId = $shop->mainId ?? 0;
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time, 'year' => $year, 'month' => $month], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatOutClass.php

@@ -24,12 +24,11 @@ class StatOutClass extends BaseClass
     // 当采购后台,将价格更新
     public static function updateOrInsert($shop, $amount)
     {
-        $sjId = $shop->sjId;
-        $shopId = $shop->id;
+        $mainId = $shop->mainId ?? 0;
         $time = date('Ymd');
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatOutMonthClass.php

@@ -15,11 +15,10 @@ class StatOutMonthClass extends BaseClass
         $time = date('Ym');
         $year = date('Y');
         $month = date('m');
-        $sjId = $shop->sjId;
-        $shopId = $shop->id;
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $mainId = $shop->mainId ?? 0;
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time, 'year' => $year, 'month' => $month], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatSaleClass.php

@@ -25,12 +25,11 @@ class StatSaleClass extends BaseClass
     //销售统计 shish 20210827
     public static function replace($shop, $amount, $date = null)
     {
-        $sjId = $shop->sjId ?? 0;
-        $shopId = $shop->id ?? 0;
+        $mainId = $shop->mainId ?? 0;
         $time = $date == null ? date('Ymd') : $date;
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'num' => 0], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time, 'num' => 0], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 3 - 4
biz/stat/classes/StatSaleMonthClass.php

@@ -23,11 +23,10 @@ class StatSaleMonthClass extends BaseClass
             $year = date('Y', $timestamp);
             $month = date('m', $timestamp);
         }
-        $sjId = $shop->sjId;
-        $shopId = $shop->id;
-        $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true);
+        $mainId = $shop->mainId ?? 0;
+        $stat = self::getByCondition(['mainId' => $mainId, 'time' => $time], true);
         if (empty($stat)) {
-            $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month, 'num' => 1], true);
+            $stat = self::add(['mainId' => $mainId, 'time' => $time, 'year' => $year, 'month' => $month, 'num' => 1], true);
         }
         $id = $stat->id;
         $unique = self::getLockById($id);

+ 10 - 2
console/controllers/InitController.php

@@ -4,18 +4,21 @@ namespace console\controllers;
 
 use biz\pt\classes\PtYeChangeClass;
 use biz\recharge\classes\RechargeClass;
-use biz\shop\classes\MainIdClass;
+use biz\shop\classes\MainClass;
 use biz\shop\classes\ShopAdminClass;
 use biz\shop\classes\ShopCapitalClass;
 use biz\shop\classes\ShopClass;
 use biz\shop\classes\ShopYeChangeClass;
 use biz\sj\classes\CashClass;
+use biz\stat\classes\StatOrderCountClass;
 use biz\stat\classes\StatOutClass;
 use biz\stat\classes\StatOutMonthClass;
 use biz\stat\classes\StatSaleClass;
 use biz\stat\classes\StatSaleMonthClass;
 use bizGhs\stat\classes\StatYjClass;
 use bizGhs\stat\classes\StatYjMonthClass;
+use bizHd\stat\classes\StatOrderClass;
+use bizHd\stat\classes\StatOrderMonthClass;
 use bizHd\stat\classes\StatUserClass;
 use bizHd\stat\classes\StatUserMonthClass;
 use bizHd\stat\classes\StatVisitClass;
@@ -37,7 +40,7 @@ class InitController extends Controller
         foreach ($shopList as $shop) {
             $mainId = $shop->mainId ?? 0;
             if (empty($mainId)) {
-                $main = MainIdClass::add(['id' => null], true);
+                $main = MainClass::add(['id' => null], true);
                 $mainId = $main->id ?? 0;
                 if (empty($mainId)) {
                     echo "mainId没有生成 \n";
@@ -75,6 +78,11 @@ class InitController extends Controller
 
             ShopAdminClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
 
+            StatOrderClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
+            StatOrderMonthClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
+
+            StatOrderCountClass::updateByCondition(['shopId' => $shopId], ['mainId' => $mainId]);
+
         }
 
     }

+ 25 - 5
sql.txt

@@ -1,8 +1,20 @@
-ALTER TABLE `xhShop` ADD mainId BIGINT(11) NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `id`;
-CREATE TABLE `xhMainId` (
-  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-  PRIMARY KEY (`id`)
-) COMMENT='中央id库';
+DROP TABLE IF EXISTS `xhMain`;
+CREATE TABLE IF NOT EXISTS `xhMain`(
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+`balance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '余额',
+  `freezeBalance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '提现时被冻结的余额',
+  `txBalance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '可提现余额',
+  `fixBalance` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '只能向推荐人消费的余额,指定余额',
+    `totalRecharge` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计充值',
+  `totalIncome` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计收入',
+  `totalExpend` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '总支出',
+  `totalItem` INT(11) NOT NULL DEFAULT '0' COMMENT '总花材数',
+  `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 '累计出库',
+  `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
+  `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+)COMMENT='中央,中控';
 
 === shish 20220311
 
@@ -23,6 +35,14 @@ ALTER TABLE xhGhsStatYjMonth ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id
 ALTER TABLE xhStatVisit ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
 ALTER TABLE xhStatVisitMonth ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
 
+ALTER TABLE xhGhsStatOrderCount ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+ALTER TABLE xhStatOrder ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+ALTER TABLE xhStatOrderCount ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+ALTER TABLE xhStatOrderMonth ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+
+ALTER TABLE xhStatIncome ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+ALTER TABLE xhStatIncomeMonth ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
+
 === 资产相关表中央化 shish 20220313