|
|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|