new Invoice())->Nuonuo()->Isv()->requestBillingNew($user_id,$content)

参数 说明
user_id 授权者的用户ID(如果需要刷新令牌开发者应妥善保存)
content 内容

content 中的参数具体参考文档

诺诺开放平台请求开具发票接口(2.0)接口对接文档【外部用】 (2).pdf

案例

  1. $content['buyerName'] = $order['buyer_name'] ?? '';
  2. $content['buyerTaxNum'] = $order['buyer_tax_num'] ?? '';
  3. $content['buyerTel'] = $order['buyer_tel'] ?? '';
  4. $content['buyerAddress'] = $order['buyer_address'] ?? '';
  5. $content['buyerAccount'] = $order['buyer_account'] ?? '';
  6. $content['salerTaxNum'] = $order['saler_tax_num'] ?? '';
  7. $content['salerTel'] = $order['saler_tel'] ?? '';
  8. $content['salerAddress'] = $order['saler_address'] ?? '';
  9. $content['salerAccount'] = $order['saler_account'] ?? '';
  10. $content['orderNo'] = $order['order_no'] ?? '';
  11. $content['invoiceDate'] = $order['invoice_date'] ?? '';
  12. $content['invoiceCode'] = $order['invoice_code'] ?? '';
  13. $content['invoiceNum'] = $order['invoice_num'] ?? '';
  14. $content['billInfoNo'] = $order['bill_info_no'] ?? '';
  15. $content['departmentId'] = $order['department_id'] ?? '';
  16. $content['clerkId'] = $order['clerk_id'] ?? '';
  17. $content['remark'] = $order['remark'] ?? '';
  18. $content['checker'] = $order['checker'] ?? '';
  19. $content['payee'] = $order['payee'] ?? '';
  20. $content['clerk'] = $order['clerk'] ?? '';
  21. $content['listFlag'] = $order['list_flag'] ?? '';
  22. $content['listName'] = $order['list_name'] ?? '';
  23. $content['pushMode'] = $order['push_mode'] ?? '';
  24. $content['buyerPhone'] = $order['buyer_phone'] ?? '';
  25. $content['email'] = $order['email'] ?? '';
  26. $content['invoiceType'] = $order['invoice_type'] ?? '';
  27. $content['invoiceLine'] = $order['invoice_line'] ?? '';
  28. $content['productOilFlag'] = $order['product_oil_flag'] ?? '';
  29. $content['proxyInvoiceFlag'] = $order['proxy_invoice_flag'] ?? '';
  30. $content['callBackUrl'] = $order['call_back_url'] ?? '';
  31. $content['extensionNumber'] = $order['extension_number'] ?? '';
  32. $content['terminalNumber'] = $order['terminal_number'] ?? '';
  33. $content['machineCode'] = $order['machine_code'] ?? '';
  34. $content['vehicleFlag'] = $order['vehicle_flag'] ?? '';
  35. $content['invoiceDetail'] = [];
  36. foreach ($order['bind_invoice_nuonuo_order_goods'] as $v) {
  37. $content['invoiceDetail'][] = [
  38. 'goodsName' => $v['goods_name'] ?: '',
  39. 'goodsCode' => $v['goods_code'] ?: '',
  40. 'selfCode' => $v['self_code'] ?: '',
  41. 'withTaxFlag' => $v['with_tax_flag'] ?: '',
  42. 'price' => $v['price'] ?: '',
  43. 'num' => $v['num'] ?: '',
  44. 'unit' => $v['unit'] ?: '',
  45. 'specType' => $v['spec_type'] ?: '',
  46. 'tax' => $v['tax'] ?: '',
  47. 'taxRate' => $v['tax_rate'] ?: '',
  48. 'taxExcludedAmount' => $v['tax_excluded_amount'] ?: '',
  49. 'taxIncludedAmount' => $v['tax_included_amount'] ?: '',
  50. 'invoiceLineProperty' => $v['invoice_line_property'] ?: '',
  51. 'favouredPolicyFlag' => $v['favoured_policy_flag'] ?: '',
  52. 'favouredPolicyName' => $v['favoured_policy_name'] ?: '',
  53. 'deduction' => $v['deduction'] ?: '',
  54. 'zeroRateFlag' => $v['zero_rate_flag'] ?: ''
  55. ];
  56. }
  57. $invoice_request_msg = json_encode($content);
  58. $order->invoice_request_msg = $invoice_request_msg;
  59. $order->invoice_time = time();
  60. try {
  61. if($order->kind == 'merchant') {
  62. //独立企业
  63. $res = (new Invoice())->Nuonuo()->Merchant()->requestBillingNew($invoice_request_msg);
  64. } else {
  65. //系统服务商
  66. $res = (new Invoice())->Nuonuo()->Isv()->requestBillingNew($order->invoice_nuonuo_isv_user_id,$invoice_request_msg);
  67. }
  68. $order->invoice_state = InvoiceNuonuoOrderModel::SUCCESS_INVOICE;
  69. $order->invoice_serial_num = $res['invoiceSerialNum'];
  70. $order->invoice_return_msg = json_encode(['result' => $res]);
  71. $order->save();
  72. return json(self::createReturn(true,'','触发成功'));
  73. } catch (\Exception $e) {
  74. $order->invoice_state = InvoiceNuonuoOrderModel::FAIL_INVOICE;
  75. $order->invoice_return_msg = json_encode(['msg' => $e->getMessage()]);
  76. $order->save();
  77. return json(self::createReturn(false,'',$e->getMessage()));
  78. }

返回结果

{
  "code": "E0000",
  "describe": "开票提交成功",
  "result": {
      "invoiceSerialNum": "20160108165823395151"
    } 
}