SellerModel.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Home\Model;
  3. use Think\Model;
  4. /**
  5. * 商家模块
  6. * @author fish
  7. *
  8. */
  9. class SellerModel extends Model{
  10. public function getStoreSellerCount($store_id)
  11. {
  12. $vir_count = M('goods')->where( array('store_id' => $store_id) )->sum('virtual_count');
  13. $seller_count = M('goods')->where( array('store_id' => $store_id) )->sum('seller_count');
  14. return ($vir_count+$seller_count);
  15. /**
  16. $sql = "select sum(quantity) as total_quantiry from ".C('DB_PREFIX')."order as o ,".C('DB_PREFIX')."order_goods as og
  17. where o.order_id=og.order_id and o.order_status_id in (1,2,4,6) and og.store_id = ".$store_id;
  18. $total_quantiry = M()->query($sql);
  19. return intval($total_quantiry['total_quantiry']);
  20. **/
  21. }
  22. /**
  23. 获取商家评价
  24. */
  25. public function get_pingjia($store_id)
  26. {
  27. $sql=" select oc.* from ".C('DB_PREFIX')."order_goods as o ,".C('DB_PREFIX')."order_comment as oc
  28. where o.order_id =oc.order_id and o.store_id = {$store_id} ";
  29. $result = array('miaoshu' =>5,'jiage' => 5,'zhiliang' => 5);
  30. $comment_list = M()->query($sql);
  31. if( !empty($comment_list) )
  32. {
  33. $total_count = count($comment_list);
  34. $total_miaoshu = 0;
  35. $total_jiage = 0;
  36. $total_zhiliang = 0;
  37. foreach($comment_list as $comment)
  38. {
  39. $total_miaoshu += $comment['star'];
  40. $total_jiage += $comment['star2'];
  41. $total_zhiliang += $comment['star3'];
  42. }
  43. $total_miaoshu = round($total_miaoshu / $total_count,2);
  44. $total_jiage = round($total_jiage / $total_count,2);
  45. $total_zhiliang = round($total_zhiliang / $total_count,2);
  46. $result = array('miaoshu' => $total_miaoshu,'jiage' =>$total_jiage,'zhiliang'=>$total_zhiliang);
  47. }
  48. return $result;
  49. }
  50. }