| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace addons\Store\common\models;
- use common\enums\StatusEnum;
- use common\models\base\BaseActiveRecord;
- use Yii;
- /**
- * This is the model class for table "{{%addons_store_settlement_log}}".
- *
- * @property int $id
- * @property int $order_id 订单id
- * @property int $store_id 门店id
- * @property int|null $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- * @property string $order_no 订单编号
- * @property int $is_settlement 是否已结算
- * @property int $settlement_at 结算时间
- */
- class SettlementLog extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_store_settlement_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['order_id', 'store_id', 'status', 'created_at', 'updated_at', 'is_settlement', 'settlement_at'], 'integer'],
- [['order_no'], 'string', 'max' => 100],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'order_id' => 'Order ID',
- 'store_id' => 'Store ID',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- 'order_no' => 'Order No',
- 'is_settlement' => 'Is Settlement',
- 'settlement_at' => 'Settlement At',
- ];
- }
- /**
- * 保存数据
- * @param array $params
- * @return bool
- */
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) throw new \Exception('数据不存在或已删除');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|