OrdersController.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. namespace App\Http\Controllers\Channel\Order;
  3. use App\Http\Controllers\Wap\BaseController;
  4. use Illuminate\Http\Request;
  5. use App\Modules\Subscribe\Services\BookOrderService;
  6. use App\Modules\Subscribe\Services\ChapterOrderService;
  7. use App\Modules\Subscribe\Services\OrderService;
  8. use App\Http\Controllers\Channel\Order\Transformers\BookOrderTransformer;
  9. use App\Http\Controllers\Channel\Order\Transformers\ChapterOrderTransformer;
  10. use App\Http\Controllers\Channel\Order\Transformers\ChargeListTransformer;
  11. class OrdersController extends BaseController
  12. {
  13. /**
  14. * @apiDefine Order 订单
  15. */
  16. /**
  17. * @apiVersion 1.0.0
  18. * @apiDescription 单本消费记录
  19. * @api {get} order/bookOrderList 单本消费记录
  20. * @apiGroup Order
  21. * @apiName bookOrderList
  22. * @apiParam {int} uid uid
  23. * @apiParam {int} [uid] page_size
  24. * @apiParam {int} [page] 页码
  25. * @apiSuccess {int} code 状态码
  26. * @apiSuccess {String} msg 信息
  27. * @apiSuccess {object} data 结果集
  28. * @apiSuccess {int} id 序号
  29. * @apiSuccess {int} type 类型
  30. * @apiSuccess {Int} detail 详情
  31. * @apiSuccess {Int} fee 书币
  32. * @apiSuccess {Int} book_name 书名
  33. * @apiSuccess {Int} chapter_name 章节名
  34. * @apiSuccess {String} created_at 时间
  35. * @apiSuccessExample {json} Success-Response:
  36. * HTTP/1.1 200 OK
  37. * {
  38. * code: 0,
  39. * msg: "",
  40. * data: list:[
  41. * {
  42. * id: 40,
  43. * type: "消耗",
  44. * detail: "单本订购",
  45. * book_name: "你的爱情那么伤",
  46. * chapter_name: "",
  47. * fee: 899,
  48. * created_at: "2017-12-08 20:07:27"
  49. * }
  50. * ]
  51. * meta: {
  52. * total: 1,
  53. * per_page: 15,
  54. * current_page: 1,
  55. * last_page: 1,
  56. * next_page_url: "",
  57. * prev_page_url: ""
  58. * }
  59. * }
  60. */
  61. public function bookOrderList(Request $request)
  62. {
  63. $uid = $request->input('uid');
  64. $page_size = $request->input('page_size', 15);
  65. $book_order = BookOrderService::getRecord($uid, $page_size);
  66. return response()->pagination(new BookOrderTransformer(), $book_order);
  67. }
  68. /**
  69. * @apiVersion 1.0.0
  70. * @apiDescription 章节消费记录
  71. * @api {get} order/chapterOrderList 章节消费记录
  72. * @apiGroup Order
  73. * @apiName chapterOrderList
  74. * @apiParam {int} uid uid
  75. * @apiParam {int} [uid] page_size
  76. * @apiParam {int} [page] 页码
  77. * @apiSuccess {int} code 状态码
  78. * @apiSuccess {String} msg 信息
  79. * @apiSuccess {object} data 结果集
  80. * @apiSuccess {int} id 序号
  81. * @apiSuccess {int} type 类型
  82. * @apiSuccess {Int} detail 详情
  83. * @apiSuccess {Int} fee 书币
  84. * @apiSuccess {Int} book_name 书名
  85. * @apiSuccess {Int} chapter_name 章节名
  86. * @apiSuccessExample {json} Success-Response:
  87. * HTTP/1.1 200 OK
  88. * {
  89. * code: 0,
  90. * msg: "",
  91. * data: list:[
  92. * {
  93. * id: 40,
  94. * type: "消耗",
  95. * detail: "单本订购",
  96. * book_name: "你的爱情那么伤",
  97. * chapter_name: "",
  98. * fee: 899,
  99. * created_at: "2017-12-08 20:07:27"
  100. * }
  101. * ]
  102. * meta: {
  103. * total: 1,
  104. * per_page: 15,
  105. * current_page: 1,
  106. * last_page: 1,
  107. * next_page_url: "",
  108. * prev_page_url: ""
  109. * }
  110. * }
  111. */
  112. public function chapterOrderList(Request $request)
  113. {
  114. $uid = $request->input('uid');
  115. $chapter_model = new ChapterOrderService();
  116. $page_size = $request->input('page_size', 15);
  117. $chapter_order = $chapter_model->getByUid($uid, $page_size);
  118. return response()->pagination(new ChapterOrderTransformer(), $chapter_order);
  119. }
  120. /**
  121. * @apiVersion 1.0.0
  122. * @apiDescription 充值记录
  123. * @api {get} order/chargeRecordLists 充值记录
  124. * @apiGroup Order
  125. * @apiName chargeRecordLists
  126. * @apiParam {int} uid uid
  127. * @apiParam {int} [uid] page_size
  128. * @apiParam {int} [page] 页码
  129. * @apiSuccess {int} code 状态码
  130. * @apiSuccess {String} msg 信息
  131. * @apiSuccess {object} data 结果集
  132. * @apiSuccess {int} id 序号
  133. * @apiSuccess {int} type 类型
  134. * @apiSuccess {Int} detail 详情
  135. * @apiSuccess {Int} fee 书币
  136. * @apiSuccess {Int} book_name 书名
  137. * @apiSuccess {Int} chapter_name 章节名
  138. * @apiSuccessExample {json} Success-Response:
  139. * HTTP/1.1 200 OK
  140. * {
  141. * code: 0,
  142. * msg: "",
  143. * data: {
  144. * list: [
  145. * {
  146. * id: 40,
  147. * type: "消耗",
  148. * detail: "单本订购",
  149. * book_name: "你的爱情那么伤",
  150. * chapter_name: "",
  151. * fee: 899,
  152. * created_at: "2017-12-08 20:07:27"
  153. * }
  154. * ],
  155. * meta: {
  156. * total: 1,
  157. * per_page: 15,
  158. * current_page: 1,
  159. * last_page: 1,
  160. * next_page_url: "",
  161. * prev_page_url: ""
  162. * }
  163. * }
  164. * }
  165. */
  166. public function chargeRecordLists(Request $request)
  167. {
  168. $page_size = $request->input('page_size', 15);
  169. $uid = $request->input('uid');
  170. $res = OrderService::getSuccessOrderList($uid, $page_size);
  171. foreach ($res as &$v){
  172. $v->type = '充值';
  173. $v->detail = '充值';
  174. if($v->order_type == 'RECHARGE'){
  175. $v->type = '充值';
  176. $v->detail = '充值书币';
  177. }
  178. if($v->order_type == 'BOOK'){
  179. $v->type = '充值';
  180. $v->detail = '单本购买';
  181. }
  182. if($v->order_type == 'YEAR'){
  183. $v->type = '充值';
  184. $v->detail = '包年';
  185. }
  186. }
  187. return response()->pagination(new ChargeListTransformer(), $res);
  188. }
  189. }