Bill.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. //以下是定义结算单状态
  5. //默认
  6. define('BILL_STATE_CREATE', 1);
  7. //店铺已确认
  8. define('BILL_STATE_STORE_COFIRM', 2);
  9. //平台已审核
  10. define('BILL_STATE_SYSTEM_CHECK', 3);
  11. //结算完成
  12. define('BILL_STATE_SUCCESS', 4);
  13. /**
  14. *
  15. *
  16. * ----------------------------------------------------------------------------
  17. *
  18. * 数据层模型
  19. */
  20. class Bill extends BaseModel
  21. {
  22. public $page_info;
  23. /**
  24. * 取得平台月结算单
  25. * @access public
  26. * @author csdeshang
  27. * @param array $condition 检索条件
  28. * @param str $fields 字段
  29. * @param int $pagesize 分页信息
  30. * @param str $order 排序
  31. * @param int $limit 数量限制
  32. * @return array
  33. */
  34. public function getOrderstatisList($condition = array(), $fields = '*', $pagesize = null, $order = '', $limit = 0)
  35. {
  36. if ($pagesize) {
  37. $result = Db::name('orderstatis')->where($condition)->field($fields)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  38. $this->page_info = $result;
  39. return $result->items();
  40. } else {
  41. return Db::name('orderstatis')->where($condition)->field($fields)->order($order)->limit($limit)->select()->toArray();
  42. }
  43. }
  44. /**
  45. * 取得平台月结算单条信息
  46. * @access public
  47. * @author csdeshang
  48. * @param array $condition 检索条件
  49. * @param string $fields 字段
  50. * @param string $order 排序
  51. * @return array
  52. */
  53. public function getOrderstatisInfo($condition = array(), $fields = '*', $order = null)
  54. {
  55. return Db::name('orderstatis')->where($condition)->field($fields)->order($order)->find();
  56. }
  57. /**
  58. * 取得店铺月结算单列表
  59. * @access public
  60. * @author csdeshang
  61. * @param array $condition 检索条件
  62. * @param str $fields 字段
  63. * @param int $pagesize 分页信息
  64. * @param str $order 排序
  65. * @param int $limit 数量限制
  66. * @return array
  67. */
  68. public function getOrderbillList($condition = array(), $fields = '*', $pagesize = null, $order = '', $limit = 0)
  69. {
  70. if ($pagesize) {
  71. $result = Db::name('orderbill')->where($condition)->field($fields)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  72. $this->page_info = $result;
  73. return $result->items();
  74. } else {
  75. return Db::name('orderbill')->where($condition)->field($fields)->order($order)->limit($limit)->select()->toArray();
  76. }
  77. }
  78. /**
  79. * 取得店铺月结算单单条
  80. * @access public
  81. * @author csdeshang
  82. * @param array $condition 检索条件
  83. * @param string $fields 字段
  84. * @return array
  85. */
  86. public function getOrderbillInfo($condition = array(), $fields = '*')
  87. {
  88. return Db::name('orderbill')->where($condition)->field($fields)->find();
  89. }
  90. /**
  91. * 取得订单数量
  92. * @access public
  93. * @author csdeshang
  94. * @param array $condition 检索条件
  95. * @return int
  96. */
  97. public function getOrderbillCount($condition)
  98. {
  99. return Db::name('orderbill')->where($condition)->count();
  100. }
  101. /**
  102. * 取得平台月结算单数量
  103. * @access public
  104. * @author csdeshang
  105. * @param array $condition 检索条件
  106. * @return int
  107. */
  108. public function getOrderstatisCount($condition)
  109. {
  110. return Db::name('orderstatis')->where($condition)->count();
  111. }
  112. /**
  113. * 添加订单统计
  114. * @access public
  115. * @author csdeshang
  116. * @param type $data 参数内容
  117. * @return type
  118. */
  119. public function addOrderstatis($data)
  120. {
  121. return Db::name('orderstatis')->insert($data);
  122. }
  123. /**
  124. * 添加订单账单
  125. * @access public
  126. * @author csdeshang
  127. * @param array $data 参数数据
  128. * @return type
  129. */
  130. public function addOrderbill($data)
  131. {
  132. return Db::name('orderbill')->insertGetId($data);
  133. }
  134. /**
  135. * 编辑订单账单
  136. * @access public
  137. * @author csdeshang
  138. * @param array $data 更新数据
  139. * @param array $condition 条件
  140. * @return bool
  141. */
  142. public function editOrderbill($data, $condition = array())
  143. {
  144. return Db::name('orderbill')->where($condition)->update($data);
  145. }
  146. }