'ID', 'mall_id' => 'Mall ID', 'status' => '状态-1 删除 0 关闭 1开启', ]; } /** * @param $mallId * @param $params * @return CouponRelationModel * @throws \Exception */ public static function setData($params) { try { $data = self::findOne($params); if(!empty($data)){ return $data; } $model = new self(); $model->mall_id = $params['mall_id'] ?? 0; $model->user_id = $params['user_id'] ?? 0; $model->scratch_log_id = $params['scratch_log_id'] ?? 0; $model->user_coupon_id = $params['user_coupon_id'] ?? 0; if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $exception) { throw new \Exception($exception->getMessage()); } } }