This commit is contained in:
ziming 2025-05-23 17:39:42 +08:00
parent 7883156d26
commit 0a45f678b8
5 changed files with 67 additions and 17 deletions

View File

@ -56,14 +56,23 @@ service Cmb {
};
}
rpc Test (Empty) returns (Empty) {
rpc BatchQuery (BatchQueryRequest) returns (Empty) {
option (google.api.http) = {
post: "/voucher/cmb/v1/test",
body: "*"
};
}
}
message BatchQueryRequest {
repeated string order_ids = 5 [json_name = "order_ids"];
string begin_time = 6 [json_name = "begin_time"];
string end_time = 7 [json_name = "end_time"];
}
message CmbRequest {
//
// ID32

View File

@ -19,11 +19,6 @@ func (v *VoucherBiz) Notice(ctx context.Context) error {
return err
}
return v.ExecuteNotice(ctx)
}
func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error {
now := time.Now()
// 获取七天前的日期
@ -41,6 +36,11 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error {
EndTime: &endTime,
}
return v.ExecuteNotice(ctx, req)
}
func (v *VoucherBiz) ExecuteNotice(ctx context.Context, req *bo.FindInBatchesUseBo) error {
return v.OrderRepo.FindInBatches(ctx, req, func(ctx context.Context, rows []*bo.OrderBo) error {
for _, order := range rows {

View File

@ -62,12 +62,3 @@ func (s *CmbService) DecryptBody(ctx context.Context, request *v1.EncryptBodyReq
DecryptBody: decryptBody,
}, nil
}
func (s *CmbService) Test(ctx context.Context, request *v1.Empty) (*v1.Empty, error) {
if err := s.VoucherBiz.ExecuteNotice(ctx); err != nil {
return nil, err
}
return nil, nil
}

View File

@ -0,0 +1,39 @@
package service
import (
"context"
"fmt"
v1 "voucher/api/v1"
"voucher/internal/biz/bo"
"voucher/internal/biz/vo"
"voucher/internal/pkg/helper"
)
func (s *CmbService) BatchQuery(ctx context.Context, request *v1.BatchQueryRequest) (*v1.Empty, error) {
req := &bo.FindInBatchesUseBo{
Type: vo.OrderTypeCmb,
}
if len(request.BeginTime) > 0 {
beginTime, err := helper.Parse(request.BeginTime)
if err != nil {
return nil, err
}
req.StartTime = &beginTime
}
if len(request.EndTime) > 0 {
endTime, err := helper.Parse(request.EndTime)
if err != nil {
return nil, err
}
req.EndTime = &endTime
}
if req.StartTime == nil || req.EndTime == nil {
return nil, fmt.Errorf("时间范围错误")
}
return nil, s.VoucherBiz.ExecuteNotice(ctx, req)
}

View File

@ -136,12 +136,12 @@ paths:
post:
tags:
- Cmb
operationId: Cmb_Test
operationId: Cmb_BatchQuery
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/api.v1.Empty'
$ref: '#/components/schemas/api.v1.BatchQueryRequest'
required: true
responses:
"200":
@ -152,6 +152,17 @@ paths:
$ref: '#/components/schemas/api.v1.Empty'
components:
schemas:
api.v1.BatchQueryRequest:
type: object
properties:
order_ids:
type: array
items:
type: string
begin_time:
type: string
end_time:
type: string
api.v1.CmbOrderRequest:
type: object
properties: