From ee14241a82bf269edd5143d8bee0508becd43aa7 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 21 Oct 2024 13:46:53 +0800 Subject: [PATCH] 1 --- rule/consume_integral_settlement.go | 57 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/rule/consume_integral_settlement.go b/rule/consume_integral_settlement.go index ab3cb80..b388e77 100644 --- a/rule/consume_integral_settlement.go +++ b/rule/consume_integral_settlement.go @@ -123,49 +123,54 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask return err, totalMap, storeTotalMap } //读出用户冻结情况 - uids := make([]int, 0) - storeUids := make([]int, 0) + uids := make([]string, 0) + storeUids := make([]string, 0) for _, v := range subsidyWithUserForConsumeList { - if zhios_order_relate_utils.InArrToInt(v.Uid, uids) == false { - uids = append(uids, v.Uid) + if zhios_order_relate_utils.InArr(zhios_order_relate_utils.IntToStr(v.Uid), uids) == false { + uids = append(uids, zhios_order_relate_utils.IntToStr(v.Uid)) } } for _, v := range subsidyWithUserForExperienceList { - if zhios_order_relate_utils.InArrToInt(v.Uid, uids) == false { - uids = append(uids, v.Uid) + if zhios_order_relate_utils.InArr(zhios_order_relate_utils.IntToStr(v.Uid), uids) == false { + uids = append(uids, zhios_order_relate_utils.IntToStr(v.Uid)) } } for _, v := range subsidyWithUserForStoreList { - if zhios_order_relate_utils.InArrToInt(v.Uid, storeUids) == false { - storeUids = append(storeUids, v.Uid) + if zhios_order_relate_utils.InArr(zhios_order_relate_utils.IntToStr(v.Uid), storeUids) == false { + storeUids = append(storeUids, zhios_order_relate_utils.IntToStr(v.Uid)) } } userStatusList := userStatus(session, uids, 0, subsidyBase) storeStatusList := userStatus(session, storeUids, 1, subsidyBase) + sql := `select uid,stop_date from subsidy_with_user_flow where uid in(%s) and kind in(1,2) order by create_at desc limit 1` + sql = fmt.Sprintf(sql, strings.Join(uids, ",")) + one, _ := db.QueryNativeStringSess(session, sql) for _, v := range uids { - sql := `select stop_date from subsidy_with_user_flow where uid=%d and kind in(1,2) order by create_at desc limit 1` - sql = fmt.Sprintf(sql, v) - one, _ := db.QueryNativeStringSess(session, sql) - if userStatusList[v]["status"] != "1" { - userStatusList[v]["date"] = time.Now().Format("2006-01-02") - if len(one) > 0 && one[0]["stop_date"] != "" { - userStatusList[v]["date"] = one[0]["stop_date"] + + if userStatusList[zhios_order_relate_utils.StrToInt(v)]["status"] != "1" { + userStatusList[zhios_order_relate_utils.StrToInt(v)]["date"] = time.Now().Format("2006-01-02") + for _, v1 := range one { + if v1["uid"] == v { + userStatusList[zhios_order_relate_utils.StrToInt(v)]["date"] = v1["stop_date"] + } } } } + storesql := `select uid,stop_date from subsidy_with_user_flow where uid in(%s) and kind=3 order by create_at desc limit 1` + storesql = fmt.Sprintf(storesql, strings.Join(uids, ",")) + storeone, _ := db.QueryNativeStringSess(session, storesql) for _, v := range storeUids { - sql := `select stop_date from subsidy_with_user_flow where uid=%d and kind=3 order by create_at desc limit 1` - sql = fmt.Sprintf(sql, v) - one, _ := db.QueryNativeStringSess(session, sql) - if storeStatusList[v]["status"] != "1" { - storeStatusList[v]["date"] = time.Now().Format("2006-01-02") - if len(one) > 0 && one[0]["stop_date"] != "" { - storeStatusList[v]["date"] = one[0]["stop_date"] + + if storeStatusList[zhios_order_relate_utils.StrToInt(v)]["status"] != "1" { + storeStatusList[zhios_order_relate_utils.StrToInt(v)]["date"] = time.Now().Format("2006-01-02") + for _, v1 := range storeone { + if v1["uid"] == v { + storeStatusList[zhios_order_relate_utils.StrToInt(v)]["date"] = v1["stop_date"] + } } } } if hasConsumeTotal > 0 { - for _, v := range subsidyWithUserForConsumeList { if v.LeaveDay > 0 && userStatusList[v.Uid]["status"] == "1" { consumeTotalMap[v.Uid] = consumeTotalMap[v.Uid].Add(decimal.NewFromFloat(consumeValue)) @@ -369,7 +374,7 @@ func Total(sess *xorm.Session, date, dayPayAmount string) error { return nil } -//计算当前消费积分价值(公式 "((资金池的金额 * 浮动比例) / 消费补贴总数) + 基础补贴") +// 计算当前消费积分价值(公式 "((资金池的金额 * 浮动比例) / 消费补贴总数) + 基础补贴") func calcNowEverydayConsumeIntegral(subsidyBase *model.SubsidyBase, hasConsumeTotal int64) (value float64, err error) { consumptionMoney, _ := decimal.NewFromString(subsidyBase.ConsumptionTotalMoney) baseSubsidyMoney, _ := decimal.NewFromString(subsidyBase.BaseSubsidyMoney) @@ -382,7 +387,7 @@ func calcNowEverydayConsumeIntegral(subsidyBase *model.SubsidyBase, hasConsumeTo return } -//计算当前体验积分价值(当前消费积分价值 * 10%) +// 计算当前体验积分价值(当前消费积分价值 * 10%) func calcNowEverydayExperienceIntegral(consumeValue float64) (value float64, err error) { value, _ = decimal.NewFromFloat(consumeValue * 0.1).RoundFloor(2).Float64() ////2、通过公式计算 "((资金池的金额 * 浮动比例) / 体验补贴总数) + 基础补贴" @@ -810,7 +815,7 @@ func DealUserStoreAmountFlow(session *xorm.Session, uid int, experienceIntegralV return nil } -func userStatus(sess *xorm.Session, uid []int, types int, base *model.SubsidyBase) map[int]map[string]string { +func userStatus(sess *xorm.Session, uid []string, types int, base *model.SubsidyBase) map[int]map[string]string { statusList := make(map[int]map[string]string) if len(uid) == 0 { return statusList