TestRemote.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. }
  16. public function testMerchants()
  17. {
  18. $mod_merchant = Model('merchant');
  19. $items = $mod_merchant->table('merchant')
  20. ->field('mchid,name,company_name')
  21. ->where(['merchant_state' => 1])->limit(0,1000)->select();
  22. $result = [];
  23. foreach ($items as $item)
  24. {
  25. $mchid = $item['mchid'];
  26. $name = $item['company_name'];
  27. $result[$mchid] = $name;
  28. }
  29. $x = $result;
  30. }
  31. public function testProviders()
  32. {
  33. $items = Model('')->table('refill_provider,store')
  34. ->field('refill_provider.*,store.store_name')
  35. ->join('inner')
  36. ->on('store.store_id=refill_provider.store_id')
  37. ->where(['opened' => 1])
  38. ->limit(1000)
  39. ->select();
  40. $result = [];
  41. foreach ($items as $item)
  42. {
  43. // $data = [];
  44. // $data['channel_name'] = $item['name'];
  45. // $data['store_name'] = $item['store_name'];
  46. // $data['provider_id'] = $item['provider_id'];
  47. // $data['store_id'] = $item['store_id'];
  48. $store_id = $item['store_id'];
  49. $store_name = $item['store_name'];
  50. $result[$store_id] = $store_name;
  51. }
  52. $x = $result;
  53. }
  54. public function testProduce()
  55. {
  56. $node = [
  57. 'mch_id' => 1092, 'mch_price' => 10000, 'plat_code' => 'YZBIG20230731',
  58. 'store_id' => 210, 'store_price' => 9900, 'store_code' => 'YLBIG20230731',
  59. 'product_name' => '大面额一万元', 'product_amount' => 10000
  60. ];
  61. try {
  62. $pcoder = new third_pcode($node);
  63. $pcoder->produce();
  64. }
  65. catch (Exception $ex) {
  66. Log::record($ex->getMessage(),Log::ERR);
  67. }
  68. }
  69. }