OrderProductModel.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\common\model;
  3. class OrderProductModel extends BaseModel
  4. {
  5. protected $table = 'erp_order_product';
  6. protected function genSchema(array $schema)
  7. {
  8. // TODO: Implement genSchema() method.
  9. }
  10. /**
  11. * @param $o_id
  12. * @return OrderProductModel[]|array|\think\Collection
  13. * @throws \think\db\exception\DataNotFoundException
  14. * @throws \think\db\exception\DbException
  15. * @throws \think\db\exception\ModelNotFoundException
  16. */
  17. public function findByOrderId($o_id) {
  18. return $this->where('is_delete', 0)
  19. ->where('order_id',$o_id)
  20. ->select();
  21. }
  22. /**
  23. * @param $c_id
  24. * @param int $is_upload_numerology
  25. * @param int $is_upload
  26. * @return int
  27. * @throws \think\db\exception\DbException
  28. */
  29. public function countByCustomerId($c_id, $is_upload_numerology = 1, $is_upload = null) {
  30. $where = [
  31. ['is_delete', '=', 0],
  32. ['customer_id', '=', $c_id],
  33. ['is_upload_numerology', '=', $is_upload_numerology]
  34. ];
  35. if ($is_upload) {
  36. array_push($where,['is_upload', '=', $is_upload]);
  37. }
  38. return $this->where($where)
  39. ->count();
  40. }
  41. }