WIN-2308041133\Administrator há 5 meses atrás
pai
commit
4c1b26875b

+ 25 - 0
application/admin/model/WechatPlanRecord.php

@@ -25,4 +25,29 @@ class WechatPlanRecord extends Model
         } while (self::where(['contract_code' => $orderId])->find());
         return $orderId;
     }
+    public static function plan_lst($where)
+    {
+        $model = new self;
+        $xwhere = null;
+        $order = "id desc";
+        if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
+        if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
+        $data = $model->where($xwhere)->where('is_signing',0)->order($order)->field('id')->select();
+        $plan=new WechatPlan();
+        $data2=$plan->where('id','in',$data)->select();
+//        $count = $plan->where('id','in',$data)->count();
+        return $data2;
+    }
+    public static function record_lst($where)
+    {
+        $model = new self;
+        $xwhere = null;
+        $order = "id desc";
+        if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
+        if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
+        if (isset($where['category_id']) && $where['category_id'] > 0) $xwhere['category_id'] = $where['category_id'];
+        $data = $model->where($xwhere)->where('is_signing',0)->order($order)->select();
+        $count = $model->where($xwhere)->count();
+        return compact('count', 'data');
+    }
 }

+ 63 - 31
application/api/controller/Lave.php

@@ -282,7 +282,7 @@ class Lave extends Api
 
         foreach ($list as $k => $v){
             $cid=$v['cid'];
-            if ($this->querySign($cid,$v['uid'],$v['plan_id'],$v['contract_code'])){
+//            if ($this->querySign($cid,$v['uid'],$v['plan_id'],$v['contract_code'])){
                 $arr['mch_id'] =Company::where('id', $cid)->value('pay_weixin_mchid');
                 $arr['out_trade_no']=LaveModel::getNewOrderId();
                 $arr['total_fee'] = $v['price'];
@@ -304,7 +304,7 @@ class Lave extends Api
                 $where1['type']='0';
                 $where1['help_id']='0';
                 $order = LaveModel::create($where1);
-            }
+//            }
         }
     }
 //    解除签约
@@ -333,35 +333,35 @@ class Lave extends Api
         }
     }
 //    查询签约状态
-    public function querySign(int $cid,int $uid,int $plan_id,string $contract_code)
-    {
-//        $where = UtilService::postMore(
-//            [
-//                ['cid', $this->cid],
-//                ['user_id', $this->auth->getUserinfo()['id']],
-//            ], $request
-//        );
-        $sign_info = WechatPlanRecord::where('cid', $cid)->where('uid', $uid)->where('is_signing', 1)->find();
-        if (!$sign_info) {
-            $this->error('未找到签约信息!');
-        }
-        $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
-//        $plan_id = $sign_info['plan_id'];
-//        $contract_code = $sign_info['contract_code'];
-        $rs = WechatService::querySign($mch_id, $contract_code, $plan_id);
-        @file_put_contents("quanju.txt", json_encode($rs) . "-查询签约状态返回结果\r\n", 8);
-        if ($rs['return_code'] == 'SUCCESS') {
-            if ($rs['contract_state'] == 1) {
-                WechatPlanRecord::where('cid',$cid)->where('uid', $uid)->where('is_signing', 1)->update(['is_signing' => 0]);
-                return false;
-            }else{
-                WechatPlanRecord::where('cid',$cid)->where('uid', $uid)->where('is_signing', 1)->update(['contract_id' => $rs['contract_id']]);
-                return true;
-            }
-        } else {
-            $this->error('查询签约状态失败!');
-        }
-    }
+//    public function querySign(int $cid,int $uid,int $plan_id,string $contract_code)
+//    {
+////        $where = UtilService::postMore(
+////            [
+////                ['cid', $this->cid],
+////                ['user_id', $this->auth->getUserinfo()['id']],
+////            ], $request
+////        );
+//        $sign_info = WechatPlanRecord::where('cid', $cid)->where('uid', $uid)->where('is_signing', 1)->find();
+//        if (!$sign_info) {
+//            $this->error('未找到签约信息!');
+//        }
+//        $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
+////        $plan_id = $sign_info['plan_id'];
+////        $contract_code = $sign_info['contract_code'];
+//        $rs = WechatService::querySign($mch_id, $contract_code, $plan_id);
+//        @file_put_contents("quanju.txt", json_encode($rs) . "-查询签约状态返回结果\r\n", 8);
+//        if ($rs['return_code'] == 'SUCCESS') {
+//            if ($rs['contract_state'] == 1) {
+//                WechatPlanRecord::where('cid',$cid)->where('uid', $uid)->where('is_signing', 1)->update(['is_signing' => 0]);
+//                return false;
+//            }else{
+//                WechatPlanRecord::where('cid',$cid)->where('uid', $uid)->where('is_signing', 1)->update(['contract_id' => $rs['contract_id']]);
+//                return true;
+//            }
+//        } else {
+//            $this->error('查询签约状态失败!');
+//        }
+//    }
     //    测试查询签约状态
     public function csquerySign(Request $request)
     {
@@ -419,6 +419,38 @@ class Lave extends Api
         );
         $this->success('获取成功', WechatPlan::read($where));
     }
+//    签约列表
+    public function user_plan_lst(Request $request)
+    {
+        $where = UtilService::getMore(
+            [
+                ['cid', 0],
+//                ['cid', $this->cid],
+//                ['uid', $this->auth->getUserinfo()['id']],
+                ['uid', 0],
+            ], $request
+        );
+        if (isset($where['uid'])) $this->error('用户不存在');
+        if (isset($where['cid'])) $this->error('请选择正确的城市的红十字会');
+        $this->success('获取成功', WechatPlanRecord::plan_lst($where));
+    }
+//    签约记录列表
+    public function user_record_lst(Request $request)
+    {
+        $where = UtilService::getMore(
+            [
+                ['category_id', 0], //捐款意愿
+                ['cid', 0],
+//                ['cid', $this->cid],
+//                ['user_id', $this->auth->getUserinfo()['id']],
+                ['user_id', 0],
+            ], $request
+        );
+        if (isset($where['uid'])) $this->error('用户不存在');
+        if (isset($where['cid'])) $this->error('请选择正确的城市的红十字会');
+        if (isset($where['category_id'])) $this->error('请选择捐款项目');
+        $this->success('获取成功', WechatPlanRecord::record_lst($where));
+    }
 }
 
 ?>

+ 270 - 270
application/api/controller/Wechat.php

@@ -101,280 +101,280 @@ 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 signing(Request $request)
-    {
-        $price = intval($request->param('price'));
-        $uid = intval($request->param('uid'));
-        $cid = intval($request->param('cid'));
-        $plan_id = WechatPlan::where('price', $price)->value('plan_id');
-        $p_id = WechatPlan::where('price', $price)->value('id');
-//        var_dump($plan_id);
-//        var_dump($p_id);die();
-//        $plan_id = 11;
-//        $p_id = 12;
-        try {
-//            $notify_url=Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口
-//            $app_id = 'wx5681205d1ef4d9d3';
-            $app_id = Company::where('id', $cid)->value('wechat_appid');
-//            $mch_id = '1623907696';
-            $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
-            $key = Company::where('id', $cid)->value('pay_weixin_key');
-            @file_put_contents("quanju.txt", $key . "-key\r\n", 8);
-            $contract_code = $this->generateRandomString(12);
-            $notify_url = Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口  $cid 企业id
-//            $num = time() + mt_rand(10, 999999) . '' . substr($msec, 2, 3);//生成随机数
-//            $request_serial=$this->generateUniqueSerialNumber();
-            $request_serial = WechatPlanRecord::where('is_signing', 0)->order('request_serial desc')->value('request_serial');
-            if (empty($request_serial)) {
-                $request_serial = 100000;
-            } else {
-                $request_serial = $request_serial + 1;
-            }
-            $contract_display_account = User::where('id', $uid)->value('nickname');
-            if (empty($contract_display_account)){
-                $this->error('用户不存在!');
-            }
-            $timestamp = time();
-            $version = '1.0';
-            $array = array(
-                'appid' => $app_id,
-                'mch_id' => $mch_id,
-                'plan_id' => $plan_id,
-//                'sub_mch_id' => $sub_mch_id,
-                'contract_code' => $contract_code,
-                'notify_url' => $notify_url,
-                'contract_display_account' => $contract_display_account,
-                'request_serial' => $request_serial,
-                'timestamp' => $timestamp,
-                'version' => $version,
-
-            );
-
-
-            ksort($array);
-            $xml = '';
-            foreach ($array as $key => $value) {
-                $xml = $xml . $key . '=' . $value . '&';
-            }
-            $xml = substr($xml, 0, -1);
-            @file_put_contents("quanju.txt", $xml . "-签约内容\r\n", 8);
-            $sign = $this->md5_sign($xml, $key);
-            @file_put_contents("quanju.txt", $sign . "-签名\r\n", 8);
-            $url = 'https://api.mch.weixin.qq.com/papay/entrustweb?' . $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 . "-返回链接\r\n", 8);
-
-            WechatPlanRecord::create([
-                'uid' => $uid,
-                'plan_id' => $plan_id,
-                'price' => $price,
-                'is_signing' => 0,
-                'request_serial' => $request_serial,
-                'contract_code' => $contract_code,
-                'contract_display_account' => $contract_display_account,
-                'createtime' => time(),
-                'cid' => 12,
-            ]);
-//            die();
-            $this->success('获取成功', $response);
-//            return $response;
-        } catch (Exception $e) {
-//            var_dump($e->getMessage());
-            @file_put_contents("quanju.txt", $e->getMessage() . "-报错信息\r\n", 8);
-            @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'));
-        $cid = intval($request->param('uid'));
-        try {
-//            $notify_url=Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口
-            $app_id = Company::where('id', $cid)->value('wechat_appid');
-            $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
-            $contract_code = WechatPlanRecord::where('id', $record_id)->value('contract_code');
-            $plan_id = WechatPlanRecord::where('id', $record_id)->value('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);
+//
+//    /**
+//     * 扣款服务
+//     * @param Request $request
+//     * @return mixed
+//     * @throws \think\db\exception\DataNotFoundException
+//     * @throws \think\db\exception\ModelNotFoundException
+//     * @throws \think\exception\DbException
+//     */
+//    public function signing(Request $request)
+//    {
+//        $price = intval($request->param('price'));
+//        $uid = intval($request->param('uid'));
+//        $cid = intval($request->param('cid'));
+//        $plan_id = WechatPlan::where('price', $price)->value('plan_id');
+//        $p_id = WechatPlan::where('price', $price)->value('id');
+////        var_dump($plan_id);
+////        var_dump($p_id);die();
+////        $plan_id = 11;
+////        $p_id = 12;
+//        try {
+////            $notify_url=Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口
+////            $app_id = 'wx5681205d1ef4d9d3';
+//            $app_id = Company::where('id', $cid)->value('wechat_appid');
+////            $mch_id = '1623907696';
+//            $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
+//            $key = Company::where('id', $cid)->value('pay_weixin_key');
+//            @file_put_contents("quanju.txt", $key . "-key\r\n", 8);
+//            $contract_code = $this->generateRandomString(12);
+//            $notify_url = Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口  $cid 企业id
+////            $num = time() + mt_rand(10, 999999) . '' . substr($msec, 2, 3);//生成随机数
+////            $request_serial=$this->generateUniqueSerialNumber();
+//            $request_serial = WechatPlanRecord::where('is_signing', 0)->order('request_serial desc')->value('request_serial');
+//            if (empty($request_serial)) {
+//                $request_serial = 100000;
+//            } else {
+//                $request_serial = $request_serial + 1;
+//            }
+//            $contract_display_account = User::where('id', $uid)->value('nickname');
+//            if (empty($contract_display_account)){
+//                $this->error('用户不存在!');
+//            }
+//            $timestamp = time();
+//            $version = '1.0';
+//            $array = array(
+//                'appid' => $app_id,
+//                'mch_id' => $mch_id,
+//                'plan_id' => $plan_id,
+////                'sub_mch_id' => $sub_mch_id,
+//                'contract_code' => $contract_code,
+//                'notify_url' => $notify_url,
+//                'contract_display_account' => $contract_display_account,
+//                'request_serial' => $request_serial,
+//                'timestamp' => $timestamp,
+//                'version' => $version,
+//
+//            );
+//
+//
+//            ksort($array);
+//            $xml = '';
+//            foreach ($array as $key => $value) {
+//                $xml = $xml . $key . '=' . $value . '&';
+//            }
+//            $xml = substr($xml, 0, -1);
+//            @file_put_contents("quanju.txt", $xml . "-签约内容\r\n", 8);
+//            $sign = $this->md5_sign($xml, $key);
+//            @file_put_contents("quanju.txt", $sign . "-签名\r\n", 8);
+//            $url = 'https://api.mch.weixin.qq.com/papay/entrustweb?' . $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)
-    {
-        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-        $charactersLength = strlen($characters);
-        $randomString = '';
-        for ($i = 0; $i < $length; $i++) {
-            $randomString .= $characters[rand(0, $charactersLength - 1)];
-        }
-        return $randomString;
-    }
-
-//    生成唯一序列号
-    public function generateUniqueSerialNumber()
-    {
-        // 使用uniqid生成一个唯一ID,并去除前缀的'0'
-        $uniqueId = ltrim(uniqid('', true), '0');
-
-        // 确保生成的ID不以0开头且长度不超过19位(int64的最大长度)
-        while (strlen($uniqueId) > 19 || substr($uniqueId, 0, 1) === '0') {
-            $uniqueId = ltrim(uniqid('', true), '0');
-        }
-
-        // 将生成的ID转换为纯数字
-        $serialNumber = preg_replace('/\D/', '', $uniqueId);
-
-        // 确保生成的序列号不以0开头
-        if (substr($serialNumber, 0, 1) === '0') {
-            $serialNumber = generateUniqueSerialNumber(); // 递归调用以重新生成
-        }
-
-        return $serialNumber;
-    }
-
-
-    public function curl_post($url = '', $name = array(), $timeout = 100)
-    {
-        // var_dump($url);die();
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_HEADER, false); //是否显示头部
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//是否直接输出到屏幕
-        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
-        curl_setopt($ch, CURLOPT_POST, true); //是否以post方式
-        //设置post数据
-        $post_data = json_encode($name);
-        // curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
-        $content = curl_exec($ch);
-        // var_dump($content);die();
-        curl_close($ch);
-        $content = json_decode($content, true);
-        return $content;
-
-    }
-
-    public function curl_get(string $url, $timeout = 100)
-    {
-//        if (!empty($name)) {
-//            $data = '&';
-//            foreach ($name as $k => $v) {
-//                $data = $data . $k . '=' . $v.'&';
+////            $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 . "-返回链接\r\n", 8);
+//
+//            WechatPlanRecord::create([
+//                'uid' => $uid,
+//                'plan_id' => $plan_id,
+//                'price' => $price,
+//                'is_signing' => 0,
+//                'request_serial' => $request_serial,
+//                'contract_code' => $contract_code,
+//                'contract_display_account' => $contract_display_account,
+//                'createtime' => time(),
+//                'cid' => 12,
+//            ]);
+////            die();
+//            $this->success('获取成功', $response);
+////            return $response;
+//        } catch (Exception $e) {
+////            var_dump($e->getMessage());
+//            @file_put_contents("quanju.txt", $e->getMessage() . "-报错信息\r\n", 8);
+//            @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'));
+//        $cid = intval($request->param('uid'));
+//        try {
+////            $notify_url=Request::instance()->domain() . "/api/wechat/notify/" . $cid; //回调接口
+//            $app_id = Company::where('id', $cid)->value('wechat_appid');
+//            $mch_id = Company::where('id', $cid)->value('pay_weixin_mchid');
+//            $contract_code = WechatPlanRecord::where('id', $record_id)->value('contract_code');
+//            $plan_id = WechatPlanRecord::where('id', $record_id)->value('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 . '&';
 //            }
-//            $url = $url . $data;
+//            $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());
 //        }
-//        $url = substr($url,0,-1);
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_HEADER, false); //是否显示头部
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//是否直接输出到屏幕
-        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
-
-        $content = curl_exec($ch);
-        curl_close($ch);
+//    }
+//
+//    public function generateRandomString($length)
+//    {
+//        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+//        $charactersLength = strlen($characters);
+//        $randomString = '';
+//        for ($i = 0; $i < $length; $i++) {
+//            $randomString .= $characters[rand(0, $charactersLength - 1)];
+//        }
+//        return $randomString;
+//    }
+//
+////    生成唯一序列号
+//    public function generateUniqueSerialNumber()
+//    {
+//        // 使用uniqid生成一个唯一ID,并去除前缀的'0'
+//        $uniqueId = ltrim(uniqid('', true), '0');
+//
+//        // 确保生成的ID不以0开头且长度不超过19位(int64的最大长度)
+//        while (strlen($uniqueId) > 19 || substr($uniqueId, 0, 1) === '0') {
+//            $uniqueId = ltrim(uniqid('', true), '0');
+//        }
+//
+//        // 将生成的ID转换为纯数字
+//        $serialNumber = preg_replace('/\D/', '', $uniqueId);
+//
+//        // 确保生成的序列号不以0开头
+//        if (substr($serialNumber, 0, 1) === '0') {
+//            $serialNumber = generateUniqueSerialNumber(); // 递归调用以重新生成
+//        }
+//
+//        return $serialNumber;
+//    }
+//
+//
+//    public function curl_post($url = '', $name = array(), $timeout = 100)
+//    {
+//        // var_dump($url);die();
+//        $ch = curl_init();
+//        curl_setopt($ch, CURLOPT_URL, $url);
+//        curl_setopt($ch, CURLOPT_HEADER, false); //是否显示头部
+//        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//是否直接输出到屏幕
+//        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+//        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
+//        curl_setopt($ch, CURLOPT_POST, true); //是否以post方式
+//        //设置post数据
+//        $post_data = json_encode($name);
+//        // curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
+//        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+//        $content = curl_exec($ch);
+//        // var_dump($content);die();
+//        curl_close($ch);
 //        $content = json_decode($content, true);
-        // $content = (array)$content;
-         var_dump($content);die();
-        return $content;
-    }
-
-    public function md5_sign($data, $key)
-    {
-        $stringSignTemp = $data . "&key=$key"; //注:key为商户平台设置的密钥key
-
-        $sign = MD5($stringSignTemp); //MD5加密
-        $sign = strtoupper($sign); //大写
-        return $sign;
-    }
-
-    /**
-     * 公众号签约
-     * see:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_1.shtml
-     * @param array $data
-     *
-     * @return array
-     * @throws AuthorizeFailedException
-     */
-    public function OfficialAccountSigning(string $appid, string $mch_id, string $plan_id, string $contract_code, string $request_serial, string $contract_display_account, string $notify_url, string $version, string $sign, string $timestamp): array
-    {
-
-        $url = 'https://api.mch.weixin.qq.com/papay/entrustweb';
-        $info = [
-            'appid' => $appid,  //应用ID
-            'mch_id' => $mch_id,  //商户号
-            'plan_id' => $plan_id,  //模板id
-//            'sub_mch_id' => $sub_mch_id,  //子商户号
-            'contract_code' => $contract_code, //签约协议号
-            'request_serial' => $request_serial, //请求序列号
-            'contract_display_account' => $contract_display_account, //用户账户展示名称
-            'notify_url' => $notify_url, //回调通知url
-            'version' => $version, //版本号 固定值1.0
-            'sign' => $sign, //签名
-            'timestamp' => $timestamp
-        ];
-        $response = $this->curl_get($url, $info);
-        return $response;
-    }
-
-    public function test()
-    {
-        return '123456';
-    }
+//        return $content;
+//
+//    }
+//
+//    public function curl_get(string $url, $timeout = 100)
+//    {
+////        if (!empty($name)) {
+////            $data = '&';
+////            foreach ($name as $k => $v) {
+////                $data = $data . $k . '=' . $v.'&';
+////            }
+////            $url = $url . $data;
+////        }
+////        $url = substr($url,0,-1);
+//        $ch = curl_init();
+//        curl_setopt($ch, CURLOPT_URL, $url);
+//        curl_setopt($ch, CURLOPT_HEADER, false); //是否显示头部
+//        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//是否直接输出到屏幕
+//        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+//        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
+//
+//        $content = curl_exec($ch);
+//        curl_close($ch);
+////        $content = json_decode($content, true);
+//        // $content = (array)$content;
+//         var_dump($content);die();
+//        return $content;
+//    }
+//
+//    public function md5_sign($data, $key)
+//    {
+//        $stringSignTemp = $data . "&key=$key"; //注:key为商户平台设置的密钥key
+//
+//        $sign = MD5($stringSignTemp); //MD5加密
+//        $sign = strtoupper($sign); //大写
+//        return $sign;
+//    }
+//
+//    /**
+//     * 公众号签约
+//     * see:https://pay.weixin.qq.com/wiki/doc/api/wxpay_v2/papay/chapter3_1.shtml
+//     * @param array $data
+//     *
+//     * @return array
+//     * @throws AuthorizeFailedException
+//     */
+//    public function OfficialAccountSigning(string $appid, string $mch_id, string $plan_id, string $contract_code, string $request_serial, string $contract_display_account, string $notify_url, string $version, string $sign, string $timestamp): array
+//    {
+//
+//        $url = 'https://api.mch.weixin.qq.com/papay/entrustweb';
+//        $info = [
+//            'appid' => $appid,  //应用ID
+//            'mch_id' => $mch_id,  //商户号
+//            'plan_id' => $plan_id,  //模板id
+////            'sub_mch_id' => $sub_mch_id,  //子商户号
+//            'contract_code' => $contract_code, //签约协议号
+//            'request_serial' => $request_serial, //请求序列号
+//            'contract_display_account' => $contract_display_account, //用户账户展示名称
+//            'notify_url' => $notify_url, //回调通知url
+//            'version' => $version, //版本号 固定值1.0
+//            'sign' => $sign, //签名
+//            'timestamp' => $timestamp
+//        ];
+//        $response = $this->curl_get($url, $info);
+//        return $response;
+//    }
+//
+//    public function test()
+//    {
+//        return '123456';
+//    }
 
     public function signing_plan()
     {

+ 2 - 0
application/route.php

@@ -91,6 +91,8 @@ Route::group('api', function () {
         Route::get('cs_query_sign', 'api/lave/csquerySign');  //测试查询签约
         Route::get('plan_lst', 'api/lave/plan_lst');  //模版列表
         Route::get('plan_info', 'api/lave/plan_read');  //模版列表
+        Route::get('user_lst', 'api/lave/user_plan_lst');  //用户签约模版列表
+        Route::get('user_info', 'api/lave/user_record_lst');  //模版列表
     });
     //帮扶
     Route::group('help', function () {

+ 0 - 16
vendor/overtrue/wechat/src/Payment/Contract/Client.php

@@ -99,20 +99,4 @@ class Client extends BaseClient
 
         return $this->safeRequest('papay/deletecontract', $params);
     }
-    /**
-     * query papay contrace.
-     *
-     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
-     *
-     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
-     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
-     * @throws \GuzzleHttp\Exception\GuzzleException
-     */
-    public function query(array $params)
-    {
-        $params['appid'] =$params['appid'] ?? $this->app['config']->app_id;
-//        $params['mchid'] = $this->app['config']['mch_id'];
-        @file_put_contents("quanju.txt", json_encode($params) . "-查询接口传参\r\n", 8);
-        return $this->request('papay/querycontract', $params);
-    }
 }