select('product_template_type')->first(); $template_type = 2; if($res){ return $template_type = $res->product_template_type; } if(in_array($template_type,[1,2])){ return $template_type; } return 2; } /** * 更新或者设置类型 * @param int $distribution_channel_id * @param int $type * @return bool */ public static function setPayTemplate(int $distribution_channel_id,int $type){ if(!in_array($type,[1,2])){ return false; } $res = PayTemplate::where('distribution_channel_id',$distribution_channel_id)->first(); if($res){ if($res->product_template_type == $type){ return false; } $res->product_template_type = $type; $res->save(); return true; } PayTemplate::create([ 'product_template_type'=>$type, 'distribution_channel_id'=>$distribution_channel_id ]); return true; } }