WIN-2308041133\Administrator 6 meses atrás
pai
commit
916eb04834
2 arquivos alterados com 61 adições e 8 exclusões
  1. 59 8
      application/api/controller/Wechat.php
  2. 2 0
      application/route.php

+ 59 - 8
application/api/controller/Wechat.php

@@ -185,6 +185,59 @@ class Wechat extends Api
             @file_put_contents("error.txt", $e->getFile() . '-', $e->getLine(), '-' . $e->getMessage());
         }
     }
+    /**
+     * 解约扣款服务
+     * @param Request $request
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function delete_signing(Request $request)
+    {
+        $record_id = intval($request->param('id'));
+        $uid = intval($request->param('uid'));
+        try {
+//            $notify_url=Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口
+            $app_id = 'wx5681205d1ef4d9d3';
+            $mch_id = '1623907696';
+            $contract_code = WechatPlanRecord::where('id', $record_id)->value('contract_code');
+            $plan_id = WechatPlanRecord::where('id', $record_id)->value('wechat_plan_id');
+            $contract_termination_remark='解约备注';
+            $version = '1.0';
+            $array = array(
+                'appid' => $app_id,
+                'mch_id' => $mch_id,
+                'plan_id' => $plan_id,
+                'contract_code' => $contract_code,
+                'contract_termination_remark' => $contract_termination_remark,
+               'version' => $version
+            );
+
+
+            ksort($array);
+            $xml = '';
+            foreach ($array as $key => $value) {
+                $xml = $xml . $key . '=' . $value . '&';
+            }
+            $xml = substr($xml, 0, -1);
+            @file_put_contents("quanju.txt", json_encode($xml) . "-签约内容\r\n", 8);
+            $sign = $this->md5_sign($xml, '192006250b4c09247ec02edce69f6a2d');
+            @file_put_contents("quanju.txt", $sign . "-签名\r\n", 8);
+            $url = 'https://api.mch.weixin.qq.com/papay/deletecontract?' . $xml . '&sign=' . $sign;
+            @file_put_contents("quanju.txt", $url . "-链接\r\n", 8);
+            var_dump($url);
+//            $response = $this->curl_get($url);
+//            $url=$this->OfficialAccountSigning($app_id,$mch_id,$plan_id,$contract_code,$request_serial,$contract_display_account,$notify_url,$version,$sign,$timestamp);
+//            @file_put_contents("quanju.txt", $response.'返回链接');
+
+            WechatPlanRecord::where('id', $record_id)->update(['is_signing' => 1]);
+            die();
+            return 1;
+        } catch (Exception $e) {
+            @file_put_contents("error.txt", $e->getFile() . '-', $e->getLine(), '-' . $e->getMessage());
+        }
+    }
 
     public function generateRandomString($length)
     {
@@ -312,14 +365,12 @@ class Wechat extends Api
 
     public function signing_plan()
     {
-//        if ($this->cid<=0){
-//            $a=WechatPlan::where('cid', 12)->select();
-//        }else{
-//            $a=WechatPlan::where('cid', $this->cid)->select();
-//        }
-//
-//        var_dump($a);die();
         $this->success('获取成功', WechatPlan::where('cid', 12)->select());
     }
-
+//    用户签约列表
+    public function user_signing(Request $request)
+    {
+        $uid = intval($request->param('uid'));
+        $this->success('获取成功', WechatPlanRecord::where('uid', $uid)->where('is_signing', 0)->select());
+    }
 }

+ 2 - 0
application/route.php

@@ -45,8 +45,10 @@ Route::group('api', function () {
         Route::get('auth', 'api/wechat/auth');
         Route::get('wxconfig', 'api/Index/wxconfig');
         Route::get('signing', 'api/wechat/signing');
+        Route::get('delete_signing', 'api/wechat/delete_signing');
         Route::get('test', 'api/wechat/test');
         Route::get('signing_plan', 'api/wechat/signing_plan');
+        Route::get('user_signing', 'api/wechat/user_signing');
     });
     Route::group('mini', function () {
         Route::post('auth', 'api/MiniProgram/mp_auth');