How to use EndDate method of result Package

Best Testkube code snippet using result.EndDate

statistic_handler.go

Source:statistic_handler.go Github

copy

Full Screen

...23)24// 获取统计数据-用户提现-用来展示统计图表25func (*CustHandler) GetStatisticUserWithdraw(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserWithdrawRequest, reply *go_micro_srv_cust.GetStatisticUserWithdrawReply) error {26 // 检查日期格式是否正确27 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {28 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)29 reply.ResultCode = ss_err.ERR_PARAM30 return nil31 }32 // 检查结束时间是否大于等于开始时间33 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {34 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)35 reply.ResultCode = ss_err.ERR_PARAM36 return nil37 }38 // 生成日期范围39 dateList, err := ss_time.GetDateRange(ss_time.DateFormat, req.StartDate, req.EndDate)40 if err != nil {41 ss_log.Error("获取日期范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, ss_time.DateFormat, req.StartDate, req.EndDate)42 reply.ResultCode = ss_err.ERR_PARAM43 return nil44 }45 // 初始化各项数据46 dateLen := len(dateList)47 reply.DateList = dateList48 reply.UsdNumList = make([]int64, dateLen)49 reply.UsdAmountList = make([]int64, dateLen)50 reply.UsdFeeList = make([]int64, dateLen)51 reply.KhrNumList = make([]int64, dateLen)52 reply.KhrAmountList = make([]int64, dateLen)53 reply.KhrFeeList = make([]int64, dateLen)54 for _, currencyType := range []string{constants.CURRENCY_USD, constants.CURRENCY_KHR} {55 // 查询统计数据56 list, err := dao.StatisticUserWithdrawDaoInst.GetStatisticData(req.StartDate, req.EndDate, currencyType)57 if err != nil {58 ss_log.Error("查询用户提现统计数据失败,err:%v,StartDate:%s,EndDate:%s, currencyType:%s", err, req.StartDate, req.EndDate, currencyType)59 continue60 }61 // 以生成的日期为准去组织数据62 for i, day := range reply.DateList {63 for _, v := range list {64 if day == v.Day {65 if currencyType == constants.CURRENCY_USD {66 reply.UsdNumList[i] = v.TotalNum67 reply.UsdAmountList[i] = v.TotalAmount68 reply.UsdFeeList[i] = v.TotalFee69 } else if currencyType == constants.CURRENCY_KHR {70 reply.KhrNumList[i] = v.TotalNum71 reply.KhrAmountList[i] = v.TotalAmount72 reply.KhrFeeList[i] = v.TotalFee73 }74 break75 }76 }77 }78 }79 reply.ResultCode = ss_err.ERR_SUCCESS80 return nil81}82// 获取统计数据-用户提现-列表83func (*CustHandler) GetStatisticUserWithdrawList(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserWithdrawListRequest, reply *go_micro_srv_cust.GetStatisticUserWithdrawListReply) error {84 // 检查日期格式是否正确85 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {86 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)87 reply.ResultCode = ss_err.ERR_PARAM88 return nil89 }90 // 检查结束时间是否大于等于开始时间91 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {92 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)93 reply.ResultCode = ss_err.ERR_PARAM94 return nil95 }96 // 检查提现类型97 if req.WithdrawType != "" && !util.InSlice(req.WithdrawType, []string{dao.StatisticWithdrawTypeCard, dao.StatisticRechargeTypeWriteoff, dao.StatisticRechargeTypeScan}) {98 ss_log.Error("参数错误:提现类型错误,WithdrawType:%v", req.WithdrawType)99 reply.ResultCode = ss_err.ERR_PARAM100 return nil101 }102 // 币种类型103 if req.CurrencyType != "" && !util.InSlice(req.CurrencyType, []string{constants.CURRENCY_USD, constants.CURRENCY_KHR}) {104 ss_log.Error("参数错误:币种类型错误,CurrencyType:%v", req.CurrencyType)105 reply.ResultCode = ss_err.ERR_PARAM106 return nil107 }108 if req.Page < 1 {109 req.Page = 1110 }111 if req.PageSize < 1 {112 req.PageSize = 10113 }114 // 查询列表数据115 dataList, total, err := dao.StatisticUserWithdrawDaoInst.GetStatisticDataList(req)116 if err != nil {117 ss_log.Error("GetStatisticDataList失败,err:%v, req:%+v", err, req)118 reply.ResultCode = ss_err.ERR_SYS_DB_GET119 return nil120 }121 reply.ResultCode = ss_err.ERR_SUCCESS122 reply.DataList = dataList123 reply.Total = total124 return nil125}126// 获取统计数据-用户充值-用来展示统计图表127func (*CustHandler) GetStatisticUserRecharge(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserRechargeRequest, reply *go_micro_srv_cust.GetStatisticUserRechargeReply) error {128 // 检查日期格式是否正确129 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {130 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)131 reply.ResultCode = ss_err.ERR_PARAM132 return nil133 }134 // 检查结束时间是否大于等于开始时间135 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {136 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)137 reply.ResultCode = ss_err.ERR_PARAM138 return nil139 }140 // 生成日期范围141 dateList, err := ss_time.GetDateRange(ss_time.DateFormat, req.StartDate, req.EndDate)142 if err != nil {143 ss_log.Error("获取日期范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, ss_time.DateFormat, req.StartDate, req.EndDate)144 reply.ResultCode = ss_err.ERR_PARAM145 return nil146 }147 // 初始化各项数据148 dateLen := len(dateList)149 reply.DateList = dateList150 reply.UsdNumList = make([]int64, dateLen)151 reply.UsdAmountList = make([]int64, dateLen)152 reply.UsdFeeList = make([]int64, dateLen)153 reply.KhrNumList = make([]int64, dateLen)154 reply.KhrAmountList = make([]int64, dateLen)155 reply.KhrFeeList = make([]int64, dateLen)156 for _, currencyType := range []string{constants.CURRENCY_USD, constants.CURRENCY_KHR} {157 // 查询统计数据158 list, err := dao.StatisticUserRechargeDaoInst.GetStatisticData(req.StartDate, req.EndDate, currencyType)159 if err != nil {160 ss_log.Error("查询用户充值统计数据失败,err:%v,StartDate:%s,EndDate:%s, currencyType:%s", err, req.StartDate, req.EndDate, currencyType)161 continue162 }163 // 以生成的日期为准去组织数据164 for i, day := range reply.DateList {165 for _, v := range list {166 if day == v.Day {167 if currencyType == constants.CURRENCY_USD {168 reply.UsdNumList[i] = v.TotalNum169 reply.UsdAmountList[i] = v.TotalAmount170 reply.UsdFeeList[i] = v.TotalFee171 } else if currencyType == constants.CURRENCY_KHR {172 reply.KhrNumList[i] = v.TotalNum173 reply.KhrAmountList[i] = v.TotalAmount174 reply.KhrFeeList[i] = v.TotalFee175 }176 break177 }178 }179 }180 }181 reply.ResultCode = ss_err.ERR_SUCCESS182 return nil183}184// 获取统计数据-用户充值-列表185func (*CustHandler) GetStatisticUserRechargeList(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserRechargeListRequest, reply *go_micro_srv_cust.GetStatisticUserRechargeListReply) error {186 // 检查日期格式是否正确187 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {188 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)189 reply.ResultCode = ss_err.ERR_PARAM190 return nil191 }192 // 检查结束时间是否大于等于开始时间193 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {194 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)195 reply.ResultCode = ss_err.ERR_PARAM196 return nil197 }198 // 检查充值类型199 if req.RechargeType != "" && !util.InSlice(req.RechargeType, []string{dao.StatisticRechargeTypeToHeadquarters, dao.StatisticRechargeTypeToservicer}) {200 ss_log.Error("参数错误:充值类型错误,RechargeType:%v", req.RechargeType)201 reply.ResultCode = ss_err.ERR_PARAM202 return nil203 }204 // 币种类型205 if req.CurrencyType != "" && !util.InSlice(req.CurrencyType, []string{constants.CURRENCY_USD, constants.CURRENCY_KHR}) {206 ss_log.Error("参数错误:币种类型错误,CurrencyType:%v", req.CurrencyType)207 reply.ResultCode = ss_err.ERR_PARAM208 return nil209 }210 if req.Page < 1 {211 req.Page = 1212 }213 if req.PageSize < 1 {214 req.PageSize = 10215 }216 // 查询列表数据217 dataList, total, err := dao.StatisticUserRechargeDaoInst.GetStatisticDataList(req)218 if err != nil {219 ss_log.Error("GetStatisticDataList失败,err:%v, req:%+v", err, req)220 reply.ResultCode = ss_err.ERR_SYS_DB_GET221 return nil222 }223 reply.ResultCode = ss_err.ERR_SUCCESS224 reply.DataList = dataList225 reply.Total = total226 return nil227}228// 获取统计数据-用户转账-用来展示统计图表229func (*CustHandler) GetStatisticUserTransfer(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserTransferRequest, reply *go_micro_srv_cust.GetStatisticUserTransferReply) error {230 // 检查日期格式是否正确231 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {232 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)233 reply.ResultCode = ss_err.ERR_PARAM234 return nil235 }236 // 检查结束时间是否大于等于开始时间237 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {238 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)239 reply.ResultCode = ss_err.ERR_PARAM240 return nil241 }242 // 生成日期范围243 dateList, err := ss_time.GetDateRange(ss_time.DateFormat, req.StartDate, req.EndDate)244 if err != nil {245 ss_log.Error("获取日期范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, ss_time.DateFormat, req.StartDate, req.EndDate)246 reply.ResultCode = ss_err.ERR_PARAM247 return nil248 }249 // 初始化各项数据250 dateLen := len(dateList)251 reply.DateList = dateList252 reply.UsdNumList = make([]int64, dateLen)253 reply.UsdAmountList = make([]int64, dateLen)254 reply.UsdFeeList = make([]int64, dateLen)255 reply.KhrNumList = make([]int64, dateLen)256 reply.KhrAmountList = make([]int64, dateLen)257 reply.KhrFeeList = make([]int64, dateLen)258 for _, currencyType := range []string{constants.CURRENCY_USD, constants.CURRENCY_KHR} {259 // 查询统计数据260 list, err := dao.StatisticUserTransferDaoInst.GetStatisticData(req.StartDate, req.EndDate, currencyType)261 if err != nil {262 ss_log.Error("查询用户充值统计数据失败,err:%v,StartDate:%s,EndDate:%s, currencyType:%s", err, req.StartDate, req.EndDate, currencyType)263 continue264 }265 // 以生成的日期为准去组织数据266 for i, day := range reply.DateList {267 for _, v := range list {268 if day == v.Day {269 if currencyType == constants.CURRENCY_USD {270 reply.UsdNumList[i] = v.TotalNum271 reply.UsdAmountList[i] = v.TotalAmount272 reply.UsdFeeList[i] = v.TotalFee273 } else if currencyType == constants.CURRENCY_KHR {274 reply.KhrNumList[i] = v.TotalNum275 reply.KhrAmountList[i] = v.TotalAmount276 reply.KhrFeeList[i] = v.TotalFee277 }278 break279 }280 }281 }282 }283 reply.ResultCode = ss_err.ERR_SUCCESS284 return nil285}286// 获取统计数据-用户转账-列表287func (*CustHandler) GetStatisticUserTransferList(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserTransferListRequest, reply *go_micro_srv_cust.GetStatisticUserTransferListReply) error {288 // 检查日期格式是否正确289 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {290 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)291 reply.ResultCode = ss_err.ERR_PARAM292 return nil293 }294 // 检查结束时间是否大于等于开始时间295 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {296 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)297 reply.ResultCode = ss_err.ERR_PARAM298 return nil299 }300 // 币种类型301 if req.CurrencyType != "" && !util.InSlice(req.CurrencyType, []string{constants.CURRENCY_USD, constants.CURRENCY_KHR}) {302 ss_log.Error("参数错误:币种类型错误,CurrencyType:%v", req.CurrencyType)303 reply.ResultCode = ss_err.ERR_PARAM304 return nil305 }306 if req.Page < 1 {307 req.Page = 1308 }309 if req.PageSize < 1 {310 req.PageSize = 10311 }312 // 查询列表数据313 dataList, total, err := dao.StatisticUserTransferDaoInst.GetStatisticDataList(req)314 if err != nil {315 ss_log.Error("GetStatisticDataList失败,err:%v, req:%+v", err, req)316 reply.ResultCode = ss_err.ERR_SYS_DB_GET317 return nil318 }319 reply.ResultCode = ss_err.ERR_SUCCESS320 reply.DataList = dataList321 reply.Total = total322 return nil323}324// 获取统计数据-用户兑换-用来展示统计图表325func (*CustHandler) GetStatisticUserExchange(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserExchangeRequest, reply *go_micro_srv_cust.GetStatisticUserExchangeReply) error {326 // 检查日期格式是否正确327 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {328 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)329 reply.ResultCode = ss_err.ERR_PARAM330 return nil331 }332 // 检查结束时间是否大于等于开始时间333 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {334 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)335 reply.ResultCode = ss_err.ERR_PARAM336 return nil337 }338 // 生成日期范围339 dateList, err := ss_time.GetDateRange(ss_time.DateFormat, req.StartDate, req.EndDate)340 if err != nil {341 ss_log.Error("获取日期范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, ss_time.DateFormat, req.StartDate, req.EndDate)342 reply.ResultCode = ss_err.ERR_PARAM343 return nil344 }345 // 初始化各项数据346 dateLen := len(dateList)347 reply.DateList = dateList348 reply.Usd2KhrNumList = make([]int64, dateLen)349 reply.Usd2KhrAmountList = make([]int64, dateLen)350 reply.Usd2KhrFeeList = make([]int64, dateLen)351 reply.Khr2UsdNumList = make([]int64, dateLen)352 reply.Khr2UsdAmountList = make([]int64, dateLen)353 reply.Khr2UsdFeeList = make([]int64, dateLen)354 // 查询统计数据355 list, err := dao.StatisticUserExchangeDaoInst.GetStatisticData(req.StartDate, req.EndDate)356 if err != nil {357 ss_log.Error("查询用户兑换统计数据失败,err:%v,StartDate:%s,EndDate:%s", err, req.StartDate, req.EndDate)358 reply.ResultCode = ss_err.ERR_SYS_DB_GET359 return nil360 }361 // 以生成的日期为准去组织数据362 for i, day := range reply.DateList {363 for _, v := range list {364 if day == v.Day {365 reply.Usd2KhrNumList[i] = v.Usd2khrNum366 reply.Usd2KhrAmountList[i] = v.Usd2khrAmount367 reply.Usd2KhrFeeList[i] = v.Usd2khrFee368 reply.Khr2UsdNumList[i] = v.Khr2usdNum369 reply.Khr2UsdAmountList[i] = v.Khr2usdAmount370 reply.Khr2UsdFeeList[i] = v.Khr2usdFee371 break372 }373 }374 }375 reply.ResultCode = ss_err.ERR_SUCCESS376 return nil377}378// 获取统计数据-用户兑换-列表379func (*CustHandler) GetStatisticUserExchangeList(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserExchangeListRequest, reply *go_micro_srv_cust.GetStatisticUserExchangeListReply) error {380 // 检查日期格式是否正确381 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {382 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)383 reply.ResultCode = ss_err.ERR_PARAM384 return nil385 }386 // 检查结束时间是否大于等于开始时间387 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {388 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)389 reply.ResultCode = ss_err.ERR_PARAM390 return nil391 }392 if req.Page < 1 {393 req.Page = 1394 }395 if req.PageSize < 1 {396 req.PageSize = 10397 }398 // 查询列表数据399 dataList, total, err := dao.StatisticUserExchangeDaoInst.GetStatisticDataList(req)400 if err != nil {401 ss_log.Error("GetStatisticDataList失败,err:%v, req:%+v", err, req)402 reply.ResultCode = ss_err.ERR_SYS_DB_GET403 return nil404 }405 reply.ResultCode = ss_err.ERR_SUCCESS406 reply.DataList = dataList407 reply.Total = total408 return nil409}410// 获取按天统计数据-用来展示统计图表411func (*CustHandler) GetStatisticDate(ctx context.Context, req *go_micro_srv_cust.GetStatisticDateRequest, reply *go_micro_srv_cust.GetStatisticDateReply) error {412 // 检查日期格式是否正确413 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {414 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)415 reply.ResultCode = ss_err.ERR_PARAM416 return nil417 }418 // 检查结束时间是否大于等于开始时间419 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {420 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)421 reply.ResultCode = ss_err.ERR_PARAM422 return nil423 }424 // 生成日期范围425 dateList, err := ss_time.GetDateRange(ss_time.DateFormat, req.StartDate, req.EndDate)426 if err != nil {427 ss_log.Error("获取日期范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, ss_time.DateFormat, req.StartDate, req.EndDate)428 reply.ResultCode = ss_err.ERR_PARAM429 return nil430 }431 // 初始化各项数据432 dateLen := len(dateList)433 reply.DateList = dateList434 reply.RegUserNumList = make([]int64, dateLen)435 reply.RegServicerNumList = make([]int64, dateLen)436 // 查询统计数据437 list, err := dao.StatisticDateDaoInst.GetStatisticData(req.StartDate, req.EndDate)438 if err != nil {439 ss_log.Error("查询按天统计数据失败,err:%v,StartDate:%s,EndDate:%s", err, req.StartDate, req.EndDate)440 reply.ResultCode = ss_err.ERR_SYS_DB_GET441 return nil442 }443 // 以生成的日期为准去组织数据444 for i, day := range reply.DateList {445 for _, v := range list {446 if day == v.Day {447 reply.RegUserNumList[i] = v.RegUserNum448 reply.RegServicerNumList[i] = v.RegServicerNum449 break450 }451 }452 }453 reply.ResultCode = ss_err.ERR_SUCCESS454 return nil455}456// 获取按天统计数据-列表457func (*CustHandler) GetStatisticDateList(ctx context.Context, req *go_micro_srv_cust.GetStatisticDateListRequest, reply *go_micro_srv_cust.GetStatisticDateListReply) error {458 // 检查日期格式是否正确459 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {460 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)461 reply.ResultCode = ss_err.ERR_PARAM462 return nil463 }464 // 检查结束时间是否大于等于开始时间465 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {466 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)467 reply.ResultCode = ss_err.ERR_PARAM468 return nil469 }470 if req.Page < 1 {471 req.Page = 1472 }473 if req.PageSize < 1 {474 req.PageSize = 10475 }476 // 查询列表数据477 dataList, total, err := dao.StatisticDateDaoInst.GetStatisticDataList(req)478 if err != nil {479 ss_log.Error("GetStatisticDataList失败,err:%v, req:%+v", err, req)480 reply.ResultCode = ss_err.ERR_SYS_DB_GET481 return nil482 }483 reply.ResultCode = ss_err.ERR_SUCCESS484 reply.DataList = dataList485 reply.Total = total486 return nil487}488// 对统计数据进行重新统计489func (*CustHandler) ReStatistic(ctx context.Context, req *go_micro_srv_cust.ReStatisticRequest, reply *go_micro_srv_cust.ReStatisticReply) error {490 // 检查日期格式是否正确491 if !ss_time.CheckDateIsRight(req.StartDate) || !ss_time.CheckDateIsRight(req.EndDate) {492 ss_log.Error("参数错误:日期格式错误,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)493 reply.ResultCode = ss_err.ERR_PARAM494 return nil495 }496 // 检查结束时间是否大于等于开始时间497 if cmp, _ := ss_time.CompareDate(ss_time.DateFormat, req.StartDate, req.EndDate); cmp > 0 {498 ss_log.Error("参数错误:开始时间大于结束时间,StartDate:%s,EndDate:%s", req.StartDate, req.EndDate)499 reply.ResultCode = ss_err.ERR_PARAM500 return nil501 }502 // 生成日期范围503 dateList, err := ss_time.GetDateRange(ss_time.DateFormat, req.StartDate, req.EndDate)504 if err != nil {505 ss_log.Error("获取日期范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, ss_time.DateFormat, req.StartDate, req.EndDate)506 reply.ResultCode = ss_err.ERR_PARAM507 return nil508 }509 if len(dateList) > 31 {510 ss_log.Error("参数错误,日期范围太大,len:%d,StartDate:%s,EndDate:%s", len(dateList), req.StartDate, req.EndDate)511 reply.ResultCode = ss_err.ERR_PARAM512 return nil513 }514 switch req.Type {515 case ReStatisticTypeServicerCheckList: // 生成服务商对账列表516 servicerCheckList := &cron.ServicerCheckList{cron.CronBase{LogCat: "重新统计服务商对账列表:"}}517 go func() {518 for _, date := range dateList {519 servicerCheckList.HandleByDate(date)520 }521 }()522 //case ReStatisticTypeServicerCount: // 生成服务商对账总计523 //servicerCount := &cron.ServicerCount{cron.CronBase{LogCat: "重新统计服务商对账总计:"}}524 //go func() {525 // for _, date := range dateList {526 // servicerCount.HandleByDate(date)527 // }528 //}()529 case ReStatisticTypeUserWithdraw: // 用户提现530 withdrawCount := &cron.WithdrawCount{cron.CronBase{LogCat: "重新统计用户提现数据:"}}531 go func() {532 for _, date := range dateList {533 withdrawCount.HandleByDate(date)534 }535 }()536 case ReStatisticTypeUserRecharge: // 用户充值537 saveCount := &cron.SaveCount{cron.CronBase{LogCat: "重新统计用户充值数据:"}}538 go func() {539 for _, date := range dateList {540 saveCount.HandleByDate(date)541 }542 }()543 case ReStatisticTypeUserTransfer: // 用户转账544 transferCount := &cron.TransferCount{cron.CronBase{LogCat: "重新统计用户转账数据:"}}545 go func() {546 for _, date := range dateList {547 transferCount.HandleByDate(date)548 }549 }()550 case ReStatisticTypeUserExchange: // 用户兑换551 exchangeCount := &cron.ExchangeCount{cron.CronBase{LogCat: "重新统计用户兑换数据:"}}552 go func() {553 for _, date := range dateList {554 exchangeCount.HandleByDate(date)555 }556 }()557 case ReStatisticTypeDate: // 按天统计558 regCount := &cron.RegCount{cron.CronBase{LogCat: "重新统计用户注册和服务商注册的数据:"}}559 go func() {560 for _, date := range dateList {561 regCount.HandleByDate(date)562 }563 }()564 default:565 ss_log.Error("参数错误:类型不支持,Type:%s", req.Type)566 reply.ResultCode = ss_err.ERR_PARAM567 return nil568 }569 reply.ResultCode = ss_err.ERR_SUCCESS570 return nil571}572// 获取统计数据-用户资金总留存-用来展示统计图表573func (*CustHandler) GetStatisticUserMoney(ctx context.Context, req *go_micro_srv_cust.GetStatisticUserMoneyRequest, reply *go_micro_srv_cust.GetStatisticUserMoneyReply) error {574 // 查询统计数据575 list, err := dao.StatisticUserMoneyDaoInst.GetStatisticUserMoneyTime(req.StartTime, req.EndTime)576 if err != nil {577 ss_log.Error("查询用户兑换统计数据失败,err:%v,StartDate:%s,EndDate:%s", err, req.StartTime, req.EndTime)578 reply.ResultCode = ss_err.ERR_SYS_DB_GET579 return nil580 }581 // 生成时间范围582 timeList, err := ss_time.GetTimeRange("2006/01/02 15:04:05", req.StartTime, req.EndTime)583 if err != nil {584 ss_log.Error("获取时间范围slice失败,err:%v,format:%s,StartDate:%s,EndDate:%s", err, "2006/01/02 15:04:05", req.StartTime, req.EndTime)585 reply.ResultCode = ss_err.ERR_PARAM586 return nil587 }588 dateLen := len(timeList)589 reply.TimeList = timeList590 reply.UsdBalanceList = make([]int64, dateLen)591 reply.KhrBalanceList = make([]int64, dateLen)592 reply.UsdFrozenBalanceList = make([]int64, dateLen)593 reply.KhrFrozenBalanceList = make([]int64, dateLen)594 // 以生成的日期为准去组织数据595 for i, time := range reply.TimeList {596 for _, v := range list {597 if time == v.CreateTime {598 reply.UsdBalanceList[i] = v.UserUseBalance...

Full Screen

Full Screen

tracksworker_test.go

Source:tracksworker_test.go Github

copy

Full Screen

...169 startDate := time.Now()170 endDate := startDate.AddDate(0, 0, 1)171 countedTracks.Station = "station-A"172 countedTracks.StartDate = startDate173 countedTracks.EndDate = endDate174 var tests = []struct {175 worker TracksWorker176 startDate time.Time177 endDate time.Time178 expectedResult model.CountedTracks179 expectedErr bool180 }{181 {182 TracksWorker{MockTrackRecordDAO{}, "station-A"},183 startDate,184 endDate,185 countedTracks,186 false,187 },188 {189 TracksWorker{MockTrackRecordDAO{}, "notracksstation"},190 startDate,191 endDate,192 model.CountedTracks{193 "notracksstation",194 startDate,195 endDate,196 []model.CountedTrack{},197 },198 false,199 },200 {201 TracksWorker{MockTrackRecordDAO{}, "errorstation"},202 endDate,203 startDate,204 model.CountedTracks{},205 true,206 },207 }208 for _, test := range tests {209 result, err := test.worker.TopTracks(test.startDate, test.endDate)210 if (err != nil) != test.expectedErr {211 t.Errorf("(%q).TopTracks(%v, %v): got err (%v), expected err: %v",212 test.worker, test.startDate, test.endDate, err, test.expectedErr)213 continue214 }215 if err != nil {216 // the following tests require a valid result,217 // continue with next test if result was created along with an error218 continue219 }220 if result.StartDate != test.expectedResult.StartDate ||221 result.EndDate != test.expectedResult.EndDate {222 t.Errorf("(%q).TopTracks(%v, %v): got result startdate: %v / enddate: %v",223 test.worker, test.startDate, test.endDate, result.StartDate, result.EndDate)224 }225 if len(result.CountedTracks) != len(test.expectedResult.CountedTracks) {226 t.Errorf("(%q).TopTracks(%v, %v): got len of result (%q), expected (%q)",227 test.worker, test.startDate, test.endDate, len(result.CountedTracks),228 len(test.expectedResult.CountedTracks))229 continue230 }231 for i, expectedCountedTrack := range test.expectedResult.CountedTracks {232 if !reflect.DeepEqual(result.CountedTracks[i], expectedCountedTrack) {233 t.Errorf("(%q).TopTracks(%v, %v): got result (%q), expected (%q)",234 test.worker, test.startDate, test.endDate, result, test.expectedResult)235 }236 }237 }238}239var countedTracksWithMoreThanTopThree = model.CountedTracks{240 "test", // to be defined in the specific tests241 time.Now(), // to be defined in the specific tests242 time.Now(), // to be defined in the specific tests243 []model.CountedTrack{244 {5, model.Track{"RHCP", "The Adventures Of Rain Dance Maggie"}},245 {3, model.Track{"RHCP", "Dani California"}},246 {2, model.Track{"Cardi B", "I Like It"}},247 },248}249var countedTracksWithMoreThanTopThreeAndDuplicatedCounters = model.CountedTracks{250 "test", // to be defined in the specific tests251 time.Now(), // to be defined in the specific tests252 time.Now(), // to be defined in the specific tests253 []model.CountedTrack{254 {5, model.Track{"RHCP", "The Adventures Of Rain Dance Maggie"}},255 {5, model.Track{"RHCP", "Dani California"}},256 {2, model.Track{"Cardi B", "I Like It"}},257 {1, model.Track{"MØ", "Final Song"}},258 {1, model.Track{"Jonas Blue, Jack & Jack", "Rise"}},259 },260}261var countedTracksWithDuplicatedCountersOnly = model.CountedTracks{262 "test", // to be defined in the specific tests263 time.Now(), // to be defined in the specific tests264 time.Now(), // to be defined in the specific tests265 []model.CountedTrack{266 {1, model.Track{"RHCP", "The Adventures Of Rain Dance Maggie"}},267 {1, model.Track{"RHCP", "Dani California"}},268 {1, model.Track{"Cardi B", "I Like It"}},269 {1, model.Track{"MØ", "Final Song"}},270 {1, model.Track{"Jonas Blue, Jack & Jack", "Rise"}},271 },272}273func TestTracksWorker_TopTracksLimited(t *testing.T) {274 startDate, endDate := time.Now(), time.Now().AddDate(0, 0, 1)275 countedTracksWithMoreThanTopThree.StartDate = startDate276 countedTracksWithMoreThanTopThree.EndDate = endDate277 countedTracksWithMoreThanTopThreeAndDuplicatedCounters.StartDate = startDate278 countedTracksWithMoreThanTopThreeAndDuplicatedCounters.EndDate = endDate279 countedTracksWithDuplicatedCountersOnly.StartDate = startDate280 countedTracksWithDuplicatedCountersOnly.EndDate = endDate281 var tests = []struct {282 worker TracksWorker283 expectedResult model.CountedTracks284 expectedErr bool285 }{286 {287 TracksWorker{MockTrackRecordDAOLimitTracks{}, "withMoreThanTopThree"},288 countedTracksWithMoreThanTopThree,289 false,290 },291 {292 TracksWorker{MockTrackRecordDAOLimitTracks{}, "withMoreThanTopThreeAndDuplicatedCounters"},293 countedTracksWithMoreThanTopThreeAndDuplicatedCounters,294 false,295 },296 {297 TracksWorker{MockTrackRecordDAOLimitTracks{}, "withDuplicatedCountersOnly"},298 countedTracksWithDuplicatedCountersOnly,299 false,300 },301 }302 for _, test := range tests {303 result, err := test.worker.TopTracks(startDate, endDate)304 if (err != nil) != test.expectedErr {305 t.Errorf("(%q).TopTracks(%v, %v): got err (%v), expected err: %v",306 test.worker, startDate, endDate, err, test.expectedErr)307 continue308 }309 if err != nil {310 // the following tests require a valid result,311 // continue with next test if result was created along with an error312 continue313 }314 if result.StartDate != test.expectedResult.StartDate ||315 result.EndDate != test.expectedResult.EndDate {316 t.Errorf("(%q).TopTracks(%v, %v): got result startdate: %v / enddate: %v",317 test.worker, startDate, endDate, result.StartDate, result.EndDate)318 }319 if len(result.CountedTracks) != len(test.expectedResult.CountedTracks) {320 t.Errorf("(%q).TopTracks(%v, %v): got len of result (%q), expected (%q)",321 test.worker, startDate, endDate, len(result.CountedTracks),322 len(test.expectedResult.CountedTracks))323 continue324 }325 expectedNumberOfTracksPerCounter := make(map[int]int)326 for _, expectedTrack := range test.expectedResult.CountedTracks {327 expectedNumberOfTracksPerCounter[expectedTrack.Counter]++328 }329 gotNumberOfTracksPerCounter := make(map[int]int)330 for _, gotTrack := range result.CountedTracks {331 gotNumberOfTracksPerCounter[gotTrack.Counter]++332 }333 // just check if the number of tracks per counter value are equal334 if !reflect.DeepEqual(expectedNumberOfTracksPerCounter, gotNumberOfTracksPerCounter) {335 t.Errorf("(%q).TopTracks(%v, %v): got number of track per counter: (%q), expected (%q)",336 test.worker, startDate, endDate, gotNumberOfTracksPerCounter, expectedNumberOfTracksPerCounter)337 }338 }339}340func TestTracksWorker_AllTracks(t *testing.T) {341 startDate := time.Now()342 endDate := startDate.AddDate(0, 0, 1)343 tracks.StartDate = startDate344 tracks.EndDate = endDate345 var tests = []struct {346 worker TracksWorker347 startDate time.Time348 endDate time.Time349 expectedResult model.Tracks350 expectedErr bool351 }{352 {353 TracksWorker{MockTrackRecordDAO{}, "station-A"},354 startDate,355 endDate,356 tracks,357 false,358 },359 {360 TracksWorker{MockTrackRecordDAO{}, "notracksstation"},361 startDate,362 endDate,363 model.Tracks{364 "notracksstation",365 startDate,366 endDate,367 []model.Track{},368 },369 false,370 },371 {372 TracksWorker{MockTrackRecordDAO{}, "errorstation"},373 endDate,374 startDate,375 tracks,376 true,377 },378 }379 for _, test := range tests {380 result, err := test.worker.AllTracks(test.startDate, test.endDate)381 if (err != nil) != test.expectedErr {382 t.Errorf("(%q).AllTracks(%v, %v): got err (%v), expected err: %v",383 test.worker, test.startDate, test.endDate, err, test.expectedErr)384 continue385 }386 if err != nil {387 // the following tests require a valid result,388 // continue with next test if result was created along with an error389 continue390 }391 if result.StartDate != test.expectedResult.StartDate ||392 result.EndDate != test.expectedResult.EndDate {393 t.Errorf("(%q).AllTracks(%v, %v): got result startdate: %v / enddate: %v",394 test.worker, test.startDate, test.endDate, result.StartDate, result.EndDate)395 }396 if len(result.Tracks) != len(test.expectedResult.Tracks) {397 t.Errorf("(%q).AllTracks(%v, %v): got result (%q), expected (%q)",398 test.worker, test.startDate, test.endDate, result, test.expectedResult)399 }400 for _, track := range test.expectedResult.Tracks {401 match := false402 for _, resultTrack := range result.Tracks {403 if resultTrack == track {404 match = true405 break406 }407 }408 if !match {...

Full Screen

Full Screen

searchrequestworker_test.go

Source:searchrequestworker_test.go Github

copy

Full Screen

...89func TestSearchWorker_Search(t *testing.T) {90 startDate := time.Now()91 endDate := startDate.AddDate(0, 0, 1)92 matchedTracks0.StartDate = startDate93 matchedTracks0.EndDate = endDate94 matchedTracks1.StartDate = startDate95 matchedTracks1.EndDate = endDate96 matchedTracks2.StartDate = startDate97 matchedTracks2.EndDate = endDate98 matchedTracks3.StartDate = startDate99 matchedTracks3.EndDate = endDate100 var tests = []struct {101 worker SearchWorker102 startDate time.Time103 endDate time.Time104 expectedResult model.MatchedTracks105 expectedErr bool106 }{107 {108 SearchWorker{MockTrackRecordDAO{}, []string{"californication"}},109 startDate,110 endDate,111 matchedTracks0,112 false,113 },114 {115 SearchWorker{MockTrackRecordDAO{}, []string{"cali"}},116 startDate,117 endDate,118 matchedTracks1,119 false,120 },121 {122 SearchWorker{MockTrackRecordDAO{}, []string{"maggie", "rhcp"}},123 startDate,124 endDate,125 matchedTracks2,126 false,127 },128 {129 SearchWorker{MockTrackRecordDAO{}, []string{"ø"}},130 startDate,131 endDate,132 matchedTracks3,133 false,134 },135 {136 SearchWorker{MockTrackRecordDAO{}, []string{"no", "tracks", "query"}},137 startDate,138 endDate,139 model.MatchedTracks{140 startDate,141 endDate,142 []model.MatchedTrack{},143 },144 false,145 },146 {147 SearchWorker{MockTrackRecordDAO{}, []string{""}},148 endDate,149 startDate,150 model.MatchedTracks{151 startDate,152 endDate,153 []model.MatchedTrack{},154 },155 true,156 },157 }158 for _, test := range tests {159 result, err := test.worker.Search(test.startDate, test.endDate)160 if (err != nil) != test.expectedErr {161 t.Errorf("(%q).Search(%v, %v): got err (%v), expected err: %v",162 test.worker, test.startDate, test.endDate, err, test.expectedErr)163 continue164 }165 if err != nil {166 // the following tests require a valid result,167 // continue with next test if result was created along with an error168 continue169 }170 if result.StartDate != test.expectedResult.StartDate ||171 result.EndDate != test.expectedResult.EndDate {172 t.Errorf("(%q).Search(%v, %v): got result startdate: %v / enddate: %v",173 test.worker, test.startDate, test.endDate, result.StartDate, result.EndDate)174 }175 if len(result.MatchedTracks) != len(test.expectedResult.MatchedTracks) {176 t.Errorf("(%q).Search(%v, %v): got result length (%d), expected (%d)",177 test.worker, test.startDate, test.endDate, len(result.MatchedTracks),178 len(test.expectedResult.MatchedTracks))179 }180 for _, expectedMatchedTrack := range test.expectedResult.MatchedTracks {181 match := false182 for _, resultTrack := range result.MatchedTracks {183 if reflect.DeepEqual(resultTrack, expectedMatchedTrack) {184 match = true185 break186 }187 }...

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "time"3type Result struct {4}5func (r Result) EndDate() time.Time {6 return r.StartDate.Add(1 * time.Hour)7}8func main() {9 r := Result{StartDate: time.Now()}10 fmt.Println(r.EndDate())11}12import "fmt"13import "time"14type Result struct {15}16func (r Result) StartDate() time.Time {17 return r.StartDate.Add(-1 * time.Hour)18}19func main() {20 r := Result{StartDate: time.Now()}21 fmt.Println(r.StartDate())22}

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import "fmt"2import "time"3type result struct {4}5func main() {6r := result{}7r.StartDate = time.Now()8r.EndDate = r.StartDate.AddDate(0, 0, 1)9fmt.Println(r.EndDate)10}11The AddDate() method accepts three arguments:12The AddDate() method is used to add a specified number of years, months, and days to the time.Time type value. The AddDate() method accepts three arguments:13The AddDate() method is used to add a specified number of years, months, and days to the time.Time type value. The AddDate() method accepts three arguments:14The AddDate() method is used to add a specified number of years, months, and days to the time.Time type value. The AddDate() method accepts three arguments:15The AddDate() method is used to add a specified number of years, months, and days to the time.Time type value. The AddDate() method accepts three arguments:16The AddDate() method is used to add a specified number of years, months, and days to the time.Time type value. The AddDate() method accepts three arguments:17The AddDate() method is used to add a specified number of years, months, and days to the time.Time type value. The AddDate() method accepts three arguments:

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 result := Result{}4 result.StartDate = time.Now()5 result.EndDate = time.Now()6 fmt.Println("Start Date: ", result.StartDate)7 fmt.Println("End Date: ", result.EndDate)8}

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4}5import (6func main() {7 fmt.Println("Hello, playground")8}9import (10func main() {11 fmt.Println("Hello, playground")12}13import (14func main() {15 fmt.Println("Hello, playground")16}17import (18func main() {19 fmt.Println("Hello, playground")20}21import (22func main() {23 fmt.Println("Hello, playground")24}25import (26func main() {27 fmt.Println("Hello, playground")28}29import (30func main() {31 fmt.Println("Hello, playground")32}33import (34func main() {35 fmt.Println("Hello, playground")36}37import (38func main() {39 fmt.Println("Hello, playground")40}41import (42func main() {43 fmt.Println("Hello, playground")44}45import (46func main() {47 fmt.Println("Hello, playground")48}49import

Full Screen

Full Screen

EndDate

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 sDate, _ := time.Parse(layout, startDate)4 eDate, _ := time.Parse(layout, endDate)5 result := Result{}6 result.SetStartDate(sDate)7 result.SetEndDate(eDate)8 fmt.Println(result.EndDate())9}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful