作者 王智

修改

... ... @@ -216,6 +216,7 @@ class Update extends Api
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="address_id", type="int", required=true, description="地址ID")
* @ApiParams (name="total", type="int", required=true, description="总价")
* @ApiParams (name="tick_id", type="int", required=true, description="优惠券id")
* @ApiParams (name="tick", type="int", required=true, description="1=使用优惠,0=不使用优惠")
* @ApiParams (name="water", type="int", required=true, description="1=使用氧气泡泡,0=不适用氧气泡泡")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
... ... @@ -243,26 +244,38 @@ class Update extends Api
$Tick = 0;
$Water = 0;
$YunPrice = 0;
if ($Parmas['tick'] == 1) {
//选择最优 优惠券
//查询用户所有优惠券
if($Parmas['tick_id']!=0){
$UserTickArray = Db::name('user_tick')
->alias('a')
->where('a.id',$Parmas['tick_id'])
->where('user_id', $UserId)
->where('a.status', 0)
->join('tick t', 't.id=a.tick_id')
->field('a.id,t.door,t.del_price')
->select();
if (!empty($UserTickArray)) {
$NewUserTickArray = [];
foreach ($UserTickArray as $key => $v) {
$NewUserTickArray[$key]['door'] = $v['door'];
}
array_multisort($NewUserTickArray, SORT_DESC, $UserTickArray);//SORT_DESC为降序,SORT_ASC为升序
foreach ($UserTickArray as $k => $v) {
if ($Parmas['total'] > $v['door'] || $Parmas['total'] == $v['door']) {
$Tick = $v['del_price'];
break;
->find();
$Tick=$UserTickArray['del_price'];
}else{
if ($Parmas['tick'] == 1) {
//选择最优 优惠券
//查询用户所有优惠券
$UserTickArray = Db::name('user_tick')
->alias('a')
->where('user_id', $UserId)
->where('a.status', 0)
->join('tick t', 't.id=a.tick_id')
->field('a.id,t.door,t.del_price')
->select();
if (!empty($UserTickArray)) {
$NewUserTickArray = [];
foreach ($UserTickArray as $key => $v) {
$NewUserTickArray[$key]['door'] = $v['door'];
}
array_multisort($NewUserTickArray, SORT_DESC, $UserTickArray);//SORT_DESC为降序,SORT_ASC为升序
foreach ($UserTickArray as $k => $v) {
if ($Parmas['total'] > $v['door'] || $Parmas['total'] == $v['door']) {
$Tick = $v['del_price'];
break;
}
}
}
}
... ...