huangjiajun 2 months ago
parent
commit
06b056bf28
1 changed files with 29 additions and 24 deletions
  1. +29
    -24
      rule/consume_integral_settlement.go

+ 29
- 24
rule/consume_integral_settlement.go View File

@@ -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, MAX(stop_date) as max_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, MAX(stop_date) as max_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))
@@ -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


Loading…
Cancel
Save