route.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. use app\http\middleware\AllowOriginMiddleware;
  12. use app\outapi\middleware\AuthTokenMiddleware;
  13. use think\facade\Config;
  14. use think\facade\Route;
  15. use think\Response;
  16. Route::group(function () {
  17. Route::group(function () {
  18. //获取token
  19. Route::post('access_token', 'Login/getToken')->name('getToken')->option(['real_name' => '登录获取token']);
  20. //刷新token
  21. Route::post('refresh_token', 'Login/refreshToken')->name('refreshToken')->option(['real_name' => '刷新token']);
  22. })->option(['mark' => 'common', 'mark_name' => '公共接口']);
  23. Route::group(function () {
  24. Route::group(function () {
  25. //商品分类
  26. Route::get('category/list', 'StoreCategory/index')->option(['real_name' => '分类列表']);
  27. Route::get('category/:id', 'StoreCategory/read')->option(['real_name' => '获取分类']);
  28. Route::post('category', 'StoreCategory/save')->option(['real_name' => '新增分类']);
  29. Route::put('category/:id', 'StoreCategory/update')->option(['real_name' => '修改分类']);
  30. Route::delete('category/:id', 'StoreCategory/delete')->option(['real_name' => '删除分类']);
  31. Route::put('category/set_show/:id/:is_show', 'StoreCategory/set_show')->option(['real_name' => '修改分类状态']);
  32. })->option(['mark' => 'category', 'mark_name' => '商品分类']);
  33. Route::group(function () {
  34. //商品
  35. Route::get('product/list', 'StoreProduct/index')->option(['real_name' => '商品列表']);
  36. Route::post('product', 'StoreProduct/save')->option(['real_name' => '新增商品']);
  37. Route::put('product/:id', 'StoreProduct/update')->option(['real_name' => '修改商品']);
  38. Route::get('product/:id', 'StoreProduct/read')->option(['real_name' => '获取商品']);
  39. Route::put('product/set_show/:id/:is_show', 'StoreProduct/set_show')->option(['real_name' => '修改商品状态']);
  40. Route::put('product/stock/upload', 'StoreProduct/uploadStock')->option(['real_name' => '同步商品库存']);
  41. })->option(['mark' => 'product', 'mark_name' => '商品']);
  42. Route::group(function () {
  43. //订单
  44. Route::get('order/list', 'StoreOrder/lst')->name('StoreOrderList')->option(['real_name' => '订单列表']);
  45. Route::get('order/:order_id', 'StoreOrder/read')->name('StoreOrderInfo')->option(['real_name' => '订单详情']);
  46. Route::put('order/remark/:order_id', 'StoreOrder/remark')->name('StoreOrderRemark')->option(['real_name' => '修改备注信息']);
  47. Route::put('order/receive/:order_id', 'StoreOrder/receive')->name('StoreOrderReceive')->option(['real_name' => '确认收货']);
  48. Route::get('order/express_list', 'StoreOrder/express')->name('StoreOrderExpress')->option(['real_name' => '获取物流公司']);
  49. Route::put('order/delivery/:order_id', 'StoreOrder/delivery')->name('StoreOrderDelivery')->option(['real_name' => '订单发货']);
  50. Route::put('order/distribution/:order_id', 'StoreOrder/updateDistribution')->name('StoreOrderDistribution')->option(['real_name' => '修改配送信息']);
  51. Route::get('order/split_cart_info/:order_id', 'StoreOrder/splitCartInfo')->name('StoreOrderSplitCartInfo')->option(['real_name' => '获取订单可拆分商品列表']);
  52. Route::put('order/split_delivery/:order_id', 'StoreOrder/splitDelivery')->name('StoreOrderSplitDelivery')->option(['real_name' => '拆单发送货']);
  53. Route::put('order/invoice/:order_id', 'StoreOrder/setInvoice')->option(['real_name' => '修改订单发票']);
  54. Route::put('order/invoice_status/:order_id', 'StoreOrder/setInvoiceStatus')->option(['real_name' => '修改订单发票状态']);
  55. })->option(['mark' => 'order', 'mark_name' => '订单']);
  56. Route::group(function () {
  57. //售后订单
  58. Route::get('refund/list', 'RefundOrder/lst')->option(['real_name' => '售后订单列表']);
  59. Route::put('refund/remark/:order_id', 'RefundOrder/remark')->option(['real_name' => '售后订单备注']);
  60. Route::put('refund/:order_id', 'RefundOrder/refundPrice')->option(['real_name' => '售后订单退款']);
  61. Route::put('refund/agree/:order_id', 'RefundOrder/agree')->option(['real_name' => '商家同意退款']);
  62. Route::put('refund/refuse/:order_id', 'RefundOrder/refuse')->option(['real_name' => '商家拒绝退款']);
  63. Route::get('refund/:order_id', 'RefundOrder/read')->option(['real_name' => '售后订单详情']);
  64. })->option(['mark' => 'refund', 'mark_name' => '售后']);
  65. Route::group(function () {
  66. //优惠券
  67. Route::get('coupon/list', 'StoreCoupon/lst')->option(['real_name' => '优惠券列表']);
  68. Route::post('coupon', 'StoreCoupon/save')->option(['real_name' => '新增优惠券']);
  69. Route::put('coupon/status/:id/:status', 'StoreCoupon/status')->option(['real_name' => '修改优惠券状态']);
  70. Route::delete('coupon/:id', 'StoreCoupon/delete')->option(['real_name' => '删除优惠券']);
  71. })->option(['mark' => 'coupon', 'mark_name' => '优惠卷']);
  72. Route::group(function () {
  73. //用户等级
  74. Route::get('user_level/list', 'UserLevel/lst')->option(['real_name' => '用户等级列表']);
  75. //用户
  76. Route::get('user/list', 'User/lst')->option(['real_name' => '用户列表']);
  77. Route::get('user/info/:uid', 'User/info')->option(['real_name' => '用户详情']);
  78. Route::post('user', 'User/save')->option(['real_name' => '新增用户']);
  79. Route::put('user/:uid', 'User/update')->option(['real_name' => '修改用户']);
  80. Route::put('user/give_balance/:uid', 'User/giveBalance')->option(['real_name' => '赠送余额']);
  81. Route::put('user/give_point/:uid', 'User/givePoint')->option(['real_name' => '赠送积分']);
  82. })->option(['mark' => 'user', 'mark_name' => '用户']);
  83. })->middleware(AuthTokenMiddleware::class);
  84. })->middleware(AllowOriginMiddleware::class);
  85. Route::miss(function () {
  86. if (app()->request->isOptions()) {
  87. $header = Config::get('cookie.header');
  88. $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
  89. return Response::create('ok')->code(200)->header($header);
  90. } else
  91. return Response::create()->code(404);
  92. });