$merchantId, 'time' => $time], true); if (empty($stat)) { $addData = ['merchantId' => $merchantId, 'time' => $time, 'addTime' => $addTime]; $stat = self::add($addData, true); } if ($type == 1) { $stat->totalUserNum = $merchantAsset->totalUser; $stat->riseUserNum += 1; } elseif ($type == 2) { $stat->totalFansNum = $merchantAsset->totalFans; $stat->riseFansNum += 1; } elseif ($type == 3) { $stat->totalUserNum = $merchantAsset->totalUser; $stat->riseUserNum += 1; $stat->totalFansNum = $merchantAsset->totalFans; $stat->riseFansNum += 1; } else { util::fail('无效的类型,既不是客户增加,也不是粉丝增加'); } $stat->save(); } //减少一个粉丝 shish 2019.9.8 public static function decreaseOneFans($merchantId, $merchantAsset) { $time = date("Ymd"); Yii::info($merchantId); $addTime = time(); $stat = self::getByCondition(['merchantId' => $merchantId, 'time' => $time], true); if (empty($stat)) { $addData = ['merchantId' => $merchantId, 'time' => $time, 'addTime' => $addTime]; $stat = self::add($addData, true); } $stat->riseFansNum -= 1; $stat->totalFansNum = $merchantAsset->totalFans; $stat->save(); } }