OrderShipService.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\common\Service\Order;
  3. use app\common\model\Shipper as ShipperModel;
  4. use app\common\model\OrderExpress as OrderExpressModel;
  5. class OrderShipService
  6. {
  7. /**
  8. * 获取快递公司列表
  9. * @return bool|string|\PDOStatement|\think\Collection
  10. */
  11. public static function getExpressCompany(){
  12. $list = (new ShipperModel())->order('id desc')->select();
  13. return $list;
  14. }
  15. /**
  16. * Summary of getExpressById
  17. * @param mixed $expressId
  18. * @return array|bool|string|\PDOStatement|\think\Model
  19. */
  20. public static function getExpressById($expressId = 0){
  21. $express = (new ShipperModel())->where('id', $expressId)->find();
  22. return $express;
  23. }
  24. /**
  25. * 创建订单快递记录
  26. * @param int $orderId 订单ID
  27. * @param int $userId 用户ID
  28. * @param string $expressName 快递公司名称
  29. * @param string $expressCode 快递公司代码
  30. * @param string $expressNo 快递单号
  31. * @param string $method 发货方式
  32. * @param string|null $driver 快递驱动
  33. * @param array $ext 扩展信息
  34. * @param array $expressImage 快递图片
  35. * @return object 快递记录对象
  36. */
  37. public static function createOrderExpress($orderId = 0, $userId = 0, $expressName ="", $expressCode = "", $expressNo = "", $method = 'input', $driver = null, $ext = [], $expressImage = [] ){
  38. $orderExpress = OrderExpressModel::create([
  39. 'user_id' => $userId,
  40. 'order_id' => $orderId,
  41. 'express_name' => $expressName,
  42. 'express_code' => $expressCode,
  43. 'express_no' => $expressNo,
  44. 'express_image' => $expressImage,
  45. 'method' => $method,
  46. 'driver' => $driver,
  47. 'ext' => $ext
  48. ]);
  49. return $orderExpress;
  50. }
  51. }