feat(card_info_walmart): 添加沃尔玛充值卡账户每日汇总功能
- 新增 AccountDailySummary 和 AccountSummaryDownload 接口 - 实现每日汇总数据的生成和下载功能 - 添加相关模型和逻辑实现
This commit is contained in:
@@ -25,12 +25,12 @@ type SubmitRes struct {
|
||||
type ListReq struct {
|
||||
g.Meta `path:"/cardInfo/cTrip/order/list" tags:"携程充值卡订单" method:"get" summary:"获取充值记录列表"`
|
||||
commonApi.CommonPageReq
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
DateRange []gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
}
|
||||
|
||||
type ListRes struct {
|
||||
|
||||
@@ -25,12 +25,12 @@ type SubmitRes struct {
|
||||
type ListReq struct {
|
||||
g.Meta `path:"/cardInfo/JDCard/order/list" tags:"京东充值卡订单" method:"get" summary:"获取充值记录列表"`
|
||||
commonApi.CommonPageReq
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
DateRange []gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
}
|
||||
|
||||
type ListRes struct {
|
||||
|
||||
@@ -23,6 +23,8 @@ type ICardInfoWalmartV1 interface {
|
||||
AccountCookieBatchCheck(ctx context.Context, req *v1.AccountCookieBatchCheckReq) (res *v1.AccountCookieBatchCheckRes, err error)
|
||||
AccountCookieBatchAdd(ctx context.Context, req *v1.AccountCookieBatchAddReq) (res *v1.AccountCookieBatchAddRes, err error)
|
||||
Download(ctx context.Context, req *v1.DownloadReq) (res *v1.DownloadRes, err error)
|
||||
AccountDailySummary(ctx context.Context, req *v1.AccountDailySummaryReq) (res *v1.AccountDailySummaryRes, err error)
|
||||
AccountSummaryDownload(ctx context.Context, req *v1.AccountSummaryDownloadReq) (res *v1.AccountSummaryDownloadRes, err error)
|
||||
RedeemConfigGet(ctx context.Context, req *v1.RedeemConfigGetReq) (res *v1.RedeemConfigGetRes, err error)
|
||||
RedeemConfigSet(ctx context.Context, req *v1.RedeemConfigSetReq) (res *v1.RedeemConfigSetRes, err error)
|
||||
Submit(ctx context.Context, req *v1.SubmitReq) (res *v1.SubmitRes, err error)
|
||||
|
||||
@@ -3,7 +3,9 @@ package v1
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"kami/api/commonApi"
|
||||
v1 "kami/api/sysUser/v1"
|
||||
"kami/internal/consts"
|
||||
"kami/internal/model/entity"
|
||||
)
|
||||
@@ -147,3 +149,56 @@ type DownloadReq struct {
|
||||
type DownloadRes struct {
|
||||
g.Meta `mime:"application/vnd.ms-excel"`
|
||||
}
|
||||
|
||||
type AccountDailySummaryReq struct {
|
||||
g.Meta `path:"/cardInfo/walmart/account/dailySummary" tags:"沃尔玛充值卡账户" method:"get" summary:"每日汇总"`
|
||||
commonApi.CommonPageReq
|
||||
AccountId string `json:"accountId" description:"用户"`
|
||||
Date *gtime.Time `json:"date" description:"日期"`
|
||||
}
|
||||
|
||||
type CardRedeemAccountSummary struct {
|
||||
g.Meta `orm:"table:card_redeem_account_summary"`
|
||||
Id int `json:"id" orm:"id" description:""`
|
||||
AccountId string `json:"accountId" orm:"account_id" description:""`
|
||||
AmountTotalSum float64 `json:"amountTotalSum" orm:"amount_total_sum" description:""`
|
||||
AmountTodaySum float64 `json:"amountTodaySum" orm:"amount_today_sum" description:""`
|
||||
AmountTotalCount int `json:"amountTotalCount" orm:"amount_total_count" description:""`
|
||||
AmountTodayCount int `json:"amountTodayCount" orm:"amount_today_count" description:""`
|
||||
Date *gtime.Time `json:"date" orm:"date" description:""`
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""`
|
||||
}
|
||||
|
||||
type AccountDailySummaryRecord struct {
|
||||
g.Meta `orm:"table:card_redeem_order_info"`
|
||||
DailySummary *CardRedeemAccountSummary `orm:"with:account_id=id" json:"dailySummary"`
|
||||
UploadUser v1.SysUserRecord `json:"uploadUser" orm:"with:id=create_user_id"`
|
||||
Id string `json:"id" orm:"id" description:""`
|
||||
Name string `json:"name" orm:"name" description:""`
|
||||
Username string `json:"username" orm:"username" description:"京东用户ID"`
|
||||
CreateUserId string `json:"createUserId" orm:"create_user_id" description:"创建人"`
|
||||
Category string `json:"category" orm:"category" description:"账户类型"`
|
||||
Balance float64 `json:"balance" orm:"balance" description:"余额"`
|
||||
Status int `json:"status" orm:"status" description:"状态 1.正常 0.禁用"`
|
||||
Remark string `json:"remark" orm:"remark" description:""`
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""`
|
||||
}
|
||||
|
||||
type AccountDailySummaryRes struct {
|
||||
commonApi.CommonPageRes[*AccountDailySummaryRecord]
|
||||
}
|
||||
|
||||
type AccountSummaryDownloadReq struct {
|
||||
g.Meta `path:"/cardInfo/walmart/account/summaryDownload" tags:"沃尔玛充值卡账户" method:"get" summary:"下载充值账户"`
|
||||
commonApi.CommonPageReq
|
||||
AccountId string `json:"accountId" description:"用户"`
|
||||
Date *gtime.Time `json:"date" description:"日期"`
|
||||
}
|
||||
|
||||
type AccountSummaryDownloadRes struct {
|
||||
g.Meta `mime:"application/vnd.ms-excel"`
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ type SubmitRes struct {
|
||||
type ListReq struct {
|
||||
g.Meta `path:"/cardInfo/walmart/order/list" tags:"沃尔玛充值卡订单" method:"get" summary:"获取充值记录列表"`
|
||||
commonApi.CommonPageReq
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
DateRange []gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
}
|
||||
|
||||
type ListRes struct {
|
||||
|
||||
@@ -9,6 +9,5 @@ type HealthCheckReq struct {
|
||||
}
|
||||
|
||||
type HealthCheckRes struct {
|
||||
g.Meta `json:"application/json"`
|
||||
Ok bool `json:"ok"`
|
||||
Ok bool `json:"ok"`
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/os/gtime"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"kami/internal/model/entity"
|
||||
)
|
||||
|
||||
@@ -37,3 +38,10 @@ type SysUserSimpleRes struct {
|
||||
UserName string `orm:"user_name" json:"userName"` // 用户名
|
||||
UserNickname string `orm:"user_nickname" json:"userNickname"` // 用户昵称
|
||||
}
|
||||
|
||||
type SysUserRecord struct {
|
||||
g.Meta `orm:"table:sys_user"`
|
||||
Id string `json:"id" orm:"id" description:"主键"`
|
||||
Username string `json:"username" orm:"username" description:"账号"`
|
||||
NickName string `json:"nickName" orm:"nick_name" description:"昵称"`
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ type PaymentSummaryListReq struct {
|
||||
}
|
||||
|
||||
type PaymentSummaryRecord struct {
|
||||
Username string `json:"username"`
|
||||
TotalDepositAmount decimal.Decimal `json:"totalDepositAmount"`
|
||||
TotalConsumeAmount decimal.Decimal `json:"totalConsumeAmount"`
|
||||
TotalManualHandleAmount decimal.Decimal `json:"totalManualHandleAmount"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
Username string `json:"username" orm:"username"`
|
||||
TotalDepositAmount decimal.Decimal `json:"totalDepositAmount" orm:"total_deposit_amount"`
|
||||
TotalConsumeAmount decimal.Decimal `json:"totalConsumeAmount" orm:"total_consume_amount"`
|
||||
TotalReturnAmount decimal.Decimal `json:"totalReturnAmount" orm:"total_return_amount"`
|
||||
TotalActualConsumeAmount decimal.Decimal `json:"totalActualConsumeAmount" orm:"total_actual_consume_amount"`
|
||||
TotalManualHandleAmount decimal.Decimal `json:"totalManualHandleAmount" orm:"total_manual_handle_amount"`
|
||||
CreatedAt string `json:"createdAt" orm:"create_at"`
|
||||
}
|
||||
|
||||
type PaymentSummaryListRes struct {
|
||||
|
||||
@@ -34,7 +34,7 @@ type SysPaymentAddReq struct {
|
||||
g.Meta `path:"/sysUser/payment/add" tags:"用户充值" method:"post" summary:"充值"`
|
||||
UserId string `json:"userId" description:"用户ID" v:"required#用户Id不能为空"`
|
||||
TransactionType consts.UserPaymentTransactionType `json:"transactionType" description:"交易类型" v:"required#交易类型不能为空"`
|
||||
Amount decimal.Decimal `json:"amount" description:"充值金额" v:"required|min:0.001#充值金额不能为空|充值金额不能为0"`
|
||||
Amount decimal.Decimal `json:"amount" description:"充值金额" v:"required|min:0.001|max:99999999#充值金额不能为空|充值金额不能为0|充值金额不可大于99999999"`
|
||||
Remark string `json:"remark" description:"备注"`
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ gfcli:
|
||||
merchant_info,merchant_deploy_info,account_info,road_info,road_pool_info,card_apple_account_info,card_apple_account_info_history,card_apple_history_info,
|
||||
card_apple_recharge_info,sys_user,sys_user_login_log,sys_role,sys_casbin_rule,sys_auth_rule,sys_user_payment,sys_user_payment_records,user_info,
|
||||
restrict_client_access_record,restrict_client_access_ip_relation,restrict_ip_order_access,restrict_ip_record,card_redeem_account_deduction,card_redeem_account_history,
|
||||
card_redeem_account_info,card_redeem_order_history,card_redeem_order_info,merchant_hidden_config,merchant_hidden_record"
|
||||
card_redeem_account_info,card_redeem_order_history,card_redeem_order_info,merchant_hidden_config,merchant_hidden_record,card_redeem_account_summary"
|
||||
prefix: v1
|
||||
descriptionTag: true
|
||||
noModelComment: true
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package card_info_walmart
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/duke-git/lancet/v2/slice"
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"kami/api/commonApi"
|
||||
"kami/internal/consts"
|
||||
"kami/internal/errHandler"
|
||||
"kami/internal/model"
|
||||
"kami/internal/service"
|
||||
|
||||
"kami/api/card_info_walmart/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AccountDailySummary(ctx context.Context, req *v1.AccountDailySummaryReq) (res *v1.AccountDailySummaryRes, err error) {
|
||||
userInfo, err := service.SysAuth().LoginWithIFrameAndLogin(ctx)
|
||||
if err != nil {
|
||||
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||
return
|
||||
}
|
||||
total, output, err := service.CardRedeemAccount().GetSummary(ctx, &model.AccountDailySummaryGetInput{
|
||||
AccountDailySummaryReq: req,
|
||||
CreatedUserId: userInfo.Id,
|
||||
Category: consts.CardRedeemAccountCategoryWalMart,
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = &v1.AccountDailySummaryRes{
|
||||
CommonPageRes: commonApi.CommonPageRes[*v1.AccountDailySummaryRecord]{
|
||||
Total: total,
|
||||
CommonDataRes: commonApi.CommonDataRes[*v1.AccountDailySummaryRecord]{
|
||||
List: slice.Map(output, func(index int, item *model.AccountDailySummaryGetOutput) *v1.AccountDailySummaryRecord {
|
||||
return item.AccountDailySummaryRecord
|
||||
}),
|
||||
},
|
||||
},
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package card_info_walmart
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/duke-git/lancet/v2/pointer"
|
||||
"github.com/duke-git/lancet/v2/slice"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/xuri/excelize/v2"
|
||||
"kami/internal/consts"
|
||||
"kami/internal/errHandler"
|
||||
"kami/internal/model"
|
||||
"kami/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"kami/api/card_info_walmart/v1"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) AccountSummaryDownload(ctx context.Context, req *v1.AccountSummaryDownloadReq) (res *v1.AccountSummaryDownloadRes, err error) {
|
||||
userInfo, err := service.SysAuth().LoginWithIFrameAndLogin(ctx)
|
||||
if err != nil {
|
||||
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||
return
|
||||
}
|
||||
_, output, err := service.CardRedeemAccount().GetSummary(ctx, &model.AccountDailySummaryGetInput{
|
||||
AccountDailySummaryReq: &v1.AccountDailySummaryReq{
|
||||
CommonPageReq: req.CommonPageReq,
|
||||
AccountId: req.AccountId,
|
||||
Date: req.Date,
|
||||
},
|
||||
CreatedUserId: userInfo.Id,
|
||||
Category: consts.CardRedeemAccountCategoryWalMart,
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
excel := excelize.NewFile()
|
||||
sw, _ := excel.NewStreamWriter("Sheet1")
|
||||
err = sw.SetRow("A1", []interface{}{
|
||||
"账户", "余额", "今日充值金额", "今日充值次数",
|
||||
"累计充值金额", "累计充值次数", "状态", "创建时间",
|
||||
})
|
||||
slice.ForEach(slice.Filter(output, func(index int, item *model.AccountDailySummaryGetOutput) bool {
|
||||
return !pointer.IsNil(item.DailySummary)
|
||||
}), func(index int, item *model.AccountDailySummaryGetOutput) {
|
||||
_ = sw.SetRow(fmt.Sprintf("A%d", index+2), []interface{}{
|
||||
item.Name, item.Balance, item.DailySummary.AmountTodaySum, item.DailySummary.AmountTodayCount,
|
||||
item.DailySummary.AmountTotalSum, item.DailySummary.AmountTotalCount,
|
||||
consts.RedeemAccountStatus(item.Status).GetStatusText(),
|
||||
item.DailySummary.Date.Format("2006-01-02"),
|
||||
})
|
||||
})
|
||||
_ = sw.Flush()
|
||||
var buffer bytes.Buffer
|
||||
_ = excel.Write(&buffer)
|
||||
_ = excel.Close()
|
||||
g.RequestFromCtx(ctx).Response.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
g.RequestFromCtx(ctx).Response.Header().Add("Content-Disposition", "attachment; filename=apple_card_info_v1_recharge_list_download.xlsx")
|
||||
g.RequestFromCtx(ctx).Response.WriteOverExit(buffer.Bytes())
|
||||
g.RequestFromCtx(ctx).Response.Flush()
|
||||
return
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package sys_payment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/duke-git/lancet/v2/slice"
|
||||
"github.com/jinzhu/copier"
|
||||
"kami/internal/errHandler"
|
||||
"kami/internal/model"
|
||||
@@ -19,6 +20,10 @@ func (c *ControllerV1) PaymentSummaryList(ctx context.Context, req *v1.PaymentSu
|
||||
err = errHandler.WrapError(ctx, errHandler.CornError, err, "获取用户充值统计失败")
|
||||
return
|
||||
}
|
||||
slice.ForEach(data, func(index int, item *model.SysUserRecord) {
|
||||
//消耗减退回是实际消耗
|
||||
item.TotalActualConsumeAmount = item.TotalConsumeAmount.Sub(item.TotalReturnAmount)
|
||||
})
|
||||
res = &v1.PaymentSummaryListRes{}
|
||||
res.Total = total
|
||||
_ = copier.CopyWithOption(&res.List, &data, copier.Option{IgnoreEmpty: true, DeepCopy: true})
|
||||
|
||||
93
internal/dao/internal/v_1_card_redeem_account_summary.go
Normal file
93
internal/dao/internal/v_1_card_redeem_account_summary.go
Normal file
@@ -0,0 +1,93 @@
|
||||
// ==========================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// V1CardRedeemAccountSummaryDao is the data access object for the table card_redeem_account_summary.
|
||||
type V1CardRedeemAccountSummaryDao struct {
|
||||
table string // table is the underlying table name of the DAO.
|
||||
group string // group is the database configuration group name of the current DAO.
|
||||
columns V1CardRedeemAccountSummaryColumns // columns contains all the column names of Table for convenient usage.
|
||||
}
|
||||
|
||||
// V1CardRedeemAccountSummaryColumns defines and stores column names for the table card_redeem_account_summary.
|
||||
type V1CardRedeemAccountSummaryColumns struct {
|
||||
Id string //
|
||||
AccountId string //
|
||||
AmountTotalSum string //
|
||||
AmountTodaySum string //
|
||||
AmountTotalCount string //
|
||||
AmountTodayCount string //
|
||||
Date string //
|
||||
Category string //
|
||||
CreatedAt string //
|
||||
UpdatedAt string //
|
||||
DeletedAt string //
|
||||
}
|
||||
|
||||
// v1CardRedeemAccountSummaryColumns holds the columns for the table card_redeem_account_summary.
|
||||
var v1CardRedeemAccountSummaryColumns = V1CardRedeemAccountSummaryColumns{
|
||||
Id: "id",
|
||||
AccountId: "account_id",
|
||||
AmountTotalSum: "amount_total_sum",
|
||||
AmountTodaySum: "amount_today_sum",
|
||||
AmountTotalCount: "amount_total_count",
|
||||
AmountTodayCount: "amount_today_count",
|
||||
Date: "date",
|
||||
Category: "category",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DeletedAt: "deleted_at",
|
||||
}
|
||||
|
||||
// NewV1CardRedeemAccountSummaryDao creates and returns a new DAO object for table data access.
|
||||
func NewV1CardRedeemAccountSummaryDao() *V1CardRedeemAccountSummaryDao {
|
||||
return &V1CardRedeemAccountSummaryDao{
|
||||
group: "default",
|
||||
table: "card_redeem_account_summary",
|
||||
columns: v1CardRedeemAccountSummaryColumns,
|
||||
}
|
||||
}
|
||||
|
||||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||
func (dao *V1CardRedeemAccountSummaryDao) DB() gdb.DB {
|
||||
return g.DB(dao.group)
|
||||
}
|
||||
|
||||
// Table returns the table name of the current DAO.
|
||||
func (dao *V1CardRedeemAccountSummaryDao) Table() string {
|
||||
return dao.table
|
||||
}
|
||||
|
||||
// Columns returns all column names of the current DAO.
|
||||
func (dao *V1CardRedeemAccountSummaryDao) Columns() V1CardRedeemAccountSummaryColumns {
|
||||
return dao.columns
|
||||
}
|
||||
|
||||
// Group returns the database configuration group name of the current DAO.
|
||||
func (dao *V1CardRedeemAccountSummaryDao) Group() string {
|
||||
return dao.group
|
||||
}
|
||||
|
||||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||
func (dao *V1CardRedeemAccountSummaryDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
|
||||
}
|
||||
|
||||
// Transaction wraps the transaction logic using function f.
|
||||
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||
// It commits the transaction and returns nil if function f returns nil.
|
||||
//
|
||||
// Note: Do not commit or roll back the transaction in function f,
|
||||
// as it is automatically handled by this function.
|
||||
func (dao *V1CardRedeemAccountSummaryDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||
}
|
||||
27
internal/dao/v_1_card_redeem_account_summary.go
Normal file
27
internal/dao/v_1_card_redeem_account_summary.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"kami/internal/dao/internal"
|
||||
)
|
||||
|
||||
// internalV1CardRedeemAccountSummaryDao is an internal type for wrapping the internal DAO implementation.
|
||||
type internalV1CardRedeemAccountSummaryDao = *internal.V1CardRedeemAccountSummaryDao
|
||||
|
||||
// v1CardRedeemAccountSummaryDao is the data access object for the table card_redeem_account_summary.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type v1CardRedeemAccountSummaryDao struct {
|
||||
internalV1CardRedeemAccountSummaryDao
|
||||
}
|
||||
|
||||
var (
|
||||
// V1CardRedeemAccountSummary is a globally accessible object for table card_redeem_account_summary operations.
|
||||
V1CardRedeemAccountSummary = v1CardRedeemAccountSummaryDao{
|
||||
internal.NewV1CardRedeemAccountSummaryDao(),
|
||||
}
|
||||
)
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
@@ -221,7 +221,8 @@ func (a *sCardRedeemAccount) ResetTodayAmountTotal(ctx context.Context) (err err
|
||||
})
|
||||
_, _ = dao.V1CardRedeemAccountInfo.Ctx(ctx).DB(config.GetDatabaseV1()).Where(dao.V1CardRedeemAccountInfo.Columns().Status, consts.RedeemAccountForbiddenByMaxLimit).
|
||||
WhereOr(dao.V1CardRedeemAccountInfo.Columns().Status, consts.RedeemAccountForbiddenDaily).Update(do.V1CardRedeemAccountInfo{
|
||||
Status: consts.RedeemAccountNormal,
|
||||
Status: consts.RedeemAccountForbidden,
|
||||
Remark: "重置今日充值金额",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
80
internal/logic/card_redeem_account/summary.go
Normal file
80
internal/logic/card_redeem_account/summary.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package card_redeem_account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/duke-git/lancet/v2/slice"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"kami/internal/dao"
|
||||
"kami/internal/model"
|
||||
"kami/internal/model/do"
|
||||
"kami/internal/model/entity"
|
||||
"kami/internal/service"
|
||||
"kami/utility/config"
|
||||
"kami/utility/utils"
|
||||
)
|
||||
|
||||
func (a *sCardRedeemAccount) DailySummary(ctx context.Context) (err error) {
|
||||
if err = config.GetDatabaseV1().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||
accountInfo, err2 := service.CardRedeemOrder().DailySummary(ctx, gtime.Now().Add(-gtime.D), tx)
|
||||
if err2 != nil {
|
||||
glog.Error(ctx, "充值订单统计错误", err2)
|
||||
return err2
|
||||
}
|
||||
data := make([]do.V1CardRedeemAccountSummary, 0)
|
||||
for _, output := range accountInfo {
|
||||
data = append(data, do.V1CardRedeemAccountSummary{
|
||||
AccountId: output.AccountId,
|
||||
AmountTotalSum: output.AmountTotalSum,
|
||||
AmountTodaySum: output.Amount,
|
||||
AmountTotalCount: output.AmountTotalCount,
|
||||
AmountTodayCount: output.Count,
|
||||
Date: gtime.Now().Add(-gtime.D),
|
||||
Category: output.Category,
|
||||
})
|
||||
}
|
||||
if len(data) == 0 {
|
||||
return nil
|
||||
}
|
||||
_, err2 = dao.V1CardRedeemAccountSummary.Ctx(ctx).DB(config.GetDatabaseV1()).TX(tx).Data(data).Insert()
|
||||
return err2
|
||||
}); err != nil {
|
||||
glog.Error(ctx, "充值订单统计错误", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (a *sCardRedeemAccount) GetSummary(ctx context.Context, input *model.AccountDailySummaryGetInput, tx gdb.TX) (total int, output []*model.AccountDailySummaryGetOutput, err error) {
|
||||
output = make([]*model.AccountDailySummaryGetOutput, 0)
|
||||
total = 0
|
||||
m := dao.V1CardRedeemAccountInfo.Ctx(ctx).DB(config.GetDatabaseV1())
|
||||
if tx != nil {
|
||||
m = m.TX(tx)
|
||||
}
|
||||
if input.AccountId != "" {
|
||||
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().Id, input.AccountId)
|
||||
}
|
||||
if input.CreatedUserId != "" {
|
||||
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().CreateUserId, input.CreatedUserId)
|
||||
}
|
||||
if input.Category != "" {
|
||||
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().Category, input.Category)
|
||||
}
|
||||
if input.Date != nil {
|
||||
m2 := dao.V1CardRedeemAccountSummary.Ctx(ctx).DB(config.GetDatabaseV1())
|
||||
if tx != nil {
|
||||
m2 = m2.TX(tx)
|
||||
}
|
||||
summaryList := make([]*entity.V1CardRedeemAccountSummary, 0)
|
||||
_ = m2.Where(dao.V1CardRedeemAccountSummary.Columns().Date, input.Date).Scan(&summaryList)
|
||||
if len(summaryList) > 0 {
|
||||
m = m.WhereIn(dao.V1CardRedeemAccountInfo.Columns().Id, slice.Map(summaryList, func(index int, item *entity.V1CardRedeemAccountSummary) string {
|
||||
return item.AccountId
|
||||
}))
|
||||
}
|
||||
}
|
||||
err = m.WithAll().ScanAndCount(&output, &total, false)
|
||||
err = utils.HandleNoRowsError(err)
|
||||
return
|
||||
}
|
||||
22
internal/logic/card_redeem_account/summary_test.go
Normal file
22
internal/logic/card_redeem_account/summary_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package card_redeem_account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
"kami/internal/logic/card_redeem_order"
|
||||
"kami/internal/service"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_sCardRedeemAccount_DailySummary(t *testing.T) {
|
||||
service.RegisterCardRedeemOrder(card_redeem_order.New())
|
||||
accountService := sCardRedeemAccount{}
|
||||
accountService.DailySummary(context.Background())
|
||||
}
|
||||
|
||||
func Test_sCardRedeemAccount_GetSummary(t *testing.T) {
|
||||
service.RegisterCardRedeemOrder(card_redeem_order.New())
|
||||
accountService := sCardRedeemAccount{}
|
||||
_, output, err := accountService.GetSummary(context.Background(), "", "", nil, "", nil)
|
||||
glog.Info(context.Background(), output, err)
|
||||
}
|
||||
67
internal/logic/card_redeem_order/summary.go
Normal file
67
internal/logic/card_redeem_order/summary.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package card_redeem_order
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"kami/internal/consts"
|
||||
"kami/internal/dao"
|
||||
"kami/internal/model"
|
||||
"kami/utility/config"
|
||||
"kami/utility/utils"
|
||||
)
|
||||
|
||||
func (h *sCardRedeemOrder) Summary(ctx context.Context, category consts.CardRedeemAccountCategory, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error) {
|
||||
m := dao.V1CardRedeemOrderInfo.Ctx(ctx).DB(config.GetDatabaseV1())
|
||||
if tx != nil {
|
||||
m = m.TX(tx)
|
||||
}
|
||||
err = m.FieldSum(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().ActualAmount), "amount").
|
||||
FieldCount(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().OrderNo), "count").
|
||||
Fields(
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemAccountInfo.Columns().AmountTotalSum), "amount_total_sum"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemAccountInfo.Columns().AmountTotalCount), "amount_total_count"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemAccountInfo.Columns().Name), "name"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().AccountId), "account_id"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().Category), "category"),
|
||||
utils.OrmAs(fmt.Sprintf("DATE(%s)", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt)), "date"),
|
||||
).
|
||||
LeftJoinOnFields(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().AccountId, "=", dao.V1CardRedeemAccountInfo.Columns().Id).
|
||||
Group(
|
||||
fmt.Sprintf("DATE(%s)", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt)),
|
||||
dao.V1CardRedeemOrderInfo.Columns().AccountId,
|
||||
dao.V1CardRedeemOrderInfo.Columns().Category,
|
||||
).
|
||||
Where(dao.V1CardRedeemAccountInfo.Columns().Category, category).
|
||||
Scan(&output)
|
||||
return
|
||||
}
|
||||
|
||||
// DailySummary 查询某个用户当日的订单总额
|
||||
func (h *sCardRedeemOrder) DailySummary(ctx context.Context, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error) {
|
||||
m := dao.V1CardRedeemOrderInfo.Ctx(ctx).DB(config.GetDatabaseV1())
|
||||
if tx != nil {
|
||||
m = m.TX(tx)
|
||||
}
|
||||
err = m.FieldSum(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().ActualAmount), "amount").
|
||||
FieldCount(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().OrderNo), "count").
|
||||
Fields(
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemAccountInfo.Columns().AmountTotalSum), "amount_total_sum"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemAccountInfo.Columns().AmountTotalCount), "amount_total_count"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemAccountInfo.Columns().Name), "name"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().AccountId), "account_id"),
|
||||
utils.OrmAs(utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().Category), "category"),
|
||||
utils.OrmAs(fmt.Sprintf("DATE(%s)", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt)), "date"),
|
||||
).
|
||||
LeftJoinOnFields(dao.V1CardRedeemAccountInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().AccountId, "=", dao.V1CardRedeemAccountInfo.Columns().Id).
|
||||
Group(
|
||||
fmt.Sprintf("DATE(%s)", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt)),
|
||||
dao.V1CardRedeemOrderInfo.Columns().AccountId,
|
||||
dao.V1CardRedeemOrderInfo.Columns().Category,
|
||||
).
|
||||
//Where(dao.V1CardRedeemAccountInfo.Columns().Status, consts.RedeemOrderSuccess).
|
||||
//Where(fmt.Sprintf("DATE(%s)=?", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt)), date.Format("Y-m-d")).
|
||||
Scan(&output)
|
||||
return
|
||||
}
|
||||
13
internal/logic/card_redeem_order/summary_test.go
Normal file
13
internal/logic/card_redeem_order/summary_test.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package card_redeem_order
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||
"kami/internal/consts"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_sCardRedeemOrder_Summary(t *testing.T) {
|
||||
orderInfo := sCardRedeemOrder{}
|
||||
orderInfo.Summary(context.Background(), consts.CardRedeemAccountCategoryWalMart, nil)
|
||||
}
|
||||
1
internal/logic/sys_user/model.go
Normal file
1
internal/logic/sys_user/model.go
Normal file
@@ -0,0 +1 @@
|
||||
package sysUser
|
||||
@@ -10,9 +10,10 @@ import (
|
||||
|
||||
func (s *sSysUserPayment) DailySummary(ctx context.Context, input model.SysUserPaymentDailySummaryInput) (total int, record []*model.SysUserRecord, err error) {
|
||||
m := dao.V1SysUserPaymentRecords.Ctx(ctx).DB(config.GetDatabaseV1()).
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'deposit' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "totalDepositAmount").
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'consumption' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "totalConsumeAmount").
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'Manual Adjustment' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "totalManualHandleAmount").
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'deposit' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "total_deposit_amount").
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'deduction_return' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "total_return_amount").
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'consumption' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "total_consume_amount").
|
||||
FieldSum(fmt.Sprintf("CASE WHEN %s = 'Manual Adjustment' THEN %s ELSE 0 END", dao.V1SysUserPaymentRecords.Columns().TransactionType, dao.V1SysUserPaymentRecords.Columns().Amount), "total_manual_handle_amount").
|
||||
Fields(fmt.Sprintf("DATE(`%s`.`%s`) AS %s", dao.V1SysUserPaymentRecords.Table(), dao.V1SysUserPaymentRecords.Columns().CreatedAt, dao.V1SysUserPaymentRecords.Columns().CreatedAt)).
|
||||
Fields(dao.V1SysUser.Columns().Username).
|
||||
Group(
|
||||
|
||||
@@ -3,6 +3,7 @@ package model
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
v1 "kami/api/card_info_walmart/v1"
|
||||
"kami/api/commonApi"
|
||||
"kami/internal/consts"
|
||||
"kami/internal/model/entity"
|
||||
@@ -105,12 +106,33 @@ type RedeemCardSubmitInput struct {
|
||||
|
||||
type RedeemCardListInput struct {
|
||||
commonApi.CommonPageReq
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
DateRange []gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||
Attach string `json:"attach" description:"附加信息"`
|
||||
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
||||
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||
UserId string
|
||||
Category consts.CardRedeemAccountCategory
|
||||
}
|
||||
|
||||
type RedeemCardSummaryOutput struct {
|
||||
Count int `orm:"count" json:"count"`
|
||||
AmountTotalCount int `orm:"amount_total_count" json:"amountTotalCount"`
|
||||
AmountTotalSum float64 `orm:"amount_total_sum" json:"amountTotalSum"`
|
||||
Amount float64 `orm:"amount" json:"amount"`
|
||||
AccountId string `orm:"account_id" json:"accountId"`
|
||||
Date string `orm:"date" json:"date"`
|
||||
Name string `orm:"name" json:"name"`
|
||||
Category consts.CardRedeemAccountCategory `orm:"category" json:"category"`
|
||||
}
|
||||
|
||||
type AccountDailySummaryGetInput struct {
|
||||
*v1.AccountDailySummaryReq
|
||||
CreatedUserId string
|
||||
Category consts.CardRedeemAccountCategory
|
||||
}
|
||||
|
||||
type AccountDailySummaryGetOutput struct {
|
||||
*v1.AccountDailySummaryRecord
|
||||
}
|
||||
|
||||
26
internal/model/do/v_1_card_redeem_account_summary.go
Normal file
26
internal/model/do/v_1_card_redeem_account_summary.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package do
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// V1CardRedeemAccountSummary is the golang structure of table card_redeem_account_summary for DAO operations like Where/Data.
|
||||
type V1CardRedeemAccountSummary struct {
|
||||
g.Meta `orm:"table:card_redeem_account_summary, do:true"`
|
||||
Id interface{} //
|
||||
AccountId interface{} //
|
||||
AmountTotalSum interface{} //
|
||||
AmountTodaySum interface{} //
|
||||
AmountTotalCount interface{} //
|
||||
AmountTodayCount interface{} //
|
||||
Date *gtime.Time //
|
||||
Category interface{} //
|
||||
CreatedAt *gtime.Time //
|
||||
UpdatedAt *gtime.Time //
|
||||
DeletedAt *gtime.Time //
|
||||
}
|
||||
24
internal/model/entity/v_1_card_redeem_account_summary.go
Normal file
24
internal/model/entity/v_1_card_redeem_account_summary.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// =================================================================================
|
||||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
// =================================================================================
|
||||
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// V1CardRedeemAccountSummary is the golang structure for table v1card_redeem_account_summary.
|
||||
type V1CardRedeemAccountSummary struct {
|
||||
Id int `json:"id" orm:"id" description:""`
|
||||
AccountId string `json:"accountId" orm:"account_id" description:""`
|
||||
AmountTotalSum float64 `json:"amountTotalSum" orm:"amount_total_sum" description:""`
|
||||
AmountTodaySum float64 `json:"amountTodaySum" orm:"amount_today_sum" description:""`
|
||||
AmountTotalCount int `json:"amountTotalCount" orm:"amount_total_count" description:""`
|
||||
AmountTodayCount int `json:"amountTodayCount" orm:"amount_today_count" description:""`
|
||||
Date *gtime.Time `json:"date" orm:"date" description:""`
|
||||
Category string `json:"category" orm:"category" description:""`
|
||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""`
|
||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""`
|
||||
}
|
||||
@@ -76,6 +76,8 @@ type (
|
||||
CheckForbiddenByTooFast(ctx context.Context)
|
||||
// GetNextOneSortByAccount 轮换策略,按照充值账户来轮换
|
||||
GetNextOneSortByAccount(ctx context.Context, category consts.CardRedeemAccountCategory, chargeAmount float64, tx gdb.TX) (output *entity.V1CardRedeemAccountInfo, err error)
|
||||
DailySummary(ctx context.Context) (err error)
|
||||
GetSummary(ctx context.Context, input *model.AccountDailySummaryGetInput, tx gdb.TX) (total int, output []*model.AccountDailySummaryGetOutput, err error)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"kami/internal/model/entity"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -50,6 +51,9 @@ type (
|
||||
ModifyCallBackStatus(ctx context.Context, orderNo string, callbackStatus consts.RedeemOrderCallbackStatus, tx gdb.TX) (err error)
|
||||
// UpdateCardNoAndCardType 更新卡号和卡种
|
||||
UpdateCardNoAndCardType(ctx context.Context, orderNo string, cardNo string, cardTypeName string, tx gdb.TX) (err error)
|
||||
Summary(ctx context.Context, category consts.CardRedeemAccountCategory, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
|
||||
// DailySummary 查询某个用户当日的订单总额
|
||||
DailySummary(ctx context.Context, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -49,12 +49,12 @@ type (
|
||||
GetRedeemCardCompensatedAutoCallback(ctx context.Context, category consts.CardRedeemAccountCategory) (isAllow bool)
|
||||
// GetRedeemCardRate 设置单位内充值速率
|
||||
GetRedeemCardRate(ctx context.Context, category consts.CardRedeemAccountCategory) (rate int)
|
||||
// GetIsAllowedRepeated 获取是否允许重复上传
|
||||
GetIsAllowedRepeated(ctx context.Context, category consts.CardRedeemAccountCategory) (isAllow bool)
|
||||
GetMaxAccountRedeemCount(ctx context.Context, category consts.CardRedeemAccountCategory) (count int)
|
||||
SetMaxAccountRedeemCount(ctx context.Context, category consts.CardRedeemAccountCategory, count int) (isAllow bool)
|
||||
// SetIsAllowedRepeated 获取是否允许重复上传
|
||||
SetIsAllowedRepeated(ctx context.Context, category consts.CardRedeemAccountCategory, isAllow bool) (err error)
|
||||
// GetIsAllowedRepeated 获取是否允许重复上传
|
||||
GetIsAllowedRepeated(ctx context.Context, category consts.CardRedeemAccountCategory) (isAllow bool)
|
||||
SetRedeemCardRate(ctx context.Context, category consts.CardRedeemAccountCategory, rate int)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -40,6 +40,8 @@ RUN if [ "1" = "1" ]; then \
|
||||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone && chmod +x /app/wait-for-it.sh
|
||||
|
||||
#添加health检查
|
||||
HEALTHCHECK --interval=5s --timeout=3s --retries=3 CMD curl -f http://127.0.0.1:12401/api/monitor/heathcheck || exit 1
|
||||
# 启动服务
|
||||
CMD ["/bin/sh","/app/wait-for-it.sh", "mysql:3306", "/app/main"]
|
||||
|
||||
|
||||
@@ -20,8 +20,13 @@ func Register(ctx context.Context) {
|
||||
if err := service.AppleAccount().ResetStatus(ctx, nil); err != nil {
|
||||
glog.Error(ctx, "重置苹果账户状态失败", err)
|
||||
}
|
||||
glog.Info(ctx, "每日0时执行,重置充值账户状态")
|
||||
if err := service.CardRedeemAccount().ResetTodayAmountTotal(ctx); err != nil {
|
||||
glog.Error(ctx, "重置京东账户状态失败", err)
|
||||
glog.Error(ctx, "重置充值账户状态", err)
|
||||
}
|
||||
glog.Info(ctx, "每日0时执行,每日账户充值统计")
|
||||
if err := service.CardRedeemAccount().DailySummary(ctx); err != nil {
|
||||
glog.Error(ctx, "每日账户充值统计失败", err)
|
||||
}
|
||||
})
|
||||
_, _ = gcron.AddSingleton(ctx, "@every 10m", func(ctx context.Context) {
|
||||
@@ -37,10 +42,4 @@ func Register(ctx context.Context) {
|
||||
//处理大多数轮询订单
|
||||
_ = service.CardRedeemOrder().TriggerConsumeWithContext(ctx)
|
||||
})
|
||||
//syncCfg := config.NewConfig(ctx).GetTMallSync()
|
||||
//if syncCfg.Interval != 0 {
|
||||
// _, _ = gcron.AddSingleton(ctx, fmt.Sprintf("@every %ds", syncCfg.Interval), func(ctx context.Context) {
|
||||
// SyncTMallGameData(ctx)
|
||||
// })
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package utils
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
@@ -11,6 +10,14 @@ func OrmLike(s string) string {
|
||||
return fmt.Sprintf("%%%s%%", s)
|
||||
}
|
||||
|
||||
func OrmTable(table string, column string) string {
|
||||
return fmt.Sprintf("`%s`.`%s`", table, column)
|
||||
}
|
||||
|
||||
func OrmAs(field, column string) string {
|
||||
return fmt.Sprintf("%s AS `%s`", field, column)
|
||||
}
|
||||
|
||||
func HandleNoRowsError(err error) error {
|
||||
if gerror.Is(err, sql.ErrNoRows) {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user