'ID', 'mall_id' => 'Mall ID', 'order_id' => 'Order ID', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @param array $params * * @return bool|self */ public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (!$model) { throw new RuntimeException('数据不存在'); } if ($model->mall_id != $params['mall_id']) { throw new RuntimeException('不允许操作此数据'); } } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) { throw new RuntimeException($model->getErrorMessage()); } if (!$model->save()) { throw new RuntimeException($model->getErrorMessage()); } return $model; } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } }