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

修改可用优惠券接口

@@ -416,11 +416,12 @@ class Cars extends Api @@ -416,11 +416,12 @@ class Cars extends Api
416 $data = Common::selectWhereOrData('coupon',$where,$where1,$where2,'id,type,coupon_name,c_type,coupon_type,full_reduce,reduce,discount,coupon_number,end_time','sort desc,id desc'); 416 $data = Common::selectWhereOrData('coupon',$where,$where1,$where2,'id,type,coupon_name,c_type,coupon_type,full_reduce,reduce,discount,coupon_number,end_time','sort desc,id desc');
417 417
418 $res = []; 418 $res = [];
419 - foreach($data as $key=>$value){  
420 -  
421 - $res[$key]['id'] = $value['id']; 419 + $key = 0;
  420 + foreach($data as $value){
  421 + $key+=0;
422 //无门槛,有门槛 422 //无门槛,有门槛
423 if($value['c_type'] == 0){ 423 if($value['c_type'] == 0){
  424 + $res[$key]['id'] = $value['id'];
424 //无门槛 425 //无门槛
425 if($value['coupon_type'] == 0){ 426 if($value['coupon_type'] == 0){
426 //减少券,去掉满减金额,折扣字段, 427 //减少券,去掉满减金额,折扣字段,
@@ -443,9 +444,24 @@ class Cars extends Api @@ -443,9 +444,24 @@ class Cars extends Api
443 $res[$key]['is_discount'] = 1;//是否为折扣(0:否,1:是) 444 $res[$key]['is_discount'] = 1;//是否为折扣(0:否,1:是)
444 $res[$key]['price_tag'] = $value['discount']; 445 $res[$key]['price_tag'] = $value['discount'];
445 } 446 }
  447 + $res[$key]['coupon_name'] = $value['coupon_name'];//优惠券名称
  448 + $res[$key]['end_time'] = date('Y.n.j',$value['end_time']);//优惠券有效期
  449 + //全场,品牌,商品
  450 + if($value['type'] == 0){
  451 + $res[$key]['type'] = '全场通用';
  452 +
  453 + }else if($value['type'] == 1){
  454 + $res[$key]['type'] = '部分品牌可用';
  455 +
  456 + }else{
  457 + $res[$key]['type'] = '部分商品可用';
  458 +
  459 + }
  460 + $key++;
446 }else{ 461 }else{
447 //有门槛 462 //有门槛
448 if(($total_goods_price <=> $value['full_reduce']) >= 0){ 463 if(($total_goods_price <=> $value['full_reduce']) >= 0){
  464 + $res[$key]['id'] = $value['id'];
449 //商品总金额大于等于满减金额 465 //商品总金额大于等于满减金额
450 if($value['coupon_type'] == 0){ 466 if($value['coupon_type'] == 0){
451 //减少券,去掉折扣字段, 467 //减少券,去掉折扣字段,
@@ -466,21 +482,21 @@ class Cars extends Api @@ -466,21 +482,21 @@ class Cars extends Api
466 $res[$key]['is_discount'] = 1;//是否为折扣(0:否,1:是) 482 $res[$key]['is_discount'] = 1;//是否为折扣(0:否,1:是)
467 $res[$key]['price_tag'] = $value['discount']; 483 $res[$key]['price_tag'] = $value['discount'];
468 } 484 }
469 - }  
470 - }  
471 -  
472 - $res[$key]['coupon_name'] = $value['coupon_name'];//优惠券名称  
473 - $res[$key]['end_time'] = date('Y.n.j',$value['end_time']);//优惠券有效期  
474 - //全场,品牌,商品  
475 - if($value['type'] == 0){  
476 - $res[$key]['type'] = '全场通用'; 485 + $res[$key]['coupon_name'] = $value['coupon_name'];//优惠券名称
  486 + $res[$key]['end_time'] = date('Y.n.j',$value['end_time']);//优惠券有效期
  487 + //全场,品牌,商品
  488 + if($value['type'] == 0){
  489 + $res[$key]['type'] = '全场通用';
477 490
478 - }else if($value['type'] == 1){  
479 - $res[$key]['type'] = '部分品牌可用'; 491 + }else if($value['type'] == 1){
  492 + $res[$key]['type'] = '部分品牌可用';
480 493
481 - }else{  
482 - $res[$key]['type'] = '部分商品可用'; 494 + }else{
  495 + $res[$key]['type'] = '部分商品可用';
483 496
  497 + }
  498 + $key++;
  499 + }
484 } 500 }
485 } 501 }
486 502