'ID', 'mall_id' => '商城ID', 'user_id' => '用户ID', 'order_id' => 'order_id', 'order_no' => 'order_no', 'clerk_nums' => 'clerk_nums', 'type' => 'type', 'store_id' => 'store_id', 'clerk_money' => 'clerk_money', 'service_income' => 'service_income', 'clerk_type' => 'clerk_type', 'reservation_service_order_id' => 'reservation_service_order_id', 'clerk_user_id' => 'clerk_user_id', 'secondary_card_id' => '绑定的次卡ID', 'status' => '状态0禁用,-1删除,1正常', 'created_at' => '创建时间', 'updated_at' => '更新时间', 'open_time' => '开卡时间', 'clerk_log_id' => '公共核销记录id', ]; } public function getSecondaryCard() { return $this->hasOne(SecondaryCard::class, ['id' => 'secondary_card_id']); } public function getSecondaryCardOrder() { return $this->hasOne(SecondaryCardOrder::class, ['order_no' => 'order_no']); } public function getClerkUser() { return $this->hasOne(User::class, ['id' => 'clerk_user_id']); } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } public static function getExportFields() { return [ 'order_no' => '卡号', 'secondary_card_name' => '次卡名称', 'nickname' => '开卡用户', 'open_time' => '开卡时间', 'clerk_nums' => '单次核销次数', 'store_name' => '核销门店', 'clerk_nickname' => '核销人', 'created_at' => '核销时间', ]; } 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, '')) 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; } } }