修正验证吗

This commit is contained in:
2023-03-22 15:15:33 +08:00
parent 563e5ca7ba
commit 26fc5f5e62
12 changed files with 326 additions and 59 deletions
+171 -3
View File
@@ -4,10 +4,18 @@ declare(strict_types=1);
namespace App\Amqp\Consumer;
use App\Constants\HttpEnumCode;
use App\Exception\BusinessException;
use App\Model\LogSms;
use App\Utils\Log;
use Extend\Alibaba\Dysms;
use Hyperf\Amqp\Result;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;
use Hyperf\Redis\Redis;
use PhpAmqpLib\Message\AMQPMessage;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* 发送短信
@@ -19,12 +27,172 @@ class SendSmsMessageConsumer extends ConsumerMessage
{
/**
* data = [
* "code" => "SMS_123",
* "data" => [
* // data内参数不确定,主要看短信模版
* "template_code" => "SMS_123",
* "template_param" => [
* // 参数不确定,主要看短信模版的不同
* ],
* "scene_desc" => "场景描述",
* "phone" => "手机号",
* "user_id" => "用户id(被推送者)"
* ]
*/
Log::getInstance()->error("开始执行 发送短信 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
if (!isset($data['template_code']) || !isset($data['template_param'])){
Log::getInstance()->error("发送短信失败:发送参数错误");
return Result::DROP;// 销毁
}
// 验证发送参数
$res = $this->checkTemplateParam($data['template_code'],$data['template_param']);
if (!$res){
Log::getInstance()->error("发送短信失败:发送参数错误");
return Result::DROP;// 销毁
}
try {
$redis = $this->container->get(Redis::class);
$redis_key = "sms_" . $data['phone'] . $data['template_code'];
$result = $redis->get($redis_key);
if (!empty($result)){
if ( $result > 3){
// 超出规定时间内最大获取次数
Log::getInstance()->error("发送短信失败:超出最大发送重试次数");
return Result::DROP;// 销毁
}
}
// 发送短信
Dysms::sendSms($data['phone'],$data['template_param'],$data['template_code'],$data['scene_desc']);
} catch (\Exception $e) {
Log::getInstance()->error("发送短信失败:" . $e->getMessage());
return Result::REQUEUE; // 重回队列
} catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) {
Log::getInstance()->error("发送短信失败:" . $e->getMessage());
return Result::DROP; // 销毁
}
return Result::ACK;
}
/**
* 验证短信发送参数
* @param string $template_code
* @param array $template_param
* @return bool
*/
private function checkTemplateParam(string $template_code, array $template_param): bool
{
switch ($template_code) {
case 'SMS_271990126':
// 医生修改简介审核通过
break;
case 'SMS_271540920':
// 处方审核通过通知患者
if (!isset($template_param['name'])) {
return false;
}
case 'SMS_271905266':
// 医师还未接诊
if (!isset($template_param['name']) || !isset($template_param['type'])) {
return false;
}
break;
case 'SMS_272140100':
// 药品收货-用药提醒
if (!isset($template_param['name']) || !isset($template_param['usage']) || !isset($template_param['frequency']) || !isset($template_param['amount']) || !isset($template_param['tell'])) {
return false;
}
break;
case 'SMS_271575911':
// 多点执业认证通过
break;
case 'SMS_271955088':
// 医生接诊通知给患者
if (!isset($template_param['type']) || !isset($template_param['name']) || !isset($template_param['duration'])) {
return false;
}
break;
case 'SMS_271905264':
// 处方审核拒绝通过医师
if (!isset($template_param['name'])) {
return false;
}
break;
case 'SMS_271980127':
// 药品已发货
if (!isset($template_param['name']) || !isset($template_param['code'])) {
return false;
}
break;
case 'SMS_272180110':
// 患者问诊费退款
if (!isset($template_param['type'])) {
return false;
}
break;
case 'SMS_272145102':
// 医生没有及时回消息
if (!isset($template_param['name']) || !isset($template_param['type'])) {
return false;
}
break;
case 'SMS_272120097':
// 处方审核通过通知医生
if (!isset($template_param['name'])) {
return false;
}
break;
case 'SMS_272030021':
// 多点执业认证拒绝
break;
case 'SMS_271925089':
// 医师身份认证通过
break;
case 'SMS_271915200':
// 医师服务费结算
if (!isset($template_param['name']) || !isset($template_param['time'])) {
return false;
}
break;
case 'SMS_272015117':
// 医生接到新问诊
if (!isset($template_param['type'])) {
return false;
}
break;
case 'SMS_271955204':
// 患者药品费用退款
if (!isset($template_param['name']) || !isset($template_param['status'])) {
return false;
}
break;
case 'SMS_271905155':
// 医师身份认证拒绝
break;
case 'SMS_271950089':
// 问诊即将结束通知患者
if (!isset($template_param['name']) || !isset($template_param['type']) || !isset($template_param['time'])) {
return false;
}
break;
case 'SMS_272165092':
// 医生修改简介审核拒绝
break;
default:
// code...
break;
}
return true;
}
// 记录发送失败log
private function addSendFailLog(array $data){
$data = array();
// $data['to_user_id']
}
}
+5
View File
@@ -732,4 +732,9 @@ class CallBackController extends AbstractController
);
}
// 处方平台物流回调
public function platformLogisticsCallBack(){
}
}
+36 -24
View File
@@ -5,6 +5,7 @@ namespace App\Controller;
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
use App\Constants\HttpEnumCode;
use App\Model\DoctorPharmacistCert;
use App\Utils\Log;
use Extend\Alibaba\Oss;
use Extend\Ca\Ca;
use Hyperf\Amqp\Producer;
@@ -15,7 +16,12 @@ use TCPDF;
class TestController extends AbstractController
{
public function test(){
$this->test_7();
// $this->test_8();
// $this->test_3();
// $this->test_4();
$this->test_6();
}
// 获取云证书-首次
@@ -111,9 +117,9 @@ class TestController extends AbstractController
// 下载阿里云图片
$oss = new Oss();
$filename = "applet/doctor/cert/67d7396d-0fc3-464d-9582-3501229ed188.png";
$filename = "applet/doctor/cert/b09ebb06-be90-40cf-9329-fab5b15139ec.png";
$style = "image/resize,m_lfit,w_100,h_350/rotate,270";
$style = "image/resize,m_lfit,w_100,h_350";
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
$sign_image = base64_encode($sign_image);
@@ -121,20 +127,18 @@ class TestController extends AbstractController
return fail(HttpEnumCode::SERVER_ERROR);
}
$sign_image = urlencode($sign_image);
$sign_param = [
[
"llx"=> 700, // 左边底部X坐标
"lly"=>2985, // 左边底部Y坐标
"urx"=>1101, // 右边上部x坐标
"ury"=>2896, // 右边上部y坐标
"llx"=> "700", // 左边底部X坐标
"lly"=>"2985", // 左边底部Y坐标
"urx"=>"1101", // 右边上部x坐标
"ury"=>"2896", // 右边上部y坐标
"pageList"=>[1],
"sealImg"=>$sign_image
]
];
$data = array();
$data['sign_param'] = json_encode($sign_param,JSON_UNESCAPED_UNICODE);
$data['sign_param'] = json_encode($sign_param);
$data['seal_img'] = $sign_image;
$result = $ca->addUserSignConfig("491925054435950592","410323199603261241",$data);
@@ -311,18 +315,21 @@ class TestController extends AbstractController
public function test_6(){
$pdf_file = $this->test_5();
$pdf_file = base64_encode($pdf_file);
if (!$pdf_file){
return fail(HttpEnumCode::SERVER_ERROR);
}
// $oss = new Oss();
// $filename = "Basic/images/prescription_img.jpg";
//
// $pdf_file = $oss->getObjectToRAM($filename);
// $pdf_file = file_get_contents('./runtime/dsddasdasdasdasdasdsa.pdf');
$pdf_file = urlencode($pdf_file);
// $pdf_file = new \CURLFILE('./runtime/dsddasdasdasdasdasdsa.pdf');
// $pdf_file = fopen("/Users/wucongxing/Desktop/work/php/hospital-applets-api/runtime/dsddasdasdasdasdasdsa.pdf",'f');
// dump($pdf_file);die;
$oss = new Oss();
$filename = "applet/doctor/cert/67d7396d-0fc3-464d-9582-3501229ed188.png";
$filename = "applet/doctor/cert/b09ebb06-be90-40cf-9329-fab5b15139ec.png";
$style = "image/resize,m_lfit,w_350,h_100/rotate";
$style = "image/resize,m_lfit,w_100,h_350";
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
$sign_image = base64_encode($sign_image);
@@ -330,21 +337,20 @@ class TestController extends AbstractController
return fail(HttpEnumCode::SERVER_ERROR);
}
$sign_image = urlencode($sign_image);
// $sign_image = urlencode($sign_image);
$sign_param = [
[
"llx"=> 700, // 左边底部X坐标
"lly"=>2985, // 左边底部Y坐标
"urx"=>1101, // 右边上部x坐标
"ury"=>2896, // 右边上部y坐标
"llx"=> "700", // 左边底部X坐标
"lly"=>"2985", // 左边底部Y坐标
"urx"=>"1101", // 右边上部x坐标
"ury"=>"2896", // 右边上部y坐标
"pageList"=>[1],
"sealImg"=>$sign_image
]
];
$data = array();
$data['sign_param'] = json_encode($sign_param,JSON_UNESCAPED_UNICODE);
$data['sign_param'] = json_encode($sign_param);
$data['pdf_file'] = $pdf_file;
$ca = new Ca();
@@ -385,4 +391,10 @@ class TestController extends AbstractController
}
}
}
// 删除签章配置
public function test_8(){
$ca = new Ca();
$result = $ca->deleteUserSignConfig("491925054435950592");
}
}
+2
View File
@@ -64,4 +64,6 @@ class UserPatientController extends AbstractController
return $this->response->json($data);
}
// public function
}
+1 -1
View File
@@ -65,7 +65,7 @@ class LogSms extends Model
* @param array $data
* @return \Hyperf\Database\Model\Model|LogSms
*/
public static function addCodeLog(array $data): \Hyperf\Database\Model\Model|LogSms
public static function LogSms(array $data): \Hyperf\Database\Model\Model|LogSms
{
return self::create($data);
}
+1 -1
View File
@@ -36,7 +36,7 @@ class PatientCaseService extends BaseService
$order_inquiry_case = OrderInquiryCase::getEndOrderInquiryCaseOne($params,$order_inquiry_params);
if (empty($order_inquiry_case)){
return success();
return success('');
}
$order_inquiry_case = $order_inquiry_case->toArray();
+1
View File
@@ -28,6 +28,7 @@ class Auth
"/callback/wxpay/product/success" => "post", // 微信药品支付回调
"/callback/wxpay/product/refund" => "post", // 微信药品退款回调
"/callback/im" => "post", // im回调
"/callback/platform/logistics" => "post", // 处方平台物流回调
"/test" => "get", // 测试
];
}