|
|
@@ -3,9 +3,9 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace SixShop\WechatPay;
|
|
|
|
|
|
+use EasyWeChat\Kernel\HttpClient\Response;
|
|
|
use GuzzleHttp\Exception\ClientException;
|
|
|
use SixShop\Core\Exception\NotFoundException;
|
|
|
-use SixShop\Core\Helper;
|
|
|
use SixShop\Payment\Contracts\PaymentNotifyResult;
|
|
|
use SixShop\Payment\Contracts\PaymentProviderInterface;
|
|
|
use SixShop\Payment\Contracts\PaymentQueryResult;
|
|
|
@@ -21,6 +21,7 @@ use SixShop\Payment\Enum\RefundStatusEnum;
|
|
|
use SixShop\Payment\Event\PaymentSuccessEvent;
|
|
|
use SixShop\Payment\Event\RefundSuccessEvent;
|
|
|
use SixShop\Wechat\Facade\WechatUser;
|
|
|
+use SixShop\Wechat\Service\MiniApp;
|
|
|
use SixShop\WechatPay\Job\QueryRefundJob;
|
|
|
use SixShop\WechatPay\Trait\ApiTrait;
|
|
|
use SixShop\WechatPay\Trait\PaymentParamsTrait;
|
|
|
@@ -36,7 +37,8 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
|
|
|
public function __construct(
|
|
|
private readonly ExtensionPaymentEntity $extensionPaymentEntity,
|
|
|
- private readonly ExtensionRefundEntity $extensionRefundEntity,
|
|
|
+ private readonly ExtensionRefundEntity $extensionRefundEntity,
|
|
|
+ private readonly MiniApp $miniApp,
|
|
|
)
|
|
|
{
|
|
|
}
|
|
|
@@ -170,12 +172,12 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
$refund->refund_result = $result;
|
|
|
if ($result->status === 'SUCCESS') {
|
|
|
$refund->status = RefundStatusEnum::SUCCESS;
|
|
|
- $refund->status_desc = '成功退款到'.$result->user_received_account;
|
|
|
+ $refund->status_desc = '成功退款到' . $result->user_received_account;
|
|
|
$refund->success_time = strtotime($result->success_time);
|
|
|
Event::trigger(new RefundSuccessEvent(
|
|
|
$refund->model(),
|
|
|
$refund->payment,
|
|
|
- new PaymentRefundRequest($refund->amount,$refund->reason, $refund->refund_param))
|
|
|
+ new PaymentRefundRequest($refund->amount, $refund->reason, $refund->refund_param))
|
|
|
);
|
|
|
} else if ($result->status === 'PROCESSING') {
|
|
|
QueryRefundJob::dispatch($refund->id)->delay(10);
|
|
|
@@ -185,4 +187,21 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
|
|
|
return new PaymentRefundResult($refund->model());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单发货
|
|
|
+ *
|
|
|
+ * @see https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent2/API/delivery/send.html
|
|
|
+ */
|
|
|
+ public function deliverySend(int $orderID, array $deliveryList, int $finishAll = 1): Response
|
|
|
+ {
|
|
|
+ $order = $this->orderEntity->find($orderID);
|
|
|
+ return $this->miniApp->getClient()->postJson('/shop/delivery/send', [
|
|
|
+ 'out_order_id' => $order->out_trade_no,
|
|
|
+ 'openid' => WechatUser::openid($order->user_id),
|
|
|
+ 'finish_all_delivery' => $finishAll,
|
|
|
+ 'delivery_list' => $deliveryList,
|
|
|
+ 'ship_done_time' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|