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.

102 lines
2.6 KiB

7 years ago
4 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
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use Illuminate\Support\Facades\Log;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Http\Request;
  6. use App\Common\ReturnData;
  7. use App\Common\Helper;
  8. use App\Common\Token;
  9. use App\Http\Model\Payment;
  10. use App\Http\Logic\PaymentLogic;
  11. class PaymentController extends BaseController
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function getLogic()
  18. {
  19. return new PaymentLogic();
  20. }
  21. public function paymentList(Request $request)
  22. {
  23. //参数
  24. $limit = $request->input('limit', 10);
  25. $offset = $request->input('offset', 0);
  26. $where['status'] = Payment::IS_SHOW;
  27. $res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
  28. /* if($res['count']>0)
  29. {
  30. foreach($res['list'] as $k=>$v)
  31. {
  32. }
  33. } */
  34. return ReturnData::create(ReturnData::SUCCESS,$res);
  35. }
  36. //详情
  37. public function paymentDetail(Request $request)
  38. {
  39. //参数
  40. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  41. $id = $request->input('id');
  42. $where['status'] = Payment::IS_SHOW;
  43. $where['id'] = $id;
  44. $res = $this->getLogic()->getOne($where);
  45. if(!$res){return ReturnData::create(ReturnData::RECORD_NOT_EXIST);}
  46. return ReturnData::create(ReturnData::SUCCESS,$res);
  47. }
  48. //添加
  49. public function paymentAdd(Request $request)
  50. {
  51. if(Helper::isPostRequest())
  52. {
  53. $res = $this->getLogic()->add($_POST);
  54. return $res;
  55. }
  56. }
  57. //修改
  58. public function paymentUpdate(Request $request)
  59. {
  60. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  61. $id = $request->input('id');
  62. if(Helper::isPostRequest())
  63. {
  64. unset($_POST['id']);
  65. $where['id'] = $id;
  66. $res = $this->getLogic()->edit($_POST,$where);
  67. return $res;
  68. }
  69. }
  70. //删除
  71. public function paymentDelete(Request $request)
  72. {
  73. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  74. $id = $request->input('id');
  75. if(Helper::isPostRequest())
  76. {
  77. $where['id'] = $id;
  78. $res = $this->getLogic()->del($where);
  79. return $res;
  80. }
  81. }
  82. }