post('quota_id', []); if (!$quotaIds) { return json_fail("参数异常"); } $quotas = MemberQuota::whereIn('member_quota_id', $quotaIds)->get()->toArray(); $memberIds = array_column($quotas, 'join_quota_member_id'); if (count(array_unique($memberIds)) > 1) { return json_fail("不可以同时核销多个会员权益"); } try { $member = Member::find(current($memberIds)); $mobile = $member->member_mobile; $code = random_string(6, 'number'); $key = self::KEY_PREFIX . 'QUOTA:' . $mobile; Redis::set($key, $code); Redis::expire($key, 600); // Sms::app()->send(15910622969, [ // 'template' => 'SMS_173171292', // 'data' => [ // 'code' => $code // ], // ]); $config = [ // HTTP 请求的超时时间(秒) 'timeout' => 5.0, // 默认发送配置 'default' => [ // 网关调用策略,默认:顺序调用 'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class, // 默认可用的发送网关 'gateways' => [ 'aliyun', ], ], // 可用的网关配置 'gateways' => [ 'errorlog' => [ 'file' => '/tmp/easy-sms.log', ], 'aliyun' => [ 'access_key_id' => 'LTAI4Ff7ZPSG4XWj7pEhMQBB', 'access_key_secret' => 'kmXJO9JH33XDstQxEBAmr08bjhsN19', 'sign_name' => '', ], //... ], ]; $easySms = new EasySms($config); $easySms->send(15910622969, [ 'content' => '验证码'.$code.',您正在登录,若非本人操作,请勿泄露。', 'template' => 'SMS_173171292', 'data' => [ 'code' => $code ], ]); } catch (\Exception $e) { dump($e->getTrace()); return json_fail("短信发送失败,请稍后重试"); } return json_success('success'); } }