WorkerWithdrawController.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/5/26
  8. * Time: 17:13
  9. */
  10. namespace app\payment\controllers;
  11. use app\common\events\withdraw\WithdrawSuccessEvent;
  12. use app\common\exceptions\ShopException;
  13. use app\common\models\Withdraw;
  14. use app\payment\PaymentController;
  15. use app\common\services\Pay;
  16. use Yunshop\Love\Common\Models\LoveWithdrawRecords;
  17. use Yunshop\WorkerWithdraw\services\RequestService;
  18. use Exception;
  19. use Yunshop\WorkerWithdraw\services\WorkWithdrawService;
  20. class WorkerWithdrawController extends PaymentController
  21. {
  22. protected $parameters;
  23. protected $withdraw;
  24. public function __construct()
  25. {
  26. parent::__construct();
  27. date_default_timezone_set('PRC');
  28. $this->setParameter();
  29. //访问记录
  30. Pay::payAccessLog();
  31. //保存响应数据
  32. Pay::payResponseDataLog('', '好灵工提现回调', json_encode($this->parameters));
  33. if (!app('plugins')->isEnabled('worker-withdraw')) {
  34. \Log::debug('好灵工提现回调通知:插件未开启', $this->parameters);
  35. exit('success');
  36. }
  37. }
  38. /**
  39. * @return ApiService
  40. */
  41. private function api()
  42. {
  43. return ApiService::current($this->parameters['appkey']);
  44. }
  45. private function setParameter()
  46. {
  47. $this->parameters = request()->input();
  48. }
  49. /**
  50. * @param $trade_number
  51. */
  52. private function setWithdraw($trade_number)
  53. {
  54. $this->withdraw = HighLightWithdrawModel::where('order_sn', $trade_number)->first();
  55. if (!$this->withdraw) {
  56. \Log::debug('高灯提现结算单回调通知:提现订单信息未找到', $trade_number);
  57. exit('success');
  58. }
  59. \Setting::$uniqueAccountId = \YunShop::app()->uniacid = $this->withdraw->uniacid;
  60. }
  61. /**
  62. * @return void
  63. * 好灵工打款结果异步回调
  64. */
  65. public function notifyUrl()
  66. {
  67. $callback_data = request()->all();
  68. \Log::debug('好灵工打款回调', $callback_data);
  69. // $data = '{"biz_content":"{\"recvType\":\"ALIPAY\",\"custBatchNo\":\"WS20220510115332681420\",\"totalDeduction\":0.99,\"batchTotalAgentFeeAmt\":0.00,\"batchServFeeAmt\":0.09,\"batchAmt\":0.90,\"batchStatus\":1,\"platBatchNo\":\"110202205103900126721085480\"}","method":"callBack","sign":"V965hv59aCKzKdHlR4j6sF611zuxSEelrV8RKjLndTLdL94K6rU6BlQ6TsyC6DqvKxWvIusMxFU44MNXZWSWDJgjCrAPx8Mgz4CFraoUx/8RVgn1CAt6Gnsg/wxdToWnzO3WSvchZNyDcsWvuWjrfI5FLVKGTm13lPXQaOEfHQZqVZ46rh//4gpVphJHgPl0ktfwnHfWQDVzA84VApDtODCcQ4fHgytSfD9Ri/tF0rB9lJ6uRsIeAvBE0lI7y0lIBxVbOYSJ4xilMFakk9Ton9UhIp9TFaF6oFHhxn9Bn2NiNHbULR33exqh8K23hIczo9qNJ0t9QBSxR+ByIj8tiw==","merchant_request_no":"0ef47d209f1d4bb1867008821d3721d8","sign_type":"RSA2","version":"1.0","timestamp":"2022-05-10"}';
  70. // $callback_data = json_decode($data,true);
  71. $callback = json_decode($callback_data['biz_content'], true);
  72. $tag = substr($callback['custBatchNo'], 0, 2);
  73. if ($tag == 'WS') {
  74. if (!$withdraw_log = Withdraw::where('withdraw_sn', $callback['custBatchNo'])->first()) {
  75. \Log::debug('好灵工打款回调异常:不存在的打款单号');
  76. }
  77. } elseif ($tag == 'LW') {
  78. if (app('plugins')->isEnabled('love')) {
  79. if (!$withdraw_log = LoveWithdrawRecords::where('order_sn', $callback['custBatchNo'])->first()) {
  80. \Log::debug('好灵工打款回调异常:不存在的打款单号');
  81. }
  82. } else {
  83. \Log::debug('好灵工打款回调异常:爱心值插件关闭');
  84. return;
  85. }
  86. } else {
  87. \Log::debug('好灵工打款回调异常:不存在提现方式');
  88. return;
  89. }
  90. \YunShop::app()->uniacid = $withdraw_log->uniacid;
  91. \app\common\facades\Setting::$uniqueAccountId = $withdraw_log->uniacid;
  92. $res = (new WorkWithdrawService())->refreshWithdraw($callback['custBatchNo']);
  93. if (!$res['result']) {
  94. \Log::debug('好灵工打款回调异常', $res['msg']);
  95. return;
  96. }
  97. \Log::debug('好灵工打款回调结果', $res['data']['status']);
  98. if ($res['result'] && $res['data']['status'] === 1) {
  99. exit('success');
  100. }
  101. }
  102. public function refundNotifyUrl()
  103. {
  104. }
  105. }