Sellerbill.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace app\api\controller;
  3. /**
  4. * ============================================================================
  5. * DSMall多用户商城
  6. * ============================================================================
  7. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  8. * 网站地址: http://www.csdeshang.com
  9. * ----------------------------------------------------------------------------
  10. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  11. * 不允许对程序代码以任何形式任何目的的再发布。
  12. * ============================================================================
  13. * 卖家账单控制器
  14. */
  15. class Sellerbill extends MobileSeller {
  16. public function initialize() {
  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. $bill_model = model('bill');
  40. $condition = array();
  41. $condition[] = array('ob_store_id','=',$this->store_info['store_id']);
  42. if (preg_match('/^\d+$/', input('post.ob_no'))) {
  43. $condition[] = array('ob_no','=',intval(input('post.ob_no')));
  44. }
  45. if (is_numeric(input('post.bill_state'))) {
  46. $condition[] = array('ob_state','=',intval(input('post.bill_state')));
  47. }
  48. $bill_list = $bill_model->getOrderbillList($condition, '*', $this->pagesize, 'ob_state asc,ob_no asc');
  49. foreach ($bill_list as $k => $v) {
  50. $bill_list[$k]['ob_time'] = date('Y-m-d', $v['ob_startdate']) . ' ~ ' . date('Y-m-d', $v['ob_enddate']);
  51. $bill_list[$k]['ob_states'] = get_bill_state($v['ob_state']);
  52. }
  53. $result = array_merge(array('bill_list' => $bill_list), mobile_page($bill_model->page_info));
  54. ds_json_encode(10000, lang('ds_common_op_succ'), $result);
  55. }
  56. /**
  57. * @api {POST} api/Sellerbill/confirm_bill 确认结算信息
  58. * @apiVersion 1.0.0
  59. * @apiGroup Sellerbill
  60. *
  61. * @apiHeader {String} X-DS-KEY 卖家授权token
  62. *
  63. * @apiParam {String} ob_no 结算单号
  64. * @apiParam {String} ob_seller_content 店铺备注
  65. *
  66. * @apiSuccess {String} code 返回码,10000为成功
  67. * @apiSuccess {String} message 返回消息
  68. * @apiSuccess {Object} result 返回数据
  69. */
  70. public function confirm_bill() {
  71. $ob_no = input('param.ob_no');
  72. if (!$ob_no) {
  73. ds_json_encode(10001, lang('param_error'));
  74. }
  75. $bill_model = model('bill');
  76. $condition = array();
  77. $condition[] = array('ob_no','=',$ob_no);
  78. $condition[] = array('ob_store_id','=',session('store_id'));
  79. $condition[] = array('ob_state','=',BILL_STATE_CREATE);
  80. $bill_info = $bill_model->getOrderbillInfo($condition);
  81. if (!$bill_info) {
  82. ds_json_encode(10001, lang('bill_is_not_exist'));
  83. }
  84. $update = $bill_model->editOrderbill(array('ob_state' => BILL_STATE_STORE_COFIRM), $condition);
  85. if ($update) {
  86. ds_json_encode(10000, lang('ds_common_op_succ'));
  87. } else {
  88. ds_json_encode(10001, lang('ds_common_op_fail'));
  89. }
  90. }
  91. }