<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SetmoneyType extends Model
{
    protected $table = 'setmoney_type';
    // 拒绝添加的字段
    protected $guarded = [];
    public $timestamps=false;
    protected $primaryKey = 'sety_id';



    /**|---------------------------------------------------------------------------------
     * @name  获取拒单、撤单原因
     * @param $param
     * @return \Illuminate\Http\JsonResponse
     * |---------------------------------------------------------------------------------
     */
    public function get_compass_reason ($param)
    {
        $afs_type = $param['afs_type']??"";
        if ($afs_type == 1){//退单
            $list = self::whereIn('lt_parent_id',['31','39'])->select('sety_name','sety_id')->get()->toArray();
        }elseif($afs_type == 2){//拒单
            $list = self::where('lt_parent_id','25')->select('sety_name','sety_id')->get()->toArray();
        }else{
            return response()->json(['Data'=>[],'ErrorCode'=>3,'ErrorMessage'=>'缺少参数']);exit;
        }
        if (isset($list)){
            $data['list'] = $list;
            return response()->json(['Data'=>$data,'ErrorCode'=>1,'ErrorMessage'=>'成功']);exit;
        }else{
            return response()->json(['Data'=>[],'ErrorCode'=>2,'ErrorMessage'=>'无数据']);exit;
        }

    }
}
