ProductOrderModel.php 918 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\index\model;
  3. class ProductOrderModel extends BaseModel
  4. {
  5. protected $table='order';
  6. protected $connection = 'db_mall';
  7. public function getProductOrder($where){
  8. $list = $this->where($where)->select();
  9. if(!$list){
  10. return [];
  11. }
  12. foreach($list as &$item){
  13. $productOrderDetailModel = new ProductOrderDetailModel();
  14. $productOrderDetail = $productOrderDetailModel->field('order_detail.*,product.product_name')->join("product","product.product_id = order_detail.product_id",'left')->where(['order_no'=>$item['order_no']])->select();
  15. $item['detail'] = $productOrderDetail;
  16. }
  17. return $list;
  18. }
  19. /**
  20. * 求条件下的订单数量
  21. * @param $where
  22. * @return int|string
  23. */
  24. public function getProductOrderCount($where){
  25. return $this->where($where)->count();
  26. }
  27. }