duxin 1 mēnesi atpakaļ
vecāks
revīzija
d680342c94

+ 2 - 0
internal/cmd/cmd.go

@@ -75,6 +75,8 @@ var (
 					orderGroup.POST("/transferAccounts", controller.TransferAccounts)          //对公转行审核
 					orderGroup.POST("/serviceOpen", controller.OrderServiceOpen)               //开通权益
 					orderGroup.POST("/invoiceQuery", controller.InvoiceQuery)                  //开通权益
+					orderGroup.POST("/invoiceUpload", controller.InvoiceUpload)                //发票上传
+					orderGroup.POST("/invoiceShow", controller.InvoiceShow)                    //开通编辑
 
 					orderGroup.POST("/createQRCode", controller.CreateQRCode)       //二维码
 					orderGroup.POST("/openInvoiceInfo", controller.OpenInvoiceInfo) //开发票

+ 19 - 0
internal/controller/invoiceShow.go

@@ -0,0 +1,19 @@
+package controller
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/net/ghttp"
+)
+
+// InvoiceQuery 发票查询
+func InvoiceShow(r *ghttp.Request) {
+	rData, err := func() (interface{}, error) {
+
+		return nil, nil
+	}()
+	if err != nil {
+		g.Log().Errorf(r.Context(), "发票查询异常 %v", err)
+	}
+	r.Response.WriteJson(NewResult(rData, err))
+}

+ 99 - 0
internal/controller/invoiceUpload.go

@@ -0,0 +1,99 @@
+package controller
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jypkg/ent/util"
+	"fmt"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/net/ghttp"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/pkg/errors"
+	"jyOrderManager/internal/jyutil"
+	"jyOrderManager/internal/model"
+	"time"
+)
+
+// InvoiceQuery 发票查询
+func InvoiceUpload(r *ghttp.Request) {
+	rData, err := func() (interface{}, error) {
+		var param model.InvoiceUploadParams
+		err := gconv.Struct(r.GetBody(), &param)
+		if err != nil {
+			return nil, errors.Wrap(err, "数据校验异常")
+		}
+		data := make(map[string]interface{})
+		orderInfo, _ := g.DB().GetOne(r.Context(), "SELECT create_time,product_type,user_mail,pay_money,create_time,signing_subject,applybill_status FROM dataexport_order WHERE order_code = ?", param.OrderCode)
+		if orderInfo.IsEmpty() {
+			return nil, errors.New("订单不存在")
+		}
+
+		if common.ObjToString(orderInfo.Map()["signing_subject"]) == "h02" {
+			return nil, errors.New("签约主体为拓普")
+		}
+		data["order_code"] = param.OrderCode
+		data["invoice_order_code"] = param.OrderCode
+		data["invoice_money"] = param.AllMoney
+		data["address_url"] = param.AddressUrl
+		data["invoice_order_money"] = param.Money
+		data["invoice_number"] = param.InvoiceNumber
+		data["billing_time"] = param.BillingTime
+		data["invoicing_entity"] = param.SigningSubject
+		data["invoice_variety"] = param.InvoiceVariety
+		data["invoice_content"] = param.InvoiceContent
+		data["invoice_type"] = param.InvoiceType
+		data["company_name"] = param.CompanyName
+		data["taxpayer_identnum"] = param.TaxpayerIdentnum
+		data["delivery_address"] = param.DeliveryAddress
+		data["phone"] = param.Phone
+		data["operator"] = jyutil.GetUserMsgFromCtx(r.Context()).EntUserId
+		data["source"] = 3
+		data["invoice_status"] = 1
+		if param.Id == 0 {
+			onlyIdentifying := fmt.Sprintf("%s%s%s", "aa", time.Now().Format("150405"), common.GetRandom(4))
+			data["only_Identifying"] = onlyIdentifying
+			data["user_id"] = orderInfo.Map()["user_id"]
+			data["product_type"] = orderInfo.Map()["product_type"]
+			g.DB().Save(r.Context(), "invoice", data)
+			g.DB().Update(r.Context(), "dataexport_order", map[string]interface{}{
+				"applybill_status": 2,
+			}, map[string]interface{}{
+				"order_code": param.OrderCode,
+			})
+		} else {
+			g.DB().Update(r.Context(), "invoice", data, map[string]interface{}{
+				"id": param.Id,
+			})
+			g.DB().Update(r.Context(), "dataexport_order", map[string]interface{}{
+				"applybill_status": 2,
+			}, map[string]interface{}{
+				"order_code": param.OrderCode,
+			})
+		}
+		return nil, nil
+	}()
+	if err != nil {
+		g.Log().Errorf(r.Context(), "发票查询异常 %v", err)
+	}
+	r.Response.WriteJson(NewResult(rData, err))
+}
+
+func InvoiceAmount(orderCode string) (invoicedMoney int64) {
+	invoicedInfo := util.Mysql.SelectBySql(fmt.Sprintf("SELECT invoice_order_money,only_Identifying FROM invoice WHERE order_code = '%s' and invoice_status>=0", orderCode))
+	if invoicedInfo != nil && len(*invoicedInfo) > 0 {
+		onlyMap := make(map[string]int64)
+		for _, m := range *invoicedInfo {
+			if m["only_Identifying"] != nil { //过滤换票过程中的数据
+				onlyMap[common.InterfaceToStr(m["only_Identifying"])] = common.Int64All(m["invoice_order_money"])
+			} else {
+				invoicedMoney += common.Int64All(m["invoice_order_money"])
+			}
+		}
+		if len(onlyMap) > 0 {
+			for _, i := range onlyMap {
+				invoicedMoney += i
+			}
+		}
+	}
+	return
+}

+ 1 - 1
internal/logic/order/detail.go

@@ -284,7 +284,7 @@ WHERE b.order_detail_id=%d`, linkedDetailId))
 FROM jy_order_detail jod
 INNER JOIN entniche_order eo ON jod.id = eo.order_detail_id
 INNER JOIN dataexport_order do on jod.order_code= do.order_code
-WHERE eo.wait_empower_id = %s and jod.is_service_open =1 and jod.status =1 and eo.create_time< '%s' ORDER BY do.create_time desc`, gconv.String(entService.Map()["id"]), orderMap["create_time"]))
+WHERE eo.wait_empower_id = %s and jod.is_service_open =1 and jod.status =1 and do.create_time< '%s' ORDER BY do.create_time desc`, gconv.String(entService.Map()["id"]), orderMap["create_time"]))
 						if !entOrderService.IsEmpty() {
 							for _, m2 := range entOrderService.List() {
 								if endTime == "" && gconv.String(m2["service_endtime"]) != "" {

+ 17 - 0
internal/model/orderParams.go

@@ -254,6 +254,23 @@ type (
 		Money     int64  `json:"money,omitempty"`
 		PayWay    int64  `json:"payWay,omitempty"`
 	}
+	InvoiceUploadParams struct {
+		Id               int    `json:"id,omitempty"`
+		OrderCode        string `json:"orderCode"`
+		Money            int64  `json:"money"`
+		AllMoney         int64  `json:"allMoney"`
+		AddressUrl       string `json:"addressUrl"`
+		InvoiceNumber    string `json:"invoice_number"`
+		BillingTime      string `json:"billing_time"`
+		SigningSubject   string `json:"signing_subject"`
+		InvoiceVariety   string `json:"invoice_variety"`
+		InvoiceContent   string `json:"invoice_content"`
+		InvoiceType      string `json:"invoice_type"`
+		CompanyName      string `json:"company_name"`
+		TaxpayerIdentnum string `json:"taxpayer_identnum"`
+		DeliveryAddress  string `json:"delivery_address,omitempty"`
+		Phone            string `json:"phone,omitempty"`
+	}
 )
 
 // todo 备份