100 lines
3.0 KiB
PHP
100 lines
3.0 KiB
PHP
<?php
|
|
namespace app\services\supplier;
|
|
|
|
use app\dao\supplier\SystemSupplierApplyDao;
|
|
use app\services\BaseServices;
|
|
use crmeb\exceptions\AdminException;
|
|
|
|
class SystemSupplierApplyServices extends BaseServices{
|
|
|
|
public function __construct(SystemSupplierApplyDao $dao){
|
|
$this->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 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 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),
|
|
],
|
|
]);
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|