Sellerbill.php 3.9 KB

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