|
|
@@ -0,0 +1,34 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace biz\stat\classes;
|
|
|
+
|
|
|
+use biz\base\classes\BaseClass;
|
|
|
+use common\components\util;
|
|
|
+
|
|
|
+class StatPdAddMonthClass extends BaseClass
|
|
|
+{
|
|
|
+
|
|
|
+ public static $baseFile = '\biz\stat\models\StatPdAddMonth';
|
|
|
+
|
|
|
+ //每月盘盈统计 shish 20210827
|
|
|
+ public static function replace($shop, $amount)
|
|
|
+ {
|
|
|
+ $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);
|
|
|
+ if (empty($stat)) {
|
|
|
+ $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month, 'num' => 1], true);
|
|
|
+ }
|
|
|
+ $id = $stat->id;
|
|
|
+ $unique = self::getLockById($id);
|
|
|
+ $currentAmount = bcadd($unique->amount, $amount, 2);
|
|
|
+ $unique->amount = $currentAmount;
|
|
|
+ $unique->totalAmount = $shop->totalPurchase;
|
|
|
+ $unique->num += 1;
|
|
|
+ $unique->save();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|