This commit is contained in:
李子铭 2025-03-08 15:17:07 +08:00
parent 874abf205f
commit d8c8ec8f6e
4 changed files with 45 additions and 2 deletions

View File

@ -74,7 +74,16 @@ message CmbQueryRequest {
string codeNo = 9 [json_name = "codeNo", (validate.rules).string = {min_len: 1,max_len: 32}]; string codeNo = 9 [json_name = "codeNo", (validate.rules).string = {min_len: 1,max_len: 32}];
} }
message CmbQueryReply { message CmbQueryReply {
// codeNo
string ticket = 9 [json_name = "ticket"];
// 0使1使
string status = 10 [json_name = "status"];
// yyyy-mm-dd hh:mm:ss.sss
string transDate = 11 [json_name = "transDate"];
//
string orgNo = 12 [json_name = "orgNo"];
//
string ext = 13 [json_name = "ext"];
} }

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"gorm.io/gorm" "gorm.io/gorm"
"time"
v1 "voucher/api/v1" v1 "voucher/api/v1"
"voucher/internal/biz/bo" "voucher/internal/biz/bo"
"voucher/internal/biz/vo" "voucher/internal/biz/vo"
@ -53,7 +54,23 @@ func (v *VoucherBiz) CmbQuery(ctx context.Context, orderNo string) (reps *v1.Cmb
err = lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(ctx, c.Key, func(ctx context.Context) error { err = lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(ctx, c.Key, func(ctx context.Context) error {
reps = &v1.CmbQueryReply{} orderWechat, err := v.OrderWechatRepo.GetByOrderNo(ctx, orderNo)
if err != nil {
return err
}
status, err := orderWechat.Status.GetCmbStatusText()
if err != nil {
return err
}
reps = &v1.CmbQueryReply{
Ticket: orderWechat.OrderNo,
Status: status.GetValue(),
TransDate: time.Now().Format("20060102150405"),
OrgNo: v.bc.Cmb.OrgNo,
Ext: "",
}
return nil return nil
}) })

View File

@ -10,6 +10,7 @@ type OrderWechatRepo interface {
Success(ctx context.Context, id uint64, couponId string) error Success(ctx context.Context, id uint64, couponId string) error
Fail(ctx context.Context, id uint64, remark string) error Fail(ctx context.Context, id uint64, remark string) error
GetByOutRequestNo(ctx context.Context, outRequestNo string) (*bo.OrderWechatBo, error) GetByOutRequestNo(ctx context.Context, outRequestNo string) (*bo.OrderWechatBo, error)
GetByOrderNo(ctx context.Context, orderNo string) (*bo.OrderWechatBo, error)
GetByMSCId(ctx context.Context, mchId, stockId, couponId string) (*bo.OrderWechatBo, error) GetByMSCId(ctx context.Context, mchId, stockId, couponId string) (*bo.OrderWechatBo, error)
Used(ctx context.Context, id uint64) error Used(ctx context.Context, id uint64) error
Expired(ctx context.Context, id uint64) error Expired(ctx context.Context, id uint64) error

View File

@ -85,6 +85,22 @@ func (p *OrderWechatRepoImpl) GetByOutRequestNo(ctx context.Context, outRequestN
return p.ToBo(info), nil return p.ToBo(info), nil
} }
func (p *OrderWechatRepoImpl) GetByOrderNo(ctx context.Context, orderNo string) (*bo.OrderWechatBo, error) {
info := &model.OrderWechat{}
tx := p.DB(ctx).Where(model.OrderWechat{OrderNo: orderNo}).Find(&info)
if tx.Error != nil {
return nil, tx.Error
}
if tx.RowsAffected == 0 {
return nil, gorm.ErrRecordNotFound
}
return p.ToBo(info), nil
}
func (p *OrderWechatRepoImpl) Success(ctx context.Context, id uint64, couponId string) error { func (p *OrderWechatRepoImpl) Success(ctx context.Context, id uint64, couponId string) error {
now := time.Now() now := time.Now()