| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace biz\stat\classes;
- use Yii;
- use biz\base\classes\BaseClass;
- class StatUserClass extends BaseClass
- {
-
- public static $baseFile = '\biz\stat\models\StatUser';
-
- /**
- * 客户和粉丝数+1,$type 1只加客 2只加粉丝 3既加客也加粉丝 shish 2019.9.7
- */
- public static function increaseOne($merchantId, $merchantAsset, $type = 1)
- {
- $time = date("Ymd");
- $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);
- }
- 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();
- }
-
- }
|