Md.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\jobs\SyncMdGoodsJob;
  9. use yii\db\ActiveRecord;
  10. use yii\behaviors\TimestampBehavior;
  11. use Yii;
  12. /**
  13. * This is the model class for table "{{%md}}".
  14. *
  15. * @property integer $id
  16. * @property integer $store_id
  17. * @property integer $user_id
  18. * @property string $contact
  19. * @property string $name
  20. * @property string $mobile
  21. * @property string $address
  22. * @property integer $is_delete
  23. * @property integer $created_at
  24. * @property string $longitude
  25. * @property string $latitude
  26. * @property string $cover_url
  27. * @property string $pic_url
  28. * @property string $start_time
  29. * @property string $end_time
  30. * @property int|null $province
  31. * @property int|null $city
  32. * @property int|null $district
  33. * @property int|null $shop_audit 审核状态(-1未通过,0待审核,1通过)
  34. * @property string|null $refuse_desc 拒接原因
  35. * @property string $delivery_type 配送方式
  36. * @property string $self_delivery_type 自己选择的配送方式
  37. * @property int $open_status
  38. * @property int $shop_time_type
  39. * @property int $is_time_forbid
  40. * @property integer $updated_at
  41. * @property int $rate
  42. * @property int $total_profit
  43. * @property int $cash_profit
  44. * @property int $clerk_profit
  45. * @property int $clerk_rate
  46. * @property int $is_single
  47. * @property int $manager
  48. * @property int $is_set_distance
  49. * @property int $distance
  50. * @property int $audit_time
  51. * @property string $food_payment
  52. * @property int $food_pay_type
  53. * @property string $user_name
  54. * @property string $password
  55. */
  56. class Md extends \yii\db\ActiveRecord
  57. {
  58. /**
  59. * @inheritdoc
  60. */
  61. public static function tableName()
  62. {
  63. return '{{%md}}';
  64. }
  65. public function behaviors()
  66. {
  67. return [
  68. [
  69. 'class' => TimestampBehavior::class,
  70. 'attributes' => [
  71. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  72. ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
  73. ]
  74. ]
  75. ];
  76. }
  77. const IS_DELETE_YES = 1;//已删除
  78. const IS_DELETE_NO = 0;//未删除
  79. const SHOP_AUDIT_YES = 1;// 审核通过
  80. const SHOP_AUDIT_NO = 2;// 审核拒绝
  81. const SHOP_AUDIT_WAIT = 0;// 等待审核
  82. /**
  83. * @inheritdoc
  84. */
  85. public function rules()
  86. {
  87. return [
  88. [['audit_time', 'store_id', 'is_delete', 'province', 'city', 'district', 'user_id', 'shop_audit',
  89. 'open_status', 'shop_time_type', 'is_time_forbid', 'updated_at', 'manager', 'is_single', 'is_set_distance', 'food_pay_type'], 'integer'],
  90. [['longitude', 'latitude', 'cover_url', 'pic_url', 'delivery_type', 'contact', 'start_time',
  91. 'end_time', 'self_delivery_type', 'food_payment', 'user_name', 'password'], 'string'],
  92. [['rate', 'total_profit', 'cash_profit', 'clerk_rate', 'clerk_profit', 'distance'], 'number'],
  93. [['name', 'mobile', 'address', 'refuse_desc'], 'string', 'max' => 255],
  94. [['created_at', 'delivery_type'], 'safe']
  95. ];
  96. }
  97. /**
  98. * @inheritdoc
  99. */
  100. public function attributeLabels()
  101. {
  102. return [
  103. 'id' => 'ID',
  104. 'store_id' => 'Store ID',
  105. 'user_id' => '用户id',
  106. 'name' => 'Name',
  107. 'mobile' => 'Mobile',
  108. 'address' => 'Address',
  109. 'is_delete' => 'Is Delete',
  110. 'created_at' => '添加时间',
  111. 'longitude' => 'Longitude',
  112. 'latitude' => 'Latitude',
  113. 'cover_url' => '自提点大图',
  114. 'pic_url' => '自提点小图',
  115. 'province' => '省份',
  116. 'city' => '城市',
  117. 'district' => '区县',
  118. 'shop_audit' => '审核状态(-1未通过,0待审核,1通过)',
  119. 'refuse_desc' => '拒接原因',
  120. 'user_name' => '登陆账户',
  121. 'password' => '密码',
  122. ];
  123. }
  124. // public function getShopPic()
  125. // {
  126. // return $this->hasMany(ShopPic::className(), ['shop_id'=>'id'])->where(['is_delete'=>0]);
  127. // }
  128. public function afterSave($insert, $changedAttributes)
  129. {
  130. parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
  131. if (1 || $insert) {
  132. $goods_id = Goods::find()->where(['store_id' => $this->store_id, 'is_delete' => 0])->select('id')->column();
  133. queue_push(new SyncMdGoodsJob(['goods_ids' => $goods_id, 'md_id' => $this->id]));
  134. }
  135. }
  136. }