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.

65 lines
1.7 KiB

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 orderAdd(Request $request)
  24. {return ReturnData::create(ReturnData::SUCCESS);
  25. //参数
  26. $data['goods_number'] = $request->input('goods_number','');
  27. $data['goods_id'] = $request->input('goods_id','');
  28. if($request->input('goods_attr', '') != ''){$data['goods_attr'] = $request->input('goods_attr');}
  29. if($request->input('shop_id', '') != ''){$data['shop_id'] = $request->input('shop_id');}
  30. $data['add_time'] = time();
  31. $data['user_id'] = Token::$uid;
  32. if($data['goods_number']=='' || $data['goods_id']=='')
  33. {
  34. return ReturnData::create(ReturnData::PARAMS_ERROR);
  35. }
  36. return Order::cartAdd($data);
  37. }
  38. //删除订单
  39. public function cartDelete(Request $request)
  40. {
  41. $id = $request->input('id','');
  42. if($id=='')
  43. {
  44. return ReturnData::create(ReturnData::PARAMS_ERROR);
  45. }
  46. $res = Cart::remove($id,Token::$uid);
  47. if($res === true)
  48. {
  49. return ReturnData::create(ReturnData::SUCCESS,$res);
  50. }
  51. return ReturnData::create(ReturnData::SYSTEM_FAIL);
  52. }
  53. }