|
|
@@ -3,7 +3,6 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace SixShop\WechatPay;
|
|
|
|
|
|
-use EasyWeChat\Kernel\HttpClient\Response;
|
|
|
use GuzzleHttp\Exception\ClientException;
|
|
|
use SixShop\Core\Exception\NotFoundException;
|
|
|
use SixShop\Payment\Contracts\PaymentNotifyResult;
|
|
|
@@ -25,14 +24,18 @@ use SixShop\Wechat\Service\MiniApp;
|
|
|
use SixShop\WechatPay\Job\QueryRefundJob;
|
|
|
use SixShop\WechatPay\Trait\ApiTrait;
|
|
|
use SixShop\WechatPay\Trait\PaymentParamsTrait;
|
|
|
+use SixShop\WechatPay\Trait\UploadShippingInfoTrait;
|
|
|
use think\facade\Db;
|
|
|
use think\facade\Event;
|
|
|
use function SixShop\Core\throw_logic_exception;
|
|
|
|
|
|
class PaymentProvider implements PaymentProviderInterface
|
|
|
{
|
|
|
- const string PAYMENT_TYPE = 'wechatpay';
|
|
|
+ private const string PAYMENT_TYPE = 'wechatpay';
|
|
|
use ApiTrait;
|
|
|
+ use UploadShippingInfoTrait {
|
|
|
+ uploadShippingInfo as private uploadShippingInfoAPI;
|
|
|
+ }
|
|
|
use PaymentParamsTrait;
|
|
|
|
|
|
public function __construct(
|
|
|
@@ -189,19 +192,29 @@ class PaymentProvider implements PaymentProviderInterface
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 订单发货
|
|
|
- *
|
|
|
- * @see https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/minishopopencomponent2/API/delivery/send.html
|
|
|
+ * 发货信息录入
|
|
|
+ * @param int $orderID 订单ID
|
|
|
+ * @param string $itemDesc 商品描述
|
|
|
+ * @param string $trackingNo 运单号
|
|
|
+ * @param string $expressCompany 快递公司ID
|
|
|
+ * @param string $receiverContact 收件人手机号码
|
|
|
*/
|
|
|
- public function deliverySend(int $orderID, array $deliveryList, int $finishAll = 1): Response
|
|
|
+ public function uploadShippingInfo(
|
|
|
+ int $orderID,
|
|
|
+ string $itemDesc,
|
|
|
+ string $trackingNo,
|
|
|
+ string $expressCompany,
|
|
|
+ string $receiverContact,
|
|
|
+ bool $failException = true
|
|
|
+ ): array
|
|
|
{
|
|
|
- $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')
|
|
|
- ]);
|
|
|
+ $order = $this->extensionPaymentEntity->where([
|
|
|
+ 'order_id' => $orderID,
|
|
|
+ 'status' => PaymentStatusEnum::SUCCESS
|
|
|
+ ])->findOrEmpty();
|
|
|
+ if ($order->isEmpty()) {
|
|
|
+ throw new \RuntimeException('支付订单不存在或未支付');
|
|
|
+ }
|
|
|
+ return $this->uploadShippingInfoAPI($order->out_trade_no, $order->user_id, $itemDesc, $trackingNo, $expressCompany, $receiverContact, $failException);
|
|
|
}
|
|
|
}
|