Mch.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. /**
  11. * This is the model class for table "{{%mch}}".
  12. *
  13. * @property string $id
  14. * @property integer $store_id
  15. * @property integer $user_id
  16. * @property integer $is_delete
  17. * @property integer $is_open
  18. * @property integer $is_recommend
  19. * @property integer $is_lock
  20. * @property string $realname
  21. * @property string $tel
  22. * @property string $name
  23. * @property integer $province_id
  24. * @property integer $city_id
  25. * @property integer $district_id
  26. * @property string $address
  27. * @property integer $mch_common_cat_id
  28. * @property string $service_tel
  29. * @property string $logo
  30. * @property string $header_bg
  31. * @property integer $transfer_rate
  32. * @property string $account_money
  33. * @property integer $sort
  34. * @property integer $wechat_name
  35. * @property string $longitude
  36. * @property string $latitude
  37. * @property string $main_content
  38. * @property string $summary
  39. * @property string $business
  40. * @property string $card_front
  41. * @property string $card_obverse
  42. * @property string $business_hours
  43. * @property string $created_at
  44. * @property string $updated_at
  45. */
  46. class Mch extends \yii\db\ActiveRecord
  47. {
  48. /**
  49. * 商户店铺状态:开启
  50. */
  51. const IS_OPEN_TRUE = 1;
  52. /**
  53. * 商户店铺状态:关闭
  54. */
  55. const IS_OPEN_FALSE = 0;
  56. /**
  57. * 好店推荐:推荐
  58. */
  59. const IS_RECOMMEND_TRUE = 1;
  60. /**
  61. * 好店推荐:不推荐
  62. */
  63. const IS_RECOMMEND_FALSE = 0;
  64. /**
  65. * @inheritdoc
  66. */
  67. public static function tableName()
  68. {
  69. return '{{%mch}}';
  70. }
  71. public function behaviors()
  72. {
  73. return [
  74. [
  75. // 自动更新创建和更新时间
  76. 'class' => TimestampBehavior::class,
  77. 'value' => time()
  78. ]
  79. ];
  80. }
  81. /**
  82. * @inheritdoc
  83. */
  84. public function rules()
  85. {
  86. return [
  87. // [['store_id', 'user_id', 'realname', 'tel', 'mch_common_cat_id'], 'required'],
  88. [['store_id', 'user_id', 'saas_user_id','is_recommend',
  89. 'province_id', 'city_id', 'district_id', 'mch_common_cat_id',
  90. 'transfer_rate', 'sort', 'created_at', 'updated_at', 'province_id', 'city_id', 'district_id','is_open', 'is_lock'], 'integer'],
  91. [['logo', 'header_bg', 'name', 'address'], 'string'],
  92. [['account_money'], 'number'],
  93. [['realname', 'tel', 'name', 'wechat_name', 'longitude', 'latitude', 'main_content', 'summary',
  94. 'business', 'card_front', 'card_obverse', 'business_hours'], 'string', 'max' => 255],
  95. [['address', 'service_tel'], 'string', 'max' => 1000],
  96. [['is_delete', 'account_money', 'longitude', 'latitude'], 'default', 'value'=>0],
  97. [['main_content'], 'default', 'value'=>''],
  98. ];
  99. }
  100. /**
  101. * @inheritdoc
  102. */
  103. public function attributeLabels()
  104. {
  105. return [
  106. 'id' => 'ID',
  107. 'store_id' => 'Store ID',
  108. 'user_id' => 'User ID',
  109. 'is_delete' => 'Is Delete',
  110. 'is_open' => '是否营业:0=否,1=是',
  111. 'is_recommend' => '是否推荐:0=否,1=是',
  112. 'is_lock' => '是否被系统关闭:0=否,1=是',
  113. 'realname' => 'Realname',
  114. 'tel' => 'Tel',
  115. 'name' => 'Name',
  116. 'province_id' => 'Province ID',
  117. 'city_id' => 'City ID',
  118. 'district_id' => 'District ID',
  119. 'address' => 'Address',
  120. 'mch_common_cat_id' => '所售类目',
  121. 'service_tel' => '客服电话',
  122. 'logo' => 'logo',
  123. 'header_bg' => '背景图',
  124. 'transfer_rate' => '商户手续费',
  125. 'account_money' => '商户余额',
  126. 'sort' => '排序:升序',
  127. 'wechat_name' => '微信号',
  128. 'longitude' => '经度',
  129. 'latitude' => '纬度',
  130. 'main_content' => '主营内容',
  131. 'summary' => '简介',
  132. 'business' => '营业执照',
  133. 'card_front' => '身份证正面',
  134. 'card_obverse' => '身份证反面',
  135. 'business_hours' => '营业时间',
  136. 'created_at' => '创建时间',
  137. 'updated_at' => '更新时间',
  138. ];
  139. }
  140. public function getSetting()
  141. {
  142. return $this->hasOne(MchSetting::className(), ['mch_id' => 'id']);
  143. }
  144. //
  145. // public function getPlugin()
  146. // {
  147. // return $this->hasOne(MchPlugin::className(), ['mch_id' => 'id']);
  148. // }
  149. public function getUser()
  150. {
  151. return $this->hasOne(User::className(), ['id' => 'user_id']);
  152. }
  153. public function getOrder()
  154. {
  155. return $this->hasMany(Order::className(), ['mch_id' => 'id']);
  156. }
  157. public function getGoods()
  158. {
  159. return $this->hasMany(Goods::className(), ['mch_id' => 'id']);
  160. }
  161. }