GoodsSalesController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\admin\controller\finance;
  3. use app\model\OrderSheet;
  4. use support\Request;
  5. class GoodsSalesController{
  6. public function list(Request $request)
  7. {
  8. $rows = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
  9. ->leftJoin('goods_sku','goods_sku.join_sku_goods_id','=','order_sheet.join_sheet_goods_id')
  10. ->selectRaw('SUM(app_order_sheet.order_sheet_num) as num,SUM(app_order_sheet_pay) as amount,CONCAT(app_goods.goods_id,"-",app_goods_sku.goods_sku_id) as goods_flag')
  11. ->orderBy('order_sheet_addtimes','DESC')
  12. ->groupBy('goods_flag')
  13. ->get();
  14. dump($rows);
  15. return json_success('');
  16. }
  17. public function statistics()
  18. {
  19. $data['total'] = OrderSheet::whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
  20. ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
  21. ->first();
  22. $data['entity'] = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
  23. ->where('goods.goods_classify','GOODS')
  24. ->whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
  25. ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
  26. ->first();
  27. $data['service'] = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
  28. ->where('goods.goods_classify','SERVICE')
  29. ->whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
  30. ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
  31. ->first();
  32. $data['package'] = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
  33. ->where('goods.goods_classify','PACKAGE')
  34. ->whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
  35. ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
  36. ->first();
  37. return json_success('',$data);
  38. }
  39. }