Authored by hf

code review by fei.hong: do format coupon list codes

... ... @@ -464,36 +464,37 @@ class UserModel
public static function getCouponData($uid, $status, $page)
{
$result = array();
// 调用接口获取优惠券数据
$coupons = UserData::couponData($uid, $status, $page);
// 没有获取到优惠券时
if (!$coupons) {
$result['noRecord'] = true;
return $result;
}
// 处理优惠券数据
if (isset($coupons['data'])) {
// 不能再查到结果了
if ($page == 1 && $coupons['data']['total'] === 0) {
do {
// 调用接口获取优惠券数据
$coupons = UserData::couponData($uid, $status, $page);
// 没有获取到优惠券时
if (empty($coupons)) {
$result['noRecord'] = true;
} else {
$couponArr = array();
isset($coupons['data']['info']) && $couponArr = $coupons['data']['info'];
break;
}
foreach ($couponArr as &$val) {
// 处理已使用的优惠券
if ($status == 1) {
$val['used'] = true;
}
if ($page == 1 && isset($coupons['data']['total']) && $coupons['data']['total'] === 0) {
$result['noRecord'] = true;
break;
}
// 判断是否有优惠券
if (empty($coupons['data']['info'])) {
break;
}
// 处理已使用的优惠券
if ($status == 1) {
foreach ($coupons['data']['info'] as &$value) {
$value['used'] = true;
}
!empty($couponArr) && $result['coupons'] = $couponArr;
}
$result['coupons'] = $coupons['data']['info'];
}
while (false);
return $result;
}
... ...