Commit b88af2a0 authored by lujunye's avatar lujunye

13

parent e8b9225b
......@@ -25,8 +25,9 @@ func getDbtRule(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture
/*
params
key:user_token
object:1为设置给代理商 2为设置给分销商/分销员
dbt_type:分账方式 1人工结算 2自动结算
commission_time:提成结算时间 1立即结算
commission_time_type:佣金结算时间 1用户发货时发放佣金 2订单完成时发放佣金
share_type:分享方式 1(1对1结算)2(1对多结算)
*/
func setDbtRule(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
......
......@@ -24,21 +24,24 @@ class getDbtRuleModel: Mappable {
}
}
class getDbtRuleDataModel: Mappable {
var is_sup:Int? //是否是供应商(1是,0不是)
var is_dbt : Int? //是否是分销商(1是,0不是)
// var is_sup:Int? //是否是供应商(1是,0不是)
// var is_dbt : Int? //是否是分销商(1是,0不是)
var dbt_type :Int? //分账方式 1人工结算 2自动结算(初始化为0,0的话就是没有设置过)
var commission_time : Int?//提成结算时间 1立即结算(初始化为0,0的话就是没有设置过)
var commission_time_type : Int?//提成结算时间 1立即结算(初始化为0,0的话就是没有设置过)
var share_type :Int?//分享方式 1(1对1结算)2(1对多结算)(初始化为0,0的话就是没有设置过)
var dbt_agent_type:Int?//代理商分账方式 1人工结算 2自动结算
var agent_commission_time_type:Int?//代理商佣金结算时间 1用户收货时结算 2订单完成时结算
required init?( map: Map) {
}
func mapping(map: Map) {
is_sup <- map["is_sup"]
is_dbt <- map["is_dbt"]
// is_sup <- map["is_sup"]
// is_dbt <- map["is_dbt"]
dbt_type <- map["dbt_type"]
commission_time <- map["commission_time"]
commission_time_type <- map["commission_time_type"]
share_type <- map["share_type"]
dbt_agent_type <- map["dbt_agent_type"]
agent_commission_time_type <- map["agent_commission_time_type"]
}
}
......
......@@ -38,11 +38,13 @@ class DistributorSettingViewController: BaseViewController {
leftBtn.backgroundColor = UIColor.white
rightBtn.isSelected = !sender.isSelected
dl_setting_view.isHidden = false
dls()
}else{
leftBtn.isSelected = !sender.isSelected
leftBtn.backgroundColor = UIColor.clear
rightBtn.backgroundColor = UIColor.white
dl_setting_view.isHidden = true
fxs()
}
}
var select_type = 2
......@@ -73,8 +75,12 @@ class DistributorSettingViewController: BaseViewController {
make.top.equalTo(topView.snp_bottom).offset(10)
make.left.equalTo(15)
}
dls()
}
func dls(){
if dataM != nil {
if dataM?.commission_time == 2 {
if dataM?.agent_commission_time_type == 2 {
btm_h.constant = 0
btm_lbl.isHidden = true
btm_btn.setImage(UIImage(named: "daixuan"), for: .normal)
......@@ -89,32 +95,62 @@ class DistributorSettingViewController: BaseViewController {
btm_lbl.isHidden = false
btm_btn.setImage(UIImage(named: "yuxuan"), for: .normal)
}
select_type = (dataM?.commission_time)!
if dataM?.dbt_type == 1 {
select_type = (dataM?.agent_commission_time_type)!
if dataM?.dbt_agent_type == 1 {
typeBtn1 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
typeBtn2 .setImage(UIImage.init(named: "daixuan"), for: .normal)
dbt_type = "1"
}else if dataM?.dbt_type == 2 {
}else if dataM?.dbt_agent_type == 2 {
typeBtn1 .setImage(UIImage.init(named: "daixuan"), for: .normal)
typeBtn2 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
dbt_type = "2"
}
if dataM?.share_type == 1 {
share_intro_lbl.text = "即用户进入分销员发送链接绑定关系,随后所买的分销商品只结算给该绑定分销员"
sharetypeBtn1 .setImage(UIImage.init(named: "daixuan"), for: .normal)
sharetypeBtn2 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
share_type = "1"
}else if dataM?.share_type == 2 {
sharetypeBtn1 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
sharetypeBtn2 .setImage(UIImage.init(named: "daixuan"), for: .normal)
share_intro_lbl.text = "即用户在哪个链接购买分销商品就结算给哪个发送链接的分销员"
share_type = "2"
}
}
}
}
func fxs(){
if dataM?.commission_time_type == 2 {
btm_h.constant = 0
btm_lbl.isHidden = true
btm_btn.setImage(UIImage(named: "daixuan"), for: .normal)
top_h.constant = 36.5
top_lbl.isHidden = false
top_btn.setImage(UIImage(named: "yuxuan"), for: .normal)
}else{
top_h.constant = 0
top_lbl.isHidden = true
top_btn.setImage(UIImage(named: "daixuan"), for: .normal)
btm_h.constant = 36.5
btm_lbl.isHidden = false
btm_btn.setImage(UIImage(named: "yuxuan"), for: .normal)
}
select_type = (dataM?.commission_time_type)!
if dataM?.dbt_type == 1 {
typeBtn1 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
typeBtn2 .setImage(UIImage.init(named: "daixuan"), for: .normal)
dbt_type = "1"
}else if dataM?.dbt_type == 2 {
typeBtn1 .setImage(UIImage.init(named: "daixuan"), for: .normal)
typeBtn2 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
dbt_type = "2"
}
if dataM?.share_type == 1 {
share_intro_lbl.text = "即用户进入分销员发送链接绑定关系,随后所买的分销商品只结算给该绑定分销员"
sharetypeBtn1 .setImage(UIImage.init(named: "daixuan"), for: .normal)
sharetypeBtn2 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
share_type = "1"
}else if dataM?.share_type == 2 {
sharetypeBtn1 .setImage(UIImage.init(named: "yuxuan"), for: .normal)
sharetypeBtn2 .setImage(UIImage.init(named: "daixuan"), for: .normal)
share_intro_lbl.text = "即用户在哪个链接购买分销商品就结算给哪个发送链接的分销员"
share_type = "2"
}
}
@IBOutlet weak var typeBtn1: UIButton!
@IBOutlet weak var typeBtn2: UIButton!
......@@ -152,14 +188,27 @@ class DistributorSettingViewController: BaseViewController {
//保存
HUD.flash(.progress)
let UserToken = UserDefaults.standard.value(forKey: "user_token")
//分账方式 1人工结算 2自动结算 分享方式 1(1对1结算)2(1对多结算)
setDbtRule(["user_token":UserToken as Any,"dbt_type":dbt_type as Any,"commission_time":select_type as Any,"share_type":share_type as Any]) { (data) in
HUD.hide()
HUD.flash(.labeledSubSuccess(subtitle: "提交成功"), delay: 1.2)
} failture: { (error) in
if dl_setting_view.isHidden == true {
setDbtRule(["user_token":UserToken as Any,"dbt_type":dbt_type as Any,"commission_time_type":select_type as Any,"share_type":share_type as Any,"object":2 as Any]) {[self] (data) in
HUD.hide()
dataM?.share_type = Int(share_type)
dataM?.dbt_type = Int(dbt_type)
dataM?.commission_time_type = select_type
HUD.flash(.labeledSubSuccess(subtitle: "提交成功"), delay: 1.2)
} failture: { (error) in
}
}else{
setDbtRule(["user_token":UserToken as Any,"dbt_type":dbt_type as Any,"commission_time_type":select_type as Any,"object":1 as Any]) {[self] (data) in
HUD.hide()
dataM?.agent_commission_time_type = Int(select_type)
dataM?.dbt_agent_type = Int(dbt_type)
HUD.flash(.labeledSubSuccess(subtitle: "提交成功"), delay: 1.2)
} failture: { (error) in
}
}
}
}
......@@ -730,9 +730,17 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
self.navigationController?.pushViewController(vc, animated: true)
return
case 155://分销分账管理
let vc = DistributorSettingViewController()
vc.titleStr = "分销分账管理"
self.navigationController?.pushViewController(vc, animated: true)
HUD.flash(.progress)
let UserToken = UserDefaults.standard.value(forKey: "user_token")
getDbtRule(["user_token":UserToken as Any]) { (data) in
let model = data as! getDbtRuleModel
let vc = DistributorSettingViewController()
vc.titleStr = "分销分账管理"
vc.dataM = model.data
self.navigationController?.pushViewController(vc, animated: true)
} failture: { (err) in
}
return
case 156://分销客户管理
let vc = KHXQ_ViewController()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment