ShopOrder.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use app\common\model\ShopOrders;
  6. class ShopOrder extends Base
  7. {
  8. public function addOrder(){
  9. $addressid = input('address_id/d',0);
  10. // $delivery_time = input('delivery_time','','trim');
  11. // $type = input('type/d',0);
  12. $json = input('json','','trim');
  13. if($addressid <= 0){
  14. HelpHander::error('未选择收货地址');
  15. }
  16. // if(!$delivery_time){
  17. // HelpHander::error('未选择配送时间');
  18. // }
  19. // if($type <= 0){
  20. // HelpHander::error('未选择类型');
  21. // }
  22. if(!$json){
  23. HelpHander::error('商品信息不能为空');
  24. }
  25. $so = new ShopOrders();
  26. $ret = $so->addOrder($json,$addressid,$this->orgId,$this->userId);
  27. if(!$ret){
  28. HelpHander::error($so->getError());
  29. }
  30. HelpHander::success($ret);
  31. }
  32. public function orderList(){
  33. $page = input('page/d',1);
  34. $size = input('size/d',10);
  35. $so = new ShopOrders();
  36. $ret = $so->list($page,$size,$this->userId,$this->orgId);
  37. HelpHander::success($ret);
  38. }
  39. public function orderDetails(){
  40. $id = input('id/d',0);
  41. $so = new ShopOrders();
  42. $ret = $so->details($id);
  43. if(!$ret){
  44. HelpHander::error('数据不存在');
  45. }
  46. HelpHander::success($ret);
  47. }
  48. public function cancel(){
  49. $id = input('id/d',0);
  50. $so = new ShopOrders();
  51. $ret = $so->cancel($id,$this->userId);
  52. if(!$ret){
  53. HelpHander::error('操作失败');
  54. }
  55. HelpHander::success([],'操作成功');
  56. }
  57. }