Updata:更新数据创建

This commit is contained in:
jiaji.H 2026-02-02 20:00:28 +08:00
parent 1f8fb4abf8
commit c348409a73
4 changed files with 729 additions and 675 deletions

View File

@ -5,12 +5,34 @@ import (
"micro-bundle/internal/model" "micro-bundle/internal/model"
"micro-bundle/pb/bundle" "micro-bundle/pb/bundle"
"micro-bundle/pkg/app" "micro-bundle/pkg/app"
"strconv"
"time"
) )
func CreateInvoice(req *bundle.CreateInvoiceReq) (res *bundle.CreateInvoiceResp, err error) { func CreateInvoice(req *bundle.CreateInvoiceReq) (res *bundle.CreateInvoiceResp, err error) {
fmt.Println("创建发票信息url=%s,type=%d,no=%s,status=%d,remark=%s", req.InvoiceUrl, req.InvoiceType, req.InvoiceNo, req.PaperInvocieStatus, req.Remark) fmt.Println("创建发票信息url=%s,type=%d,no=%s,status=%d,remark=%s", req.InvoiceUrl, req.InvoiceType, req.InvoiceNo, req.PaperInvocieStatus, req.Remark)
res = new(bundle.CreateInvoiceResp) res = new(bundle.CreateInvoiceResp)
err = app.ModuleClients.BundleDB.Model(&model.Invoice{}).Create(&req).Error userId, err := strconv.Atoi(req.UserId)
if err != nil {
return nil, err
}
applyTime, err := time.Parse(req.ApplyTime, time.DateTime)
if err != nil {
return nil, err
}
inv := &model.Invoice{
UserId: userId,
UserNum: req.UserNum,
UserName: req.UserName,
OrderNo: req.OrderNo,
ApplyTime: applyTime,
InvoiceType: int(req.InvoiceType),
InvoiceNo: req.InvoiceNo,
InvoiceUrl: req.InvoiceUrl,
PaperInvocieStatus: int(req.PaperInvocieStatus),
Remark: req.Remark,
}
err = app.ModuleClients.BundleDB.Model(&model.Invoice{}).Create(inv).Error
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -19,7 +41,28 @@ func CreateInvoice(req *bundle.CreateInvoiceReq) (res *bundle.CreateInvoiceResp,
func CreatePaperInvoiceAddress(req *bundle.CreatePaperInvoiceAddressReq) (res *bundle.CreatePaperInvoiceAddressResp, err error) { func CreatePaperInvoiceAddress(req *bundle.CreatePaperInvoiceAddressReq) (res *bundle.CreatePaperInvoiceAddressResp, err error) {
res = new(bundle.CreatePaperInvoiceAddressResp) res = new(bundle.CreatePaperInvoiceAddressResp)
err = app.ModuleClients.BundleDB.Model(&model.PaperInvoiceAddress{}).Create(&req).Error userId, err := strconv.Atoi(req.UserId)
if err != nil {
return nil, err
}
applyTime, err := time.Parse(req.ApplyTime, time.DateTime)
if err != nil {
return nil, err
}
pia := &model.PaperInvoiceAddress{
UserId: userId,
ApplyTime: applyTime,
OrderNo: req.OrderNo,
InvoiceNo: req.InvoiceNo,
Name: req.Name,
TelAreaCode: req.TelAreaCode,
Phone: req.Phone,
PostalCode: req.PostalCode,
Country: req.Country,
Address: req.Address,
Remark: req.Remark,
}
err = app.ModuleClients.BundleDB.Model(&model.PaperInvoiceAddress{}).Create(pia).Error
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1920,13 +1920,14 @@ message CreatePaperInvoiceAddressReq{
string userId = 1; string userId = 1;
string orderNo = 2; string orderNo = 2;
string invoiceNo = 3; string invoiceNo = 3;
string name = 4; string applyTime = 4;
string telAreaCode = 5; string name = 5;
string phone = 6; string telAreaCode = 6;
string postalCode = 7; string phone = 7;
string country = 8; string postalCode = 8;
string address = 9; string country = 9;
string remark = 10; string address = 10;
string remark = 11;
} }
message CreatePaperInvoiceAddressResp{ message CreatePaperInvoiceAddressResp{

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@ import (
fmt "fmt" fmt "fmt"
math "math" math "math"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
_ "google.golang.org/protobuf/types/descriptorpb" _ "google.golang.org/protobuf/types/descriptorpb"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators" github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
) )