| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace biz\stat\classes;
- use biz\base\classes\BaseClass;
- class StatStockOutMonthClass extends BaseClass
- {
- public static $baseFile = '\biz\stat\models\StatStockOutMonth';
- //出库添加或更新 ssh 20210526
- public static function replace($main, $shop, $amount)
- {
- $time = date('Ym');
- $year = date('Y');
- $month = date('m');
- $sjId = $shop->sjId;
- $mainId = $main->id ?? 0;
- $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'time' => $time], true);
- if (empty($stat)) {
- $stat = self::add(['mainId' => $mainId, 'sjId' => $sjId, 'time' => $time, 'year' => $year, 'month' => $month], true);
- }
- $id = $stat->id;
- $unique = self::getLockById($id);
- if (empty($unique)) {
- util::fail('没有记录');
- }
- $currentAmount = bcadd($unique->amount, $amount, 2);
- $unique->amount = $currentAmount;
- $unique->totalAmount = $main->totalStockOut;
- $unique->save();
- }
- }
|