作者 jinglong
1 个管道 的构建 通过 耗费 4 秒

修改我的优惠券列表

... ... @@ -74,17 +74,20 @@ class Common
*/
public static function selectWhereOrData($table,$where,$where1,$where2,$field,$order='id desc'){
$res = Db::name($table)
->where($where)
->where(function (Query $query) use ($where1, $where2) {
if(empty($where2)){
$query->where($where1);
}else{
$query->where($where1)->whereOr($where2);
->where(function(Query $query) use($where,$where1){
$query->where($where);
$query->where($where1);
})
->whereOr(function(Query $query) use($where,$where2){
if(!empty($where2)){
$query->where($where);
$query->where($where2);
}
})
->field($field)
->order($order)
->select();
// SELECT * FROM `ffg_coupon` WHERE (`id` IN (9,4) AND `end_time` > 1575427684 AND `bg_id` IN (2) AND `type` = 2 ) OR ( `id` IN (9,4) AND `end_time` > 1575427665 AND `bg_id` IN (1) AND `type` = 1 ) ORDER BY `c_type` ASC,`coupon_type` DESC
return $res;
}
... ...
... ... @@ -368,20 +368,21 @@ class User extends Api
//查询商品所属品牌id
$res1 = Common::selectSoftWhereData('goods',['id'=>['in',$goods_id_s],'type'=>$flag[1],],'id,t_id');
$b_id_s = array_unique(array_values(array_column($res1,'t_id')));
//包含品牌中的商品
if(!empty($b_id_s)){
$where2['bg_id'] = ['in',$b_id_s];
$where2['type'] = $type[1];
}else{
$where2 = [];
}
//包含品牌中的商品
//普通商品
$where1['bg_id'] = ['in',$goods_id_s];
$where1['type'] = $type[2];
$time = time();
$where['id'] = ['in',$receive_s];
$where['end_time'] = ['>',$time];
//普通商品
$where1['bg_id'] = ['in',$goods_id_s];
$where1['type'] = $type[2];
$data = Common::selectWhereOrData('coupon',$where,$where1,$where2,'id,type,coupon_name,c_type,coupon_type,full_reduce,reduce,discount,coupon_number,end_time','c_type asc,coupon_type desc');
}else{
$where['id'] = ['in',$receive_s];
... ...