cmb
This commit is contained in:
parent
874abf205f
commit
d8c8ec8f6e
|
|
@ -74,7 +74,16 @@ message CmbQueryRequest {
|
|||
string codeNo = 9 [json_name = "codeNo", (validate.rules).string = {min_len: 1,max_len: 32}];
|
||||
}
|
||||
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"];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
v1 "voucher/api/v1"
|
||||
"voucher/internal/biz/bo"
|
||||
"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 {
|
||||
|
||||
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
|
||||
})
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ type OrderWechatRepo interface {
|
|||
Success(ctx context.Context, id uint64, couponId string) error
|
||||
Fail(ctx context.Context, id uint64, remark string) 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)
|
||||
Used(ctx context.Context, id uint64) error
|
||||
Expired(ctx context.Context, id uint64) error
|
||||
|
|
|
|||
|
|
@ -85,6 +85,22 @@ func (p *OrderWechatRepoImpl) GetByOutRequestNo(ctx context.Context, outRequestN
|
|||
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 {
|
||||
now := time.Now()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue