hasOne(User::class, ['id' => 'user_id']); } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'store_id' => 'Store ID', 'user_id' => 'User ID', 'last_time' => 'Last Time', 'order_nums' => 'Order Nums', 'pay_nums' => 'Pay Nums', 'pay_money' => 'Pay Money', 'refund_nums' => 'Refund Nums', 'refund_money' => 'Refund Money', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData(array $params) { try { if (!empty($params['mall_id']) && !empty($params['id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id']]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } } else { $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; } } }