'ID', 'mall_id' => 'Mall ID', 'store_id' => '门店id', 'total_amount' => '总金额', 'total_income' => '总收益', 'total_count' => '总次数', 'status'=>'状态', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public function getStore() { return $this->hasOne(Store::class, ['id' => 'store_id']); } public static function setData(array $params) { $t = Yii::$app->db->beginTransaction(); 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, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); $t->commit(); return $model; } catch (\Exception $e) { $t->rollBack(); self::$static_error = $e->getMessage(); return false; } } }