gogs 1 year ago
parent
commit
f9a0f5151c

+ 1 - 1
app/Http/Controllers/Api/WeixinController.php

@@ -84,7 +84,7 @@ class WeixinController extends BaseController
     public function login(Request $request)
     {
         $service = new WxEmployeeService();
-        list($status, $data) = $service->login($request->all());
+        list($status, $data) = $service->login($request->all(),$request->header('ciphertext'));
 
         if ($status) {
             return $this->json_return(200, '', $data);

+ 8 - 0
app/Http/Controllers/Api/WxController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
 
 use App\Service\PurchaseOrderService;
 use App\Service\SalesOrderService;
+use App\Service\Weixin\WeixinService;
 use App\Service\Wx\WxEmployeeService;
 use Illuminate\Http\Request;
 
@@ -90,4 +91,11 @@ class WxController extends BaseController
             die('fail');
         }
     }
+
+    public function ttt(){
+        $a = new WeixinService();
+        $a = $a->sendTmpMsg([]);
+
+        return $a;
+    }
 }

+ 10 - 8
app/Service/Weixin/WeixinService.php

@@ -49,7 +49,7 @@ class WeixinService extends Service
         $uri = isset($data['uri']) ? $data['uri'] : '';
         $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
         $param = isset($data['param']) ? $data['param'] : '';
-        $redirect_uri = urlencode('http://t9api.qingyaokeji.com/wxapi/getUnionid?uri='.$uri.'&param='.$param);
+        $redirect_uri = urlencode('https://t9api.qingyaokeji.com/wxapi/getUnionid?uri='.$uri.'&param='.$param);
         $url = sprintf($url,self::APPID,$redirect_uri);
         header("Location:".$url);exit;
         echo 'ok';die;
@@ -61,11 +61,12 @@ class WeixinService extends Service
 
         if(isset($data['code'])) {
             list($status,$openid) = $this->getOpenid($data);
+            file_put_contents('222.txt',date('YmdHis').json_encode($openid));
             if(!$status) return [false,$openid];
             $uri = $data['uri'];
             $openid = $openid['openid'];
             $param = isset($data['param']) ? $data['param'] : '';
-            $url = 'http://t9.qingyaokeji.com/#/wxGet?uri='.$uri.'&openid='.$openid.'&param='.$param;
+            $url = 'https://t9.qingyaokeji.com/#/wxGet?uri='.$uri.'&openid='.$openid.'&param='.$param;
             header('Location:'.$url);exit();
         }
     }
@@ -73,16 +74,17 @@ class WeixinService extends Service
     public function sendTmpMsg($data){
         //        $openid = 'okXNa69ggEX61KvHUhCq9PcGrPKI';
         $data = [
-            'openid' => 'okXNa69ggEX61KvHUhCq9PcGrPKI',
-            'tempid' => 'qaD9NBasjTNKDBzIuinSpLDMy6zWbPtRb1HN8ZOjY-Y',
+            'openid' => 'o7B4f68DuDlBSevGdctFyP8MD-nw',
+            'tempid' => '5azHlaoAu6MgRzkxn_HL6ygFt_wIkXEz9CklPWEdP70',
             'reload_url' => '',
             'first' => '工资发放',
             'remark' => '请查收',
             'detail' => [
-                'thing1' => '姓名',
-                'amount2' => '10',
-                'time3' => '2023-09-01',
-                'thing4' => '类型',
+                'thing2' => '姓名',
+                'thing6' => '10',
+                'time4' => '2023-09-01',
+                'character_string3' => 'st.1231',
+                'thing1' => '类型',
             ]
         ];
         if(!isset($data['detail'])) return [false,'invalid detail'];

+ 6 - 3
app/Service/Weixin/WxEmployeeService.php

@@ -32,19 +32,22 @@ class WxEmployeeService extends Service
         $account = $data['account'];
         $password = $data['password'];
 
+        file_put_contents('111.txt',json_encode([$account,$password,$openid]));
+
         list($status,$data) = $this->loginRule([
             'account' => $account,
             'password' => $password,
         ]);
         if(!$status) return [false,$data];
-
+//        var_dump($data);
         $user_id = $data['id'];
         $user = WxEmployeeOfficial::where('openid',$openid)->first();
-        if(empty($user)) {
+//        var_dump($user);die;
+        if(!empty($user)) {
             $bool = WxEmployeeOfficial::where('employee_id',$user_id)->exists();
             if($bool) return [false,'该账号已经与其他微信用户绑定!'];
 
-            $user = new WxEmployeeOfficial();
+//            $user = new WxEmployeeOfficial();
             $user->openid = $openid;
             $user->appid = WeixinService::APPID;
             $user->employee_id = $user_id;

+ 1 - 1
config/cors.php

@@ -21,7 +21,7 @@ return [
      * You can enable CORS for 1 or multiple paths.
      * Example: ['api/*']
      */
-    'paths' => ['api/*'],
+    'paths' => ['api/*','wxapi/*','wx/*'],
 
     /*
     * Matches the request method. `[*]` allows all methods.

+ 1 - 0
routes/wx.php

@@ -16,6 +16,7 @@ Route::any('wxSetUser', 'Api\WxController@setUser');
 Route::any('wxSetMobile', 'Api\WxController@setMobile');
 Route::any('wxLogin', 'Api\WxController@login');
 Route::any('wxH5', 'Api\WxController@wxH5');
+Route::any('ttt', 'Api\WxController@ttt');
 
 Route::group(['middleware'=> ['checkWx']],function ($route){
     $route->any('oaCheck', 'Api\OaController@oaCheck');