我需要做出一个json看起来像这样的结果{"data":[ {"id":2, "name":"miles", "email":"sb-o8c47x137031@personal.example.com", "details":{ "id":11, "product_id":"product-003","purchase_rebate":2, "purchase_rebate_date":"2019-09-10 23:07:33", "survey_ans_rebate":2,"survey_ans_rebate_date":"2019-09-10 23:07:33", "created_at":"2019-09-10 23:07:33","updated_at":"2019-09-10 23:07:33" }, }, {"id":3, "name":"Jayson", "email":"sb-rv9me150874@personal.example.com", "details":{ "id":13, "product_id":"product-010", "purchase_rebate":2, "purchase_rebate_date":"2019-09-11 04:26:24", "survey_ans_rebate":2, "survey_ans_rebate_date":"2019-09-11 04:26:24", "created_at":"2019-09-11 04:26:24", "updated_at":"2019-09-11 04:26:24"} } ]}这是我的服务器端 PHP 脚本$get_merchant_users = DB::table('merchant_users as a') ->leftjoin('user_transactions as b', 'b.email','=','a.email') ->select('a.id','a.name',DB::raw('SUM(b.purchase_rebate) + SUM(b.survey_ans_rebate) as total'),'a.email') ->groupBy('a.id','a.name','a.email') ->get(); $details = DB::table('user_transactions') ->select('*') ->get(); $data = array('data'=> $get_merchant_users,'details'=> $details); return $data;
目前暂无任何回答
- 0 回答
- 0 关注
- 131 浏览
添加回答
举报
0/150
提交
取消