小程序一些功能更新
This commit is contained in:
@@ -90,8 +90,8 @@ func QuotaPacksFor(ctx context.Context, toolKey string) (*v1.QuotaPacksRes, erro
|
||||
return &v1.QuotaPacksRes{List: list}, nil
|
||||
}
|
||||
|
||||
// QuotaOrderCreate 创建次数包订单;与会员订单共用下单/发货链路
|
||||
func QuotaOrderCreate(ctx context.Context, packKey, toolKey, code string) (*v1.QuotaOrderCreateRes, error) {
|
||||
// QuotaOrderCreate 创建次数包订单(**只建单**,N1:与会员套餐两步式同款,共用 createOrder)。
|
||||
func QuotaOrderCreate(ctx context.Context, packKey, toolKey string) (*v1.QuotaOrderCreateRes, error) {
|
||||
userId := CtxUserId(ctx)
|
||||
if !xpayConfig(ctx).Configured() {
|
||||
return nil, gerror.NewCode(gcodePayFail(),
|
||||
@@ -128,27 +128,28 @@ func QuotaOrderCreate(ctx context.Context, packKey, toolKey, code string) (*v1.Q
|
||||
validDays = 365
|
||||
}
|
||||
|
||||
pay, err := prepareXpayOrder(ctx, userId, code, pack.ProductId, pack.PriceCents, g.Map{
|
||||
"order_type": consts.OrderTypeQuota,
|
||||
"pack_key": pack.PackKey,
|
||||
"tool_key": tool.ToolKey,
|
||||
"times": pack.Times,
|
||||
"duration_days": validDays, // 次数包复用 duration_days 承载「有效期天数」
|
||||
})
|
||||
res, err := createOrder(ctx, userId, consts.OrderTypeQuota, pack.ProductId, pack.PriceCents,
|
||||
g.Map{"pack_key": pack.PackKey, "tool_key": tool.ToolKey},
|
||||
g.Map{
|
||||
"order_type": consts.OrderTypeQuota,
|
||||
"pack_key": pack.PackKey,
|
||||
"tool_key": tool.ToolKey,
|
||||
"times": pack.Times,
|
||||
"duration_days": validDays, // 次数包复用 duration_days 承载「有效期天数」
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.QuotaOrderCreateRes{
|
||||
OutTradeNo: pay.OutTradeNo,
|
||||
Mode: consts.XPayMode,
|
||||
SignData: pay.SignData,
|
||||
PaySig: pay.PaySig,
|
||||
Signature: pay.Signature,
|
||||
Env: pay.Env,
|
||||
PackKey: pack.PackKey,
|
||||
ToolKey: tool.ToolKey,
|
||||
Times: pack.Times,
|
||||
ValidDays: validDays,
|
||||
OutTradeNo: res.OutTradeNo,
|
||||
Reused: res.Reused,
|
||||
OriginPriceCents: res.OriginPriceCents,
|
||||
PaidPriceCents: res.PaidPriceCents,
|
||||
PackKey: pack.PackKey,
|
||||
ToolKey: tool.ToolKey,
|
||||
Times: pack.Times,
|
||||
ValidDays: validDays,
|
||||
Status: res.Status,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -156,7 +157,7 @@ func QuotaOrderCreate(ctx context.Context, packKey, toolKey, code string) (*v1.Q
|
||||
|
||||
// quotaListForUser 用户可见(已启用)的全部工具的额度状态
|
||||
func quotaListForUser(ctx context.Context, user *entity.Users) ([]v1.QuotaToolOut, error) {
|
||||
records, err := g.Model(consts.TableTools).Where("is_enabled", 1).Order("sort asc").All()
|
||||
records, err := g.Model(consts.TableTools).Where("is_enabled", 1).WhereNull("deleted_at").Order("sort asc").All()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user