调整位置

This commit is contained in:
mkm 2023-08-03 12:47:20 +08:00
parent 6ec71df1e3
commit 0f0a1f72c2
4 changed files with 105 additions and 118 deletions
app
adminapi/controller
api
common/logic

@ -24,6 +24,7 @@ use app\api\logic\SmsLogic;
use app\common\model\auth\Admin;
use app\common\model\Company;
use think\facade\Db;
use app\common\logic\CompanyLogic as CommonCompanyLogic;
/**
* Company控制器
@ -116,92 +117,38 @@ class CompanyController extends BaseAdminController
$result = CompanyLogic::detail($params);
return $this->data($result);
}
//**发起合同 */
public function initiate_contract()
{
$params = $this->request->param();
$params['party_a'] = $this->adminInfo['company_id'];
$params['type'] = 1;
$result = CommonCompanyLogic::initiate_contract($params);
if ($result == true) {
return $this->success('发起成功,等待平台风控部上传合同');
}
return $this->fail(CommonCompanyLogic::getError());
}
// /**生成合同 */
public function Draftingcontracts()
{
$params = (new CompanyValidate())->goCheck('detail');
$result = CompanyLogic::detail($params);
if ($result && $result['contract'] && $result['contract']['file'] != '') {
$data = [
'name' => $result['company_name'] . '合同',
'signatories' => [['fullName' => $result['company_name'], 'identityType' => 12, 'identityCard' => $result['organization_code'], 'email' => $result['master_email'], 'noNeedVerify' => 1, 'signLevel' => 1]],
'url' => $result['contract']['file']
];
$res = app(JunziqianController::class)->Signing($data,$result['contract']['id']);
if ($res->success == true) {
Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data]);
$company = Db::name('company')->where('id', $params['id'])->find();
if ($company) {
$find = Db::name('contract')->where('party_b', $company['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})->find();
if ($find) {
$data = array(
"applyNo" => $find['contract_no'], //TODO *
"fullName" => $company['company_name'], //TODO *
"identityCard" => $company['organization_code'], //TODO *
"identityType" => 12, //TODO *
);
$res = app(JunziqianController::class)->SigningLink($data);
if ($res->success == true) {
Db::name('contract')->where('id', $find['id'])->update(['url' => $res->data]);
//发送短信
$sms = [
'mobile' => $company['master_phone'],
'name' => $company['company_name'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id='.$find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return $this->success('发送成功');
} else {
return $this->fail(SmsLogic::getError());
}
} else {
return $this->fail($res->msg);
}
}
}
return $this->success('生成合同成功', [], 1, 1);
} else {
return $this->fail($res->msg);
}
} else {
return $this->fail('生成合同成功失败,联系管理员');
$params = $this->request->param();
$result = CommonCompanyLogic::Draftingcontracts($params);
if ($result == true) {
return $this->success('生成合同成功');
}
return $this->fail(CommonCompanyLogic::getError());
}
//**发送短信 */
public function postsms()
{
$params = (new CompanyValidate())->goCheck('detail');
$company = Db::name('company')->where('id', $params['id'])->find();
if ($company) {
$find = Db::name('contract')->where('party_b', $company['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})
->find();
if ($find) {
//发送短信
$sms = [
'mobile' => $company['master_phone'],
'name' => $company['company_name'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id='.$find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return $this->success('发送成功');
} else {
return $this->fail(SmsLogic::getError());
}
}
$res = CommonCompanyLogic::postsms($params);
if ($res == true) {
return $this->success('发送成功', [], 1, 1);
} else {
return $this->fail(CommonCompanyLogic::getError());
}
}
@ -221,7 +168,7 @@ class CompanyController extends BaseAdminController
];
$res = app(JunziqianController::class)->EnterpriseCertification($data);
if ($res->success == true) {
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data,'is_authentication'=>1]);
Db::name('company')->where('id', $params['id'])->update(['master_email' => $res->data, 'is_authentication' => 1]);
return $this->success('认证成功', ['email' => $res->data], 1, 1);
} else {
return $this->fail($res->msg);
@ -271,9 +218,8 @@ class CompanyController extends BaseAdminController
public function subordinate($company_id)
{
$company = Company::findOrEmpty($company_id);
$result = loopGetChild(Company::class, $company->id, 'level_one','company_name,id,company_type,area,area area_name,street,street street_name,is_contract,area_manager,area_manager area_manager_name,master_name,master_phone');
$data['lists']=$result;
$result = loopGetChild(Company::class, $company->id, 'level_one', 'company_name,id,company_type,area,area area_name,street,street street_name,is_contract,area_manager,area_manager area_manager_name,master_name,master_phone');
$data['lists'] = $result;
return $this->success('success', $data);
}
}

@ -26,7 +26,7 @@ class CompanyController extends BaseApiController
[$page, $limit] = $this->getPage();
$myCompany = Company::findOrEmpty($this->userInfo['company_id'])->toArray();
$companyIds = Contract::where('party_a', $myCompany['id'])->column('party_b');
$query = Company::whereIn('id', $companyIds)->where('status',1)->append(['province_name', 'city_name', 'area_name', 'street_name', 'area_manager_name']);
$query = Company::whereIn('id', $companyIds)->where('status', 1)->append(['province_name', 'city_name', 'area_name', 'street_name', 'area_manager_name']);
$count = $query->count();
$companies = $query->page($page)->limit($limit)->select()->each(function ($company) {
$company['other_contacts'] = json_decode($company['other_contacts'], true);
@ -42,7 +42,7 @@ class CompanyController extends BaseApiController
public function unsigned()
{
$myCompany = Company::findOrEmpty($this->userInfo['company_id'])->toArray();
$query = Company::where(['street' => $myCompany['street'], 'company_type' => [17, 18],'is_contract'=>0]);
$query = Company::where(['street' => $myCompany['street'], 'company_type' => [17, 18], 'is_contract' => 0]);
$count = $query->count();
$companies = $query->field('*,street street_name,area area_name,city city_name,province province_name')->select()->toArray();
return $this->success('', ['count' => $count, 'data' => $companies]);
@ -74,7 +74,7 @@ class CompanyController extends BaseApiController
$contract['contract_type_name'] = Db::name('dict_data')->where('id', $contract['contract_type'])->value('name');
}
$company['company_type_name'] = Db::name('dict_data')->where('id', $company['company_type'])->value('name');
$company['day_money_count']=UserAccountLog::where(['company_id'=>$company['id'],'action'=>1])->whereDay('create_time')->sum('change_amount');
$company['day_money_count'] = UserAccountLog::where(['company_id' => $company['id'], 'action' => 1])->whereDay('create_time')->sum('change_amount');
$users = Admin::where('company_id', $company['id'])->field('id,name,account,phone,qualification')->select()->toArray();
foreach ($users as &$user) {
$user['is_main'] = $user['id'] == $company['admin_id'] ? 1 : 0;
@ -100,28 +100,28 @@ class CompanyController extends BaseApiController
public function users()
{
[$page, $limit] = $this->getPage();
$params = $this->request->param();
$params = $this->request->param();
// if($companyId==0){
// $companyId=$this->userInfo['company_id'];
// }
$wehre[]=['company_id','=',$this->userInfo['company_id']];
if(isset($params['is_captain'])&& $params['is_captain']==1){
$wehre[]= ['is_captain','=',1];
$wehre[] = ['company_id', '=', $this->userInfo['company_id']];
if (isset($params['is_captain']) && $params['is_captain'] == 1) {
$wehre[] = ['is_captain', '=', 1];
}
$query = User::where($wehre);
$count = $query->count();
$users = $query->page($page)->limit($limit)->with(['company' => function ($query) {
$query->field('id,company_name');
}])->append(['province_name', 'city_name', 'area_name', 'street_name'])
->field('id,avatar,real_name,account,mobile as phone,province,city,area,street,company_id,qualification,nickname,is_contract,is_captain')
->select()->each(function ($item, $key) {
if ($item['qualification'] != '') {
$item['qualification'] = json_decode($item['qualification'], true);
}
if($item['is_captain']==1){
$item['informationg_count']=UserInformationg::where(['create_user_id'=>$item['id'],'status'=>1])->count();
}
});
->field('id,avatar,real_name,account,mobile as phone,province,city,area,street,company_id,qualification,nickname,is_contract,is_captain')
->select()->each(function ($item, $key) {
if ($item['qualification'] != '') {
$item['qualification'] = json_decode($item['qualification'], true);
}
if ($item['is_captain'] == 1) {
$item['informationg_count'] = UserInformationg::where(['create_user_id' => $item['id'], 'status' => 1])->count();
}
});
return $this->success('success', ['count' => $count, 'data' => $users]);
}
@ -140,26 +140,38 @@ class CompanyController extends BaseApiController
return $this->success('success', $user);
}
//**发起合同 */
public function initiate_contract()
{
$params = $this->request->param();
$params['party_a']=$this->userInfo['company_id'];
$params['type']=1;
$result = CommonCompanyLogic::initiate_contract($params);
if($result==true){
return $this->success('发起成功,等待平台风控部上传合同');
}
return $this->fail(CommonCompanyLogic::getError());
//**发起合同 */
public function initiate_contract()
{
$params = $this->request->param();
$params['party_a'] = $this->userInfo['company_id'];
$params['type'] = 1;
$result = CommonCompanyLogic::initiate_contract($params);
if ($result == true) {
return $this->success('发起成功,等待平台风控部上传合同');
}
// /**生成合同 */
public function Draftingcontracts()
{
$params = $this->request->param();
$result = CommonCompanyLogic::Draftingcontracts($params);
if($result==true){
return $this->success('生成合同成功');
}
return $this->fail(CommonCompanyLogic::getError());
return $this->fail(CommonCompanyLogic::getError());
}
// /**生成合同 */
public function Draftingcontracts()
{
$params = $this->request->param();
$result = CommonCompanyLogic::Draftingcontracts($params);
if ($result == true) {
return $this->success('生成合同成功');
}
return $this->fail(CommonCompanyLogic::getError());
}
//**发送短信 */
public function postsms()
{
$params = $this->request->param();
$res = CommonCompanyLogic::postsms($params);
if ($res == true) {
return $this->success('发送成功', [], 1, 1);
} else {
return $this->fail(CommonCompanyLogic::getError());
}
}
}

@ -74,7 +74,7 @@ class UserLogic extends BaseLogic
*/
public static function info(int $userId)
{
$user = User::where(['id' => $userId])->with(['admin','company'])
$user = User::where(['id' => $userId])->with(['company'])
->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time,user_money,income,admin_id,company_id,is_captain')
->findOrEmpty();
// $user['avatar'] = $user['avatar'] ? Request()->host() . $user['avatar'] : $user['avatar'];

@ -27,7 +27,7 @@ use app\api\controller\JunziqianController;
use app\api\logic\SmsLogic;
/**
* Company逻辑
* 公司逻辑
* Class CompanyLogic
* @package app\adminapi\logic
*/
@ -289,4 +289,33 @@ class CompanyLogic extends BaseLogic
return self::setError('生成合同成功失败,联系管理员');
}
}
//**发送短信 */
public static function postsms($params)
{
$company = Db::name('company')->where('id', $params['id'])->find();
if ($company) {
$find = Db::name('contract')->where('party_b', $company['id'])
->withAttr('contract_type_name', function ($value, $data) {
return Db::name('dict_data')->where('id', $data['contract_type'])->value('name');
})
->find();
if ($find) {
//发送短信
$sms = [
'mobile' => $company['master_phone'],
'name' => $company['company_name'],
'type' => '《' . $find['contract_type_name'] . '》',
'code' => 'api/Hetong/url?id='.$find['id'],
'scene' => 'WQ'
];
$result = SmsLogic::contractUrl($sms);
if (true === $result) {
return true;
} else {
return self::setError(SmsLogic::getError());
}
}
}
}
}