|
@@ -2,6 +2,7 @@ package svc |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"applet/app/cfg" |
|
|
"applet/app/cfg" |
|
|
|
|
|
"applet/app/e" |
|
|
"applet/app/utils/cache" |
|
|
"applet/app/utils/cache" |
|
|
"applet/app/utils/logx" |
|
|
"applet/app/utils/logx" |
|
|
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/md" |
|
|
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/md" |
|
@@ -9,6 +10,7 @@ import ( |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_o2o_business.git/o2o" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_o2o_business.git/o2o" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan" |
|
|
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/implement" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/implement" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/tidwall/gjson" |
|
|
"github.com/tidwall/gjson" |
|
@@ -856,7 +858,7 @@ func orderSecondFreeCheck(eg *xorm.Engine, v *md.OrderInfo, oid int64, uid int, |
|
|
} |
|
|
} |
|
|
return m |
|
|
return m |
|
|
} |
|
|
} |
|
|
func orderFourFreeCheck(eg *xorm.Engine, v *md.OrderInfo, oid int64, uid int, isNeedReduct int) *model.FourNewcomersFreeProduct { |
|
|
|
|
|
|
|
|
func orderFourFreeCheck(eg *xorm.Engine, v *md.OrderInfo, oid int64, uid int, isNeedReduct int, dbName string) *model.FourNewcomersFreeProduct { |
|
|
m, err := db.FourFreeProductByID(eg, v.ItemId, v.SkuId, v.Pvd) |
|
|
m, err := db.FourFreeProductByID(eg, v.ItemId, v.SkuId, v.Pvd) |
|
|
if err != nil || m == nil { |
|
|
if err != nil || m == nil { |
|
|
|
|
|
|
|
@@ -910,8 +912,85 @@ func orderFourFreeCheck(eg *xorm.Engine, v *md.OrderInfo, oid int64, uid int, is |
|
|
eg.Where("id=?", tmp.Id).Cols("is_buy").Update(&tmp) |
|
|
eg.Where("id=?", tmp.Id).Cols("is_buy").Update(&tmp) |
|
|
m.Sale++ |
|
|
m.Sale++ |
|
|
eg.Where("id=?", m.Id).Cols("sale").Update(m) |
|
|
eg.Where("id=?", m.Id).Cols("sale").Update(m) |
|
|
|
|
|
StationDeduct(utils.Int64ToStr(oid), v.PvdOid, dbName) |
|
|
} |
|
|
} |
|
|
return m |
|
|
return m |
|
|
} |
|
|
} |
|
|
return m |
|
|
return m |
|
|
} |
|
|
} |
|
|
|
|
|
func StationDeduct(oid, pvdOid string, dbName string) (error, int) { |
|
|
|
|
|
eg := db.Db |
|
|
|
|
|
var user model.PlanSubsidyUserMoney |
|
|
|
|
|
get, err := eg.Where("uid=? ", dbName).Get(&user) |
|
|
|
|
|
if get == false { |
|
|
|
|
|
return e.NewErr(400, "站点预存款不足!"), 0 |
|
|
|
|
|
} |
|
|
|
|
|
count, _ := eg.Where("pvd_oid=? and type=1", pvdOid).Count(&model.PlanSubsidyUserMoneyFlow{}) |
|
|
|
|
|
if count > 0 { |
|
|
|
|
|
return nil, 0 |
|
|
|
|
|
} |
|
|
|
|
|
price := offical.MasterListCfgGetOneData(eg, "0", "plan_subsidy_money") |
|
|
|
|
|
if utils.StrToFloat64(price) == 0 { |
|
|
|
|
|
return nil, 0 |
|
|
|
|
|
} |
|
|
|
|
|
//判断站长的 |
|
|
|
|
|
user.Money = utils.Float64ToStr(utils.StrToFloat64(user.Money) - utils.StrToFloat64(price)) |
|
|
|
|
|
_, err = eg.Where("id=?", user.Id).Update(&user) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return e.NewErr(400, "站点预存款扣除失败!"), 0 |
|
|
|
|
|
} |
|
|
|
|
|
var flow = &model.PlanSubsidyUserMoneyFlow{ |
|
|
|
|
|
Uid: user.Uid, |
|
|
|
|
|
Type: 1, |
|
|
|
|
|
Time: time.Now(), |
|
|
|
|
|
Amount: price, |
|
|
|
|
|
AfterAmount: user.Money, |
|
|
|
|
|
Oid: oid, |
|
|
|
|
|
PvdOid: pvdOid, |
|
|
|
|
|
Title: "下单扣款", |
|
|
|
|
|
} |
|
|
|
|
|
_, err = eg.Insert(flow) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return e.NewErr(400, "站点预存款扣除失败!"), 0 |
|
|
|
|
|
} |
|
|
|
|
|
return nil, 1 |
|
|
|
|
|
} |
|
|
|
|
|
func StationAdd(oid, pvdOid string, dbName string) (error, int) { |
|
|
|
|
|
eg := db.Db |
|
|
|
|
|
var user model.PlanSubsidyUserMoney |
|
|
|
|
|
get, err := eg.Where("uid=? ", dbName).Get(&user) |
|
|
|
|
|
if get == false { |
|
|
|
|
|
return e.NewErr(400, "站点预存款不足!"), 0 |
|
|
|
|
|
} |
|
|
|
|
|
var tmp model.PlanSubsidyUserMoneyFlow |
|
|
|
|
|
count, _ := eg.Where("pvd_oid=? and type=0", pvdOid).Count(&model.PlanSubsidyUserMoneyFlow{}) |
|
|
|
|
|
if count > 0 { |
|
|
|
|
|
return nil, 0 |
|
|
|
|
|
} |
|
|
|
|
|
eg.Where("pvd_oid=? and type=1", pvdOid).Get(&tmp) |
|
|
|
|
|
if tmp.Id == 0 { |
|
|
|
|
|
return nil, 0 |
|
|
|
|
|
} |
|
|
|
|
|
price := tmp.Amount |
|
|
|
|
|
//判断站长的 |
|
|
|
|
|
user.Money = utils.Float64ToStr(utils.StrToFloat64(user.Money) + utils.StrToFloat64(price)) |
|
|
|
|
|
_, err = eg.Where("id=?", user.Id).Update(&user) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return e.NewErr(400, "站点预存款扣除失败!"), 0 |
|
|
|
|
|
} |
|
|
|
|
|
var flow = &model.PlanSubsidyUserMoneyFlow{ |
|
|
|
|
|
Uid: user.Uid, |
|
|
|
|
|
Type: 0, |
|
|
|
|
|
Time: time.Now(), |
|
|
|
|
|
Amount: price, |
|
|
|
|
|
AfterAmount: user.Money, |
|
|
|
|
|
Oid: oid, |
|
|
|
|
|
PvdOid: pvdOid, |
|
|
|
|
|
Title: "退款退回", |
|
|
|
|
|
} |
|
|
|
|
|
_, err = eg.Insert(flow) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return e.NewErr(400, "站点预存款扣除失败!"), 0 |
|
|
|
|
|
} |
|
|
|
|
|
return nil, 1 |
|
|
|
|
|
} |