huangjiajun 1 anno fa
parent
commit
42fc1e8322
2 ha cambiato i file con 72 aggiunte e 17 eliminazioni
  1. +5
    -0
      md/regional_agent.go
  2. +67
    -17
      rule/regional_agent.go

+ 5
- 0
md/regional_agent.go Vedi File

@@ -21,6 +21,11 @@ type InsertRegionalAgentOrdBelongData struct {
Commission string `json:"commission"`
OrderId int64 `json:"order_id"`
Status string `json:"status"`
ProvinceId string `json:"province_id"`
CityId string `json:"city_id"`
CountyId string `json:"county_id"`
SiteId string `json:"site_id"`
BelongType string `json:"belong_type"`
}

type RegionalAgentSystemArgs struct {


+ 67
- 17
rule/regional_agent.go Vedi File

@@ -17,7 +17,7 @@ func BindUserOrdToAgent(eg *xorm.Engine, dbName string, data *md.InsertRegionalA

//公共调用
func CommRegionalAgentInsert(engine *xorm.Engine, args *md.InsertRegionalAgentOrdBelongData) int {
res, userBelong := InsertRegionalAgentOrdBelong(engine, args)
res, RegionId := InsertRegionalAgentOrdBelong(engine, args)
if !res {
return 0
}
@@ -30,7 +30,7 @@ func CommRegionalAgentInsert(engine *xorm.Engine, args *md.InsertRegionalAgentOr
CommPvd: args.CommPvd,
Status: args.Status,
Type: "2",
RegionId: zhios_order_relate_utils.AnyToString(userBelong.RegionId),
RegionId: zhios_order_relate_utils.AnyToString(RegionId),
})
if !res {
return 2
@@ -328,33 +328,83 @@ func CommAmount(CommissionRate float64, amount float64, agentUser *[]model.Regio
}

//InsertRegionalAgentOrdBelong 插入 regional_agent_ord_belong (用户订单归属表) 数据
func InsertRegionalAgentOrdBelong(engine *xorm.Engine, data *md.InsertRegionalAgentOrdBelongData) (bool, *model.RegionalAgentUserBelong) {
func InsertRegionalAgentOrdBelong(engine *xorm.Engine, data *md.InsertRegionalAgentOrdBelongData) (bool, int) {
// 查询 regional_agent_user_belong 得到用户归属的区域代理
userBelong, err := db.GetCountByRegionalAgentUserBelongById(engine, data.Uid, data.Pvd, data.CommPvd)

if err != nil || userBelong == nil {
return false, nil
RegionId := 0
ProvinceId := 0
RegionalName := ""
CityId := 0
DistrictId := 0
SiteId := 0
Level := 0
if data.BelongType == "1" {
ProvinceId = zhios_order_relate_utils.StrToInt(data.ProvinceId)
if ProvinceId > 0 {
Level = 1
RegionId = ProvinceId
}
CityId = zhios_order_relate_utils.StrToInt(data.CityId)
if CityId > 0 {
Level = 2
RegionId = CityId
}
DistrictId = zhios_order_relate_utils.StrToInt(data.CountyId)
if DistrictId > 0 {
Level = 3
RegionId = DistrictId
}
SiteId = zhios_order_relate_utils.StrToInt(data.SiteId)
if SiteId > 0 {
Level = 4
RegionId = SiteId
}
if RegionId > 0 {
regionalAgentRegion, err := db.RegionalAgentRegionGetOneByParams(engine, map[string]interface{}{
"key": "id",
"value": zhios_order_relate_utils.AnyToInt64(RegionId),
})
if err != nil {
return false, 0
}
if regionalAgentRegion == nil {
return false, 0
}
RegionalName = regionalAgentRegion.RegionName
}
} else {
userBelong, err := db.GetCountByRegionalAgentUserBelongById(engine, data.Uid, data.Pvd, data.CommPvd)
if err != nil || userBelong == nil {
return false, 0
}
RegionId = userBelong.RegionId
ProvinceId = int(userBelong.ProvinceId)
RegionalName = userBelong.RegionalName
CityId = int(userBelong.CityId)
DistrictId = int(userBelong.DistrictId)
SiteId = int(userBelong.SiteId)
Level = userBelong.Level
}

date := time.Now()
_, err = db.RegionalAgentOrdBelongInsert(engine, &model.RegionalAgentOrdBelong{
_, err := db.RegionalAgentOrdBelongInsert(engine, &model.RegionalAgentOrdBelong{
Uid: int(zhios_order_relate_utils.AnyToInt64(data.Uid)),
Pvd: data.Pvd,
OrderId: data.OrderId,
CurrencyType: 1,
Commission: data.Commission,
RegionId: userBelong.RegionId,
RegionalName: userBelong.RegionalName,
ProvinceId: userBelong.ProvinceId,
CityId: userBelong.CityId,
DistrictId: userBelong.DistrictId,
SiteId: userBelong.SiteId,
RegionId: RegionId,
RegionalName: RegionalName,
ProvinceId: int64(ProvinceId),
CityId: int64(CityId),
DistrictId: int64(DistrictId),
SiteId: int64(SiteId),
CreateTime: date,
UpdateTime: date,
Level: userBelong.Level,
Level: Level,
})
if err != nil {
return false, nil
return false, 0
}

return true, userBelong
return true, RegionId
}

Caricamento…
Annulla
Salva