checkToken(); if ($token['code'] < 0) return $this->response($token); $order_create = new OrderCreateModel(); $data = array_merge( [ 'order_id' => $this->params['order_id'] ], $this->getInvoiceParam() ); $result = $order_create->initInvoice($data); if ($result['code'] < 0) { return $this->response($result); } $order_create->calculateInvoice(); if ($order_create->error) { return $this->response($this->error($order_create->error_msg)); } $res = $order_create->saveInvoice(); return $this->response($res); } }