@@ -255,6 +255,15 @@ func VirtualCoinFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[ | |||||
} | } | ||||
} | } | ||||
func VirtualCoinFindByAll(Db *xorm.Engine) (*[]model.VirtualCoin, error) { | |||||
var m []model.VirtualCoin | |||||
//查询全部数据 | |||||
err := Db.Find(&m) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
return &m, nil | |||||
} | |||||
func RegionalAgentCalcSystemRelateInsert(Db *xorm.Engine, regionalAgentCalcSystemRelate *model.RegionalAgentCalcSystemRelate) (int64, error) { | func RegionalAgentCalcSystemRelateInsert(Db *xorm.Engine, regionalAgentCalcSystemRelate *model.RegionalAgentCalcSystemRelate) (int64, error) { | ||||
_, err := Db.InsertOne(regionalAgentCalcSystemRelate) | _, err := Db.InsertOne(regionalAgentCalcSystemRelate) | ||||
if err != nil { | if err != nil { | ||||
@@ -36,4 +36,5 @@ type RegionalAgentBase struct { | |||||
AutoAddRegion int `json:"auto_add_region" xorm:"default 0 comment('自动加入网点设置:1、自动获取位置并加入网点 2、手动选择网点加入') TINYINT(4)"` | AutoAddRegion int `json:"auto_add_region" xorm:"default 0 comment('自动加入网点设置:1、自动获取位置并加入网点 2、手动选择网点加入') TINYINT(4)"` | ||||
CustomerSetRegion int `json:"customer_set_region" xorm:"default 0 comment('网点自定义设置:1、用户可以手动添加网点 2、只允许后台添加网点') TINYINT(4)"` | CustomerSetRegion int `json:"customer_set_region" xorm:"default 0 comment('网点自定义设置:1、用户可以手动添加网点 2、只允许后台添加网点') TINYINT(4)"` | ||||
SiteOfMinimumSeparationDistance string `json:"site_of_minimum_separation_distance" xorm:"comment('网点之间最小间隔距离(单位:km)') VARCHAR(255)"` | SiteOfMinimumSeparationDistance string `json:"site_of_minimum_separation_distance" xorm:"comment('网点之间最小间隔距离(单位:km)') VARCHAR(255)"` | ||||
CoinIdList string `json:"coin_id_list" xorm:"comment('') VARCHAR(255)"` | |||||
} | } |
@@ -77,13 +77,15 @@ func HandleCommissionDistributionSystem(engine *xorm.Engine, args *md.RegionalAg | |||||
} | } | ||||
//查询 virtual_coin 获取虚拟货币的 “兑换比例” | //查询 virtual_coin 获取虚拟货币的 “兑换比例” | ||||
virtualCoin, err := db.VirtualCoinFindByParams(engine, map[string]interface{}{}) | |||||
virtualCoin, err := db.VirtualCoinFindByAll(engine) | |||||
if err != nil { | if err != nil { | ||||
return nil, false | return nil, false | ||||
} | } | ||||
var virtualCoinMap = map[int]string{} | var virtualCoinMap = map[int]string{} | ||||
for _, v := range *virtualCoin { | |||||
virtualCoinMap[v.Id] = v.ExchangeRatio | |||||
if virtualCoin != nil { | |||||
for _, v := range *virtualCoin { | |||||
virtualCoinMap[v.Id] = v.ExchangeRatio | |||||
} | |||||
} | } | ||||
//查询代理网点的代理(网点、区、市、省)信息 | //查询代理网点的代理(网点、区、市、省)信息 | ||||
var parents, tempParents []map[string]interface{} | var parents, tempParents []map[string]interface{} | ||||
@@ -301,17 +303,17 @@ func CommAmount(CommissionRate float64, amount float64, agentUser *[]model.Regio | |||||
} else { | } else { | ||||
temp["divide_amount"] = everyPersonDivideAmount | temp["divide_amount"] = everyPersonDivideAmount | ||||
var coinSetDetailMap []map[string]interface{} | var coinSetDetailMap []map[string]interface{} | ||||
for _, v := range coinSetDetail { | |||||
for _, v1 := range coinSetDetail { | |||||
var exchangeRatio float64 | var exchangeRatio float64 | ||||
if zhios_order_relate_utils.AnyToFloat64(virtualCoin[v.CoinID]) != 0 { | |||||
exchangeRatio = zhios_order_relate_utils.AnyToFloat64(virtualCoin[v.CoinID]) | |||||
if zhios_order_relate_utils.AnyToFloat64(virtualCoin[v1.CoinID]) != 0 { | |||||
exchangeRatio = zhios_order_relate_utils.AnyToFloat64(virtualCoin[v1.CoinID]) | |||||
} else { | } else { | ||||
exchangeRatio = 0 | exchangeRatio = 0 | ||||
} | } | ||||
coinSetDetailMap = append(coinSetDetailMap, map[string]interface{}{ | coinSetDetailMap = append(coinSetDetailMap, map[string]interface{}{ | ||||
"coin_id": v.CoinID, | |||||
"coin_name": v.CoinName, | |||||
"divide_value": zhios_order_relate_utils.AnyToFloat64(temp["divide_amount"]) * (zhios_order_relate_utils.AnyToFloat64(v.Value) / 100) * exchangeRatio, | |||||
"coin_id": v1.CoinID, | |||||
"coin_name": v1.CoinName, | |||||
"divide_value": zhios_order_relate_utils.AnyToFloat64(temp["divide_amount"]) * (zhios_order_relate_utils.AnyToFloat64(v1.Value) / 100) * exchangeRatio, | |||||
}) | }) | ||||
} | } | ||||
temp["divide_virtual_currency"] = coinSetDetailMap | temp["divide_virtual_currency"] = coinSetDetailMap | ||||
@@ -77,13 +77,15 @@ func HandleSubCommissionDistributionSystem(engine *xorm.Engine, args *md.Regiona | |||||
} | } | ||||
//查询 virtual_coin 获取虚拟货币的 “兑换比例” | //查询 virtual_coin 获取虚拟货币的 “兑换比例” | ||||
virtualCoin, err := db.VirtualCoinFindByParams(engine, map[string]interface{}{}) | |||||
virtualCoin, err := db.VirtualCoinFindByAll(engine) | |||||
if err != nil { | if err != nil { | ||||
return nil, false | return nil, false | ||||
} | } | ||||
var virtualCoinMap = map[int]string{} | var virtualCoinMap = map[int]string{} | ||||
for _, v := range *virtualCoin { | |||||
virtualCoinMap[v.Id] = v.ExchangeRatio | |||||
if virtualCoin != nil { | |||||
for _, v := range *virtualCoin { | |||||
virtualCoinMap[v.Id] = v.ExchangeRatio | |||||
} | |||||
} | } | ||||
//查询代理网点的代理(网点、区、市、省)信息 | //查询代理网点的代理(网点、区、市、省)信息 | ||||
var parents, tempParents []map[string]interface{} | var parents, tempParents []map[string]interface{} | ||||
@@ -265,17 +267,17 @@ func SubCommAmount(parentUid int, CommissionRate float64, amount float64, agentU | |||||
} else { | } else { | ||||
temp["divide_amount"] = everyPersonDivideAmount | temp["divide_amount"] = everyPersonDivideAmount | ||||
var coinSetDetailMap []map[string]interface{} | var coinSetDetailMap []map[string]interface{} | ||||
for _, v := range coinSetDetail { | |||||
for _, v1 := range coinSetDetail { | |||||
var exchangeRatio float64 | var exchangeRatio float64 | ||||
if zhios_order_relate_utils.AnyToFloat64(virtualCoin[v.CoinID]) != 0 { | |||||
exchangeRatio = zhios_order_relate_utils.AnyToFloat64(virtualCoin[v.CoinID]) | |||||
if zhios_order_relate_utils.AnyToFloat64(virtualCoin[v1.CoinID]) != 0 { | |||||
exchangeRatio = zhios_order_relate_utils.AnyToFloat64(virtualCoin[v1.CoinID]) | |||||
} else { | } else { | ||||
exchangeRatio = 0 | exchangeRatio = 0 | ||||
} | } | ||||
coinSetDetailMap = append(coinSetDetailMap, map[string]interface{}{ | coinSetDetailMap = append(coinSetDetailMap, map[string]interface{}{ | ||||
"coin_id": v.CoinID, | |||||
"coin_name": v.CoinName, | |||||
"divide_value": zhios_order_relate_utils.AnyToFloat64(temp["divide_amount"]) * (zhios_order_relate_utils.AnyToFloat64(v.Value) / 100) * exchangeRatio, | |||||
"coin_id": v1.CoinID, | |||||
"coin_name": v1.CoinName, | |||||
"divide_value": zhios_order_relate_utils.AnyToFloat64(temp["divide_amount"]) * (zhios_order_relate_utils.AnyToFloat64(v1.Value) / 100) * exchangeRatio, | |||||
}) | }) | ||||
} | } | ||||
temp["divide_virtual_currency"] = coinSetDetailMap | temp["divide_virtual_currency"] = coinSetDetailMap | ||||