diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 9df2d5a1..e7608167 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -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); diff --git a/app/common/service/SmsService.php b/app/common/service/SmsService.php index d1270b1a..af0d86ba 100644 --- a/app/common/service/SmsService.php +++ b/app/common/service/SmsService.php @@ -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{ diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 2a08a4f1..8f4fb033 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -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('发送失败'); + } + + + } }