| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace biz\merchant\classes;
- use biz\stat\classes\StatUserClass;
- use common\components\util;
- use Yii;
- use biz\base\classes\BaseClass;
- class MerchantAssetClass extends BaseClass
- {
-
- public static $baseFile = '\biz\merchant\models\MerchantAsset';
-
- //客户和粉丝数+1,$type 1只加客 2只加粉丝 3既加客也加粉丝 shish 2019.9.7
- public static function addUserNum($merchantId, $type = 1)
- {
- $asset = self::getByMerchantId($merchantId, true);
- if ($type == 2) {
- $asset->totalFans += 1;
- } elseif ($type == 1) {
- $asset->totalUser += 1;
- } elseif ($type == 3) {
- $asset->totalUser += 1;
- $asset->totalFans += 1;
- } else {
- util::fail('无效的类型,既不是客户增加,也不是粉丝增加');
- }
- $asset->save();
-
- /**每天统计数量+1**/
- StatUserClass::increaseOne($merchantId, $asset, $type);
-
- }
-
- //取消关注,减少粉丝数 shish 2019.9.7
- public static function reduceFans($merchantId)
- {
- $asset = self::getByMerchantId($merchantId, true);
- $asset->totalFans -= 1;
- $asset->save();
- /**每日统计数量减少**/
- StatUserClass::decreaseOneFans($merchantId, $asset);
- }
-
- //获取商家资产信息 shish 2019.9.7
- public static function getByMerchantId($merchantId, $returnObj = false)
- {
- return self::getByCondition(['merchantId' => $merchantId], $returnObj);
- }
-
- //会员数+1 shish 2019.9.7
- public static function addMemberNum($merchantId)
- {
- $asset = self::getByMerchantId($merchantId, true);
- $asset->totalMember += 1;
- $asset->save();
- }
- }
|