<?php
/*
 本代码由 焕岱科技 创建
 技术支持 WX：15285007200
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace app\admin\controller\bbfxshop\ladderabonus;

use app\admin\controller\bbfxshop\Base;
use think\Db;


class Config extends Base
{

    public $model = null;
    public function _initialize(){
        parent::_initialize();
        $this->model = new \app\common\model\bbfxshop\Ladderabonus;
    }
    
    public function set(){
        $params = $this->param();
        
        $config = Db::name("bbfx_ladderabonus")->where(["uniacid"=>UNIACID])->find();
        
        $data = array(
            "uniacid"=>UNIACID,
            "status"=>intval($params['status']),
            "is_ladder_abonus_gld"=>intval($params['is_ladder_abonus_gld']),
            "ladder_abonus_mode"=>intval($params['ladder_abonus_mode']),
            "is_deduct_daquachievement"=>intval($params['is_deduct_daquachievement']),
      	    "ladder_abonus"=>iserializer($params['ladder_abonus']),
      	    "ladder_abonus_multiple"=>iserializer($params['ladder_abonus_multiple']),
            "is_ladder_abonus_pingji"=>intval($params['is_ladder_abonus_pingji']),
            "ladder_abonus_pingji_rate"=>intval($params['ladder_abonus_pingji_rate']),
      	    "settlement_abonus_stype"=>intval($params['settlement_abonus_stype']),
        );
        
    	if(!empty($config)){
          	$res = Db::name("bbfx_ladderabonus")->where(["id"=>$config['id']])->update($data);;
        }
      	else{
        	$res = Db::name("bbfx_ladderabonus")->insert($data);
        }
        
        
        if($res){
            \app\admin\model\AdminLog::record("","",$data,"bbfx_ladderabonus");
            __success("编辑成功",$data);
        }
      	else{
      	    __success("操作成功",$data);
      	}
    }
}