TestRemote.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. define('APP_ID', 'test');
  4. define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
  5. require_once(BASE_ROOT_PATH . '/global.php');
  6. require_once(BASE_CORE_PATH . '/lrlz.php');
  7. require_once(BASE_ROOT_PATH . '/fooder.php');
  8. require_once(BASE_HELPER_PATH . '/refill/ops/third_pcode.php');
  9. use refill\third_pcode;
  10. class TestRemote extends TestCase
  11. {
  12. public static function setUpBeforeClass(): void
  13. {
  14. Base::run_util();
  15. include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
  16. }
  17. public function testMerchants()
  18. {
  19. $mod_merchant = Model('merchant');
  20. $items = $mod_merchant->table('merchant')
  21. ->field('mchid,name,company_name')
  22. ->where(['merchant_state' => 1])->limit(0,1000)->select();
  23. $result = [];
  24. foreach ($items as $item)
  25. {
  26. $mchid = $item['mchid'];
  27. $name = $item['company_name'];
  28. $result[$mchid] = $name;
  29. }
  30. $x = $result;
  31. }
  32. public function testProviders()
  33. {
  34. $items = Model('')->table('refill_provider,store')
  35. ->field('refill_provider.*,store.store_name')
  36. ->join('inner')
  37. ->on('store.store_id=refill_provider.store_id')
  38. ->where(['opened' => 1])
  39. ->limit(1000)
  40. ->select();
  41. $result = [];
  42. foreach ($items as $item)
  43. {
  44. // $data = [];
  45. // $data['channel_name'] = $item['name'];
  46. // $data['store_name'] = $item['store_name'];
  47. // $data['provider_id'] = $item['provider_id'];
  48. // $data['store_id'] = $item['store_id'];
  49. $store_id = $item['store_id'];
  50. $store_name = $item['store_name'];
  51. $result[$store_id] = $store_name;
  52. }
  53. $x = $result;
  54. }
  55. public function testProduce()
  56. {
  57. $node = [
  58. 'mch_id' => 1092, 'mch_price' => 10000, 'plat_code' => 'YZBIG20230731',
  59. 'store_id' => 151, 'store_price' => 9900, 'store_code' => 'YLBIG20230731',
  60. 'product_name' => '大面额一万元', 'product_amount' => 10000
  61. ];
  62. try {
  63. $pcoder = new third_pcode($node);
  64. $pcoder->produce();
  65. }
  66. catch (Exception $ex) {
  67. Log::record($ex->getMessage(),Log::ERR);
  68. }
  69. }
  70. }