123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- <?php
- namespace app\user\controller;
- use app\user\model\CompanyType;use app\user\model\Headquarters;
- use app\user\model\SupplierBank;use app\user\model\SupplierContact;
- use think\App;
- use think\facade\Validate;
- class Supplier extends Base{
- public function __construct(App $app) {
- parent::__construct($app);
- $this->model = new \app\user\model\Supplier();
- }
- /** * @param 参数列表如下:
- * - name: 供应商名称
- * - source: 来源
- * - coop_state: 合作状态
- * - category: 类别
- * - delivery_way: 配送方式
- * - level: 级别
- * - supplier_type: 供应商类型
- * - pay_type: 支付方式
- * - registercode: 注册码
- * - registertime: 注册时间
- * - scope: 业务范围
- * - type: 类型
- * - nature: 性质
- * - legaler: 法人
- * - addr: 地址
- * - prove_img: 证明图片
- * - license_img: 供应商图片
- * - contactor: 联系人
- * - mobile: 手机号
- * - telephone: 电话
- * - position: 职位
- * - email: 电子邮件
- * - personid: 负责人id
- */
- public function create(){
- $param = $this->request->only(["name"=>"","source"=>"","coop_state"=>"","category"=>"","delivery_way"=>"",
- "level"=>"","supplier_type"=>"","pay_type"=>"","registercode"=>"","registertime"=>"","scope"=>"","type"=>"",
- "nature"=>"","legaler"=>"","addr"=>"","prove_img"=>"","license_img"=>"","contactor"=>"","mobile"=>"",
- "telephone"=>"","position"=>"","email"=>"",'personid'=>'','lead_prove'=>'','legaler_type'=>'','invoice_code'=>''],"post","trim");
- $valid=Validate::rule([
- 'name|供应商名称' => 'requireIf:license_img,""|max:255',
- 'source|供应商来源' => 'require|number|in:0,1,2',
- 'coop_state|合作状态' => 'require|number|in:0,1',
- 'category|所属类别' => 'require|number|in:0,1',
- 'delivery_way|提供物流方式' => 'require|number|in:0,1',
- 'level|供应商级别' => 'require|number|in:0,1,2',
- 'supplier_type|供应商性质' => 'require|number|in:0,1,2,3,4',
- 'pay_type|付款方式' => 'require|number|in:0,1,2',
- 'registercode|纳税识别编号' => 'requireIf:license_img,""|max:255',
- 'registertime|成立日期' => 'requireIf:license_img,""|max:255',
- 'scope|经营范围' => 'requireIf:license_img,""|max:3000',
- 'type|申请类型' => 'require|number|in:0,1',
- 'nature|公司类型' => 'requireIf:license_img,""|number|in:1,2,3,4,5,6,7,8,9',
- 'legaler|法人' => 'requireIf:license_img,""|max:255',
- 'addr|公司详细地址' => 'requireIf:license_img,""|max:255',
- 'prove_img|资质证明' => 'max:255',
- 'license_img|营业执照' => 'requireIf:name,""|url',
- 'contactor|联系人' => 'require|max:255',
- 'mobile|手机号' => 'require|mobile',
- 'telephone|座机号' => 'max:255',
- 'position|职位' => 'require',
- 'email|邮箱' => 'require|email',
- 'personid|负责人' => 'require|number|gt:0',
- 'legaler_type|纳税人资质' => 'require|number|in:0,1,2,3,4',
- 'invoice_code|纳税人编号' => 'require|max:255',
- 'lead_prove|资质证明' => 'url',
- ]);
- if(!$valid->check($param))return error($valid->getError());
- if ($param['license_img']!=''){
- $Busines = $this->GetBusinessInfoByParam($param['license_img']);
- /**
- * Array of attributes to getter functions (for serialization of requests)
- * registrationNumber - 老版本营业执照对应注册号。 - 新三证合一版本营业执照对应社会保障号。
- * name 企业名称。
- * type 公司/企业类型/主体类型/类型。
- * address 住所/营业场所/企业住所/主要经营场所/经营场所。
- * legalRepresentative 法定代表人/负责人/执行事务合伙人/投资人/经营者。
- * registeredCapital 注册资本/出资额。
- * organizationForm 组成形式。
- * foundDate 成立日期/注册日期。
- * businessTerm 营业期限。
- * businessScope 经营范围。
- * issueDate 发照日期。
- * confidence 相关字段的置信度信息,置信度越大,表示本次识别的对应字段的可靠性越高,在统计意义上,置信度越大,准确率越高。 置信度由算法给出,不直接等价于对应字段的准确率。
- * @var string[]
- */
- if($Busines['isResult']){
- $result = $Busines['data'];
- $param['ocr_status'] = 1;
- if ($param['name'] != $result['name']) {
- $param['remark'] = '企业名称与营业执照不匹配';
- }
- if ($param['registercode'] !=$result['registration_number']&& $param['registercode']!= '') {
- $param['remark'] .= '企业纳税识别号与营业执照不匹配';
- }
- $param['addr']=$result['address']??"";
- $param['legaler']=$result['legal_representative']??"";
- $param['registercode']=$result['registration_number']??"";
- $param['registertime']=$result['found_date']??"";
- $param['scope']=$result['business_scope']??"";
- $param['nature']= CompanyType::checkType($result['type']);
- $param['capital'] = $result['registered_capital']??"";
- $param['status'] = $param['registercode']==$param['invoice_code']?1:0;
- }else{
- $param['remark'] = '营业执照识别失败';
- $param['ocr_status'] = 2;
- }
- }
- $this->model->startTrans();
- try{
- $data=[
- 'code'=>makeNo('QS'),
- 'person'=>\app\user\model\User::where('account_id','=',$param['personid'])->value('nickname',''),
- 'creater'=>$this->uname,
- 'createrid'=>$this->uid
- ];
- $create = \app\user\model\Supplier::create(array_merge($data,$param));
- if($create->isEmpty())throw new \Exception('供应商创建失败');
- $contact=[
- "code"=>$data['code'],
- "contactor"=>$param['contactor'],
- "mobile"=>$param['mobile'],
- "position"=>$param['position'],
- "telephone"=>$param["telephone"],
- "email"=>$param['email'],
- ];
- $contactC= SupplierContact::create($contact);
- if ($contactC->isEmpty())throw new \Exception("供应商联系人信息创建失败");
- $create->updater=$this->uname;
- $create->updaterid=$this->uid;
- $hqcreate= Headquarters::createInfo($create,3);
- if (!$hqcreate)throw new \Exception("供应商信息创建失败");
- }catch (\Exception $exception){
- $this->model->rollback();
- return error($exception->getMessage());
- }
- $this->model->commit();
- return success("创建成功");
- }
- /**
- * 编辑供应商
- * 参数:
- * id 供应商id
- * - name: 供应商名称
- * - source: 来源
- * - coop_state: 合作状态
- * - category: 类别
- * - delivery_way: 配送方式
- * - level: 级别
- * - supplier_type: 供应商类型
- * - pay_type: 支付方式
- * - registercode: 注册码
- * - registertime: 注册时间
- * - scope: 业务范围
- * - type: 类型
- * - nature: 性质
- * - legaler: 法人
- * - addr: 地址
- * - prove_img: 证明图片
- * - supplier_img: 供应商图片
- * - contactor: 联系人
- * - mobile: 手机号
- * - telephone: 电话
- * - position: 职位
- * - email: 电子邮件
- * - personid: 负责人id
- * @return
- */
- public function save(){
- $param = $this->request->param([
- 'id' => '',
- 'coop_state' => '0',
- 'source' => '0',
- 'type' => '0',
- 'category' => '0',
- 'delivery_way' => '0',
- 'supplier_type' => '0',
- 'level' => '0',
- 'pay_type' => '0',
- 'license_img' => '',
- 'prove_img' => '',
- 'contactor' => '',
- 'mobile' => '', // 确保这是经过验证的格式
- 'telephone' => '',
- 'position' => '',
- 'registercode' => '',
- 'name' => '',
- 'email' => '', // 更正了邮箱格式
- 'nature' => '',
- 'addr' => '',
- "capital"=>"",
- 'legaler' => '',
- 'registertime' => '',
- 'scope' => '',
- 'personid' => '','lead_prove'=>'','legaler_type'=>'','invoice_code'=>''],"post",'trim');
- $valid=Validate::rule([
- "id|主键ID"=>"require|number|gt:0",
- 'name|供应商名称' => 'requireIf:license_img,""|max:255',
- 'source|供应商来源' => 'require|number|in:0,1,2',
- 'coop_state|合作状态' => 'require|number|in:0,1',
- 'category|所属类别' => 'require|number|in:0,1',
- 'delivery_way|提供物流方式' => 'require|number|in:0,1',
- 'level|供应商级别' => 'require|number|in:0,1,2',
- 'supplier_type|供应商性质' => 'require|number|in:0,1,2,3,4',
- 'pay_type|付款方式' => 'require|number|in:0,1,2',
- 'registercode|纳税识别编号' => 'requireIf:license_img,""|max:255',
- 'registertime|成立日期' => 'requireIf:license_img,""|max:255',
- 'scope|经营范围' => 'requireIf:license_img,""|max:3000',
- 'type|申请类型' => 'require|number|in:0,1',
- 'nature|公司类型' => 'requireIf:license_img,""|number',
- 'legaler|法人' => 'requireIf:license_img,""|max:255',
- 'addr|公司详细地址' => 'requireIf:license_img,""|max:255',
- 'prove_img|资质证明' => 'url',
- 'license_img|营业执照' => 'requireIf:name,""|url',
- 'contactor|联系人' => 'require|max:255',
- 'mobile|手机号' => 'require|mobile',
- 'telephone|座机号' => 'max:255',
- 'position|职位' => 'require',
- 'email|邮箱' => 'require|email',
- 'personid|负责人' => 'require|number|gt:0',
- 'legaler_type|纳税人资质' => 'require|number|in:0,1,2,3,4',
- 'invoice_code|纳税人编号' => 'require|max:255',
- 'lead_prove|资质证明' => 'url',
- ]);
- if(!$valid->check($param)) return error($valid->getError());
- $info = \app\user\model\Supplier::with(["contactInfo"])->where('id','=',$param['id'])->find();
- if(!$info)return error('供应商不存在');
- $goodUpdateBool=false;
- if($info->personid!=$param['personid'])$goodUpdateBool=true;
- $info->name=$param['name'];
- $info->personid=$param['personid'];
- $info->person=\app\user\model\User::where('account_id','=',$param['personid'])->value('nickname','');
- $info->source=$param['source'];
- $info->type=$param['legaler_type'];
- $info->invoice_code=$param['invoice_code'];
- $info->lead_prove=$param['lead_prove'];
- $info->coop_state=$param['coop_state'];
- $info->category=$param['category'];
- $info->delivery_way=$param['delivery_way'];
- $info->level=$param['level'];
- $info->supplier_type=$param['supplier_type'];
- $info->pay_type=$param['pay_type'];
- $info->type=$param['type'];
- $info->prove_img=$param['prove_img'];
- $info->updater=$this->uname;
- $info->updaterid=$this->uid;
- if($param['license_img']!='' && $info->license_img!=$param['license_img']){
- $info->license_img=$param['license_img'];
- $business = $this->GetBusinessInfoByParam($param['license_img']);
- if($business['isResult']){
- $info->ocr_status = 1;
- $result = $business['data'];
- if ($param['name'] != $result['name']) {
- $info->remark = "企业名称与营业执照不匹配";
- }
- if ($param['registercode'] !=$result['registration_number']&& $param['registercode']!= '') {
- $info->remark .= '企业纳税识别号与营业执照不匹配';
- }
- $param['addr']=$result['address']??'';
- $param['legaler']=$result['legal_representative']??'';
- $param['registercode']=$result['registration_number']??'';
- $param['registertime']=$result['found_date']??'';
- $param['scope']=$result['business_scope']??'';
- $param['nature']=CompanyType::checkType($result['type']);
- $param['capital'] = $result['registered_capital']??'';
- }else{
- $info->remark = '营业执照识别失败';
- $info->ocr_status = 2;
- }
- }
- $info->registercode=$param['registercode'];
- $info->nature=$param['nature'];
- $info->legaler=$param['legaler'];
- $info->registertime=$param['registertime'];
- $info->capital=$param['capital'];
- $info->addr=$param['addr'];
- $info->scope=$param['scope'];
- $info->status=$param['registercode']==$param['invoice_code']?1:0;
- $info->remark .= $param['registercode']==$param['invoice_code']?"":"企业纳税识别号与营业执照不匹配";
- $this->model->startTrans();
- try{
- if($info->save()){
- $contact=[
- 'contactor'=>$param['contactor'],
- 'mobile'=>$param['mobile'],
- 'position'=>$param['position'],
- 'telephone'=>$param['telephone'],
- 'email'=>$param['email'],
- ];
- $contactC=$info->contactInfo->save($contact);
- if (!$contactC)throw new \Exception('供应商联系人信息保存失败');
- $hqcreate= Headquarters::createInfo($info,3);
- if(!$hqcreate)throw new \Exception('供应商信息保存失败');
- }else throw new \Exception('供应商信息保存失败');
- $this->model->commit();
- }catch (\Exception $e){
- $this->model->rollback();
- return error($e->getMessage());
- }
- if($goodUpdateBool)event("updateSupplierGood",["code"=>$info->code,"personid"=>$info->personid,"person"=>$info->person]);
- return success("保存成功!");
- }
- /**
- * 获取供应商列表
- */
- public function list()
- {
- $param=$this->request->param(["page"=>1,"size"=>15,"createrid"=>"","name"=>"","start"=>"","end"=>"",'status'=>'','ocr_status'=>''],"post","trim");
- $where=[["is_del","=",0]];
- if($param['createrid']!='') $where[]=['createrid','=',$param['createrid']];
- if($param['name']!='') $where[]=['name','like',"%".$param['name']."%"];
- if($param['status']!='') $where[]=['status','=',$param['status']];
- if($param['ocr_status']!='') $where[]=['ocr_status','=',$param['ocr_status']];
- if($param['start']!='') $where[]=['addtime','>=',$param['start']];
- if($param['end']!='') $where[]=['addtime','<=',$param['end']];
- $list = $this->model->with(["contactInfo"])->where($where)->order('id desc')
- ->paginate(['page'=>$param['page'],'list_rows'=>$param['size']]);
- return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
- }
- /**
- * 获取供应商详情
- */
- public function info()
- {
- $code=$this->request->param("code");
- if($code=="")return error("参数错误");
- $info = $this->model->with(["contactInfo"])->where('code','=',$code)->findOrEmpty();
- if($info->isEmpty())return error("供应商不存在");
- return success("获取成功",$info);
- }
- /**删除供应商
- * @return
- */
- public function delete()
- {
- $param=$this->request->param(["id"=>""],"post","trim");
- if($param['id']=="")return error("参数错误");
- $info = $this->model->where('id','=',$param['id'])->findOrEmpty();
- if($info->isEmpty())return error("供应商不存在");
- $this->model->startTrans();
- try{
- $info->is_del=1;
- $save=$info->save();
- if(!$save)throw new \Exception('删除失败');
- $header=Headquarters::where('code',$info->code)->findOrEmpty();
- if(!$header->isEmpty()){
- $header->is_del=1;
- $header->updater=$this->uname;
- $header->updaterid=$this->uid;
- $header->save();
- }
- $this->model->commit();
- }catch (\Exception $e){
- $this->model->rollback();
- return error($e->getMessage());
- }
- return success("删除成功");
- }
- /**
- * @return
- */
- public function status()
- {
- $param=$this->request->param(["id"=>"","status"=>""],"post","trim");
- $valid=Validate::check($param,[
- 'id|供应商id'=>'require',
- 'status|状态'=>'require|number|in:0,1',
- ]);
- if($valid!==true)return error(Validate::getError());
- $info = $this->model->where('id','=',$param['id'])->findOrEmpty();
- if($info->isEmpty())return error("供应商不存在");
- if($info->registercode!=""&& $info->invoice_code!=$info->registercode && $param['status']==1) return error("供应商纳税编号不一致");
- $this->model->startTrans();
- try{
- $info->status=$param['status'];
- $save=$info->save();
- if(!$save)throw new \Exception("修改失败");
- $header=Headquarters::where('code',$info->code)->findOrEmpty();
- if(!$header->isEmpty()){
- $header->status=$param['status'];
- $header->updater=$this->uname;
- $header->updaterid=$this->uid;
- $header->save();
- }
- $this->model->commit();
- }catch (\Exception $e){
- $this->model->rollback();
- return error($e->getMessage());
- }
- return success("修改成功");
- }
- /**
- * @param $post
- */
- public function upgrade()
- {
- $post = $this->request->only(['code', 'inv_bank', 'inv_bankNo', 'inv_addr', 'invoice_mobile', 'uid', 'uname', 'invoice_title'], 'post', 'trim');
- $val = Validate::rule([
- 'code|供应商编码' => 'require',
- 'inv_bank|银行名称' => 'require|max:255',
- 'inv_bankNo|银行卡号' => 'require|number',
- 'inv_addr|联系地址' => 'require|max:255',
- 'invoice_mobile' => 'require',
- 'invoice_title|公司抬头' => 'require',
- ]);
- if ($val->check($post) == false) return error($val->getError());
- $supplier = $this->model->with(["contactInfo"])->where([['code',"=", $post['code']],["is_del","=",0]])->findOrEmpty();
- if ($supplier->isEmpty()) return error("供应商不存在");
- if ($supplier->status == 0) return error("供应商未启用");
- if ($supplier->is_upgrade == 1) return error("供应商已升级为业务公司");
- $this->model->startTrans();
- try {
- $post['uid']=$this->uid;
- $post['uname']=$this->uname;
- $up= $this->model->upgrade($post);
- if(!$up)throw new \Exception("升级失败");
- $this->model->commit();
- }catch (\Exception $exception){
- $this->model->rollback();
- return error($exception->getMessage());
- }
- return success("升级成功");
- }
- public function selectQuery()
- {
- $data=[
- "source"=>\app\user\model\Supplier::$source, //供应商来源
- "suptype"=>\app\user\model\Supplier::$suptype, //申请类型
- "coop_state"=>\app\user\model\Supplier::$coop_state,//合作状态
- "pay_type"=>\app\user\model\Supplier::$pay_type,//付款方式
- "delivery_way"=>\app\user\model\Supplier::$delivery_way, //提供物流方式
- "level"=>\app\user\model\Supplier::$level, //供应商级别
- "supplier_type"=>\app\user\model\Supplier::$supplier_type,//供应商性质
- "legaler_type"=>\app\user\model\Supplier::$legaler_type, //纳税人资质 类型
- "nature"=>\app\user\model\CompanyType::where(["is_del"=>0])->order('id', 'desc')->field(["id","company_type","status"])->select()
- ];
- return success("获取成功",$data);
- }
- /**
- * 银行信息添加
- * @param code|供应商编码
- * @param bank_name|银行名称
- * @param contact_name|联系人
- * @param contact_mobile|联系电话
- * @param bank_no|银行卡号
- * @return \think\Response|\think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- public function bankCreate()
- {
- $post = $this->request->only(['code', 'bank_name', 'bank_no', 'contact_name', 'contact_mobile'], 'post', 'trim');
- $val = Validate::rule([
- 'code|供应商编码' => 'require',
- 'bank_name|银行名称' => 'require|max:255',
- 'bank_no|银行卡号' => 'require|number|unique:\app\user\model\supplier_bank,bank_no',
- 'contact_name|联系人' => 'max:255',
- 'contact_mobile|联系电话' => 'mobile',
- ]);
- if ($val->check($post) == false) return error($val->getError());
- $supplier = $this->model->where([['code',"=", $post['code']],["is_del","=",0]])->findOrEmpty();
- if ($supplier->isEmpty()) return error("供应商不存在");
- $data=[
- 'code'=>$post['code'],
- 'bank_name'=>$post['bank_name'],
- 'bank_no'=>$post['bank_no'],
- 'contact_name'=>$post['contact_name'],
- 'contact_mobile'=>$post['contact_mobile'],
- 'apply_name'=>$this->uname,
- 'apply_id'=>$this->uid,
- "status"=>0,
- "is_default"=>SupplierBank::where(["code"=>$post['code']])->count()==0?1:0,
- ];
- SupplierBank::create($data);
- return success("添加成功");
- }
- /**
- * 银行信息删除
- * @param id|供应商银行id
- * @return \think\Response|\think\response\Json|void
- */
- public function bankDelete()
- {
- $post = $this->request->only(['id'], 'post', 'trim');
- $val = Validate::rule([
- 'id|供应商银行id' => 'require',
- ]);
- if ($val->check($post) == false) return error($val->getError());
- $bank = SupplierBank::where([['id',"=", $post['id']]])->findOrEmpty();
- if ($bank->isEmpty()) return error("供应商银行不存在");
- if($bank->is_default==1)return error("默认银行不能删除");
- $bank->delete();
- return success("删除成功");
- }
- /**
- * @param id|供应商银行id
- *@param bank_name|银行名称
- *@param contact_name|联系人
- *@param contact_mobile|联系电话
- *@return \think\Response|\think\response\Json|void
- **/
- public function bankUpdate()
- {
- $post = $this->request->only(['id', 'bank_name', 'bank_no', 'contact_name', 'contact_mobile'], 'post', 'trim');
- $val = Validate::rule([
- 'id|供应商银行id' => 'require',
- 'bank_name|银行名称' => 'require|max:255',
- 'bank_no|银行卡号' => 'require|number|unique:\app\user\model\supplier_bank,bank_no',
- 'contact_name|联系人' => 'max:255',
- 'contact_mobile|联系电话' => 'mobile',
- ]);
- if ($val->check($post) == false) return error($val->getError());
- $bank = SupplierBank::where([['id',"=", $post['id']]])->findOrEmpty();
- if ($bank->isEmpty()) return error("供应商银行不存在");
- $bank->bank_name=$post['bank_name'];
- $bank->bank_no=$post['bank_no'];
- $bank->contact_name=$post['contact_name'];
- $bank->contact_mobile=$post['contact_mobile'];
- $bank->save();
- return success("修改成功");
- }
- /**
- * @param id|供应商银行id
- * @return \think\Response|\think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- public function bankDefault()
- {
- $post = $this->request->only(['id'], 'post', 'trim');
- $val = Validate::rule([
- 'id|供应商银行id' => 'require',
- ]);
- if ($val->check($post) == false) return error($val->getError());
- $bank = SupplierBank::where([['id',"=", $post['id']]])->findOrEmpty();
- if ($bank->isEmpty()) return error("供应商银行不存在");
- SupplierBank::where(["code"=>$bank->code,"is_default"=>1])->update(["is_default"=>0]);
- $bank->is_default=1;
- $bank->save();
- return success("设置成功");
- }
- /**
- * 银行信息列表
- * @param code|供应商编码
- * @param status|状态
- * @param contact_name|联系人
- * @param contact_mobile|联系电话
- * @param page|页码
- * @param size|每页数量
- * @return \think\Response|\think\response\Json|void
- * @throws \think\db\exception\DbException
- */
- public function bankList()
- {
- $post = $this->request->only(['code'=>"","status"=>"","contact_name"=>"","contact_mobile"=>"","page"=>1,"size"=>15], 'post', 'trim');
- $where=[];
- if($post['code']!="")$where[]=["code","=",$post['code']];
- if($post['status']!=="")$where[]=["status","=",$post['status']];
- if($post['contact_name']!="")$where[]=["contact_name","like","%".$post['contact_name']."%"];
- if($post['contact_mobile']!="")$where[]=["contact_mobile","like","%".$post['contact_mobile']."%"];
- $data=SupplierBank::with(['supplier'])->where($where)->order('id', 'desc')
- ->paginate(['list_rows'=>$post['size'],'page'=>$post['page']]);
- return success("获取成功",["list"=>$data->items(),"total"=>$data->total()]);
- }
- /**
- * @param id|供应商银行id
- * @param status|状态
- * @return \think\Response|\think\response\Json|void
- */
- public function bankStatus()
- {
- $post = $this->request->only(['id','status'], 'post', 'trim');
- $val = Validate::rule([
- 'id|供应商银行id' => 'require',
- 'status|状态' => 'require|in:0,1',
- ]);
- if ($val->check($post) == false) return error($val->getError());
- $bank = SupplierBank::where([['id',"=", $post['id']]])->findOrEmpty();
- if ($bank->isEmpty()) return error("供应商银行不存在");
- $bank->status=$post['status'];
- $bank->save();
- return success("修改成功");
- }
- }
|