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

namespace app\admin\controller\bbfxshop\pingji;

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\Pingji;
    }
    
    public function set(){
        $params = $this->param();
        
        $config = Db::name("bbfx_pingji")->where(["uniacid"=>UNIACID])->find();
        
        $data = array(
            "uniacid"=>UNIACID,
            "status"=>intval($params['status']),
            "pingji_calculate"=>intval($params['pingji_calculate']),
            "pingji_type"=>intval($params['pingji_type']),
            "pingji_layer"=>max(1,intval($params['pingji_layer'])),
            "pingji_reward_num"=>intval($params['pingji_reward_num']),
            "zhitui_pingji"=>intval($params['zhitui_pingji']),
            "limit_num"=>max(0,intval($params['limit_num'])),
        );
        
    	if(!empty($config)){
          	$res = Db::name("bbfx_pingji")->where(["id"=>$config['id']])->update($data);;
        }
      	else{
        	$res = Db::name("bbfx_pingji")->insert($data);
        }
        
        
        if($res){
            \app\admin\model\AdminLog::record("","",$data,"bbfx_pingji");
            __success("编辑成功",$data);
        }
      	else{
      	    __success("操作成功",$data);
      	}
    }
}