Selaa lähdekoodia

for bodian_yd

stanley-king 2 vuotta sitten
vanhempi
commit
93bb4dc98a
3 muutettua tiedostoa jossa 105 lisäystä ja 14 poistoa
  1. 15 0
      helper/refill/api/xyz/bodian_yd/RefillCallBack.php
  2. 76 0
      plot/ratio_analyze.ipynb
  3. 14 14
      test/TestRefill.php

+ 15 - 0
helper/refill/api/xyz/bodian_yd/RefillCallBack.php

@@ -4,6 +4,7 @@ namespace refill\bodian_yd;
 require_once(BASE_HELPER_RAPI_PATH . '/bodian_yd/config.php');
 
 use refill;
+
 class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
@@ -41,10 +42,24 @@ class RefillCallBack implements refill\IRefillCallBack
             return [$order_id, true, false,true];
         }
         elseif ($status === 3) {
+            $this->add_filter($order_id,false);
             return [$order_id, false, true,true];
         }
         else {
             return [$order_id, false, false,false];
         }
     }
+
+    private function add_filter($order_id,$can_commit)
+    {
+        $refill_info = Model('refill_order')->getOrderInfo(['order_id' => $order_id]);
+        if(!empty($refill_info)) {
+            $quality = intval($refill_info['quality']);
+            $card_type = intval($refill_info['card_type']);
+            $mchid = intval($refill_info['mchid']);
+            $mch_order = $refill_info['mch_order'];
+            $chfilters = new refill\channel_filter($mchid,$mch_order,$quality,$card_type);
+            $chfilters->add_channel('bodian_yd',$can_commit);
+        }
+    }
 }

+ 76 - 0
plot/ratio_analyze.ipynb

@@ -0,0 +1,76 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "import time\n",
+    "import unittest\n",
+    "import logging"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "outputs": [
+    {
+     "ename": "ImportError",
+     "evalue": "attempted relative import with no known parent package",
+     "output_type": "error",
+     "traceback": [
+      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
+      "\u001B[0;31mImportError\u001B[0m                               Traceback (most recent call last)",
+      "Cell \u001B[0;32mIn [6], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mrefill\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m ChannelCumPainter\n",
+      "\u001B[0;31mImportError\u001B[0m: attempted relative import with no known parent package"
+     ]
+    }
+   ],
+   "source": [
+    "from .refill import ChannelCumPainter"
+   ],
+   "metadata": {
+    "collapsed": false,
+    "pycharm": {
+     "name": "#%%\n"
+    }
+   }
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "outputs": [],
+   "source": [],
+   "metadata": {
+    "collapsed": false,
+    "pycharm": {
+     "name": "#%%\n"
+    }
+   }
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 2
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython2",
+   "version": "2.7.6"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}

+ 14 - 14
test/TestRefill.php

@@ -54,6 +54,20 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance();
     }
 
+    public function testBodian_yd()
+    {
+//        $provider = $this->getProvider('bodian_yd');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '16971663724801057246']);
+
+        $body = ' {"szOrderId":"16971663724801057246","fSalePrice":"30.09","szAgentId":"200064","nFlag":"2","szVerifyString":"69c41652845d37f130186b05ddeecf6a","szPhoneNum":"15811535608","szRtnMsg":"00772022092109464443723910546991","nDemo":"30"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('bodian_yd', 'RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testMerchantPrice()
     {
         $price = new refill\merchant_price();
@@ -2544,20 +2558,6 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
-    public function testBodian_yd()
-    {
-//        $provider = $this->getProvider('bodian_yd');
-//        $resp = $provider->balance();
-//        $resp = $provider->add(15811535608, 4, 30, ['order_sn' => $this->make_sn()]);
-//        $resp = $provider->query(['order_sn' => '16971663724801057246']);
-
-        $body = ' {"szOrderId":"16971663724801057246","fSalePrice":"30.09","szAgentId":"200064","nFlag":"2","szVerifyString":"69c41652845d37f130186b05ddeecf6a","szPhoneNum":"15811535608","szRtnMsg":"00772022092109464443723910546991","nDemo":"30"}';
-        $params = json_decode($body, true);
-        $provider = $this->getProvider('bodian_yd', 'RefillCallBack');
-        $ret = $provider->verify($params);
-        $resp = $provider->notify($params);
-    }
-
     public function testDazhanggui_fs()
     {
 //        $provider = $this->getProvider('dazhanggui_fs');