Skip to content

Commit

Permalink
Merge branch 'feat/coupon' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sjatsh committed Nov 6, 2023
2 parents f4aa1e5 + ef0ed3e commit 7fea789
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dao/t_coupon_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (d *DbDao) UpdateCouponSetInfo(setInfo *tables.CouponSetInfo) error {
}

func (d *DbDao) GetUnPaidCouponSetByAccId(accId string) (res tables.CouponSetInfo, err error) {
if err = d.db.Where("account_id = ? and order_id = ''", accId).First(&res).Error; err != nil {
if err = d.db.Where("account_id = ? and status = ?", accId, tables.CouponSetInfoStatusDefault).First(&res).Error; err != nil {

Check failure on line 82 in dao/t_coupon_info.go

View workflow job for this annotation

GitHub Actions / ci

undefined: tables.CouponSetInfoStatusDefault
if errors.Is(err, gorm.ErrRecordNotFound) {
err = nil
return
Expand Down
6 changes: 4 additions & 2 deletions http_server/handle/coupon_code_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ type RespCouponCodeList struct {
Account string `json:"account" `
Name string `json:"name"`
Note string `json:"note"`
Price string `json:"price" `
Num int `json:"num" `
Price string `json:"price"`
Num int `json:"num"`
Status int `json:"status"`
ExpiredAt int64 `json:"expired_at"`
CreatedAt int64 `json:"created_at"`
List []RespCouponCode `json:"list"`
Expand Down Expand Up @@ -115,6 +116,7 @@ func (h *HttpHandle) doCouponCodeList(req *ReqCouponCodeList, apiResp *api_code.
Note: setInfo.Note,
Price: setInfo.Price.String(),
Num: setInfo.Num,
Status: setInfo.Status,
ExpiredAt: setInfo.ExpiredAt,
CreatedAt: setInfo.CreatedAt.UnixMilli(),
List: make([]RespCouponCode, 0),
Expand Down
2 changes: 1 addition & 1 deletion http_server/handle/coupon_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (h *HttpHandle) couponCreateParamsCheck(req *ReqCouponCreate, apiResp *api_
}
address := common.FormatAddressPayload(res.AddressPayload, res.DasAlgorithmId)

if !strings.EqualFold(accInfo.Manager, address) {
if !strings.EqualFold(accInfo.Manager, address) && !strings.EqualFold(accInfo.Owner, address) {
apiResp.ApiRespErr(api_code.ApiCodeNoAccountPermissions, "no account permissions")
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions http_server/handle/coupon_order_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (h *HttpHandle) doCouponOrderCreate(req *ReqCouponOrderCreate, apiResp *api
apiResp.ApiRespErr(api_code.ApiCodeNoAccountPermissions, "no account permissions")
return nil
}
if setInfo.Status != tables.CouponSetInfoStatusPending {
apiResp.ApiRespErr(api_code.ApiCodeParamsInvalid, "coupon status invalid")
return nil
}

tokenPrice, err := h.DbDao.GetTokenById(req.TokenId)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions tables/t_coupon_set_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

const (
CouponSetInfoStatusPending = 0
CouponSetInfoStatusSuccess = 1
CouponSetInfoStatusFailed = 2
)
Expand Down

0 comments on commit 7fea789

Please sign in to comment.