Bill.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. * ============================================================================
  21. * 数据层模型
  22. */
  23. class Bill extends BaseModel {
  24. public $page_info;
  25. /**
  26. * 取得平台月结算单
  27. * @access public
  28. * @author csdeshang
  29. * @param array $condition 检索条件
  30. * @param str $fields 字段
  31. * @param int $pagesize 分页信息
  32. * @param str $order 排序
  33. * @param int $limit 数量限制
  34. * @return array
  35. */
  36. public function getOrderstatisList($condition = array(), $fields = '*', $pagesize = null, $order = '', $limit = 0) {
  37. if($pagesize){
  38. $result = Db::name('orderstatis')->where($condition)->field($fields)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  39. $this->page_info = $result;
  40. return $result->items();
  41. }else{
  42. return Db::name('orderstatis')->where($condition)->field($fields)->order($order)->limit($limit)->select()->toArray();
  43. }
  44. }
  45. /**
  46. * 取得平台月结算单条信息
  47. * @access public
  48. * @author csdeshang
  49. * @param array $condition 检索条件
  50. * @param string $fields 字段
  51. * @param string $order 排序
  52. * @return array
  53. */
  54. public function getOrderstatisInfo($condition = array(), $fields = '*', $order = null) {
  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. if($pagesize){
  70. $result = Db::name('orderbill')->where($condition)->field($fields)->order($order)->paginate(['list_rows'=>$pagesize,'query' => request()->param()],false);
  71. $this->page_info = $result;
  72. return $result->items();
  73. }else{
  74. return Db::name('orderbill')->where($condition)->field($fields)->order($order)->limit($limit)->select()->toArray();
  75. }
  76. }
  77. /**
  78. * 取得店铺月结算单单条
  79. * @access public
  80. * @author csdeshang
  81. * @param array $condition 检索条件
  82. * @param string $fields 字段
  83. * @return array
  84. */
  85. public function getOrderbillInfo($condition = array(), $fields = '*') {
  86. return Db::name('orderbill')->where($condition)->field($fields)->find();
  87. }
  88. /**
  89. * 取得订单数量
  90. * @access public
  91. * @author csdeshang
  92. * @param array $condition 检索条件
  93. * @return int
  94. */
  95. public function getOrderbillCount($condition) {
  96. return Db::name('orderbill')->where($condition)->count();
  97. }
  98. /**
  99. * 取得平台月结算单数量
  100. * @access public
  101. * @author csdeshang
  102. * @param array $condition 检索条件
  103. * @return int
  104. */
  105. public function getOrderstatisCount($condition) {
  106. return Db::name('orderstatis')->where($condition)->count();
  107. }
  108. /**
  109. * 添加订单统计
  110. * @access public
  111. * @author csdeshang
  112. * @param type $data 参数内容
  113. * @return type
  114. */
  115. public function addOrderstatis($data) {
  116. return Db::name('orderstatis')->insert($data);
  117. }
  118. /**
  119. * 添加订单账单
  120. * @access public
  121. * @author csdeshang
  122. * @param array $data 参数数据
  123. * @return type
  124. */
  125. public function addOrderbill($data) {
  126. return Db::name('orderbill')->insertGetId($data);
  127. }
  128. /**
  129. * 编辑订单账单
  130. * @access public
  131. * @author csdeshang
  132. * @param array $data 更新数据
  133. * @param array $condition 条件
  134. * @return bool
  135. */
  136. public function editOrderbill($data, $condition = array()) {
  137. return Db::name('orderbill')->where($condition)->update($data);
  138. }
  139. }