huangjiajun 1 周之前
父節點
當前提交
ee14241a82
共有 1 個文件被更改,包括 31 次插入26 次删除
  1. +31
    -26
      rule/consume_integral_settlement.go

+ 31
- 26
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


Loading…
取消
儲存