This commit is contained in:
mkm 2023-07-17 00:09:53 +08:00
parent b55f77d5c3
commit ac32b7b11a
7 changed files with 101 additions and 52 deletions

View File

@ -0,0 +1,34 @@
<?php
namespace app\adminapi\controller;
use think\facade\Db;
class CommonController extends BaseAdminController
{
public array $notNeedLogin = ['city', 'area', 'street'];
//**省列表 */
public function province()
{
$data = Db::name('geo_province')->where(['switch' => 1])->select();
return $this->data($data->toArray());
} //**市列表 */
public function city($city)
{
$data = Db::name('geo_city')->where(['province_code' => $city])->select();
return $this->data($data->toArray());
}
//**区域列表 */
public function area($area)
{
$data = Db::name('geo_area')->where(['city_code' => $area])->select();
return $this->data($data->toArray());
}
//**街道列表 */
public function street($street)
{
$data = Db::name('geo_street')->where(['area_code' => $street])->select();
return $this->data($data->toArray());
}
}

View File

@ -52,6 +52,8 @@ class CompanyController extends BaseAdminController
public function add()
{
$params = (new CompanyValidate())->post()->goCheck('add');
$params['other_contacts']=json_encode($params['other_contacts']);
$params['qualification']=json_encode($params['qualification']);
$result = CompanyLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
@ -69,6 +71,8 @@ class CompanyController extends BaseAdminController
public function edit()
{
$params = (new CompanyValidate())->post()->goCheck('edit');
$params['other_contacts']=json_encode($params['other_contacts']);
$params['qualification']=json_encode($params['qualification']);
$result = CompanyLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);

View File

@ -40,30 +40,43 @@ class CompanyLogic extends BaseLogic
{
Db::startTrans();
try {
Company::create([
'level_two' => $params['level_two'],
'level_one' => $params['level_one'],
$data=Company::create([
// 'level_two' => $params['level_two'],
// 'level_one' => $params['level_one'],
'company_name' => $params['company_name'],
'organization_code' => $params['organization_code'],
'province' => $params['province'],
'city' => $params['city'],
'area' => $params['area'],
'street' => $params['street'],
'address' => $params['address'],
'company_type' => $params['company_type'],
'master_name' => $params['master_name'],
'master_position' => $params['master_position'],
'master_phone' => $params['master_phone'],
'master_email' => $params['master_email'],
'other_contacts' => $params['other_contacts'],
'area_manager' => $params['area_manager'],
'is_contract' => $params['is_contract'],
'account' => $params['account'],
'password' => $params['password'],
'deposit' => $params['deposit'],
'deposit_time' => $params['deposit_time'],
// 'area_manager' => $params['area_manager'],
// 'is_contract' => $params['is_contract'],
// 'account' => $params['account'],
// 'password' => $params['password'],
// 'deposit' => $params['deposit'],
// 'deposit_time' => $params['deposit_time'],
'qualification' => $params['qualification'],
'status' => $params['status']
// 'status' => $params['status']
]);
$contract=$params['contract'];
$datas=[
'company_id'=>$data['id'],
'contract_type'=>$contract['contract_type'],
'contract_no'=>time(),
'file'=>$contract['file'],
'create_time'=>time(),
'update_time'=>time(),
'party_a'=>$contract['party_a'],
'party_b'=>$data['id'],
];
Db::name('contract')->insert($datas);
Db::commit();
return true;
} catch (\Exception $e) {
@ -86,34 +99,46 @@ class CompanyLogic extends BaseLogic
Db::startTrans();
try {
Company::where('id', $params['id'])->update([
'level_two' => $params['level_two'],
'level_one' => $params['level_one'],
// 'level_two' => $params['level_two'],
// 'level_one' => $params['level_one'],
'company_name' => $params['company_name'],
'organization_code' => $params['organization_code'],
'province' => $params['province'],
'city' => $params['city'],
'area' => $params['area'],
'street' => $params['street'],
'address' => $params['address'],
'company_type' => $params['company_type'],
'master_name' => $params['master_name'],
'master_position' => $params['master_position'],
'master_phone' => $params['master_phone'],
'master_email' => $params['master_email'],
'other_contacts' => $params['other_contacts'],
'area_manager' => $params['area_manager'],
'is_contract' => $params['is_contract'],
'account' => $params['account'],
'password' => $params['password'],
'deposit' => $params['deposit'],
'deposit_time' => $params['deposit_time'],
// 'area_manager' => $params['area_manager'],
// 'is_contract' => $params['is_contract'],
// 'account' => $params['account'],
// 'password' => $params['password'],
// 'deposit' => $params['deposit'],
// 'deposit_time' => $params['deposit_time'],
'qualification' => $params['qualification'],
'status' => $params['status']
// 'status' => $params['status']
]);
$contract=$params['contract'];
$datas=[
'company_id'=>$params['id'],
'contract_type'=>$contract['contract_type'],
'contract_no'=>time(),
'file'=>$contract['file'],
'update_time'=>time(),
'party_a'=>$contract['party_a'],
'party_b'=>$params['id'],
];
Db::name('contract')->insert($datas);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
self::setError($e->getMessage(), $e->getFile());
return false;
}
}
@ -141,6 +166,17 @@ class CompanyLogic extends BaseLogic
*/
public static function detail($params): array
{
return Company::findOrEmpty($params['id'])->toArray();
$data=Company::findOrEmpty($params['id'])->toArray();
if($data){
$data['other_contacts']=json_decode($data['other_contacts'],true);
$data['qualification']=json_decode($data['qualification'],true);
$data['contract']=Db::name('contract')->where('company_id',$data['id'])
->withAttr('party_a_name',function($value,$data){
return Db::name('company')->where('id',$data['party_a'])->value('company_name');
})
->find();
}
return $data;
}
}

View File

@ -68,7 +68,7 @@ class CompanyValidate extends BaseValidate
*/
public function sceneAdd()
{
return $this->only(['company_name','organization_code','master_name','master_position','master_phone','master_email','account','password']);
return $this->only(['company_name','organization_code','master_name','master_position','master_phone','master_email']);
}
@ -80,7 +80,7 @@ class CompanyValidate extends BaseValidate
*/
public function sceneEdit()
{
return $this->only(['id','company_name','organization_code','master_name','master_position','master_phone','master_email','account','password']);
return $this->only(['id','company_name','organization_code','master_name','master_position','master_phone','master_email']);
}

View File

@ -1,27 +0,0 @@
<?php
namespace app\api\controller;
use think\facade\Db;
class CommonController extends BaseApiController
{
public array $notNeedLogin = ['city','area','street'];
//**省份列表 */
public function city(){
$data = Db::name('geo_city')->where(['city_id'=>259])->select();
return $this->data($data->toArray());
}
//**区域列表 */
public function area(){
$data = Db::name('geo_area')->where(['city_code'=>510500])->select();
return $this->data($data->toArray());
}
//**街道列表 */
public function street(){
$data = Db::name('geo_street')->where(['area_code'=>510502])->select();
return $this->data($data->toArray());
}
}

View File

@ -26,6 +26,7 @@ use think\response\Json;
*/
class UploadController extends BaseApiController
{
public array $notNeedLogin = ['image'];
/**
* @notes 上传图片

View File

@ -0,0 +1 @@
jvGPsGV8dSY3kiokKm83QbY7p7AzLpoiYRDILKtqxTw.ygZpRA3Elso4JmfhhS2sEZzf8WSBgcsagKxvXavv6_M