|
|
@@ -17,6 +17,54 @@ func OrderReturnMoneyRelateInsert(eg *xorm.Engine, oid int64, pvd string, create |
|
|
|
return |
|
|
|
} |
|
|
|
if isDelete { |
|
|
|
if newOrd.IsTotal == 1 { |
|
|
|
var ordRelate = make([]model.OrdListRelate, 0) |
|
|
|
eg.Where("oid=?", newOrd.OrdId).Find(&ordRelate) |
|
|
|
now := time.Unix(int64(newOrd.CreateAt), 0).Format("200601") |
|
|
|
nowDay := time.Unix(int64(newOrd.CreateAt), 0).Format("20060102") |
|
|
|
if len(ordRelate) > 0 { |
|
|
|
isDeduct := 0 |
|
|
|
for _, v := range ordRelate { |
|
|
|
if v.Amount == 0 && utils.StrToFloat64(v.AdditionalSubsidy) == 0 { |
|
|
|
continue |
|
|
|
} |
|
|
|
var userStatistics model.UserMonthAmount |
|
|
|
eg.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics) |
|
|
|
if userStatistics.Id != 0 { |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
eg.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics) |
|
|
|
} |
|
|
|
if v.CreateAt > 1711086661 { |
|
|
|
var userStatistics1 model.UserDayAmount |
|
|
|
eg.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1) |
|
|
|
if userStatistics1.Id != 0 { |
|
|
|
userStatistics1 = model.UserDayAmount{ |
|
|
|
Date: utils.StrToInt(nowDay), |
|
|
|
Uid: v.Uid, |
|
|
|
} |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) |
|
|
|
} |
|
|
|
} |
|
|
|
var userStatistics1 model.UserWaitAmount |
|
|
|
eg.Where("uid=? ", v.Uid).Get(&userStatistics1) |
|
|
|
if userStatistics1.Id != 0 { |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) |
|
|
|
} |
|
|
|
isDeduct = 1 |
|
|
|
} |
|
|
|
if isDeduct == 1 { |
|
|
|
if newOrd.State == 4 { |
|
|
|
newOrd.IsTotal = 2 |
|
|
|
} else { |
|
|
|
newOrd.IsTotal = 0 |
|
|
|
} |
|
|
|
eg.Where("pvd_oid=?", newOrd.PvdOid).Cols("is_total").Update(newOrd) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("=====================写入明细2", newOrd.PvdOid) |
|
|
|
if newOrd.ReturnMoneySettleAt > 0 { |
|
|
|
db.OrderRelateDeleteByOidbylevel(eg, oid, pvd) |
|
|
@@ -101,6 +149,54 @@ func PlayLetOrderReturnMoneyRelateInsert(eg *xorm.Engine, oid int64, pvd string, |
|
|
|
return |
|
|
|
} |
|
|
|
if isDelete { |
|
|
|
if newOrd.IsTotal == 1 { |
|
|
|
var ordRelate = make([]model.OrdListRelate, 0) |
|
|
|
eg.Where("oid=?", newOrd.OrdId).Find(&ordRelate) |
|
|
|
now := time.Unix(int64(newOrd.CreateAt), 0).Format("200601") |
|
|
|
nowDay := time.Unix(int64(newOrd.CreateAt), 0).Format("20060102") |
|
|
|
if len(ordRelate) > 0 { |
|
|
|
isDeduct := 0 |
|
|
|
for _, v := range ordRelate { |
|
|
|
if v.Amount == 0 && utils.StrToFloat64(v.AdditionalSubsidy) == 0 { |
|
|
|
continue |
|
|
|
} |
|
|
|
var userStatistics model.UserMonthAmount |
|
|
|
eg.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics) |
|
|
|
if userStatistics.Id != 0 { |
|
|
|
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
eg.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics) |
|
|
|
} |
|
|
|
if v.CreateAt > 1711086661 { |
|
|
|
var userStatistics1 model.UserDayAmount |
|
|
|
eg.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1) |
|
|
|
if userStatistics1.Id != 0 { |
|
|
|
userStatistics1 = model.UserDayAmount{ |
|
|
|
Date: utils.StrToInt(nowDay), |
|
|
|
Uid: v.Uid, |
|
|
|
} |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) |
|
|
|
} |
|
|
|
} |
|
|
|
var userStatistics1 model.UserWaitAmount |
|
|
|
eg.Where("uid=? ", v.Uid).Get(&userStatistics1) |
|
|
|
if userStatistics1.Id != 0 { |
|
|
|
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4) |
|
|
|
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1) |
|
|
|
} |
|
|
|
isDeduct = 1 |
|
|
|
} |
|
|
|
if isDeduct == 1 { |
|
|
|
if newOrd.State == 4 { |
|
|
|
newOrd.IsTotal = 2 |
|
|
|
} else { |
|
|
|
newOrd.IsTotal = 0 |
|
|
|
} |
|
|
|
eg.Where("pvd_oid=?", newOrd.PvdOid).Cols("is_total").Update(newOrd) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("=====================写入明细2", newOrd.PvdOid) |
|
|
|
if newOrd.ReturnMoneySettleAt > 0 { |
|
|
|
db.OrderRelateDeleteByOidbylevel(eg, oid, pvd) |
|
|
|