@ -943,52 +943,52 @@ func ItemIncomeExpenseRecords(ctx context.Context, req *game.ItemRecordReq) (res
func ShopRecords ( ctx context . Context , req * game . ShopRecordReq ) ( res * game . ShopRecordRes , err error ) {
res = new ( game . ShopRecordRes )
g . Try ( ctx , func ( ctx context . Context ) {
model := dao . GameShopLog . Ctx ( ctx )
_ , err = model . Insert ( & do . GameShopLog {
Uid : req . Uid ,
ItemId : req . ItemId ,
Price : req . Price ,
Num : req . Num ,
ServerId : req . ServerId ,
Uid : req . Uid ,
ItemId : req . ItemId ,
Price : req . Price ,
Num : req . Num ,
ServerId : req . ServerId ,
ConfigType : req . ConfigType ,
} )
return
} )
g . Log ( ) . Info ( ctx , "a== " , res )
return
}
func GetShopItemLog ( ctx context . Context , req * game . GetShopItemLogReq ) ( res * game . GetShopItemLogRes , err error ) {
res = new ( game . GetShopItemLogRes )
g . Try ( ctx , func ( ctx context . Context ) {
shopLogSql := fmt . Sprintf ( ` select u.account,s.itemId,s.num,s.price from game_shop_log s inner join game_unit u on s.uid=u.uid where 1=1 ` )
shopLogSql := fmt . Sprintf ( ` select u.account,s.itemId,s.num,s.price,s.config_type from game_shop_log s inner join game_unit u on s.uid=u.uid and s.serverId=u.server where 1=1 ` )
rechargeSql := fmt . Sprintf ( ` select DISTINCT u.account from game_recharge r inner join game_unit u on r.unitId=u.uid inner join game_register rr on rr.account=u.account where r.status=2 ` )
if req . LowTime != 0 {
start := time . Unix ( req . LowTime , 0 ) . Format ( consts . TIME_FORMAT )
rechargeSql += fmt . Sprintf ( ` and rr.create_time>%s ` , start )
shopLogSql += fmt . Sprintf ( ` and s.c_date>%s ` , start )
if req . LowTime != "" {
//start := time.Unix(req.LowTime, 0).Format(consts.TIME_FORMAT)
rechargeSql += fmt . Sprintf ( ` and rr.create_time>" %s" ` , req . LowTime )
shopLogSql += fmt . Sprintf ( ` and s.c_date>" %s" ` , req . LowTime )
}
if req . Uptime != 0 {
end := time . Unix ( req . Uptime , 0 ) . Format ( consts . TIME_FORMAT )
rechargeSql = fmt . Sprintf ( ` %s and rr.create_time<%s ` , rechargeSql , end )
shopLogSql = fmt . Sprintf ( ` %s and s.c_date<%s ` , shopLogSql , end )
if req . Uptime != "" {
//end := time.Unix(req.Uptime, 0).Format(consts.TIME_FORMAT)
rechargeSql = fmt . Sprintf ( ` %s and rr.create_time<" %s" ` , rechargeSql , req . Uptime )
shopLogSql = fmt . Sprintf ( ` %s and s.c_date<" %s" ` , shopLogSql , req . Uptime )
}
if req . ServerId != 0 {
rechargeSql = fmt . Sprintf ( ` %s and u.server=%d ` , rechargeSql , req . ServerId )
shopLogSql = fmt . Sprintf ( ` %s and u.server=%d ` , shopLogSql , req . ServerId )
}
if req . Channel != "" {
rechargeSql = fmt . Sprintf ( ` %s and u.channel=%s ` , rechargeSql , req . Channel )
shopLogSql = fmt . Sprintf ( ` %s and u.channel=%s ` , shopLogSql , req . Channel )
rechargeSql = fmt . Sprintf ( ` %s and u.channel=" %s" ` , rechargeSql , req . Channel )
shopLogSql = fmt . Sprintf ( ` %s and u.channel=" %s" ` , shopLogSql , req . Channel )
}
if req . GM == 0 {
rechargeSql = fmt . Sprintf ( ` %s and r.tradeNo NOT LIKE 'GM%%' ` , rechargeSql )
rechargeSql = fmt . Sprintf ( ` %s and r.tradeNo NOT LIKE "GM%%" ` , rechargeSql )
}
shopLogSql = fmt . Sprintf ( ` select a.account, a.itemId from (%s) as a group by a.itemId,a.account ` , shopLogSql )
shopLogSql = fmt . Sprintf ( ` select count(1) as num, b.itemId from (%s) as b group by b.itemId ` , shopLogSql )
err = g . Model ( ) . Raw ( shopLogSql ) . Scan ( & res . Logs )
shopLogSql = fmt . Sprintf ( ` select a.account, a.itemId, a.config_type from (%s) as a group by a.itemId,a.config_type,a.account ` , shopLogSql )
shopLogSql = fmt . Sprintf ( ` select count(1) as num, b.itemId, b.config_type from (%s) as b group by b.itemId,b.config_type ` , shopLogSql )
res . Total , err = g . Model ( ) . Raw ( shopLogSql ) . Count ( )
err = g . Model ( ) . Raw ( shopLogSql ) . Page ( req . PageNum , req . PageSize ) . Scan ( & res . Logs )
res . RechargeTotal , err = g . Model ( ) . Raw ( rechargeSql ) . Count ( )
if err != nil {
return
@ -998,6 +998,42 @@ func GetShopItemLog(ctx context.Context, req *game.GetShopItemLogReq) (res *game
return
}
func GetShopItemList ( ctx context . Context , req * game . GetShopItemListReq ) ( res * game . GetShopItemListRes , err error ) {
res = new ( game . GetShopItemListRes )
g . Try ( ctx , func ( ctx context . Context ) {
model := dao . GameShopLog . Ctx ( ctx )
if req . LowTime != "" {
model = model . Where ( "c_date>?" , req . LowTime )
}
if req . Uptime != "" {
model = model . Where ( "c_date<?" , req . Uptime )
}
if req . ServerId != 0 {
model = model . Where ( "serverId=?" , req . ServerId )
}
if req . Uid != 0 {
id , _ := GetIdToUid ( ctx , int64 ( req . Uid ) )
model = model . Where ( "uid=?" , id )
}
err = model . Page ( req . PageNum , req . PageSize ) . OrderDesc ( "c_date" ) . Scan ( & res . Logs )
res . Total , err = model . Count ( )
for k , v := range res . Logs {
res . Logs [ k ] . StringId = fmt . Sprint ( v . Uid )
res . Logs [ k ] . UniqueId , _ = GetStringIdToUid ( ctx , res . Logs [ k ] . StringId )
account , err := GetUnitById ( ctx , v . Uid , v . ServerId )
if err != nil {
continue
}
res . Logs [ k ] . Account = fmt . Sprint ( account . Account )
}
if err != nil {
return
}
return
} )
return
}
func GameUserDel ( ctx context . Context , req * game . UserDelReq ) ( res * game . UserDelRes , err error ) {
err = g . Try ( ctx , func ( ctx context . Context ) {
res = new ( game . UserDelRes )