From 80ea7ba786311f94b0fb0099d7a7a49778328132 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 2 Sep 2021 19:15:45 +0800 Subject: [PATCH] add-admin-wx-profitsharingfinish --- admin/controllers/app/Profinish.php | 78 +++++++++++ admin/views/app/profinish.php | 23 ++++ .../WXconfig/1612096731.Config.php | 30 +++++ .../WXconfig/liche_cert/1612096731_cert.pem | 24 ++++ .../WXconfig/liche_cert/1612096731_key.pem | 28 ++++ api/third_party/WXpay/WxPay.Api.php | 36 ++++- api/third_party/WXpay/WxPay.Data.php | 123 ++++++++++++++++++ 7 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 admin/controllers/app/Profinish.php create mode 100644 admin/views/app/profinish.php create mode 100755 api/third_party/WXconfig/1612096731.Config.php create mode 100644 api/third_party/WXconfig/liche_cert/1612096731_cert.pem create mode 100644 api/third_party/WXconfig/liche_cert/1612096731_key.pem diff --git a/admin/controllers/app/Profinish.php b/admin/controllers/app/Profinish.php new file mode 100644 index 00000000..1fa27523 --- /dev/null +++ b/admin/controllers/app/Profinish.php @@ -0,0 +1,78 @@ +data['log_file'] = $this->log_file; + $this->data['_title'] = '结束分账'; + return $this->show_view('app/profinish',true); + } + + public function lists() + { + } + + public function get() + { + } + + + public function add() + { + } + + public function edit() + { + require_once COMMPATH."../api/third_party/WXconfig/1612096731.Config.php"; + require_once COMMPATH."../api/third_party/WXpay/WxPay.Api.php"; + $transaction_id = $this->input->post('transaction_id'); + $description = $this->input->post('description'); + if(!$transaction_id || !$description){ + return $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $this->load->helper('order'); + $out_order_no = create_order_no(); + $config = new WxPayConfig(); + $wxpay = new WxPayProfitSharingFinish(); + $wxpay -> SetTransaction_id($transaction_id); + $wxpay -> SetOut_order_no($out_order_no); + $wxpay -> SetDescription($description); + $return = WxPayApi::profitsharingfinish($config, $wxpay); + debug_log("[结束分账返回参数]:" .json_encode($return,JSON_UNESCAPED_UNICODE), $this->log_file,'wxapi'); + if($return['result_code'] == 'SUCCESS') { + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + }else{ + $err_msg = $return['return_msg'] ? $return['return_msg'] : $return['return_msg'].$return['err_code_des']; + return $this->show_json(SYS_CODE_FAIL, '错误信息:'.$err_msg); + } + } + + + public function del() + { + } + + public function batch() + { + // TODO: Implement batch() method. + } + + public function export() + { + // TODO: Implement export() method. + } +} diff --git a/admin/views/app/profinish.php b/admin/views/app/profinish.php new file mode 100644 index 00000000..3aecc655 --- /dev/null +++ b/admin/views/app/profinish.php @@ -0,0 +1,23 @@ +
+ + diff --git a/api/third_party/WXconfig/1612096731.Config.php b/api/third_party/WXconfig/1612096731.Config.php new file mode 100755 index 00000000..efe7dc44 --- /dev/null +++ b/api/third_party/WXconfig/1612096731.Config.php @@ -0,0 +1,30 @@ +GetTransaction_id()) { + throw new WxPayException("完结分账接口中,缺少必填参数transaction_id!"); + }else if(!$inputObj->IsOut_order_noSet()){ + throw new WxPayException("完结分账接口中,缺少必填参数out_order_no!"); + }else if(!$inputObj->IsDescriptSet()){ + throw new WxPayException("完结分账接口中,缺少必填参数description!"); + } + $inputObj->SetAppid($config::APPID);//公众账号ID + $inputObj->SetMch_id($config::MCHID);//商户号 + $inputObj->SetNonce_str(self::getNonceStr());//随机字符串 + + $inputObj->SetSign($config);//签名 + $xml = $inputObj->ToXml(); + $startTimeStamp = self::getMillisecond();//请求开始时间 + $response = self::postXmlCurl($config, $xml, $url, true, $timeOut); + $result = WxPayResults::Init($config, $response); + self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间 + + return $result; + } /** * * 查询退款 diff --git a/api/third_party/WXpay/WxPay.Data.php b/api/third_party/WXpay/WxPay.Data.php index 78c5f894..d4af09b7 100755 --- a/api/third_party/WXpay/WxPay.Data.php +++ b/api/third_party/WXpay/WxPay.Data.php @@ -3106,3 +3106,126 @@ class WxPayBizPayUrl extends WxPayDataBaseSignMd5 } } +/** + * + * 完结分账 + * @author widyhu + * + */ +class WxPayProfitSharingFinish extends WxPayDataBase +{ + /** + * 设置微信分配的公众账号ID + * @param string $value + **/ + public function SetAppid($value) + { + $this->values['appid'] = $value; + } + /** + * 获取微信分配的公众账号ID的值 + * @return 值 + **/ + public function GetAppid() + { + return $this->values['appid']; + } + + /** + * 设置微信的订单号,优先使用 + * @param string $value + **/ + public function SetTransaction_id($value) + { + $this->values['transaction_id'] = $value; + } + /** + * 获取微信的订单号,优先使用的值 + * @return 值 + **/ + public function GetTransaction_id() + { + return $this->values['transaction_id']; + } + /** + * 设置商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 + * @param string $value + **/ + public function SetOut_order_no($value) + { + $this->values['out_order_no'] = $value; + } + /** + * 获取商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号的值 + * @return 值 + **/ + public function GetOut_order_no() + { + return $this->values['out_order_no']; + } + /** + * 设置微信支付分配的商户号 + * @param string $value + **/ + public function SetMch_id($value) + { + $this->values['mch_id'] = $value; + } + /** + * 获取微信支付分配的商户号的值 + * @return 值 + **/ + public function GetMch_id() + { + return $this->values['mch_id']; + } + /** + * 设置随机字符串,不长于32位。推荐随机数生成算法 + * @param string $value + **/ + public function SetNonce_str($value) + { + $this->values['nonce_str'] = $value; + } + /** + * 获取随机字符串,不长于32位。推荐随机数生成算法的值 + * @return 值 + **/ + public function GetNonce_str() + { + return $this->values['nonce_str']; + } + /** + * 设置分账完结的原因描述 + * @param string $value + **/ + public function SetDescription($value) + { + $this->values['description'] = $value; + } + /** + * 获取分账完结的原因描述 + * @return 值 + **/ + public function GetDescription($value) + { + $this->values['description'] = $value; + } + /** + * 判断商户系统内部的退款单号 + * @return true 或 false + **/ + public function IsOut_order_noSet() + { + return array_key_exists('out_order_no', $this->values); + } + /** + * 判断分账描述是否填写 + * @return true 或 false + **/ + public function IsDescriptSet() + { + return array_key_exists('description', $this->values); + } +} +