| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace addons\Store\common\models;
- use common\models\user\User;
- /**
- * This is the model class for table "qimall_addons_store_merchant_reduce_profit".
- *
- * @property int $id
- * @property int $mall_id 商城ID
- * @property string $source 来源,插件名称
- * @property string $audit_remark 来源,插件名称
- * @property int $source_id 来源id
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- * @property int $user_id
- * @property int $audit_status
- * @property int $admins_id
- * @property int $audit_at
- * @property float $rate 让利比例
- */
- class StoreMerchantReduceProfit extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_store_merchant_reduce_profit';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id'], 'required'],
- [['mall_id', 'source_id', 'status', 'created_at', 'updated_at', 'user_id', 'audit_status', 'admins_id', 'audit_at'], 'integer'],
- [['rate'], 'number'],
- [['source'], 'string', 'max' => 30],
- [['audit_remark'], 'string', 'max' => 1000],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'source' => 'Source',
- 'source_id' => 'Source ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'rate' => 'Rate',
- ];
- }
- public function getStore()
- {
- return $this->hasOne(Store::class, ['id' => 'source_id']);
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- /**
- * @return StoreMerchantReduceProfit|mixed|string|null
- */
- public static function setData(int $mall_id, int $user_id, string $source, int $source_id, float $rate)
- {
- $model = new self();
- $model->mall_id = $mall_id;
- $model->source = $source;
- $model->source_id = $source_id;
- $model->rate = $rate;
- $model->user_id = $user_id;
- if (!$model->save()) return $model->getErrorMessage();
- return $model;
- }
- }
|