| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- namespace addons\WechatVideoShop\common\models;
- use common\enums\StatusEnum;
- use common\models\common\Region;
- use Yii;
- /**
- * This is the model class for table "{{%addons_wechat_video_shop}}".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property string $name 店铺名称
- * @property string $wechat_appid 微信视频小店APPID
- * @property string $wechat_secret 微信视频小店密钥
- * @property string $wechat_token 微信视频小店消息推送令牌(Token)
- * @property string $wechat_aes_key 微信视频小店消息加密密钥
- * @property int $status 状态[-1删除;0禁用;1正常]
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- * @property int $province_id 更新时间
- * @property int $city_id 更新时间
- * @property int $district_id 更新时间
- * @property int $is_auto_down_up_goods 更新时间
- * @property string $district 更新时间
- * @property string $province 更新时间
- * @property string $city 更新时间
- * @property string $contact_person 更新时间
- * @property string $phone 更新时间
- * @property string $address 更新时间
- * @property string $logo 更新时间
- * @property string $third_status 更新时间
- * @property int $is_auth 更新时间
- */
- class WechatVideoShop extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_wechat_video_shop}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'status', 'created_at', 'updated_at', 'province_id', 'city_id', 'district_id',
- 'is_auto_down_up_goods', 'is_auth'], 'integer'],
- [['name'], 'string', 'max' => 64],
- [['province', 'city', 'district'], 'string', 'max' => 50],
- [['address', 'logo'], 'string', 'max' => 255],
- [['contact_person'], 'string', 'max' => 30],
- [['phone'], 'string', 'max' => 13],
- [['third_status'], 'string', 'max' => 20],
- [['wechat_appid', 'wechat_secret', 'wechat_token', 'wechat_aes_key'], 'string', 'max' => 128],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'name' => '店铺名称',
- 'wechat_appid' => '微信视频小店APPID',
- 'wechat_secret' => '微信视频小店密钥',
- 'wechat_token' => '微信视频小店消息推送令牌(Token)',
- 'wechat_aes_key' => '微信视频小店消息加密密钥',
- 'status' => '状态[-1删除;0禁用;1正常]',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['and', ['id' => $params['id'], 'mall_id' => $params['mall_id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]]);
- if (empty($model)) throw new \Exception('id参数错误');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- public function getProvinceInfo()
- {
- return $this->hasOne(Region::class, ['id' => 'province_id']);
- }
- public function getCityInfo()
- {
- return $this->hasOne(Region::class, ['id' => 'city_id']);
- }
- public function getDistrictInfo()
- {
- return $this->hasOne(Region::class, ['id' => 'district_id']);
- }
- public function getAddress()
- {
- return $this->hasOne(WechatVideoShopAddress::class, ['shop_id' => 'id']);
- }
- }
|