林琦海 5 лет назад
Родитель
Сommit
050f7fcbc3

+ 38 - 0
biz/stat/classes/StatOutClass.php

@@ -0,0 +1,38 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/4/13 21:37
+ */
+
+namespace biz\stat\classes;
+
+use biz\base\classes\BaseClass;
+class StatOutClass extends BaseClass
+{
+    public static $baseFile = '\biz\stat\models\StatOut';
+
+    //更新当前商家的数据 linqh 2021.4.13
+    // 当采购后台,将价格更新,若无则新增  ps 总支出金额暂不累计
+    public static function updateOrInsert($sjId,$shopId,$amount)
+    {
+        $time = date('Ymd');
+        $where = [
+            'merchantId'=>$sjId,
+            'shopId'=>$shopId,
+            'time'=>$time,
+        ];
+        $model = self::getByCondition($where);
+        if($model){
+            $id = $model['id'];
+            //累加金额 amount
+            $newAmount = bcadd($amount,$model['amount'],2);
+            self::updateById($id,['amount'=>$newAmount]);
+        }else{
+            //insert
+            $data = $where;
+            $data['createTime'] = date('Y-m-d H:i:s');
+            self::add($data);
+        }
+    }
+
+}

+ 41 - 0
biz/stat/classes/StatOutMonthClass.php

@@ -0,0 +1,41 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/4/13 21:37
+ */
+
+namespace biz\stat\classes;
+
+use biz\base\classes\BaseClass;
+use common\components\dateUtil;
+
+class StatOutMonthClass extends BaseClass
+{
+    public static $baseFile = '\biz\stat\models\StatOutMonth';
+
+    public static function updateOrInsert($sjId,$shopId,$amount)
+    {
+        $time = date('Ym');
+        $year = date('Y');
+        $month = date('m');
+        $where = [
+            'merchantId'=>$sjId,
+            'shopId'=>$shopId,
+            'year'=>$year,
+            'month'=>$month,
+            'time'=>$time,
+        ];
+        $model = self::getByCondition($where);
+        if($model){
+            $id = $model['id'];
+            //累加金额 amount
+            $newAmount = bcadd($amount,$model['amount'],2);
+            self::updateById($id,['amount'=>$newAmount]);
+        }else{
+            //insert
+            $data = $where;
+            $data['createTime'] = date('Y-m-d H:i:s');
+            self::add($data);
+        }
+    }
+}

+ 16 - 0
biz/stat/models/StatOut.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/4/13 21:35
+ */
+
+namespace biz\stat\models;
+
+use biz\base\models\Base;
+class StatOut extends Base
+{
+    public static function tableName()
+    {
+        return 'xhStatOut';
+    }
+}

+ 16 - 0
biz/stat/models/StatOutMonth.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/4/13 21:36
+ */
+
+namespace biz\stat\models;
+
+use biz\base\models\Base;
+class StatOutMonth extends Base
+{
+    public static function tableName()
+    {
+        return 'xhStatOutMonth';
+    }
+}

+ 13 - 0
biz/stat/services/StatOutMonthService.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/4/13 21:40
+ */
+
+namespace biz\stat\services;
+
+use biz\base\services\BaseService;
+class StatOutMonthService extends BaseService
+{
+    public static $baseFile = '\biz\stat\classes\StatOutMonthClass';
+}

+ 13 - 0
biz/stat/services/StatOutService.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * User: admin
+ * Date Time: 2021/4/13 21:40
+ */
+
+namespace biz\stat\services;
+
+use biz\base\services\BaseService;
+class StatOutService extends BaseService
+{
+    public static $baseFile = '\biz\stat\classes\StatOutClass';
+}