|
@@ -160,8 +160,18 @@ class Api extends Core
|
|
|
|
|
|
$this->data['card'] = Dever::db('card/code')->getPageData(array('dh_uid' => $this->uid));
|
|
|
|
|
|
+ $city = Dever::input('city');
|
|
|
+ if ($city) {
|
|
|
+ $county = Dever::db('area/county')->find($city);
|
|
|
+ if ($county) {
|
|
|
+ $city = $county['city_id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if ($this->data['card']) {
|
|
|
foreach ($this->data['card'] as $k => $v) {
|
|
|
+ $v['info'] = $this->data['card'][$k]['info'] = Dever::db('card/info')->find($v['card_id']);
|
|
|
+
|
|
|
if (!$v['total_cash']) {
|
|
|
$v['total_cash'] = $v['info']['value'];
|
|
|
}
|
|
@@ -169,8 +179,39 @@ class Api extends Core
|
|
|
$v['use_cash'] = 0;
|
|
|
}
|
|
|
$this->data['card'][$k]['cash'] = $v['total_cash'] - $v['use_cash'];
|
|
|
- $this->data['card'][$k]['info'] = Dever::db('card/info')->find($v['card_id']);
|
|
|
- $this->data['card'][$k]['type'] = Dever::db('card/type')->find($this->data['card'][$k]['info']['type_id']);
|
|
|
+
|
|
|
+ $info = $this->data['card'][$k]['type'] = Dever::db('card/type')->find($this->data['card'][$k]['info']['type_id']);
|
|
|
+
|
|
|
+ $this->data['card'][$k]['minfo'] = '';
|
|
|
+
|
|
|
+ if ($info['city_type'] == 2) {
|
|
|
+ $city = $v['city'];
|
|
|
+ if (!$city) {
|
|
|
+ $card_order = Dever::db('card/order_card')->find($v['order_card_id']);
|
|
|
+ if ($card_order && $card_order['city']) {
|
|
|
+ $city = $card_order['city'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($city) {
|
|
|
+ $city = Dever::db('area/city')->find($city);
|
|
|
+ if ($city) {
|
|
|
+ $this->data['card'][$k]['minfo'] = '仅限' . $city['name'] . '可用';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } elseif ($info['type'] == 1) {
|
|
|
+ $config_type = Dever::db('shop/info')->config['config_type'];
|
|
|
+ if ($info['shop_type'] && strstr($info['shop_type'], ',')) {
|
|
|
+ $this->data['card'][$k]['minfo'] = '全部店铺可用';
|
|
|
+ } elseif ($info['shop_type'] && isset($config_type[$info['shop_type']])) {
|
|
|
+ $this->data['card'][$k]['minfo'] = $config_type[$info['shop_type']] . '可用';
|
|
|
+ }
|
|
|
+ } elseif ($info['type'] == 2 && $v['shop_id']) {
|
|
|
+ $shop = Dever::db('shop/info')->find($v['shop_id']);
|
|
|
+ if ($shop) {
|
|
|
+ $this->data['card'][$k]['minfo'] = '限' . $shop['name'] . '可用';
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -184,11 +225,11 @@ class Api extends Core
|
|
|
$this->data['card_name'] = $config['card_name'];
|
|
|
|
|
|
$shop_type = $this->shop['type'];
|
|
|
- $city = Dever::input('city');
|
|
|
- if ($city) {
|
|
|
- $county = Dever::db('area/county')->find($city);
|
|
|
+ $cur_city = Dever::input('city');
|
|
|
+ if ($cur_city) {
|
|
|
+ $county = Dever::db('area/county')->find($cur_city);
|
|
|
if ($county) {
|
|
|
- $city = $county['city_id'];
|
|
|
+ $cur_city = $county['city_id'];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -216,11 +257,25 @@ class Api extends Core
|
|
|
if ($type['city_type'] == 1) {
|
|
|
$this->data['card'][] = $v;
|
|
|
} else {
|
|
|
+ $city = $v['city'];
|
|
|
+ if (!$city) {
|
|
|
+ $card_order = Dever::db('card/order_card')->find($v['order_card_id']);
|
|
|
+ if ($card_order && $card_order['city']) {
|
|
|
+ $city = $card_order['city'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($city && $city == $cur_city) {
|
|
|
+ $this->data['card'][] = $v;
|
|
|
+ }
|
|
|
+ /*
|
|
|
$type['city'] = explode(',', $type['city']);
|
|
|
if (in_array($city, $type['city'])) {
|
|
|
$this->data['card'][] = $v;
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
+ } elseif ($v['shop_id'] && $v['shop_id'] == $this->shop_id) {
|
|
|
+ $this->data['card'][] = $v;
|
|
|
}
|
|
|
}
|
|
|
}
|