预留模板到货短信

This commit is contained in:
liu 2024-06-15 18:46:37 +08:00
parent 80d24acad4
commit 1976367b3c
3 changed files with 39 additions and 10 deletions

View File

@ -314,7 +314,7 @@ class StoreOrderLogic extends BaseLogic
}
public function dealSendSms($param)
public function dealSendSms($param,$type = 0)
{
$code = generateRandomCode();
$phone = User::where('id',$param['uid'])->value('mobile');
@ -322,8 +322,12 @@ class StoreOrderLogic extends BaseLogic
throw new \Exception('用户未设置手机号');
}
$template = getenv('SMS_TEMPLATE');
if($type){
$check =(new SmsService())->client($phone,$template,$code,1);
}else{
$check =(new SmsService())->client($phone,$template,$code);
}
$check =(new SmsService())->client($phone,$template,$code);
if($check){
$remark = $param['uid'].'_smsPay';
Cache::set($remark,$code,5*60);

View File

@ -45,18 +45,30 @@ class SmsService
}
public function client($phone,$template,$code)
public function client($phone,$template,$code,$type = 0)
{
try{
$easySms = new EasySms($this->config);
$res = $easySms->send($phone, [
'content' => '您的验证码为: '.$code,
'template' => $template,
'data' => [
'code' => $code
],
]);
if($type){//预留发送到货短信
$res = $easySms->send($phone, [
'content' => '您的验证码为: '.$code,
'template' => $template,
'data' => [
'code' => $code
],
]);
}else{
$res = $easySms->send($phone, [
'content' => '您的验证码为: '.$code,
'template' => $template,
'data' => [
'code' => $code
],
]);
}
if($res && $res['aliyun']['status'] == 'success'){
return true;
}else{

View File

@ -373,5 +373,18 @@ class StoreOrderController extends BaseAdminController
}
return $this->fail('支付失败');
}
public function stocking()
{
$uid = $this->request->post('uid');
$res = (new StoreOrderLogic())->dealSendSms(['uid'=>$uid],1);
if($res){
return $this->success('发送成功',[],0,1);
}else{
return $this->fail('发送失败');
}
}
}