From be5c081d3c559cc8af36654e109cfb9c2feb70a1 Mon Sep 17 00:00:00 2001 From: weiz Date: Mon, 6 Nov 2023 16:51:31 +0800 Subject: [PATCH] update --- .../contract/ContractController.php | 76 ++++++++++++++++++- .../contract/VehicleContractController.php | 2 +- ...ongController.php => HetongController.php} | 2 +- app/api/controller/IndexController.php | 1 - 4 files changed, 76 insertions(+), 5 deletions(-) rename app/api/controller/{HeTongController.php => HetongController.php} (98%) diff --git a/app/adminapi/controller/contract/ContractController.php b/app/adminapi/controller/contract/ContractController.php index 950557aa..2d3bb766 100644 --- a/app/adminapi/controller/contract/ContractController.php +++ b/app/adminapi/controller/contract/ContractController.php @@ -3,7 +3,12 @@ use app\adminapi\controller\BaseAdminController; use app\adminapi\lists\contract\ContractLists; + use app\api\logic\SmsLogic; use app\common\logic\contract\ContractLogic; + use app\common\model\company\Company; + use app\common\model\contract\Contract; + use app\common\model\user\WorkerUser; + use think\facade\Db; /** * 合同控制器 @@ -13,16 +18,83 @@ class ContractController extends BaseAdminController { - public function lists() + public function lists(): \think\response\Json { return $this->dataLists(new ContractLists()); } - public function detail() + public function detail(): \think\response\Json { $params = $this->request->get(['id']); $result = ContractLogic::detail($params); return $this->data($result); } + public function wind_control(): \think\response\Json + { + $params = $this->request->param(); + $file = $params['file']; + $res = Contract::where('id', $params['id'])->update(['file' => $file, 'check_status' => 2]); + if ($res) { + $find = Contract::where('id', $params['id'])->with(['party_a_info'])->field('type,party_b,party_a') + ->find()->toArray(); + if ($find['type'] == 1) { + $find['party_b_info'] = Company::where('id', $find['party_b'])->field('company_name name,master_phone phone')->find()->toArray(); + } else { + $find['party_b_info'] = WorkerUser::where('id', $find['party_b'])->field('nickname name,mobile phone')->find()->toArray(); + } + $a = [ + 'mobile' => $find['party_a_info']['master_phone'], + 'name' => $find['party_a_info']['company_name'], + 'scene' => 'WQTZ' + ]; + SmsLogic::contractUrl($a); + $b = [ + 'mobile' => $find['party_b_info']['phone'], + 'name' => $find['party_b_info']['name'], + 'scene' => 'WQTZ' + ]; + SmsLogic::contractUrl($b); + return $this->success('上传成功', [], 1, 1); + } else { + if ($res == 0) { + return $this->success('没有更新', [], 1, 1); + } + return $this->fail('上传失败'); + } + } + + public function postsms() + { + $params = $this->request->param(); + $find = Db::connect('mysql2')->name('la_contract')->where('id', $params['id']) + ->withAttr('contract_type_name', function ($value, $data) { + return Db::connect('mysql2')->name('la_dict_data')->where('id', $data['contract_type'])->value('name'); + }) + ->withAttr('user_info', function ($value, $data) { + if ($data['type'] == 1) { + return Db::connect('mysql2')->name('la_admin')->where('id', $data['party_b'])->field('name,phone')->find(); + } else { + return Db::connect('mysql2')->name('la_user')->where('id', $data['party_b'])->field('nickname name,mobile phone')->find(); + } + }) + ->find(); + if ($find && $find['url'] != '') { + //发送短信 + $sms = [ + 'mobile' => $find['user_info']['phone'], + 'name' => $find['user_info']['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()); + } + } + } + } diff --git a/app/adminapi/controller/contract/VehicleContractController.php b/app/adminapi/controller/contract/VehicleContractController.php index bd284ae4..b11d0a85 100644 --- a/app/adminapi/controller/contract/VehicleContractController.php +++ b/app/adminapi/controller/contract/VehicleContractController.php @@ -192,7 +192,7 @@ 'mobile' => $v['master_phone'], 'name' => $v['fullName'], 'type' => $title, - 'code' => 'api/HeTong/info?id='.$id.'&type='.$v['type'], + 'code' => 'api/Hetong/info?id='.$id.'&type='.$v['type'], 'scene' => 'WQ' ]; $scene = NoticeEnum::getSceneByTag($sms['scene']); diff --git a/app/api/controller/HeTongController.php b/app/api/controller/HetongController.php similarity index 98% rename from app/api/controller/HeTongController.php rename to app/api/controller/HetongController.php index 638bd2ee..392ad6fe 100644 --- a/app/api/controller/HeTongController.php +++ b/app/api/controller/HetongController.php @@ -8,7 +8,7 @@ use think\facade\Db; use think\facade\Log; - class HeTongController extends BaseLikeAdminController + class HetongController extends BaseLikeAdminController { public array $notNeedLogin = ['url','info', 'toFaceCreate', 'notifyOrganizationFaceCreate']; diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 7003d5ef..1fd36a8f 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -3,7 +3,6 @@ namespace app\api\controller; use app\common\enum\notice\NoticeEnum; -use app\common\model\user\User; use think\facade\Log; use think\response\Json;