Browse Source

更新

master
huangjiajun 1 year ago
parent
commit
72b3822282
1 changed files with 29 additions and 25 deletions
  1. +29
    -25
      rule/consume_integral_settlement.go

+ 29
- 25
rule/consume_integral_settlement.go View File

@@ -87,50 +87,55 @@ func DailySettlementBlockConsumeIntegral(engine *xorm.Engine, mid string, isTask
startAt := time.Now().Add(time.Duration(subsidyBase.ConsumptionDay) * -24 * time.Hour).Format("2006-01-02") //起始时间 startAt := time.Now().Add(time.Duration(subsidyBase.ConsumptionDay) * -24 * time.Hour).Format("2006-01-02") //起始时间
var subsidyWithUserForConsumeList []model.SubsidyWithUser var subsidyWithUserForConsumeList []model.SubsidyWithUser
hasConsumeTotal, err := session.Where("date <= ?", startAt).And("kind = ? and is_can_subsidy=?", 1, 1).FindAndCount(&subsidyWithUserForConsumeList) hasConsumeTotal, err := session.Where("date <= ?", startAt).And("kind = ? and is_can_subsidy=?", 1, 1).FindAndCount(&subsidyWithUserForConsumeList)
if err != nil {
return
}
consumeValue, err := calcNowEverydayConsumeIntegral(subsidyBase, hasConsumeTotal)
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
return err
}


for _, v := range subsidyWithUserForConsumeList {
consumeValueTotal = consumeValueTotal.Add(decimal.NewFromFloat(consumeValue))
err1 := DealUserConsumeIntegral(session, &v, consumeValue, mid)
if err1 != nil {
return
}
if hasConsumeTotal > 0 {
consumeValue, err := calcNowEverydayConsumeIntegral(subsidyBase, hasConsumeTotal)
if err != nil {
_ = session.Rollback() _ = session.Rollback()
return err1
return err
} }
}


for _, v := range subsidyWithUserForConsumeList {
consumeValueTotal = consumeValueTotal.Add(decimal.NewFromFloat(consumeValue))
err1 := DealUserConsumeIntegral(session, &v, consumeValue, mid)
if err1 != nil {
_ = session.Rollback()
return err1
}
}
}
//2、统计当前拥有多少份体验补贴 //2、统计当前拥有多少份体验补贴
var subsidyWithUserForExperienceList []model.SubsidyWithUser var subsidyWithUserForExperienceList []model.SubsidyWithUser
hasExperienceTotal, err := session.Where("date <= ?", startAt).And("kind = ? and is_can_subsidy=?", 2, 1).FindAndCount(&subsidyWithUserForExperienceList) hasExperienceTotal, err := session.Where("date <= ?", startAt).And("kind = ? and is_can_subsidy=?", 2, 1).FindAndCount(&subsidyWithUserForExperienceList)
if err != nil {
return
}
experienceValue, err := calcNowEverydayExperienceIntegral(subsidyBase, hasExperienceTotal)
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
return err
return
} }
for _, v := range subsidyWithUserForConsumeList {
experienceValueTotal = experienceValueTotal.Add(decimal.NewFromFloat(experienceValue))
err1 := DealUserExperienceIntegral(session, &v, experienceValue, mid)
if err1 != nil {
if hasExperienceTotal > 0 {
experienceValue, err := calcNowEverydayExperienceIntegral(subsidyBase, hasExperienceTotal)
if err != nil {
_ = session.Rollback() _ = session.Rollback()
return err1
return err
}
for _, v := range subsidyWithUserForConsumeList {
experienceValueTotal = experienceValueTotal.Add(decimal.NewFromFloat(experienceValue))
err1 := DealUserExperienceIntegral(session, &v, experienceValue, mid)
if err1 != nil {
_ = session.Rollback()
return err1
}
} }
} }

//3、修改 subsidy_base 中 consumption_money、experience_money //3、修改 subsidy_base 中 consumption_money、experience_money
consumeTotal, _ := consumeValueTotal.Float64() consumeTotal, _ := consumeValueTotal.Float64()
experienceTotal, _ := experienceValueTotal.Float64() experienceTotal, _ := experienceValueTotal.Float64()
subsidyBase.ConsumptionTotalMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ConsumptionTotalMoney) - consumeTotal) subsidyBase.ConsumptionTotalMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ConsumptionTotalMoney) - consumeTotal)
subsidyBase.ExperienceTotalMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ExperienceTotalMoney) - experienceTotal) subsidyBase.ExperienceTotalMoney = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(subsidyBase.ExperienceTotalMoney) - experienceTotal)
updateAffected, err := db.SubsidyBaseUpdate(session, subsidyBase.Id, subsidyBase, "consumption_money", "experience_money")
updateAffected, err := db.SubsidyBaseUpdate(session, subsidyBase.Id, subsidyBase, "consumption_total_money", "experience_total_money")
if err != nil { if err != nil {
_ = session.Rollback() _ = session.Rollback()
return return
@@ -302,5 +307,4 @@ func DealUserExperienceIntegral(session *xorm.Session, subsidyWithUser *model.Su
} }
return nil return nil


return nil
} }

Loading…
Cancel
Save