huangjiajun 2 місяці тому
джерело
коміт
c876f724d3
1 змінених файлів з 60 додано та 19 видалено
  1. +60
    -19
      consume/zhios_valid_user.go

+ 60
- 19
consume/zhios_valid_user.go Переглянути файл

@@ -6,6 +6,7 @@ import (
"applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
model2 "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"encoding/json"
"errors"
@@ -121,9 +122,10 @@ func RoutineUpdateUserComm(eg *xorm.Engine, dbName, uid string) {
todone--
}
case "goodsCommission":
sqlTpl := `SELECT cast(SUM(LEFT(olr.amount,LENGTH(olr.amount)-2)) as decimal(50,4)) AS amount

sqlTpl := `SELECT SUM(olr.amount) AS amount
FROM ord_list_relate olr
LEFT JOIN ord_list ol ON olr.oid = ol.ord_id
LEFT JOIN ord_list ol ON olr.oid = ol.ord_id
LEFT JOIN privilege_card_ord pco ON olr.oid =pco.ord_id
LEFT JOIN duoyou_ord_list dol ON olr.oid =dol.oid
LEFT JOIN recharge_order ro ON olr.oid =ro.oid
@@ -131,32 +133,71 @@ FROM ord_list_relate olr
WHERE olr.uid = ? AND (ol.state<>4 or pco.state=1 or dol.id>0 or ro.status<>'已退款' or pso.status<>'订单退款');
`
todayResult, err := db.QueryNativeString(eg, sqlTpl, uid)
today := "0"
if err == nil {
today = todayResult[0]["amount"]

var sum float64 = 0
if err != nil {
_ = logx.Warn(err)
sum = 0
} else {
sum = utils.StrToFloat64(todayResult[0]["amount"])
}
sqlTpl = `SELECT SUM(olr.amount) AS amount
FROM o2o_ord_list_relate olr
LEFT JOIN o2o_ord ol ON olr.oid = ol.ord_id
LEFT JOIN o2o_pay_to_merchant optm ON optm.pay_id = olr.oid
WHERE olr.uid = ? AND (ol.state IN (1,2,3,4) or optm.state=1);
`
todayResult, err = db.QueryNativeString(eg, sqlTpl, uid)
if err != nil {
_ = logx.Warn(err)
sum += 0
} else {
sum += utils.StrToFloat64(todayResult[0]["amount"])
}

sqlTpl = `SELECT SUM(olr.amount) AS amount
FROM b2c_ord_list_relate olr
JOIN b2c_ord ol ON olr.oid = ol.ord_id
WHERE olr.uid = ? AND ol.state IN (1,2,3,4);
`
todayResult, err = db.QueryNativeString(eg, sqlTpl, uid)
if err != nil {
_ = logx.Warn(err)
sum += 0
} else {
sum += utils.StrToFloat64(todayResult[0]["amount"])
}
sqlTpl = `SELECT SUM(olr.amount) AS amount
FROM mall_ord_list_relate olr
JOIN mall_ord ol ON olr.oid = ol.ord_id
WHERE olr.uid = ? AND ol.state IN (1,2,3);
`
todayResult, err = db.QueryNativeString(eg, sqlTpl, uid)
if err != nil {
_ = logx.Warn(err)
sum += 0
} else {
sum += utils.StrToFloat64(todayResult[0]["amount"])
}
// 累计佣金
if utils.StrToFloat64(today) >= utils.AnyToFloat64(v) {
if sum >= utils.AnyToFloat64(v) {
todone--
}
case "orderPay":
// 付款订单满足v元
ms, err := db.OrderListByUIDByPaidPrice(eg, user.Uid, v, []string{"0", "1", "2", "3", "5"})
if err != nil {
logx.Warn(err)
}
mss := *ms
if len(mss) > 0 {
count, _ := eg.Where("uid=?", user.Uid).In("state", []string{"1", "2", "3", "5"}).Sum(&model.OrdList{}, "paid_price")
count1, _ := eg.Where("uid=?", user.Uid).In("state", []string{"1", "2", "3"}).Sum(&model.MallOrd{}, "cost_price")
count2, _ := eg.Where("uid=?", user.Uid).In("state", []string{"1", "2", "3"}).Sum(&model2.O2oOrd{}, "cost_price")
count3, _ := eg.Where("uid=?", user.Uid).In("state", []string{"1", "2", "3"}).Sum(&model2.B2cOrd{}, "cost_price")
if count+count3+count2+count1 > utils.AnyToFloat64(v) {
todone--
}
case "receive":
// 已收货
ms, err := db.OrderListByUIDByState(eg, user.Uid, []string{"1", "2", "3", "5"})
if err != nil {
logx.Warn(err)
}
mss := *ms
if len(mss) > 0 {
count, _ := eg.Where("uid=?", user.Uid).In("state", []string{"1", "2", "3", "5"}).Count(&model.OrdList{})
count1, _ := eg.Where("uid=?", user.Uid).In("state", []string{"3"}).Count(&model.MallOrd{})
count2, _ := eg.Where("uid=?", user.Uid).In("state", []string{"3"}).Count(&model2.O2oOrd{})
count3, _ := eg.Where("uid=?", user.Uid).In("state", []string{"3"}).Count(&model2.B2cOrd{})
if count+count3+count2+count1 > 0 {
todone--
}
case "tbAuth":


Завантаження…
Відмінити
Зберегти