Merchant.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. namespace common\models\merchant;
  3. use Yii;
  4. use common\helpers\RegularHelper;
  5. use common\helpers\StringHelper;
  6. /**
  7. * This is the model class for table "{{%merchant}}".
  8. *
  9. * @property int $id
  10. * @property string|null $title 店铺名称
  11. * @property int|null $operating_type 运营类型
  12. * @property int|null $cate_id 分类
  13. * @property float|null $tax_rate 税率
  14. * @property string|null $logo 店铺logo
  15. * @property string|null $cover 店铺头像
  16. * @property int|null $sort 店铺排序
  17. * @property string|null $brief_introduction 简介
  18. * @property int|null $term_of_validity_type 有效期类型 0固定时间 1不限
  19. * @property int|null $start_time 开始时间
  20. * @property int|null $end_time 结束时间
  21. * @property string|null $email 邮箱
  22. * @property int|null $province_id 省
  23. * @property int|null $city_id 城市
  24. * @property int|null $area_id 地区
  25. * @property string|null $address_name 地址
  26. * @property string|null $address_details 详细地址
  27. * @property string|null $longitude 经度
  28. * @property string|null $latitude 纬度
  29. * @property string|null $contacts 联系人
  30. * @property string|null $mobile 手机号码
  31. * @property string|null $tel_no 电话号码
  32. * @property int|null $level_id 店铺等级
  33. * @property string|null $keywords 店铺seo关键字
  34. * @property string|null $description 店铺seo描述
  35. * @property string|null $environment 环境相册
  36. * @property string|null $qq QQ
  37. * @property int|null $credit 店铺信用
  38. * @property float|null $desc_credit 描述相符度分数
  39. * @property float|null $service_credit 服务态度分数
  40. * @property float|null $delivery_credit 发货速度分数
  41. * @property float|null $sales_money 店铺销售额(不计算退款)
  42. * @property string|null $business_week 每周营业日期
  43. * @property string|null $business_time 营业开始时间
  44. * @property int|null $collect_num 收藏数量
  45. * @property int|null $comment_num 评价数
  46. * @property int|null $transmit_num 分享数
  47. * @property int|null $auth_role_id 开店套餐
  48. * @property int|null $certification_type 认证类型
  49. * @property string|null $close_cause 店铺关闭原因
  50. * @property int|null $audit_status 审核状态
  51. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  52. * @property int|null $created_at 创建时间
  53. * @property int|null $updated_at 修改时间
  54. */
  55. class Merchant extends \common\models\base\BaseModel
  56. {
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public static function tableName()
  61. {
  62. return '{{%merchant}}';
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function rules()
  68. {
  69. return [
  70. [['title', 'cate_id', 'auth_role_id', 'mobile'], 'required'],
  71. [['operating_type', 'cate_id', 'sort', 'term_of_validity_type', 'province_id', 'city_id', 'area_id', 'level_id', 'credit', 'collect_num', 'comment_num', 'transmit_num', 'auth_role_id', 'certification_type', 'audit_status', 'status', 'created_at', 'updated_at'], 'integer'],
  72. [['tax_rate', 'desc_credit', 'service_credit', 'delivery_credit', 'sales_money'], 'number'],
  73. [['environment', 'business_week', 'business_time'], 'safe'],
  74. [['title', 'address_name'], 'string', 'max' => 200],
  75. [['logo', 'address_details', 'longitude', 'latitude', 'mobile', 'contacts'], 'string', 'max' => 100],
  76. [['cover'], 'string', 'max' => 150],
  77. [['brief_introduction'], 'string', 'max' => 1000],
  78. [['email'], 'string', 'max' => 60],
  79. [['email'], 'email'],
  80. [['start_time', 'end_time'], 'safe'],
  81. ['mobile', 'match', 'pattern' => RegularHelper::mobile(), 'message' => '请输入正确的手机号'],
  82. [['tel_no'], 'string', 'max' => 20],
  83. [['keywords', 'description', 'close_cause'], 'string', 'max' => 255],
  84. [['qq'], 'string', 'max' => 50],
  85. ];
  86. }
  87. /**
  88. * {@inheritdoc}
  89. */
  90. public function attributeLabels()
  91. {
  92. return [
  93. 'id' => 'ID',
  94. 'title' => '店铺名称',
  95. 'operating_type' => '运营类型',
  96. 'cate_id' => '主营行业',
  97. 'tax_rate' => '税率',
  98. 'logo' => '商户 Logo',
  99. 'cover' => '商户头像',
  100. 'sort' => '店铺排序',
  101. 'brief_introduction' => '简介',
  102. 'term_of_validity_type' => '有效期类型',
  103. 'start_time' => '开始时间',
  104. 'end_time' => '到期时间',
  105. 'email' => '邮箱',
  106. 'province_id' => '省',
  107. 'city_id' => '城市',
  108. 'area_id' => '地区',
  109. 'address_name' => '地址',
  110. 'address_details' => '详细地址',
  111. 'longitude' => '经度',
  112. 'latitude' => '纬度',
  113. 'contacts' => '联系人',
  114. 'mobile' => '手机号码',
  115. 'tel_no' => '电话号码',
  116. 'level_id' => '店铺等级',
  117. 'keywords' => '店铺关键字',
  118. 'description' => '店铺 seo 描述',
  119. 'environment' => '环境相册',
  120. 'qq' => 'QQ',
  121. 'credit' => '店铺信用',
  122. 'desc_credit' => '描述相符度分数',
  123. 'service_credit' => '服务态度分数',
  124. 'delivery_credit' => '发货速度分数',
  125. 'sales_money' => '店铺销售额',
  126. 'business_week' => '每周营业日期',
  127. 'business_time' => '营业开始时间',
  128. 'collect_num' => '收藏数量',
  129. 'comment_num' => '评价数',
  130. 'transmit_num' => '分享数',
  131. 'auth_role_id' => '开店套餐',
  132. 'certification_type' => '认证类型',
  133. 'close_cause' => '店铺关闭原因',
  134. 'audit_status' => '审核状态',
  135. 'status' => '状态',
  136. 'created_at' => '创建时间',
  137. 'updated_at' => '修改时间',
  138. ];
  139. }
  140. public function attributeHints()
  141. {
  142. return [
  143. 'keywords' => '多个关键字之间用英文“,”隔开'
  144. ];
  145. }
  146. public function beforeSave($insert)
  147. {
  148. $this->start_time = StringHelper::dateToInt($this->start_time);
  149. $this->end_time = StringHelper::dateToInt($this->end_time);
  150. if (isset($this->oldAttributes['area_id']) && $this->area_id != $this->oldAttributes['area_id']) {
  151. $this->address_name = Yii::$app->services->provinces->getCityListName([$this->province_id, $this->city_id, $this->area_id]);
  152. }
  153. return parent::beforeSave($insert);
  154. }
  155. }
粤ICP备19079148号