dao = $dao; } /** * Common: 查询模型 * Author: wu-hui * Time: 2024/01/30 14:46 * @param $where * @return \crmeb\basic\BaseModel */ public function searchModel($where){ return $this->dao->searchModel($where); } /** * Common: 获取列表信息 * Author: wu-hui * Time: 2024/01/30 15:13 * @param $search * @param $page * @param $limit * @param string $field * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getList($search, $page, $limit, $field = '*'){ $query = $this->dao->searchModel($search); $list = $query ->field($field) ->order('create_time desc,id desc') ->page($page, $limit) ->select(); $count = $query->count(); return compact('count', 'list'); } /** * Common: 获取单条信息 * Author: wu-hui * Time: 2024/01/30 17:34 * @param $search * @return array */ public function getSingleInfo($search){ return $this->dao->searchModel($search)->findOrEmpty()->toArray(); } /** * Common: 添加申请信息 * Author: wu-hui * Time: 2024/01/30 14:28 * @param array $data * @return mixed */ public function createApplyInfo(array $data){ return $this->transaction(function() use ($data){ // 添加供应商申请信息 $relation_id = $this->dao->save($data['applyInfo'])->id; if(!$relation_id) throw new AdminException('申请失败'); return $relation_id; }); } /** * Common: 修改编辑信息 * Author: wu-hui * Time: 2024/01/30 18:07 * @param array $data * @return mixed */ public function editApplyInfo(array $data){ return $this->transaction(function() use ($data){ // 修改供应商申请信息 $data['applyInfo']['status'] = 0; $data['applyInfo']['reason'] = ''; $res = $this->dao->update($data['supplierApplyId'],$data['applyInfo']); if(!$res) throw new AdminException('申请信息修改失败'); return true; }); } /** * Common: 审核通过的操作 * Author: wu-hui * Time: 2024/01/30 16:54 * @param $params * @return mixed */ public function toExaminePass($params){ return $this->transaction(function() use ($params){ // 修改状态 $this->update($params['id'],['status'=>$params['status']]); // 自动生成账号信息 $applyInfo = $this->searchModel(['id'=>$params['id']])->findOrEmpty()->toArray(); app()->make(SystemSupplierServices::class)->create([ 'accountInfo' => [ 'supplier_name' => $applyInfo['winery_name'], 'detailed_address' => '', 'name' => $applyInfo['contacts_name'], 'phone' => $applyInfo['contacts_phone'], 'is_show' => 1, 'invite_agent_id' => $applyInfo['agent']['id'] ?? 0, 'invite_uid' => $applyInfo['agent']['uid'] ?? 0, ], 'accountPassword' => [ 'supplier_account' => $applyInfo['contacts_phone'], 'supplier_password' => substr($applyInfo['contacts_phone'],-6), ], ]); }); } }