Memberinvoice.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 发票控制器
  10. */
  11. class Memberinvoice extends MobileMember
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize(); // TODO: Change the autogenerated stub
  16. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberinvoice.lang.php');
  17. }
  18. /**
  19. * @api {POST} api/Memberinvoice/invoice_list 发票信息列表
  20. * @apiVersion 1.0.0
  21. * @apiGroup MemberInvoice
  22. *
  23. * @apiHeader {String} X-DS-KEY 用户授权token
  24. *
  25. * @apiParam {Int} page 页码
  26. * @apiParam {Int} per_page 每页数量
  27. *
  28. * @apiSuccess {String} code 返回码,10000为成功
  29. * @apiSuccess {String} message 返回消息
  30. * @apiSuccess {Object} result 返回数据
  31. * @apiSuccess {Object[]} result.invoice_list 发票列表
  32. * @apiSuccess {String} result.invoice_list.invoice_code 纳税人识别号[普通发票]
  33. * @apiSuccess {String} result.invoice_list.invoice_company 单位名称
  34. * @apiSuccess {String} result.invoice_list.invoice_company_code 纳税人识别号
  35. * @apiSuccess {String} result.invoice_list.invoice_content 发票内容[普通发票]
  36. * @apiSuccess {String} result.invoice_list.invoice_goto_addr 送票地址
  37. * @apiSuccess {Int} result.invoice_list.invoice_id 发票信息ID
  38. * @apiSuccess {String} result.invoice_list.invoice_rec_mobphone 收票人手机号
  39. * @apiSuccess {String} result.invoice_list.invoice_rec_name 收票人姓名
  40. * @apiSuccess {String} result.invoice_list.invoice_rec_province 收票人省份
  41. * @apiSuccess {String} result.invoice_list.invoice_reg_addr 注册地址
  42. * @apiSuccess {String} result.invoice_list.invoice_reg_baccount 银行帐户
  43. * @apiSuccess {String} result.invoice_list.invoice_reg_bname 开户银行
  44. * @apiSuccess {String} result.invoice_list.invoice_reg_phone 注册电话
  45. * @apiSuccess {Int} result.invoice_list.invoice_state 发票类型 1:普通发票 2:增值税发票
  46. * @apiSuccess {String} result.invoice_list.invoice_title 发票抬头[普通发票]
  47. * @apiSuccess {Int} result.invoice_list.member_id 用户ID
  48. */
  49. public function invoice_list()
  50. {
  51. $invoice_model = model('invoice');
  52. $condition = array();
  53. $condition[] = array('member_id', '=', $this->member_info['member_id']);
  54. $invoice_list = $invoice_model->getInvoiceList($condition, 10, '*');
  55. ds_json_encode(10000, '', array('invoice_list' => $invoice_list));
  56. }
  57. /**
  58. * @api {POST} api/Memberinvoice/invoice_info 发票信息详情
  59. * @apiVersion 1.0.0
  60. * @apiGroup MemberInvoice
  61. *
  62. * @apiHeader {String} X-DS-KEY 用户授权token
  63. *
  64. * @apiParam {Int} invoice_id 发票ID
  65. *
  66. * @apiSuccess {String} code 返回码,10000为成功
  67. * @apiSuccess {String} message 返回消息
  68. * @apiSuccess {Object} result 返回数据
  69. * @apiSuccess {String} result.invoice_code 纳税人识别号[普通发票]
  70. * @apiSuccess {String} result.invoice_company 单位名称
  71. * @apiSuccess {String} result.invoice_company_code 纳税人识别号
  72. * @apiSuccess {String} result.invoice_content 发票内容[普通发票]
  73. * @apiSuccess {String} result.invoice_goto_addr 送票地址
  74. * @apiSuccess {Int} result.invoice_id 发票信息ID
  75. * @apiSuccess {String} result.invoice_rec_mobphone 收票人手机号
  76. * @apiSuccess {String} result.invoice_rec_name 收票人姓名
  77. * @apiSuccess {String} result.invoice_rec_province 收票人省份
  78. * @apiSuccess {String} result.invoice_reg_addr 注册地址
  79. * @apiSuccess {String} result.invoice_reg_baccount 银行帐户
  80. * @apiSuccess {String} result.invoice_reg_bname 开户银行
  81. * @apiSuccess {String} result.invoice_reg_phone 注册电话
  82. * @apiSuccess {Int} result.invoice_state 发票类型 1:普通发票 2:增值税发票
  83. * @apiSuccess {String} result.invoice_title 发票抬头[普通发票]
  84. * @apiSuccess {Int} result.member_id 用户ID
  85. */
  86. public function invoice_info()
  87. {
  88. $invoice_id = intval(input('post.invoice_id'));
  89. if ($invoice_id <= 0) {
  90. ds_json_encode(10001, lang('param_error'));
  91. }
  92. $invoice_model = model('invoice');
  93. $result = $invoice_model->getInvoiceInfo(array('invoice_id' => $invoice_id, 'member_id' => $this->member_info['member_id']));
  94. ds_json_encode(10000, '', $result);
  95. }
  96. /**
  97. * @api {POST} api/Memberinvoice/invoice_del 发票信息删除
  98. * @apiVersion 1.0.0
  99. * @apiGroup MemberInvoice
  100. *
  101. * @apiHeader {String} X-DS-KEY 用户授权token
  102. *
  103. * @apiParam {Int} invoice_id 发票ID
  104. *
  105. * @apiSuccess {String} code 返回码,10000为成功
  106. * @apiSuccess {String} message 返回消息
  107. */
  108. public function invoice_del()
  109. {
  110. $invoice_id = intval(input('post.invoice_id'));
  111. if ($invoice_id <= 0) {
  112. ds_json_encode(10001, lang('param_error'));
  113. }
  114. $invoice_model = model('invoice');
  115. $result = $invoice_model->delInvoice(array('invoice_id' => $invoice_id, 'member_id' => $this->member_info['member_id']));
  116. if ($result) {
  117. ds_json_encode(10000, '', 1);
  118. } else {
  119. ds_json_encode(10001, lang('ds_common_op_fail'));
  120. }
  121. }
  122. /**
  123. * @api {POST} api/Memberinvoice/invoice_add 发票信息添加
  124. * @apiVersion 1.0.0
  125. * @apiGroup MemberInvoice
  126. *
  127. * @apiHeader {String} X-DS-KEY 用户授权token
  128. *
  129. * @apiParam {String} invoice_state 发票类型
  130. * @apiParam {String} invoice_title 发票抬头[普通发票]
  131. * @apiParam {String} invoice_code 纳税人识别号[普通发票]
  132. * @apiParam {String} invoice_content 发票内容[普通发票]
  133. * @apiParam {String} invoice_company 单位名称
  134. * @apiParam {String} invoice_company_code 纳税人识别号
  135. * @apiParam {String} invoice_reg_addr 注册地址
  136. * @apiParam {String} invoice_reg_phone 注册电话
  137. * @apiParam {String} invoice_reg_bname 开户银行
  138. * @apiParam {String} invoice_reg_baccount 银行帐户
  139. *
  140. * @apiSuccess {String} code 返回码,10000为成功
  141. * @apiSuccess {String} message 返回消息
  142. * @apiSuccess {Object} result 返回数据
  143. * @apiSuccess {Int} result.invoice_id 发票ID
  144. */
  145. public function invoice_add()
  146. {
  147. $invoice_model = model('invoice');
  148. $data = array();
  149. $data['invoice_state'] = input('post.invoice_state');
  150. $data['invoice_title'] = input('post.invoice_title');
  151. $data['invoice_content'] = input('post.invoice_content');
  152. $data['invoice_code'] = input('post.invoice_code');
  153. $data['invoice_company'] = input('post.invoice_company');
  154. $data['invoice_company_code'] = input('post.invoice_company_code');
  155. $data['invoice_reg_addr'] = input('post.invoice_reg_addr');
  156. $data['invoice_reg_phone'] = input('post.invoice_reg_phone');
  157. $data['invoice_reg_bname'] = input('post.invoice_reg_bname');
  158. $data['invoice_reg_baccount'] = input('post.invoice_reg_baccount');
  159. $data['member_id'] = $this->member_info['member_id'];
  160. $result = $invoice_model->addInvoice($data);
  161. if ($result) {
  162. ds_json_encode(10000, '', array('invoice_id' => $result));
  163. } else {
  164. ds_json_encode(10001, lang('ds_common_op_fail'));
  165. }
  166. }
  167. /**
  168. * @api {POST} api/Memberinvoice/invoice_edit 发票信息编辑
  169. * @apiVersion 1.0.0
  170. * @apiGroup MemberInvoice
  171. *
  172. * @apiHeader {String} X-DS-KEY 用户授权token
  173. *
  174. * @apiParam {Int} invoice_id 发票ID
  175. * @apiParam {String} invoice_state 发票类型
  176. * @apiParam {String} invoice_title 发票抬头[普通发票]
  177. * @apiParam {String} invoice_code 纳税人识别号[普通发票]
  178. * @apiParam {String} invoice_content 发票内容[普通发票]
  179. * @apiParam {String} invoice_company 单位名称
  180. * @apiParam {String} invoice_company_code 纳税人识别号
  181. * @apiParam {String} invoice_reg_addr 注册地址
  182. * @apiParam {String} invoice_reg_phone 注册电话
  183. * @apiParam {String} invoice_reg_bname 开户银行
  184. * @apiParam {String} invoice_reg_baccount 银行帐户
  185. *
  186. * @apiSuccess {String} code 返回码,10000为成功
  187. * @apiSuccess {String} message 返回消息
  188. */
  189. public function invoice_edit()
  190. {
  191. $invoice_id = intval(input('post.invoice_id'));
  192. $invoice_model = model('invoice');
  193. $data['invoice_state'] = input('post.invoice_state');
  194. $data['invoice_title'] = input('post.invoice_title');
  195. $data['invoice_content'] = input('post.invoice_content');
  196. $data['invoice_code'] = input('post.invoice_code');
  197. $data['invoice_company'] = input('post.invoice_company');
  198. $data['invoice_company_code'] = input('post.invoice_company_code');
  199. $data['invoice_reg_addr'] = input('post.invoice_reg_addr');
  200. $data['invoice_reg_phone'] = input('post.invoice_reg_phone');
  201. $data['invoice_reg_bname'] = input('post.invoice_reg_bname');
  202. $data['invoice_reg_baccount'] = input('post.invoice_reg_baccount');
  203. $result = $invoice_model->editInvoice($data, array('invoice_id' => $invoice_id, 'member_id' => $this->member_info['member_id']));
  204. if ($result) {
  205. ds_json_encode(10000, '');
  206. } else {
  207. ds_json_encode(10001, lang('ds_common_op_fail'));
  208. }
  209. }
  210. /**
  211. * 发票内容列表
  212. */
  213. public function invoice_content_list()
  214. {
  215. $invoice_content_list = array(
  216. lang('detailed'), lang('alcohol'), lang('food'), lang('drinks'), lang('toys'), lang('daily_necessities'), lang('decoration_materials'), lang('cosmetics'), lang('office_supplies'), lang('student_supplies'), lang('furnishings'), lang('ornaments'), lang('clothing'), lang('luggage'), lang('boutique'), lang('electrical_appliances'),
  217. lang('building_supplies'), lang('consumables'), lang('computer_parts')
  218. );
  219. ds_json_encode(10000, '', array('invoice_content_list' => $invoice_content_list));
  220. }
  221. }