OrderAnnualFeeModel.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\common\model;
  3. class OrderAnnualFeeModel extends BaseModel
  4. {
  5. protected $table = 'erp_order_annual_fee';
  6. protected function genSchema(array $schema)
  7. {
  8. // TODO: Implement genSchema() method.
  9. }
  10. public function fetchByOrderIds($order_ids, $is_pay = 0)
  11. {
  12. return $this->where('is_delete', 0)
  13. ->where('order_id', 'in', $order_ids)
  14. ->where('is_pay', '=', $is_pay)
  15. ->select()->toArray();
  16. }
  17. public function fetchByAdviser($admin_id, $text = null, $start_time = null, $end_time = null, $page = 1, $size = 10)
  18. {
  19. $where = [
  20. ['is_delete', '=', 0],
  21. ['is_pay', '=', 0],
  22. ];
  23. if ($text) array_push($where, ['customer_name|customer_mobile', 'like', "%" . $text . "%"]);
  24. if ($start_time) array_push($where, ['order_create_time', '>=', $start_time]);
  25. if ($end_time) array_push($where, ['order_create_time', '<=', $end_time]);
  26. return [
  27. $this->where($where)
  28. ->where("FIND_IN_SET('{$admin_id}', adviser_ids)")
  29. ->page($page)
  30. ->paginate($size),
  31. $this->where($where)->sum("fee")
  32. ];
  33. }
  34. public function fetchByOrderProductId(array $o_p_ids)
  35. {
  36. $where = [
  37. ['is_delete', '=', 0],
  38. ['order_product_id', 'in', $o_p_ids],
  39. ];
  40. return $this->where($where)
  41. ->select()->toArray();
  42. }
  43. }