TransactionServiceTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace SixShop\Lakala\Service;
  3. use PHPUnit\Framework\TestCase;
  4. use SixShop\Lakala\Dto\LocationInfo;
  5. use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaAccBusiFields;
  6. use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaDetail;
  7. use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaGoodsDetail;
  8. use SixShop\Payment\Enum\NumberBizEnum;
  9. class TransactionServiceTest extends TestCase
  10. {
  11. private TransactionService $transactionService;
  12. protected function setUp(): void
  13. {
  14. $this->transactionService = app(TransactionService::class);
  15. }
  16. public function testPreOrder()
  17. {
  18. $totalAmount = 500;
  19. // 微信主扫场景 - 账户端业务信息
  20. $accBusiFields = new TradePreorderWechaAccBusiFields();
  21. $accBusiFields->setTimeoutExpress(15);
  22. $accBusiFields->setSubAppid('wx1308d811d01639eb');
  23. $accBusiFields->setUserId('oPuRO15wmxv3AwRyEznRfuDLehrk');
  24. $detail = new TradePreorderWechaDetail();
  25. $detail->setCostPrice($totalAmount);
  26. $detail->setReceiptId('');
  27. $goodsDetail = new TradePreorderWechaGoodsDetail();
  28. $goodsDetail->setGoodsId('3452234');
  29. $goodsDetail->setWxpayGoodsId('');
  30. $goodsDetail->setGoodsName('纯礼 脚臭粉*2+沐浴皂液*1+氨基酸洁面液*1+羊奶皂*6');
  31. $goodsDetail->setQuantity(1);
  32. $goodsDetail->setPrice($totalAmount);
  33. $detail->setGoodsDetail([$goodsDetail]);
  34. // $accBusiFields->setDetail($detail);
  35. $response = $this->transactionService->preOrder(
  36. outTradeNo: generate_number(NumberBizEnum::ORDER_PAY),
  37. totalAmount: $totalAmount,
  38. locationInfo: new LocationInfo(requestIP: '183.214.109.50'),
  39. subject: '测试订单',
  40. settleType: "1",
  41. remark: "纯礼 脚臭粉*2+沐浴皂液*1+氨基酸洁面液*1+羊奶皂*6",
  42. accBusiFields: $accBusiFields,
  43. );
  44. dump($response);
  45. }
  46. }