You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Api\CommonController;
  4. use Illuminate\Http\Request;
  5. use App\Common\ReturnData;
  6. use App\Common\Token;
  7. use App\Http\Model\Order;
  8. class OrderController extends CommonController
  9. {
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. }
  14. //订单列表
  15. public function orderList(Request $request)
  16. {
  17. //参数
  18. $data['user_id'] = Token::$uid;
  19. $res = Order::getList($data);
  20. return ReturnData::create(ReturnData::SUCCESS,$res);
  21. }
  22. //订单详情
  23. public function orderDetail(Request $request)
  24. {
  25. //参数
  26. $data['user_id'] = Token::$uid;
  27. $res = Order::getList($data);
  28. return ReturnData::create(ReturnData::SUCCESS,$res);
  29. }
  30. //生成订单
  31. public function orderAdd(Request $request)
  32. {
  33. //参数
  34. $default_address_id = $request->input('default_address_id','');
  35. $payid = $request->input('payid','');
  36. $user_bonus_id = $request->input('user_bonus_id','');
  37. $shipping_costs = $request->input('shipping_costs','');
  38. $message = $request->input('message','');
  39. //获取商品列表
  40. $cartids = $request->input('cartids','');
  41. if($cartids=='')
  42. {
  43. return ReturnData::create(ReturnData::PARAMS_ERROR);
  44. }
  45. $orderGoods = Cart::cartCheckoutGoodsList(array('ids'=>$cartids,'user_id'=>Token::$uid));
  46. return Order::add($data);
  47. }
  48. //删除订单
  49. public function cartDelete(Request $request)
  50. {
  51. $id = $request->input('id','');
  52. if($id=='')
  53. {
  54. return ReturnData::create(ReturnData::PARAMS_ERROR);
  55. }
  56. $res = Cart::remove($id,Token::$uid);
  57. if($res === true)
  58. {
  59. return ReturnData::create(ReturnData::SUCCESS,$res);
  60. }
  61. return ReturnData::create(ReturnData::SYSTEM_FAIL);
  62. }
  63. }