excel导出接口
This commit is contained in:
parent
37fa991a9f
commit
1ba0cce450
@ -53,3 +53,7 @@ func (b *BundleProvider) ConfirmWork(_ context.Context, req *bundle.ConfirmWorkR
|
||||
func (b *BundleProvider) BundleActivate(_ context.Context, req *bundle.BundleActivateReq) (*bundle.BundleActivateResp, error) {
|
||||
return nil, logic.BundleActivate(req)
|
||||
}
|
||||
|
||||
func (b *BundleProvider) BundleBalanceExport(_ context.Context, req *bundle.BundleBalanceExportReq) (*bundle.BundleBalanceExportResp, error) {
|
||||
return logic.BundleBalanceExport(req)
|
||||
}
|
||||
|
@ -586,3 +586,36 @@ inner join (
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// excel导出前置信息
|
||||
func BalanceExportPrefix() (data []model.BundleExportDto, err error) {
|
||||
err = app.ModuleClients.BundleDB.DB.Raw(`select
|
||||
bor.pay_time as pay_time,
|
||||
bor.customer_num as customer_num,
|
||||
r.fee as fee,
|
||||
bor.customer_id as user_id,
|
||||
bor.amount as bundle_amount,
|
||||
total_amount as total_pay_amount
|
||||
from
|
||||
bundle_order_records bor
|
||||
right join (
|
||||
select
|
||||
max(created_at) as created_at
|
||||
from
|
||||
bundle_order_records bor
|
||||
group by
|
||||
bor.customer_id
|
||||
) newest on
|
||||
bor.created_at = newest.created_at
|
||||
left join (
|
||||
select
|
||||
sum(r.handling_fee) as fee,
|
||||
r.bundle_order_on
|
||||
from
|
||||
reconciliation r
|
||||
group by
|
||||
r.bundle_order_on
|
||||
) r on r.bundle_order_on = bor.order_no
|
||||
`).Scan(&data).Error
|
||||
return
|
||||
}
|
||||
|
@ -395,3 +395,41 @@ func BundleActivate(req *bundle.BundleActivateReq) error {
|
||||
func UpdateBundleBalance() {
|
||||
dao.UpdateBundleBalance()
|
||||
}
|
||||
|
||||
func BundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.BundleBalanceExportResp, error) {
|
||||
data, err := GetBundleBalanceList(&bundle.GetBundleBalanceListReq{
|
||||
Month: req.Month,
|
||||
Bought: 2,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
prefixData, err := dao.BalanceExportPrefix()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var prefixMap = map[int32]model.BundleExportDto{}
|
||||
for _, v := range prefixData {
|
||||
prefixMap[v.UserId] = v
|
||||
}
|
||||
|
||||
items := []*bundle.BundleBalanceExportItem{}
|
||||
|
||||
for _, v := range data.Data {
|
||||
prefixItem := prefixMap[v.UserId]
|
||||
item := &bundle.BundleBalanceExportItem{}
|
||||
copier.Copy(item, v)
|
||||
item.CustomerNum = prefixItem.CustomNum
|
||||
item.PayTime = prefixItem.PayTime
|
||||
item.BundleAmount = prefixItem.BundleAmount
|
||||
item.IncreaseAmount = prefixItem.TotalPayAmount - prefixItem.BundleAmount
|
||||
item.TotalPayAmount = prefixItem.TotalPayAmount
|
||||
item.Currency = "USD"
|
||||
item.Fee = prefixItem.Fee
|
||||
item.BundleVideoUnitPrice = float32(item.BundleAmount / float32(v.BundleVideoNumber))
|
||||
item.IncreaseVideoUnitPrice = float32(item.IncreaseAmount / float32(v.IncreaseVideoNumber))
|
||||
items = append(items, item)
|
||||
}
|
||||
return &bundle.BundleBalanceExportResp{Total: int64(len(items)), Data: items}, nil
|
||||
}
|
||||
|
@ -324,3 +324,21 @@ type BundleUsedRecord struct {
|
||||
func (BundleUsedRecord) TableName() string {
|
||||
return "bundle_used_record"
|
||||
}
|
||||
|
||||
type BundleExportDto struct {
|
||||
UserId int32
|
||||
Month string
|
||||
CustomNum string
|
||||
Name string
|
||||
PayTime string
|
||||
BundleAmount float32
|
||||
IncreaseAmount float32
|
||||
TotalPayAmount float32
|
||||
Currency string
|
||||
Fee string
|
||||
}
|
||||
|
||||
type BundleExport struct {
|
||||
BundleExportDto
|
||||
balance *BundleBalance
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ service Bundle {
|
||||
rpc CreateBundleBalance(CreateBundleBalanceReq) returns (CreateBundleBalanceResp) {} // 创建新的余量信息
|
||||
rpc AddBundleBalance(AddBundleBalanceReq) returns (AddBundleBalanceResp) {} // 修改余量信息
|
||||
rpc BundleActivate(BundleActivateReq) returns (BundleActivateResp) {} // 用户套餐激活
|
||||
rpc BundleBalanceExport(BundleBalanceExportReq) returns (BundleBalanceExportResp) {} // 套餐余量导出
|
||||
|
||||
// 使用记录
|
||||
rpc GetUsedRecordList(GetUsedRecordListReq) returns (GetUsedRecordListResp) {} // 获取套餐使用记录列表
|
||||
@ -756,6 +757,87 @@ message BundleBalanceItem {
|
||||
int32 activate = 51 ; // 激活状态
|
||||
}
|
||||
|
||||
message BundleBalanceExportItem {
|
||||
// 基本信息
|
||||
int32 month = 1; // 所属月份
|
||||
string customerNum = 2; // 用户编号
|
||||
string userName = 3; // 名字
|
||||
string userPhoneNumber = 4; // 手机号
|
||||
string payTime = 5; // 支付时间
|
||||
float bundleAmount = 6; // 套餐金额
|
||||
float increaseAmount = 7; // 增值服务金额
|
||||
float totalPayAmount = 8; // 支付金额
|
||||
string currency = 9; // 币种
|
||||
string fee = 10; // 手续费
|
||||
|
||||
float bundleVideoUnitPrice = 11; // 套餐视频单价
|
||||
float increaseVideoUnitPrice = 12; // 增值视频单价
|
||||
|
||||
// 账号类
|
||||
int32 bundleAccountNumber = 13; // 套餐账号总数
|
||||
int32 increaseAccountNumber = 14; // 增值账号总数
|
||||
int32 bundleAccountConsumptionNumber = 15; // 套餐账号使用数
|
||||
int32 increaseAccountConsumptionNumber = 16; // 增值账号使用数
|
||||
|
||||
// 视频类
|
||||
int32 bundleVideoNumber = 17; // 当前可用套餐视频数
|
||||
int32 increaseVideoNumber = 18; // 当前可用增值视频数
|
||||
int32 bundleVideoConsumptionNumber = 19; // 当前已用套餐视频数
|
||||
int32 increaseVideoConsumptionNumber = 20; // 当前已用增值视频数
|
||||
int32 invalidBundleVideoNumber = 21; // 当前作废套餐视频数
|
||||
int32 invalidIncreaseVideoNumber = 22; // 当前作废增值视频数
|
||||
int32 monthlyNewBundleVideoNumber = 23; // 当月新增套餐视频数
|
||||
int32 monthlyNewIncreaseVideoNumber = 24; // 当月新增增值视频数
|
||||
int32 monthlyInvalidBundleVideoNumber = 25; // 当月作废套餐视频数
|
||||
int32 monthlyInvalidIncreaseVideoNumber = 26; // 当月作废增值视频数
|
||||
|
||||
// 图文类
|
||||
int32 bundleImageNumber = 27; // 当前可用套餐图文数
|
||||
int32 increaseImageNumber = 28; // 当前可用增值图文数
|
||||
int32 bundleImageConsumptionNumber = 29; // 当前已用套餐图文数
|
||||
int32 increaseImageConsumptionNumber = 30; // 当前已用增值图文数
|
||||
int32 invalidBundleImageNumber = 31; // 当前作废套餐图文数
|
||||
int32 invalidIncreaseImageNumber = 32; // 当前作废增值图文数
|
||||
int32 monthlyNewBundleImageNumber = 33; // 当月新增套餐图文数
|
||||
int32 monthlyNewIncreaseImageNumber = 34; // 当月新增增值图文数
|
||||
int32 monthlyInvalidBundleImageNumber = 35; // 当月作废套餐图文数
|
||||
int32 monthlyInvalidIncreaseImageNumber = 36; // 当月作废增值图文数
|
||||
|
||||
// 数据分析类
|
||||
int32 bundleDataAnalysisNumber = 37; // 当前可用套餐数据分析数
|
||||
int32 increaseDataAnalysisNumber = 38; // 当前可用增值数据分析数
|
||||
int32 bundleDataAnalysisConsumptionNumber = 39; // 当前已用套餐数据分析数
|
||||
int32 increaseDataAnalysisConsumptionNumber = 40; // 当前已用增值数据分析数
|
||||
int32 invalidBundleDataAnalysisNumber = 41; // 当前作废套餐数据分析数
|
||||
int32 invalidIncreaseDataAnalysisNumber = 42; // 当前作废增值数据分析数
|
||||
int32 monthlyNewBundleDataAnalysisNumber = 43; // 当月新增套餐数据分析数
|
||||
int32 monthlyNewIncreaseDataAnalysisNumber = 44; // 当月新增增值数据分析数
|
||||
int32 monthlyInvalidBundleDataAnalysisNumber = 45; // 当月作废套餐数据分析数
|
||||
int32 monthlyInvalidIncreaseDataAnalysisNumber = 46; // 当月作废增值数据分析数
|
||||
|
||||
// 手动扩展类
|
||||
int32 monthlyNewManualAccountNumber = 47; // 当月手动扩展账号新增数
|
||||
int32 monthlyNewManualVideoNumber = 48; // 当月手动扩展视频新增数
|
||||
int32 monthlyNewManualImageNumber = 49; // 当月手动扩展图文新增数
|
||||
int32 monthlyNewManualDataAnalysisNumber = 50; // 当月手动扩展数据分析新增数
|
||||
int32 monthlyNewDurationNumber = 51; // 当月新增手动扩展时长(天)
|
||||
int32 monthlyManualAccountConsumptionNumber = 52; // 当月手动扩展账号使用数
|
||||
int32 monthlyManualVideoConsumptionNumber = 53; // 当月手动扩展视频使用数
|
||||
int32 monthlyManualImageConsumptionNumber = 54; // 当月手动扩展图文使用数
|
||||
int32 monthlyManualDataAnalysisConsumptionNumber = 55; // 当月手动扩展数据分析使用数
|
||||
}
|
||||
|
||||
|
||||
message BundleBalanceExportReq{
|
||||
string month = 1;
|
||||
}
|
||||
|
||||
message BundleBalanceExportResp{
|
||||
int64 total = 1;
|
||||
repeated BundleBalanceExportItem data =2;
|
||||
}
|
||||
|
||||
|
||||
message GetBundleBalanceListResp{
|
||||
int64 total = 1;
|
||||
repeated BundleBalanceItem data = 2;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -370,6 +370,22 @@ func (this *GetBundleBalanceReq) Validate() error {
|
||||
func (this *BundleBalanceItem) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *BundleBalanceExportItem) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *BundleBalanceExportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *BundleBalanceExportResp) Validate() error {
|
||||
for _, item := range this.Data {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetBundleBalanceListResp) Validate() error {
|
||||
for _, item := range this.Data {
|
||||
if item != nil {
|
||||
|
@ -70,6 +70,7 @@ type BundleClient interface {
|
||||
CreateBundleBalance(ctx context.Context, in *CreateBundleBalanceReq, opts ...grpc_go.CallOption) (*CreateBundleBalanceResp, common.ErrorWithAttachment)
|
||||
AddBundleBalance(ctx context.Context, in *AddBundleBalanceReq, opts ...grpc_go.CallOption) (*AddBundleBalanceResp, common.ErrorWithAttachment)
|
||||
BundleActivate(ctx context.Context, in *BundleActivateReq, opts ...grpc_go.CallOption) (*BundleActivateResp, common.ErrorWithAttachment)
|
||||
BundleBalanceExport(ctx context.Context, in *BundleBalanceExportReq, opts ...grpc_go.CallOption) (*BundleBalanceExportResp, common.ErrorWithAttachment)
|
||||
// 使用记录
|
||||
GetUsedRecordList(ctx context.Context, in *GetUsedRecordListReq, opts ...grpc_go.CallOption) (*GetUsedRecordListResp, common.ErrorWithAttachment)
|
||||
GetImageWorkDetail(ctx context.Context, in *GetImageWorkDetailReq, opts ...grpc_go.CallOption) (*GetImageWorkDetailResp, common.ErrorWithAttachment)
|
||||
@ -140,6 +141,7 @@ type BundleClientImpl struct {
|
||||
CreateBundleBalance func(ctx context.Context, in *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error)
|
||||
AddBundleBalance func(ctx context.Context, in *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
|
||||
BundleActivate func(ctx context.Context, in *BundleActivateReq) (*BundleActivateResp, error)
|
||||
BundleBalanceExport func(ctx context.Context, in *BundleBalanceExportReq) (*BundleBalanceExportResp, error)
|
||||
GetUsedRecordList func(ctx context.Context, in *GetUsedRecordListReq) (*GetUsedRecordListResp, error)
|
||||
GetImageWorkDetail func(ctx context.Context, in *GetImageWorkDetailReq) (*GetImageWorkDetailResp, error)
|
||||
GetVedioWorkDetail func(ctx context.Context, in *GetVedioWorkDetailReq) (*GetVedioeWorkDetailResp, error)
|
||||
@ -408,6 +410,12 @@ func (c *bundleClient) BundleActivate(ctx context.Context, in *BundleActivateReq
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleActivate", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) BundleBalanceExport(ctx context.Context, in *BundleBalanceExportReq, opts ...grpc_go.CallOption) (*BundleBalanceExportResp, common.ErrorWithAttachment) {
|
||||
out := new(BundleBalanceExportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleBalanceExport", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) GetUsedRecordList(ctx context.Context, in *GetUsedRecordListReq, opts ...grpc_go.CallOption) (*GetUsedRecordListResp, common.ErrorWithAttachment) {
|
||||
out := new(GetUsedRecordListResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -574,6 +582,7 @@ type BundleServer interface {
|
||||
CreateBundleBalance(context.Context, *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error)
|
||||
AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
|
||||
BundleActivate(context.Context, *BundleActivateReq) (*BundleActivateResp, error)
|
||||
BundleBalanceExport(context.Context, *BundleBalanceExportReq) (*BundleBalanceExportResp, error)
|
||||
// 使用记录
|
||||
GetUsedRecordList(context.Context, *GetUsedRecordListReq) (*GetUsedRecordListResp, error)
|
||||
GetImageWorkDetail(context.Context, *GetImageWorkDetailReq) (*GetImageWorkDetailResp, error)
|
||||
@ -723,6 +732,9 @@ func (UnimplementedBundleServer) AddBundleBalance(context.Context, *AddBundleBal
|
||||
func (UnimplementedBundleServer) BundleActivate(context.Context, *BundleActivateReq) (*BundleActivateResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method BundleActivate not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) BundleBalanceExport(context.Context, *BundleBalanceExportReq) (*BundleBalanceExportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method BundleBalanceExport not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) GetUsedRecordList(context.Context, *GetUsedRecordListReq) (*GetUsedRecordListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetUsedRecordList not implemented")
|
||||
}
|
||||
@ -1942,6 +1954,35 @@ func _Bundle_BundleActivate_Handler(srv interface{}, ctx context.Context, dec fu
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Bundle_BundleBalanceExport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(BundleBalanceExportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("BundleBalanceExport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Bundle_GetUsedRecordList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUsedRecordListReq)
|
||||
if err := dec(in); err != nil {
|
||||
@ -2685,6 +2726,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "BundleActivate",
|
||||
Handler: _Bundle_BundleActivate_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "BundleBalanceExport",
|
||||
Handler: _Bundle_BundleBalanceExport_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUsedRecordList",
|
||||
Handler: _Bundle_GetUsedRecordList_Handler,
|
||||
|
Loading…
Reference in New Issue
Block a user