|
|
@@ -1,12 +1,8 @@ |
|
|
|
package svc |
|
|
|
|
|
|
|
import ( |
|
|
|
"applet/app/cfg" |
|
|
|
"applet/app/utils/cache" |
|
|
|
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/md" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_day_luck_draw.git/svc" |
|
|
|
"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_order_relate_rule.git/lib/comm_plan" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/implement" |
|
|
|
"fmt" |
|
|
@@ -103,6 +99,9 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
if pvd == md.PVD_WPHUNIONOWN { //判断下 |
|
|
|
pvd = md.PVD_VIP |
|
|
|
} |
|
|
|
if pvd == "pdd_union_own_zero" { //判断下 |
|
|
|
pvd = md.PVD_PDD |
|
|
|
} |
|
|
|
pidToUser := map[string]*md.UserPid{} |
|
|
|
for _, vv := range userInfo { |
|
|
|
if pvd == md.PVD_TB { |
|
|
@@ -225,10 +224,10 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
NotSettleDeduct(eg, &v, dbName) |
|
|
|
} |
|
|
|
if v.State != 4 && v.FourPriceType > 0 { |
|
|
|
m, _ := db.FourFreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) |
|
|
|
m, _ := db.FourFreeProductByID(eg, v.ItemId, utils.Int64ToStr(v.NumItemId), v.Pvd) |
|
|
|
if m != nil { |
|
|
|
var tmp model.FourNewcomersFreeStock |
|
|
|
eg.Where("lid=? and uid=? and is_buy=1 and is_back=0", m.Id, v.Uid).Get(&tmp) |
|
|
|
eg.Where("lid=? and uid=? and is_buy=1 and is_back=0 and gid=?", m.Id, v.Uid, v.ItemId).Get(&tmp) |
|
|
|
if tmp.Id > 0 { |
|
|
|
tmp.IsBuy = 0 |
|
|
|
eg.Where("id=?", tmp.Id).Cols("is_buy").Update(&tmp) |
|
|
@@ -242,7 +241,8 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
v.State = ords[v.PvdOid].State |
|
|
|
_ = db.DbsOrderUpdate(eg, v.OrdId, &v) |
|
|
|
} |
|
|
|
if ords[v.PvdOid].State == 3 && utils.InArr(utils.IntToStr(v.State), []string{"3", "4", "5"}) == false && v.PvdSettleAt > 0 { |
|
|
|
v.State = 3 |
|
|
@@ -410,7 +410,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
if pvd == "hw_movie" { |
|
|
|
newPvd = "cinema" |
|
|
|
} |
|
|
|
if pvd == md.PVD_PDDBYCREATETIME || pvd == md.PVD_PDDBYAGOTIME || pvd == md.PVD_PDDBYSTATUS || pvd == md.PVD_PDDBYSTATUSSUCCESS || pvd == md.PVD_PDDBYSTATUSFAIL { //判断下拼多多 |
|
|
|
if pvd == "pdd_union_own_zero" || pvd == md.PVD_PDDBYCREATETIME || pvd == md.PVD_PDDBYAGOTIME || pvd == md.PVD_PDDBYSTATUS || pvd == md.PVD_PDDBYSTATUSSUCCESS || pvd == md.PVD_PDDBYSTATUSFAIL { //判断下拼多多 |
|
|
|
newPvd = md.PVD_PDD |
|
|
|
} |
|
|
|
if pvd == md.PVD_JDUNIONOWN || pvd == md.PVD_JDUNIONOWNUPDATE || pvd == md.PVD_JDBYCREATETIME || pvd == md.PVD_JDBYSUCCESS || pvd == md.PVD_JDFAILBYCREATETIME || pvd == md.PVD_JDBYSTATUS { //判断下京东 |
|
|
@@ -453,7 +453,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
optPvd = md.PVD_KUAISHOULIVE |
|
|
|
} |
|
|
|
} |
|
|
|
if !strings.Contains(v.Pid, "fourFree") && !strings.Contains(v.Pid, "moreFree") && !strings.Contains(v.Pid, "shareSeFree") && !strings.Contains(v.Pid, "seFree") && !strings.Contains(v.Pid, "cloud") && !strings.Contains(v.Pid, "share") && !strings.Contains(v.Pid, "self") && !strings.Contains(v.Pid, "free") && !strings.Contains(v.Pid, "actself") && !strings.Contains(v.Pid, "wechatactself") && !strings.Contains(v.Pid, "wechatactselfnew") && !strings.Contains(v.Pid, "wechatactshare") { |
|
|
|
if !strings.Contains(v.Pid, "fourf") && !strings.Contains(v.Pid, "moreFree") && !strings.Contains(v.Pid, "shareSeFree") && !strings.Contains(v.Pid, "seFree") && !strings.Contains(v.Pid, "cloud") && !strings.Contains(v.Pid, "share") && !strings.Contains(v.Pid, "self") && !strings.Contains(v.Pid, "free") && !strings.Contains(v.Pid, "actself") && !strings.Contains(v.Pid, "wechatactself") && !strings.Contains(v.Pid, "wechatactselfnew") && !strings.Contains(v.Pid, "wechatactshare") { |
|
|
|
continue |
|
|
|
} |
|
|
|
var oid int64 |
|
|
@@ -585,7 +585,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
if pvd == "hw_movie" { |
|
|
|
newPvd = "cinema" |
|
|
|
} |
|
|
|
if pvd == md.PVD_PDDBYCREATETIME || pvd == md.PVD_PDDBYAGOTIME || pvd == md.PVD_PDDBYSTATUS || pvd == md.PVD_PDDBYSTATUSSUCCESS || pvd == md.PVD_PDDBYSTATUSFAIL { //判断下拼多多 |
|
|
|
if pvd == "pdd_union_own_zero" || pvd == md.PVD_PDDBYCREATETIME || pvd == md.PVD_PDDBYAGOTIME || pvd == md.PVD_PDDBYSTATUS || pvd == md.PVD_PDDBYSTATUSSUCCESS || pvd == md.PVD_PDDBYSTATUSFAIL { //判断下拼多多 |
|
|
|
newPvd = md.PVD_PDD |
|
|
|
} |
|
|
|
if utils.InArr(pvd, []string{"csjp_create", "own_csjp", "own_csjp_activity"}) { |
|
|
@@ -618,20 +618,12 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
} |
|
|
|
optPvd := newPvd |
|
|
|
opt := opts[newPvd] |
|
|
|
if opt == nil { |
|
|
|
continue |
|
|
|
} |
|
|
|
if v.Pvd == md.PVD_JDOwn && (opt == nil || (opt != nil && opt.PlanCommissionId == 0)) { |
|
|
|
opt = opts[md.PVD_JD] |
|
|
|
} |
|
|
|
//判断是否加油 |
|
|
|
if newPvd == "oil" { |
|
|
|
var ok = true |
|
|
|
optPvd = "oilstation" |
|
|
|
opt, ok = opts["oilstation"] |
|
|
|
if ok == false { |
|
|
|
continue |
|
|
|
} |
|
|
|
} else if opt == nil { |
|
|
|
continue |
|
|
|
} |
|
|
|
if (pvd == "tikTok" || pvd == "csjp") && v.IsTikTokTeamOrder == 1 && opts["tikTokTeam"] != nil && opts["tikTokTeam"].PlanCommissionId > 0 { |
|
|
|
opt = opts["tikTokTeam"] |
|
|
|
} |
|
|
@@ -641,7 +633,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
priceType := 0 |
|
|
|
secondPriceType := 0 |
|
|
|
fourPriceType := 0 |
|
|
|
if !strings.Contains(v.Pid, "fourFree") && !strings.Contains(v.Pid, "moreFree") && !strings.Contains(v.Pid, "shareSeFree") && !strings.Contains(v.Pid, "seFree") && !strings.Contains(v.Pid, "cloud") && !strings.Contains(v.Pid, "share") && !strings.Contains(v.Pid, "self") && !strings.Contains(v.Pid, "free") && !strings.Contains(v.Pid, "actself") && !strings.Contains(v.Pid, "wechatactself") && !strings.Contains(v.Pid, "wechatactselfnew") && !strings.Contains(v.Pid, "wechatactshare") { |
|
|
|
if !strings.Contains(v.Pid, "fourf") && !strings.Contains(v.Pid, "moreFree") && !strings.Contains(v.Pid, "shareSeFree") && !strings.Contains(v.Pid, "seFree") && !strings.Contains(v.Pid, "cloud") && !strings.Contains(v.Pid, "share") && !strings.Contains(v.Pid, "self") && !strings.Contains(v.Pid, "free") && !strings.Contains(v.Pid, "actself") && !strings.Contains(v.Pid, "wechatactself") && !strings.Contains(v.Pid, "wechatactselfnew") && !strings.Contains(v.Pid, "wechatactshare") { |
|
|
|
continue |
|
|
|
} |
|
|
|
var oid = v.Oid |
|
|
@@ -653,10 +645,14 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
if v.OrderType == 15 { |
|
|
|
v.OrderType = md.OrderTypeFree |
|
|
|
} |
|
|
|
freeOrderType := v.OrderType |
|
|
|
|
|
|
|
returnMoney := "0" |
|
|
|
freezeTime := "96" |
|
|
|
if v.OrderType == 20 { |
|
|
|
PlanCommissionId := 0 |
|
|
|
if v.State == 4 { |
|
|
|
state = 4 |
|
|
|
} |
|
|
|
if v.OrderType == 20 && v.State != 4 { |
|
|
|
if user == nil || user.Uid == 0 { //判断免单的如果没有用户不跟这个订单 |
|
|
|
continue |
|
|
|
} |
|
|
@@ -670,6 +666,9 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
if freeOrder.IsShow == 0 || utils.StrToFloat64(freeOrder.CheckPrice) != v.PaidPrice { |
|
|
|
v.State = 4 |
|
|
|
} |
|
|
|
if opt != nil { |
|
|
|
PlanCommissionId = opt.PlanCommissionId |
|
|
|
} |
|
|
|
returnMoney = freeOrder.ReturnMoney |
|
|
|
if gjson.Get(freeOrder.NewData, "freeze_time").String() != "" { |
|
|
|
freezeTime = gjson.Get(freeOrder.NewData, "freeze_time").String() |
|
|
@@ -693,7 +692,6 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
if user != nil { |
|
|
|
user.OwnbuyReturnType = ownbuyReturnType //是否有自购奖励 |
|
|
|
uid = user.Uid |
|
|
|
userLv := user.Lv |
|
|
|
|
|
|
|
fmt.Println(optPvd) |
|
|
|
if returnMoneyType == "0" { |
|
|
@@ -719,26 +717,6 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
} |
|
|
|
fmt.Println(returnProfit) |
|
|
|
|
|
|
|
//判断下这个等级有么有设置 |
|
|
|
if opt.UserRate != nil { |
|
|
|
for k, item := range opt.UserRate { |
|
|
|
if k == 0 { |
|
|
|
selfRate = item.SelfRate |
|
|
|
subsidyRate = item.SubsidyShareRate |
|
|
|
if v.OrderType == 0 { |
|
|
|
subsidyRate = item.SubsidySelfRate |
|
|
|
} |
|
|
|
} |
|
|
|
if k == userLv { |
|
|
|
selfRate = item.SelfRate |
|
|
|
selfRate = item.SelfRate |
|
|
|
subsidyRate = item.SubsidyShareRate |
|
|
|
if v.OrderType == 0 { |
|
|
|
subsidyRate = item.SubsidySelfRate |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if v.OrderType == 20 || v.OrderType == 15 || v.OrderType == 11 || v.OrderType == md.OrderTypeFree || v.OrderType == md.OrderTypeWechatActSelf || v.OrderType == md.OrderTypeWechatActSelfNew || v.OrderType == md.OrderTypeActSelf { |
|
|
@@ -773,7 +751,8 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
OldState: state, |
|
|
|
ServiceUid: utils.StrToInt(ServiceUid), |
|
|
|
WaitSettleAt: int(v.WaitSettleAt), |
|
|
|
NumItemId: v.SkuId, |
|
|
|
NumItemId: utils.StrToInt64(v.SkuId), |
|
|
|
ShopId: v.ShopId, |
|
|
|
TaskType: v.TaskType, |
|
|
|
OrderFormType: orderFormType, |
|
|
|
OrdId: oid, |
|
|
@@ -795,10 +774,8 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
UserReturnMoney: returnProfit, |
|
|
|
UserCommissionRate: selfRate, |
|
|
|
PvdCommission: pvdFee, |
|
|
|
PvdCommissionRate: opt.PvdRate, |
|
|
|
SysCommission: sysFee, |
|
|
|
SysCommissionRate: opt.SysRate, |
|
|
|
PlanCommissionId: opt.PlanCommissionId, |
|
|
|
PlanCommissionId: PlanCommissionId, |
|
|
|
Reason: v.Reason, |
|
|
|
State: v.State, |
|
|
|
CreateAt: int(v.StartTime), |
|
|
@@ -868,91 +845,6 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI |
|
|
|
} |
|
|
|
} |
|
|
|
AcquisitionHookFirstOrder(eg, dbName, newOrd) |
|
|
|
if uid > 0 { |
|
|
|
//商家分佣 |
|
|
|
args := map[string]string{ |
|
|
|
"commission": utils.Float64ToStr(utils.FloatFormat(allCommission, 6)), // 总佣金 |
|
|
|
"bili": utils.Float64ToStrByPrec(opt.MerchantRate, 4), // 抽成 除以100之后的 |
|
|
|
"uid": utils.IntToStr(uid), // 用户id |
|
|
|
"oid": utils.Int64ToStr(oid), // 订单号 |
|
|
|
"pvd": newPvd, // 渠道 |
|
|
|
} |
|
|
|
o2o.AddStoreCommission(eg, args) |
|
|
|
//写入区域代理订单 |
|
|
|
var req = &md.InsertRegionalAgentOrdBelongData{ |
|
|
|
Uid: uid, |
|
|
|
Pvd: md.PVD_GUIDE, |
|
|
|
CommPvd: md.PVD_COMMON, |
|
|
|
Commission: utils.Float64ToStr(utils.FloatFormat(allCommission, 6)), |
|
|
|
OrderId: oid, |
|
|
|
RegionRate: opt.RegionRate, |
|
|
|
GlobalRate: opt.GlobalRate, |
|
|
|
RegionSubRate: opt.RegionSubRate, |
|
|
|
|
|
|
|
Status: "0", |
|
|
|
} |
|
|
|
//if opt.Mode == "lv_ds_check" && lvUser != nil { |
|
|
|
// req.Commission = utils.Float64ToStrByPrec(lvUser.MinProfit, 8) |
|
|
|
//} |
|
|
|
go SaveOrderByCommApi(eg, dbName, req) |
|
|
|
commCheckCoupon(eg, uid, v.ItemId, 0, 1, newOrd.Pvd, utils.Int64ToStr(v.Oid)) //导购的判断 |
|
|
|
|
|
|
|
if v.State != 4 { |
|
|
|
//加油扣除优惠券额度 查询优惠券使用记录 |
|
|
|
if v.Pvd == md.PVD_OILSTATION { |
|
|
|
profits := v.CostPrice - v.PaidPrice |
|
|
|
profits = utils.FloatFormat(profits, 2) |
|
|
|
if profits > 0 { |
|
|
|
bools := ReduceCoupon(eg, dbName, utils.Float64ToStr(profits), uid, v.ItemId, md.PVD_OILSTATION, "OIL", newOrd.CreateAt, v.ItemTitle, utils.Int64ToStr(v.Oid)) |
|
|
|
//加入公告栏明细 |
|
|
|
if bools == 1 { |
|
|
|
AddPlacardRecord(eg, uid, "", "", md.PVD_OILSTATION, utils.Float64ToStr(profits), "") |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
commCheckCoupon(eg, uid, v.ItemId, 0, 1, newOrd.Pvd, utils.Int64ToStr(v.Oid)) //导购的判断 |
|
|
|
} |
|
|
|
//定制 抽奖加入付款订单 |
|
|
|
req := md3.DayLuckDrawOrderJackpotReq{ |
|
|
|
Uid: utils.IntToStr(uid), |
|
|
|
Oid: utils.Int64ToStr(newOrd.OrdId), |
|
|
|
Pvd: newOrd.Pvd, |
|
|
|
Amount: utils.Float64ToStrByPrec(newOrd.PaidPrice, 7), |
|
|
|
Commission: utils.Float64ToStrByPrec(newOrd.BenefitAll, 7), |
|
|
|
} |
|
|
|
svc.AddOrderJackpot(eg, req) |
|
|
|
if cfg.Prd { |
|
|
|
CheckValid(eg, dbName, uid, 1, ch) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if freeOrderType == 13 || freeOrderType == md.OrderTypeFree || freeOrderType == md.OrderTypeTljFree || freeOrderType == md.OrderTypeTljRelationFree { |
|
|
|
mutexKey := fmt.Sprintf("%s:all_order_to_store:%s:pvd:%s", dbName, v.PvdOid, v.Pvd) |
|
|
|
available, err := cache.Do("SET", mutexKey, 1, "EX", 5, "NX") |
|
|
|
if err != nil { |
|
|
|
continue |
|
|
|
} |
|
|
|
if available != "OK" { |
|
|
|
continue |
|
|
|
} |
|
|
|
arg := md.ZhiosOrderFree{ |
|
|
|
ItemId: newOrd.ItemId, |
|
|
|
SkuId: newOrd.NumItemId, |
|
|
|
OptPvd: newPvd, |
|
|
|
OrderType: utils.IntToStr(freeOrderType), |
|
|
|
Pid: v.Pid, |
|
|
|
Uid: utils.IntToStr(newOrd.Uid), |
|
|
|
Mid: dbName, |
|
|
|
Oid: utils.Int64ToStr(newOrd.OrdId), |
|
|
|
} |
|
|
|
if cfg.Prd { |
|
|
|
ch.Publish(md.OrderFree, utils.SerializeStr(arg), md.OrderFreeRoutKeyForOrder) |
|
|
|
|
|
|
|
} else { |
|
|
|
ch.Publish(md.OrderFree, utils.SerializeStr(arg), md.OrderFreeRoutKeyForOrderdev) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |