TradeOrderShippingInfo.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace addons\shopro\service\order\shippingInfo;
  3. class TradeOrderShippingInfo extends Base
  4. {
  5. /**
  6. * 获取整个订单的 shippingParams 参数
  7. *
  8. * @return array
  9. */
  10. public function getShippingParams()
  11. {
  12. $wechatPay = $this->getWechatPay('trade_order');
  13. $uploadParams = [];
  14. if ($this->order->type == 'recharge') {
  15. // 充值订单
  16. $virtualParams = $this->getVirtualShippingParams();
  17. $uploadParams[] = $virtualParams;
  18. }
  19. // 处理微信相关参数
  20. return $this->setWechatParams($uploadParams, $wechatPay);
  21. }
  22. /**
  23. * 获取订单中虚拟商品的 shippingParams
  24. *
  25. * @return array
  26. */
  27. private function getVirtualShippingParams()
  28. {
  29. $item_desc = '用户充值订单';
  30. $shippingList[] = [
  31. 'item_desc' => $item_desc,
  32. ];
  33. // 发货
  34. return [
  35. 'logistics_type' => $this->getLogisticsType('autosend'),
  36. 'shipping_list' => $shippingList,
  37. ];
  38. }
  39. }