Ver código fonte

更新

guide_order
huangjiajun 1 dia atrás
pai
commit
5a3db53c4e
5 arquivos alterados com 109 adições e 5 exclusões
  1. +17
    -0
      app/db/model/plan_subsidy_money_flow.go
  2. +7
    -0
      app/db/model/plan_subsidy_user_money.go
  3. +80
    -1
      app/svc/svc_order_track_save_create.go
  4. +2
    -2
      app/svc/svc_order_track_save_create_update.go
  5. +3
    -2
      app/svc/svc_order_track_save_create_update_zero.go

+ 17
- 0
app/db/model/plan_subsidy_money_flow.go Ver arquivo

@@ -0,0 +1,17 @@
package model

import (
"time"
)

type PlanSubsidyUserMoneyFlow struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Type int `json:"type" xorm:"default 0 comment('0收入 1支出') INT(1)"`
Time time.Time `json:"time" xorm:"DATETIME"`
Amount string `json:"amount" xorm:"default 0.00 DECIMAL(20,2)"`
AfterAmount string `json:"after_amount" xorm:"default 0.00 DECIMAL(20,2)"`
Oid string `json:"oid" xorm:"VARCHAR(255)"`
PvdOid string `json:"pvd_oid" xorm:"VARCHAR(255)"`
Title string `json:"title" xorm:"VARCHAR(255)"`
}

+ 7
- 0
app/db/model/plan_subsidy_user_money.go Ver arquivo

@@ -0,0 +1,7 @@
package model

type PlanSubsidyUserMoney struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 comment('代理id') INT(11)"`
Money string `json:"money" xorm:"default 0.00 DECIMAL(20,2)"`
}

+ 80
- 1
app/svc/svc_order_track_save_create.go Ver arquivo

@@ -2,6 +2,7 @@ package svc

import (
"applet/app/cfg"
"applet/app/e"
"applet/app/utils/cache"
"applet/app/utils/logx"
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_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_third_party_api.git/db/offical"
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/implement"
"fmt"
"github.com/tidwall/gjson"
@@ -856,7 +858,7 @@ func orderSecondFreeCheck(eg *xorm.Engine, v *md.OrderInfo, oid int64, uid int,
}
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)
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)
m.Sale++
eg.Where("id=?", m.Id).Cols("sale").Update(m)
StationDeduct(utils.Int64ToStr(oid), v.PvdOid, dbName)
}
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
}

+ 2
- 2
app/svc/svc_order_track_save_create_update.go Ver arquivo

@@ -629,7 +629,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
if user == nil || user.Uid == 0 { //判断免单的如果没有用户不跟这个订单
continue
}
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 0)
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 0, dbName)
if freeOrder != nil {
optPvd = "fourFree_" + utils.IntToStr(freeOrder.PriceType)
}
@@ -842,7 +842,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
continue
}
//TODO
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 1)
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 1, dbName)
if freeOrder != nil {
fourPriceType = freeOrder.PriceType
// 切换免单活动的分佣方案, 如1元购等


+ 3
- 2
app/svc/svc_order_track_save_create_update_zero.go Ver arquivo

@@ -232,6 +232,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI
m.Sale = 0
}
eg.Where("id=?", m.Id).Cols("sale,stock").Update(m)
StationAdd(utils.Int64ToStr(v.OrdId), v.PvdOid, dbName)
}
}
}
@@ -466,7 +467,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI
if user == nil || user.Uid == 0 { //判断免单的如果没有用户不跟这个订单
continue
}
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 0)
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 0, dbName)
if freeOrder != nil {
optPvd = "fourFree_" + utils.IntToStr(freeOrder.PriceType)
}
@@ -652,7 +653,7 @@ func OrderSaveCreateUpdateZero(eg *xorm.Engine, pvd string, ordData *[]md.OrderI
continue
}
//TODO
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 1)
freeOrder := orderFourFreeCheck(eg, &v, oid, user.Uid, 1, dbName)
if freeOrder != nil {
fourPriceType = freeOrder.PriceType
// 切换免单活动的分佣方案, 如1元购等


Carregando…
Cancelar
Salvar