StoreOrder.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\openapi\store;
  12. use app\common\repositories\delivery\DeliveryOrderRepository;
  13. use app\common\repositories\openapi\OpenAuthRepository;
  14. use app\common\repositories\store\order\StoreOrderCreateRepository;
  15. use app\common\repositories\store\order\StoreOrderReceiptRepository;
  16. use app\validate\api\UserReceiptValidate;
  17. use crmeb\basic\BaseController;
  18. use app\common\repositories\store\order\StoreCartRepository;
  19. use app\common\repositories\store\order\StoreGroupOrderRepository;
  20. use app\common\repositories\store\order\StoreOrderRepository;
  21. use crmeb\exceptions\AuthException;
  22. use crmeb\services\ExpressService;
  23. use crmeb\services\LockService;
  24. use think\App;
  25. use think\exception\ValidateException;
  26. use think\facade\Log;
  27. /**
  28. * Class StoreOrder
  29. * @package app\controller\api\store\order
  30. * @author xaboy
  31. * @day 2020/6/10
  32. */
  33. class StoreOrder extends BaseController
  34. {
  35. /**
  36. * @var StoreOrderRepository
  37. */
  38. protected $repository;
  39. protected $merId;
  40. /**
  41. * 构造函数
  42. *
  43. * @param App $app 应用实例
  44. * @param StoreOrderRepository $repository 订单仓库实例
  45. */
  46. public function __construct(App $app, StoreOrderRepository $repository)
  47. {
  48. // 调用父类构造函数
  49. parent::__construct($app);
  50. // 初始化订单仓库实例
  51. $this->repository = $repository;
  52. // 获取当前请求的开放商家ID
  53. $this->merId = $this->request->openMerId();
  54. // 判断当前请求的开放路由是否包含订单管理权限
  55. if (!in_array(OpenAuthRepository::AUTH_TYPE_ORDER, $this->request->openRoule())) throw new AuthException('无此权限');
  56. }
  57. /**
  58. * 订单列表
  59. * @return \think\response\Json
  60. * @author Qinii
  61. * @day 2023/7/24
  62. */
  63. public function lst()
  64. {
  65. /**
  66. * status 订单状态:0 全部 1 未支付 2 待发货 3 待收货 4 待评价 5 交易完成 6 已退款 7 待核销
  67. * date 时间筛选:2023/07/25 - 2023/07/31
  68. * order_sn 订单编号
  69. * group_order_sn 主订单编号
  70. * username 用户昵称
  71. * order_type 订单类型 0 普通订单 1 自提订单 2 虚拟订单 3 卡密订单
  72. * order_id 订单ID
  73. * activity_type 活动类型
  74. * store_name 商品名称模糊搜索
  75. * filter_product 商品类型搜索 1 实物商品、2虚拟商品、3卡密商品
  76. * filter_delivery 按发货方式:1快递订单、2配送订单、4核销订单、3虚拟发货、6自动发货
  77. */
  78. [$page, $limit] = $this->getPage();
  79. $where = $this->request->params(['status', 'date', 'order_sn', 'username', 'order_type', 'keywords', 'order_id', 'activity_type', 'group_order_sn', 'store_name','filter_delivery','filter_product']);
  80. $where['mer_id'] = $this->merId;
  81. $pay_type = $this->request->param('pay_type','');
  82. if ($pay_type != '') $where['pay_type'] = $this->repository::PAY_TYPE_FILTEER[$pay_type];
  83. return app('json')->success($this->repository->merchantGetList($where, $page, $limit));
  84. }
  85. /**
  86. * 订单详情
  87. * @param $id
  88. * @return \think\response\Json
  89. * @author Qinii
  90. * @day 2023/7/24
  91. */
  92. public function detail($id)
  93. {
  94. $data = $this->repository->getOne($id, $this->merId);
  95. if (!$data) return app('json')->fail('数据不存在');
  96. return app('json')->success($data);
  97. }
  98. }