OrderController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\erp;
  12. use app\Request;
  13. use app\services\erp\OrderServices;
  14. use think\facade\Log;
  15. class OrderController
  16. {
  17. protected $services;
  18. /**
  19. * OrderController constructor.
  20. * @param OrderServices $services
  21. */
  22. public function __construct(OrderServices $services)
  23. {
  24. $this->services = $services;
  25. }
  26. /**
  27. * 订单发货回调
  28. * @return mixed
  29. */
  30. public function deliverCallback(Request $request)
  31. {
  32. $data = $request->postMore([
  33. ['type', 1],
  34. ['logistics_company', ''], //快递公司名称
  35. ['l_id', ''], // 快递单号
  36. ['lc_id', ''], // 快递公司编码
  37. ['o_id', ''], // 内部订单号
  38. ['so_id', ''], // 线上单号
  39. ['send_date', ''], // 发货时间
  40. ['items', []], // 商品列表
  41. ]);
  42. Log::info(['data' => json_encode($data), 'type' => 'deliverCallback']);
  43. if (sys_config('erp_open')) {
  44. $this->services->deliverCallback($data);
  45. }
  46. return app('json')->success();
  47. }
  48. /**
  49. * 订单取消回调
  50. * @return mixed
  51. */
  52. public function cancelCallback(Request $request)
  53. {
  54. $data = $request->postMore([
  55. ['so_id', 0],
  56. ['remark', ''],
  57. ]);
  58. Log::info(['data' => json_encode($data), 'type' => 'cancelCallback']);
  59. if (sys_config('erp_open')) {
  60. $this->services->cancelCallback($data);
  61. }
  62. return app('json')->success();
  63. }
  64. /**
  65. * 售后收货回调
  66. * @return mixed
  67. */
  68. public function receiveCallback(Request $request)
  69. {
  70. $data = $request->postMore([
  71. ['so_id', 0],
  72. ['shop_id', 0], // 店铺ID
  73. ['action_name', ''], // 操作类型
  74. ['as_id', 0], // 售后单号
  75. ['o_id', 0], // 内部单号
  76. ['outer_as_id', ''], // 外部售后单号
  77. ['remark', ''],
  78. ['items', []], // 商品列表
  79. ]);
  80. Log::info(['data' => json_encode($data), 'type' => 'receiveCallback']);
  81. if (sys_config('erp_open')) {
  82. $this->services->receivedCallback($data, 1, true);
  83. }
  84. return app('json')->success();
  85. }
  86. }