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

namespace app\admin\controller\bbfxshop\capitalpool;

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\Capitalpool;
    }
    
    public function set(){
        $params = $this->param();
        
        $config = Db::name("bbfx_capitalpool")->where(["uniacid"=>UNIACID])->find();
        
        $data = array(
            "uniacid"=>UNIACID,
            "status"=>$params['status'],
            // "abonus_money"=>max(0,round($params['abonus_money'],2)),
            "capital_rate"=>max(0,intval($params['capital_rate'])),
            "capital_settlement_type"=>intval($params['capital_settlement_type']),
            "capital_settlement_order"=>max(0,intval($params['capital_settlement_order'])),
            "manual_abonus"=>iserializer($params['manual_abonus']),
            // "abonus_money"=>max(0,round($params['abonus_money'],2)),
            // "settlement_type"=>intval($params['settlement_type']),
        );
        
    	if(!empty($config)){
          	$res = Db::name("bbfx_capitalpool")->where(["id"=>$config['id']])->update($data);;
        }
      	else{
        	$res = Db::name("bbfx_capitalpool")->insert($data);
        }
        
        
        if($res){
            \app\admin\model\AdminLog::record("","",$data,"bbfx_capitalpool");
            __success("编辑成功",$data);
        }
      	else{
      	    __success("操作成功",$data);
      	}
    }
    
}