TestThirdRefill.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_CORE_PATH . '/framework/function/http.php');
  9. require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
  10. require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
  11. class TestThirdRefill extends TestCase
  12. {
  13. public static function setUpBeforeClass() : void
  14. {
  15. Base::run_util();
  16. }
  17. public function testProviderPrice()
  18. {
  19. $thrid_refill = Model('thrid_refill');
  20. $product = $thrid_refill->getProviderProduct(34,1000,'LZPLM100591');
  21. }
  22. public function testMerchantPrice()
  23. {
  24. $thrid_refill = Model('thrid_refill');
  25. $price = $thrid_refill->getMerchantPrice(1,'LZ100465');
  26. }
  27. public function testSctongqian()
  28. {
  29. // $provider = new refill\sctongqian\RefillPhone([]);
  30. // $resp = $providers->CardOrderAdd(18500608333, 5, 50, ['order_sn' => $this->make_sn(), 'product_code' => 'PLM100024']);
  31. // $resp = $providers->query(['order_sn' => '84471620782999495754']);
  32. $data = '{"AppKey":"211394658","TimesTamp":"1620811809019","MOrderID":"84471620782999495754","OrderID":"210512093007747001","State":"2","ChargeAccount":"","Version":"1.0","BuyCount":"1","Attach":"","CardInfo":"HaDGHP8EECrqLl+Jlo1vqGP4Uws4dm9fd1msGnY3FBAPOQuvXcK9bd7Ffg5NKpkXLPH46\/dPGxM\/XR7UOXb4znxs9+7JOlCbw+AqdDJ2cxkzc\/euqHpc8VszvoUD6JpE1bgCaL0DdfCpcYhSzFOND7MnN+WIl+P\/jOn0j8k9I4Lfa2\/Y3\/V3TjKfc4CSnNTU0m+g8cGQ6AGJfSkNDbEg+RlcqW98nLWl\/+YO2wEnkzaMX2B966tjwuPIdsGZHntBXaIIJNwnQ4YWPlx8Hx6ms8s7QPYs8FuFDjdiJzlDEdjJyfyRIzsvY0LZYSZ9WWo8yqMtpulTzLrhVVjvxW7Upg==","Sign":"EEE6F112A14B38EF2BCA6BE37F030266"}';
  33. $params = json_decode($data, true);
  34. refill\RefillFactory::instance()->notify('sctongqian', $params);
  35. }
  36. public function testMerchantGoods()
  37. {
  38. $goods_list = refill\RefillFactory::instance()->goods();
  39. $sorter = function (array $items) {
  40. $ret = [];
  41. foreach ($items as $key => $val) {
  42. sort($val);
  43. $ret[$key] = $val;
  44. }
  45. return $ret;
  46. };
  47. $goods_list = $sorter($goods_list);
  48. $result = [];
  49. $mchid = 10254;
  50. $merchant_goods = rcache('merchant_goods', 'refill-', $mchid);
  51. $goods = $merchant_goods[$mchid] ?? serialize([]);
  52. $goods = unserialize($goods);
  53. foreach ($goods_list as $card_type => $value) {
  54. $key = mtopcard\scard_type($card_type);
  55. if (array_key_exists($key, $goods)) {
  56. $result[$key] = $goods[$key];
  57. } else {
  58. $result[$key] = $value;
  59. }
  60. }
  61. $thrid_refill = Model('thrid_refill');
  62. $pcode = $thrid_refill->getMerchantPcode($mchid);
  63. $result['third'] = $pcode;
  64. }
  65. }