jace 6 лет назад
Родитель
Сommit
e2c62349be

+ 2 - 1
normandcrm/crm/backend/models/forms/PayForm.php

@@ -33,6 +33,7 @@ class PayForm extends Model
         16 =>'对私支付',
         17 =>'对公支付',
         18 =>'globalpay',
+        19 =>'payplat支付',
     ]; 
     public static $payMethods = [
         'renren' => 1,
@@ -51,7 +52,7 @@ class PayForm extends Model
         'duisi'=>16,
         'duigong'=>17,
         'globalpay'=>18,
-		
+        'payplat'=>19,
     ];
 
     /**

+ 3 - 0
normandcrm/crm/backend/modules/user/controllers/PayController.php

@@ -58,6 +58,9 @@ class PayController extends BaseController
             if ($data['payType'] == 18) {
                 $data['bankCode'] = isset($data['globalpayBankCode']) ? trim($data['globalpayBankCode']) : '';
             }
+            if ($data['payType'] == 19) {
+                $data['bankCode'] = isset($data['payplatBankCode']) ? trim($data['payplatBankCode']) : '';
+            }
 
 			//echo "<pre>";
 			//var_dump($data);die;

+ 33 - 1
normandcrm/crm/backend/modules/user/views/bankdeposit/index.php

@@ -293,6 +293,27 @@ $this->title = '入金';
                                 <div class="col-sm-1"></div>
                             </div>
                         </div>
+
+                        <div id="payplat_bank_code" style="display: none">
+                            <br>
+                            <div class="row">
+                                <div class="col-sm-1"></div>
+                                <div class="col-sm-4">
+                                    <div class="input-group">
+                                       <span class="input-group-btn">
+                                           <button type="button" class="btn btn-primary"><i class="fa fa-dollar"></i>支付方式</button>
+                                       </span>
+                                        <select id="payplatBankCode" name="payplatBankCode" class="form-control">
+                                            <option value="USDT_PAY">人民币支付</option>
+                                        </select>
+                                    </div>
+                                </div>
+                                <div class="col-sm-4" style="text-align:center;">
+                                   <!-- <span style="line-height: 2.5;color:red">此通道单笔转账金额必须大于7500美元</span> -->
+                                </div>
+                                <div class="col-sm-1"></div>
+                            </div>
+                        </div>
                          
 
 						
@@ -477,7 +498,7 @@ $this->title = '入金';
         }
 
 
-         //对公支付
+        //对公支付
         if (payMethod == 'duigong') {
             $("#duigong_bank_code").attr("style", "display:block");
             $('#RMBcode').text('人民币');
@@ -488,6 +509,17 @@ $this->title = '入金';
 			$('.well').text('友情提示:银联入金,1个工作日到账。');
         }
 
+        //payplat支付
+        if (payMethod == 'payplat') {
+            $("#payplat_bank_code").attr("style", "display:block");
+            $('#RMBcode').text('人民币');
+            $('.guojiyinlian').css('display','none');
+            $('.well').text('友情提示:银联入金,1个工作日到账。');
+        } else {
+            $("#payplat_bank_code").attr("style", "display:none");
+			$('.well').text('友情提示:银联入金,1个工作日到账。');
+        }
+
     }
     changeBank()
     $("#payMethod").on("change", changeBank);

+ 8 - 2
normandcrm/service/common/config/params.php

@@ -50,6 +50,12 @@ return [
      "globalpay.confirmUrl" =>'http://142.11.227.79/pay/confirm/',                                    //跳转地址
      'globalpay.merId' => 'E1C75C27',                                                                 //商户号码
      'globalpay.Key' => '5323da5ece164c97a4f45d8b5ead40b8',                                           //md5key
-	
-		
+
+
+
+	 //payplat支付方式
+     "payplat.payUrl" =>'http://142.11.227.79/api/pay/order',                                       //网关地址
+     'payplat.merId' => 'E1C75C27',                                                                 //商户号码
+     'payplat.Key' => '5323da5ece164c97a4f45d8b5ead40b8',                                           //md5key
+         	
 ];

+ 3 - 0
normandcrm/service/common/pay/BasePayHandler.php

@@ -116,6 +116,9 @@ eot;
             case 18:
                 $handler = new \common\pay\globalpay\PayHandler();
                 break;
+            case 19:
+                $handler = new \common\pay\payplat\PayHandler();
+                break;
             default:
                 $handler = null;
                 break;

+ 1 - 0
normandcrm/service/common/pay/PayForm.php

@@ -42,6 +42,7 @@ class PayForm extends Model
         16 =>'对私支付',
         17 =>'对公支付',
         18 =>'globalpay',
+        19 =>'payplat支付',
     ];
 
     /**

+ 136 - 0
normandcrm/service/common/pay/payplat/PayHandler.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace common\pay\payplat;
+
+use backend\models\Config;
+use backend\models\Deposit;
+use backend\models\SyncDesposit;
+use common\pay\BasePayHandler;
+use Yii;
+use yii\helpers\VarDumper;
+
+class PayHandler extends BasePayHandler
+{
+    public $payUrl;
+    public $confirmUrl;
+    public $merId;
+    public $Key;
+
+    /**
+     * @inheritdoc  
+     */
+    public function init()
+    {
+        parent::init();
+        if ($this->payUrl == null) {
+            $this->payUrl = Yii::$app->params['payplat.payUrl'];
+        }
+        if ($this->merId == null) {
+            $this->merId = Yii::$app->params['payplat.merId'];
+        }
+        if ($this->Key == null) {
+            $this->Key = Yii::$app->params['payplat.Key'];
+        }
+    }
+
+    /**
+     * @param array $deposit 
+     * @param array $params
+     * @return string
+     */
+    public function outPay($deposit, $params = [])
+    {
+        $data = [];
+        
+        $data['userNo'] = $this->merId;                     //商户号码
+
+        $data['payType'] = 'wypay';                         //商户平台用户唯一标识
+        $data['price'] = $deposit['rmb'] * 100;             //订单金额
+        $data['sdOrderNo']  = $deposit['order_sn'];         //商户订单号码 
+
+        $data['sdReturnUrl'] =  $this->returnUrl;           //支付完成返回地址(同步地址)
+        $data['sdNotifyUrl']  = $this->notifyUrl;           //异步回调地址
+
+        $data['secret'] = $this->Key;                       //签名的秘钥
+
+        $data['sign'] = PayUtils::makeSign($data);
+        $result = static::createHtml($data, $this->payUrl);
+        return  $result;
+    }
+
+    /**
+     * @param array $data
+     * @return bool
+     */
+    public function handleNotify($data)
+    {
+   		
+        $tt = print_r($data,true);
+        file_put_contents('payplat_data.txt',$tt);
+        $data['secret'] = $this->Key;
+        if (isset($data['sign']) && trim($data['sign']) !== '') {
+			
+            if (PayUtils::verify($data)) {
+                    file_put_contents('payplat_success.txt','验签成功');
+                    $merOrderId = trim($data['orderNo']);
+                    $reuslt = Deposit::find()->where(['order_sn' => $merOrderId])->asArray()->limit(1)->one();
+                    if ($reuslt['type'] != 1) {
+                        $res = Deposit::updateAll(['type' => 1], "order_sn = $merOrderId");
+                        $configData = Config::find()->asArray()->one();
+                        if ($configData['auto_deposit'] == 1 && $res) {
+                            $syncDespositModel = new SyncDesposit();
+                            $syncDespositModel->login = $reuslt['login'];
+                            $syncDespositModel->amount = $reuslt['amount'];
+                            $syncDespositModel->comment = 'Deposit';
+                            $syncDespositModel->memo = $merOrderId;               //存储入金表的订单id
+                            $syncDespositModel->type = 2;
+                            $syncDespositModel->in_time = time();
+                            $syncDespositModel->save();
+                        }
+                        return true;
+                    }
+                
+            }
+
+        }
+        return false;
+    }
+
+    public function outNotify($success)
+    {
+        if ($success == true) {
+            return success;
+        } else {
+			// 返回的数据格式
+            return "FAIL";
+        }
+    }
+
+    /**
+     * @param array $data
+     * @return bool
+     */
+    public function handleReturn($data)
+    {
+        //Yii::warning('支付同步通知参数,' . VarDumper::dumpAsString($data), __METHOD__);
+        if (isset($data['sign']) && trim($data['sign']) !== '') {
+            $data['secret'] = $this->Key;
+            if (PayUtils::verify($data)) {
+                if ($data['payStatus'] == '1') {
+                    $merOrderId = trim($data['orderNo']);
+                    $reuslt = Deposit::find()->where(['order_sn' => $merOrderId])->asArray()->limit(1)->one();
+                    if ($reuslt) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    public function outReturn($success)
+    {
+
+    }
+
+}

+ 48 - 0
normandcrm/service/common/pay/payplat/PayUtils.php

@@ -0,0 +1,48 @@
+<?php
+namespace common\pay\payplat;
+
+class PayUtils
+{
+
+
+     /**
+     * @param array $data
+     * @param string $secretKey
+     * @return string
+     */
+    public static function makeSign($data)
+    {
+        $str = '';
+        ksort($data);
+        foreach ($data as $key => $value) {
+            if ($key == 'sign') {
+                continue;
+            }
+            $value = strval($value);
+            if ($value === '') {               //参数为空不参与签名
+                continue;
+            }
+            $str .= "{$key}={$value}&";
+        }
+        $str = rtrim($str, '&');
+        return strtoupper(md5($str));
+    }
+
+
+
+    /**
+     * @param array $data  参数
+     * @param string $secretKey
+     * @return bool
+     */
+    public static function checkSign($data)
+    {
+        $sign = isset($data['sign']) ? $data['sign'] : null;
+        if ($sign == null) {
+            return false;
+        }
+        return self::makeSign($data) === $sign;
+    }
+
+
+}