|
@@ -160,24 +160,14 @@ class Api extends Core
|
|
Dever::alert('礼品卡卡号错误或礼品卡已兑换');
|
|
Dever::alert('礼品卡卡号错误或礼品卡已兑换');
|
|
}
|
|
}
|
|
|
|
|
|
- $info['info'] = Dever::db('card/info')->find($data['card_id']);
|
|
+ $check = Dever::load('card/lib/code')->check($data);
|
|
- if (!$info['info']) {
|
|
+ if ($check] == -1) {
|
|
Dever::alert('兑换失败,礼品卡已下架');
|
|
Dever::alert('兑换失败,礼品卡已下架');
|
|
- }
|
|
+ } elseif ($check == -2) {
|
|
- if ($info['info']['status'] == 2) {
|
|
|
|
Dever::alert('兑换失败,礼品卡已下架');
|
|
Dever::alert('兑换失败,礼品卡已下架');
|
|
- }
|
|
+ } elseif ($check == -3) {
|
|
-
|
|
+ Dever::alert('礼品卡已过兑换时间');
|
|
- if ($info['info']['end_dh_day'] && $info['info']['end_dh_day'] > 0) {
|
|
+ }
|
|
- $data['eddate'] = ($data['bdate'] ? $data['bdate'] : $data['cdate']) + ($info['info']['end_dh_day'] * 86400);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (isset($data['eddate']) && $data['eddate'] && $data['eddate'] > 0) {
|
|
|
|
- $time = time();
|
|
|
|
- if ($data['eddate'] <= $time) {
|
|
|
|
- Dever::alert('礼品卡已过兑换时间');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
$update['where_id'] = $data['id'];
|
|
$update['where_id'] = $data['id'];
|
|
$update['dh_uid'] = $this->uid;
|
|
$update['dh_uid'] = $this->uid;
|
|
@@ -240,37 +230,22 @@ class Api extends Core
|
|
$time = time();
|
|
$time = time();
|
|
if ($card) {
|
|
if ($card) {
|
|
foreach ($card as $k => $v) {
|
|
foreach ($card as $k => $v) {
|
|
- $v['info'] = $card[$k]['info'] = Dever::db('card/info')->find($v['card_id']);
|
|
+ $check = Dever::load('card/lib/code')->check($v);
|
|
-
|
|
+ if ($check < 0) {
|
|
- if (!$v['info']) {
|
|
|
|
- unset($card[$k]);
|
|
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if ($v['info']['end_dh_day'] && $v['info']['end_dh_day'] > 0) {
|
|
|
|
- $v['eddate'] = ($v['bdate'] ? $v['bdate'] : $v['cdate']) + ($v['info']['end_dh_day'] * 86400);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (isset($v['eddate']) && $v['eddate'] && $v['eddate'] > 0) {
|
|
|
|
- if ($v['eddate'] <= $time) {
|
|
|
|
- unset($card[$k]);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (!$v['total_cash']) {
|
|
if (!$v['total_cash']) {
|
|
$v['total_cash'] = $v['info']['value'];
|
|
$v['total_cash'] = $v['info']['value'];
|
|
}
|
|
}
|
|
if (!$v['use_cash']) {
|
|
if (!$v['use_cash']) {
|
|
$v['use_cash'] = 0;
|
|
$v['use_cash'] = 0;
|
|
}
|
|
}
|
|
- $card[$k]['cash'] = $v['total_cash'] - $v['use_cash'];
|
|
+ $v['cash'] = $v['total_cash'] - $v['use_cash'];
|
|
-
|
|
+ $v['type'] = Dever::db('card/type')->find($v['info']['type_id']);
|
|
- $info = $card[$k]['type'] = Dever::db('card/type')->find($card[$k]['info']['type_id']);
|
|
+ $v['minfo'] = '';
|
|
-
|
|
|
|
- $card[$k]['minfo'] = '';
|
|
|
|
|
|
|
|
- if ($info['city_type'] == 2) {
|
|
+ if ($v['type']['city_type'] == 2) {
|
|
$city = $v['city'];
|
|
$city = $v['city'];
|
|
if (!$city) {
|
|
if (!$city) {
|
|
$card_order = Dever::db('card/order_card')->find($v['order_card_id']);
|
|
$card_order = Dever::db('card/order_card')->find($v['order_card_id']);
|
|
@@ -282,46 +257,46 @@ class Api extends Core
|
|
if ($city) {
|
|
if ($city) {
|
|
$city = Dever::db('area/city')->find($city);
|
|
$city = Dever::db('area/city')->find($city);
|
|
if ($city) {
|
|
if ($city) {
|
|
- $card[$k]['minfo'] = '仅限' . $city['name'] . '可用';
|
|
+ $v['minfo'] = '仅限' . $city['name'] . '可用';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } elseif ($info['type'] == 2 && $v['shop_id']) {
|
|
+ } elseif ($v['type']['type'] == 2 && $v['shop_id']) {
|
|
$shop = Dever::db('shop/info')->find($v['shop_id']);
|
|
$shop = Dever::db('shop/info')->find($v['shop_id']);
|
|
if ($shop) {
|
|
if ($shop) {
|
|
- $card[$k]['minfo'] = '限' . $shop['name'] . '可用';
|
|
+ $v['minfo'] = '限' . $shop['name'] . '可用';
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
$config_type = Dever::db('shop/info')->config['config_type'];
|
|
$config_type = Dever::db('shop/info')->config['config_type'];
|
|
|
|
|
|
|
|
|
|
- $info['shop_type'] = explode(',', $info['shop_type']);
|
|
+ $v['type']['shop_type'] = explode(',', $v['type']['shop_type']);
|
|
- $card[$k]['minfo'] = array();
|
|
+ $v['minfo'] = array();
|
|
- foreach ($info['shop_type'] as $tv) {
|
|
+ foreach ($v['type']['shop_type'] as $tv) {
|
|
if (isset($config_type[$tv])) {
|
|
if (isset($config_type[$tv])) {
|
|
- $card[$k]['minfo'][] = $config_type[$tv];
|
|
+ $v['minfo'][] = $config_type[$tv];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $card[$k]['minfo'] = implode('、', $card[$k]['minfo']) . '可用';
|
|
+ $v['minfo'] = implode('、', $v['minfo']) . '可用';
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
- if ($info['shop_type'] && strstr($info['shop_type'], ',')) {
|
|
+ if ($v['type']['shop_type'] && strstr($v['type']['shop_type'], ',')) {
|
|
- $card[$k]['minfo'] = '多店铺可用';
|
|
+ $v['minfo'] = '多店铺可用';
|
|
- } elseif ($info['shop_type'] && isset($config_type[$info['shop_type']])) {
|
|
+ } elseif ($v['type']['shop_type'] && isset($config_type[$v['type']['shop_type']])) {
|
|
- $card[$k]['minfo'] = $config_type[$info['shop_type']] . '可用';
|
|
+ $v['minfo'] = $config_type[$v['type']['shop_type']] . '可用';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- $card[$k]['cinfo'] = '';
|
|
+ $v['cinfo'] = '';
|
|
if ($v['info']['category']) {
|
|
if ($v['info']['category']) {
|
|
- $card[$k]['cinfo'] = '限部分要求商品可用';
|
|
+ $v['cinfo'] = '限部分要求商品可用';
|
|
} else {
|
|
} else {
|
|
$goods = Dever::db('card/info_goods')->find(array('card_id' => $v['info']['id']));
|
|
$goods = Dever::db('card/info_goods')->find(array('card_id' => $v['info']['id']));
|
|
if ($goods) {
|
|
if ($goods) {
|
|
- $card[$k]['cinfo'] = '限部分要求商品可用';
|
|
+ $v['cinfo'] = '限部分要求商品可用';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $this->data['card'][] = $card[$k];
|
|
+ $this->data['card'][] = $v;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -360,19 +335,10 @@ class Api extends Core
|
|
if ($card) {
|
|
if ($card) {
|
|
$time = time();
|
|
$time = time();
|
|
foreach ($card as $k => $v) {
|
|
foreach ($card as $k => $v) {
|
|
- $v['info'] = Dever::db('card/info')->find($v['card_id']);
|
|
+ $check = Dever::load('card/lib/code')->check($v);
|
|
- if (!$v['info']) {
|
|
+ if ($check < 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if ($v['info']['end_dh_day'] && $v['info']['end_dh_day'] > 0) {
|
|
|
|
- $v['eddate'] = ($v['bdate'] ? $v['bdate'] : $v['cdate']) + ($v['info']['end_dh_day'] * 86400);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (isset($v['eddate']) && $v['eddate'] && $v['eddate'] > 0) {
|
|
|
|
- if ($v['eddate'] <= $time) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
if (!$v['total_cash']) {
|
|
if (!$v['total_cash']) {
|
|
$v['total_cash'] = $v['info']['value'];
|
|
$v['total_cash'] = $v['info']['value'];
|
|
}
|
|
}
|