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

namespace app\admin\controller\bbfxshop\merchant;

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\Merchant;
    }
    
    public function set(){
        $params = $this->param();
        
        $config = Db::name("bbfx_merchant_set")->where(["uniacid"=>UNIACID])->find();
        
        $data = array(
            "uniacid"=>UNIACID,
            "status"=>intval($params['status']),
            "is_fenxiao"=>intval($params['is_fenxiao']),
            "apply_status"=>intval($params['apply_status']),
            "apply_shenhe"=>intval($params['apply_shenhe']),
            "goods_shenhe"=>intval($params['goods_shenhe']),
            "edit_shenhe"=>intval($params['edit_shenhe']),
            "edit_goods_shenhe"=>intval($params['edit_goods_shenhe']),
            "daozhang_type"=>intval($params['daozhang_type']),
            "apply_condition_type"=>intval($params['apply_condition_type']),
      	    "apply_condition"=>iserializer($params['apply_condition']),
      	    "withdrawal"=>iserializer($params['withdrawal']),
      	    "banner"=>replaceSiteroot($params['banner']),
        );
        
    	if(!empty($config)){
          	$res = Db::name("bbfx_merchant_set")->where(["id"=>$config['id']])->update($data);;
        }
      	else{
        	$res = Db::name("bbfx_merchant_set")->insert($data);
        }
        
        
        if($res){
            \app\admin\model\AdminLog::record("","",$data,"bbfx_merchant_set");
            __success("编辑成功",$data);
        }
      	else{
      	    __success("操作成功",$data);
      	}
    }
}