feat(card_info_walmart): 添加分组统计功能
在沃尔玛充值卡账户模块中新增了分组统计接口,支持获取各分组的账户统计信息,包括总数、正常状态和异常状态的账户数量及金额。同时,优化了相关数据模型和服务逻辑,提升了系统的统计能力和数据处理效率。这些改进有助于增强用户对账户状态的监控和管理。 feat(card_info_walmart): 更新分组统计功能和数据模型 在沃尔玛充值卡账户模块中,增强了分组统计功能,支持按日期、类别和创建用户ID进行统计。同时,优化了相关数据模型,确保统计结果的准确性和完整性。这些改进提升了系统的统计能力和用户对账户状态的管理效率。 feat(card_info_walmart): 更新分组统计功能以支持数据库配置 在沃尔玛充值卡账户模块中,更新了分组统计功能,新增了数据库配置的支持,确保在不同数据库环境下的正确操作。这些改进提升了系统的灵活性和稳定性。 feat(card_info_walmart): 更新分组统计功能以支持数据库配置 在沃尔玛充值卡账户模块中,修改了分组统计功能,新增了数据库配置支持,确保在不同数据库环境下的正确操作。这些改进提升了系统的灵活性和稳定性。 feat(card_info_walmart): 新增订单导出功能 在沃尔玛充值卡账户模块中,新增了订单导出接口,支持将订单信息导出为Excel文件。此功能包括订单的详细信息,如卡号、卡密、商户订单号等,提升了用户对订单数据的管理和分析能力。 feat(card_info_walmart): 增强订单导出功能的错误处理 在沃尔玛充值卡账户模块中,优化了订单导出功能,新增了错误处理逻辑以确保在获取订单列表失败时能够正确返回错误信息。同时,添加了数据缓冲到本地的注释,提升了代码的可读性和维护性。 feat(card_info_walmart): 新增账户分组导出功能 在沃尔玛充值卡账户模块中,新增了账户分组导出接口,支持将账户分组信息导出为Excel文件。此功能包括上传人昵称、分组名称、正常账户数量等详细信息,提升了用户对账户数据的管理和分析能力。同时,更新了分组统计功能以支持用户权限验证,确保数据安全性。 fix(card_info_walmart): 修正创建用户ID字段名称 在沃尔玛充值卡账户模块中,修正了分组统计功能中创建用户ID字段的名称,从`created_user_id`更改为`create_user_id`,确保SQL查询的正确性。这一改动提升了数据查询的准确性。 feat(card_info_walmart): 更新账户分组和订单导出功能 在沃尔玛充值卡账户模块中,新增了账户分组实体的删除状态字段,并在分组统计和订单导出功能中优化了分页逻辑,确保在当前页和每页大小为零时的处理。同时,增强了对已删除账户的统计,提升了数据的准确性和完整性。这些改进有助于用户更好地管理和分析账户数据。 feat(card_info_walmart): 增强账户分组导出功能 在沃尔玛充值卡账户模块中,更新了账户分组导出功能,新增了已删除账户数量的统计,并将导出文件保存到本地。此改进提升了数据导出的完整性和用户体验,同时优化了导出逻辑,确保用户能够方便地下载所需数据。 feat(card_info_walmart): 更新账户信息模型和导出功能 在沃尔玛充值卡账户模块中,新增了账户分组名称、创建时间、更新时间和删除时间字段,增强了账户信息的完整性。同时,更新了账户导出功能,支持在导出文件中显示分组信息和删除状态,提升了用户对账户数据的管理和分析能力。 feat(card_info_walmart): 增强账户信息模型,新增时间戳字段 在沃尔玛充值卡账户模块中,更新了账户信息模型,新增了创建时间、更新时间和删除时间字段,以提升账户信息的完整性。同时,优化了获取账户摘要的逻辑,确保在处理账户信息时能够正确返回相关时间戳数据。这些改进有助于用户更好地管理和分析账户数据。 feat(card_info_walmart): 优化账户信息和摘要获取逻辑 在沃尔玛充值卡账户模块中,更新了账户信息模型,将`AccountInfo`字段改为指针类型,以提高内存效率。同时,优化了获取账户摘要的逻辑,确保在处理账户信息时能够正确返回相关数据。这些改进提升了代码的可读性和性能。 feat(card_info_walmart): 更新账户信息和导出功能 在沃尔玛充值卡账户模块中,优化了账户信息导出功能,新增了分组ID和账户ID字段,以提升导出数据的完整性。同时,更新了相关逻辑以支持根据分组ID进行查询,增强了数据处理的灵活性和准确性。这些改进有助于用户更好地管理和分析账户数据。 feat(card_info_walmart): 优化分组统计逻辑和测试用例 在沃尔玛充值卡账户模块中,优化了分组统计功能,使用了更高效的集合操作以获取唯一的分组ID。同时,更新了相关测试用例,简化了参数传递,提升了代码的可读性和测试的准确性。这些改进有助于提高数据处理的性能和测试的可靠性。 feat(sysUser): 更新获取所有用户接口的描述和逻辑 在用户管理模块中,修改了获取所有用户的请求描述,将“商户”更改为“用户”,以提高接口的准确性。同时,增强了获取用户列表的逻辑,添加了权限验证,确保用户信息的安全性,并在返回数据时过滤掉当前用户的信息。这些改进提升了接口的可用性和安全性。 feat(card_info_walmart): 新增用户ID字段并更新相关逻辑 在沃尔玛充值卡账户模块中,新增了多个请求和响应结构中的用户ID字段,以提升用户信息的管理能力。同时,更新了相关逻辑以支持用户ID的传递,确保在处理账户和分组信息时能够正确识别用户。这些改进增强了系统的灵活性和数据处理的准确性。 feat(card_info_walmart): 新增用户ID字段并更新相关逻辑 在沃尔玛充值卡账户模块中,新增了`UserId`字段到分组统计请求结构体,并在相关逻辑中更新以支持用户ID的传递。这些改进确保在处理分组统计时能够正确识别用户信息,提升了系统的灵活性和数据处理的准确性。
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
### docker deploy token
|
### docker deploy token
|
||||||
|
|
||||||
6acddd2c6f1c0df7f0f3bb848caeeced6ec6ef2a
|
579f3fab0f179949b1b8a509ba4f2dff0c8dcdd5
|
||||||
|
|||||||
@@ -34,10 +34,13 @@ type ICardInfoWalmartV1 interface {
|
|||||||
GroupList(ctx context.Context, req *v1.GroupListReq) (res *v1.GroupListRes, err error)
|
GroupList(ctx context.Context, req *v1.GroupListReq) (res *v1.GroupListRes, err error)
|
||||||
GroupDelete(ctx context.Context, req *v1.GroupDeleteReq) (res *v1.GroupDeleteRes, err error)
|
GroupDelete(ctx context.Context, req *v1.GroupDeleteReq) (res *v1.GroupDeleteRes, err error)
|
||||||
GroupAllList(ctx context.Context, req *v1.GroupAllListReq) (res *v1.GroupAllListRes, err error)
|
GroupAllList(ctx context.Context, req *v1.GroupAllListReq) (res *v1.GroupAllListRes, err error)
|
||||||
|
GroupStat(ctx context.Context, req *v1.GroupStatReq) (res *v1.GroupStatRes, err error)
|
||||||
|
GroupExport(ctx context.Context, req *v1.GroupExportReq) (res *v1.GroupExportRes, err error)
|
||||||
Submit(ctx context.Context, req *v1.SubmitReq) (res *v1.SubmitRes, err error)
|
Submit(ctx context.Context, req *v1.SubmitReq) (res *v1.SubmitRes, err error)
|
||||||
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
|
List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error)
|
||||||
OrderHistory(ctx context.Context, req *v1.OrderHistoryReq) (res *v1.OrderHistoryRes, err error)
|
OrderHistory(ctx context.Context, req *v1.OrderHistoryReq) (res *v1.OrderHistoryRes, err error)
|
||||||
OrderCallback(ctx context.Context, req *v1.OrderCallbackReq) (res *v1.OrderCallbackRes, err error)
|
OrderCallback(ctx context.Context, req *v1.OrderCallbackReq) (res *v1.OrderCallbackRes, err error)
|
||||||
OrderStatusReset(ctx context.Context, req *v1.OrderStatusResetReq) (res *v1.OrderStatusResetRes, err error)
|
OrderStatusReset(ctx context.Context, req *v1.OrderStatusResetReq) (res *v1.OrderStatusResetRes, err error)
|
||||||
|
OrderExport(ctx context.Context, req *v1.OrderExportReq) (res *v1.OrderExportRes, err error)
|
||||||
OrderSummaryList(ctx context.Context, req *v1.OrderSummaryListReq) (res *v1.OrderSummaryListRes, err error)
|
OrderSummaryList(ctx context.Context, req *v1.OrderSummaryListReq) (res *v1.OrderSummaryListRes, err error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
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"
|
"kami/api/commonApi"
|
||||||
v1 "kami/api/sysUser/v1"
|
v1 "kami/api/sysUser/v1"
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AccountDeleteReq struct {
|
type AccountDeleteReq struct {
|
||||||
@@ -25,6 +26,7 @@ type AccountListReq struct {
|
|||||||
Cookie string `json:"cookie"`
|
Cookie string `json:"cookie"`
|
||||||
CreatedUserName string `json:"CreatedUserName" description:"创建用户昵称"`
|
CreatedUserName string `json:"CreatedUserName" description:"创建用户昵称"`
|
||||||
GroupId int `json:"groupId" description:"分组ID"`
|
GroupId int `json:"groupId" description:"分组ID"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountListRecord struct {
|
type AccountListRecord struct {
|
||||||
@@ -154,6 +156,7 @@ type AccountCookieBatchAddRes struct {
|
|||||||
|
|
||||||
type DownloadReq struct {
|
type DownloadReq struct {
|
||||||
g.Meta `path:"/cardInfo/walmart/account/download" tags:"沃尔玛充值卡账户" method:"get" summary:"下载充值账户"`
|
g.Meta `path:"/cardInfo/walmart/account/download" tags:"沃尔玛充值卡账户" method:"get" summary:"下载充值账户"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DownloadRes struct {
|
type DownloadRes struct {
|
||||||
@@ -168,18 +171,24 @@ type AccountDailySummaryReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CardRedeemAccountSummary struct {
|
type CardRedeemAccountSummary struct {
|
||||||
AccountInfo AccountInfo `json:"accountInfo"`
|
GroupId int `json:"groupId" orm:"group_id" description:""`
|
||||||
Id int `json:"id" orm:"id" description:""`
|
GroupName string `json:"groupName" orm:"group_name" description:""`
|
||||||
AccountId string `json:"accountId" orm:"account_id" description:""`
|
AccountInfo *AccountInfo `json:"accountInfo"`
|
||||||
AmountTotalSum float64 `json:"amountTotalSum" orm:"amount_total_sum" description:""`
|
Id int `json:"id" orm:"id" description:""`
|
||||||
AmountTodaySum float64 `json:"amountTodaySum" orm:"amount_today_sum" description:""`
|
AccountId string `json:"accountId" orm:"account_id" description:""`
|
||||||
AmountTotalCount int `json:"amountTotalCount" orm:"amount_total_count" description:""`
|
AmountTotalSum float64 `json:"amountTotalSum" orm:"amount_total_sum" description:""`
|
||||||
AmountTodayCount int `json:"amountTodayCount" orm:"amount_today_count" description:""`
|
AmountTodaySum float64 `json:"amountTodaySum" orm:"amount_today_sum" description:""`
|
||||||
Date *gtime.Time `json:"date" orm:"date" 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 AccountInfo struct {
|
type AccountInfo struct {
|
||||||
g.Meta `orm:"table:card_redeem_account_info"`
|
g.Meta `orm:"table:card_redeem_account_info"`
|
||||||
|
GroupId int `json:"groupId" orm:"group_id" description:""`
|
||||||
UploadUser v1.SysUserRecord `json:"uploadUser" orm:"with:id=create_user_id"`
|
UploadUser v1.SysUserRecord `json:"uploadUser" orm:"with:id=create_user_id"`
|
||||||
CreateUserId string `json:"createUserId" orm:"create_user_id" description:"创建人"`
|
CreateUserId string `json:"createUserId" orm:"create_user_id" description:"创建人"`
|
||||||
Balance float64 `json:"balance" orm:"balance" description:"余额"`
|
Balance float64 `json:"balance" orm:"balance" description:"余额"`
|
||||||
@@ -194,6 +203,9 @@ type AccountInfo struct {
|
|||||||
AmountTodaySum float64 `json:"amountTodaySum" orm:"amount_today_sum" description:"账单今日统计金额"`
|
AmountTodaySum float64 `json:"amountTodaySum" orm:"amount_today_sum" description:"账单今日统计金额"`
|
||||||
EffectiveBalance float64 `json:"effectiveBalance" orm:"effective_balance" description:"有效充值余额"`
|
EffectiveBalance float64 `json:"effectiveBalance" orm:"effective_balance" description:"有效充值余额"`
|
||||||
AmountTotalCount int `json:"amountTotalCount" orm:"amount_total_count" description:""`
|
AmountTotalCount int `json:"amountTotalCount" orm:"amount_total_count" 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 {
|
type AccountDailySummaryRes struct {
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
|
||||||
"kami/api/commonApi"
|
"kami/api/commonApi"
|
||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupRecord struct {
|
type GroupRecord struct {
|
||||||
@@ -31,6 +33,7 @@ type GroupUpdateRes struct {
|
|||||||
type GroupListReq struct {
|
type GroupListReq struct {
|
||||||
g.Meta `path:"/cardInfo/walmart/group/list" tags:"沃尔玛充值卡账户" method:"get" summary:"获取沃尔玛账户分组"`
|
g.Meta `path:"/cardInfo/walmart/group/list" tags:"沃尔玛充值卡账户" method:"get" summary:"获取沃尔玛账户分组"`
|
||||||
commonApi.CommonPageReq
|
commonApi.CommonPageReq
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupListRes struct {
|
type GroupListRes struct {
|
||||||
@@ -47,9 +50,58 @@ type GroupDeleteRes struct {
|
|||||||
|
|
||||||
type GroupAllListReq struct {
|
type GroupAllListReq struct {
|
||||||
g.Meta `path:"/cardInfo/walmart/group/allList" tags:"沃尔玛充值卡账户" method:"get" summary:"获取所有沃尔玛账户分组"`
|
g.Meta `path:"/cardInfo/walmart/group/allList" tags:"沃尔玛充值卡账户" method:"get" summary:"获取所有沃尔玛账户分组"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupAllListRes 获取所有分组
|
// GroupAllListRes 获取所有分组
|
||||||
type GroupAllListRes struct {
|
type GroupAllListRes struct {
|
||||||
commonApi.CommonPageRes[*entity.V1CardRedeemAccountGroup]
|
commonApi.CommonPageRes[*entity.V1CardRedeemAccountGroup]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分组统计
|
||||||
|
type GroupStatReq struct {
|
||||||
|
g.Meta `path:"/cardInfo/walmart/group/stat" tags:"沃尔玛充值卡账户" method:"get" summary:"分组统计"`
|
||||||
|
commonApi.CommonPageReq
|
||||||
|
Username string `json:"username" description:"用户名"`
|
||||||
|
Date *gtime.Time `json:"date" description:"日期"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type V1CardRedeemAccountGroupStatsEntity struct {
|
||||||
|
OrderDate string `orm:"order_date" json:"orderDate"`
|
||||||
|
GroupId int `orm:"group_id" json:"groupId"`
|
||||||
|
GroupName string `orm:"group_name" json:"groupName"`
|
||||||
|
Count int `orm:"count" json:"count"`
|
||||||
|
Sum float64 `orm:"sum" json:"sum"`
|
||||||
|
CreatedUserId string `orm:"group_created_user_id" json:"createdUserId"`
|
||||||
|
CreatedUserName string `orm:"username" json:"createdUserName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type V1CardRedeemAccountGroupEntityAccount struct {
|
||||||
|
Total int `json:"total"`
|
||||||
|
Normal int `json:"normal"`
|
||||||
|
UnNormal int `json:"unNormal"`
|
||||||
|
Deleted int `json:"deleted"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type V1CardRedeemAccountGroupEntity struct {
|
||||||
|
*V1CardRedeemAccountGroupStatsEntity
|
||||||
|
Account *V1CardRedeemAccountGroupEntityAccount `json:"account"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupStatRes struct {
|
||||||
|
commonApi.CommonPageRes[*V1CardRedeemAccountGroupEntity]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
type GroupExportReq struct {
|
||||||
|
g.Meta `path:"/cardInfo/walmart/group/export" tags:"沃尔玛充值卡账户" method:"get" summary:"导出账户分组" produces:"application/octet-stream"`
|
||||||
|
commonApi.CommonPageReq
|
||||||
|
Username string `json:"username" description:"用户名"`
|
||||||
|
Date *gtime.Time `json:"date" description:"日期"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GroupExportRes struct {
|
||||||
|
g.Meta `mime:"application/vnd.ms-excel"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
|
||||||
"kami/api/commonApi"
|
"kami/api/commonApi"
|
||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SubmitReq 礼品卡充值
|
// SubmitReq 礼品卡充值
|
||||||
@@ -32,6 +33,7 @@ type ListReq struct {
|
|||||||
GroupId int `json:"groupId" description:"组ID"`
|
GroupId int `json:"groupId" description:"组ID"`
|
||||||
AccountCk string `json:"accountCk" description:"账户cookie"`
|
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||||
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListRes struct {
|
type ListRes struct {
|
||||||
@@ -62,3 +64,21 @@ type OrderStatusResetReq struct {
|
|||||||
|
|
||||||
type OrderStatusResetRes struct {
|
type OrderStatusResetRes struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 导出
|
||||||
|
type OrderExportReq struct {
|
||||||
|
g.Meta `path:"/cardInfo/walmart/order/export" tags:"沃尔玛充值卡订单" method:"get" summary:"导出订单" produces:"application/octet-stream"`
|
||||||
|
commonApi.CommonPageReq
|
||||||
|
GiftCardPwd string `json:"giftCardPwd" description:"礼品卡密码"`
|
||||||
|
MerchantId string `json:"merchantId" description:"商户ID"`
|
||||||
|
Attach string `json:"attach" description:"附加信息"`
|
||||||
|
AccountNickName string `json:"accountNickName" dc:"账户昵称"`
|
||||||
|
GroupId int `json:"groupId" description:"组ID"`
|
||||||
|
AccountCk string `json:"accountCk" description:"账户cookie"`
|
||||||
|
DateRange []*gtime.Time `json:"dateRange" description:"时间范围"`
|
||||||
|
UserId string `json:"userId" description:"用户ID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderExportRes struct {
|
||||||
|
g.Meta `mime:"application/vnd.ms-excel"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ type UserGetByIdsRes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserGetAllUserReq struct {
|
type UserGetAllUserReq struct {
|
||||||
g.Meta `path:"/user/getSimpleAll" tags:"用户管理" method:"get" summary:"获取所有的商户(简单)"`
|
g.Meta `path:"/user/getSimpleAll" tags:"用户管理" method:"get" summary:"获取所有的用户(简单)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserGetAllSimpleUser struct {
|
type UserGetAllSimpleUser struct {
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ services:
|
|||||||
profiles:
|
profiles:
|
||||||
- jd_bind_card_server
|
- jd_bind_card_server
|
||||||
- all
|
- all
|
||||||
babel_channel:
|
jd_babel_channel:
|
||||||
image: git.kkknametrans.buzz/danial/jd_babel_channel_$BRANCH:$VERSION
|
image: git.kkknametrans.buzz/danial/jd_babel_channel_$BRANCH:$VERSION
|
||||||
container_name: babel-channel-$BRANCH-$VERSION
|
container_name: babel-channel-$BRANCH-$VERSION
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -118,6 +118,57 @@ const (
|
|||||||
RedeemOrderFailWithFrozen RedeemOrderStatus = 21 // 卡密冻结
|
RedeemOrderFailWithFrozen RedeemOrderStatus = 21 // 卡密冻结
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (r *RedeemOrderStatus) String() string {
|
||||||
|
switch *r {
|
||||||
|
case RedeemOrderStart:
|
||||||
|
return "开始处理"
|
||||||
|
case RedeemOrderProcessing:
|
||||||
|
return "处理中"
|
||||||
|
case RedeemOrderFail:
|
||||||
|
return "充值失败"
|
||||||
|
case RedeemOrderSuccess:
|
||||||
|
return "充值成功"
|
||||||
|
case RedeemOrderPending:
|
||||||
|
return "待处理"
|
||||||
|
case RedeemOrderRefundWithValidatedFail:
|
||||||
|
return "验证失败(账号相关)"
|
||||||
|
case RedeemOrderFailWithCKFail:
|
||||||
|
return "账号失效(账号相关)"
|
||||||
|
case RedeemOrderFailWithFrequent:
|
||||||
|
return "账号频繁"
|
||||||
|
case RedeemOrderFailWithCardUnknown:
|
||||||
|
return "未知状态"
|
||||||
|
case RedeemOrderForbiddenByMaxLimit:
|
||||||
|
return "订单禁用,最大调用次数"
|
||||||
|
case RedeemOrderSuccessWithDifferentAmount:
|
||||||
|
return "充值金额与订单金额不一致(已经充值)"
|
||||||
|
case RedeemOrderFailWithWrongCardType:
|
||||||
|
return "卡密类型错误"
|
||||||
|
case RedeemOrderFailWithDifferentAmount:
|
||||||
|
return "充值金额与订单金额不一致(没有充值)"
|
||||||
|
case RedeemOrderFailWithOtherBind:
|
||||||
|
return "卡密被绑定"
|
||||||
|
case RedeemOrderFailWithRepeat:
|
||||||
|
return "重复绑卡"
|
||||||
|
case RedeemOrderFailWithDailyAccountLimited:
|
||||||
|
return "账号受到限制"
|
||||||
|
case RedeemOrderFailCardNotExist:
|
||||||
|
return "卡片无效/不存在"
|
||||||
|
case RedeemOrderFailWithCardOverDue:
|
||||||
|
return "卡片过期"
|
||||||
|
case RedeemOrderSuccessWithCompensated:
|
||||||
|
return "补卡成功"
|
||||||
|
case RedeemOrderFailRepeated:
|
||||||
|
return "重复订单"
|
||||||
|
case RedeemOrderFailRuleError:
|
||||||
|
return "卡号不符合规则"
|
||||||
|
case RedeemOrderFailWithFrozen:
|
||||||
|
return "卡密冻结"
|
||||||
|
default:
|
||||||
|
return "未知错误"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type RedeemOrderOperationStatus int
|
type RedeemOrderOperationStatus int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -2,19 +2,21 @@ package card_info_walmart
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/duke-git/lancet/v2/pointer"
|
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
|
||||||
"github.com/duke-git/lancet/v2/strutil"
|
|
||||||
"github.com/gogf/gf/v2/text/gstr"
|
|
||||||
"github.com/jinzhu/copier"
|
|
||||||
"kami/api/commonApi"
|
"kami/api/commonApi"
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/errHandler"
|
"kami/internal/errHandler"
|
||||||
"kami/internal/model"
|
"kami/internal/model"
|
||||||
"kami/internal/service"
|
"kami/internal/service"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/pointer"
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/duke-git/lancet/v2/strutil"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
|
||||||
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
"kami/api/card_info_walmart/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *ControllerV1) AccountList(ctx context.Context, req *v1.AccountListReq) (res *v1.AccountListRes, err error) {
|
func (c *ControllerV1) AccountList(ctx context.Context, req *v1.AccountListReq) (res *v1.AccountListRes, err error) {
|
||||||
@@ -23,6 +25,9 @@ func (c *ControllerV1) AccountList(ctx context.Context, req *v1.AccountListReq)
|
|||||||
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
accountService := service.CardRedeemAccount()
|
accountService := service.CardRedeemAccount()
|
||||||
total, list, err := accountService.List(ctx, &model.RedeemAccountListInput{
|
total, list, err := accountService.List(ctx, &model.RedeemAccountListInput{
|
||||||
CommonPageReq: commonApi.CommonPageReq{
|
CommonPageReq: commonApi.CommonPageReq{
|
||||||
|
|||||||
@@ -4,16 +4,19 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
|
||||||
"github.com/xuri/excelize/v2"
|
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/errHandler"
|
"kami/internal/errHandler"
|
||||||
"kami/internal/model"
|
"kami/internal/model"
|
||||||
"kami/internal/service"
|
"kami/internal/service"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
"github.com/xuri/excelize/v2"
|
||||||
|
|
||||||
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"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) {
|
func (c *ControllerV1) AccountSummaryDownload(ctx context.Context, req *v1.AccountSummaryDownloadReq) (res *v1.AccountSummaryDownloadRes, err error) {
|
||||||
@@ -37,15 +40,16 @@ func (c *ControllerV1) AccountSummaryDownload(ctx context.Context, req *v1.Accou
|
|||||||
excel := excelize.NewFile()
|
excel := excelize.NewFile()
|
||||||
sw, _ := excel.NewStreamWriter("Sheet1")
|
sw, _ := excel.NewStreamWriter("Sheet1")
|
||||||
err = sw.SetRow("A1", []interface{}{
|
err = sw.SetRow("A1", []interface{}{
|
||||||
"账户", "余额", "今日充值金额", "今日充值次数",
|
"分组id", "分组名称", "id", "账户", "余额", "今日充值金额", "今日充值次数",
|
||||||
"累计充值金额", "累计充值次数", "状态", "创建时间",
|
"累计充值金额", "累计充值次数", "状态", "创建时间", "是否还在",
|
||||||
})
|
})
|
||||||
slice.ForEach(output, func(index int, item *model.AccountDailySummaryGetOutput) {
|
slice.ForEach(output, func(index int, item *model.AccountDailySummaryGetOutput) {
|
||||||
_ = sw.SetRow(fmt.Sprintf("A%d", index+2), []interface{}{
|
_ = sw.SetRow(fmt.Sprintf("A%d", index+2), []interface{}{
|
||||||
item.AccountInfo.Name, item.AccountInfo.Balance, item.AmountTodaySum, item.AmountTodayCount,
|
item.GroupId, item.GroupName, item.AccountInfo.Id, item.AccountInfo.Name,
|
||||||
item.AmountTotalSum, item.AmountTotalCount,
|
item.AccountInfo.Balance, item.AmountTodaySum,
|
||||||
|
item.AmountTodayCount, item.AmountTotalSum, item.AmountTotalCount,
|
||||||
consts.RedeemAccountStatus(item.AccountInfo.Status).GetStatusText(),
|
consts.RedeemAccountStatus(item.AccountInfo.Status).GetStatusText(),
|
||||||
item.Date.Format("2006-01-02"),
|
item.Date.Format("2006-01-02"), isDeleted(item.DeletedAt),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
_ = sw.Flush()
|
_ = sw.Flush()
|
||||||
@@ -58,3 +62,10 @@ func (c *ControllerV1) AccountSummaryDownload(ctx context.Context, req *v1.Accou
|
|||||||
g.RequestFromCtx(ctx).Response.Flush()
|
g.RequestFromCtx(ctx).Response.Flush()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isDeleted(deletedAt *gtime.Time) string {
|
||||||
|
if deletedAt != nil {
|
||||||
|
return "✅"
|
||||||
|
}
|
||||||
|
return "❌"
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,19 +4,21 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"kami/internal/consts"
|
||||||
|
"kami/internal/errHandler"
|
||||||
|
"kami/internal/model/entity"
|
||||||
|
"kami/internal/service"
|
||||||
|
|
||||||
"github.com/duke-git/lancet/v2/pointer"
|
"github.com/duke-git/lancet/v2/pointer"
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
"github.com/duke-git/lancet/v2/strutil"
|
"github.com/duke-git/lancet/v2/strutil"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
"github.com/gogf/gf/v2/text/gstr"
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
"github.com/xuri/excelize/v2"
|
"github.com/xuri/excelize/v2"
|
||||||
"kami/internal/consts"
|
|
||||||
"kami/internal/errHandler"
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
"kami/internal/model/entity"
|
|
||||||
"kami/internal/service"
|
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
"kami/api/card_info_walmart/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *ControllerV1) Download(ctx context.Context, req *v1.DownloadReq) (res *v1.DownloadRes, err error) {
|
func (c *ControllerV1) Download(ctx context.Context, req *v1.DownloadReq) (res *v1.DownloadRes, err error) {
|
||||||
@@ -29,6 +31,9 @@ func (c *ControllerV1) Download(ctx context.Context, req *v1.DownloadReq) (res *
|
|||||||
if userInfo.Id == "" {
|
if userInfo.Id == "" {
|
||||||
isAdmin = true
|
isAdmin = true
|
||||||
}
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
data, err := service.CardRedeemAccount().GetAllByUserId(ctx, userInfo.Id, consts.CardRedeemAccountCategoryWalMart, nil)
|
data, err := service.CardRedeemAccount().GetAllByUserId(ctx, userInfo.Id, consts.CardRedeemAccountCategoryWalMart, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "下载失败")
|
err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "下载失败")
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package card_info_walmart
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
|
"kami/api/commonApi"
|
||||||
|
"kami/internal/consts"
|
||||||
|
"kami/internal/errHandler"
|
||||||
|
"kami/internal/model"
|
||||||
|
"kami/internal/service"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/xuri/excelize/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) GroupExport(ctx context.Context, req *v1.GroupExportReq) (res *v1.GroupExportRes, err error) {
|
||||||
|
userInfo, err := service.SysAuth().LoginWithIFrameAndLogin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
|
_, output, err := service.CardRedeemAccount().GroupStats(ctx, &model.RedeemAccountGroupStatsInput{
|
||||||
|
Category: consts.CardRedeemAccountCategoryWalMart,
|
||||||
|
CreatedUserId: userInfo.Id,
|
||||||
|
GroupStatReq: &v1.GroupStatReq{
|
||||||
|
CommonPageReq: commonApi.CommonPageReq{
|
||||||
|
Current: 0,
|
||||||
|
PageSize: 0,
|
||||||
|
},
|
||||||
|
Username: req.Username,
|
||||||
|
Date: req.Date,
|
||||||
|
UserId: userInfo.Id,
|
||||||
|
},
|
||||||
|
}, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
excel := excelize.NewFile()
|
||||||
|
sw, _ := excel.NewStreamWriter("Sheet1")
|
||||||
|
err = sw.SetRow("A1", []interface{}{
|
||||||
|
"id", "上传人昵称", "分组名称", "正常账户数量", "异常账户数量", "已删除账户数量", "充值金额", "充值比数", "充值日期",
|
||||||
|
})
|
||||||
|
slice.ForEach(output, func(index int, item *model.RedeemAccountGroupStatsOutput) {
|
||||||
|
_ = sw.SetRow(fmt.Sprintf("A%d", index+2), []interface{}{
|
||||||
|
item.GroupId, item.CreatedUserName, item.GroupName, item.Account.Normal, item.Account.UnNormal,
|
||||||
|
item.Account.Deleted, item.Sum, item.Count, item.OrderDate,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
_ = sw.Flush()
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
_ = excel.Write(&buffer)
|
||||||
|
_ = excel.Close()
|
||||||
|
// 数据下载到本地
|
||||||
|
fileName := fmt.Sprintf("沃尔玛充值卡分组统计_%s.xlsx", time.Now().Format("20060102150405"))
|
||||||
|
err = os.WriteFile(fileName, buffer.Bytes(), 0644)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// 数据缓冲到本地
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
|
||||||
"kami/api/card_info_walmart/v1"
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *ControllerV1) GroupList(ctx context.Context, req *v1.GroupListReq) (res *v1.GroupListRes, err error) {
|
func (c *ControllerV1) GroupList(ctx context.Context, req *v1.GroupListReq) (res *v1.GroupListRes, err error) {
|
||||||
@@ -19,6 +19,9 @@ func (c *ControllerV1) GroupList(ctx context.Context, req *v1.GroupListReq) (res
|
|||||||
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
total, data, err := service.CardRedeemAccount().GroupList(ctx, &model.RedeemAccountGroupList{
|
total, data, err := service.CardRedeemAccount().GroupList(ctx, &model.RedeemAccountGroupList{
|
||||||
Category: consts.CardRedeemAccountCategoryWalMart,
|
Category: consts.CardRedeemAccountCategoryWalMart,
|
||||||
CreatedUserId: userInfo.Id,
|
CreatedUserId: userInfo.Id,
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package card_info_walmart
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
|
"kami/internal/consts"
|
||||||
|
"kami/internal/errHandler"
|
||||||
|
"kami/internal/model"
|
||||||
|
"kami/internal/service"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) GroupStat(ctx context.Context, req *v1.GroupStatReq) (res *v1.GroupStatRes, err error) {
|
||||||
|
userInfo, err := service.SysAuth().LoginWithIFrameAndLogin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
|
total, output, err := service.CardRedeemAccount().GroupStats(ctx, &model.RedeemAccountGroupStatsInput{
|
||||||
|
Category: consts.CardRedeemAccountCategoryWalMart,
|
||||||
|
CreatedUserId: userInfo.Id,
|
||||||
|
GroupStatReq: req,
|
||||||
|
}, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res = &v1.GroupStatRes{}
|
||||||
|
res.Total = total
|
||||||
|
res.List = slice.Map(output, func(index int, item *model.RedeemAccountGroupStatsOutput) *v1.V1CardRedeemAccountGroupEntity {
|
||||||
|
return item.V1CardRedeemAccountGroupEntity
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
|
||||||
"kami/api/card_info_walmart/v1"
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
|
||||||
@@ -19,6 +19,9 @@ func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListR
|
|||||||
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
res = &v1.ListRes{}
|
res = &v1.ListRes{}
|
||||||
res.Total, res.List, err = service.CardRedeemOrder().List(ctx, &model.RedeemCardListInput{
|
res.Total, res.List, err = service.CardRedeemOrder().List(ctx, &model.RedeemCardListInput{
|
||||||
CommonPageReq: commonApi.CommonPageReq{
|
CommonPageReq: commonApi.CommonPageReq{
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package card_info_walmart
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/xuri/excelize/v2"
|
||||||
|
|
||||||
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
|
"kami/api/commonApi"
|
||||||
|
"kami/internal/consts"
|
||||||
|
"kami/internal/errHandler"
|
||||||
|
"kami/internal/model"
|
||||||
|
"kami/internal/model/entity"
|
||||||
|
"kami/internal/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *ControllerV1) OrderExport(ctx context.Context, req *v1.OrderExportReq) (res *v1.OrderExportRes, err error) {
|
||||||
|
userInfo, err := service.SysAuth().LoginWithIFrameAndLogin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.UserId != "" && userInfo.Id == "" {
|
||||||
|
userInfo.Id = req.UserId
|
||||||
|
}
|
||||||
|
_, list, err := service.CardRedeemOrder().List(ctx, &model.RedeemCardListInput{
|
||||||
|
CommonPageReq: commonApi.CommonPageReq{
|
||||||
|
Current: 0,
|
||||||
|
PageSize: 0,
|
||||||
|
},
|
||||||
|
GiftCardPwd: req.GiftCardPwd,
|
||||||
|
MerchantId: req.MerchantId,
|
||||||
|
Attach: req.Attach,
|
||||||
|
DateRange: req.DateRange,
|
||||||
|
AccountNickName: req.AccountNickName,
|
||||||
|
AccountCk: req.AccountCk,
|
||||||
|
UserId: userInfo.Id,
|
||||||
|
GroupId: req.GroupId,
|
||||||
|
Category: consts.CardRedeemAccountCategoryWalMart,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "获取订单列表失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
excel := excelize.NewFile()
|
||||||
|
sw, _ := excel.NewStreamWriter("Sheet1")
|
||||||
|
err = sw.SetRow("A1", []interface{}{
|
||||||
|
"卡号", "卡密", "商户订单号", "ck唯一id", "ck账号", "充值状态", "状态明细",
|
||||||
|
"拉单金额", "实际金额", "创建时间",
|
||||||
|
})
|
||||||
|
slice.ForEach(list, func(index int, item *entity.V1CardRedeemOrderInfo) {
|
||||||
|
status := consts.RedeemOrderStatus(item.Status)
|
||||||
|
orderStatus := consts.RedeemOrderStatus(item.OrderStatus)
|
||||||
|
_ = sw.SetRow(fmt.Sprintf("A%d", index+2), []interface{}{
|
||||||
|
item.CardNo, item.GiftCardPwd, item.Attach, item.MerchantId, item.AccountName, status.String(), orderStatus.String(),
|
||||||
|
item.OrderAmount, item.ActualAmount, item.CreatedAt,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
_ = 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
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ func (c *ControllerV1) PlaceOrder(ctx context.Context, req *v1.PlaceOrderReq) (r
|
|||||||
BankOrderId: order.BankOrderId,
|
BankOrderId: order.BankOrderId,
|
||||||
OrderAmount: orderAmount,
|
OrderAmount: orderAmount,
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Error(ctx, "下单失败", "merchantOrderId", req.MerchantOrderId, err)
|
glog.Error(ctx, "下单失败", "merchantOrderId", req.MerchantOrderId, err)
|
||||||
return nil, gerror.NewCode(gcode.CodeOperationFailed, "下单失败")
|
return nil, gerror.NewCode(gcode.CodeOperationFailed, "下单失败")
|
||||||
|
|||||||
@@ -2,17 +2,33 @@ package sysUser
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/jinzhu/copier"
|
|
||||||
"kami/internal/errHandler"
|
"kami/internal/errHandler"
|
||||||
|
"kami/internal/model"
|
||||||
"kami/internal/service"
|
"kami/internal/service"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/jinzhu/copier"
|
||||||
|
|
||||||
|
v1 "kami/api/sysUser/v1"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
"kami/api/sysUser/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *ControllerV1) UserGetAllUser(ctx context.Context, req *v1.UserGetAllUserReq) (res *v1.UserGetAllUserRes, err error) {
|
func (c *ControllerV1) UserGetAllUser(ctx context.Context, req *v1.UserGetAllUserReq) (res *v1.UserGetAllUserRes, err error) {
|
||||||
|
userInfo, err := service.SysAuth().LoginWithIFrameAndLogin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
userService := service.SysUser()
|
userService := service.SysUser()
|
||||||
data, err := userService.GetAllSimpleUser(ctx)
|
data, err := userService.GetAllSimpleUser(ctx)
|
||||||
|
|
||||||
|
if userInfo.Id != "" {
|
||||||
|
data = slice.Filter(data, func(index int, item model.UserSimpleUsersOutput) bool {
|
||||||
|
return item.Id != userInfo.Id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
res = &v1.UserGetAllUserRes{}
|
res = &v1.UserGetAllUserRes{}
|
||||||
err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "获取用户列表失败")
|
err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "获取用户列表失败")
|
||||||
err = copier.Copy(&res.List, data)
|
err = copier.Copy(&res.List, data)
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ package card_redeem_account
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/gogf/gf/frame/g"
|
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
|
||||||
"github.com/gogf/gf/v2/os/gmlock"
|
|
||||||
"github.com/gogf/gf/v2/text/gstr"
|
|
||||||
"kami/internal/dao"
|
"kami/internal/dao"
|
||||||
"kami/internal/model"
|
"kami/internal/model"
|
||||||
"kami/internal/model/do"
|
"kami/internal/model/do"
|
||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
"kami/utility/config"
|
"kami/utility/config"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/os/gmlock"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *sCardRedeemAccount) GroupAdd(ctx context.Context, input *model.RedeemAccountGroup, tx gdb.TX) (id int64, err error) {
|
func (a *sCardRedeemAccount) GroupAdd(ctx context.Context, input *model.RedeemAccountGroup, tx gdb.TX) (id int64, err error) {
|
||||||
@@ -96,6 +97,9 @@ func (a *sCardRedeemAccount) GroupAll(ctx context.Context, input *model.RedeemAc
|
|||||||
if input.CreatedUserId != "" {
|
if input.CreatedUserId != "" {
|
||||||
m = m.Where(dao.V1CardRedeemAccountGroup.Columns().CreatedUserId, input.CreatedUserId)
|
m = m.Where(dao.V1CardRedeemAccountGroup.Columns().CreatedUserId, input.CreatedUserId)
|
||||||
}
|
}
|
||||||
|
if len(input.GroupIds) > 0 {
|
||||||
|
m = m.WhereIn(dao.V1CardRedeemAccountGroup.Columns().Id, input.GroupIds)
|
||||||
|
}
|
||||||
err = m.Where(dao.V1CardRedeemAccountGroup.Columns().Category, input.Category).
|
err = m.Where(dao.V1CardRedeemAccountGroup.Columns().Category, input.Category).
|
||||||
OrderDesc(dao.V1CardRedeemAccountGroup.Columns().CreatedAt).ScanAndCount(&data, &total, false)
|
OrderDesc(dao.V1CardRedeemAccountGroup.Columns().CreatedAt).ScanAndCount(&data, &total, false)
|
||||||
return
|
return
|
||||||
|
|||||||
124
internal/logic/card_redeem_account/group_stats.go
Normal file
124
internal/logic/card_redeem_account/group_stats.go
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
package card_redeem_account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
|
"kami/internal/consts"
|
||||||
|
"kami/internal/dao"
|
||||||
|
"kami/internal/model"
|
||||||
|
"kami/internal/model/entity"
|
||||||
|
"kami/utility/config"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (a *sCardRedeemAccount) GroupStats(ctx context.Context, input *model.RedeemAccountGroupStatsInput, tx gdb.TX) (total int, output []*model.RedeemAccountGroupStatsOutput, err error) {
|
||||||
|
sqlQuery := `
|
||||||
|
SELECT
|
||||||
|
DATE(card_redeem_order_info.created_at) AS order_date,
|
||||||
|
card_redeem_account_group.id AS group_id,
|
||||||
|
card_redeem_account_group.name AS group_name,
|
||||||
|
card_redeem_account_group.created_user_id AS group_created_user_id,
|
||||||
|
COUNT(card_redeem_order_info.order_no) AS count,
|
||||||
|
SUM(card_redeem_order_info.actual_amount) AS sum,
|
||||||
|
sys_user.username
|
||||||
|
FROM
|
||||||
|
card_redeem_order_info
|
||||||
|
LEFT JOIN card_redeem_account_info ON card_redeem_account_info.id = card_redeem_order_info.account_id
|
||||||
|
LEFT JOIN card_redeem_account_group ON card_redeem_account_info.group_id = card_redeem_account_group.id
|
||||||
|
LEFT JOIN sys_user ON sys_user.id=card_redeem_account_group.created_user_id
|
||||||
|
WHERE
|
||||||
|
card_redeem_order_info.status = 1
|
||||||
|
OR (card_redeem_order_info.status = 100 AND card_redeem_order_info.order_status = 8)
|
||||||
|
`
|
||||||
|
|
||||||
|
if input.Date != nil {
|
||||||
|
sqlQuery += fmt.Sprintf(" AND DATE(card_redeem_order_info.created_at) = '%s'", input.Date.Format("2006-01-02"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if input.Category != "" {
|
||||||
|
sqlQuery += fmt.Sprintf(" AND card_redeem_account_info.category = '%s'", input.Category)
|
||||||
|
}
|
||||||
|
|
||||||
|
if input.CreatedUserId != "" {
|
||||||
|
sqlQuery += fmt.Sprintf(" AND card_redeem_account_info.create_user_id = '%s'", input.CreatedUserId)
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlQuery += `
|
||||||
|
GROUP BY
|
||||||
|
order_date,
|
||||||
|
group_id
|
||||||
|
`
|
||||||
|
// 分页
|
||||||
|
var sqlQueryPage string
|
||||||
|
if input.Current != 0 && input.PageSize != 0 {
|
||||||
|
offset := (input.Current - 1) * input.PageSize
|
||||||
|
limit := input.PageSize
|
||||||
|
sqlQueryPage = sqlQuery + fmt.Sprintf(" LIMIT %d, %d", offset, limit)
|
||||||
|
} else {
|
||||||
|
sqlQueryPage = sqlQuery
|
||||||
|
}
|
||||||
|
m := dao.V1CardRedeemAccountGroup.Ctx(ctx).Unscoped().DB(config.GetDatabaseV1())
|
||||||
|
if tx != nil {
|
||||||
|
m = m.TX(tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
var data []*v1.V1CardRedeemAccountGroupStatsEntity
|
||||||
|
// 查询总数
|
||||||
|
err = m.Raw(sqlQuery).Scan(&data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
total = len(data)
|
||||||
|
err = m.Raw(sqlQueryPage).Scan(&data)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有分组 id
|
||||||
|
groupIds := slice.Union(slice.Filter(slice.Map(data, func(index int, item *v1.V1CardRedeemAccountGroupStatsEntity) int {
|
||||||
|
return item.GroupId
|
||||||
|
}),
|
||||||
|
func(index int, item int) bool {
|
||||||
|
return item != 0
|
||||||
|
},
|
||||||
|
))
|
||||||
|
|
||||||
|
var accountInfos []*entity.V1CardRedeemAccountInfo
|
||||||
|
// 获取所有账户
|
||||||
|
m = dao.V1CardRedeemAccountInfo.Ctx(ctx).Unscoped().DB(config.GetDatabaseV1())
|
||||||
|
if tx != nil {
|
||||||
|
m = m.TX(tx)
|
||||||
|
}
|
||||||
|
err = m.WhereIn(dao.V1CardRedeemAccountInfo.Columns().Id, groupIds).Scan(&accountInfos)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
output = make([]*model.RedeemAccountGroupStatsOutput, 0)
|
||||||
|
for _, group := range data {
|
||||||
|
targetAccountInfos := slice.Filter(accountInfos, func(index int, item *entity.V1CardRedeemAccountInfo) bool {
|
||||||
|
return item.GroupId == group.GroupId
|
||||||
|
})
|
||||||
|
output = append(output, &model.RedeemAccountGroupStatsOutput{
|
||||||
|
V1CardRedeemAccountGroupEntity: &v1.V1CardRedeemAccountGroupEntity{
|
||||||
|
V1CardRedeemAccountGroupStatsEntity: group,
|
||||||
|
Account: &v1.V1CardRedeemAccountGroupEntityAccount{
|
||||||
|
Total: len(targetAccountInfos),
|
||||||
|
Normal: len(slice.Filter(targetAccountInfos, func(index int, item *entity.V1CardRedeemAccountInfo) bool {
|
||||||
|
return consts.RedeemAccountStatus(item.Status) == consts.RedeemAccountNormal && item.DeletedAt == nil
|
||||||
|
})),
|
||||||
|
UnNormal: len(slice.Filter(targetAccountInfos, func(index int, item *entity.V1CardRedeemAccountInfo) bool {
|
||||||
|
return consts.RedeemAccountStatus(item.Status) != consts.RedeemAccountNormal && item.DeletedAt == nil
|
||||||
|
})),
|
||||||
|
Deleted: len(slice.Filter(targetAccountInfos, func(index int, item *entity.V1CardRedeemAccountInfo) bool {
|
||||||
|
return item.DeletedAt != nil
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -2,10 +2,6 @@ package card_redeem_account
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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"
|
|
||||||
v1 "kami/api/card_info_walmart/v1"
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
"kami/internal/dao"
|
"kami/internal/dao"
|
||||||
"kami/internal/model"
|
"kami/internal/model"
|
||||||
@@ -13,6 +9,11 @@ import (
|
|||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
"kami/internal/service"
|
"kami/internal/service"
|
||||||
"kami/utility/config"
|
"kami/utility/config"
|
||||||
|
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *sCardRedeemAccount) DailySummary(ctx context.Context) (err error) {
|
func (a *sCardRedeemAccount) DailySummary(ctx context.Context) (err error) {
|
||||||
@@ -47,80 +48,74 @@ func (a *sCardRedeemAccount) DailySummary(ctx context.Context) (err error) {
|
|||||||
|
|
||||||
func (a *sCardRedeemAccount) GetSummary(ctx context.Context, input *model.AccountDailySummaryGetInput, tx gdb.TX) (total int, output []*model.AccountDailySummaryGetOutput, err error) {
|
func (a *sCardRedeemAccount) GetSummary(ctx context.Context, input *model.AccountDailySummaryGetInput, tx gdb.TX) (total int, output []*model.AccountDailySummaryGetOutput, err error) {
|
||||||
//查询当前用户上传账户
|
//查询当前用户上传账户
|
||||||
m := dao.V1CardRedeemAccountInfo.Ctx(ctx).DB(config.GetDatabaseV1())
|
|
||||||
if tx != nil {
|
|
||||||
m = m.TX(tx)
|
|
||||||
}
|
|
||||||
if input.CreatedUserId != "" {
|
|
||||||
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().CreateUserId, input.CreatedUserId)
|
|
||||||
}
|
|
||||||
|
|
||||||
redeemAccountInfos := make([]*entity.V1CardRedeemAccountInfo, 0)
|
orderSummary, err := service.CardRedeemOrder().Summary(ctx, input.CommonPageReq, input.Category, input.Username, input.Date, tx)
|
||||||
_ = m.Unscoped().Scan(&redeemAccountInfos)
|
|
||||||
|
|
||||||
redeemAccountIds := slice.Map(redeemAccountInfos, func(index int, item *entity.V1CardRedeemAccountInfo) string {
|
|
||||||
return item.Id
|
|
||||||
})
|
|
||||||
|
|
||||||
orderSummary, err := service.CardRedeemOrder().Summary(ctx, input.CommonPageReq, input.Category, redeemAccountIds, input.Username, input.Date, tx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
total = len(orderSummary)
|
|
||||||
slice.ForEach(orderSummary, func(index int, item *model.RedeemCardSummaryOutput) {
|
// 查询所有账户
|
||||||
|
var accountInfos []*v1.AccountInfo
|
||||||
|
m := dao.V1CardRedeemAccountInfo.Ctx(ctx).DB(config.GetDatabaseV1()).Unscoped()
|
||||||
|
if tx != nil {
|
||||||
|
m = m.TX(tx)
|
||||||
|
}
|
||||||
|
accountIds := slice.Map(orderSummary, func(index int, item *model.RedeemCardSummaryOutput) string {
|
||||||
|
return item.AccountId
|
||||||
|
})
|
||||||
|
m = m.WhereIn(dao.V1CardRedeemAccountInfo.Columns().Id, accountIds)
|
||||||
|
if input.CreatedUserId != "" {
|
||||||
|
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().CreateUserId, input.CreatedUserId)
|
||||||
|
}
|
||||||
|
if input.Category != "" {
|
||||||
|
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().Category, input.Category)
|
||||||
|
}
|
||||||
|
_ = m.WithAll().Scan(&accountInfos)
|
||||||
|
|
||||||
|
// 查询所有分组
|
||||||
|
total, groups, err := service.CardRedeemAccount().GroupAll(ctx, &model.RedeemAccountGroupAll{
|
||||||
|
Category: input.Category,
|
||||||
|
CreatedUserId: input.CreatedUserId,
|
||||||
|
GroupIds: slice.Map(accountInfos, func(index int, item *v1.AccountInfo) int {
|
||||||
|
return item.GroupId
|
||||||
|
}),
|
||||||
|
}, tx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
slice.ForEachConcurrent(orderSummary, func(index int, item *model.RedeemCardSummaryOutput) {
|
||||||
|
accountInfo, ok := slice.FindBy(accountInfos, func(index int, item2 *v1.AccountInfo) bool {
|
||||||
|
return item2.Id == item.AccountId
|
||||||
|
})
|
||||||
|
if !ok {
|
||||||
|
accountInfo = &v1.AccountInfo{
|
||||||
|
Id: item.AccountId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group, ok := slice.FindBy(groups, func(index int, item2 *entity.V1CardRedeemAccountGroup) bool {
|
||||||
|
return item2.Id == accountInfo.GroupId
|
||||||
|
})
|
||||||
|
if !ok {
|
||||||
|
group = &entity.V1CardRedeemAccountGroup{
|
||||||
|
Id: accountInfo.GroupId,
|
||||||
|
}
|
||||||
|
}
|
||||||
output = append(output, &model.AccountDailySummaryGetOutput{
|
output = append(output, &model.AccountDailySummaryGetOutput{
|
||||||
CardRedeemAccountSummary: &v1.CardRedeemAccountSummary{
|
CardRedeemAccountSummary: &v1.CardRedeemAccountSummary{
|
||||||
AccountId: item.AccountId,
|
AccountId: item.AccountId,
|
||||||
AmountTodaySum: item.Amount,
|
AmountTodaySum: item.Amount,
|
||||||
AmountTodayCount: item.Count,
|
AmountTodayCount: item.Count,
|
||||||
Date: item.Date.StartOfDay(),
|
Date: item.Date.StartOfDay(),
|
||||||
|
AccountInfo: accountInfo,
|
||||||
|
AmountTotalSum: accountInfo.AmountTotalSum,
|
||||||
|
AmountTotalCount: accountInfo.AmountTotalCount,
|
||||||
|
CreatedAt: accountInfo.CreatedAt,
|
||||||
|
UpdatedAt: accountInfo.UpdatedAt,
|
||||||
|
DeletedAt: accountInfo.DeletedAt,
|
||||||
|
GroupName: group.Name,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
}, 5)
|
||||||
accountIds := slice.Map(orderSummary, func(index int, item *model.RedeemCardSummaryOutput) string {
|
|
||||||
return item.AccountId
|
|
||||||
})
|
|
||||||
//查询所有账户id
|
|
||||||
var accountInfos []v1.AccountInfo
|
|
||||||
m = dao.V1CardRedeemAccountInfo.Ctx(ctx).DB(config.GetDatabaseV1()).
|
|
||||||
WhereIn(dao.V1CardRedeemAccountInfo.Columns().Id, accountIds)
|
|
||||||
if tx != nil {
|
|
||||||
m = m.TX(tx)
|
|
||||||
}
|
|
||||||
if input.CreatedUserId != "" {
|
|
||||||
m = m.Where(dao.V1CardRedeemAccountInfo.Columns().CreateUserId, input.CreatedUserId)
|
|
||||||
}
|
|
||||||
_ = m.Where(dao.V1CardRedeemAccountInfo.Columns().Category, input.Category).Unscoped().WithAll().Scan(&accountInfos)
|
|
||||||
//匹配账户和订单
|
|
||||||
slice.ForEach(output, func(index int, item *model.AccountDailySummaryGetOutput) {
|
|
||||||
accountInfo, ok := slice.FindBy(accountInfos, func(index int, item2 v1.AccountInfo) bool {
|
|
||||||
return item2.Id == item.AccountId
|
|
||||||
})
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
item.AccountInfo = accountInfo
|
|
||||||
item.AmountTotalSum = accountInfo.AmountTotalSum
|
|
||||||
item.AmountTotalCount = accountInfo.AmountTotalCount
|
|
||||||
})
|
|
||||||
//查询累加值所有日期
|
|
||||||
dates := slice.Map(orderSummary, func(index int, item *model.RedeemCardSummaryOutput) *gtime.Time {
|
|
||||||
return item.Date
|
|
||||||
})
|
|
||||||
redeemAccountSummaries := make([]*entity.V1CardRedeemAccountSummary, 0)
|
|
||||||
dao.V1CardRedeemAccountSummary.Ctx(ctx).DB(config.GetDatabaseV1()).WhereIn(dao.V1CardRedeemAccountSummary.Columns().Date, dates).
|
|
||||||
Where(dao.V1CardRedeemAccountSummary.Columns().AccountId, accountIds).
|
|
||||||
Where(dao.V1CardRedeemAccountSummary.Columns().Category, input.Category).Unscoped().
|
|
||||||
Where(&redeemAccountSummaries)
|
|
||||||
slice.ForEach(output, func(index int, item *model.AccountDailySummaryGetOutput) {
|
|
||||||
summary, ok := slice.FindBy(redeemAccountSummaries, func(index int, item2 *entity.V1CardRedeemAccountSummary) bool {
|
|
||||||
return item2.AccountId == item.AccountId && item2.Date.EndOfDay().Equal(item.Date.EndOfDay())
|
|
||||||
})
|
|
||||||
if !ok || summary.Date.StartOfDay().Equal(item.Date.StartOfDay()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
item.AmountTotalCount = summary.AmountTotalCount
|
|
||||||
item.AmountTotalSum = summary.AmountTotalSum
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ package card_redeem_order
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
|
||||||
"github.com/gogf/gf/container/gset"
|
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
|
||||||
"github.com/gogf/gf/v2/text/gstr"
|
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/dao"
|
"kami/internal/dao"
|
||||||
"kami/internal/model"
|
"kami/internal/model"
|
||||||
@@ -15,6 +11,11 @@ import (
|
|||||||
"kami/internal/service"
|
"kami/internal/service"
|
||||||
"kami/utility/config"
|
"kami/utility/config"
|
||||||
"kami/utility/utils"
|
"kami/utility/utils"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
|
"github.com/gogf/gf/container/gset"
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AddOne 添加一条充值记录
|
// AddOne 添加一条充值记录
|
||||||
@@ -91,8 +92,12 @@ func (h *sCardRedeemOrder) List(ctx context.Context, input *model.RedeemCardList
|
|||||||
if input.Category != "" {
|
if input.Category != "" {
|
||||||
m = m.Where(dao.V1CardRedeemOrderInfo.Columns().Category, input.Category)
|
m = m.Where(dao.V1CardRedeemOrderInfo.Columns().Category, input.Category)
|
||||||
}
|
}
|
||||||
err = m.Page(input.Current, input.PageSize).
|
|
||||||
OrderDesc(dao.V1CardRedeemOrderInfo.Columns().CreatedAt).
|
if input.Current != 0 && input.PageSize != 0 {
|
||||||
|
m = m.Page(input.Current, input.PageSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = m.OrderDesc(dao.V1CardRedeemOrderInfo.Columns().CreatedAt).
|
||||||
ScanAndCount(&data, &total, false)
|
ScanAndCount(&data, &total, false)
|
||||||
err = utils.HandleNoRowsError(err)
|
err = utils.HandleNoRowsError(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -3,19 +3,20 @@ package card_redeem_order
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gogf/gf/v2/database/gdb"
|
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
|
||||||
"kami/api/commonApi"
|
"kami/api/commonApi"
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/dao"
|
"kami/internal/dao"
|
||||||
"kami/internal/model"
|
"kami/internal/model"
|
||||||
"kami/utility/config"
|
"kami/utility/config"
|
||||||
"kami/utility/utils"
|
"kami/utility/utils"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *sCardRedeemOrder) Summary(ctx context.Context, page commonApi.CommonPageReq, category consts.CardRedeemAccountCategory, accountIds []string, username string, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error) {
|
func (h *sCardRedeemOrder) Summary(ctx context.Context, page commonApi.CommonPageReq, category consts.CardRedeemAccountCategory, username string, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error) {
|
||||||
output = make([]*model.RedeemCardSummaryOutput, 0)
|
output = make([]*model.RedeemCardSummaryOutput, 0)
|
||||||
m := dao.V1CardRedeemOrderInfo.Ctx(ctx).DB(config.GetDatabaseV1()).WhereIn(dao.V1CardRedeemOrderInfo.Columns().AccountId, accountIds)
|
m := dao.V1CardRedeemOrderInfo.Ctx(ctx).DB(config.GetDatabaseV1()).Unscoped()
|
||||||
if tx != nil {
|
if tx != nil {
|
||||||
m = m.TX(tx)
|
m = m.TX(tx)
|
||||||
}
|
}
|
||||||
@@ -43,7 +44,7 @@ func (h *sCardRedeemOrder) Summary(ctx context.Context, page commonApi.CommonPag
|
|||||||
).
|
).
|
||||||
Page(page.Current, page.PageSize).
|
Page(page.Current, page.PageSize).
|
||||||
OrderDesc(fmt.Sprintf("DATE(%s)", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt))).
|
OrderDesc(fmt.Sprintf("DATE(%s)", utils.OrmTable(dao.V1CardRedeemOrderInfo.Table(), dao.V1CardRedeemOrderInfo.Columns().CreatedAt))).
|
||||||
Unscoped().WhereIn(dao.V1CardRedeemOrderInfo.Columns().Category, category).
|
WhereIn(dao.V1CardRedeemOrderInfo.Columns().Category, category).
|
||||||
WhereIn(dao.V1CardRedeemOrderInfo.Columns().OrderStatus, []consts.RedeemOrderStatus{consts.RedeemOrderSuccess, consts.RedeemOrderSuccessWithDifferentAmount}).
|
WhereIn(dao.V1CardRedeemOrderInfo.Columns().OrderStatus, []consts.RedeemOrderStatus{consts.RedeemOrderSuccess, consts.RedeemOrderSuccessWithDifferentAmount}).
|
||||||
Scan(&output)
|
Scan(&output)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package card_redeem_order
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
|
||||||
"kami/api/commonApi"
|
"kami/api/commonApi"
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_sCardRedeemOrder_Summary(t *testing.T) {
|
func Test_sCardRedeemOrder_Summary(t *testing.T) {
|
||||||
@@ -14,7 +15,7 @@ func Test_sCardRedeemOrder_Summary(t *testing.T) {
|
|||||||
orderInfo.Summary(context.Background(), commonApi.CommonPageReq{
|
orderInfo.Summary(context.Background(), commonApi.CommonPageReq{
|
||||||
Current: 1,
|
Current: 1,
|
||||||
PageSize: 50,
|
PageSize: 50,
|
||||||
}, consts.CardRedeemAccountCategoryWalMart, []string{}, "", nil, nil)
|
}, consts.CardRedeemAccountCategoryWalMart, "", nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_sCardRedeemOrder_DailySummary(t *testing.T) {
|
func Test_sCardRedeemOrder_DailySummary(t *testing.T) {
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
|
||||||
v1 "kami/api/card_info_walmart/v1"
|
v1 "kami/api/card_info_walmart/v1"
|
||||||
"kami/api/commonApi"
|
"kami/api/commonApi"
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RedeemAccountGroup struct {
|
type RedeemAccountGroup struct {
|
||||||
@@ -21,9 +22,20 @@ type RedeemAccountGroupList struct {
|
|||||||
Category consts.CardRedeemAccountCategory
|
Category consts.CardRedeemAccountCategory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RedeemAccountGroupStatsInput struct {
|
||||||
|
CreatedUserId string
|
||||||
|
Category consts.CardRedeemAccountCategory
|
||||||
|
*v1.GroupStatReq
|
||||||
|
}
|
||||||
|
|
||||||
|
type RedeemAccountGroupStatsOutput struct {
|
||||||
|
*v1.V1CardRedeemAccountGroupEntity
|
||||||
|
}
|
||||||
|
|
||||||
type RedeemAccountGroupAll struct {
|
type RedeemAccountGroupAll struct {
|
||||||
CreatedUserId string
|
CreatedUserId string
|
||||||
Category consts.CardRedeemAccountCategory
|
Category consts.CardRedeemAccountCategory
|
||||||
|
GroupIds []int
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedeemAccountAddHistory struct {
|
type RedeemAccountAddHistory struct {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ type (
|
|||||||
GroupAll(ctx context.Context, input *model.RedeemAccountGroupAll, tx gdb.TX) (total int, data []*entity.V1CardRedeemAccountGroup, err error)
|
GroupAll(ctx context.Context, input *model.RedeemAccountGroupAll, tx gdb.TX) (total int, data []*entity.V1CardRedeemAccountGroup, err error)
|
||||||
// GroupDelete 删除某个分组
|
// GroupDelete 删除某个分组
|
||||||
GroupDelete(ctx context.Context, id uint, createdUserId string, tx gdb.TX) (err error)
|
GroupDelete(ctx context.Context, id uint, createdUserId string, tx gdb.TX) (err error)
|
||||||
|
GroupStats(ctx context.Context, input *model.RedeemAccountGroupStatsInput, tx gdb.TX) (total int, output []*model.RedeemAccountGroupStatsOutput, err error)
|
||||||
// AddHistory 添加操作历史
|
// AddHistory 添加操作历史
|
||||||
AddHistory(ctx context.Context, input *model.RedeemAccountAddHistory, tx gdb.TX) (err error)
|
AddHistory(ctx context.Context, input *model.RedeemAccountAddHistory, tx gdb.TX) (err error)
|
||||||
// GetWalletHistory 获取单账户钱包明细
|
// GetWalletHistory 获取单账户钱包明细
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ type (
|
|||||||
ModifyCallBackStatus(ctx context.Context, orderNo string, callbackStatus consts.RedeemOrderCallbackStatus, tx gdb.TX) (err error)
|
ModifyCallBackStatus(ctx context.Context, orderNo string, callbackStatus consts.RedeemOrderCallbackStatus, tx gdb.TX) (err error)
|
||||||
// UpdateCardNoAndCardType 更新卡号和卡种
|
// UpdateCardNoAndCardType 更新卡号和卡种
|
||||||
UpdateCardNoAndCardType(ctx context.Context, orderNo string, cardNo string, cardTypeName string, tx gdb.TX) (err error)
|
UpdateCardNoAndCardType(ctx context.Context, orderNo string, cardNo string, cardTypeName string, tx gdb.TX) (err error)
|
||||||
Summary(ctx context.Context, page commonApi.CommonPageReq, category consts.CardRedeemAccountCategory, accountIds []string, username string, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
|
Summary(ctx context.Context, page commonApi.CommonPageReq, category consts.CardRedeemAccountCategory, username string, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
|
||||||
// DailySummary 查询某个用户当日的订单总额
|
// DailySummary 查询某个用户当日的订单总额
|
||||||
DailySummary(ctx context.Context, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
|
DailySummary(ctx context.Context, date *gtime.Time, tx gdb.TX) (output []*model.RedeemCardSummaryOutput, err error)
|
||||||
}
|
}
|
||||||
|
|||||||
7
utility/cache/cache.go
vendored
7
utility/cache/cache.go
vendored
@@ -2,12 +2,13 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
|
||||||
"github.com/gogf/gf/v2/os/glog"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
|
|
||||||
"github.com/duke-git/lancet/v2/slice"
|
"github.com/duke-git/lancet/v2/slice"
|
||||||
"github.com/gogf/gf/v2/net/gtrace"
|
"github.com/gogf/gf/v2/net/gtrace"
|
||||||
"github.com/gogf/gf/v2/os/gcache"
|
"github.com/gogf/gf/v2/os/gcache"
|
||||||
@@ -53,7 +54,7 @@ func NewCache() *Cache {
|
|||||||
cache = &Cache{
|
cache = &Cache{
|
||||||
Cache: gcache.New(),
|
Cache: gcache.New(),
|
||||||
}
|
}
|
||||||
//cache.SetAdapter(gcache.NewAdapterMemory())
|
// cache.SetAdapter(gcache.NewAdapterMemory())
|
||||||
cache.SetAdapter(gcache.NewAdapterRedis(g.Redis()))
|
cache.SetAdapter(gcache.NewAdapterRedis(g.Redis()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user