|
|
@@ -11,6 +11,39 @@ class StatKhCgMonthClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\biz\stat\models\StatKhCgMonth';
|
|
|
|
|
|
+ //供应商预订单退款,客户采购金额减少
|
|
|
+ public static function ghsBookOrderChange($add, $order, $amount, $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;
|
|
|
+ $shopId = $order->shopId ?? 0;
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'customId' => $customId, 'time' => $time], true);
|
|
|
+ if (empty($stat)) {
|
|
|
+ $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'customId' => $customId, 'time' => $time, 'year' => $year, 'month' => $month], true);
|
|
|
+ }
|
|
|
+ $id = $stat->id;
|
|
|
+ $unique = self::getLockById($id);
|
|
|
+
|
|
|
+ if ($add == true) {
|
|
|
+ $currentAmount = bcadd($unique->amount, $amount, 2);
|
|
|
+ } else {
|
|
|
+ $currentAmount = bcsub($unique->amount, $amount, 2);
|
|
|
+ }
|
|
|
+ $unique->amount = $currentAmount;
|
|
|
+
|
|
|
+ $unique->save();
|
|
|
+ }
|
|
|
+
|
|
|
//每月客户采购统计 ssh 20211012
|
|
|
public static function replace($order, $amount, $date = null)
|
|
|
{
|