| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- declare(strict_types=1);
- namespace SixShop\Lakala\Service;
- use PHPUnit\Framework\Attributes\Test;
- use PHPUnit\Framework\TestCase;
- use SixShop\Lakala\Dto\LocationInfo;
- use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaAccBusiFields;
- use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaDetail;
- use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaGoodsDetail;
- use SixShop\Payment\Enum\NumberBizEnum;
- class TransactionServiceTest extends TestCase
- {
- private TransactionService $transactionService;
- protected function setUp(): void
- {
- $this->transactionService = app(TransactionService::class);
- }
- #[Test]
- public function preOrder()
- {
- $totalAmount = 500;
- // 微信主扫场景 - 账户端业务信息
- $accBusiFields = new TradePreorderWechaAccBusiFields();
- $accBusiFields->setTimeoutExpress(15);
- $accBusiFields->setSubAppid('wx1308d811d01639eb');
- $accBusiFields->setUserId('oPuRO15wmxv3AwRyEznRfuDLehrk');
- $detail = new TradePreorderWechaDetail();
- $detail->setCostPrice($totalAmount);
- $detail->setReceiptId('');
- $goodsDetail = new TradePreorderWechaGoodsDetail();
- $goodsDetail->setGoodsId('3452234');
- $goodsDetail->setWxpayGoodsId('');
- $goodsDetail->setGoodsName('纯礼 脚臭粉*2+沐浴皂液*1+氨基酸洁面液*1+羊奶皂*6');
- $goodsDetail->setQuantity(1);
- $goodsDetail->setPrice($totalAmount);
- $detail->setGoodsDetail([$goodsDetail]);
- // $accBusiFields->setDetail($detail);
- $response = $this->transactionService->preOrder(
- outTradeNo: generate_number(NumberBizEnum::ORDER_PAY),
- totalAmount: $totalAmount,
- locationInfo: new LocationInfo(requestIP: '183.214.109.50'),
- subject: '测试订单',
- settleType: "1",
- remark: "纯礼 脚臭粉*2+沐浴皂液*1+氨基酸洁面液*1+羊奶皂*6",
- accBusiFields: $accBusiFields,
- );
- dump($response);
- }
- #[Test]
- public function queryTrade()
- {
- $response = $this->transactionService->queryTrade(
- tradeNo: '20251201110113130266241823831000', outTradeNo: '20251119161738023242',
- );
- dump($response);
- }
- #[Test]
- public function refund()
- {
- $response = $this->transactionService->refund(
- refundTradeNo: '20251119215114025260',
- refundAmount: .01,
- locationInfo: new LocationInfo(requestIP: '183.214.109.50'),
- originOutTradeNo: '20251119215114025260',
- refundReason: '测试退款',
- );
- dump($response);
- }
- }
|