123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- use bsn\Bsn;
- use app\common\library\Sms as Smslib;
- class Sandpay extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
-
-
-
- public function notify()
- {
-
-
- $postData = isset($_POST['data']) ? $_POST['data'] : [];
- $sign = isset($_POST['sign']) ? $_POST['sign'] : '';
- filePut('[wallet][paySucc]充值参数 recharge money data:'.$postData."\n".' sign:'.$sign);
-
-
-
-
- $plainText = $postData;
- $dataArray = json_decode($postData,true);
- $head = isset($dataArray['head']) ? $dataArray['head'] : [];
- $body = isset($dataArray['body']) ? $dataArray['body'] : [];
- $respCode = isset($head['respCode']) ? $head['respCode'] : '000001';
- $orderStatus = isset($body['orderStatus']) ? $body['orderStatus'] : '0';
- $orderCode = isset($body['orderCode']) ? $body['orderCode'] : '';
- $extend = isset($body['extend']) ? $body['extend'] : '';
- $extendType = '';
- if (!empty($extend)) {
- $extendArr = json_decode($extend,true);
- $extendType = isset($extendArr['type']) ? $extendArr['type'] : '';
- }
-
- $sandpay = new \app\common\library\Sandpay();
-
- $encrypt_str = $sandpay->verify($plainText, $sign);
- if($encrypt_str != 1){
- filePut('[wallet][paySucc]充值入账更新余额失败 recharge money fail'.$orderCode."\n".' data:'.$postData."\n".' sign:'.$sign);
- echo 'Fail';exit;
- }
-
- if($respCode != '000000'){
- filePut('[wallet][paySucc]验证回调状态失败 respCode'.$orderCode);
- echo 'Fail';exit;
- }
- if($orderStatus != '1'){
- filePut('[wallet][paySucc]验证回调订单状态 recharge money fail orderStatus'.$orderCode);
- echo 'Fail';exit;
- }
-
- $PayResult = Db::name('pay_order');
- $where['pay_no'] = $orderCode;
- $order_info = $PayResult->where($where)->find();
- if ($order_info['status'] == 1) {
- filePut('[wallet][paySucc]充值入账更新余额失败 recharge money fail status已更新过'.$orderCode);
- echo 'respCode=000000';exit;
- }
-
-
- $_data['status'] = 2;
- $result = $PayResult->where($where)->setField($_data);
- if ($result || 1) {
-
- $payEventWhere['pay_no'] = $orderCode;
- $payEvent = Db::name('pay_event')->where($payEventWhere)->find();
- $args = isset($payEvent['args']) ? $payEvent['args'] : '';
- $args = json_decode($args,true);
- $rechargeM = new \app\common\model\Recharge();
- if ($extendType == 'gold') {
- $payRes = $rechargeM->goldpaysucc($orderCode,$args);
- $payTypeStr = '充值';
- } elseif($extendType == 'vip') {
- $payRes = $rechargeM->vippaysucc($orderCode,$args);
- $payTypeStr = 'vip';
- } else {
- $payRes = false;
- $payTypeStr = '未知支付类型';
- }
- if(!$payRes){
- filePut('[wallet][paySucc]'.$payTypeStr.'更新失败请查看问题'.$orderCode);
- exit;
- }
- filePut('[wallet][paySucc]回调成功'.$orderCode);
- echo 'respCode=000000';exit;
- }
- }
- }
|