Best Testkube code snippet using result.StartDate
statistic_handler.go
Source:statistic_handler.go
...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...
transactionout.go
Source:transactionout.go
1package daily23import (4 "context"5 "errors"6 "go-api-report2/ent"7 "go-api-report2/ent/consumer"8 "go-api-report2/model"9 "time"10)1112func (reportService DailyService) GetAdjustFromWallet(date string) (model.AdjustFromWallet, error) {13 var result model.AdjustFromWallet14 if date == "" {15 return result, errors.New("Date is required")16 }1718 startDate, err := time.Parse(timeCustomLayout, date)19 if err != nil {20 return result, err21 }2223 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)2425 var restotal []model.AdjustFromWallet26 err = reportService.connection.Consumer.Query().27 Where(28 consumer.DateTimeGTE(startDate),29 consumer.DateTimeLTE(endDate),30 consumer.TransactionType("TRANSFER"),31 consumer.PaymentChannel("CLOSELOOP"),32 consumer.PaymentType("ADJUST_WALLET_Out"),33 ).34 GroupBy(consumer.FieldPaymentChannel).35 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).36 Scan(context.Background(), &restotal)37 if err != nil {38 return result, err39 }4041 if len(restotal) == 0 {42 result.SumAdjustFromWalletTranOut = 043 result.CountAdjustFromWalletTranOut = 044 return result, nil45 }4647 result.SumAdjustFromWalletTranOut = restotal[0].Sum48 result.CountAdjustFromWalletTranOut = restotal[0].Count49 return result, nil50}5152func (reportService DailyService) GetPromptPayOutOtherBank(date string) (model.PromptPayOutOtherBank, error) {53 var result model.PromptPayOutOtherBank54 if date == "" {55 return result, errors.New("Date is required")56 }5758 startDate, err := time.Parse(timeCustomLayout, date)59 if err != nil {60 return result, err61 }6263 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)6465 var restotal []model.PromptPayOutOtherBank66 err = reportService.connection.Consumer.Query().67 Where(68 consumer.DateTimeGTE(startDate),69 consumer.DateTimeLTE(endDate),70 consumer.TransactionType("TRANSFER"),71 consumer.PaymentChannel("PROMPTPAY"),72 consumer.PaymentType("PROMPTPAY29_CASH_OUT"),73 consumer.BankCodeNEQ("071"),74 ).75 GroupBy(consumer.FieldPaymentType).76 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).77 Scan(context.Background(), &restotal)78 if err != nil {79 return result, err80 }8182 if len(restotal) == 0 {83 result.SumPromptPayOutOtherBankTranOut = 084 result.CountPromptPayOutOtherBankTranOut = 085 return result, nil86 }8788 result.SumPromptPayOutOtherBankTranOut = restotal[0].Sum89 result.CountPromptPayOutOtherBankTranOut = restotal[0].Count90 return result, nil91}9293func (reportService DailyService) GetPromptPayOutTCRB(date string) (model.PromptPayOutTCRB, error) {94 var result model.PromptPayOutTCRB95 if date == "" {96 return result, errors.New("Date is required")97 }9899 startDate, err := time.Parse(timeCustomLayout, date)100 if err != nil {101 return result, err102 }103104 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)105106 var restotal []model.PromptPayOutTCRB107 err = reportService.connection.Consumer.Query().108 Where(109 consumer.DateTimeGTE(startDate),110 consumer.DateTimeLTE(endDate),111 consumer.TransactionType("TRANSFER"),112 consumer.PaymentChannel("PROMPTPAY"),113 consumer.PaymentType("PROMPTPAY29_CASH_OUT"),114 consumer.BankCodeEQ("071"),115 ).116 GroupBy(consumer.FieldPaymentType).117 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).118 Scan(context.Background(), &restotal)119 if err != nil {120 return result, err121 }122123 if len(restotal) == 0 {124 result.SumPromptPayOutTCRBTranOut = 0125 result.CountPromptPayOutTCRBTranOut = 0126 return result, nil127 }128129 result.SumPromptPayOutTCRBTranOut = restotal[0].Sum130 result.CountPromptPayOutTCRBTranOut = restotal[0].Count131 return result, nil132}133134func (reportService DailyService) GetTcrbBillPayment(date string) (model.TcrbBillPayment, error) {135 var result model.TcrbBillPayment136 if date == "" {137 return result, errors.New("Date is required")138 }139140 startDate, err := time.Parse(timeCustomLayout, date)141 if err != nil {142 return result, err143 }144145 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)146147 var restotal []model.TcrbBillPayment148 err = reportService.connection.Consumer.Query().149 Where(150 consumer.DateTimeGTE(startDate),151 consumer.DateTimeLTE(endDate),152 consumer.TransactionType("TRANSFER"),153 consumer.PaymentChannel("CLOSELOOP"),154 consumer.PaymentType("TCRB_LOAN"),155 ).156 GroupBy(consumer.FieldPaymentType).157 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).158 Scan(context.Background(), &restotal)159 if err != nil {160 return result, err161 }162163 if len(restotal) == 0 {164 result.SumTcrbBillPaymentTranOut = 0165 result.CountTcrbBillPaymentTranOut = 0166 return result, nil167 }168169 result.SumTcrbBillPaymentTranOut = restotal[0].Sum170 result.CountTcrbBillPaymentTranOut = restotal[0].Count171 return result, nil172}173174func (reportService DailyService) GetTransferToBankAccountTxn(date string) (model.TransferToBankAccountTxn, error) {175 var result model.TransferToBankAccountTxn176 if date == "" {177 return result, errors.New("Date is required")178 }179180 startDate, err := time.Parse(timeCustomLayout, date)181 if err != nil {182 return result, err183 }184185 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)186187 var restotal []model.TransferToBankAccountTxn188 err = reportService.connection.Consumer.Query().189 Where(190 consumer.DateTimeGTE(startDate),191 consumer.DateTimeLTE(endDate),192 consumer.PaymentType("TCRB_BULK_PAYMENT"),193 ).194 GroupBy(consumer.FieldPaymentType).195 Aggregate(ent.Sum(consumer.FieldAmount), ent.Count()).196 Scan(context.Background(), &restotal)197 if err != nil {198 return result, err199 }200201 if len(restotal) == 0 {202 result.SumTransferToBankAccountTxnTranOut = 0203 result.CountTransferToBankAccountTxnTranOut = 0204 return result, nil205 }206207 result.SumTransferToBankAccountTxnTranOut = restotal[0].Sum208 result.CountTransferToBankAccountTxnTranOut = restotal[0].Count209 return result, nil210}211212func (reportService DailyService) GetTransferToBankAccountFee(date string) (model.TransferToBankAccountFee, error) {213 var result model.TransferToBankAccountFee214 if date == "" {215 return result, errors.New("Date is required")216 }217218 startDate, err := time.Parse(timeCustomLayout, date)219 if err != nil {220 return result, err221 }222223 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)224225 var restotal []model.TransferToBankAccountFee226 err = reportService.connection.Consumer.Query().227 Where(228 consumer.DateTimeGTE(startDate),229 consumer.DateTimeLTE(endDate),230 consumer.PaymentType("TCRB_BULK_PAYMENT"),231 ).232 GroupBy(consumer.FieldPaymentType).233 Aggregate(ent.Sum(consumer.FieldFee), ent.Count()).234 Scan(context.Background(), &restotal)235 if err != nil {236 return result, err237 }238239 if len(restotal) == 0 {240 result.SumTransferToBankAccountFeeTranOut = 0241 result.CountTransferToBankAccountFeeTranOut = 0242 return result, nil243 }244245 result.SumTransferToBankAccountFeeTranOut = restotal[0].Sum246 result.CountTransferToBankAccountFeeTranOut = restotal[0].Count247 return result, nil248}249250func (reportService DailyService) GetOnlineBillPayment(date string) (model.OnlineBillPayment, error) {251 var result model.OnlineBillPayment252 if date == "" {253 return result, errors.New("Date is required")254 }255256 startDate, err := time.Parse(timeCustomLayout, date)257 if err != nil {258 return result, err259 }260261 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)262263 var restotal []model.OnlineBillPayment264 err = reportService.connection.Consumer.Query().265 Where(266 consumer.DateTimeGTE(startDate),267 consumer.DateTimeLTE(endDate),268 consumer.TransactionType("REPAYMENT"),269 consumer.PaymentChannel("LOAN_DIRECT_TCRB"),270 consumer.PaymentType("TCRB_ONLINE_BILL"),271 ).272 GroupBy(consumer.FieldPaymentType).273 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).274 Scan(context.Background(), &restotal)275 if err != nil {276 return result, err277 }278279 if len(restotal) == 0 {280 result.SumOnlineBillPaymentTranOut = 0281 result.CountOnlineBillPaymentTranOut = 0282 return result, nil283 }284285 result.SumOnlineBillPaymentTranOut = restotal[0].Sum286 result.CountOnlineBillPaymentTranOut = restotal[0].Count287 return result, nil288}289290func (reportService DailyService) GetPromptpayOutTagThirty(date string) (model.PromptpayOutTagThirty, error) {291 var result model.PromptpayOutTagThirty292 if date == "" {293 return result, errors.New("Date is required")294 }295296 startDate, err := time.Parse(timeCustomLayout, date)297 if err != nil {298 return result, err299 }300301 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)302303 var restotal []model.PromptpayOutTagThirty304 err = reportService.connection.Consumer.Query().305 Where(306 consumer.DateTimeGTE(startDate),307 consumer.DateTimeLTE(endDate),308 consumer.TransactionType("PAYMENT"),309 consumer.PaymentChannel("PROMPTPAY"),310 consumer.PaymentType("CASH_OUT_PROMPTPAY_TAG30_OFF_US"),311 ).312 GroupBy(consumer.FieldPaymentType).313 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).314 Scan(context.Background(), &restotal)315 if err != nil {316 return result, err317 }318319 if len(restotal) == 0 {320 result.SumPromptpayOutTagThirtyTranOut = 0321 result.CountPromptpayOutTagThirtyTranOut = 0322 return result, nil323 }324325 result.SumPromptpayOutTagThirtyTranOut = restotal[0].Sum326 result.CountPromptpayOutTagThirtyTranOut = restotal[0].Count327 return result, nil328}329330func (reportService DailyService) GetRtpTCRBLoanTranOut(date string) (model.TCRBLoanTranOut, error) {331 var result model.TCRBLoanTranOut332 if date == "" {333 return result, errors.New("Date is required")334 }335336 startDate, err := time.Parse(timeCustomLayout, date)337 if err != nil {338 return result, err339 }340341 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)342343 var restotal []model.TCRBLoanTranOut344 err = reportService.connection.Consumer.Query().345 Where(346 consumer.DateTimeGTE(startDate),347 consumer.DateTimeLTE(endDate),348 consumer.TransactionType("TRANSFER"),349 consumer.PaymentChannel("CLOSELOOP"),350 consumer.PaymentType("RTP_TCRB_LOAN"),351 ).352 GroupBy(consumer.FieldPaymentType).353 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).354 Scan(context.Background(), &restotal)355 if err != nil {356 return result, err357 }358359 if len(restotal) == 0 {360 result.SumTCRBLoanTranOut = 0361 result.CountTCRBLoanTranOut = 0362 return result, nil363 }364365 result.SumTCRBLoanTranOut = restotal[0].Sum366 result.CountTCRBLoanTranOut = restotal[0].Count367 return result, nil368}369370func (reportService DailyService) GetRtpThaiHealthTranOut(date string) (model.ThaiHealthTranOut, error) {371 var result model.ThaiHealthTranOut372 if date == "" {373 return result, errors.New("Date is required")374 }375376 startDate, err := time.Parse(timeCustomLayout, date)377 if err != nil {378 return result, err379 }380381 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)382383 var restotal []model.ThaiHealthTranOut384 err = reportService.connection.Consumer.Query().385 Where(386 consumer.DateTimeGTE(startDate),387 consumer.DateTimeLTE(endDate),388 consumer.ToAccount("105011100200002"),389 ).390 GroupBy(consumer.FieldPaymentType).391 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).392 Scan(context.Background(), &restotal)393 if err != nil {394 return result, err395 }396397 if len(restotal) == 0 {398 result.SumThaiHealthTranOut = 0399 result.CountThaiHealthTranOut = 0400 return result, nil401 }402403 result.SumThaiHealthTranOut = restotal[0].Sum404 result.CountThaiHealthTranOut = restotal[0].Count405 return result, nil406}407408func (reportService DailyService) GetRtpThaiPaiboonTranOut(date string) (model.ThaiPaiboonTranOut, error) {409 var result model.ThaiPaiboonTranOut410 if date == "" {411 return result, errors.New("Date is required")412 }413414 startDate, err := time.Parse(timeCustomLayout, date)415 if err != nil {416 return result, err417 }418419 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)420421 var restotal []model.ThaiPaiboonTranOut422 err = reportService.connection.Consumer.Query().423 Where(424 consumer.DateTimeGTE(startDate),425 consumer.DateTimeLTE(endDate),426 consumer.ToAccount("105011100200003"),427 ).428 GroupBy(consumer.FieldPaymentType).429 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).430 Scan(context.Background(), &restotal)431 if err != nil {432 return result, err433 }434435 if len(restotal) == 0 {436 result.SumThaiPaiboonTranOut = 0437 result.CountThaiPaiboonTranOut = 0438 return result, nil439 }440441 result.SumThaiPaiboonTranOut = restotal[0].Sum442 result.CountThaiPaiboonTranOut = restotal[0].Count443 return result, nil444}445446func (reportService DailyService) GetBillPayMeaTranOut(date string) (model.BillPayMeaTranOut, error) {447 var result model.BillPayMeaTranOut448449 if date == "" {450 return result, errors.New("Date is required")451 }452453 startDate, err := time.Parse(timeCustomLayout, date)454 if err != nil {455 return result, err456 }457458 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)459460 var restotal []model.BillPayMeaTranOut461 err = reportService.connection.Consumer.Query().462 Where(463 consumer.DateTimeGTE(startDate),464 consumer.DateTimeLTE(endDate),465 consumer.TransactionType("PAYMENT"),466 consumer.PaymentType("BILLPAYMENT_MEA"),467 consumer.PaymentChannel("MEA"),468 ).469 GroupBy(consumer.FieldPaymentType).470 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).471 Scan(context.Background(), &restotal)472 if err != nil {473 return result, err474 }475476 if len(restotal) == 0 {477 result.SumBillPayMeaTranOut = 0478 result.CountBillPayMeaTranOut = 0479 return result, nil480 }481482 result.SumBillPayMeaTranOut = restotal[0].Sum483 result.CountBillPayMeaTranOut = restotal[0].Count484 return result, nil485}486487func (reportService DailyService) GetBillPayPeaTranOut(date string) (model.BillPayPeaTranOut, error) {488 var result model.BillPayPeaTranOut489490 if date == "" {491 return result, errors.New(" Date is required ")492 }493494 startDate, err := time.Parse(timeCustomLayout, date)495 if err != nil {496 return result, err497 }498499 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)500501 var restotal []model.BillPayPeaTranOut502 err = reportService.connection.Consumer.Query().503 Where(504 consumer.DateTimeGTE(startDate),505 consumer.DateTimeLTE(endDate),506 consumer.TransactionType("PAYMENT"),507 consumer.PaymentType("BILLPAYMENT_PEA"),508 consumer.PaymentChannel("PEA"),509 ).510 GroupBy(consumer.FieldPaymentType).511 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).512 Scan(context.Background(), &restotal)513 if err != nil {514 return result, err515 }516517 if len(restotal) == 0 {518 result.SumBillPayPeaTranOut = 0519 result.CountBillPayPeaTranOut = 0520 return result, nil521 }522523 result.SumBillPayPeaTranOut = restotal[0].Sum524 result.CountBillPayPeaTranOut = restotal[0].Count525 return result, nil526}
...
transactionin.go
Source:transactionin.go
1package daily23import (4 "context"5 "errors"6 "go-api-report2/ent"7 "go-api-report2/ent/consumer"8 "go-api-report2/ent/merchanttransaction"9 "go-api-report2/model"10 "time"11)1213func (reportService DailyService) GetWalletToWallet(date string) (model.WalletToWallet, error) {14 var result model.WalletToWallet15 if date == "" {16 return result, errors.New("Date is required")17 }1819 startDate, err := time.Parse(timeCustomLayout, date)20 if err != nil {21 return result, err22 }23 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)2425 var restotal []model.WalletToWallet26 err = reportService.connection.Consumer.Query().27 Where(28 consumer.DateTimeGTE(startDate),29 consumer.DateTimeLTE(endDate),30 consumer.TransactionType("TRANSFER"),31 consumer.PaymentChannel("CLOSELOOP"),32 consumer.PaymentType("WALLET"),33 ).34 GroupBy(consumer.FieldPaymentChannel).35 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).36 Scan(context.Background(), &restotal)37 if err != nil {38 return result, err39 }4041 if len(restotal) == 0 {42 result.SumWalletToWallet = 043 result.CountWalletToWallet = 044 return result, nil45 }4647 result.SumWalletToWallet = restotal[0].Sum48 result.CountWalletToWallet = restotal[0].Count49 return result, nil50}5152func (reportService DailyService) GetSettleMerchantOnline(date string) (model.SettleMerchantOnline, error) {53 var result model.SettleMerchantOnline54 if date == "" {55 return result, errors.New("Date is required")56 }5758 startDate, err := time.Parse(timeCustomLayout, date)59 if err != nil {60 return result, err61 }6263 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)6465 var restotal []model.SettleMerchantOnline66 err = reportService.connection.Consumer.Query().67 Where(68 consumer.DateTimeGTE(startDate),69 consumer.DateTimeLTE(endDate),70 consumer.TransactionType("TOP_UP"),71 consumer.PaymentChannel("MERCHANT"),72 consumer.PaymentType("SETTLE_MERCHANT"),73 ).74 GroupBy(consumer.FieldPaymentChannel).75 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).76 Scan(context.Background(), &restotal)77 if err != nil {78 return result, err79 }8081 if len(restotal) == 0 { // code to check array. use len()82 result.SumSettleMerchantOnline = 083 result.CountSettleMerchantOnline = 084 return result, nil85 }8687 result.SumSettleMerchantOnline = restotal[0].Sum88 result.CountSettleMerchantOnline = restotal[0].Count89 return result, nil90}9192func (reportService DailyService) GetAdjustToWallet(date string) (model.AdjustToWallet, error) {93 var result model.AdjustToWallet94 if date == "" {95 return result, errors.New("Date is required")96 }9798 startDate, err := time.Parse(timeCustomLayout, date)99 if err != nil {100 return result, err101 }102103 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)104105 var restotal []model.AdjustToWallet106 err = reportService.connection.Consumer.Query().107 Where(108 consumer.DateTimeGTE(startDate),109 consumer.DateTimeLTE(endDate),110 consumer.TransactionType("TRANSFER"),111 consumer.PaymentChannel("CLOSELOOP"),112 consumer.PaymentType("ADJUST_WALLET_IN"),113 ).114 GroupBy(consumer.FieldPaymentChannel).115 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).116 Scan(context.Background(), &restotal)117 if err != nil {118 return result, err119 }120121 if len(restotal) == 0 {122 result.SumAdjustToWallet = 0123 result.CountAdjustToWallet = 0124 return result, nil125 }126127 result.SumAdjustToWallet = restotal[0].Sum128 result.CountAdjustToWallet = restotal[0].Count129 return result, nil130}131132func (reportService DailyService) GetPromptPayInOtherBank(date string) (model.PromptPayInOtherBank, error) {133 var result model.PromptPayInOtherBank134 if date == "" {135 return result, errors.New("Date is required")136 }137138 startDate, err := time.Parse(timeCustomLayout, date)139 if err != nil {140 return result, err141 }142143 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)144145 var restotal []model.PromptPayInOtherBank146 err = reportService.connection.Consumer.Query().147 Where(148 consumer.DateTimeGTE(startDate),149 consumer.DateTimeLTE(endDate),150 consumer.TransactionType("TOP_UP"),151 consumer.PaymentChannel("PROMPTPAY"),152 consumer.PaymentType("PROMPTPAY_IN"),153 consumer.BankCodeNEQ("071"),154 ).155 GroupBy(consumer.FieldPaymentType).156 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).157 Scan(context.Background(), &restotal)158 if err != nil {159 return result, err160 }161162 if len(restotal) == 0 {163 result.SumPromptPayInOtherBankTranIn = 0164 result.CountPromptPayInOtherBankTranIn = 0165 return result, nil166 }167168 result.SumPromptPayInOtherBankTranIn = restotal[0].Sum169 result.CountPromptPayInOtherBankTranIn = restotal[0].Count170 return result, nil171}172173func (reportService DailyService) GetPromptPayInTCRB(date string) (model.PromptPayInTCRB, error) {174 var result model.PromptPayInTCRB175 if date == "" {176 return result, errors.New("Date is required")177 }178179 startDate, err := time.Parse(timeCustomLayout, date)180 if err != nil {181 return result, err182 }183184 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)185186 var restotal []model.PromptPayInTCRB187 err = reportService.connection.Consumer.Query().188 Where(189 consumer.DateTimeGTE(startDate),190 consumer.DateTimeLTE(endDate),191 consumer.TransactionType("TOP_UP"),192 consumer.PaymentChannel("PROMPTPAY"),193 consumer.PaymentType("PROMPTPAY_IN"),194 consumer.BankCodeEQ("071"),195 ).196 GroupBy(consumer.FieldPaymentType).197 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).198 Scan(context.Background(), &restotal)199 if err != nil {200 return result, err201 }202203 if len(restotal) == 0 { // code to check array. use len()204 result.SumPromptPayInTCRBTranIn = 0205 result.CountPromptPayInTCRBTranIn = 0206 return result, nil207 }208209 result.SumPromptPayInTCRBTranIn = restotal[0].Sum210 result.CountPromptPayInTCRBTranIn = restotal[0].Count211 return result, nil212}213214func (reportService DailyService) GetPromptpayInTagThirty(date string) (model.PromptpayInTagThirty, error) {215 var result model.PromptpayInTagThirty216 if date == "" {217 return result, errors.New("Date is required")218 }219220 startDate, err := time.Parse(timeCustomLayout, date)221 if err != nil {222 return result, err223 }224225 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)226227 var restotal []model.PromptpayInTagThirty228 err = reportService.connection.MerchantTransaction.Query().229 Where(230 merchanttransaction.DateTimeGTE(startDate),231 merchanttransaction.DateTimeLTE(endDate),232 merchanttransaction.PaymentType("PROMPTPAY_TAG30_ONLINE"),233 merchanttransaction.PaymentChannel("PROMPTPAY"),234 merchanttransaction.StatusIn("SETTLE", "APPROVED"),235 ).236 GroupBy(merchanttransaction.FieldPaymentType).237 Aggregate(ent.Sum(merchanttransaction.FieldAmount), ent.Count()).238 Scan(context.Background(), &restotal)239 if err != nil {240 return result, err241 }242243 if len(restotal) == 0 { // code to check array. use len()244 result.SumPromptpayInTagThirtyTranIn = 0245 result.CountPromptpayInTagThirtyTranIn = 0246 return result, nil247 }248249 result.SumPromptpayInTagThirtyTranIn = restotal[0].Sum250 result.CountPromptpayInTagThirtyTranIn = restotal[0].Count251 return result, nil252}253254func (reportService DailyService) GetTopupLoanDisbursement(date string) (model.TopupLoanDisbursement, error) {255 var result model.TopupLoanDisbursement256 if date == "" {257 return result, errors.New("Date is required")258 }259260 startDate, err := time.Parse(timeCustomLayout, date)261 if err != nil {262 return result, err263 }264265 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)266267 var restotal []model.TopupLoanDisbursement268 err = reportService.connection.Consumer.Query().269 Where(270 consumer.DateTimeGTE(startDate),271 consumer.DateTimeLTE(endDate),272 consumer.TransactionType("TOP_UP"),273 consumer.PaymentChannel("DIRECT_TCRB"),274 consumer.PaymentType("LOAN_DISBURSE"),275 ).276 GroupBy(consumer.FieldPaymentType).277 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).278 Scan(context.Background(), &restotal)279280 if err != nil {281 return result, err282 }283284 if len(restotal) == 0 {285 result.SumTopupLoanDisbursementTranIn = 0286 result.CountTopupLoanDisbursementTranIn = 0287 return result, nil288 }289290 result.SumTopupLoanDisbursementTranIn = restotal[0].Sum291 result.CountTopupLoanDisbursementTranIn = restotal[0].Count292 return result, nil293}294295func (reportService DailyService) GetTopupDirectDebit(date string) (model.TopupDirectDebit, error) {296 var result model.TopupDirectDebit297 if date == "" {298 return result, errors.New("Date is required")299 }300301 startDate, err := time.Parse(timeCustomLayout, date)302 if err != nil {303 return result, err304 }305306 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)307308 var restotal []model.TopupDirectDebit309 err = reportService.connection.Consumer.Query().310 Where(311 consumer.DateTimeGTE(startDate),312 consumer.DateTimeLTE(endDate),313 consumer.TransactionType("TOP_UP"),314 consumer.PaymentChannel("DIRECT_DEBIT"),315 consumer.PaymentType("TCRB_DEPOSIT"),316 ).317 GroupBy(consumer.FieldPaymentType).318 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).319 Scan(context.Background(), &restotal)320 if err != nil {321 return result, err322 }323324 if len(restotal) == 0 {325 result.CountTopupDirectDebitTranIn = 0326 result.SumTopupDirectDebitTranIn = 0327 return result, nil328 }329330 result.CountTopupDirectDebitTranIn = restotal[0].Count331 result.SumTopupDirectDebitTranIn = restotal[0].Sum332 return result, nil333}334335func (reportService DailyService) GetTopupPayRoll(date string) (model.TopupPayRoll, error) {336 var result model.TopupPayRoll337 if date == "" {338 return result, errors.New("Date is required")339 }340341 startDate, err := time.Parse(timeCustomLayout, date)342 if err != nil {343 return result, err344 }345346 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)347348 var restotal []model.TopupPayRoll349 err = reportService.connection.Consumer.Query().350 Where(351 consumer.DateTimeGTE(startDate),352 consumer.DateTimeLTE(endDate),353 consumer.TransactionType("TOP_UP"),354 consumer.PaymentChannel("PAYROLL"),355 consumer.PaymentType("TCRB_PAY_ROLL"),356 ).357 GroupBy(consumer.FieldPaymentType).358 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).359 Scan(context.Background(), &restotal)360 if err != nil {361 return result, err362 }363364 if len(restotal) == 0 {365 result.SumTopupPayRollTranIn = 0366 result.CountTopupPayRollTranIn = 0367 return result, nil368 }369370 result.SumTopupPayRollTranIn = restotal[0].Sum371 result.CountTopupPayRollTranIn = restotal[0].Count372 return result, nil373}374375func (reportService DailyService) GetOnlineLoanTopup(date string) (model.OnlineLoanTopup, error) {376 var result model.OnlineLoanTopup377 if date == "" {378 return result, errors.New("Date is required")379 }380381 startDate, err := time.Parse(timeCustomLayout, date)382 if err != nil {383 return result, err384 }385386 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)387388 var restotal []model.OnlineLoanTopup389 err = reportService.connection.Consumer.Query().390 Where(391 consumer.DateTimeGTE(startDate),392 consumer.DateTimeLTE(endDate),393 consumer.TransactionType("TOP_UP"),394 consumer.PaymentChannel("LOAN_DIRECT_TCRB"),395 consumer.PaymentType("TOPUP_ONLINE"),396 ).397 GroupBy(consumer.FieldPaymentType).398 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).399 Scan(context.Background(), &restotal)400 if err != nil {401 return result, err402 }403404 if len(restotal) == 0 {405 result.SumOnlineLoanTopupTranIn = 0406 result.CountOnlineLoanTopupTranIn = 0407 return result, nil408 }409410 result.SumOnlineLoanTopupTranIn = restotal[0].Sum411 result.CountOnlineLoanTopupTranIn = restotal[0].Count412 return result, nil413}414415func (reportService DailyService) GetCashBack(date string) (model.CashBack, error) {416 var result model.CashBack417 if date == "" {418 return result, errors.New("Date is required")419 }420421 startDate, err := time.Parse(timeCustomLayout, date)422 if err != nil {423 return result, err424 }425426 endDate := startDate.Add(23 * time.Hour).Add(59 * time.Minute).Add(59 * time.Second)427428 var restotal []model.OnlineLoanTopup429 err = reportService.connection.Consumer.Query().430 Where(431 consumer.DateTimeGTE(startDate),432 consumer.DateTimeLTE(endDate),433 consumer.TransactionType("TOP_UP"),434 consumer.PaymentChannel("PROMOTION"),435 consumer.PaymentType("CASH_BACK"),436 ).437 GroupBy(consumer.FieldPaymentType).438 Aggregate(ent.Sum(consumer.FieldTotal), ent.Count()).439 Scan(context.Background(), &restotal)440 if err != nil {441 return result, err442 }443444 if len(restotal) == 0 {445 result.SumCashBackTranIn = 0446 result.CountCashBackTranIn = 0447 return result, nil448 }449450 result.SumCashBackTranIn = restotal[0].Sum451 result.CountCashBackTranIn = restotal[0].Count452 return result, nil453}
...
StartDate
Using AI Code Generation
1import (2type Result struct {3}4func (r *Result) StartDate() time.Time {5}6func main() {7 r := Result{time.Now()}8 fmt.Println(r.StartDate())9}
StartDate
Using AI Code Generation
1import (2type result struct {3}4func (r *result) StartDate() time.Time {5}6type result1 struct {7}8func main() {9 r := &result1{}10 r.startDate = time.Now()11 fmt.Println(r.StartDate())12}13import (14type result interface {15 StartDate() time.Time16}17type result1 struct {18}19func (r *result1) StartDate() time.Time {20}21func main() {22 r := &result1{}23 r.startDate = time.Now()
StartDate
Using AI Code Generation
1import (2type Result struct {3}4func main() {5 result := &Result{}6 fmt.Println(result.StartDate)7}
StartDate
Using AI Code Generation
1import (2type Result struct {3}4func main() {5 result.StartDate = time.Now()6 fmt.Println(result.StartDate)7}8import (9func main() {10 fmt.Println(time.Now())11}12import (13func main() {14 fmt.Println(time.Now())15}16import (17func main() {18 fmt.Println(time.Now())19}20import (21func main() {22 fmt.Println(time.Now())23}24import (25func main() {26 fmt.Println(time.Now())27}
StartDate
Using AI Code Generation
1import "fmt"2import "time"3func main() {4 result = Result{StartDate: time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC)}5 fmt.Println(result.StartDate())6}
StartDate
Using AI Code Generation
1import (2func main() {3 r := result.NewResult()4 r.SetName("John Doe")5 r.SetStartDate(time.Now())6 fmt.Println(r.StartDate())7}8import (9type Result struct {10}11func NewResult() *Result {12 return &Result{}13}14func (r *Result) SetName(name string) {15}16func (r *Result) SetStartDate(start time.Time) {17}18func (r *Result) StartDate() time.Time {19}20import (21func init() {22 result.NewResult()23}24func main() {25 r := result.NewResult()26 r.SetName("John Doe")27 r.SetStartDate(time.Now())28 fmt.Println(r.StartDate())29}30Recommended Posts: Go | init() Function31Go | Create a new file using os.Create()32Go | Create a new file using os.OpenFile()33Go | Create a new file using os.OpenFile() and os.O_CREATE
StartDate
Using AI Code Generation
1import "result"2func main() {3 myDate = result.StartDate()4}5func StartDate() Date {6 return Date(2019)7}8./2.go:5:9: cannot use result.StartDate() (type result.Date) as type result.Date in assignment9func StartDate() Date {10 return Date(2019)11}12import "result"13func main() {14 myDate = result.StartDate()15}16import "result"17func main() {18 myDate = result.StartDate()19}20import "result"21func main() {22 myDate = StartDate()23}24func StartDate() Date {25 return Date(2019)26}27If you have a type named Date in the same package, then you can use it without importing the result package. The Date type in the
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!