Sellerbill.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\api\controller;
  3. /**
  4. * ============================================================================
  5. *
  6. * ============================================================================
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * ============================================================================
  11. * 卖家账单控制器
  12. */
  13. class Sellerbill extends MobileSeller
  14. {
  15. public function initialize()
  16. {
  17. parent::initialize(); // TODO: Change the autogenerated stub
  18. }
  19. /**
  20. * @api {POST} api/Sellerbill/bill_list 获取结算列表
  21. * @apiVersion 1.0.0
  22. * @apiGroup Sellerbill
  23. *
  24. * @apiHeader {String} X-DS-KEY 卖家授权token
  25. *
  26. * @apiParam {String} ob_no 结算单号
  27. * @apiParam {String} bill_state 结算状态 1已出账 2店家已确认 3平台已审核 4结算完成
  28. * @apiParam {String} page 页码
  29. * @apiParam {String} per_page 每页显示数量
  30. *
  31. * @apiSuccess {String} code 返回码,10000为成功
  32. * @apiSuccess {String} message 返回消息
  33. * @apiSuccess {Object} result 返回数据
  34. * @apiSuccess {Object[]} result.bill_list (返回字段参考orderbill表)
  35. * @apiSuccess {Int} result.page_total 总页数
  36. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  37. */
  38. public function bill_list()
  39. {
  40. $bill_model = model('bill');
  41. $condition = array();
  42. $condition[] = array('ob_store_id', '=', $this->store_info['store_id']);
  43. if (preg_match('/^\d+$/', input('post.ob_no'))) {
  44. $condition[] = array('ob_no', '=', intval(input('post.ob_no')));
  45. }
  46. if (is_numeric(input('post.bill_state'))) {
  47. $condition[] = array('ob_state', '=', intval(input('post.bill_state')));
  48. }
  49. $bill_list = $bill_model->getOrderbillList($condition, '*', $this->pagesize, 'ob_state asc,ob_no asc');
  50. foreach ($bill_list as $k => $v) {
  51. $bill_list[$k]['ob_time'] = date('Y-m-d', $v['ob_startdate']) . ' ~ ' . date('Y-m-d', $v['ob_enddate']);
  52. $bill_list[$k]['ob_states'] = get_bill_state($v['ob_state']);
  53. }
  54. $result = array_merge(array('bill_list' => $bill_list), mobile_page($bill_model->page_info));
  55. ds_json_encode(10000, lang('ds_common_op_succ'), $result);
  56. }
  57. /**
  58. * @api {POST} api/Sellerbill/confirm_bill 确认结算信息
  59. * @apiVersion 1.0.0
  60. * @apiGroup Sellerbill
  61. *
  62. * @apiHeader {String} X-DS-KEY 卖家授权token
  63. *
  64. * @apiParam {String} ob_no 结算单号
  65. * @apiParam {String} ob_seller_content 店铺备注
  66. *
  67. * @apiSuccess {String} code 返回码,10000为成功
  68. * @apiSuccess {String} message 返回消息
  69. * @apiSuccess {Object} result 返回数据
  70. */
  71. public function confirm_bill()
  72. {
  73. $ob_no = input('param.ob_no');
  74. if (!$ob_no) {
  75. ds_json_encode(10001, lang('param_error'));
  76. }
  77. $bill_model = model('bill');
  78. $condition = array();
  79. $condition[] = array('ob_no', '=', $ob_no);
  80. $condition[] = array('ob_store_id', '=', session('store_id'));
  81. $condition[] = array('ob_state', '=', BILL_STATE_CREATE);
  82. $bill_info = $bill_model->getOrderbillInfo($condition);
  83. if (!$bill_info) {
  84. ds_json_encode(10001, lang('bill_is_not_exist'));
  85. }
  86. $update = $bill_model->editOrderbill(array('ob_state' => BILL_STATE_STORE_COFIRM), $condition);
  87. if ($update) {
  88. ds_json_encode(10000, lang('ds_common_op_succ'));
  89. } else {
  90. ds_json_encode(10001, lang('ds_common_op_fail'));
  91. }
  92. }
  93. }