new Invoice())->Nuonuo()->Isv()->requestBillingNew($user_id,$content)
参数 | 说明 |
---|---|
user_id | 授权者的用户ID(如果需要刷新令牌开发者应妥善保存) |
content | 内容 |
content 中的参数具体参考文档
诺诺开放平台请求开具发票接口(2.0)接口对接文档【外部用】 (2).pdf
案例
$content['buyerName'] = $order['buyer_name'] ?? '';
$content['buyerTaxNum'] = $order['buyer_tax_num'] ?? '';
$content['buyerTel'] = $order['buyer_tel'] ?? '';
$content['buyerAddress'] = $order['buyer_address'] ?? '';
$content['buyerAccount'] = $order['buyer_account'] ?? '';
$content['salerTaxNum'] = $order['saler_tax_num'] ?? '';
$content['salerTel'] = $order['saler_tel'] ?? '';
$content['salerAddress'] = $order['saler_address'] ?? '';
$content['salerAccount'] = $order['saler_account'] ?? '';
$content['orderNo'] = $order['order_no'] ?? '';
$content['invoiceDate'] = $order['invoice_date'] ?? '';
$content['invoiceCode'] = $order['invoice_code'] ?? '';
$content['invoiceNum'] = $order['invoice_num'] ?? '';
$content['billInfoNo'] = $order['bill_info_no'] ?? '';
$content['departmentId'] = $order['department_id'] ?? '';
$content['clerkId'] = $order['clerk_id'] ?? '';
$content['remark'] = $order['remark'] ?? '';
$content['checker'] = $order['checker'] ?? '';
$content['payee'] = $order['payee'] ?? '';
$content['clerk'] = $order['clerk'] ?? '';
$content['listFlag'] = $order['list_flag'] ?? '';
$content['listName'] = $order['list_name'] ?? '';
$content['pushMode'] = $order['push_mode'] ?? '';
$content['buyerPhone'] = $order['buyer_phone'] ?? '';
$content['email'] = $order['email'] ?? '';
$content['invoiceType'] = $order['invoice_type'] ?? '';
$content['invoiceLine'] = $order['invoice_line'] ?? '';
$content['productOilFlag'] = $order['product_oil_flag'] ?? '';
$content['proxyInvoiceFlag'] = $order['proxy_invoice_flag'] ?? '';
$content['callBackUrl'] = $order['call_back_url'] ?? '';
$content['extensionNumber'] = $order['extension_number'] ?? '';
$content['terminalNumber'] = $order['terminal_number'] ?? '';
$content['machineCode'] = $order['machine_code'] ?? '';
$content['vehicleFlag'] = $order['vehicle_flag'] ?? '';
$content['invoiceDetail'] = [];
foreach ($order['bind_invoice_nuonuo_order_goods'] as $v) {
$content['invoiceDetail'][] = [
'goodsName' => $v['goods_name'] ?: '',
'goodsCode' => $v['goods_code'] ?: '',
'selfCode' => $v['self_code'] ?: '',
'withTaxFlag' => $v['with_tax_flag'] ?: '',
'price' => $v['price'] ?: '',
'num' => $v['num'] ?: '',
'unit' => $v['unit'] ?: '',
'specType' => $v['spec_type'] ?: '',
'tax' => $v['tax'] ?: '',
'taxRate' => $v['tax_rate'] ?: '',
'taxExcludedAmount' => $v['tax_excluded_amount'] ?: '',
'taxIncludedAmount' => $v['tax_included_amount'] ?: '',
'invoiceLineProperty' => $v['invoice_line_property'] ?: '',
'favouredPolicyFlag' => $v['favoured_policy_flag'] ?: '',
'favouredPolicyName' => $v['favoured_policy_name'] ?: '',
'deduction' => $v['deduction'] ?: '',
'zeroRateFlag' => $v['zero_rate_flag'] ?: ''
];
}
$invoice_request_msg = json_encode($content);
$order->invoice_request_msg = $invoice_request_msg;
$order->invoice_time = time();
try {
if($order->kind == 'merchant') {
//独立企业
$res = (new Invoice())->Nuonuo()->Merchant()->requestBillingNew($invoice_request_msg);
} else {
//系统服务商
$res = (new Invoice())->Nuonuo()->Isv()->requestBillingNew($order->invoice_nuonuo_isv_user_id,$invoice_request_msg);
}
$order->invoice_state = InvoiceNuonuoOrderModel::SUCCESS_INVOICE;
$order->invoice_serial_num = $res['invoiceSerialNum'];
$order->invoice_return_msg = json_encode(['result' => $res]);
$order->save();
return json(self::createReturn(true,'','触发成功'));
} catch (\Exception $e) {
$order->invoice_state = InvoiceNuonuoOrderModel::FAIL_INVOICE;
$order->invoice_return_msg = json_encode(['msg' => $e->getMessage()]);
$order->save();
return json(self::createReturn(false,'',$e->getMessage()));
}
返回结果
{
"code": "E0000",
"describe": "开票提交成功",
"result": {
"invoiceSerialNum": "20160108165823395151"
}
}