| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace common\models\order;
- use common\enums\StatusEnum;
- use Exception;
- use RuntimeException;
- use Yii;
- /**
- * This is the model class for table "qimall_order_modify_shipping_address_log".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $order_id
- * @property int $status -1删除 1禁用 2正常
- * @property int $created_at
- * @property int $updated_at
- */
- class OrderModifyShippingAddressLog extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_order_modify_shipping_address_log';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'order_id', 'status', 'created_at', 'updated_at'], 'integer']
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => '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;
- }
- }
- }
|