Shop.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/12/19
  6. * Time: 2:45 PM
  7. */
  8. namespace app\common\modules\shop\models;
  9. use app\common\models\AccountWechats;
  10. use app\common\models\MemberRelation;
  11. /**
  12. * todo 商城类
  13. * Class Shop
  14. * @package app\common\modules\trade\models
  15. * @property int uniacid
  16. * @property int weid
  17. * @property int acid
  18. * @property AccountWechats account
  19. * @property MemberRelation memberRelation
  20. */
  21. class Shop extends \app\common\models\Shop
  22. {
  23. static $current;
  24. static $currentUniacid;
  25. /**
  26. * 当前公众号对应的商城
  27. * @return Shop
  28. */
  29. public static function current()
  30. {
  31. if (!isset(self::$current) || self::$currentUniacid != \YunShop::app()->uniacid) {
  32. self::$currentUniacid = \YunShop::app()->uniacid;
  33. self::$current = new self();
  34. self::$current->uniacid = self::$currentUniacid;
  35. }
  36. return self::$current;
  37. }
  38. public function memberRelation()
  39. {
  40. return $this->hasOne(MemberRelation::class, 'uniacid', 'uniacid');
  41. }
  42. }