shish há 5 anos atrás
pai
commit
142ba3eb58

+ 6 - 5
biz-hd/purchase/classes/PurchaseClass.php

@@ -3,6 +3,7 @@
 namespace bizHd\purchase\classes;
 
 use biz\ghs\classes\GhsClass;
+use biz\shop\classes\ShopClass;
 use biz\shop\classes\ShopCouponClass;
 use biz\shop\models\Shop;
 use bizGhs\admin\classes\AdminClass;
@@ -157,7 +158,7 @@ class PurchaseClass extends BaseClass
         }
         PurchaseItemClass::batchAdd($productList);
 
-        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
@@ -227,12 +228,12 @@ class PurchaseClass extends BaseClass
     //订单取消,变更状态,占用库存释放 shish 2021.5.8
     public static function cancel($id)
     {
-        $purchase = Purchase::findBySql('select * from ' . Purchase::tableName() . ' where id = :id for update', ['id' => $id])->one();
+        $purchase = PurchaseClass::getLockById($id);
         $purchase->status = self::STATUS_CANCEL;
         $purchase->save();
 
         $shopId = $purchase->shopId;
-        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
@@ -292,7 +293,7 @@ class PurchaseClass extends BaseClass
         $purchase->save();
 
         $shopId = $purchase->shopId;
-        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
@@ -330,7 +331,7 @@ class PurchaseClass extends BaseClass
         $purchase->save();
 
         $shopId = $purchase->shopId;
-        $shop = Shop::findBySql('select * from ' . Shop::tableName() . ' where id = :id for update', ['id' => $shopId])->one();
+        $shop = ShopClass::getLockById($shopId);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }

+ 17 - 17
biz-hd/stat/classes/StatIncomeClass.php

@@ -26,7 +26,7 @@ class StatIncomeClass extends BaseClass
         $model = self::getByCondition($where, true);
         if (empty($model)) {
             $data = [
-                'shopId'=>$shopId,
+                'shopId' => $shopId,
                 'time' => $time,
                 'amount' => 0,
                 'totalAmount' => $shop->totalIncome,
@@ -36,7 +36,7 @@ class StatIncomeClass extends BaseClass
         }
         $id = $model->id;
         //查id行级锁
-        $stat = StatIncome::findBySql('select * from ' . StatIncome::tableName() . ' where id = :id for update', ['id' => $id])->one();
+        $stat = StatIncomeClass::getLockById($id);
         $stat->amount = bcadd($amount, $stat->amount, 2);
         $stat->totalAmount = bcadd($amount, $shop->totalIncome, 2);
         $stat->save();
@@ -48,16 +48,16 @@ class StatIncomeClass extends BaseClass
     public static function getAmountToday($shopId)
     {
         $time = date('Ymd');
-        $res = self::getDetail($shopId,$time);
-        return $res['amount']??0;
+        $res = self::getDetail($shopId, $time);
+        return $res['amount'] ?? 0;
     }
 
     //yesterday
     public static function getAmountYesterday($shopId)
     {
-        $time = date('Ymd',strtotime("-1 days"));
-        $res = self::getDetail($shopId,$time);
-        return $res['amount']??0;
+        $time = date('Ymd', strtotime("-1 days"));
+        $res = self::getDetail($shopId, $time);
+        return $res['amount'] ?? 0;
     }
 
 
@@ -65,8 +65,8 @@ class StatIncomeClass extends BaseClass
     public static function getAmountWeek($shopId)
     {
         $end = date('Ymd');
-        $start = date('Ymd',strtotime("-7 days"));
-        return self::getAmountByTime($shopId,$start,$end);
+        $start = date('Ymd', strtotime("-7 days"));
+        return self::getAmountByTime($shopId, $start, $end);
     }
 
     //30天输入金额
@@ -74,13 +74,13 @@ class StatIncomeClass extends BaseClass
     {
 
         $end = date('Ymd');
-        $start = date('Ymd',strtotime("-30 days"));
-        return self::getAmountByTime($shopId,$start,$end);
+        $start = date('Ymd', strtotime("-30 days"));
+        return self::getAmountByTime($shopId, $start, $end);
     }
 
 
     //查询某一天的信息
-    public static function getDetail($shopId,$time)
+    public static function getDetail($shopId, $time)
     {
         $where = [
             'shopId' => $shopId,
@@ -90,16 +90,16 @@ class StatIncomeClass extends BaseClass
         return $model;
     }
 
-    public static function getAmountByTime($shopId,$start,$end)
+    public static function getAmountByTime($shopId, $start, $end)
     {
         $where = [];
         $where['shopId'] = $shopId;
         $where['time'] = ['between', [$start, $end]];
-        $res = self::getAllByCondition($where,null,"amount");
+        $res = self::getAllByCondition($where, null, "amount");
         $amount = 0;
-        if($res){
-            foreach ($res as $v){
-                $amount = bcadd($amount,$v['amount'],2);
+        if ($res) {
+            foreach ($res as $v) {
+                $amount = bcadd($amount, $v['amount'], 2);
             }
         }
         return $amount;

+ 14 - 13
biz-hd/stat/classes/StatOrderClass.php

@@ -1,6 +1,7 @@
 <?php
 
 namespace bizHd\stat\classes;
+
 use bizHd\stat\models\StatOrder;
 use bizHd\base\classes\BaseClass;
 
@@ -21,11 +22,11 @@ class StatOrderClass extends BaseClass
         ];
         $model = self::getByCondition($where, true);
         if (empty($model)) {
-            $model = self::add(['merchantId' => $sjId, 'shopId'=>$shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
+            $model = self::add(['merchantId' => $sjId, 'shopId' => $shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
         }
         $id = $model->id;
         //查id行级锁
-        $stat = StatOrder::findBySql('select * from ' . StatOrder::tableName() . ' where id = :id for update', ['id' => $id])->one();
+        $stat = StatOrderClass::getLockById($id);
         $stat->riseNum += 1;
         $stat->totalNum += 1;
         $stat->save();
@@ -37,19 +38,19 @@ class StatOrderClass extends BaseClass
     public static function getRiseNumToday($shopId)
     {
         $time = date('Ymd');
-        $res = self::getDetail($shopId,$time);
-        return $res['riseNum']??0;
+        $res = self::getDetail($shopId, $time);
+        return $res['riseNum'] ?? 0;
     }
 
     //yesterday
     public static function getRiseNumYesterday($shopId)
     {
-        $time = date('Ymd',strtotime("-1 days"));
-        $res = self::getDetail($shopId,$time);
-        return $res['riseNum']??0;
+        $time = date('Ymd', strtotime("-1 days"));
+        $res = self::getDetail($shopId, $time);
+        return $res['riseNum'] ?? 0;
     }
 
-    public static function getDetail($shopId,$time)
+    public static function getDetail($shopId, $time)
     {
         $where = [
             'shopId' => $shopId,
@@ -63,20 +64,20 @@ class StatOrderClass extends BaseClass
     public static function getRiseNumWeek($shopId)
     {
         $end = date('Ymd');
-        $start = date('Ymd',strtotime("-6 days"));
-        return self::getRiseNumByTime($shopId,$start,$end);
+        $start = date('Ymd', strtotime("-6 days"));
+        return self::getRiseNumByTime($shopId, $start, $end);
     }
 
     //近30天
     public static function getRiseNumThirty($shopId)
     {
         $end = date('Ymd');
-        $start = date('Ymd',strtotime("-29 days"));
-        return self::getRiseNumByTime($shopId,$start,$end);
+        $start = date('Ymd', strtotime("-29 days"));
+        return self::getRiseNumByTime($shopId, $start, $end);
     }
 
 
-    public static function getRiseNumByTime($shopId,$start,$end)
+    public static function getRiseNumByTime($shopId, $start, $end)
     {
         $where = [];
         $where['shopId'] = $shopId;

+ 2 - 2
biz-hd/stat/classes/StatOrderMonthClass.php

@@ -35,11 +35,11 @@ class StatOrderMonthClass extends BaseClass
         ];
         $model = self::getByCondition($where, true);
         if (empty($model)) {
-            $model = self::add(['merchantId' => $sjId,'shopId'=>$shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
+            $model = self::add(['merchantId' => $sjId, 'shopId' => $shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $shop->totalOrderNum], true);
         }
         $id = $model->id;
         //查id行级锁
-        $stat = StatOrderMonth::findBySql('select * from ' . StatOrderMonth::tableName() . ' where id = :id for update', ['id' => $id])->one();
+        $stat = StatOrderMonthClass::getLockById($id);
         $stat->riseNum += 1;
         $stat->totalNum += 1;
         $stat->save();

+ 6 - 2
sql.sql

@@ -2585,9 +2585,13 @@ ADD COLUMN `productId`  int(11) NOT NULL DEFAULT 0 AFTER `orderSn`;
 
 ---shish 20210518
 ALTER TABLE xhGhsOrder ADD customPrice DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '客户实际付款金额' AFTER `actPrice`;
-
+ALTER TABLE xhShopYeChange MODIFY `fromType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '来源 1门店 2商城 3朋友圈 请查看dict.php文件';
+ALTER TABLE xhOrder MODIFY `fromType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '来源 1门店 2商城 3朋友圈 请查看dict.php文件';
+ALTER TABLE xhOrder MODIFY `store` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '门店订单,作废字段。';
+ALTER TABLE xhOrder MODIFY `sourceType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '来源,作废字段';
+ALTER TABLE xhShopYeChange ADD tx TINYINT NOT NULL DEFAULT 1 COMMENT '本条变动的余额 1不可提现 2可提现' AFTER `txBalance`;
 
 ----linqh  2021.5.18
 ALTER TABLE `xhGhsStockOutOrderItem`
 MODIFY COLUMN `itemStock`  decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '当时的库存(变更前)' AFTER `itemNum`,
-ADD COLUMN `newStock`  decimal(10,2) NOT NULL DEFAULT 0 COMMENT '变更后的库存' AFTER `itemPrice`;
+ADD COLUMN `newStock`  decimal(10,2) NOT NULL DEFAULT 0 COMMENT '变更后的库存' AFTER `itemPrice`;