Memberinvoice.php 11 KB

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