Memberinvoice.php 11 KB

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