123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\admin\controller\finance;
- use app\model\OrderSheet;
- use support\Request;
- class GoodsSalesController{
- public function list(Request $request)
- {
- $rows = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
- ->leftJoin('goods_sku','goods_sku.join_sku_goods_id','=','order_sheet.join_sheet_goods_id')
- ->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')
- ->orderBy('order_sheet_addtimes','DESC')
- ->groupBy('goods_flag')
- ->get();
- dump($rows);
- return json_success('');
- }
- public function statistics()
- {
-
- $data['total'] = OrderSheet::whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
- ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
- ->first();
- $data['entity'] = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
- ->where('goods.goods_classify','GOODS')
- ->whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
- ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
- ->first();
- $data['service'] = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
- ->where('goods.goods_classify','SERVICE')
- ->whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
- ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
- ->first();
- $data['package'] = OrderSheet::leftJoin('goods','goods.goods_id','=','order_sheet.join_sheet_goods_id')
- ->where('goods.goods_classify','PACKAGE')
- ->whereIn('order_sheet_status',['PENDING','NOSTOCK','WAITING','ENDING','RECVING','SIGNED','CONFIRM','DONE'])
- ->selectRaw("SUM(order_sheet_pay) as pay_amount ,SUM(order_sheet_num) as goods_amount")
- ->first();
- return json_success('',$data);
- }
- }
|