123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- package controller
- //
- //type (
- // addInvoiceAddParam struct {
- // OrderCode string `json:"Swno"` //orderCode订单号
- // CustType string `json:"custType"` //购货方企业类型 01:企业 02:机关执业单位 03:个人 04:其他
- // CustTaxNo string `json:"custTaxNo"` //纳税人税号
- // Phone string `json:"phone"` //手机号
- // BillDate string `json:"billDate"` //单据日期 格式:yyyy-MM-dd HH:mm:ss
- // CustName string `json:"custName"` //购方名称
- // Orders []*orders `json:"orders"` //发票内容
- // }
- //
- // orders struct {
- // BillNo string `json:"billNo"` //订单号
- // Items []*items `json:"items"`
- // }
- //
- // items struct {
- // Name string `json:"name"` //商品名称
- // Code string `json:"code"` //商品编号(税收分类编码)
- // Yhzcbs string `json:"yhzcbs"` //享受税收优惠政策内容
- // LineType string `json:"lineType"` //发票行性质 0:正常行1:折扣行2:被折扣行
- // TaxRate string `json:"taxRate"` //税率
- // TaxPrice string `json:"taxPrice"` //单价
- // TotalAmount string `json:"totalAmount"` //含税金额
- // Quantity string `json:"quantity"` //数量
- // }
- //
- // addInvoiceAddResp struct {
- // Code int `json:"code"` //0 开票成功;2 开票中 ;其他开票失败
- // Msg interface{} `json:"msg,omitempty"`
- // Data addInvoiceAddData `json:"data,omitempty"` //异步开票,通过回调通知
- // }
- // addInvoiceAddData struct {
- // Swno string `json:"swno"` //流水号 invoice_serialnum
- // Fpdm string `json:"fpdm"` //发票代码 invoice_code
- // Fphm string `json:"fphm"` //发票号码 invoice_number
- // Path string `json:"path"` //pdf地址 url
- // }
- //)
- //
- //// InvoiceAdd 开票
- //func InvoiceAdd(r *ghttp.Request) {
- // err := func() error {
- // haLogin, sessVal := service.GetJySessionVal(r)
- // if !haLogin {
- // return gerror.New("未登录")
- // }
- // var (
- // orderCode = r.Get("order_code").String()
- // invoiceType = r.Get("invoice_type").String() //个人 or 企业
- // mail = r.Get("email").String()
- // phoneNum = r.Get("phone_num").String()
- // companyName = r.Get("company").String() //公司名字
- // companyTaxNo = r.Get("id_num").String() //企业税号
- // userId = gconv.String(sessVal["userId"])
- // )
- // if (mail != "" || phoneNum != "" || orderCode != "") || (invoiceType == "企业" && (companyName == "" || companyTaxNo == "")) {
- // return gerror.New("缺少参数")
- // }
- // orderRes, err := g.DB().GetOne(r.Context(), "SELECT order_money,product_type,order_channel,pay_way,pay_money,is_backstage_order,billingMode FROM dataexport_order WHERE order_code=? AND user_id=? AND applyBill_status!=2", orderCode, userId)
- // if err != nil || orderRes.IsEmpty() {
- // g.Log().Errorf(r.Context(), "查询%d订单异常 err:%v", orderCode, err)
- // return gerror.New("未知订单")
- // }
- // if !(gconv.Int(orderRes["billingMode"]) == 1 && (gconv.Int(orderRes["is_backstage_order"]) != 1 || gconv.String(orderRes["order_channel"]) == "xdqd04")) {
- // return gerror.New("改订单不支持线上开票")
- // }
- // var (
- // prices float64
- // price = strconv.FormatFloat(prices, 'f', -1, 64)
- // product_name = gconv.String(orderRes["product_type"])
- // dataexport_data = map[string]interface{}{}
- // data = map[string]interface{}{}
- // )
- // //公对公转账 账单金额可以修改 开发票应取实付金额 pay_money
- // //微信支付宝支付 pay_money为订单金额减去微信or支付包红包
- // if gconv.String(orderRes["pay_way"]) == "transferAccounts" {
- // prices = gconv.Float64(orderRes["pay_money"]) / float64(100)
- // } else {
- // prices = gconv.Float64(orderRes["order_money"]) / float64(100)
- // }
- // dataexport_data["applyBill_status"] = 1
- // if invoiceType == "个人" {
- // dataexport_data["applyBill_type"] = 0
- // data["taxpayer_identnum"] = ""
- // data["company_name"] = ""
- // dataexport_data["applyBill_taxnum"] = ""
- // dataexport_data["applybill_company"] = ""
- // } else {
- // data["taxpayer_identnum"] = companyTaxNo
- // data["company_name"] = companyName
- // dataexport_data["applyBill_taxnum"] = companyTaxNo
- // dataexport_data["applybill_company"] = companyName
- // dataexport_data["applyBill_type"] = 1
- // }
- // dataexport_data["user_mail"] = mail
- //
- // data["product_type"] = product_name
- // data["order_code"] = orderCode
- // data["mail"] = mail
- // data["phone"] = phoneNum
- // data["invoice_type"] = invoiceType
- // data["invoice_changed"] = 0
- // data["create_time"] = time.Now().Unix()
- // data["user_id"] = userId
- // data["invoice_status"] = 0
- //
- // //g.DB().GetCount(r.Context(),"SELECT count(*) FROM invoice WHERE order_code=? and user_id=?",orderCode,userId)
- // //
- // //status := g.DB().(dbname, map[string]interface{}{"order_code": order_code, "user_id": userId}, "", "create_time", 0, 0)
- // //if len(*status) > 0 {
- // // return nil
- // //}
- // //util.Mysql.Insert(dbname, data)
- // //if !util.Mysql.Update("dataexport_order", map[string]interface{}{"order_code": order_code, "user_id": userId}, dataexport_data) {
- // // invoice_status = -1
- // //}
- // g.Dump(price)
- //
- // return nil
- // }()
- // if err != nil {
- //
- // }
- //
- //}
- //
- //func InvoiceAdd222(r *ghttp.Request) {
- // var param *addInvoiceAddParam
- // err := func() error {
- // err := gconv.Struct(r.GetBody(), param)
- // if err != nil {
- // return gerror.Wrap(err, "获取参数异常")
- // }
- // // 存入开票记录表
- //
- // // 调用第三方开票接口
- // if err := tripartite.MakeSingleInvoice(tripartite.MakeInvoiceData{
- // Type: "2",
- // Gmfmc: param.CustName,
- // Gmfnsrsbh: param.CustTaxNo,
- // Id: param.OrderCode,
- // //Gmfdz: "北京市朝阳区安定路5号院13号楼B座12层1201室",
- // Lxdh: param.Phone,
- // //Yhyywdmc: "郑州交通银行总行",
- // //Yhzh: "6320123123000121",
- // InvoiceArr: []tripartite.MakeInvoiceItems{{
- // Xmmc: "0fccdac71c36a8552ba662e7a2f42726",
- // WhStatus: 1,
- // Je: param.Orders[0].Items[0].TaxPrice,
- // Sl: "1",
- // }},
- // }); err != nil {
- // return gerror.Wrapf(err, "调用开票接口异常%v", err)
- // }
- // return nil
- // }()
- // if err != nil {
- // g.Log().Errorf(r.Context(), "处理开票业务异常")
- // r.Response.Write(addInvoiceAddResp{
- // Code: -1,
- // Msg: err.Error(),
- // })
- // return
- // }
- // r.Response.Write(addInvoiceAddResp{
- // Code: 0,
- // Msg: "开票中",
- // })
- //}
|