diff --git a/app/api/controller/UserController.php b/app/api/controller/UserController.php index 152948d5b..28e0c299e 100755 --- a/app/api/controller/UserController.php +++ b/app/api/controller/UserController.php @@ -169,21 +169,35 @@ class UserController extends BaseApiController public function initiate_contract() { $params = $this->request->param(); - $admin_id=Db::name('user')->where('id',$this->userId)->value('admin_id'); - $result = CommonUserLogic::initiate_contract($params,$admin_id); - if($result==true){ + $admin_id = Db::name('user')->where('id', $this->userId)->value('admin_id'); + $result = CommonUserLogic::initiate_contract($params, $admin_id); + if ($result == true) { return $this->success('发起成功,等待平台风控部上传合同'); } - return $this->fail(CommonUserLogic::getError()); + return $this->fail(CommonUserLogic::getError()); } // /**生成合同 */ public function Draftingcontracts() { $params = $this->request->param(); $result = CommonUserLogic::Draftingcontracts($params); - if($result==true){ + if ($result == true) { return $this->success('生成合同成功'); } - return $this->fail(CommonUserLogic::getError()); + return $this->fail(CommonUserLogic::getError()); + } + + //**发送短信 */ + public function postsms() + { + $params = $this->request->param(); + $params['mobile']=$this->userInfo['mobile']; + $params['nickname']=$this->userInfo['nickname']; + $res = CommonUserLogic::postsms($params); + if ($res == true) { + return $this->success('发送成功', [], 1, 1); + } else { + return $this->fail(CommonUserLogic::getError()); + } } } diff --git a/app/common/logic/UserLogic.php b/app/common/logic/UserLogic.php index 334f72ec3..441fabdcb 100755 --- a/app/common/logic/UserLogic.php +++ b/app/common/logic/UserLogic.php @@ -54,7 +54,7 @@ class UserLogic extends BaseLogic // $user->sex = $user->getData('sex'); $user['qualification'] = json_decode($user->qualification, true); // if ($user->is_contract == 1) { - $user['contract'] = Contract::where(['type' => 2, 'party_b' => $userId])->with(['partyA', 'contractType'])->find(); + $user['contract'] = Contract::where(['type' => 2, 'party_b' => $userId])->with(['partyA', 'contractType'])->find(); // } return $user->toArray(); } @@ -143,7 +143,7 @@ class UserLogic extends BaseLogic $result = self::detail($params['id']); if ($result && $result['contract'] && $result['contract']['file'] != '') { - if($result['contract']['check_status']==3){ + if ($result['contract']['check_status'] == 3) { return self::setError('你已经生成过合同,请问重复生成'); } $data = [ @@ -153,7 +153,7 @@ class UserLogic extends BaseLogic ]; $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,'check_status'=>3]); + Db::name('contract')->where('id', $result['contract']['id'])->update(['contract_no' => $res->data, 'check_status' => 3]); $data = array( "applyNo" => $res->data, //TODO * "fullName" => $result['nickname'], //TODO * @@ -187,4 +187,30 @@ class UserLogic extends BaseLogic return self::setError('生成合同成功失败,联系管理员'); } } + + //**发送短信 */ + public static function postsms($params) + { + $find = Db::name('contract')->where('party_b', $params['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' => $params['mobile'], + 'name' => $params['nickname'], + '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()); + } + } + } }