ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
多个条件并行查询 ~~~ //已完成 $where1 = [ 'user_id' => ['in',$childUserIdArr], 'prom_type' => ['<',5], 'order_status' => 4 ]; //待收货 $where2 = [ 'user_id' => ['in',$childUserIdArr], 'prom_type' => ['<',5], 'order_status' => 1 , 'shipping_status' => 1 ]; //待发货 $where3 = [ 'user_id' => ['in',$childUserIdArr], 'prom_type' => ['<',5], 'order_status' => ['in',[0,1]] , 'shipping_status' => ['neq',1] , 'pay_status' => 1 , ]; $totalAmount = $orderModel ->whereOr(function ($query) use ($where1){ $query->where($where1); }) ->whereOr(function ($query) use ($where2){ $query->where($where2); }) ->whereOr(function ($query) use ($where3){ $query->where($where3); }) ->sum('total_amount'); 生成的sql:SELECT * FROM `tp_order` WHERE ( `user_id` IN (4,3,2,11,10,9,8,7,6,5) AND `prom_type` < 5 AND `order_status` = 4 ) OR ( `user_id` IN (4,3,2,11,10,9,8,7,6,5) AND `prom_type` < 5 AND `order_status` = 1 AND `shipping_status` = 1 ) OR ( `user_id` IN (4,3,2,11,10,9,8,7,6,5) AND `prom_type` < 5 AND `order_status` IN (0,1) AND `shipping_status` <> 1 AND `pay_status` = 1 ) ~~~