Anyon 4 gadi atpakaļ
vecāks
revīzija
70511c61db

+ 1 - 1
app/data/controller/Config.php

@@ -95,7 +95,7 @@ class Config extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    private function __sysdata(string $template = 'content')
+    private function __sysdata(string $template)
     {
         if ($this->request->isGet()) {
             $this->data = sysdata($this->skey);

+ 20 - 0
app/data/controller/api/Login.php

@@ -2,6 +2,7 @@
 
 namespace app\data\controller\api;
 
+use app\data\service\MessageService;
 use app\data\service\UserService;
 use think\admin\Controller;
 
@@ -69,4 +70,23 @@ class Login extends Controller
         empty($user) ? $this->success('会员注册成功!', $user) : $this->error('手机注册失败!');
     }
 
+    /**
+     * 发送短信验证码
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function sendsms()
+    {
+        $data = $this->_vali([
+            'phone.require'  => '手机号不能为空!',
+            'phone.mobile'   => '手机号格式错误!',
+            'secure.require' => '安全码不能为空!',
+        ]);
+        if ($data['secure'] !== sysconf('zt.secure_code')) $this->error('短信发送安全码错误!');
+        [$state, $message, $data] = MessageService::instance()->sendVerifyCode($data['phone']);
+        $state ? $this->success($message, $data) : $this->error($message, $data);
+        // 检测验证码:if(MessageService::instance()->checkVerifyCode($data['verify'], $data['phone'])){ }
+    }
+
 }

+ 2 - 2
app/data/controller/api/Notify.php

@@ -22,7 +22,7 @@ class Notify extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function wxpay($scene = 'order')
+    public function wxpay(string $scene = 'order')
     {
         $notify = ($payment = WechatService::WePayOrder())->getNotify();
         if ($notify['result_code'] == 'SUCCESS' && $notify['return_code'] == 'SUCCESS') {
@@ -47,7 +47,7 @@ class Notify extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    private function setOrder($code, $amount, $paycode, $paytype = 'wxpay')
+    private function setOrder(string $code, string $amount, string $paycode, string $paytype = 'wxpay')
     {
         // 检查订单支付状态
         $map = ['order_no' => $code, 'payment_status' => 0, 'status' => 2];

+ 1 - 1
app/data/controller/api/Wxapp.php

@@ -94,7 +94,7 @@ class Wxapp extends Controller
      * @param string $code 换取授权CODE
      * @return array [openid, sessionkey]
      */
-    private function _getSessionKey($code)
+    private function _getSessionKey(string $code)
     {
         try {
             $cache = $this->app->cache->get($code, []);

+ 1 - 1
app/data/service/TruckService.php

@@ -54,7 +54,7 @@ class TruckService extends Service
      * @param null|integer $status 状态筛选
      * @return array
      */
-    public function region($level = 3, $status = null): array
+    public function region(int $level = 3, ?int $status = null): array
     {
         $query = $this->app->db->name('ShopTruckRegion');
         if (is_numeric($level)) $query->where('level', '<=', $level);

+ 3 - 3
app/wechat/command/Fans.php

@@ -71,7 +71,7 @@ class Fans extends Command
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    protected function _list($next = '', $done = 0)
+    protected function _list(string $next = '', int $done = 0)
     {
         $appid = WechatService::instance()->getAppid();
         $this->output->comment('开始获取微信用户数据');
@@ -111,7 +111,7 @@ class Fans extends Command
      * @throws \WeChat\Exceptions\LocalCacheException
      * @throws \think\db\exception\DbException
      */
-    public function _black($next = '', $done = 0)
+    public function _black(string $next = '', int $done = 0)
     {
         $wechat = WechatService::WeChatUser();
         $this->output->comment('开始更新黑名单的微信用户');
@@ -147,7 +147,7 @@ class Fans extends Command
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function _tags($done = 0)
+    public function _tags(int $done = 0)
     {
         $appid = WechatService::instance()->getAppid();
         $this->output->comment('开始获取微信用户标签数据');

+ 6 - 5
app/wechat/controller/api/Login.php

@@ -26,16 +26,17 @@ use think\admin\Controller;
 class Login extends Controller
 {
     /**
+     * 数据缓存时间
+     * @var integer
+     */
+    protected $expire = 3600;
+
+    /**
      * 授权码前缀
      * @var string
      */
     protected $prefix = 'wxlogin';
 
-    /**
-     * 数据缓存时间
-     * @var integer
-     */
-    protected $expire = 3600;
 
     /**
      * 扫描显示二维码

+ 4 - 4
app/wechat/controller/api/Review.php

@@ -34,7 +34,7 @@ class Review extends Controller
      */
     public function news($id = 0)
     {
-        $this->id = empty($id) ? input('id') : $id;
+        $this->id = $id ?: input('id', 0);
         $this->news = MediaService::instance()->news($this->id);
         $this->fetch();
     }
@@ -48,11 +48,11 @@ class Review extends Controller
      */
     public function view($id = 0)
     {
-        $where = ['id' => empty($id) ? input('id') : $id];
-        $this->app->db->name('WechatNewsArticle')->where($where)->update([
+        $map = ['id' => $id ?: input('id', 0)];
+        $this->app->db->name('WechatNewsArticle')->where($map)->update([
             'read_num' => $this->app->db->raw('read_num+1'),
         ]);
-        $this->info = $this->app->db->name('WechatNewsArticle')->where($where)->find();
+        $this->info = $this->app->db->name('WechatNewsArticle')->where($map)->find();
         $this->fetch();
     }