WIN-2308041133\Administrator 6 mēneši atpakaļ
vecāks
revīzija
1f09bb76c5
2 mainītis faili ar 23 papildinājumiem un 46 dzēšanām
  1. 21 46
      application/api/controller/Lave.php
  2. 2 0
      extend/liuniu/WechatService.php

+ 21 - 46
application/api/controller/Lave.php

@@ -293,13 +293,13 @@ class Lave extends Api
 //            $rs = WechatService::paymentOrder($openid, $orderInfo['order_id'], $orderInfo['amount'], "lave", $orderInfo['order_name'], '', 'JSAPI', [], $cid);
                 $rs = WechatService::papPayApply($arr['out_trade_no'], $arr['total_fee'], "lave", '月捐款', 'PAP', [], $cid,$arr['mch_id'],$arr['contract_id']);
                 $where1['cid']=$cid;
-                $where1['user_id']=$this->auth->getUserinfo()['id'];
-                $where1['order_name']='月捐款';
-                $where1['category_id']=81;
+                $where1['user_id']=$v['uid'];
+                $where1['order_name']=$v['order_name'];
+                $where1['category_id']=$v['category_id'];
                 $where1['amount']=$arr['total_fee'];
-                $where1['name']=$this->auth->getUserinfo()['username'];
+                $where1['name']=$v['contract_display_account'];
                 $where1['contact']='';
-                $where1['tel']=$this->auth->getUserinfo()['mobile'];
+                $where1['tel']=$v['tel'];
                 $where1['address']='用户未填写联系地址';
                 $where1['is_open']=$v['is_open'];
                 $where1['is_ticket']='0';
@@ -313,11 +313,17 @@ class Lave extends Api
     public function deleteSign(Request $request){
         $where = UtilService::postMore(
             [
+                ['id',0],
                 ['cid', $this->cid],
                 ['user_id', $this->auth->getUserinfo()['id']],
             ], $request
         );
-        $sign_info=WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing',1)->find();
+        if ($where['id']==0){
+            $sign_info=WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing',0)->find();
+        }else{
+            $sign_info=WechatPlanRecord::where('id', $where['id'])->where('is_signing',0)->find();
+        }
+
         if (!$sign_info){
             $this->error('未找到签约信息!');
         }
@@ -327,12 +333,13 @@ class Lave extends Api
 //        $mch_id,$contract_code,$pan_id,$version='1.0',$options=[],$cid=0)
         $rs=WechatService::deleteSign($mch_id,$contract_code,$plan_id,'1.0',[],$where['cid']);
         @file_put_contents("quanju.txt", json_encode($rs)."-解除签约返回结果\r\n", 8);
-        if ($rs){
-            WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing',0)->update(['is_signing'=>1]);
-            $this->success('解除签约成功!');
-        }else{
-            $this->error('解除签约失败!');
-        }
+        $this->success('解除签约成功!');
+//        if ($rs){
+//            WechatPlanRecord::where('cid', $where['cid'])->where('uid', $where['user_id'])->where('is_signing',0)->update(['is_signing'=>1]);
+//            $this->success('解除签约成功!');
+//        }else{
+//            $this->error('解除签约失败!');
+//        }
     }
 //    查询签约状态
 //    public function querySign(int $cid,int $uid,int $plan_id,string $contract_code)
@@ -364,38 +371,6 @@ class Lave extends Api
 //            $this->error('查询签约状态失败!');
 //        }
 //    }
-    //    测试查询签约状态
-    public function csquerySign(Request $request)
-    {
-        $where = UtilService::postMore(
-            [
-                ['cid', ''],
-                ['user_id', ''],
-                ['contract_code',''],
-                ['plan_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', $where['cid'])->value('pay_weixin_mchid');
-//        $plan_id = $sign_info['plan_id'];
-//        $contract_code = $sign_info['contract_code'];
-        $rs = WechatService::querySign($mch_id, $where['contract_code'], $where['plan_id']);
-
-//        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 plan_lst(Request $request)
     {
         $where = UtilService::getMore(
@@ -443,8 +418,8 @@ class Lave extends Api
             [
                 ['id', 0],
 //                ['cid', 0],
-                ['cid', 0],
-                ['user_id', 0],
+                ['cid', $this->cid],
+                ['user_id', $this->auth->getUserinfo()['id']],
 //                ['user_id', 0],
             ], $request
         );

+ 2 - 0
extend/liuniu/WechatService.php

@@ -585,12 +585,14 @@ class WechatService
      */
     public static function deleteSign($mch_id,$contract_code,$pan_id,$version='1.0',$options=[],$cid=0)
     {
+        $contract_termination_remark = '月捐款解约';
         $order = array_merge(compact('mch_id','contract_code','pan_id','version'), $options);
         if ($order['detail'] == '') unset($order['detail']);
 //        $order['notify_url']=Request::instance()->domain() . "/api/wechat/notify/" . $cid;
         $result = self::payment(false, $cid)->contract->delete(
             $order
         );
+        var_dump($result);die();
         return $result;
     }
     /**