Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/huahuibao

shish 5 лет назад
Родитель
Сommit
87e7ec5172

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

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use biz\shop\services\ShopService;
 use biz\sj\services\MerchantAssetService;
 use biz\stat\services\StatOutService;
 use bizHd\stat\services\StatIncomeMonthService;
@@ -21,7 +22,7 @@ class ConsoleController extends BaseController
     //概况 ssh 2019.12.19
     public function actionProfile()
     {
-        $asset = MerchantAssetService::getByMerchantId($this->sjId);
+        $asset = ShopService::getById($this->shopId);
         $notice = [
             //['title' => '您的试用期还有7天,点击免费续期1年 ', 'action' => '查看', 'page' => '/admin/recharge/renew'],
         ];

+ 4 - 0
app-ghs/controllers/OrderController.php

@@ -113,6 +113,10 @@ class OrderController extends BaseController
             ProductClass::valid($productList, $this->shopId);
             $post['product'] = $productList;
             $return = OrderClass::addOrder($post, $this->shop);
+            //总订单+1
+            \biz\shop\services\ShopService::totalOrderPlus($this->shopId);
+            //总收入
+            \biz\shop\services\ShopService::updateTotalIncome($this->shopId,$return['actPrice']);
             $transaction->commit();
             util::success($return);
         } catch (\Exception $e) {

+ 1 - 0
app-ghs/controllers/ProductController.php

@@ -211,6 +211,7 @@ class ProductController extends BaseController
                 $type => $val
             ];
             ProductClass::updateByCondition($where, $data);
+            ProductClass::autoPriceById($id);
         }
         util::complete();
     }

+ 0 - 7
app-ghs/controllers/PurchaseOrderController.php

@@ -1,8 +1,6 @@
 <?php
 namespace ghs\controllers;
 
-use biz\stat\classes\StatOutClass;
-use biz\stat\classes\StatOutMonthClass;
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\order\classes\PurchaseOrderItemClass;
 use bizGhs\order\models\PurchaseOrder;
@@ -52,11 +50,6 @@ class PurchaseOrderController extends BaseController
         $post['itemInfo'] = $ghsItemInfo;
         $order = PurchaseOrderClass::addOrder($post);
         if($order){
-            //记录支出
-            //当天
-            StatOutClass::updateOrInsert($this->sjId,$this->sjId,$order['orderPrice']);
-            //当月
-            StatOutMonthClass::updateOrInsert($this->sjId,$this->sjId,$order['orderPrice']);
             util::success($order);
         }else{
             util::fail();

+ 3 - 1
app-hd/controllers/GhsProductController.php

@@ -6,6 +6,7 @@
 
 namespace hd\controllers;
 
+use biz\shop\services\ShopService;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\classes\ItemClassClass;
@@ -25,6 +26,7 @@ class GhsProductController extends BaseController
         $shopId = $get['shopId']??0;
         $sjId = $get['sjId']??0;
         AdminClass::addRecentShop($shopId,$this->admin);
+
         //获取所有当前供应商的分类 (全部、常用)
         //根据分类组装分类下的花材信息
         $classIds = ItemClassClass::getGhsItemClassAll($sjId);
@@ -41,7 +43,7 @@ class GhsProductController extends BaseController
         //dd($itemInfoData);
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
         $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, '');
-
+        ShopService::totalViewPlus($shopId);
         util::success($data);
 
     }

+ 2 - 0
biz-ghs/item/services/ItemService.php

@@ -228,6 +228,8 @@ class ItemService extends BaseService
                     $productData['itemId'] = $v['id'];
                     unset($productData['id']);
                     $productData['rank'] = 'A';
+                    //计算价格
+                    $productData['price'] = bcadd($v['cost'],$v['addPrice'],2);
                     ProductClass::add($productData);
                 }
             }

+ 17 - 0
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -3,6 +3,9 @@
 namespace bizGhs\order\classes;
 
 use biz\ghs\classes\GhsClass;
+use biz\shop\services\ShopService;
+use biz\stat\classes\StatOutClass;
+use biz\stat\classes\StatOutMonthClass;
 use bizGhs\base\classes\BaseClass;
 use bizGhs\item\classes\ItemClass;
 use bizGhs\order\traits\OrderTrait;
@@ -139,6 +142,7 @@ class PurchaseOrderClass extends BaseClass
                 ProductClass::changeCost($productId,$avgCost);
 
             }
+            self::updateStat($order);
             $transaction->commit();
             return $order;
         }catch (\Exception $exception){
@@ -292,4 +296,17 @@ class PurchaseOrderClass extends BaseClass
         return $data;
     }
 
+    //更新统计
+    public static function updateStat($order)
+    {
+        //记录支出
+        //当天
+        StatOutClass::updateOrInsert($order['merchantId'],$order['shopId'],$order['orderPrice']);
+        //当月
+        StatOutMonthClass::updateOrInsert($order['merchantId'],$order['shopId'],$order['orderPrice']);
+        //总采购+1
+        ShopService::totalPurchaseOrderPlus($order['shopId']);
+        //总支出
+        ShopService::updateTotalExpend($order['shopId'],$order['orderPrice']);
+    }
 }

+ 10 - 0
biz-ghs/product/classes/ProductClass.php

@@ -603,4 +603,14 @@ class ProductClass extends BaseClass
         }
         self::updateById($id, $upData);
     }
+
+    //自动改价 2021.4.14
+    public static function autoPriceById($productId)
+    {
+        $product = self::getById($productId);
+        if($product && $product['priceLabel']==self::PRICE_LABEL_AUTO){
+            $price = bcadd($product['cost'],$product['addPrice'],2);
+            self::changePrice($productId,$product['shopId'],$price,self::PRICE_LABEL_AUTO);
+        }
+    }
 }

+ 4 - 1
biz/ghs/classes/GhsClass.php

@@ -3,6 +3,7 @@
 namespace biz\ghs\classes;
 
 use biz\shop\classes\ShopClass;
+use biz\shop\services\ShopService;
 use biz\sj\classes\MerchantAssetClass;
 use common\components\imgUtil;
 use common\components\util;
@@ -45,6 +46,8 @@ class GhsClass extends BaseClass
     //增加供货商 shish 2021.3.29
     public static function addGhs($data)
     {
+        //供货商客户+1
+        ShopService::totalUserPlus($data['ghsShopId']);
         return self::add($data);
     }
 
@@ -115,4 +118,4 @@ class GhsClass extends BaseClass
         util::fail('您没有权限访问的供货商');
     }
 
-}
+}

+ 85 - 0
biz/shop/services/ShopService.php

@@ -95,4 +95,89 @@ class ShopService extends BaseService
         }
         return $shopIds;
     }
+
+    //获取门店资产信息 linqh 2021.4.14
+    public static function getById($shopId, $returnObj = false)
+    {
+        return ShopClass::getById($shopId, $returnObj);
+    }
+
+    //总订单加1
+    public static function totalOrderPlus($shopId)
+    {
+        $shop = ShopClass::getById($shopId);
+        if($shop){
+            $data = [
+                'totalOrder'=>$shop['totalOrder'] + 1
+            ];
+            ShopClass::updateById($shopId,$data);
+        }
+
+    }
+
+    //总采购+1
+    public static function totalPurchaseOrderPlus($shopId)
+    {
+        $shop = ShopClass::getById($shopId);
+        if($shop){
+            $data = [
+                'totalPurchaseOrder'=>$shop['totalPurchaseOrder'] + 1
+            ];
+            ShopClass::updateById($shopId,$data);
+        }
+
+    }
+
+    //更新总收入
+    public static function updateTotalIncome($shopId,$amount)
+    {
+        $shop = ShopClass::getById($shopId);
+        if($shop){
+            $data = [
+                'totalIncome'=>bcadd($shop['totalIncome'],$amount,2)
+            ];
+            ShopClass::updateById($shopId,$data);
+        }
+    }
+
+    //更新总支出
+    public static function updateTotalExpend($shopId,$amount)
+    {
+        $shop = ShopClass::getById($shopId);
+        if($shop){
+            $data = [
+                'totalExpend'=>bcadd($shop['totalExpend'],$amount,2)
+            ];
+            ShopClass::updateById($shopId,$data);
+        }
+    }
+
+    //更新客户数 +1
+    public static function totalUserPlus($shopId)
+    {
+        $shop = ShopClass::getById($shopId);
+        if($shop){
+            $data = [
+                'totalUser'=>$shop['totalUser'] + 1
+            ];
+            ShopClass::updateById($shopId,$data);
+        }
+
+    }
+
+    //更新总访问数 +1
+    public static function totalViewPlus($shopId)
+    {
+        $shop = ShopClass::getById($shopId);
+        if($shop){
+            $data = [
+                'totalView'=>$shop['totalView'] + 1
+            ];
+            ShopClass::updateById($shopId,$data);
+        }
+
+    }
+
+
+
 }

+ 11 - 1
sql.sql

@@ -2089,6 +2089,16 @@ ALTER TABLE xhAdmin DROP COLUMN `identity`;
 
 国兰原有的商品拼音需要补回去
 
+
 ALTER TABLE xhShopAdmin ADD VARCHAR(500) NOT NULL DEFAULT '' COMMENT '添加员工时的备注' AFTER `super`;
 ALTER TABLE xhShopAdmin ADD founder TINYINT NOT NULL DEFAULT 1 COMMENT '创始人 1不是 2是' AFTER `super`;
-ALTER TABLE xhShop ADD `totalPurchase` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计采购' AFTER `totalPurchaseOrder`;
+ALTER TABLE xhShop ADD `totalPurchase` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '累计采购' AFTER `totalPurchaseOrder`;
+
+======linqh 2021-04-14
+==
+ALTER TABLE `xhShop`
+ADD COLUMN `freezeBalance`  decimal(9,2) NOT NULL DEFAULT 0 COMMENT '提现时被冻结的余额' AFTER `balance`,
+ADD COLUMN `totalExpend`  decimal(9,2) NOT NULL DEFAULT 0 COMMENT '总支出' AFTER `totalIncome`,
+ADD COLUMN `totalView`  int(11) NOT NULL DEFAULT 0 COMMENT '累计访问次数' AFTER `status`,
+ADD COLUMN `totalUser`  int(11) NOT NULL DEFAULT 0 COMMENT '总用户;总客户数' AFTER `totalView`,
+ADD COLUMN `totalPurchaseOrder`  int(11) NOT NULL DEFAULT 0 COMMENT '总采购订单' AFTER `totalUser`;