PHP code example of tourze / wechat-mini-program-delivery-return-bundle

1. Go to this page and download the library: Download tourze/wechat-mini-program-delivery-return-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tourze / wechat-mini-program-delivery-return-bundle example snippets




return [
    // ... other bundles
    WechatMiniProgramDeliveryReturnBundle\WechatMiniProgramDeliveryReturnBundle::class => ['all' => true],
];



use WechatMiniProgramDeliveryReturnBundle\Entity\DeliveryReturnOrder;
use WechatMiniProgramDeliveryReturnBundle\Service\DeliveryReturnService;

// Create a new return order
$returnOrder = new DeliveryReturnOrder();
$returnOrder->setShopOrderId('ORDER_123456');
$returnOrder->setOpenId('user_openid');
$returnOrder->setOrderPrice(9999); // Price in cents
$returnOrder->setBizAddress([
    'province' => 'Guangdong',
    'city' => 'Shenzhen',
    'area' => 'Nanshan',
    'street' => 'Tencent Building'
]);
$returnOrder->setUserAddress([
    'province' => 'Beijing',
    'city' => 'Beijing',
    'area' => 'Chaoyang',
    'street' => 'User Address'
]);

// Persist the order
$entityManager->persist($returnOrder);
$entityManager->flush();



use WechatMiniProgramDeliveryReturnBundle\Service\DeliveryReturnService;

// Inject the service
$deliveryReturnService = $container->get(DeliveryReturnService::class);

// Sync a specific return order
$deliveryReturnService->syncReturnOrder($returnOrder);



use WechatMiniProgramDeliveryReturnBundle\Event\ReturnOrderSyncedEvent;

// Listen for return order sync events
$eventDispatcher->addListener(ReturnOrderSyncedEvent::class, function (ReturnOrderSyncedEvent $event) {
    $returnOrder = $event->getReturnOrder();
    // Handle the synchronized return order
});



use WechatMiniProgramDeliveryReturnBundle\Repository\DeliveryReturnOrderRepository;

// Get return orders by status
$repository = $entityManager->getRepository(DeliveryReturnOrder::class);
$pendingOrders = $repository->findByStatus(DeliveryReturnStatus::Waiting);

// Get return orders within date range
$recentOrders = $repository->findRecentOrders(15); // Last 15 days
bash
php bin/console wechat-delivery-return:sync-single-return-order ORDER_123456
bash
php bin/console wechat-delivery-return:sync-valid-return-orders