多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
多个条件并行查询 ~~~ //已完成 $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 ) ~~~