seven 1 주 전
부모
커밋
30426cc4af
3개의 변경된 파일75개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 1
      app/Http/Controllers/admin/Wallet.php
  2. 34 0
      app/Services/Payment/SanJinService.php
  3. 40 5
      app/Services/PaymentOrderService.php

+ 1 - 1
app/Http/Controllers/admin/Wallet.php

@@ -293,7 +293,7 @@ class Wallet extends Controller
         // $result = mb_strlen('哈哈哈123ABC');
         // $order_no = SanJinService::createOrderNo();
         // $result = SanJinService::pay(10000,$order_no);
-        $result = PaymentOrderService::createPay($memberId,100,SanJinService::PRODUCT_TEST);
+        $result = PaymentOrderService::createPay($memberId,100,'test');
         echo "<pre>";
         var_dump($result);
     }

+ 34 - 0
app/Services/Payment/SanJinService.php

@@ -13,6 +13,40 @@ class SanJinService extends BaseService
 
     const PRODUCT_TEST = 'T888'; // 测试支付通道
 
+
+    public static $PRODUCT = [
+        'T888' => [
+            'type' => 'test',
+            'rate' => "2%",
+            'max' => "5000",
+            'min' => "10"
+        ],
+        'ZPB001' => [
+            'type' => 'zfb',
+            'rate' => "8.5%",
+            'max' => "200",
+            'min' => "100"
+        ],
+        'ZPB002' => [
+            'type' => 'zfb',
+            'rate' => "5.7%",
+            'max' => "200",
+            'min' => "1000"
+        ],
+        'ZPB003' => [
+            'type' => 'zfb',
+            'rate' => "5.2%",
+            'max' => "1000",
+            'min' => "3000"
+        ],
+        'ZPB004' => [
+            'type' => 'zfb',
+            'rate' => "4.2%",
+            'max' => "3000",
+            'min' => "20000"
+        ],
+    ];
+
     // 获取商户ID
     public static function getMerchantId()
     {

+ 40 - 5
app/Services/PaymentOrderService.php

@@ -152,25 +152,60 @@ class PaymentOrderService extends BaseService
      * @description: 创建代收订单
      * @param {*} $memberId
      * @param {*} $amount
-     * @param {*} $channel
-     * @param {*} $account
+     * @param {*} $paymentType 支付类型:支付宝、数字人民币
      * @return {*}
      */    
-    public static function createPay($memberId,$amount,$channel)
+    public static function createPay($memberId,$amount,$paymentType)
     {
         $result = [];
         $result['chat_id'] = $memberId;
+        $channel = ''; // 支付的通道
+        $product = SanJinService::$PRODUCT;
+        $max = 0;
+        $min = 0;
+        $rate = 0;
+        foreach($product as $k => $v){
+            if($v['type'] == $paymentType){
+                if($amount >= $v['min'] && $amount <= $v['max']){
+                    $channel = $k;
+                    $rate = $v['rate'];
+                    
+                }
+                if($min == 0){
+                    $min = $v['min'];
+                }
+                if($max == 0){
+                    $max = $v['max'];
+                }
+                if($min > $v['min']){
+                    $min = $v['min'];
+                }
+                if($max < $v['max']){
+                    $max = $v['max'];
+                }
+            }
+        }
+
+        // 没有找到支付通道
+        if(empty($channel)){
+            $text = "发起充值失败 \n";
+            $text .= "最低充值:".$min." \n";
+            $text .= "最高充值:".$max." \n";
+            $text .= "请重新填写充值的金额!";
+            $result['text'] = $text;
+            return $result;
+        }
 
         $data = [];
         $data['type'] = self::TYPE_PAY;
         $data['member_id'] = $memberId;
         $data['amount'] = $amount;
         $data['channel'] = $channel;
-        $data['free'] = "";
+        $data['free'] = $amount * $rate;
         $order_no = self::createOrderNo('sj'.$data['type'].'_', $memberId);
         $data['order_no'] = $order_no;
         $data['callback_url'] = SanJinService::getNotifyUrl();
-        $data['remark'] = '充值费率:';
+        $data['remark'] = '充值费率:'.$rate;
         $data['status'] = self::STATUS_STAY;
         $ret = SanJinService::pay(($amount*100), $order_no, $channel);
         if($ret['code'] == 0){