This commit is contained in:
戴育兵 2026-02-10 11:36:15 +08:00
commit 1a9f538001
7 changed files with 1124 additions and 805 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1096,3 +1096,9 @@ func (this *GetLastInvoiceNoResp) Validate() error {
func (this *OrderInfoByOrderUuidRequest) Validate() error {
return nil
}
func (this *UpdataInvoiceInfoReq) Validate() error {
return nil
}
func (this *UpdataInvoiceInfoResp) Validate() error {
return nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v3.21.1
// - protoc-gen-go-triple v1.0.5
// - protoc v5.26.0
// source: pb/bundle.proto
package bundle
@ -132,6 +132,7 @@ type BundleClient interface {
GetOrderInfoByOrderNo(ctx context.Context, in *GetOrderInfoByOrderNoReq, opts ...grpc_go.CallOption) (*GetOrderInfoByOrderNoResp, common.ErrorWithAttachment)
GetInvoiceInfoByOrderNo(ctx context.Context, in *GetInvoiceInfoByOrderNoReq, opts ...grpc_go.CallOption) (*GetInvoiceInfoByOrderNoResp, common.ErrorWithAttachment)
GetLastInvoiceNo(ctx context.Context, in *GetLastInvoiceNoReq, opts ...grpc_go.CallOption) (*GetLastInvoiceNoResp, common.ErrorWithAttachment)
UpdataInvoiceInfo(ctx context.Context, in *UpdataInvoiceInfoReq, opts ...grpc_go.CallOption) (*UpdataInvoiceInfoResp, common.ErrorWithAttachment)
// 临时接口
ExportWorkCastInfo(ctx context.Context, in *ExportWorkCastInfoReq, opts ...grpc_go.CallOption) (*ExportWorkCastInfoResp, common.ErrorWithAttachment)
// 客户管理
@ -249,6 +250,7 @@ type BundleClientImpl struct {
GetOrderInfoByOrderNo func(ctx context.Context, in *GetOrderInfoByOrderNoReq) (*GetOrderInfoByOrderNoResp, error)
GetInvoiceInfoByOrderNo func(ctx context.Context, in *GetInvoiceInfoByOrderNoReq) (*GetInvoiceInfoByOrderNoResp, error)
GetLastInvoiceNo func(ctx context.Context, in *GetLastInvoiceNoReq) (*GetLastInvoiceNoResp, error)
UpdataInvoiceInfo func(ctx context.Context, in *UpdataInvoiceInfoReq) (*UpdataInvoiceInfoResp, error)
ExportWorkCastInfo func(ctx context.Context, in *ExportWorkCastInfoReq) (*ExportWorkCastInfoResp, error)
GetCustomerList func(ctx context.Context, in *CustomerListRequest) (*CustomerListResponse, error)
GetCustomerDetail func(ctx context.Context, in *CustomerDetailRequest) (*CustomerDetailResponse, error)
@ -845,6 +847,12 @@ func (c *bundleClient) GetLastInvoiceNo(ctx context.Context, in *GetLastInvoiceN
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetLastInvoiceNo", in, out)
}
func (c *bundleClient) UpdataInvoiceInfo(ctx context.Context, in *UpdataInvoiceInfoReq, opts ...grpc_go.CallOption) (*UpdataInvoiceInfoResp, common.ErrorWithAttachment) {
out := new(UpdataInvoiceInfoResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdataInvoiceInfo", in, out)
}
func (c *bundleClient) ExportWorkCastInfo(ctx context.Context, in *ExportWorkCastInfoReq, opts ...grpc_go.CallOption) (*ExportWorkCastInfoResp, common.ErrorWithAttachment) {
out := new(ExportWorkCastInfoResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -1025,6 +1033,7 @@ type BundleServer interface {
GetOrderInfoByOrderNo(context.Context, *GetOrderInfoByOrderNoReq) (*GetOrderInfoByOrderNoResp, error)
GetInvoiceInfoByOrderNo(context.Context, *GetInvoiceInfoByOrderNoReq) (*GetInvoiceInfoByOrderNoResp, error)
GetLastInvoiceNo(context.Context, *GetLastInvoiceNoReq) (*GetLastInvoiceNoResp, error)
UpdataInvoiceInfo(context.Context, *UpdataInvoiceInfoReq) (*UpdataInvoiceInfoResp, error)
// 临时接口
ExportWorkCastInfo(context.Context, *ExportWorkCastInfoReq) (*ExportWorkCastInfoResp, error)
// 客户管理
@ -1333,6 +1342,9 @@ func (UnimplementedBundleServer) GetInvoiceInfoByOrderNo(context.Context, *GetIn
func (UnimplementedBundleServer) GetLastInvoiceNo(context.Context, *GetLastInvoiceNoReq) (*GetLastInvoiceNoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetLastInvoiceNo not implemented")
}
func (UnimplementedBundleServer) UpdataInvoiceInfo(context.Context, *UpdataInvoiceInfoReq) (*UpdataInvoiceInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdataInvoiceInfo not implemented")
}
func (UnimplementedBundleServer) ExportWorkCastInfo(context.Context, *ExportWorkCastInfoReq) (*ExportWorkCastInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ExportWorkCastInfo not implemented")
}
@ -4152,6 +4164,35 @@ func _Bundle_GetLastInvoiceNo_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _Bundle_UpdataInvoiceInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdataInvoiceInfoReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("UpdataInvoiceInfo", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
func _Bundle_ExportWorkCastInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ExportWorkCastInfoReq)
if err := dec(in); err != nil {
@ -4887,6 +4928,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "GetLastInvoiceNo",
Handler: _Bundle_GetLastInvoiceNo_Handler,
},
{
MethodName: "UpdataInvoiceInfo",
Handler: _Bundle_UpdataInvoiceInfo_Handler,
},
{
MethodName: "ExportWorkCastInfo",
Handler: _Bundle_ExportWorkCastInfo_Handler,

View File

@ -22,6 +22,7 @@ func BundleOrderRouter(r *gin.RouterGroup) {
// 套餐
{
bundleOrderNoAuthRoute.POST("common/web/no-auth/reconciliation-list-download", bundle.GetReconciliationListDownload)
bundleOrderNoAuthRoute.POST("common/web/no-auth/creat-invoice", bundle.CreatInvoice)
bundleOrderClientWebRoute := bundleOrderWebRoute.Group("common/web")
{
bundleOrderClientWebRoute.POST("bundle-order-list", bundle.OrderRecordsList)
@ -38,6 +39,7 @@ func BundleOrderRouter(r *gin.RouterGroup) {
bundleOrderClientWebRoute.POST("updata-invoice-express-info", bundle.UpdateInvoiceExpressInfo)
bundleOrderClientWebRoute.GET("country-list", bundle.GetCountryList)
bundleOrderClientWebRoute.POST("export-invoice", bundle.ExportInvoice)
bundleOrderClientWebRoute.POST("download-invoice", bundle.CreateDownloadInvoice)
}
bundleOrderClientAppRoute := bundleOrderRoute.Group("common/app")
{

View File

@ -12,6 +12,7 @@ import (
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/service/bundle/common"
"fonchain-fiee/pkg/service/bundle/logic"
"fonchain-fiee/pkg/service/bundle/model"
bundleModel "fonchain-fiee/pkg/service/bundle/model"
"fonchain-fiee/pkg/service/upload"
"strconv"
@ -1211,3 +1212,62 @@ func ExportOrderInfoOss(c *gin.Context) {
service.Success(c, &bundleModel.ExportResponse{ExportUrl: exportUrl})
}
func CreatInvoice(c *gin.Context) {
var orderInof model.InvoiceInfo
if err := c.ShouldBindBodyWith(&orderInof, binding.JSON); err != nil {
service.Error(c, err)
return
}
//生成发票
orderRecord, err := service.BundleProvider.GetOrderInfoByOrderNo(context.Background(), &bundle.GetOrderInfoByOrderNoReq{
Uuid: orderInof.OrderUUID,
})
if err != nil {
service.Error(c, err)
return
}
amountType := strconv.FormatInt(orderRecord.AmountType, 10)
applyTime := orderInof.ApplyTime
payTime, _ := time.Parse("2006-01-02 15:04:05", applyTime)
payTimeString := payTime.Format("20060102")
fmt.Println("发票payTimeString :", payTimeString, "发票applyTime :", applyTime, "发票payTime :", payTime)
fmt.Println("发票时间数据获取完成")
err = createInvoice(orderRecord.UserId, orderRecord.UserNum, orderRecord.UserName, orderRecord.Address, orderRecord.Phone, orderRecord.BundleName, orderRecord.OrderNo, "1", amountType, orderRecord.TotalAmount, payTimeString, payTimeString, applyTime)
if err != nil {
service.Error(c, errors.New("生成发票失败"))
return
}
service.Success(c, "生成发票成功")
}
func CreateDownloadInvoice(c *gin.Context) {
var orderInof model.InvoiceDownloadInfo
if err := c.ShouldBindBodyWith(&orderInof, binding.JSON); err != nil {
service.Error(c, err)
return
}
//生成发票
orderRecord, err := service.BundleProvider.GetOrderInfoByOrderNo(context.Background(), &bundle.GetOrderInfoByOrderNoReq{
Uuid: orderInof.OrderNo,
})
if err != nil {
service.Error(c, err)
return
}
amountType := strconv.FormatInt(orderRecord.AmountType, 10)
applyTime := orderRecord.PayTime
payTime, _ := time.Parse("2006-01-02 15:04:05", applyTime)
payTimeString := payTime.Format("20060102")
fmt.Println("发票payTimeString :", payTimeString, "发票applyTime :", applyTime, "发票payTime :", payTime)
fmt.Println("发票时间数据获取完成")
invoiceUrl, err := createDownloadInvoice(orderRecord.UserId, orderRecord.UserNum, orderRecord.UserName, orderRecord.Address, orderRecord.Phone, orderRecord.BundleName, orderRecord.OrderNo, "1", amountType, orderRecord.TotalAmount, payTimeString, payTimeString, applyTime)
if err != nil {
fmt.Println("生成发票失败:", err)
service.Error(c, errors.New("生成发票失败:"+err.Error()))
return
}
service.Success(c, &bundleModel.ExportResponse{ExportUrl: invoiceUrl})
}

View File

@ -13,3 +13,12 @@ const (
type ExportResponse struct {
ExportUrl string `json:"exportUrl"`
}
type InvoiceInfo struct {
ApplyTime string `json:"applyTime"`
OrderUUID string `json:"orderUuid"`
}
type InvoiceDownloadInfo struct {
OrderNo string `json:"orderNo"`
}

View File

@ -1055,9 +1055,10 @@ func createInvoice(userId, userNum, userName, address, phone, bundleName, orderN
fmt.Println("当前发票号码:", currentInvoiceNo)
invoiceDate = time.Now().Format("20060102")
payTime, _ := time.Parse("2006-01-02 15:04:05", applyTime)
transactionDate = payTime.Format("2006-01-02")
invoiceUrl, err := invoice.MakeInvoice(currentInvoiceNo, userName, address, phone, bundleName, spec, priceType, totalAmount, transactionDate, invoiceDate)
invoiceUrl, err := invoice.MakeInvoice(currentInvoiceNo, userName, address, phone, bundleName, spec, priceType, totalAmount, transactionDate, "")
if err != nil {
return err
}
@ -1083,3 +1084,38 @@ func createInvoice(userId, userNum, userName, address, phone, bundleName, orderN
return nil
}
func createDownloadInvoice(userId, userNum, userName, address, phone, bundleName, orderNo, spec, priceType, totalAmount, transactionDate, invoiceDate, applyTime string) (string, error) {
// InvoiceInfo 发票信息
currentInvoiceNo := ""
// 获取 lastestInvoiceNo CNY-ART-202501010001的 长度
InvoiceInfo, err := service.BundleProvider.GetInvoiceInfoByOrderNo(context.Background(), &bundle.GetInvoiceInfoByOrderNoReq{
UserId: userId,
OrderNo: orderNo,
})
if err != nil {
return "", err
}
if InvoiceInfo.Data[0].InvoiceNo != "" {
currentInvoiceNo = InvoiceInfo.Data[0].InvoiceNo
} else {
fmt.Println("获取发票号码失败:没有找到发票号码")
return "", errors.New("获取发票号码失败:没有找到发票号码")
}
fmt.Println("当前发票号码:", currentInvoiceNo)
payTime, _ := time.Parse("2006-01-02 15:04:05", applyTime)
transactionDate = payTime.Format("2006-01-02")
invoiceDate = time.Now().Format("2006-01-02")
invoiceUrl, err := invoice.MakeInvoice(currentInvoiceNo, userName, address, phone, bundleName, spec, priceType, totalAmount, transactionDate, invoiceDate)
if err != nil {
return "", err
}
fmt.Println("发票生成成功URL:", invoiceUrl)
return invoiceUrl, nil
}