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.

95 lines
2.5 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
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\UserMoney;
  10. use App\Http\Logic\UserMoneyLogic;
  11. //余额明细
  12. class UserMoneyController extends BaseController
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function getLogic()
  19. {
  20. return logic('UserMoney');
  21. }
  22. public function userMoneyList(Request $request)
  23. {
  24. //参数
  25. $limit = $request->input('limit', 10);
  26. $offset = $request->input('offset', 0);
  27. if($request->input('type', null) != null){$data['type'] = $request->input('type');}
  28. $where['user_id'] = Token::$uid;
  29. $res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
  30. return ReturnData::create(ReturnData::SUCCESS,$res);
  31. }
  32. public function userMoneyDetail(Request $request)
  33. {
  34. //参数
  35. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  36. $id = $request->input('id');
  37. $where['id'] = $id;
  38. $res = $this->getLogic()->getOne($where);
  39. if(!$res)
  40. {
  41. return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
  42. }
  43. return ReturnData::create(ReturnData::SUCCESS,$res);
  44. }
  45. //添加
  46. public function userMoneyAdd(Request $request)
  47. {
  48. if(Helper::isPostRequest())
  49. {
  50. $_POST['user_id'] = Token::$uid;
  51. return $this->getLogic()->add($_POST);
  52. }
  53. }
  54. //修改
  55. public function userMoneyUpdate(Request $request)
  56. {
  57. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  58. $id = $request->input('id');
  59. if(Helper::isPostRequest())
  60. {
  61. unset($_POST['id']);
  62. $where['id'] = $id;
  63. $where['user_id'] = Token::$uid;
  64. return $this->getLogic()->edit($_POST,$where);
  65. }
  66. }
  67. //删除
  68. public function userMoneyDelete(Request $request)
  69. {
  70. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  71. $id = $request->input('id');
  72. if(Helper::isPostRequest())
  73. {
  74. $where['id'] = $id;
  75. $where['user_id'] = Token::$uid;
  76. return $this->getLogic()->del($where);
  77. }
  78. }
  79. }