|
|
@@ -9,6 +9,33 @@ class StatCgGhsMonthClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\biz\stat\models\StatCgGhsMonth';
|
|
|
|
|
|
+ public static function hdCgGhsReplace($order, $date = null)
|
|
|
+ {
|
|
|
+ if ($date == null) {
|
|
|
+ $time = date('Ym');
|
|
|
+ $year = date('Y');
|
|
|
+ $month = date('m');
|
|
|
+ } else {
|
|
|
+ $timestamp = strtotime($date);
|
|
|
+ $time = date('Ym', $timestamp);
|
|
|
+ $year = date('Y', $timestamp);
|
|
|
+ $month = date('m', $timestamp);
|
|
|
+ }
|
|
|
+ $sjId = $order->sjId ?? 0;
|
|
|
+ $mainId = $order->mainId ?? 0;
|
|
|
+ $ghsId = $order->ghsId ?? 0;
|
|
|
+ $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'ghsId' => $ghsId, 'time' => $time], true);
|
|
|
+ if (empty($stat)) {
|
|
|
+ $stat = self::add(['mainId' => $mainId, 'sjId' => $sjId, 'ghsId' => $ghsId, 'time' => $time, 'year' => $year, 'month' => $month], true);
|
|
|
+ }
|
|
|
+ $id = $stat->id;
|
|
|
+ $unique = self::getLockById($id);
|
|
|
+ $amount = $cgInfo->orderPrice ?? 0;
|
|
|
+ $currentAmount = bcadd($unique->amount, $amount, 2);
|
|
|
+ $unique->amount = $currentAmount;
|
|
|
+ $unique->save();
|
|
|
+ }
|
|
|
+
|
|
|
//每月采购统计 shish 20211012
|
|
|
public static function ghsReplace($order, $date = null)
|
|
|
{
|