| xqd
@@ -14,9 +14,22 @@ use App\Repositories\Base\Criteria\OrderBy;
|
|
|
use App\Repositories\Medical\Criteria\MultiWhere;
|
|
|
use App\Repositories\Medical\OrderRepository;
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
+use Auth, Validator;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
+use Carbon\Carbon;
|
|
|
+use GuzzleHttp\Client as GuzzleHttpClient;
|
|
|
+use GuzzleHttp\Exception\RequestException;
|
|
|
|
|
|
class OrderController extends Controller
|
|
|
{
|
|
|
+
|
|
|
+ public $keySmsCodeExist = 'keySmsCodeExist';
|
|
|
+
|
|
|
+ public $expireTimeExist = '';
|
|
|
+
|
|
|
+ public $keySmsCode = 'keySmsCode';
|
|
|
+
|
|
|
+ public $expireTime = '';
|
|
|
private $repository;
|
|
|
|
|
|
public function __construct(OrderRepository $repository) {
|
| xqd
@@ -151,7 +164,8 @@ class OrderController extends Controller
|
|
|
$url = '/upload/pdf/'.$filename;
|
|
|
$update['pdf'] = $this->formatUrl($url);
|
|
|
$res = MedicalOrderModel::where('id',$data['id'])->update($update);
|
|
|
-
|
|
|
+ $check = MedicalOrderModel::find($data['id']);
|
|
|
+ $this->getCode($check->mobile);
|
|
|
return $this->showMessage('操作成功');
|
|
|
}else{
|
|
|
return $this->showWarning('操作失败');
|
| xqd
@@ -162,6 +176,63 @@ class OrderController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function getCode($phone)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ $ipkeyexist = $this->keySmsCodeExist . $_SERVER["REMOTE_ADDR"] . Carbon::now()->toDateString();
|
|
|
+
|
|
|
+ $times = Cache::store('file')->get($ipkeyexist);
|
|
|
+
|
|
|
+
|
|
|
+ $keyexist = $this->keySmsCodeExist . $phone . Carbon::now()->toDateString();;
|
|
|
+ $times = Cache::store('file')->get($keyexist);
|
|
|
+
|
|
|
+
|
|
|
+ $verify_code = (string)mt_rand(1000, 9999);
|
|
|
+ $key = $this->keySmsCode . $phone;
|
|
|
+ Cache::store('file')->put($key, $verify_code, 6000);
|
|
|
+ $msg = '【精准医疗】您的资料已处理';
|
|
|
+
|
|
|
+ $result = $this->sendSms($msg, $phone);
|
|
|
+ dd($result);
|
|
|
+// \Log::info($msg . " res:" . $result);
|
|
|
+ }
|
|
|
+ public function sendSms($msg, $mobile) {
|
|
|
+ $url = "http://api.106txt.com/smsGBK.aspx?";
|
|
|
+ $account = "swufecredit2017";
|
|
|
+ $password = "mask751002";
|
|
|
+ $password = strtoupper(md5($password));
|
|
|
+ $gwid = 53;
|
|
|
+ $message = iconv("UTF-8", "GB2312", $msg);
|
|
|
+
|
|
|
+ try {
|
|
|
+ $client = new GuzzleHttpClient();
|
|
|
+ $data = [
|
|
|
+ 'action' => 'Send',
|
|
|
+ 'username' => $account,
|
|
|
+ 'password' => $password,
|
|
|
+ 'gwid' => $gwid,
|
|
|
+ 'mobile' => $mobile,
|
|
|
+ 'message' => $message,
|
|
|
+ ];
|
|
|
+ $apiRequest = $client->post($url, [
|
|
|
+ 'form_params' => $data,
|
|
|
+ ]);
|
|
|
+ $resp = $apiRequest->getBody()->getContents();
|
|
|
+ $res = iconv("GB2312", "UTF-8", $resp);
|
|
|
+ $re = json_decode($res, true);
|
|
|
+ \Log::info("发送短信 到手机:$mobile 内容:$msg RESULT:".$re['RESULT']);
|
|
|
+ if (trim($re['CODE']) == '1') {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (RequestException $re) {
|
|
|
+ \Log::info("发送短信错误:".$re->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
/**
|
|
|
* 保存修改
|
|
|
*/
|