Просмотр исходного кода

Merge branch 'mh' into raccount

stanley-king 1 год назад
Родитель
Сommit
537bc97eb5
66 измененных файлов с 4373 добавлено и 277 удалено
  1. 15 0
      admin/config/mh/config.ini.php
  2. 6 1
      admin/index.php
  3. 11 8
      core/framework/core/base.php
  4. 32 65
      data/config/dev/base.ini.php
  5. 122 107
      data/config/mh/refill.ini.php
  6. 1952 0
      docker/compose/homecuda/conf/php/php-remote.ini
  7. 1 1
      docker/compose/homecuda/remote/docker-compose.yml
  8. 2 8
      docker/compose/mh/compose.env
  9. 2 2
      docker/compose/mh/conf/nginx/admin.conf
  10. 1 1
      docker/compose/mh/conf/nginx/racc.conf
  11. 1 1
      docker/compose/mh/cpenv
  12. 0 35
      docker/compose/mh/mh-macc/docker-compose.yml
  13. 61 7
      docker/compose/mh/mh-slave/docker-compose.yml
  14. 1 1
      helper/fcgisrv/BaseServer.php
  15. 115 0
      helper/rbridge/BridgeTrait.php
  16. 16 0
      helper/rbridge/IBridgeEx.php
  17. 26 1
      helper/rbridge/RBridgeFactory.php
  18. 278 0
      helper/rbridge/gy/Bridge.php
  19. 29 0
      helper/rbridge/gy/config.php
  20. BIN
      helper/rbridge/gy/协议.pdf
  21. 16 1
      helper/refill/api/mh/ReadMe.MD
  22. 4 0
      helper/refill/api/mh/dixin_normal/ReadMe.MD
  23. 4 5
      helper/refill/api/mh/dixin_normal/RefillCallBack.php
  24. 4 3
      helper/refill/api/mh/dixin_normal/RefillPhone.php
  25. 3 0
      helper/refill/api/mh/dixin_slow/ReadMe.MD
  26. 48 0
      helper/refill/api/mh/dixin_slow/RefillCallBack.php
  27. 173 0
      helper/refill/api/mh/dixin_slow/RefillPhone.php
  28. 74 0
      helper/refill/api/mh/dixin_slow/config.php
  29. 133 0
      helper/refill/api/mh/dixin_slow/demo.txt
  30. 19 0
      helper/refill/api/mh/lifang_normal/API.MD
  31. 51 0
      helper/refill/api/mh/lifang_normal/RefillCallBack.php
  32. 133 0
      helper/refill/api/mh/lifang_normal/RefillPhone.php
  33. 48 0
      helper/refill/api/mh/lifang_normal/config.php
  34. BIN
      helper/refill/api/mh/lifang_normal/力方接口返回示例.docx
  35. 3 1
      helper/refill/api/mh/suhu_normal/ReadMe.MD
  36. 18 4
      helper/refill/api/mh/suhu_normal/RefillCallBack.php
  37. 1 1
      helper/refill/api/mh/suhu_normal/RefillPhone.php
  38. 3 0
      helper/refill/api/mh/suhu_wozhifu/ReadMe.MD
  39. 17 4
      helper/refill/api/mh/suhu_wozhifu/RefillCallBack.php
  40. 2 2
      helper/refill/api/mh/suhu_wozhifu/RefillPhone.php
  41. 4 4
      helper/refill/api/mh/suhu_wozhifu/config.php
  42. 34 0
      helper/refill/api/mh/weisanhuo_normal/API.MD
  43. 40 0
      helper/refill/api/mh/weisanhuo_normal/RefillCallBack.php
  44. 147 0
      helper/refill/api/mh/weisanhuo_normal/RefillPhone.php
  45. BIN
      helper/refill/api/mh/weisanhuo_normal/code.xlsx
  46. 70 0
      helper/refill/api/mh/weisanhuo_normal/config.php
  47. BIN
      helper/refill/api/mh/weisanhuo_normal/help.doc
  48. BIN
      helper/refill/api/mh/weisanhuo_normal/~$help.doc
  49. 50 0
      helper/refill/api/mh/yushang_normal/RefillCallBack.php
  50. 158 0
      helper/refill/api/mh/yushang_normal/RefillPhone.php
  51. 83 0
      helper/refill/api/mh/yushang_normal/config.php
  52. 46 0
      helper/refill/api/mh/yushang_normal/jiekou.txt
  53. 8 0
      helper/refill/policy/chctlex.php
  54. 2 0
      helper/refill/policy/xyz/policy.php
  55. 27 0
      racc/bridge/gy.php
  56. 9 0
      racc/callback/mh/dixin_slow.php
  57. 5 0
      racc/callback/mh/lifang_normal.php
  58. 3 0
      racc/callback/mh/suhu_normal.php
  59. 3 0
      racc/callback/mh/suhu_wozhifu.php
  60. 21 0
      racc/callback/mh/testcb.php
  61. 12 0
      racc/callback/mh/weisanhuo_normal.php
  62. 4 0
      racc/callback/mh/yushang_normal.php
  63. 1 1
      racc/config/config.ini.php
  64. 2 1
      racc/index.php
  65. 151 0
      test/TestRBridge.php
  66. 68 12
      test/mh/TestRefill.php

+ 15 - 0
admin/config/mh/config.ini.php

@@ -0,0 +1,15 @@
+<?php
+
+defined('InShopNC') or exit('Access Invalid!');
+
+
+$config['receive_bank'] = [
+    '平安',
+    '民生',
+];
+
+$config['test_mchid'] = [
+
+];
+
+$config['WEB_COMPANY_NAME'] = '北京美嗨信息技术有限公司';

+ 6 - 1
admin/index.php

@@ -18,7 +18,7 @@ function handle_error($level, $message, $file, $line)
     foreach ($backtrace as $item) {
         $trace .= "{$item['file']}\t{$item['line']}\t{$item['function']}\n";
     }
-    $x = $trace;
+    Log::record($trace,Log::DEBUG);
 }
 
 set_error_handler('handle_error');
@@ -32,7 +32,12 @@ define('BASE_TPL_PATH',BASE_PATH.'/templates/'.TPL_NAME);
 
 if (!@include(BASE_PATH.'/control/control.php')) exit('control.php isn\'t exists!');
 include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
+
 $start = microtime(true);
+$addr = $_SERVER['REMOTE_ADDR'];
+Log::record("admin start request ip:$addr", Log::DEBUG);
+
 Base::run();
+
 $msg = sprintf("admin request time=%.6f\r\n\r\n",microtime(true) - $start);
 Log::record($msg,Log::DEBUG);

+ 11 - 8
core/framework/core/base.php

@@ -15,7 +15,7 @@ final class Base
 
 	public static function init() 
 	{
-	    global $setting_config;     
+	    global $setting_config;
 	    self::parse_conf($setting_config);
 	    define('MD5_KEY',md5($setting_config['md5_key']));
 
@@ -163,7 +163,8 @@ final class Base
 		}
 
 		$act_file = realpath(BASE_PATH.'/control/'.$_GET['act'].'.php');
-		$class_name = $_GET['act'].'Control';
+
+        $class_name = $_GET['act'].'Control';
 		if (!@include_once($act_file))
 		{
 		    if (C('debug')) {
@@ -172,17 +173,18 @@ final class Base
 		        showMessage('抱歉!您访问的页面不存在','','html','error');
 		    }
 		}
+        Log::record("Base::control 3", Log::DEBUG);
 
 		if (class_exists($class_name))
 		{
 			$main = new $class_name();
-			$function = $_GET['op'].'Op';
-            Log::record("act={$class_name},op={$function}",Log::DEBUG);
+            $function = $_GET['op'].'Op';
 
-			if (method_exists($main,$function)){                       
+            Log::record("act=$class_name,op=$function",Log::DEBUG);
+            if (method_exists($main,$function)){
 				$main->$function();
-			} elseif (method_exists($main,'indexOp')){
-				$main->indexOp();
+			} elseif (method_exists($main,'indexOp')) {
+                $main->indexOp();
 			} else {
 				$error = "Base Error: function $function not in $class_name!";
 				throw_exception($error);
@@ -226,7 +228,8 @@ final class Base
             Log::record("session on redis path={$config['session_save_path']}",Log::DEBUG);
         }
 		
-		session_start();
+		$ret = session_start();
+        Log::record("session_start return=$ret.",Log::DEBUG);
 	}
 
     public static function autoload($class)

+ 32 - 65
data/config/dev/base.ini.php

@@ -67,72 +67,39 @@ if(SSH_TUNEL_PROD ==='local') {
     $config['db']['slave'][0]['dbname']     = 'xyzshop';
     $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
 }
-if(SSH_TUNEL_PROD ==='workcuda') {
-    $config['db'][1]['dbhost']       = MASTER_DBHOST;
-    $config['db'][1]['dbport']       = '3306';
-    $config['db'][1]['dbuser']       = 'root';
-    $config['db'][1]['dbpwd']        = '55668899';
-    $config['db'][1]['dbname']       = 'ylshop';
-    $config['db'][1]['dbcharset']    = 'UTF-8';
 
-    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
-    $config['db']['slave'][0]['dbport']     = '3306';
-    $config['db']['slave'][0]['dbuser']     = 'root';
-    $config['db']['slave'][0]['dbpwd']      = '55668899';
-    $config['db']['slave'][0]['dbname']     = 'ylshop';
-    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
-}
-elseif(SSH_TUNEL_PROD === 'xyz') {
-    //调试是先执行这行命令
-    //shell_exec("ssh -NCPf root@39.103.201.41 -L 3307:127.0.0.1:3306");
-    $config['db'][1]['dbhost']       = MASTER_DBHOST;
-    $config['db'][1]['dbport']       = '3307';
-    $config['db'][1]['dbuser']       = 'root';
-    $config['db'][1]['dbpwd']        = 'XTZ@shop@951688';
-    $config['db'][1]['dbname']       = 'xyzshop';
-    $config['db'][1]['dbcharset']    = 'UTF-8';
-
-    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
-    $config['db']['slave'][0]['dbport']     = '3307';
-    $config['db']['slave'][0]['dbuser']     = 'root';
-    $config['db']['slave'][0]['dbpwd']      = 'XTZ@shop@951688';
-    $config['db']['slave'][0]['dbname']     = 'xyzshop';
-    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
-}
-elseif(SSH_TUNEL_PROD === 'xyztest') {
-    //调试是先执行这行命令
-    //shell_exec("ssh -NCPf root@39.103.162.175 -L 3307:127.0.0.1:3306");
-    $config['db'][1]['dbhost']       = MASTER_DBHOST;
-    $config['db'][1]['dbport']       = '3307';
-    $config['db'][1]['dbuser']       = 'root';
-    $config['db'][1]['dbpwd']        = 'XTZ@shop@951688';
-    $config['db'][1]['dbname']       = 'xyzshop';
-    $config['db'][1]['dbcharset']    = 'UTF-8';
-
-    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
-    $config['db']['slave'][0]['dbport']     = '3307';
-    $config['db']['slave'][0]['dbuser']     = 'root';
-    $config['db']['slave'][0]['dbpwd']      = 'XTZ@shop@951688';
-    $config['db']['slave'][0]['dbname']     = 'xyzshop';
-    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
-}
-elseif(SSH_TUNEL_PROD === 'lingzh') {
-    //调试是先执行这行命令
-    //shell_exec("ssh -NCPf root@121.89.212.167 -L 3307:127.0.0.1:3306");
-    $config['db'][1]['dbhost']       = MASTER_DBHOST;
-    $config['db'][1]['dbport']       = '3307';
-    $config['db'][1]['dbuser']       = 'root';
-    $config['db'][1]['dbpwd']        = 'Linzhuhmnbmhhah#2021';
-    $config['db'][1]['dbname']       = 'xyzshop';
-    $config['db'][1]['dbcharset']    = 'UTF-8';
-
-    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
-    $config['db']['slave'][0]['dbport']     = '3307';
-    $config['db']['slave'][0]['dbuser']     = 'root';
-    $config['db']['slave'][0]['dbpwd']      = 'Linzhuhmnbmhhah#2021';
-    $config['db']['slave'][0]['dbname']     = 'xyzshop';
-    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
-}
+//if(SSH_TUNEL_PROD ==='workcuda') {
+//    $config['db'][1]['dbhost']       = MASTER_DBHOST;
+//    $config['db'][1]['dbport']       = '3306';
+//    $config['db'][1]['dbuser']       = 'root';
+//    $config['db'][1]['dbpwd']        = '55668899';
+//    $config['db'][1]['dbname']       = 'ylshop';
+//    $config['db'][1]['dbcharset']    = 'UTF-8';
+//
+//    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
+//    $config['db']['slave'][0]['dbport']     = '3306';
+//    $config['db']['slave'][0]['dbuser']     = 'root';
+//    $config['db']['slave'][0]['dbpwd']      = '55668899';
+//    $config['db']['slave'][0]['dbname']     = 'ylshop';
+//    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
+//}
+//elseif(SSH_TUNEL_PROD === 'xyz') {
+//    //调试是先执行这行命令
+//    //shell_exec("ssh -NCPf root@39.103.201.41 -L 3307:127.0.0.1:3306");
+//    $config['db'][1]['dbhost']       = MASTER_DBHOST;
+//    $config['db'][1]['dbport']       = '3307';
+//    $config['db'][1]['dbuser']       = 'root';
+//    $config['db'][1]['dbpwd']        = 'XTZ@shop@951688';
+//    $config['db'][1]['dbname']       = 'xyzshop';
+//    $config['db'][1]['dbcharset']    = 'UTF-8';
+//
+//    $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
+//    $config['db']['slave'][0]['dbport']     = '3307';
+//    $config['db']['slave'][0]['dbuser']     = 'root';
+//    $config['db']['slave'][0]['dbpwd']      = 'XTZ@shop@951688';
+//    $config['db']['slave'][0]['dbname']     = 'xyzshop';
+//    $config['db']['slave'][0]['dbcharset']  = 'UTF-8';
+//}
 
 $config['session_expire'] 	= 3600;
 $config['lang_type'] 		= 'zh_cn';

+ 122 - 107
data/config/mh/refill.ini.php

@@ -19,26 +19,9 @@ $oil_providers = [
 ];
 $config['oil_providers'] = $oil_providers;
 
+//1 普充,2是快充,3是卡密
 $dixin_normal = ['name' => 'dixin_normal', 'store_id' => 377,'qualitys' => '1',
     'amount' => [
-//        10 => [
-//            ['goods_id' => 8948, 'price' => 10.065, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8948, 'price' => 10.02, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8948, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
-//        20 => [
-//            ['goods_id' => 8949, 'price' => 20.13, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8949, 'price' => 20.04, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8949, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
-//        30 => [
-//            ['goods_id' => 8950, 'price' => 30.195, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8950, 'price' => 30.06, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8950, 'price' => 30, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-
         50 => [
             ['goods_id' => 8951, 'price' => 48.75,'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 8951, 'price' => 47.3, 'quality' => 1, 'card_type' => 'chinaunicom'],
@@ -54,129 +37,156 @@ $dixin_normal = ['name' => 'dixin_normal', 'store_id' => 377,'qualitys' => '1',
             ['goods_id' => 8953, 'price' => 191.0, 'quality' => 1, 'card_type' => 'chinaunicom'],
             ['goods_id' => 8953, 'price' => 193.0, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
-
-//        300 => [
-//            ['goods_id' => 8955, 'price' => 299.85, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8955, 'price' => 300.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8955, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
-//        500 => [
-//            ['goods_id' => 8954, 'price' => 499.75, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8954, 'price' => 501, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8954, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
-
-$suhu_normal = ['name' => 'suhu_normal', 'store_id' => 379,'qualitys' => '1',
+$suhu_normal = ['name' => 'suhu_normal', 'store_id' => 379,'qualitys' => '3',
     'amount' => [
-//        10 => [
-//            ['goods_id' => 8948, 'price' => 10.065, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8948, 'price' => 10.02, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8948, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
        20 => [
-//            ['goods_id' => 8949, 'price' => 20.13, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8949, 'price' => 19.896, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8949, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 8957, 'price' => 19.896, 'quality' => 3, 'card_type' => 'chinaunicom'],
         ],
-//
+
         30 => [
-            ['goods_id' => 8950, 'price' => 30.09, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8950, 'price' => 29.844, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8950, 'price' => 30.009, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 8958, 'price' => 30.090, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8958, 'price' => 29.844, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8958, 'price' => 30.009, 'quality' => 3, 'card_type' => 'chinatelecom']
         ],
 
         50 => [
-            ['goods_id' => 8951, 'price' => 50.15,'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8951, 'price' => 49.47, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8951, 'price' => 50.15,   'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 8959, 'price' => 50.15,'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8959, 'price' => 49.47,'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8959, 'price' => 50.15,'quality' => 3, 'card_type' => 'chinatelecom']
         ],
         100 => [
-            ['goods_id' => 8952, 'price' => 100.1, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8952, 'price' => 94.7, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 8952, 'price' => 100.3, 'quality' => 1, 'card_type' => 'chinatelecom']
-        ],
-//        200 => [
-//            ['goods_id' => 8953, 'price' => 191.0, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8953, 'price' => 191.0, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8953, 'price' => 193.0, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-
-//        300 => [
-//            ['goods_id' => 8955, 'price' => 299.85, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8955, 'price' => 300.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8955, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
-//        500 => [
-//            ['goods_id' => 8954, 'price' => 499.75, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8954, 'price' => 501, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8954, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ]
+            ['goods_id' => 8960, 'price' => 100.1, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8960, 'price' =>  98.7, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8960, 'price' => 100.3, 'quality' => 3, 'card_type' => 'chinatelecom']
+        ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
 
 
-$suhu_wozhifu = ['name' => 'suhu_wozhifu', 'store_id' => 380,'qualitys' => '1',
+$suhu_wozhifu = ['name' => 'suhu_wozhifu', 'store_id' => 380,'qualitys' => '2',
     'amount' => [
-//        10 => [
-//            ['goods_id' => 8948, 'price' => 10.065, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8948, 'price' => 10.02, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8948, 'price' => 10, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
-//        20 => [
-//            ['goods_id' => 8949, 'price' => 20.13, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8949, 'price' => 19.896, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8949, 'price' => 20, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
-//
-//        30 => [
-//            ['goods_id' => 8950, 'price' => 30.09, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8950, 'price' => 29.844, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8950, 'price' => 30.009, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ],
+        50 => [
+            ['goods_id' => 8967, 'price' => 49.94, 'quality' => 2, 'card_type' => 'chinaunicom'],
+        ],
+        100 => [
+            ['goods_id' => 8968, 'price' => 99.88, 'quality' => 2, 'card_type' => 'chinaunicom'],
+        ],
+        200 => [
+            ['goods_id' => 8969, 'price' => 199.76, 'quality' => 2, 'card_type' => 'chinaunicom'],
+        ],
+        300 => [
+            ['goods_id' => 8970, 'price' => 299.64, 'quality' => 2, 'card_type' => 'chinaunicom'],
+        ],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 
+$yushang_normal = ['name' => 'yushang_normal', 'store_id' => 381,'qualitys' => '1',
+    'amount' => [
         50 => [
-//            ['goods_id' => 8951, 'price' => 50.15,'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8951, 'price' => 49.94, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8951, 'price' => 50.15,   'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 8975, 'price' => 51.9,'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8975, 'price' => 51.9,'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8975, 'price' => 51.9,'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         100 => [
-//            ['goods_id' => 8952, 'price' => 100.1, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8952, 'price' => 99.88, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8952, 'price' => 100.3, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 8976, 'price' => 103.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8976, 'price' => 103.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8976, 'price' => 103.8, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         200 => [
-//            ['goods_id' => 8953, 'price' => 191.0, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8953, 'price' => 199.76, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8953, 'price' => 193.0, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 8977, 'price' => 207.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8977, 'price' => 207.6, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8977, 'price' => 207.6, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
 
         300 => [
-//            ['goods_id' => 8955, 'price' => 299.85, 'quality' => 1, 'card_type' => 'chinamobile'],
-            ['goods_id' => 8955, 'price' => 299.64, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8955, 'price' => 300, 'quality' => 1, 'card_type' => 'chinatelecom']
-        ],
-//
-//        500 => [
-//            ['goods_id' => 8954, 'price' => 499.75, 'quality' => 1, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8954, 'price' => 501, 'quality' => 1, 'card_type' => 'chinaunicom'],
-//            ['goods_id' => 8954, 'price' => 500, 'quality' => 1, 'card_type' => 'chinatelecom']
-//        ]
+            ['goods_id' => 8978, 'price' => 311.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8978, 'price' => 311.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8978, 'price' => 311.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+
+        500 => [
+            ['goods_id' => 8979, 'price' => 519, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8979, 'price' => 519, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8979, 'price' => 519, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
+$dixin_slow = ['name' => 'dixin_slow', 'store_id' => 382,'qualitys' => '1',
+    'amount' => [
+        50 => [
+            ['goods_id' => 8983, 'price' => 46.75,'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8983, 'price' => 46.75,'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8983, 'price' => 46.75,'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8984, 'price' => 93.50, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8984, 'price' => 93.50, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8984, 'price' => 93.50, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8985, 'price' => 187.0, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8985, 'price' => 187.0, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8985, 'price' => 187.0, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$weisanhuo_normal = ['name' => 'weisanhuo_normal', 'store_id' => 383, 'qualitys' => '2',
+    'amount' => [
+        50 => [
+            ['goods_id' => 8991, 'price' => 47.6, 'quality' => 2, 'card_type' => 'chinamobile'],
+        ],
+        100 => [
+            ['goods_id' => 8992, 'price' => 95.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+        ],
+        200 => [
+            ['goods_id' => 8993, 'price' => 190.4,'quality' => 2, 'card_type' => 'chinamobile'],
+        ],
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+
+$lifang_normal = ['name' => 'lifang_normal', 'store_id' => 384,'qualitys' => '1',
+    'amount' => [
+        30 => [
+            ['goods_id' => 8998, 'price' => 29.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8998, 'price' => 29.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8998, 'price' => 29.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8999, 'price' => 49,'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8999, 'price' => 49,'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8999, 'price' => 49,'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9000, 'price' => 98, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9000, 'price' => 98, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9000, 'price' => 98, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9001, 'price' => 196.0, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9001, 'price' => 196.0, 'quality' => 1, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9001, 'price' => 196.0, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
 
 $phone_providers = [
     ['name' => 'dixin_normal', 'cfg' => $dixin_normal],
+    ['name' => 'dixin_slow', 'cfg' => $dixin_slow],
+    ['name' => 'lifang_normal', 'cfg' => $lifang_normal],
     ['name' => 'suhu_normal', 'cfg' => $suhu_normal],
-    ['name' => 'suhu_wozhifu', 'cfg' => $suhu_wozhifu]
+    ['name' => 'suhu_wozhifu', 'cfg' => $suhu_wozhifu],
+    ['name' => 'weisanhuo_normal', 'cfg' => $weisanhuo_normal],
+    ['name' => 'yushang_normal', 'cfg' => $yushang_normal]
 ];
 
 $config['phone_providers'] = $phone_providers;
@@ -200,3 +210,8 @@ $config['third_jumps'] = $third_jumps;
 
 #油需要发短信的机构
 $config['sms_mchids'] = [];
+
+#风险流水号管理
+$config['risk_official_sn'] = [
+    'exclude_stores' => [377, 379, 380, 381, 382, 383, 384]
+];

Разница между файлами не показана из-за своего большого размера
+ 1952 - 0
docker/compose/homecuda/conf/php/php-remote.ini


+ 1 - 1
docker/compose/homecuda/remote/docker-compose.yml

@@ -13,7 +13,7 @@ services:
     volumes:
       - ../../../../:${SHOP_ROOT_PATH}
       - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
+      - ../conf/php/php-remote.ini:/usr/local/etc/php/php.ini
       - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
       - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
     container_name: "${CONTAINER_PREFIX}-cli"

+ 2 - 8
docker/compose/mh/compose.env

@@ -1,13 +1,7 @@
-#Mobile接入层Nigix端口
-MACCNGINX_PORT=8100
-#ReadMine Nigix 端口
-RMINE_NGINX_PORT=8080
-
 #racc Refill接入层Nginx端口
-RACCNGINX_PORT=80
+RACCNGINX_PORT=8180
 #Admin后台Nginx端口
-ADMINGINX_PORT=80
-
+ADMINGINX_PORT=8000
 #主站上传文件路径
 SHOP_UPLOAD_PATH=/nfs/mhupload
 #日志路径

+ 2 - 2
docker/compose/mh/conf/nginx/admin.conf

@@ -31,7 +31,7 @@ http
     {
     	listen       80;
         set  $folder_name /var/www/html;
-        server_name 47.92.239.240;
+        server_name web.mhigh.cn;
         root $folder_name;
         index index.html index.php; 
 
@@ -77,7 +77,7 @@ http
 
         location /plot {
             root $folder_name;
-            proxy_pass         http://docker.hostip:5000;
+            proxy_pass         http://172.22.67.134:5000;
             proxy_redirect     off;
 
             proxy_set_header   Host                 $host;

+ 1 - 1
docker/compose/mh/conf/nginx/racc.conf

@@ -31,7 +31,7 @@ http
     {
     	listen       80;
         set  $folder_name /var/www/html;
-        server_name 192.168.3.104;
+        server_name api.mhigh.cn;
         root $folder_name;
         index index.html index.php; 
 

+ 1 - 1
docker/compose/mh/cpenv

@@ -1,7 +1,7 @@
 #!/bin/bash
 
 # shellcheck disable=SC2039
-dest_dirs=("mh-macc" "mh-admin" "mh-cli" "mh-master" "mh-racc" "mh-slave" "mh-worker" "mh-storage")
+dest_dirs=("mh-admin" "mh-cli" "mh-master" "mh-racc" "mh-slave" "mh-worker" "mh-storage")
 src_file=".env"
 
 for dir in "${dest_dirs[@]}"; do

+ 0 - 35
docker/compose/mh/mh-macc/docker-compose.yml

@@ -1,35 +0,0 @@
-version: "3.9"
-
-include:
-  - ../docker-compose.networks.yml
-
-services:
-  nginx:
-    image: nginx:alpine
-    ports:
-      - ${MACCNGINX_PORT}:80
-    volumes:
-      - ../../../../:${SHOP_ROOT_PATH}
-      - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/nginx/macc.conf:/etc/nginx/nginx.conf:ro
-      - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
-      - ${MERCHANT_PATH}:${SHOP_ROOT_PATH}/merchant
-      - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
-    container_name: "${CONTAINER_PREFIX}-mnginx"
-    command: [nginx,'-g','daemon off;']
-    networks:
-      - ${DOCKER_NET_NAME}
-
-  macc:
-    image: php-zts:7.3.18
-    volumes:
-      - ../../../../:${SHOP_ROOT_PATH}
-      - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
-      - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
-      - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
-      - ../conf/php/spwan-start:/usr/local/bin/spwan-start
-    container_name: "${CONTAINER_PREFIX}-macc"
-    command: [ spwan-start,"/mobile/mobile_run.php","16" ]
-    networks:
-      - ${DOCKER_NET_NAME}

+ 61 - 7
docker/compose/mh/mh-slave/docker-compose.yml

@@ -18,6 +18,19 @@ services:
     networks:
       - ${DOCKER_NET_NAME}
 
+  statutil:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:${SHOP_ROOT_PATH}
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
+      - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
+    container_name: "${CONTAINER_PREFIX}-slave-stat"
+    command: [php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','stat']
+    networks:
+      - ${DOCKER_NET_NAME}
+
   taska:
     image: php-zts:7.3.18
     volumes:
@@ -26,8 +39,8 @@ services:
       - ../conf/php/php.ini:/usr/local/etc/php/php.ini
       - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
       - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
-    container_name: "${CONTAINER_PREFIX}-slave-taska"
-    command: [php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','task']
+    container_name: "${CONTAINER_PREFIX}-admin-taska"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
     networks:
       - ${DOCKER_NET_NAME}
 
@@ -39,12 +52,12 @@ services:
       - ../conf/php/php.ini:/usr/local/etc/php/php.ini
       - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
       - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
-    container_name: "${CONTAINER_PREFIX}-slave-taskb"
-    command: [php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','task']
+    container_name: "${CONTAINER_PREFIX}-admin-taskb"
+    command: [php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','admin_task']
     networks:
       - ${DOCKER_NET_NAME}
 
-  statutil:
+  taskc:
     image: php-zts:7.3.18
     volumes:
       - ../../../../:${SHOP_ROOT_PATH}
@@ -52,7 +65,48 @@ services:
       - ../conf/php/php.ini:/usr/local/etc/php/php.ini
       - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
       - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
-    container_name: "${CONTAINER_PREFIX}-slave-stat"
-    command: [php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','stat']
+    container_name: "${CONTAINER_PREFIX}-admin-taskc"
+    command: [ php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','admin_task' ]
+    networks:
+      - ${DOCKER_NET_NAME}
+
+  taskd:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:${SHOP_ROOT_PATH}
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
+      - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
+    container_name: "${CONTAINER_PREFIX}-admin-taskd"
+    command: [ php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','admin_task' ]
+    networks:
+      - ${DOCKER_NET_NAME}
+
+  mtaska:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
+      - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
+    container_name: "${CONTAINER_PREFIX}-mch-taska"
+    command: [ php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','merchant_task' ]
+    networks:
+      - ${DOCKER_NET_NAME}
+
+  mtaskb:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
+      - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
+    container_name: "${CONTAINER_PREFIX}-mch-taskb"
+    command: [ php,"${SHOP_ROOT_PATH}/crontab/index.php",'minutes','merchant_task' ]
     networks:
       - ${DOCKER_NET_NAME}

+ 1 - 1
helper/fcgisrv/BaseServer.php

@@ -102,7 +102,7 @@ abstract class BaseServer
     public function run_looper()
     {
         $this->preLooper();
-        Log::record('Waiting......',Log::DEBUG);
+        Log::record('Waiting......', Log::DEBUG);
 
         $index = 0;
         fcgi_init();

+ 115 - 0
helper/rbridge/BridgeTrait.php

@@ -0,0 +1,115 @@
+<?php
+/**
+ *   BridgeTrait.php
+ *   stanley-king
+ *   2023/12/17
+ *   PhpStorm
+ *   PHPProject
+ */
+
+namespace rbridge;
+use refill;
+use Log;
+
+trait BridgeTrait
+{
+    public function order_query($mchid,$mch_order)
+    {
+        $detail_checker = function($mchid, $mch_order)
+        {
+            $mod_refill = Model('refill_order');
+            $detail = $mod_refill->get_detail($mchid,$mch_order);
+            if (empty($detail)) {
+                return false;
+            } else {
+                return true;
+            }
+        };
+
+        $send = ['mchid' => $mchid,'order_sn' => $mch_order,'order_state' => ORDER_STATE_SEND];
+
+        $order_state = refill\util::query_queue_order($mchid,$mch_order);
+        if ($order_state == ORDER_STATE_QUEUE || $order_state == ORDER_STATE_SEND) {
+            Log::record("query_state in queue mchid=$mchid mch_order=$mch_order order_state=$order_state", Log::DEBUG);
+            return [200,$send];
+        }
+        else
+        {
+            $mod_refill = Model('refill_order');
+            $refill_info = $mod_refill->partition(refill\util::part_query())->getOrderInfo(['mch_order' => $mch_order,'mchid' => $mchid,'inner_status' => 0]);
+
+            if(empty($refill_info))
+            {
+                $mod_qerr = Model('refill_query_err');
+                $insert = ['mch_order' => $mch_order,'mchid' => $mchid];
+
+                $items = $mod_refill->getOrderInfo(['mch_order' => $mch_order,'mchid' => $mchid]);
+                if (empty($items))
+                {
+                    Log::record("query_state in db no order mchid=$mchid mch_order=$mch_order", Log::DEBUG);
+
+                    $insert['code'] = 202;
+                    $insert['msg'] = "检索充值中的单子,查不到任何订单信息.";
+                    $mod_qerr->add($insert);
+
+                    $detail = $detail_checker($mchid,$mch_order);
+                    if($detail == false) {
+                        return [201, []];
+                    }
+                    else {
+                        return [200, $send];
+                    }
+                }
+                else
+                {
+                    Log::record("DEBUG_TAG: query_state in db mchid=$mchid mch_order=$mch_order order_state not completed.", Log::DEBUG);
+
+
+                    $insert['code'] = 200;
+                    $insert['msg'] = "检索充值中的单子能查到,但inner_status=0时查不到,回调充值中状态.";
+                    $mod_qerr->add($insert);
+
+                    return [200, $send];
+                }
+            }
+            else
+            {
+                $vr_order = Model('vr_order');
+                $order_info = $vr_order->partition(refill\util::part_query())->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
+                Log::record("query_state in db mchid=$mchid mch_order=$mch_order order_state={$order_info['order_state']}" ,Log::DEBUG);
+
+                if (empty($order_info))
+                {
+                    $mod_qerr = Model('refill_query_err');
+                    $insert = ['mch_order' => $mch_order,'mchid' => $mchid];
+                    $insert['code'] = 203;
+                    $insert['msg'] = "检索充值中的单子能查到,但inner_status=0时查不到vr_order中的订单.";
+                    $mod_qerr->add($insert);
+
+                    return [200, $send];
+                } else {
+                    $result = $this->format($order_info, $refill_info);
+                    return [200, $result];
+                }
+            }
+        }
+    }
+
+    private function format($order_info,$refill_info)
+    {
+        $result = [];
+        $result['mchid'] = $refill_info['mchid'];
+        $result['trade_no'] = $refill_info['order_sn'];
+        $result['order_sn'] = $refill_info['mch_order'];
+        $result['card_no'] = $refill_info['card_no'];
+        $result['card_type'] = $refill_info['card_type'];
+        $result['refill_amount'] = $refill_info['refill_amount'];
+        $result['order_amount'] = $refill_info['mch_amount'];
+        $result['order_time'] = $refill_info['order_time'];
+        $result['success_time'] = $refill_info['notify_time'];
+        $result['official_sn'] = $refill_info['official_sn'] ?? "";
+        $result['order_state'] = $order_info['order_state'];
+
+        return $result;
+    }
+}

+ 16 - 0
helper/rbridge/IBridgeEx.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ *   IBridgeEx.php
+ *   stanley-king
+ *   2023/12/16
+ *   PhpStorm
+ *   PHPProject
+ */
+
+namespace rbridge;
+
+interface IBridgeEx
+{
+    public function query($params);
+    public function balance($params);
+}

+ 26 - 1
helper/rbridge/RBridgeFactory.php

@@ -3,12 +3,16 @@
 namespace rbridge;
 
 require_once(BASE_HELPER_PATH . '/refill_proxy.php');
+
 require_once(BASE_HELPER_PATH . '/rbridge/IBridge.php');
+require_once(BASE_HELPER_PATH . '/rbridge/IBridgeEx.php');
+require_once(BASE_HELPER_PATH . '/rbridge/BridgeTrait.php');
 require_once(BASE_HELPER_PATH . '/rbridge/wsd/Bridge.php');
 require_once(BASE_HELPER_PATH . '/rbridge/fulu/Bridge.php');
 require_once(BASE_HELPER_PATH . '/rbridge/fulu_ylyw/Bridge.php');
 require_once(BASE_HELPER_PATH . '/rbridge/fulu_youjun/Bridge.php');
 require_once(BASE_HELPER_PATH . '/rbridge/fulu_qdw/Bridge.php');
+require_once(BASE_HELPER_PATH . '/rbridge/gy/Bridge.php');
 
 use Exception;
 use Log;
@@ -51,7 +55,6 @@ class RBridgeFactory
         }
 
         $ret = $bridge->notify($parmas);
-
         if($ret) {
             return "SUCCESS";
         }
@@ -60,6 +63,28 @@ class RBridgeFactory
         }
     }
 
+    public function query($mch_name,$parmas)
+    {
+        $bridge = $this->find($mch_name);
+        if(is_null($bridge)) {
+            return false;
+        }
+
+        $ret = $bridge->query($parmas);
+        return $ret;
+    }
+
+    public function balance($mch_name,$parmas)
+    {
+        $bridge = $this->find($mch_name);
+        if(is_null($bridge)) {
+            return false;
+        }
+
+        $ret = $bridge->balance($parmas);
+        return $ret;
+    }
+
     private function find($name)
     {
         try

+ 278 - 0
helper/rbridge/gy/Bridge.php

@@ -0,0 +1,278 @@
+<?php
+
+namespace rbridge\gy;
+
+require_once(BASE_HELPER_PATH . '/rbridge/gy/config.php');
+
+use rbridge\IBridge;
+use rbridge\IBridgeEx;
+use rbridge\BridgeTrait;
+use refill;
+use Log;
+use SimpleXMLElement;
+use member_info;
+
+class Bridge implements IBridge, IBridgeEx
+{
+    use BridgeTrait;
+
+    public function add($params)
+    {
+        $input_names = ['userid', 'request_id', 'telephone', 'money', 'callbackurl'];
+        $out_names = ['order_id', 'request_id', 'telephone', 'money', 'result'];
+
+        $mchid = config::mchid($params);
+        if ($mchid === false) {
+            $params['result'] = 4; //请求参数不完整或不合法
+            return [false, $this->result_format($params, $out_names, '')];
+        }
+
+        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
+        if (empty($mchinfo)) {
+            $params['result'] = 6; //代理商不存在
+            return [false, $this->result_format($params, $out_names, '')];
+        }
+
+        $secure_key = $mchinfo['secure_key'];
+        [$succ, $result] = $this->check($mchinfo, $params, $input_names);
+        if (!$succ) {
+            $params['result'] = $result;
+            return [false, $this->result_format($params, $out_names, $secure_key)];
+        }
+
+        Model('merchant_query')->add_info($mchid, $params['request_id'], json_encode($params));
+
+        $order_time = time();
+        $mch_order = $params['request_id'];
+        $card_no = $params['telephone'];
+        $input = ['mchid' => $mchid,
+            'buyer_id' => intval($mchinfo['admin_id']),
+            'amount' => $params['money'],
+            'card_no' => $card_no,
+            'mch_order' => $mch_order,
+            'notify_url' => config::MCH_NOTIFY_URL,
+            'order_time' => $order_time
+        ];
+
+        refill\util::push_queue_order($mchid, $mch_order, ORDER_STATE_QUEUE);
+        $detail_id = Model('refill_order')->add_detail($mchid, $mch_order, $order_time, $params, ORDER_STATE_QUEUE);
+
+        $state = refill\util::push_add($input);
+        if ($state === true) {
+            Log::record("gy::Bridge refill::util::push_add success mchid=$mchid mch_order=$mch_order state=true", Log::DEBUG);
+            $params['order_id'] = $detail_id;
+            $params['result'] = 2; //提交成功,正在充值(适用于异步接口)
+            return [true, $this->result_format($params, $out_names, $secure_key)];
+        } else {
+            refill\util::del_queue_order($mchid, $mch_order);
+            Model('refill_order')->del_detail($mchid, $mch_order);
+            Log::record("gy::Bridge refill::util::push_add error mchid=$mchid mch_order=$mch_order state=$state", Log::DEBUG);
+
+            $params['result'] = 12; //未知错误
+            return [true, $this->result_format($params, $out_names, $secure_key)];
+        }
+    }
+
+    private function result_format($input, $names, $secure_key)
+    {
+        $result = $this->sign($input, $names, $secure_key);
+        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root></root>');
+        config::arrayToXml($xml,$result);
+
+        return $xml->asXML();
+    }
+
+    private function sign($input, $names, $secure_key)
+    {
+        $result = [];
+
+        $body = '';
+        foreach ($names as $name) {
+            $val = $input[$name] ?? '';
+            $body .= $val;
+
+            $result[$name] = $val;
+        }
+        $body .= $secure_key;
+
+        $sign = strtoupper(md5($body));
+        $result['sign'] = $sign;
+        return $result;
+    }
+
+    private function check($mchinfo, $input, $names): array
+    {
+        if ($mchinfo['merchant_state'] != 1) {
+            return [false, 6]; //代理商不存在
+        }
+
+        $ips = unserialize($mchinfo['ip_white_list']);
+        if(!empty($ips))
+        {
+            $addr = $_SERVER['REMOTE_ADDR'];
+            if(!in_array($addr,$ips)) {
+                Log::record("request ip:$addr", Log::DEBUG);
+                return [false, 12]; //未知错误
+            }
+        }
+
+        $usekey = intval($mchinfo['use_key']);
+        $key = $mchinfo['secure_key'];
+
+        if ($usekey) {
+            $ret = $this->verify($input, $names, $key);
+            if (!$ret) {
+                return [false, 5]; //签名错误
+            }
+        }
+
+        return [true, ''];
+    }
+
+    private function verify($params, $names, $key)
+    {
+        $body = '';
+        foreach ($names as $name) {
+            $val = $params[$name] ?? '';
+            $body .= $val;
+        }
+        $body .= $key;
+
+        $sign = strtoupper(md5($body));
+        return $params['sign'] == $sign;
+    }
+
+    public function query($params)
+    {
+        $input_names = ['userid', 'request_id'];
+        $out_names = ['order_id', 'request_id', 'telephone', 'money', 'result'];
+
+        $mchid = config::mchid($params);
+        $mch_order = $params['request_id'];
+
+        if ($mchid === false or empty($mch_order)) {
+            $params['result'] = 4; //请求参数不完整或不合法
+            return [false, $this->result_format($params, $out_names, '')];
+        }
+
+        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
+        if (empty($mchinfo)) {
+            $params['result'] = 6; //代理商不存在
+            return [false, $this->result_format($params, $out_names, '')];
+        }
+
+        $secure_key = $mchinfo['secure_key'];
+        [$succ, $result] = $this->check($mchinfo, $params, $input_names);
+        if(!$succ) {
+            $params['result'] = $result;
+            return [$succ, $this->result_format($params, $out_names, $secure_key)];
+        }
+
+        [$detail_id,$info] = $this->detail($mchid, $mch_order);
+        [$code, $order] = $this->order_query($mchid, $mch_order);
+
+        if ($code == 200) {
+            $info['order_id'] = $detail_id;
+            $order_state = $order['order_state'];
+        } else {
+            $order_state = ORDER_STATE_NOEXIST;
+        }
+
+        if (in_array($order_state, [ORDER_STATE_QUEUE, ORDER_STATE_NEW, ORDER_STATE_PAY, ORDER_STATE_SEND])) {
+            $info['result'] = 2;
+        } elseif ($order_state == ORDER_STATE_SUCCESS) {
+            $info['result'] = 0;
+        } elseif ($order_state == ORDER_STATE_CANCEL) {
+            $info['result'] = 1;
+        } else {
+            $info['result'] = 3;
+        }
+
+        return [true, $this->result_format($info, $out_names, $secure_key)];
+    }
+
+    private function detail($mchid, $mch_order)
+    {
+        $mod_refill = Model('refill_order');
+        $detail = $mod_refill->get_detail($mchid,$mch_order);
+        if(empty($detail)) {
+            return [false, []];
+        }
+        else {
+            return [intval($detail['detail_id']), json_decode($detail['params'], true)];
+        }
+    }
+
+    public function balance($params)
+    {
+        $input_names = ['userid'];
+        $out_names = ['userid', 'money'];
+
+        $mchid = config::mchid($params);
+
+        if ($mchid === false) {
+            $params['result'] = 4; //请求参数不完整或不合法
+            return [false, $this->result_format($params, $out_names, '')];
+        }
+
+        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
+        if (empty($mchinfo)) {
+            $params['result'] = 6; //代理商不存在
+            return [false, $this->result_format($params, $out_names, '')];
+        }
+
+        $secure_key = $mchinfo['secure_key'];
+        [$succ, $result] = $this->check($mchinfo, $params, $input_names);
+        if(!$succ) {
+            $params['result'] = $result;
+            return [$succ, $this->result_format($params, $out_names, $secure_key)];
+        }
+
+        $uid = intval($mchinfo['admin_id']);
+        $minfo = new member_info($uid);
+        $available = $minfo->available_predeposit();
+        $money = ncPriceFormat($available - $mchinfo['credit_bonus']);
+        $params['money'] = $money;
+
+        return [true, $this->result_format($params, $out_names, $secure_key)];
+    }
+
+    public function notify($params)
+    {
+        $out_names = ['order_id', 'request_id', 'telephone', 'money', 'result'];
+
+        $mchid = $params['mchid'];
+        $mch_order = $params['order_sn'];
+        [$detail_id,$input] = $this->detail($mchid, $mch_order);
+
+
+        $mchid = $params['mchid'];
+        $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
+        $secure_key = $mchinfo['secure_key'];
+
+        $body = $this->notify_body($detail_id,$input,$params['state']);
+        $body = $this->sign($body,$out_names,$secure_key);
+
+        $resp = http_request($input['callbackurl'], $body, 'GET');
+        if (empty($resp)) {
+            Log::record("回调下游,请求超时 mchid = $mchid mch_order = $mch_order", Log::ERR);
+            return false;
+        } elseif (in_array($resp, ['success'])) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function notify_body($detail_id, $input, $order_state)
+    {
+        $input['order_id'] = $detail_id;
+        if($order_state == 'SUCCESS') {
+            $input['result'] = 0;
+        } else {
+            $input['result'] = 1;
+        }
+
+        return $input;
+    }
+}

+ 29 - 0
helper/rbridge/gy/config.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace rbridge\gy;
+
+class config
+{
+    const MCH_NOTIFY_URL = 'gy';
+    public static function mchid($params)
+    {
+        $userid = intval($params['userid']);
+        return $userid;
+    }
+
+    public static function arrayToXml($obj, $array)
+    {
+        foreach ($array as $k => $v)
+        {
+            if (is_numeric($k))
+                $k = 'item' . $k;
+            if (is_array($v)) {
+                $node = $obj->addChild($k);
+                self::arrayToXml($node, $v);
+            } else {
+                $obj->addChild($k, htmlspecialchars($v));
+            }
+        }
+    }
+}
+

BIN
helper/rbridge/gy/协议.pdf


+ 16 - 1
helper/refill/api/mh/ReadMe.MD

@@ -1 +1,16 @@
-测试
+视频会员系统正式环境前台登录地址:
+http://mbsmemberclient.scyshy.com
+视频会员系统正式环境收单地址:
+
+接口地址:
+订单查询地址为:http://mbapiq.mbs.scyshy.com/Order/QueryV2
+余额查询地址为:http://mbapiq.mbs.scyshy.com/Member/GetAccount
+直充产品订单收单地址为:http://mbapii.mbs.scyshy.com/Order/InsertV2
+卡密产品订单收单地址:http://mbapii.mbs.scyshy.com/Order/InsertSiberianNitrariaFruitV2
+发送验证码地址为:http://mboapi.mbs.scyshy.com/mbs/down/jd/verify/code
+短信验证接口地址为:http://mboapi.mbs.scyshy.com/mbs/down/jd/check/code
+
+登陆名称(会员名):bjmeihai
+新用户密码为:882788
+AppKey:211395563
+AppSecret:MjY0NTU0NmUtNmNhOS00Y2YzLTk5YmUtMjM4MzIyYWE1MmVj

+ 4 - 0
helper/refill/api/mh/dixin_normal/ReadMe.MD

@@ -1,3 +1,7 @@
 登陆地址:https://xin.baiopen.com/#/login?redirect=%2F404
 账号:15652921127
 初始密码:xl123456
+
+## 店铺
+- 账号:dixin
+- 密码:dixin@67890

+ 4 - 5
helper/refill/api/mh/dixin_normal/RefillCallBack.php

@@ -28,18 +28,17 @@ class RefillCallBack implements refill\IRefillCallBack
             return [false, false, false, false, ''];
         }
 
-        $official_sn = strtolower($params['official_sn']) == 'null' ? '' : $params['official_sn'];
         $order_id = $order_info['order_id'];
+        $ch_trade_no = $params['order_no'];
 
         $status = intval($params['recharge_status']);
         if ($status === 3) {
-            $data['ch_trade_no'] = $params['order_no'];
-            $data['official_sn'] = $official_sn;
-            Model('refill_order')->edit($order_id, $data);
+            $official_sn = $params['official_sn'] ?? '';
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no,'official_sn' => $official_sn]);
             return [$order_id, true, false, true, $official_sn];
         }
         elseif (in_array($status,[4,5])) {
-            Model('refill_order')->edit($order_id, ['ch_trade_no' => $params['order_no']]);
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
             return [$order_id, false, true, true, ''];
         }
         else {

+ 4 - 3
helper/refill/api/mh/dixin_normal/RefillPhone.php

@@ -76,6 +76,7 @@ class RefillPhone extends refill\IRefillPhone
         return (float)sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
     }
 
+    //[$state, $errmsg, $neterr]
     public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
     {
         $params = $this->add_params($card_no, $amount, $params['order_sn'],$card_type);
@@ -104,8 +105,8 @@ class RefillPhone extends refill\IRefillPhone
 
     public function query($refill_info): array
     {
-        $params['merchant_no'] = $refill_info['order_sn'];
-        $params = $this->method('query.order',$params);
+        $params['merchant_no'] = $refill_info['order_sn'];  //sn码
+        $params = $this->method('query.order',$params);//查数据库情况,查询全部数据结构包括orderid
         $resp = http_request(config::ORDER_URL, $params , 'POST');
 
         if (empty($resp)) {
@@ -126,7 +127,7 @@ class RefillPhone extends refill\IRefillPhone
 
                 //充值状态:1=待充值,2=充值中,3=充值完成,4=充值失败,5=运营商维护,8=部分到账
                 if ($status == '3') {
-                    $save['ch_trade_no'] = $val['order_no'];
+                    $save['ch_trade_no'] = $val['order_no'];//平台的订单号
                     $save['official_sn'] = $official_sn;
                     Model('refill_order')->edit($refill_info['order_id'], $save);
                     $order_state = ORDER_STATE_SUCCESS;

+ 3 - 0
helper/refill/api/mh/dixin_slow/ReadMe.MD

@@ -0,0 +1,3 @@
+登陆地址:https://xin.baiopen.com/#/login?redirect=%2F404
+账号:15652921127
+初始密码:xl123456

+ 48 - 0
helper/refill/api/mh/dixin_slow/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\dixin_slow;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dixin_slow/config.php');
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = config::sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //[$order_id, $success, $can_try, $need_handle, $official_sn]
+    public function notify($params): array
+    {
+        $order_sn = $params['merchant_no'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        $ch_trade_no = $params['order_no'];
+
+        $status = intval($params['recharge_status']);
+        if ($status === 3) {
+            $official_sn = $params['official_sn'] ?? '';
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no,'official_sn' => $official_sn]);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif (in_array($status,[4,5])) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 173 - 0
helper/refill/api/mh/dixin_slow/RefillPhone.php

@@ -0,0 +1,173 @@
+<?php
+
+namespace refill\dixin_slow;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dixin_slow/config.php');
+
+use mtopcard;
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function add_params(int $phone, int $amount, string $order_sn, int $card_type): array
+    {
+        $oper_getter = function ($card_type)
+        {
+            if($card_type == mtopcard\ChinaMobileCard) {
+                return 'YD';
+            }
+            elseif($card_type == mtopcard\ChinaUnicomCard) {
+                return 'LT';
+            }
+            elseif($card_type == mtopcard\ChinaTelecomCard) {
+                return 'DX';
+            }
+            else {
+                return false;
+            }
+        };
+
+        $operator = $oper_getter($card_type);
+        $sku_code = config::sku_code($card_type,$amount);
+
+        if($operator === false || empty($sku_code)) {
+            return [];
+        }
+
+        $params = [
+            'merchant_no' => $order_sn,
+            'sku_code' => $sku_code,
+            'format' =>  ['account' => $phone],
+            "format_type" => "common",
+            'notice_url' => config::NOTIFY_URL,
+            "uid" => "123456"
+        ];
+
+        $result = $this->method('create.order',$params);
+
+        return $result;
+    }
+
+    private function method($method,$data = [],$attach = '')
+    {
+        $param = [
+            'access_token' => config::ACCESS_TOKEN,
+            'once' => uniqid(),
+            'timestamp' => $this->getUnixTimestamp(),
+            'attach' => $attach,
+            'format' => 'JSON',
+            'sign_type' => 'MD5',
+            'version' => '1.0.0',
+            'method' => $method,
+            'data' => json_encode($data, 256),
+        ];
+        $param = array_merge($param, ['sign' => config::sign($param)]);
+        return $param;
+    }
+    private function getUnixTimestamp ()
+    {
+        list($s1, $s2) = explode(' ', microtime());
+        return (float)sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
+    }
+
+    //[$state, $errmsg, $neterr]
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->add_params($card_no, $amount, $params['order_sn'],$card_type);
+        if(empty($params)) {
+            return [false, '提单参数不符合', false];
+        }
+
+        $resp = http_request(config::ORDER_URL, $params , 'POST' , false , [] , $net_errno);
+
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp ,true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === 200) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['message'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['merchant_no'] = $refill_info['order_sn'];  //sn码
+        $params = $this->method('query.order',$params);//查数据库情况,查询全部数据结构包括orderid
+        $resp = http_request(config::ORDER_URL, $params , 'POST');
+
+        if (empty($resp)) {
+            return [false, '系统错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', ''];
+            }
+            elseif ($resp['code'] === 200)
+            {
+                $val = $resp['data'][0];
+                $status = $val['recharge_status'];
+                $official_sn = '';//strtolower($val['official_sn']) == 'null' ? '' : $val['official_sn'];
+
+                //充值状态:1=待充值,2=充值中,3=充值完成,4=充值失败,5=运营商维护,8=部分到账
+                if ($status == '3') {
+                    $save['ch_trade_no'] = $val['order_no'];//平台的订单号
+                    $save['official_sn'] = $official_sn;
+                    Model('refill_order')->edit($refill_info['order_id'], $save);
+                    $order_state = ORDER_STATE_SUCCESS;
+                }
+                elseif (in_array($status,[4,5])) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['order_no']]);
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+                else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+            else
+            {
+                return [false, $resp['message'], ''];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params = $this->method('query.balance',[]);
+        $resp = http_request(config::ORDER_URL, $params , 'POST');
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === 200) {
+                return [true, ncPriceFormat($resp['data']['predict_money'])];
+            } else {
+                return [false, $resp['message']];
+            }
+        }
+    }
+}

+ 74 - 0
helper/refill/api/mh/dixin_slow/config.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace refill\dixin_slow;
+
+use mtopcard;
+
+class config
+{
+    const ACCESS_TOKEN = '406c0c33c27e18662a756b369a1074c1';
+    const KEY = 'a6573b34c420dc7304c4331672297f7d';
+    const ORDER_URL = 'https://m.baiopen.com/openapi/method';
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/dixin_slow.php";
+    const IS_DEBUG = false;
+    private static $stStoreProducts = [
+        50  => [4 => 'G32540029294752736', 5 => 'G32540029294758742', 6 => 'G32540029294755739'],
+        100 => [4 => 'G32540029294753737', 5 => 'G32540029294759743', 6 => 'G32540029294756740'],
+        200 => [4 => 'G32540029294754738', 5 => 'G32540029294760744', 6 => 'G32540029294757741']
+    ];
+
+    public static function sign($params)
+    {
+        if (is_object($params)) { //对象转数组
+            $params = json_decode(json_encode($params), true);
+        }
+
+        $params['sign_key'] = config::KEY;
+        ksort($params);
+
+        $formatData = [];
+        foreach ($params as $k => $v) {
+            if (is_array($v) || is_object($v)) {
+                $v = json_encode($v, JSON_UNESCAPED_UNICODE);
+            }
+            if ((!empty($v) || (string)$v === '0') && $k != 'sign') {
+                $formatData[] = "$k=$v";
+            }
+        }
+        $signStr = implode('&', $formatData);
+
+        return md5($signStr);
+    }
+
+    public static function sku_code($card_type,$amount)
+    {
+        if(config::IS_DEBUG)
+        {
+            if($card_type === mtopcard\ChinaMobileCard)
+            {
+                switch ($amount)
+                {
+                    case 50:
+                        return 'G34707828905632832';
+                }
+            }
+            elseif($card_type === mtopcard\ChinaUnicomCard)
+            {
+                switch ($amount)
+                {
+                    case 50:
+                        return 'G34707828917408824';
+                }
+            }
+        }
+        else
+        {
+            if(array_key_exists($amount,self::$stStoreProducts)) {
+                if(array_key_exists($card_type,self::$stStoreProducts[$amount])) {
+                    return self::$stStoreProducts[$amount][$card_type];
+                }
+            }
+            return false;
+        }
+    }
+}

+ 133 - 0
helper/refill/api/mh/dixin_slow/demo.txt

@@ -0,0 +1,133 @@
+<?php
+
+
+namespace refill\dixin_normal;
+class demo
+{
+    //默认配置
+    protected $config = [
+        "access_token"          => "您的访问token",
+        "sign_key"          => "您的签名key",
+        'url'      =>'http://openapi.baishouopen.com/method',
+        'test_url'      =>'http://t.openapi.baishouopen.com/method',
+    ];
+
+    //使用
+    // $demo = new demo();
+    // $rs = $demo->method('maintain.region',[]);
+
+    // method
+    // create.order  创建订单
+    // query.order   查询订单
+    // 更多见文档 http://api.35kds.com/web/#/64?page_id=720
+
+    /**
+     * @var string 请求地址
+     */
+    protected $service;
+
+    /**
+     * demo constructor.
+     * @param bool $is_debug
+     */
+    public function __construct($is_debug=true)
+    {
+        $this->service = $is_debug?$this->config['test_url']:$this->config['url'];
+    }
+
+    /**
+     * @introduce 请求接口
+     * @param string $method 接口名称
+     * @param json $data 参数
+     * @param string $attach 透传参数
+     * @return bool|string
+     * @author yanglei
+     * @Date 2022/1/27
+     */
+    public function method($method,$data = [],$attach = ''){
+        $param = [
+            'access_token'        =>  $this->config['access_token'],
+            'once'        =>  uniqid() ,
+            'timestamp'  =>  time()*1000,
+            'attach'       =>  $attach,
+            'format'     =>  'JSON',
+            'sign_type'    =>  'MD5',
+            'version'       =>  '1.0.0',
+            'method'       =>  $method,
+            'data'       =>  json_encode($data,256),
+        ];
+        $param = array_merge($param,['sign'=>$this->sign($param,$this->config['sign_key'])]);
+        return $this->http($this->service,$param);
+    }
+
+    /**
+     * @introduce 获取13时间戳
+     * @return float
+     * @Date 2022/1/27
+     * @author yanglei
+     */
+    function getUnixTimestamp ()
+    {
+        list($s1, $s2) = explode(' ', microtime());
+        return (float)sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
+
+    }
+    /**
+     * 创建签名
+     * @param $params array|object 参与签名的数据
+     * @param $signKey string 签名key
+     * @return string
+     */
+    protected function sign($params, $signKey = '')
+    {
+        if (is_object($params)) { //对象转数组
+            $params = json_decode(json_encode($params), true);
+        }
+        if (!empty($signKey)) {
+            $params['sign_key'] = $signKey;
+        }
+        ksort($params);
+        $formatData = [];
+        foreach ($params as $k => $v) {
+            if (is_array($v) || is_object($v)) {
+                $v = json_encode($v,JSON_UNESCAPED_UNICODE);
+            }
+            if ((!empty($v) || (string)$v === '0') && $k != 'sign') {
+                $formatData[] = "$k=$v";
+            }
+        }
+        $signStr = implode('&', $formatData);
+        return strtoupper(md5($signStr));
+    }
+    /**
+     * @introduce http post请求
+     * @param $url string 请求地址
+     * @param $data array 参数
+     * @return bool|string
+     * @Date 2022/1/4
+     * @author yanglei
+     */
+    protected function http($url, $data){
+        $curl = curl_init(); // 启动一个CURL会话
+        curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
+        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查
+        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在
+        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); // 模拟用户使用的浏览器
+        //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
+        //curl_setopt($curl, CURLOPT_AUTOREFERER, 1);    // 自动设置Referer
+        curl_setopt($curl, CURLOPT_POST, 1);             // 发送一个常规的Post请求
+        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);   // Post提交的数据包x
+        curl_setopt($curl, CURLOPT_TIMEOUT, 30);         // 设置超时限制 防止死循环
+        curl_setopt($curl, CURLOPT_HEADER, 0);           // 显示返回的Header区域内容
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);   // 获取的信息以文件流的形式返回
+
+        $tmpInfo = curl_exec($curl); // 执行操作
+        if(curl_errno($curl))
+        {
+            return false;//捕抓异常
+        }
+        curl_close($curl); // 关闭CURL会话
+        return $tmpInfo; // 返回数据
+
+    }
+}

+ 19 - 0
helper/refill/api/mh/lifang_normal/API.MD

@@ -0,0 +1,19 @@
+项目编号:A231116000
+登录账号:北京美嗨
+登录密码:LF123456
+
+## 店铺
+- 账号:lifang
+- 密码:lifang@888999
+
+accessToken:beaf87f8-7c6b-cb8a-98b8-53c207ca9aef
+appSecret:24b67f6f-2696-ede0-ced6-0b975b05d8e1
+
+登录网址:http://cz.lifang001.com/
+
+API文档:http://api.lifang001.com/doc.html
+下单地址:http://api.lifang001.com/api/mobile/charge
+查询地址:http://api.lifang001.com/api/mobile/query
+余额地址:http://api.lifang001.com/api/finance/balance
+
+

+ 51 - 0
helper/refill/api/mh/lifang_normal/RefillCallBack.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace refill\lifang_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/lifang_normal/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = config::sign($input,config::notify_keys);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //[$order_id, $success, $can_try, $need_handle, $official_sn]
+    public function notify($params): array
+    {
+        $order_sn = $params['outOrderId'];
+        $ch_trade_no = $params['orderId'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        $official_sn = $params['chargeOrderInfo'] ?? '';
+
+        //订单状态,0 充值中, 1 充值成功, 9 充值失败, 6 存疑(人工核实)
+        $status = $params['status'];
+        if ($status == 1) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no, 'official_sn' => $official_sn]);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif ($status == 9) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 133 - 0
helper/refill/api/mh/lifang_normal/RefillPhone.php

@@ -0,0 +1,133 @@
+<?php
+
+namespace refill\lifang_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/lifang_normal/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function add_params(int $phone, int $amount, string $order_sn, int $card_type): array
+    {
+        $input = [
+            'amount'        => $amount,
+            'outOrderId'    => $order_sn,
+            'phoneNumber'   => $phone,
+            'requestDate'   => config::time_stamp(),
+            'callBackUrl'   => config::NOTIFY_URL
+        ];
+
+        $params =  config::gen_params($input,config::add_keys);
+        return  $params;
+    }
+
+    //[$state, $errmsg, $neterr]
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->add_params($card_no, $amount, $params['order_sn'], $card_type);
+        if(empty($params)) {
+            return [false, '提单参数不符合', false];
+        }
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $net_errno);
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            /// 订单状态,0 充值中 1 充值成功 9 充值失败 6 存疑(人工核实)
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['code'] === 200) {
+                return [true, $resp['orderId'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $input = [
+            'outOrderId'  => $refill_info['order_sn'],
+            'requestDate' => config::time_stamp()
+        ];
+        $params = config::gen_params($input,config::query_keys);
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', ''];
+            }
+
+            $code = intval($resp['code']);
+            if ($code === 200)
+            {
+                $val = $resp['data'];
+                $status = intval($val['status']);
+                $official_sn = '';
+
+                //订单状态,0 充值中 1 充值成功 9 充值失败 6 存疑(人工核实)
+                if ($status == 1) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['orderId'],'official_sn' => $official_sn]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                }
+                elseif ($status == 9) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['orderId']]);
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+                else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+            elseif($code === 80001 and (time() - $refill_info['commit_time']) >= 300) {
+                return [true, ORDER_STATE_NOEXIST, ''];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $input = [
+            'requestDate' => config::time_stamp()
+        ];
+        $params = config::gen_params($input,config::balance_keys);
+
+        $resp = http_request(config::BALANCE_URL, $params , 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['code'] === 200) {
+                return [true, ncPriceFormat($resp['data']['leftBalance'])];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+}

+ 48 - 0
helper/refill/api/mh/lifang_normal/config.php

@@ -0,0 +1,48 @@
+<?php
+
+namespace refill\lifang_normal;
+
+class config
+{
+    public const accessToken = 'beaf87f8-7c6b-cb8a-98b8-53c207ca9aef';
+    public const appSecret = '24b67f6f-2696-ede0-ced6-0b975b05d8e1';
+    public const ORDER_URL = 'http://api.lifang001.com/api/mobile/charge';
+    public const QUERY_URL = 'http://api.lifang001.com/api/mobile/query';
+    public const BALANCE_URL = 'http://api.lifang001.com/api/finance/balance';
+    public const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/lifang_normal.php";
+
+    public const add_keys = ['accessToken', 'amount', 'outOrderId', 'phoneNumber', 'requestDate'];
+    public const query_keys = ['accessToken', 'outOrderId', 'requestDate'];
+    public const balance_keys = ['accessToken', 'requestDate'];
+    public const notify_keys = ['accessToken', 'orderId', 'outOrderId', 'requestDate', 'status'];
+
+    public static function sign($params,$keys): string
+    {
+        $str = '';
+        foreach ($keys as $key)
+        {
+            $str .= $key;
+            if($key == 'accessToken') {
+                $str .= config::accessToken;
+            }
+            else {
+                $val = $params[$key] ?? '';
+                $str .= $val;
+            }
+        }
+
+        $str .= self::appSecret;
+        return strtoupper(md5($str));
+    }
+
+    public static function gen_params($params,$keys)
+    {
+        $params['sign'] = config::sign($params,$keys);
+        $params['accessToken'] = config::accessToken;
+        return $params;
+    }
+    public static function time_stamp ()
+    {
+        return date('YmdHis', time());
+    }
+}

BIN
helper/refill/api/mh/lifang_normal/力方接口返回示例.docx


+ 3 - 1
helper/refill/api/mh/suhu_normal/ReadMe.MD

@@ -6,7 +6,9 @@
 登录密码:n82e471z9g
 签名密钥:xnx4uaqbmqg0f03e0ey62zn4zoxnackl
 
-
+## 店铺
+- 账号:suhupu
+- 密码:suhu@1117
 
 
 全国移动话费100元的商品编号是:10010

+ 18 - 4
helper/refill/api/mh/suhu_normal/RefillCallBack.php

@@ -3,22 +3,36 @@ namespace refill\suhu_normal;
 
 require_once(BASE_HELPER_RAPI_PATH . '/suhu_normal/config.php');
 use refill;
+use Log;
 
 class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $signer = function ($params) {
-            $body = "code={$params['memberId']}rechargeOrderId={$params['rechargeOrderId']}memberOrderId={$params['memberOrderId']}rechargeAccount={$params['rechargeAccount']}productId={$params['productId']}faceValue={$params['faceValue']}signkey=";
-            $body .= config::KEY;
+        $input_names = ['code','rechargeOrderId','memberOrderId','rechargeAccount','productId','faceValue','signkey'];
+
+        $signer = function ($params,$names)
+        {
+            $body = '';
+            foreach ($names as $name)
+            {
+                if($name == 'signkey') {
+                    $body .= $name . '=' . config::KEY;
+                }
+                else {
+                    $body .= $name . '=' . $params[$name];
+                }
+
+            }
 
             return md5($body);
         };
 
-        $sign = $signer($params);
+        $sign = $signer($params,$input_names);
         if ($params['sign'] == $sign) {
             return true;
         } else {
+            Log::record('suhu_normal\RefillCallBack::verify fail',Log::DEBUG);
             return false;
         }
     }

+ 1 - 1
helper/refill/api/mh/suhu_normal/RefillPhone.php

@@ -182,7 +182,7 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '系统错误'];
             } elseif ($resp['status'] === 1) {
-                return [true, ncPriceFormat($resp['result']['money'])];
+                return [true, ncPriceFormat($resp['result']['money']+$resp['result']['grantMoney'])];
             } else {
                 return [false, $resp['msg']];
             }

+ 3 - 0
helper/refill/api/mh/suhu_wozhifu/ReadMe.MD

@@ -4,6 +4,9 @@
 登录密码:kwgfi6fm9e
 签名密钥:dvv0atra7egmbcji8wy07ba3dt0h7609
 
+## 店铺
+- 账号:suhuwozhifu
+- 密码:suhuwozhifu1118
 
 沃支付产品编码:
 

+ 17 - 4
helper/refill/api/mh/suhu_wozhifu/RefillCallBack.php

@@ -3,22 +3,35 @@ namespace refill\suhu_wozhifu;
 
 require_once(BASE_HELPER_RAPI_PATH . '/suhu_wozhifu/config.php');
 use refill;
+use Log;
 
 class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $signer = function ($params) {
-            $body = "code={$params['memberId']}rechargeOrderId={$params['rechargeOrderId']}memberOrderId={$params['memberOrderId']}rechargeAccount={$params['rechargeAccount']}productId={$params['productId']}faceValue={$params['faceValue']}signkey=";
-            $body .= config::KEY;
+        $input_names = ['code','rechargeOrderId','memberOrderId','rechargeAccount','productId','faceValue','signkey'];
+        $signer = function ($params,$names)
+        {
+            $body = '';
+            foreach ($names as $name)
+            {
+                if($name == 'signkey') {
+                    $body .= $name . '=' . config::KEY;
+                }
+                else {
+                    $body .= $name . '=' . $params[$name];
+                }
+
+            }
 
             return md5($body);
         };
 
-        $sign = $signer($params);
+        $sign = $signer($params,$input_names);
         if ($params['sign'] == $sign) {
             return true;
         } else {
+            Log::record('suhu_wozhifu\RefillCallBack::verify fail',Log::DEBUG);
             return false;
         }
     }

+ 2 - 2
helper/refill/api/mh/suhu_wozhifu/RefillPhone.php

@@ -136,7 +136,7 @@ class RefillPhone extends refill\IRefillPhone
                     $order_state = ORDER_STATE_CANCEL;
                 }
             }
-            elseif($status === 2 and (time() - $refill_info['commit_time'] >= 600))
+            elseif($status === 2 and (time() - $refill_info['commit_time']) >= 600)
             {
                 $order_state = ORDER_STATE_NOEXIST;
             }
@@ -182,7 +182,7 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '系统错误'];
             } elseif ($resp['status'] === 1) {
-                return [true, ncPriceFormat($resp['result']['money'])];
+                return [true, ncPriceFormat($resp['result']['money']+$resp['result']['grantMoney'])];
             } else {
                 return [false, $resp['msg']];
             }

+ 4 - 4
helper/refill/api/mh/suhu_wozhifu/config.php

@@ -17,10 +17,10 @@ class config
     const ERRCODES = [101, 102, 103, 104, 105, 106, 107, 108, 109];
 
     private static $stStoreProducts = [
-        50  => [ 5 => '10011'],
-        100 => [ 5 => '10012'],
-        200 => [ 5 => '10013'],
-        300 => [ 5 => '10014']
+        50  => [ 5 => '10131'],
+        100 => [ 5 => '10132'],
+        200 => [ 5 => '10133'],
+        300 => [ 5 => '10134']
     ];
 
     public static function sign($params)

+ 34 - 0
helper/refill/api/mh/weisanhuo_normal/API.MD

@@ -0,0 +1,34 @@
+
+## 微三活 普充
+
+### 账号:
+- 用户名:bjmh
+- 密码:bjmh@2023
+- 密钥ID(secretId):9aebda54f899419a80f315b33b6ed395
+- 密钥值(secretKey):14d56f3637ba4618b50e91f444d1a029
+### 后台地址:
+> http://124.70.69.117:50080
+
+## 店铺
+- 账号:weisanhuo
+- 密码:weisanhuo@888
+
+### 编码
+序号 商品名称 商品代码 面值 商品类型 品牌
+1 全国电信200元 k-dx-200 200 元 手机话费 电信
+2 全国电信100元 k-dx-100 100 元 手机话费 电信
+3 全国电信50元 k-dx-50 50 元 手机话费 电信
+4 全国电信30元 k-dx-30 30 元 手机话费 电信
+5 全国移动500元 k-yd-500 500 元 手机话费 移动
+6 全国移动300元 k-yd-300 300 元 手机话费 移动
+7 全国移动200元 k-yd-200 200 元 手机话费 移动
+8 全国移动100元 k-yd-100 100 元 手机话费 移动
+9 全国移动50元 k-yd-50 50 元 手机话费 移动
+10 全国移动30元 k-yd-30 30 元 手机话费 移动
+11 全国联通200元 k-lt-200 200 元 手机话费 联通
+12 全国联通100元 k-lt-100 100 元 手机话费 联通
+13 全国联通50元 k-lt-50 50 元 手机话费 联通
+14 全国联通30元 k-lt-30 30 元 手机话费 联通
+
+### 测试代码
+- cshf1

+ 40 - 0
helper/refill/api/mh/weisanhuo_normal/RefillCallBack.php

@@ -0,0 +1,40 @@
+<?php
+namespace refill\weisanhuo_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo_normal/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = config::sign($params, ['sign']);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public function notify($params): array
+    {
+        $status = $params['status'];
+        $order_sn = $params['outTradeNo'];
+        $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        if ($status == 'success') {
+            $official_sn = $params['operatorTradeNo'];
+            Model('refill_order')->edit($order_id, ['official_sn' => $official_sn, 'ch_trade_no' => $params['inTradeNo']]);
+            return [$order_id, true, false, true, $official_sn];
+        } elseif ($status == 'failed') {
+            return [$order_id, false, true, true, ''];
+        } else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 147 - 0
helper/refill/api/mh/weisanhuo_normal/RefillPhone.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace refill\weisanhuo_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/weisanhuo_normal/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $card_no, int $card_type, string $order_sn, int $amount): array
+    {
+        $params['outTradeNo'] = $order_sn;
+        $params['secretId'] = config::SECRET_ID;
+        $params['account'] = $card_no;
+
+        $product_id = config::ProductIdS[$card_type][$amount] ?? false;
+        if ($product_id === false){
+            return [];
+        }
+        $params['packageCode'] = $product_id;
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->req_params($card_no, $card_type, $params['order_sn'], $amount);
+        if (empty($params)){
+            return [false, '产品编码错误', false];
+        }
+
+        $sign = config::sign($params,['outTradeNo']);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $net_errno);
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+
+            $resp = json_decode($resp ,true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            }
+            if ($resp['success'] === false){
+                return [false, $resp['returnMessage'], false];
+            }
+
+            $status = $resp['data']['status'];
+            if ($status == 'waiting') {
+                return [true, $resp['data']['inTradeNo'], false];
+            } else {
+                return [false, $resp['data']['statusDesc'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['secretId'] = config::SECRET_ID;
+        $params['outTradeNo'] = $refill_info['order_sn'];
+        $sign = config::sign($params, ['outTradeNo']);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::QUERY_URL, $params, 'GET');
+        if (empty($resp)) {
+            return [false, '网络错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+
+            $resp = json_decode($resp, true);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            elseif ($resp['success'] === true)
+            {
+                $offical_sn = '';
+
+                if(!empty($resp['data']))
+                {
+                    $status = $resp['data']['status'];
+                    if ($status == 'success') {
+                        $offical_sn = $resp['data']['operatorTradeNo'];
+                        $ch_trade_no = $resp['data']['inTradeNo'];
+                        Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $offical_sn,'ch_trade_no' => $ch_trade_no]);
+                        $order_state = ORDER_STATE_SUCCESS;
+                    } elseif ($status == 'failed') {
+                        $ch_trade_no = $resp['data']['inTradeNo'];
+                        Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $ch_trade_no]);
+                        $order_state = ORDER_STATE_CANCEL;
+                    } elseif ($status == 'waiting') {
+                        $order_state = ORDER_STATE_SEND;
+                    } else {
+                        return [false, $status, $offical_sn];
+                    }
+
+                    return [true, $order_state, $offical_sn];
+                }
+                elseif ((time() - $refill_info['commit_time']) >= 600) {
+                    return [true, ORDER_STATE_NOEXIST, $offical_sn];
+                }
+                else {
+                    return [true, ORDER_STATE_SEND, $offical_sn];
+                }
+            }
+            else
+            {
+                return [false, $resp['returnMessage'], ''];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['secretId'] = config::SECRET_ID;
+
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::BALANCE_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        } else {
+            Log::record($resp, Log::DEBUG);
+
+            $resp = json_decode($resp, true);
+            if ($resp['success'] === true) {
+                return [true, $resp['data']];
+            } else {
+                return [false, $resp['returnMessage']];
+            }
+        }
+    }
+}

BIN
helper/refill/api/mh/weisanhuo_normal/code.xlsx


+ 70 - 0
helper/refill/api/mh/weisanhuo_normal/config.php

@@ -0,0 +1,70 @@
+<?php
+namespace refill\weisanhuo_normal;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/single';
+    const QUERY_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/report/query';
+    const BALANCE_URL = 'http://124.70.69.117:50050/api/v1/rest/multi/charge/balance';
+
+    const SECRET_ID = '9aebda54f899419a80f315b33b6ed395';
+    const SECRET_KEY = '14d56f3637ba4618b50e91f444d1a029';
+    const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/weisanhuo_normal.php";
+    const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
+
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30 => 'cshf1',  //测试
+                50 => 'k-yd-50',
+                100 => 'k-yd-100',
+                200 => 'k-yd-200'
+                //300 => 'k-yd-300',
+               // 500 => 'k-yd-500'
+            ],
+//        mtopcard\ChinaUnicomCard =>
+//            [
+//                30 => 'k-lt-30',
+//                50 => 'k-lt-50',
+//                100 => 'k-lt-100',
+//                200 => 'k-lt-200'
+//            ],
+//        mtopcard\ChinaTelecomCard =>
+//            [
+//                30 => 'k-dx-30',
+//                50 => 'k-dx-50',
+//                100 => 'k-dx-100',
+//                200 => 'k-dx-200'
+//            ]
+    ];
+
+    public static function sign(array $params, array $ignore = []): string
+    {
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if (in_array($key, $ignore)) {
+                continue;
+            }
+
+            if(self::check_empty($value) === false) {
+                $key = strtolower($key);
+                $value = urlencode($value);
+                $content .= "$key=$value&";
+            }
+        }
+        $content .= "secretkey=" . config::SECRET_KEY;
+        return md5($content);
+    }
+
+    public static function check_empty($value): bool
+    {
+        if (!isset($value))
+            return true;
+        if (trim($value) === "null")
+            return true;
+
+        return false;
+    }
+}

BIN
helper/refill/api/mh/weisanhuo_normal/help.doc


BIN
helper/refill/api/mh/weisanhuo_normal/~$help.doc


+ 50 - 0
helper/refill/api/mh/yushang_normal/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace refill\yushang_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yushang_normal/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = config::sign($params,config::notify_keys);
+        if ($params['Sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    //[$order_id, $success, $can_try, $need_handle, $official_sn]
+    public function notify($params): array
+    {
+        $order_sn = $params['MOrderID'];
+        $ch_trade_no = $params['OrderID'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+
+        if (empty($order_info)) {
+            return [false, false, false, false, ''];
+        }
+
+        $order_id = $order_info['order_id'];
+        $ExtendParam = json_decode($params['ExtendParam'],true);
+        $official_sn = $ExtendParam['OfficialOrderID'] ?? '';
+
+        //充值状态:1=订单正在处理中,2=订单成功,3=订单失败,4=订单状态异常或未知
+        $status = intval($params['State']);
+        if ($status === 2) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no, 'official_sn' => $official_sn]);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif ($status === 3) {
+            Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 158 - 0
helper/refill/api/mh/yushang_normal/RefillPhone.php

@@ -0,0 +1,158 @@
+<?php
+
+namespace refill\yushang_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yushang_normal/config.php');
+
+use mtopcard;
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function add_params(int $phone, int $amount, string $order_sn, int $card_type): array
+    {
+        $oper_getter = function ($card_type)
+        {
+            if($card_type == mtopcard\ChinaMobileCard) {
+                return 'YD';
+            }
+            elseif($card_type == mtopcard\ChinaUnicomCard) {
+                return 'LT';
+            }
+            elseif($card_type == mtopcard\ChinaTelecomCard) {
+                return 'DX';
+            }
+            else {
+                return false;
+            }
+        };
+
+        $operator = $oper_getter($card_type);
+        $sku_code = config::sku_code($card_type,$amount);
+
+        if($operator === false || empty($sku_code)) {
+            return [];
+        }
+
+        $input = [
+            'BuyCount'      => 1,
+            'CallBackUrl'   => config::NOTIFY_URL,
+            'ChargeAccount' => $phone,
+            'CustomerIP'    => '127.0.0.1',
+            'MOrderID'      => $order_sn,
+            'ProductCode'   => $sku_code,
+            'TimesTamp'     => config::time_stamp()
+        ];
+
+        return config::gen_params($input,config::add_keys);
+    }
+
+    //[$state, $errmsg, $neterr]
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $params = $this->add_params($card_no, $amount, $params['order_sn'],$card_type);
+        if(empty($params)) {
+            return [false, '提单参数不符合', false];
+        }
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, [], $net_errno);
+        if (empty($resp)) {
+            return [false, '系统错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', true];
+            } elseif ($resp['Code'] === 999) {    /// 999 收单成功
+                return [true, $resp['OrderID'], false];
+            } else {
+                return [false, $resp['Msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $input = [
+            'TimesTamp' => config::time_stamp(),
+            'MOrderID'  =>$refill_info['order_sn']
+        ];
+        $params = config::gen_params($input,config::query_keys);
+
+        $resp = http_request(config::QUERY_URL, $params , 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误', ''];
+            }
+
+            $code = intval($resp['Code']);
+            if ($code === 999)
+            {
+                $val = $resp['Data'];
+                $status = intval($val['OrderState']);
+                $official_sn = $val['ExtendParam']['OfficialOrderID'] ?? '';
+
+                //充值状态:1=订单正在处理中,2=订单成功,3=订单失败,4=订单状态异常或位置
+                if ($status == 2) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['OrderID'],'official_sn' => $official_sn]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                }
+                elseif ($status == 3) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $val['OrderID']]);
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+                else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+
+                return [true, $order_state, $official_sn];
+            }
+            elseif($code === 10 and (time() - $refill_info['commit_time']) >= 300) {
+                return [true, ORDER_STATE_NOEXIST, ''];
+            }
+            else
+            {
+                return [false, $resp['Msg']];
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $input = [
+            'TimesTamp' => config::time_stamp()
+        ];
+        $params = config::gen_params($input,config::balance_keys);
+
+        $resp = http_request(config::BALANCE_URL, $params , 'POST');
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['Code'] === 999) {
+                return [true, ncPriceFormat($resp['Data'][0]['Balance'])];
+            } else {
+                return [false, $resp['Msg']];
+            }
+        }
+    }
+}

+ 83 - 0
helper/refill/api/mh/yushang_normal/config.php

@@ -0,0 +1,83 @@
+<?php
+
+namespace refill\yushang_normal;
+
+class config
+{
+//    const AppKey = '211394653';
+//    const AppSecret = 'cyQpQKMaGUG186iEZRt1uQ==';
+//    const ORDER_URL = 'http://mbsmemberwebapi.test.onfishes.com/Order/InsertV2';
+//    const QUERY_URL = 'http://mbsmemberwebapi.test.onfishes.com/Order/QueryV2';
+//    const BALANCE_URL = 'http://mbsmemberwebapi.test.onfishes.com/Member/GetAccount';
+//    const NOTIFY_URL = "https://api.mhigh.cn/racc/callback/mh/testcb.php";
+//    const TestProduct = 'PLM100068';
+//    const IS_DEBUG = true;
+
+
+    public const AppKey = '211395563';
+    public const AppSecret = 'MjY0NTU0NmUtNmNhOS00Y2YzLTk5YmUtMjM4MzIyYWE1MmVj';
+    public const ORDER_URL = "http://mbapii.mbs.scyshy.com/Order/InsertV2";
+    public const QUERY_URL = 'http://mbapiq.mbs.scyshy.com/Order/QueryV2';
+    public const BALANCE_URL = 'http://mbapiq.mbs.scyshy.com/Member/GetAccount';
+    public const NOTIFY_URL = BASE_SITE_URL . "/racc/callback/mh/yushang_normal.php";
+
+    public const add_keys = ['AppKey', 'BuyCount', 'CallBackUrl', 'ChargeAccount', 'CustomerIP', 'MOrderID', 'ProductCode', 'TimesTamp', 'AppSecret'];
+    public const query_keys = ['AppKey', 'TimesTamp', 'OrderID', 'MOrderID', 'AppSecret'];
+    public const balance_keys = ['AppKey', 'TimesTamp', 'AppSecret'];
+    public const notify_keys = ['AppKey', 'TimesTamp', 'OrderID', 'MOrderID', 'State', 'AppSecret'];
+    private static $stStoreProducts = [
+        50  => [4 => 'PLM102741', 5 => 'PLM102741', 6 => 'PLM102741'],
+        100 => [4 => 'PLM102681', 5 => 'PLM102681', 6 => 'PLM102681'],
+        200 => [4 => 'PLM102742', 5 => 'PLM102742', 6 => 'PLM102742'],
+        300 => [4 => 'PLM104318', 5 => 'PLM104318', 6 => 'PLM104318'],
+        500 => [4 => 'PLM104319', 5 => 'PLM104319', 6 => 'PLM104319'],
+    ];
+
+    public static function sign($params,$keys): string
+    {
+        $str = '';
+        foreach ($keys as $key)
+        {
+            if($key == 'AppKey') {
+                $str .= config::AppKey;
+            }
+            elseif ($key == 'AppSecret') {
+                $str .= config::AppSecret;
+            }
+            else {
+                $val = $params[$key] ?? '';
+                $str .= $val;
+            }
+        }
+
+        return strtoupper(md5($str));
+    }
+
+    public static function gen_params($params,$keys)
+    {
+        $params['Sign'] =config::sign($params,$keys);
+        $params['AppKey'] = config::AppKey;
+        return $params;
+    }
+
+    //for 测试产品编码
+//    public static function sku_code($card_type, $amount)
+//    {
+//        return config::TestProduct;
+//    }
+
+    public static function sku_code($card_type, $amount)
+    {
+        if (array_key_exists($amount, self::$stStoreProducts)) {
+            if (array_key_exists($card_type, self::$stStoreProducts[$amount])) {
+                return self::$stStoreProducts[$amount][$card_type];
+            }
+        }
+        return false;
+    }
+
+    public static function time_stamp () : int
+    {
+        return intval(microtime(true) * 1000);
+    }
+}

+ 46 - 0
helper/refill/api/mh/yushang_normal/jiekou.txt

@@ -0,0 +1,46 @@
+接口文档地址:
+https://www.showdoc.cc/MbsNewPal?page_id=4432468445781375
+
+【腾讯文档】娱尚-环境联调信息
+https://docs.qq.com/doc/DYlJwQ3R3eHdPc1Fa
+
+
+直充测试:
+测试收单地址:http://mbsmemberwebapi.test.onfishes.com/Order/InsertV2
+AppKey:211394653
+AppSecret:cyQpQKMaGUG186iEZRt1uQ==
+产品编码:PLM100068
+
+## 店铺
+- 账号:yushang
+- 密码:yushang@1123
+
+卡密测试:
+测试收单地址:http://mbsmemberwebapi.test.onfishes.com/Order/InsertSiberianNitrariaFruitV2
+AppKey:211394653
+AppSecret:cyQpQKMaGUG186iEZRt1uQ==
+产品编码:PLM100010
+
+
+测试环境会员管理地址:http://mbsmemberclient.test.onfishes.com
+登陆名:jt 密码:000000
+
+
+
+
+视频会员系统正式环境前台登录地址:
+http://mbsmemberclient.scyshy.com
+视频会员系统正式环境收单地址:
+
+接口地址:
+订单查询地址为:http://mbapiq.mbs.scyshy.com/Order/QueryV2
+余额查询地址为:http://mbapiq.mbs.scyshy.com/Member/GetAccount
+直充产品订单收单地址为:http://mbapii.mbs.scyshy.com/Order/InsertV2
+卡密产品订单收单地址:http://mbapii.mbs.scyshy.com/Order/InsertSiberianNitrariaFruitV2
+发送验证码地址为:http://mboapi.mbs.scyshy.com/mbs/down/jd/verify/code
+短信验证接口地址为:http://mboapi.mbs.scyshy.com/mbs/down/jd/check/code
+
+登陆名称(会员名):bjmeihai
+新用户密码为:882788
+AppKey:211395563
+AppSecret:MjY0NTU0NmUtNmNhOS00Y2YzLTk5YmUtMjM4MzIyYWE1MmVj

+ 8 - 0
helper/refill/policy/chctlex.php

@@ -141,6 +141,8 @@ class chctlex
             $ctls = [];
             foreach ($names as $name)
             {
+                Log::record("channel=$name",Log::DEBUG);
+
                 $key = $pThis->prefix($name,$spec,$card_type,$quality);
                 if(array_key_exists($key,$pThis->mSpeedtable))
                 {
@@ -148,6 +150,7 @@ class chctlex
 
                     $inPrice = $item->price();
                     if ($max_inprice !== false && $inPrice > $max_inprice) {
+                        Log::record("skip channel=$name",Log::DEBUG);
                         continue;
                     } else {
                         $ctls[] = $item;
@@ -157,6 +160,7 @@ class chctlex
             return $ctls;
         };
         $ctl_items = $price_filter($names,$spec,$card_type,$quality);
+        Log::record("ctl_items count=" . count($ctl_items), Log::DEBUG);
 
         $chooser = function ($ctl_items)
         {
@@ -173,6 +177,8 @@ class chctlex
 
         //去掉已经关闭通道
         $usable_items = $chooser($ctl_items);
+        Log::record("usable_items count=" . count($usable_items), Log::DEBUG);
+
 
         //不过载的排在前面
         $ascending = function ($l, $r)
@@ -213,6 +219,8 @@ class chctlex
         }
 
         $result = array_merge($result, $over_loads);
+        Log::record("result=" . implode(',', $result), Log::DEBUG);
+
         return $result;
     }
 

+ 2 - 0
helper/refill/policy/xyz/policy.php

@@ -433,6 +433,8 @@ class policy extends ProviderManager implements IPolicy
                 $names = array_intersect($names, $channels);
             }
 
+            Log::record(implode(',',$names),Log::DEBUG);
+
             $names = $this->mChannelControl->match($names, $spec, $card_type, $quality, $max_inprice);
             if (!empty($names)) {
                 return [$org_quality, $quality];

+ 27 - 0
racc/bridge/gy.php

@@ -0,0 +1,27 @@
+<?php
+/**
+ *   add.php
+ *   stanley-king
+ *   2023/12/16
+ *   PhpStorm
+ *   PHPProject
+ */
+
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
+require_once(BASE_HELPER_PATH . '/rbridge/RBridgeFactory.php');
+
+$params = $_POST;
+Log::record("gy_message:" . json_encode($params), Log::DEBUG);
+
+if (isset($params['request_id']) and isset($params['telephone'])) {
+    [$ret, $message] = rbridge\RBridgeFactory::instance()->add('gy', $params);
+}
+elseif(isset($params['request_id'])) {
+    [$ret, $message] = rbridge\RBridgeFactory::instance()->query('gy', $params);
+}
+else {
+    [$ret, $message] = rbridge\RBridgeFactory::instance()->balance('gy', $params);
+}
+
+echo($message);
+Log::record("return message=$message",Log::DEBUG);

+ 9 - 0
racc/callback/mh/dixin_slow.php

@@ -0,0 +1,9 @@
+<?php
+
+$content = $_SERVER['post_content'];
+Log::record("dixin_slow content=$content",Log::DEBUG);
+
+$input = json_decode($content,true);
+refill\util::push_notify('dixin_slow',$input);
+
+echo ('success');

+ 5 - 0
racc/callback/mh/lifang_normal.php

@@ -0,0 +1,5 @@
+<?php
+$content = $_SERVER['post_content'];
+Log::record("lifang_normal content=$content",Log::DEBUG);
+refill\util::push_notify('lifang_normal',$_POST);
+echo ('success');

+ 3 - 0
racc/callback/mh/suhu_normal.php

@@ -1,4 +1,7 @@
 <?php
 
+$content = $_SERVER['post_content'];
+Log::record("suhu_normal content=$content",Log::DEBUG);
+
 refill\util::push_notify('suhu_normal',$_POST);
 echo ('ok');

+ 3 - 0
racc/callback/mh/suhu_wozhifu.php

@@ -1,4 +1,7 @@
 <?php
 
+$content = $_SERVER['post_content'];
+Log::record("suhu_wozhifu content=$content",Log::DEBUG);
+
 refill\util::push_notify('suhu_wozhifu',$_POST);
 echo ('ok');

+ 21 - 0
racc/callback/mh/testcb.php

@@ -0,0 +1,21 @@
+<?php
+
+//class testcb
+
+$data = json_encode($_POST);
+$sign = $_SERVER['HTTP_SIGN'];
+$addr = $_SERVER['REMOTE_ADDR'];
+$content = $_SERVER['post_content'];
+$xmldata = file_get_contents("php://input");
+$squery = $_SERVER['QUERY_STRING'];
+
+Log::record("request ip:$addr", Log::DEBUG);
+Log::record("signature data :$data", Log::DEBUG);
+Log::record("content data :$content", Log::DEBUG);
+Log::record("query_string data :$squery", Log::DEBUG);
+Log::record("HTTP_SIGN$sign", Log::DEBUG);
+Log::record("XML_DATA:$xmldata", Log::DEBUG);
+
+echo('SUCCESS');
+
+

+ 12 - 0
racc/callback/mh/weisanhuo_normal.php

@@ -0,0 +1,12 @@
+<?php
+$content = $_SERVER['post_content'] ?? [];
+Log::record("weissanhuo_normal content=$content",Log::DEBUG);
+
+
+$input = json_decode($content,true);
+if(!empty($input)) {
+    refill\util::push_notify('weisanhuo_normal',$input);
+    echo ('success');
+} else {
+    echo ('fail');
+}

+ 4 - 0
racc/callback/mh/yushang_normal.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('yushang_normal',$_POST);
+echo json_encode(['Code' => 0]);

+ 1 - 1
racc/config/config.ini.php

@@ -1,4 +1,4 @@
 <?php
 defined('InShopNC') or exit('Access Invalid!');
 
-$config['access_include_dirs'] = ['/callback/lingzh','/callback/mh'];
+$config['access_include_dirs'] = ['/callback/lingzh', '/callback/mh', '/bridge'];

+ 2 - 1
racc/index.php

@@ -8,4 +8,5 @@
 require_once(BASE_PATH . '/config/config.ini.php');
 require_once(BASE_HELPER_PATH . '/errcode.php');
 require_once(BASE_PATH . '/framework/function/function.php');
-require_once(BASE_PATH . '/control/merchant.php');
+require_once(BASE_PATH . '/control/merchant.php');
+require_once(BASE_PATH . '/control/refill.php');

+ 151 - 0
test/TestRBridge.php

@@ -144,4 +144,155 @@ class TestRBridge extends TestCase
         return $sign;
     }
 
+    public function testDetail()
+    {
+        $detail_id_getter = function ($mchid,$mch_order)
+        {
+            $mod_refill = Model('refill_order');
+            $detail = $mod_refill->get_detail($mchid,$mch_order);
+            if(empty($detail)) {
+                return [false, []];
+            }
+            else {
+                return [intval($detail['detail_id']), json_decode($detail['params'], true)];
+            }
+        };
+
+        [$detail_id,$info] = $detail_id_getter(10234,'5a095fd33955c4ef941f04e9307c4845');
+    }
+
+    //gao yang test
+    public function testGyAdd()
+    {
+        $signer = function ($params,$names)
+        {
+            $key = '57ccb90f02ad5d5b099f518f8afb2c19';
+            $body = '';
+            foreach ($names as $name) {
+                $val = $params[$name] ?? '';
+                $body .= $val;
+            }
+            $body .= $key;
+
+            $sign = strtoupper(md5($body));
+            return $sign;
+        };
+
+        $params = [
+            'userid' => 10234,
+            'request_id' => $this->make_sn(),
+            'telephone' => 13911129867,
+            'money' => 50,
+            'callbackurl' => 'https://api.mhigh.cn/racc/callback/testcb.php'
+        ];
+        $names = ['userid','request_id','telephone','money','callbackurl'];
+
+        $sign = $signer($params,$names);
+        $params['sign'] = $sign;
+
+        [$succ,$xml] = rbridge\RBridgeFactory::instance()->add('gy', $params);
+    }
+
+    public function testGyQuery()
+    {
+        $signer = function ($params,$names)
+        {
+            $key = '57ccb90f02ad5d5b099f518f8afb2c19';
+            $body = '';
+            foreach ($names as $name) {
+                $val = $params[$name] ?? '';
+                $body .= $val;
+            }
+            $body .= $key;
+
+            $sign = strtoupper(md5($body));
+            return $sign;
+        };
+
+        $params = [
+            'userid' => 10234,
+            'request_id' => '60871702829743177981',
+        ];
+        $names = ['userid','request_id'];
+
+        $sign = $signer($params,$names);
+        $params['sign'] = $sign;
+
+        $ret = rbridge\RBridgeFactory::instance()->query('gy', $params);
+    }
+
+    public function testGyBalance()
+    {
+        $signer = function ($params,$names)
+        {
+            $key = '57ccb90f02ad5d5b099f518f8afb2c19';
+            $body = '';
+            foreach ($names as $name) {
+                $val = $params[$name] ?? '';
+                $body .= $val;
+            }
+            $body .= $key;
+
+            $sign = strtoupper(md5($body));
+            return $sign;
+        };
+
+        $params = [
+            'userid' => 10234
+        ];
+        $names = ['userid'];
+
+        $sign = $signer($params,$names);
+        $params['sign'] = $sign;
+
+        $ret = rbridge\RBridgeFactory::instance()->balance('gy', $params);
+    }
+
+
+    public function testXML()
+    {
+        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><root></root>');
+        $ar2xml = function ($obj, $array) use(&$ar2xml)
+        {
+            foreach ($array as $k => $v)
+            {
+                if(is_numeric($k))
+                    $k = 'item' . $k;
+                if(is_array($v)){
+                    $node = $obj->addChild($k);
+                    $ar2xml($node, $v);
+                }else{
+                    $obj->addChild($k, htmlspecialchars($v));
+                }
+            }
+        };
+
+        $params = [
+            'userid' => 10234,
+            'request_id' => $this->make_sn(),
+            'telephone' => 13911129867,
+            'money' => 50,
+            'callbackurl' => 'https://api.mhigh.cn/racc/callback/testcb.php'
+        ];
+
+        self::arrayToXml($xml,$params);
+
+        $val = $xml->asXML();
+
+    }
+
+    public static function arrayToXml($obj, $array)
+    {
+        foreach ($array as $k => $v)
+        {
+            if (is_numeric($k))
+                $k = 'item' . $k;
+            if (is_array($v)) {
+                $node = $obj->addChild($k);
+                arrayToXml($node, $v);
+            } else {
+                $obj->addChild($k, htmlspecialchars($v));
+            }
+        }
+    }
 }

+ 68 - 12
test/mh/TestRefill.php

@@ -40,12 +40,11 @@ class TestRefill extends TestCase
         $provider->verify($content);
         $provider->notify($content);
     }
-
     public function testSuhu()
     {
         $provider = $this->getProvider('suhu_normal');
         $order_sn = $this->make_sn();
-        $resp = $provider->add(13911129867, 5, 30, ['order_sn' => $order_sn, 'regin_no' => 1]);
+        $resp = $provider->add(13167599238, 5, 100, ['order_sn' => $order_sn, 'regin_no' => 1]);
         $resp = $provider->query(['order_sn' => $order_sn]);
         $resp = $provider->balance();
     }
@@ -60,21 +59,73 @@ class TestRefill extends TestCase
 
     public function testSuhuWozhifu()
     {
-//        $provider = $this->getProvider('suhu_wozhifu');
-//        $order_sn = $this->make_sn();
-//        $resp = $provider->add(13911129867, 5, 30, ['order_sn' => $order_sn, 'regin_no' => 1]);
-//        $resp = $provider->query(['order_sn' => $order_sn]);
-//        $resp = $provider->balance();
+        $provider = $this->getProvider('suhu_wozhifu');
+        $order_sn = $this->make_sn();
+        $resp = $provider->add(13911129867, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
+        $resp = $provider->query(['order_sn' => $order_sn]);
+        $resp = $provider->balance();
     }
     public function testSuhuWozhifuCB()
     {
-//        $content = '{"order_no":"OD40636475187360296","merchant_no":"0059570753462761433314","recharge_account":"13911129867","recharge_status":4,"complete_time":"2023-11-16 15:12:42","settlement_price":"47.30","total_amount":"50.00","actual_amount":"0.00","create_time":"2023-11-16 15:12:41","custom_tag":"123456","sign":"49b7f9f32a34f1c83dcb0d976f28d061"}';
-//        $provider = $this->getProvider('suhu_wozhifu','RefillCallBack');
-//        $content = json_decode($content,true);
-//        $provider->verify($content);
-//        $provider->notify($content);
+        $content = '{"order_no":"OD40636475187360296","merchant_no":"0059570753462761433314","recharge_account":"13911129867","recharge_status":4,"complete_time":"2023-11-16 15:12:42","settlement_price":"47.30","total_amount":"50.00","actual_amount":"0.00","create_time":"2023-11-16 15:12:41","custom_tag":"123456","sign":"49b7f9f32a34f1c83dcb0d976f28d061"}';
+        $provider = $this->getProvider('suhu_wozhifu','RefillCallBack');
+        $content = json_decode($content,true);
+        $provider->verify($content);
+        $provider->notify($content);
+    }
+
+    public function testYushang()
+    {
+        $provider = $this->getProvider('yushang_normal');
+        $order_sn = $this->make_sn();
+        $resp = $provider->add(13911129867, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
+        $resp = $provider->query(['order_sn' => $order_sn]);
+        $resp = $provider->balance();
+    }
+    public function testYushangCB()
+    {
+        $_POST= '{"ChargeAccount":"13911129867","ProductCode":"PLM100068","BuyCount":"1","MOrderID":"85661700722959070814","OrderID":"231123150239738000","State":"2","AppKey":"211394653","TimesTamp":"1700723025672","Sign":"86004EF5A40B8D8B30D7454246763DF4","ExtendParam":"{\"OfficialDes\":\"\u624b\u652f\u6e20\u9053\",\"OfficialOrderID\":\"OfficialOrderID001\",\"SellPrice\":16000}","ChargeMsg":""}';
+        $content = json_decode($_POST,true);
+        $provider = $this->getProvider('yushang_normal','RefillCallBack');
+        $provider->verify($content);
+        $provider->notify($content);
+    }
+
+    public function testLifang()
+    {
+        $provider = $this->getProvider('lifang_normal');
+        $order_sn = $this->make_sn();
+       // $resp = $provider->add(15652921127, 5, 30, ['order_sn' => $order_sn, 'regin_no' => 1]);
+       // $resp = $provider->query(['order_sn' => $order_sn]);
+       // $resp = $provider->balance();
     }
 
+    public function testLifangCB()
+    {
+        $_POST='{"orderId":"S23112800025098","outOrderId":"60201701159853851187","requestDate":"20231128164156","sign":"E172D40D040D26C8226E237ACED8C861","accessToken":"beaf87f8-7c6b-cb8a-98b8-53c207ca9aef","status":"1"}';
+        $content = json_decode($_POST,true);
+        $provider = $this->getProvider('lifang_normal','RefillCallBack');
+        $provider->verify($content);
+        $provider->notify($content);
+    }
+
+    public function testWensanhuo()
+    {
+        $provider = $this->getProvider('weisanhuo_normal');
+        $order_sn = $this->make_sn();
+        //$resp = $provider->add(18855414101, 4, 30, ['order_sn' => $order_sn, 'regin_no' => 1]);//30为测试产品
+        //$resp = $provider->query(['order_sn' => $order_sn]);
+        $resp = $provider->balance();
+    }
+
+    public function testWensanhuoCB()
+    {
+        $_POST='{"orderId":"S23112800025098","outOrderId":"60201701159853851187","requestDate":"20231128164156","sign":"E172D40D040D26C8226E237ACED8C861","accessToken":"beaf87f8-7c6b-cb8a-98b8-53c207ca9aef","status":"1"}';
+        $content = json_decode($_POST,true);
+        $provider = $this->getProvider('lifang_normal','RefillCallBack');
+        $provider->verify($content);
+        $provider->notify($content);
+    }
 
     public function testJson()
     {
@@ -110,6 +161,11 @@ class TestRefill extends TestCase
             . sprintf('%06d', (float)microtime() * 1000000);
     }
 
+    public function testMillsec()
+    {
+        $microtime = intval(microtime(true) * 1000);
+    }
+
     public function testweisanhuo()
     {
         $provider = $this->getProvider('weisanhuo');