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

namespace app\admin\controller\bbfxshop\tongue_diagnosis;

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\TongueDiagnosis;
    }
    
    public function set(){
        $params = $this->param();
        
        $config = Db::name("bbfx_tongue_diagnosis")->where(["uniacid"=>UNIACID])->find();
        
        $data = array(
            "uniacid"=>UNIACID,
            "status"=>$params['status'],
            "appcode"=>$params['appcode'],
            "main_recommendation_goods"=>$params['main_recommendation_goods'],
            "huoqu_num_method"=>implode(',',$params['huoqu_num_method']),
            "buy_rule"=>iserializer($params['buy_rule']),
            "instructions"=>htmlspecialchars_decode($this->param('instructions/h')),
        );
        
    	if(!empty($config)){
          	$res = Db::name("bbfx_tongue_diagnosis")->where(["id"=>$config['id']])->update($data);;
        }
      	else{
        	$res = Db::name("bbfx_tongue_diagnosis")->insert($data);
        }
        
        \app\admin\model\AdminLog::record("","",$data,"bbfx_tongue_diagnosis");
        __success("编辑成功",$data);
    }
    
    
    public function getGoodsList(){
        $list = Db::name("bbfx_goods")->where(['uniacid'=>UNIACID,'status'=>1,'mid'=>0,'plugin_tongue_diagnosis'=>1])->field("id,title,thumb,price")->select();
        foreach($list as $key => $val){
            $val['thumb'] = cdnurl($val['thumb']);
        }
        unset($val);

        __success("操作成功",['list'=>$list]);
    }
}