255], [['order_no'], 'string', 'max' => 100], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'store_id' => 'Store ID', 'commission' => 'Commission', 'source_table' => 'Source Table', 'source_table_id' => 'Source Table ID', 'is_settle' => 'Is Settle', 'desc' => 'Desc', 'status' => 'Status', 'order_no' => 'Order No', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @desc:保存数据 * @Author: hua * @Date: 2021/11/18 * @Time: 10:54 * @Copyright: copyright (c) 2021 广东七件事集团 * @param array $params * @return AgentCommissionBasisLog|false|null */ public static function setData(array $params) { try { $model = self::findOne([ 'user_id' => $params['user_id'], 'store_id' => $params['store_id'], 'mall_id' => $params['mall_id'], 'source_table_id' => $params['source_table_id'], 'source_table' => $params['source_table'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if(!empty($model)) return $model; $model = new self(); $model->loadDefaultValues(); if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,nickname,mobile,username,avatar_url'); } }