MerchantAssetClass.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace biz\merchant\classes;
  3. use biz\stat\classes\StatUserClass;
  4. use common\components\util;
  5. use Yii;
  6. use biz\base\classes\BaseClass;
  7. class MerchantAssetClass extends BaseClass
  8. {
  9. public static $baseFile = '\biz\merchant\models\MerchantAsset';
  10. //客户和粉丝数+1,$type 1只加客 2只加粉丝 3既加客也加粉丝 shish 2019.9.7
  11. public static function addUserNum($merchantId, $type = 1)
  12. {
  13. $asset = self::getByMerchantId($merchantId, true);
  14. if ($type == 2) {
  15. $asset->totalFans += 1;
  16. } elseif ($type == 1) {
  17. $asset->totalUser += 1;
  18. } elseif ($type == 3) {
  19. $asset->totalUser += 1;
  20. $asset->totalFans += 1;
  21. } else {
  22. util::fail('无效的类型,既不是客户增加,也不是粉丝增加');
  23. }
  24. $asset->save();
  25. /**每天统计数量+1**/
  26. StatUserClass::increaseOne($merchantId, $asset, $type);
  27. }
  28. //取消关注,减少粉丝数 shish 2019.9.7
  29. public static function reduceFans($merchantId)
  30. {
  31. $asset = self::getByMerchantId($merchantId, true);
  32. $asset->totalFans -= 1;
  33. $asset->save();
  34. /**每日统计数量减少**/
  35. StatUserClass::decreaseOneFans($merchantId, $asset);
  36. }
  37. //获取商家资产信息 shish 2019.9.7
  38. public static function getByMerchantId($merchantId, $returnObj = false)
  39. {
  40. return self::getByCondition(['merchantId' => $merchantId], $returnObj);
  41. }
  42. //会员数+1 shish 2019.9.7
  43. public static function addMemberNum($merchantId)
  44. {
  45. $asset = self::getByMerchantId($merchantId, true);
  46. $asset->totalMember += 1;
  47. $asset->save();
  48. }
  49. }