ConvergeseparateController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <?php
  2. /**
  3. * Author: 芸众商城 www.yunzshop.com
  4. * Date: 2019/4/24
  5. * Time: 下午3:10
  6. */
  7. namespace app\payment\controllers;
  8. use app\common\helpers\Url;
  9. use app\common\models\AccountWechats;
  10. use app\common\models\Order;
  11. use app\common\models\OrderPay;
  12. use app\common\models\PayOrder;
  13. use app\common\services\Pay;
  14. use app\common\services\PayFactory;
  15. use app\framework\Http\Request;
  16. use app\payment\PaymentController;
  17. use Illuminate\Support\Facades\DB;
  18. use Yunshop\ConvergeAllocFunds\events\SupplierSeparateEndEvent;
  19. use Yunshop\ConvergeAllocFunds\models\OpenAccount;
  20. use Yunshop\ConvergeAllocFunds\models\PayDetailed;
  21. use Yunshop\ConvergeAllocFunds\models\PayRecord;
  22. use Yunshop\ConvergeAllocFunds\models\SeparateRecode;
  23. use Yunshop\ConvergeAllocFunds\services\JoinPayService;
  24. use Yunshop\ConvergePay\models\WithdrawLog;
  25. use Yunshop\ConvergePay\services\NotifyService;
  26. use app\common\events\withdraw\WithdrawSuccessEvent;
  27. use Yunshop\Supplier\common\models\SupplierOrder;
  28. class ConvergeseparateController extends PaymentController
  29. {
  30. private $attach = [];
  31. private $parameter = [];
  32. public function __construct()
  33. {
  34. parent::__construct();
  35. $this->parameter = request()->all();
  36. }
  37. /***
  38. * @param Request $request
  39. * 分账回调函数
  40. */
  41. public function separateNotify()
  42. {
  43. $data["resp_code"]="A1000";
  44. $data["resp_msg"]="success";
  45. \Log::debug("separateNotify分账回调数据",$this->parameter);
  46. \Log::debug("separateNotify分账回调数据1",\YunShop::request());
  47. \Log::debug("separateNotify分账回调数据3",request()->all());
  48. $pay_sn=$this->parameter["data"]["mch_order_no"];
  49. $alt_order_no=$this->parameter["data"]["alt_order_no"]; //订单号
  50. $alt_mch_no=$this->parameter["data"]["alt_info"][0]["allocate_mch_no"];
  51. $allocate_status=$this->parameter["data"]["alt_info"][0]["allocate_status"];
  52. $money=$this->parameter["data"]["alt_info"][0]["allocate_amount"];
  53. \Log::debug("separateNotify分账回调数据5",$alt_mch_no);
  54. if($this->parameter["data"]["biz_code"] == "B100000" && $this->parameter["data"]["alt_main_status"]=="P1000" && $allocate_status==100 ){
  55. \Log::debug("分账回调-分账成功");
  56. \Log::debug("分账回调支付单号",$pay_sn);
  57. \Log::debug("分账回调商户号",$alt_mch_no);
  58. \Log::debug("分账回调订单号",$alt_order_no);
  59. $pay_detailed=PayDetailed::where("pay_sn",$pay_sn)->where("alt_mch_no",$alt_mch_no)->first();
  60. $pay_id=$pay_detailed->order_pay_id;
  61. $pay_detailed->status=2;
  62. $pay_detailed->end_time=time();
  63. $pay_detailed->save();
  64. PayRecord::where("pay_sn",$pay_sn)->increment("separate_amount",$money);
  65. \Log::debug("分账回调返回数据ffff",$pay_id);
  66. event(new SupplierSeparateEndEvent($pay_id)); //处理完结事件
  67. \Log::debug("分账回调返回数据",json_encode($data));
  68. echo json_encode($data);
  69. exit;
  70. }
  71. }
  72. //开户完成后回调
  73. public function createNotify()
  74. {
  75. $data["resp_code"]="A1000";
  76. $data["resp_msg"]="success";
  77. \Log::debug("createNotify回调数据",$this->parameter);
  78. \Log::debug("createNotify回调数据3",request()->all());
  79. $alt_mch_no=$this->parameter["data"]["alt_mch_no"];
  80. if($this->parameter["resp_code"]=="A1000"){
  81. DB::connection()->enableQueryLog(); // 开启查询日志
  82. OpenAccount::where("alt_mch_no",$alt_mch_no)->update(["auth_status"=>$this->parameter["data"]["auth_status"],"biz_msg"=>$this->parameter["data"]["biz_msg"]]);
  83. $logs = DB::getQueryLog();
  84. \Log::debug("createNotify回调数据sql:",$logs);
  85. }
  86. echo json_encode($data);
  87. exit;
  88. }
  89. /***
  90. * 完结分账回调, 剩余金额全部结算到平台总账户
  91. */
  92. public function finishAllocateNotify()
  93. {
  94. $data["resp_code"]="A1000";
  95. $data["resp_msg"]="success";
  96. \Log::debug("完结分账回调数据",$this->parameter);
  97. \Log::debug("完结分账回调数据3",request()->all());
  98. if($this->parameter["data"]["alt_main_status"]=="P1000"){
  99. PayRecord::where("pay_sn",$this->parameter["data"]["mch_order_no"])
  100. ->update([
  101. "platform_revenue"=>$this->parameter["data"]["alt_this_amount"],
  102. "separate_status"=>2,
  103. "poundage"=>$this->parameter["data"]["fee"],
  104. ]); //完结成功后 更新支付单状态, 与记录平台收益
  105. }
  106. echo json_encode($data);
  107. exit;
  108. }
  109. /***
  110. * @param $pay_id
  111. * @throws \GuzzleHttp\Exception\GuzzleException
  112. * 处理最终完结逻辑
  113. */
  114. public function findPayOrder($pay_id)
  115. {
  116. \Log::debug("分账回调findPayOrder-------pay_id:",$pay_id);
  117. (new JoinPayService())->findPayOrder($pay_id);
  118. }
  119. /***
  120. * @param Request $request
  121. * @throws \GuzzleHttp\Exception\GuzzleException
  122. * 结算回调函数
  123. */
  124. public function manualClearNotify()
  125. {
  126. // dd(333);
  127. $data["resp_code"]="A1000";
  128. $data["resp_msg"]="success";
  129. \Log::debug("结算回调数据",$this->parameter);
  130. \Log::debug("结算回调数据1",\YunShop::request()->get());
  131. $alt_mch_no=$this->parameter["data"]["alt_mch_no"];
  132. $mch_order_no=$this->parameter["data"]["mch_order_no"];
  133. if($this->parameter["data"]["order_status"] == "P1000" ){
  134. $up_data["status"]=5; //结算完成
  135. /*分账成功后操作*/
  136. $parameter=$this->parameter;
  137. DB::transaction(function ()use($parameter) {
  138. \Log::debug("结算完成开启事务",$parameter);
  139. $pay_order=PayDetailed::where("pay_sn",$parameter["data"]["mch_order_no"])->first()->toArray();
  140. \Log::debug("结算完成开启事务查询order信息",$pay_order);
  141. PayRecord::where("order_pay_id",$pay_order["order_pay_id"])->increment('separate_amount',$parameter["data"]["settle_amount"]); //结算成功后增加结算金额
  142. SupplierOrder::where('order_id', $pay_order["order_id"])->update(['apply_status' => 1]); //结算成功后 更新供应商订单状态
  143. $this->findPayOrder( $pay_order["order_pay_id"]); //查询当前支付单下的 订单是否都已经分过账, 如果都已经分账就走完结,给平台分账
  144. });
  145. }else{
  146. $up_data["status"]=4; //结算失败
  147. }
  148. PayDetailed::where("pay_sn",$mch_order_no)->where("alt_mch_no",$alt_mch_no)->update($up_data);
  149. echo json_encode($data);
  150. exit;
  151. }
  152. /***
  153. * @param $settle_data
  154. * @param $money
  155. * 结算流程
  156. */
  157. public function settle($settle_data,$money)
  158. {
  159. \Log::debug("开始进入结算数据:",$settle_data);
  160. \Log::debug("结算金额:",$money);
  161. $settle_res= (new JoinPayService())->manualClearing($settle_data,$money);
  162. if($settle_res["data"]["biz_code"] == B100000){
  163. PayDetailed::where("pay_sn",$settle_data["mch_order_no"])->where("alt_mch_no",$settle_data["alt_mch_no"])->update(["status"=>3]);
  164. \Log::debug("结算请求成功",$settle_res);
  165. }else{
  166. \Log::debug("结算请求失败",$settle_res);
  167. }
  168. }
  169. public function alipayNotify()
  170. {
  171. if (empty(\YunShop::app()->uniacid)) {
  172. if (!$this->parameter['r5_Mp']) {
  173. \Log::debug('汇聚支付宝支付-分账回调公众号为空--->', $this->parameter);
  174. echo 'No official account exists.';exit();
  175. }
  176. \Log::debug('汇聚支付宝支付-分账回调公众号为空 开始设置uniacid--->', $this->parameter);
  177. \Setting::$uniqueAccountId = \YunShop::app()->uniacid = $this->parameter['r5_Mp'];
  178. AccountWechats::setConfig(AccountWechats::getAccountByUniacid(\YunShop::app()->uniacid));
  179. }
  180. \Log::debug("payNotify支付宝支付回调数据",$this->parameter);
  181. if($this->parameter["r6_Status"]==100 ){
  182. \Log::debug("payNotify支付宝支付回调成功");
  183. $data = [
  184. 'total_fee' => floatval($this->parameter["r3_Amount"]),
  185. 'out_trade_no' => $this->parameter["r2_OrderNo"],
  186. 'trade_no' => $this->parameter["r7_TrxNo"],
  187. 'unit' => 'yuan',
  188. 'pay_type' => '汇聚支付宝支付-分账',
  189. 'pay_type_id' => PayFactory::PAY_ALI_SEPARATE_HJ,
  190. ];
  191. $pay_id=OrderPay::where("pay_sn",$this->parameter["r2_OrderNo"])->first()->id;
  192. $record_data["pay_sn"]=$this->parameter["r2_OrderNo"];
  193. $record_data["order_pay_id"]=$pay_id;
  194. $record_data["uniacid"]=\YunShop::app()->uniacid;
  195. \Log::debug('<---------汇聚分账支付宝支付回调--插入PayRecord数据--->', $record_data);
  196. PayRecord::create($record_data);
  197. \Log::debug('<---------汇聚分账支付宝支付回调--交易成功--->', request()->all());
  198. \Log::debug('<---------汇聚分账支付宝支付回调--请求数据--->', $data);
  199. $this->payResutl($data);
  200. }
  201. echo 'success'; exit();
  202. }
  203. public function payNotify()
  204. {
  205. if (empty(\YunShop::app()->uniacid)) {
  206. if (!$this->parameter['r5_Mp']) {
  207. \Log::debug('汇聚微信支付-分账回调公众号为空--->', $this->parameter);
  208. echo 'No official account exists.';exit();
  209. }
  210. \Log::debug('汇聚微信支付-分账回调公众号为空 开始设置uniacid--->', $this->parameter);
  211. \Setting::$uniqueAccountId = \YunShop::app()->uniacid = $this->parameter['r5_Mp'];
  212. AccountWechats::setConfig(AccountWechats::getAccountByUniacid(\YunShop::app()->uniacid));
  213. }
  214. \Log::debug("payNotify支付回调数据",$this->parameter);
  215. if($this->parameter["r6_Status"]==100 ){
  216. \Log::debug("payNotify支付回调成功");
  217. $data = [
  218. 'total_fee' => floatval($this->parameter["r3_Amount"]),
  219. 'out_trade_no' => $this->parameter["r2_OrderNo"],
  220. 'trade_no' => $this->parameter["r7_TrxNo"],
  221. 'unit' => 'yuan',
  222. 'pay_type' => '汇聚微信支付-分账',
  223. 'pay_type_id' => PayFactory::PAY_SEPARATE_HJ,
  224. ];
  225. $pay_id=OrderPay::where("pay_sn",$this->parameter["r2_OrderNo"])->first()->id;
  226. $record_data["pay_sn"]=$this->parameter["r2_OrderNo"];
  227. $record_data["order_pay_id"]=$pay_id;
  228. $record_data["uniacid"]=\YunShop::app()->uniacid;
  229. \Log::debug('<---------汇聚分账支付回调--插入PayRecord数据--->', $record_data);
  230. PayRecord::create($record_data);
  231. \Log::debug('<---------汇聚分账支付回调--交易成功--->', request()->all());
  232. \Log::debug('<---------汇聚分账支付回调--请求数据--->', $data);
  233. $this->payResutl($data);
  234. }
  235. echo 'success'; exit();
  236. }
  237. public function refundNotify()
  238. {
  239. \Log::debug('<---------汇聚分账支付退款回调--数据--->', request()->all());
  240. }
  241. public function notifyUrlWechat()
  242. {
  243. if (empty(\YunShop::app()->uniacid)) {
  244. if (!$this->getResponse('r5_Mp')) {
  245. \Log::debug('汇聚支付回调公众号为空--->', $this->parameter);
  246. echo 'No official account exists.';exit();
  247. }
  248. \Setting::$uniqueAccountId = \YunShop::app()->uniacid =$this->getResponse('r5_Mp');
  249. AccountWechats::setConfig(AccountWechats::getAccountByUniacid(\YunShop::app()->uniacid));
  250. }
  251. $this->log($this->parameter, '微信支付-HJ');
  252. if ($this->getSignResult()) {
  253. if ($_GET['r6_Status'] == '100') {
  254. \Log::debug('------微信支付-HJ 验证成功-----');
  255. $data = $this->data('微信支付-HJ', '28');
  256. $this->payResutl($data);
  257. \Log::debug('----微信支付-HJ 结束----');
  258. echo 'success';
  259. } else {
  260. //其他错误
  261. \Log::debug('------微信支付-HJ 其他错误-----');
  262. echo 'fail';
  263. }
  264. } else {
  265. //签名验证失败
  266. \Log::debug('------微信支付-HJ 签名验证失败-----');
  267. echo 'fail1';
  268. }
  269. }
  270. public function returnUrlWechat()
  271. {
  272. $trade = \Setting::get('shop.trade');
  273. if (!is_null($trade) && isset($trade['redirect_url']) && !empty($trade['redirect_url'])) {
  274. return redirect($trade['redirect_url'])->send();
  275. }
  276. if (0 == $_GET['state'] && $_GET['errorDetail'] == '成功') {
  277. redirect(Url::absoluteApp('member/payYes', ['i' => $this->getResponse('r5_Mp')]))->send();
  278. } else {
  279. redirect(Url::absoluteApp('member/payErr', ['i' => $this->getResponse('r5_Mp')]))->send();
  280. }
  281. }
  282. public function notifyUrlAlipay()
  283. {
  284. if (empty(\YunShop::app()->uniacid)) {
  285. if (!$this->getResponse('r5_Mp')) {
  286. \Log::debug('汇聚支付回调公众号为空--->', $this->parameter);
  287. echo 'No official account exists.';exit();
  288. }
  289. \Setting::$uniqueAccountId = \YunShop::app()->uniacid = $this->getResponse('r5_Mp');
  290. AccountWechats::setConfig(AccountWechats::getAccountByUniacid(\YunShop::app()->uniacid));
  291. }
  292. $this->log($this->parameter, '支付宝支付-HJ');
  293. if ($this->getSignResult()) {
  294. if ($_GET['r6_Status'] == '100') {
  295. \Log::debug('------支付宝支付-HJ 验证成功-----');
  296. $data = $this->data('支付宝支付', '29');
  297. $this->payResutl($data);
  298. \Log::debug('----支付宝支付-HJ 结束----');
  299. echo 'success';
  300. } else {
  301. //其他错误
  302. \Log::debug('------支付宝支付-HJ 其他错误-----');
  303. echo 'fail';
  304. }
  305. } else {
  306. //签名验证失败
  307. \Log::debug('------支付宝支付-HJ 签名验证失败-----');
  308. echo 'fail1';
  309. }
  310. }
  311. public function returnUrlAlipay()
  312. {
  313. $trade = \Setting::get('shop.trade');
  314. if (!is_null($trade) && isset($trade['redirect_url']) && !empty($trade['redirect_url'])) {
  315. return redirect($trade['redirect_url'])->send();
  316. }
  317. if (0 == $_GET['state'] && $_GET['errorDetail'] == '成功') {
  318. redirect(Url::absoluteApp('member/payYes', ['i' => $this->getResponse('r5_Mp')]))->send();
  319. } else {
  320. redirect(Url::absoluteApp('member/payErr', ['i' => $this->getResponse('r5_Mp')]))->send();
  321. }
  322. }
  323. /**
  324. * 签名验证
  325. *
  326. * @return bool
  327. */
  328. public function getSignResult()
  329. {
  330. $pay = \Setting::get('plugin.convergePay_set');
  331. $notify = new NotifyService();
  332. $notify->setKey($pay['hmacVal']);
  333. return $notify->verifySign();
  334. }
  335. /**
  336. * 支付日志
  337. *
  338. * @param $data
  339. * @param $sign
  340. */
  341. public function log($data, $sign)
  342. {
  343. //访问记录
  344. Pay::payAccessLog();
  345. //保存响应数据
  346. Pay::payResponseDataLog($this->getResponse('r2_OrderNo'), $sign, json_encode($data));
  347. }
  348. /**
  349. * 支付回调参数
  350. *
  351. * @param $pay_type_id
  352. * @return array
  353. */
  354. public function data($pay_type, $pay_type_id)
  355. {
  356. $data = [
  357. 'total_fee' => floatval($this->parameter['r3_Amount']),
  358. 'out_trade_no' => $this->getResponse('r2_OrderNo'),
  359. 'trade_no' => $this->parameter['r7_TrxNo'],
  360. 'unit' => 'yuan',
  361. 'pay_type' => $pay_type,
  362. 'pay_type_id' => $pay_type_id
  363. ];
  364. return $data;
  365. }
  366. /**
  367. * 提现回调
  368. *
  369. */
  370. public function notifyUrlWithdraw()
  371. {
  372. $parameter = request();
  373. \Log::debug('汇聚提现回调参数--', $parameter->input());
  374. //查询提现记录
  375. $withdrawLog = WithdrawLog::where('merchantOrderNo',$parameter->merchantOrderNo)->first();
  376. if (!$withdrawLog) {
  377. echo json_encode([
  378. 'statusCode' => 2002,
  379. 'message' => "汇聚代付记录不存在,单号:{$parameter->merchantOrderNo}",
  380. 'errorCode' => '',
  381. 'errorDesc' => ''
  382. ]);exit();
  383. }
  384. //已提现成功的记录无需再处理
  385. if ($withdrawLog->status == 1) {
  386. echo json_encode([
  387. 'statusCode' => 2001,
  388. 'message' => "成功"
  389. ]);exit();
  390. }
  391. //设置公众号i
  392. if (empty(\YunShop::app()->uniacid)) {
  393. \Setting::$uniqueAccountId = \YunShop::app()->uniacid = $withdrawLog->uniacid;
  394. AccountWechats::setConfig(AccountWechats::getAccountByUniacid(\YunShop::app()->uniacid));
  395. }
  396. //访问记录
  397. Pay::payAccessLog();
  398. //保存响应数据
  399. Pay::payResponseDataLog($withdrawLog->withdraw_sn, '汇聚提现回调', $parameter->input());
  400. if ($this->checkWithdrawHmac($parameter)) {
  401. if ($parameter->status == '205') {
  402. \Log::debug('------汇聚打款 开始-----'.$withdrawLog->withdraw_type);
  403. if ($withdrawLog->withdraw_type == 1) {
  404. //兼容供应商提现
  405. if ( app('plugins')->isEnabled('supplier')) {
  406. $supplierWithdraw = \Yunshop\Supplier\common\models\SupplierWithdraw::where('apply_sn', $withdrawLog->withdraw_sn)->where('status', 4)->first();
  407. if ($supplierWithdraw) {
  408. $supplierWithdraw->status = 3;
  409. $supplierWithdraw->pay_time = time();
  410. $supplierWithdraw->save();
  411. }
  412. }
  413. } else {
  414. event(new WithdrawSuccessEvent($withdrawLog->withdraw_sn));
  415. }
  416. \Log::debug('----汇聚打款 结束----');
  417. $withdrawLog->status = 1;
  418. $withdrawLog->response_data = $parameter->input();
  419. $withdrawLog->save();
  420. echo json_encode([
  421. 'statusCode' => 2001,
  422. 'message' => "成功"
  423. ]);exit();
  424. }
  425. \Log::debug('------汇聚打款失败---- ', $parameter->input());
  426. if ( in_array($parameter->input('status'), ['204', '208','214'])) {
  427. $withdrawLog->status = -1;
  428. $withdrawLog->desc = $parameter->input('errorCodeDesc');
  429. $withdrawLog->response_data = $parameter->input();
  430. $withdrawLog->save();
  431. echo json_encode([
  432. 'statusCode' => 2002,
  433. 'message' => "受理失败",
  434. 'errorCode' => $parameter->errorCode,
  435. 'errorDesc' => $parameter->errorCodeDesc
  436. ]);exit();
  437. }
  438. } else {
  439. //签名验证失败
  440. \Log::debug('------汇聚打款 签名验签失败-----');
  441. echo json_encode([
  442. 'statusCode' => 2002,
  443. 'message' => "签名验签失败",
  444. 'errorCode' => '300002017',
  445. 'errorDesc' => '签名验签失败'
  446. ]);exit();
  447. }
  448. }
  449. /**
  450. * 验证提现签名
  451. *
  452. * @param $parameter
  453. * @return bool
  454. */
  455. public function checkWithdrawHmac($parameter)
  456. {
  457. $setting = \Setting::get('plugin.convergePay_set');
  458. $verify = $parameter->hmac == md5($parameter->status . $parameter->errorCode . $parameter->errorCodeDesc . $parameter->userNo
  459. . $parameter->merchantOrderNo . $parameter->platformSerialNo . $parameter->receiverAccountNoEnc
  460. . $parameter->receiverNameEnc . sprintf("%.2f", $parameter->paidAmount) . sprintf("%.2f", $parameter->fee) . $setting['hmacVal']);
  461. \Log::debug('---汇聚打款签名验证--->', [$verify]);
  462. return $verify;
  463. }
  464. /**
  465. * 微信或支付宝退款
  466. */
  467. public function refundUrlWechat()
  468. {
  469. $this->logRefund($this->parameter, '微信或支付宝退款-HJ');
  470. if ($this->getSignWechatResult()) {
  471. if ($this->parameter['ra_Status'] == '100') {
  472. \Log::debug('------微信或支付宝退款-HJ 验证成功-----');
  473. \Log::debug('----微信或支付宝退款-HJ 结束----');
  474. } else {
  475. //其他错误
  476. \Log::debug('------微信或支付宝退款-HJ 其他错误-----');
  477. }
  478. } else {
  479. //签名验证失败
  480. \Log::debug('------微信或支付宝退款-HJ 签名验证失败-----');
  481. }
  482. echo 'success';
  483. }
  484. /**
  485. * 汇聚-微信或支付宝退款 签名验证
  486. *
  487. * @return bool
  488. */
  489. public function getSignWechatResult()
  490. {
  491. $pay = \Setting::get('plugin.convergePay_set');
  492. \Log::debug('--汇聚-微信或支付宝退款签名验证参数--' . $this->parameter['r1_MerchantNo'] . $this->parameter['r2_OrderNo']
  493. . $this->parameter['r3_RefundOrderNo'] . $this->parameter['r4_RefundAmount_str'] . $this->parameter['r5_RefundTrxNo']
  494. . $this->parameter['ra_Status'] . $pay['hmacVal']);
  495. return $this->parameter['hmac'] == md5($this->parameter['r1_MerchantNo'] . $this->parameter['r2_OrderNo']
  496. . $this->parameter['r3_RefundOrderNo'] . $this->parameter['r4_RefundAmount_str'] . $this->parameter['r5_RefundTrxNo']
  497. . $this->parameter['ra_Status'] . $pay['hmacVal']);
  498. }
  499. /**
  500. * 支付日志
  501. *
  502. * @param $data
  503. * @param $sign
  504. */
  505. public function logRefund($data, $sign)
  506. {
  507. //访问记录
  508. Pay::payAccessLog();
  509. //保存响应数据
  510. Pay::payResponseDataLog($data['r2_OrderNo'], $sign, json_encode($data));
  511. }
  512. /**
  513. * 获取参数值
  514. * @param string $key
  515. * @return string
  516. */
  517. public function getResponse($key)
  518. {
  519. //todo 兼容以前判断
  520. if ($key == 'r2_OrderNo' && strpos($this->parameter['r2_OrderNo'], ':') !== false) {
  521. $attach = explode(':', $_GET['r2_OrderNo']);
  522. return $attach[0];
  523. }
  524. return array_get($this->parameter, $key, '');
  525. }
  526. }