From 87f3ff0ba80f271c0d9e5f43ebed9c042b284340 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 13 Sep 2023 17:48:44 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=95=86=E6=88=B7=E5=90=88=E5=90=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ShopContractController.php | 145 +++++++++++++++++ app/adminapi/lists/ShopContractLists.php | 77 +++++++++ app/adminapi/logic/ShopContractLogic.php | 153 ++++++++++++++++++ .../validate/ShopContractValidate.php | 94 +++++++++++ app/api/controller/JunziqianController.php | 20 +++ app/common/model/ShopContract.php | 34 ++++ 6 files changed, 523 insertions(+) create mode 100644 app/adminapi/controller/ShopContractController.php create mode 100644 app/adminapi/lists/ShopContractLists.php create mode 100644 app/adminapi/logic/ShopContractLogic.php create mode 100644 app/adminapi/validate/ShopContractValidate.php create mode 100644 app/common/model/ShopContract.php diff --git a/app/adminapi/controller/ShopContractController.php b/app/adminapi/controller/ShopContractController.php new file mode 100644 index 000000000..7fc1b68b2 --- /dev/null +++ b/app/adminapi/controller/ShopContractController.php @@ -0,0 +1,145 @@ +dataLists(new ShopContractLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function add() + { + $params = (new ShopContractValidate())->post()->goCheck('add'); + $result = ShopContractLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ShopContractLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function edit() + { + $params = (new ShopContractValidate())->post()->goCheck('edit'); + $result = ShopContractLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ShopContractLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function delete() + { + $params = (new ShopContractValidate())->post()->goCheck('delete'); + ShopContractLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function detail() + { + $params = (new ShopContractValidate())->goCheck('detail'); + $result = ShopContractLogic::detail($params); + return $this->data($result); + } + + public function wind_control() + { + $params = Request::param(); + $file = $params['file']; + $res = ShopContract::where('id', $params['id'])->update(['file' => $file, 'check_status' => 2]); + if ($res) { + $find = ShopContract::where('id', $params['id'])->field('type,party_b,party_a') + ->find()->toArray(); + + $find['party_a_info'] = ShopMerchant::where('id', $find['party_a'])->field('company_name name,master_phone phone')->find()->toArray(); + $find['party_b_info'] = ShopMerchant::where('id', $find['party_b'])->field('company_name name,master_phone 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('上传失败'); + } + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/ShopContractLists.php b/app/adminapi/lists/ShopContractLists.php new file mode 100644 index 000000000..39bbdf520 --- /dev/null +++ b/app/adminapi/lists/ShopContractLists.php @@ -0,0 +1,77 @@ + ['contract_no', 'party_a', 'party_b', 'check_status'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function lists(): array + { + return ShopContract::where($this->searchWhere) + ->field(['id', 'contract_no', 'party_a', 'party_b', 'area_manager', 'type', 'evidence_url', 'check_status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function count(): int + { + return ShopContract::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/ShopContractLogic.php b/app/adminapi/logic/ShopContractLogic.php new file mode 100644 index 000000000..d89516aad --- /dev/null +++ b/app/adminapi/logic/ShopContractLogic.php @@ -0,0 +1,153 @@ + $params['contract_no'], + 'type' => $params['type'], + 'contract_url' => $params['contract_url'], + 'evidence_url' => $params['evidence_url'], + 'url' => $params['url'], + 'signing_timer' => $params['signing_timer'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ShopContract::where('id', $params['id'])->update([ + 'file' => $params['file'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public static function delete(array $params): bool + { + return ShopContract::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public static function detail($params): array + { + $data = Db::name('shop_contract')->where('id', $params['id']) + ->withAttr('party_b_info', function ($value, $data) { + + $field = ['id,company_name,company_type,company_type company_type_name,organization_code, + province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name, + qualification']; + $shopMerchant = ShopMerchant::where(['id' => $data['party_b']])->field($field)->find()->toArray(); + return $shopMerchant; + }) + ->withAttr('party_a_info', function ($value, $data) { + $field = ['id,company_name,company_type,company_type company_type_name,organization_code, + province,city,area,street,village,brigade,address,province province_name,city city_name,area area_name,street street_name,village village_name,brigade brigade_name,master_phone,master_name, + qualification']; + $shopMerchant = ShopMerchant::where(['id' => $data['party_a']])->field($field)->find()->toArray(); + + return $shopMerchant; + }) + ->withAttr('status_name', function ($value, $data) { + return $data['status'] == 1 ? '已签约' : '未签约'; + }) + ->find(); + dd($data); + $data['signed_contract_url'] = self::getSignedContract($data); + return $data; + } + + public static function getSignedContract($contract) + { + $signedContractUrl = ''; + if($contract['status'] == 1){ + if ($contract['contract_url'] == '') { + $res = app(JunziqianController::class)->download_shop_file($contract['contract_no'])->getData(); + if ($res['code'] == 1) { + $signedContractUrl = $res['data']['url']; + } + }else { + $signedContractUrl = env('url.url_prefix').$contract['contract_url']; + } + } + return $signedContractUrl; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/ShopContractValidate.php b/app/adminapi/validate/ShopContractValidate.php new file mode 100644 index 000000000..4b7b4e6fe --- /dev/null +++ b/app/adminapi/validate/ShopContractValidate.php @@ -0,0 +1,94 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return ShopContractValidate + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return ShopContractValidate + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return ShopContractValidate + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ShopContractValidate + * @author likeadmin + * @date 2023/09/13 17:01 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/api/controller/JunziqianController.php b/app/api/controller/JunziqianController.php index 4ac9b4796..89e4bcdaf 100644 --- a/app/api/controller/JunziqianController.php +++ b/app/api/controller/JunziqianController.php @@ -332,6 +332,26 @@ class JunziqianController extends BaseApiController return $this->fail('获取失败'); } } + public function download_shop_file($applyNo) + { + $requestUtils = new RequestUtils($this->serviceUrl, $this->appkey, $this->appSecret); + $find = Db::name('contract')->where('contract_no', $applyNo)->value('contract_url'); + if ($find) { + return $this->success('获取成功', ['url' => env('url.url_prefix') . $find]); + } + //初始化请求参数 + $request = array( + "applyNo" => $applyNo, //TODO + + ); + $response = $requestUtils->doPost("/v2/sign/linkFile", $request); + if ($response->success == true) { + $this->getDownload($response->data, root_path() . 'public/uploads/contract/' . $applyNo . '.pdf'); + Db::name('shop_contract')->where('contract_no', $applyNo)->update(['contract_url' => '/uploads/contract/' . $applyNo . '.pdf']); + return $this->success('获取成功', ['url' => env('url.url_prefix') . '/uploads/contract/' . $applyNo . '.pdf']); + } else { + return $this->fail('获取失败'); + } + } /** * 保全后合同文件及证据包下载 */ diff --git a/app/common/model/ShopContract.php b/app/common/model/ShopContract.php new file mode 100644 index 000000000..08f58008e --- /dev/null +++ b/app/common/model/ShopContract.php @@ -0,0 +1,34 @@ +