|
@@ -165,7 +165,7 @@ class Api extends Core
|
|
$where['type_id'] = $data['card_id'];
|
|
$where['type_id'] = $data['card_id'];
|
|
$agent = Dever::db('agent/member_goods')->find($where);
|
|
$agent = Dever::db('agent/member_goods')->find($where);
|
|
if ($agent) {
|
|
if ($agent) {
|
|
- Dever::db('agent/member_goods')->update(array('where_id' => $agent['id'], 'sell_num' => $agent['total_num']))
|
|
|
|
|
|
+ Dever::db('agent/member_goods')->update(array('where_id' => $agent['id'], 'sell_num' => $agent['total_num']));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -273,16 +273,8 @@ class Api extends Core
|
|
# 对商品进行处理
|
|
# 对商品进行处理
|
|
$goods_id = Dever::input('goods_id');
|
|
$goods_id = Dever::input('goods_id');
|
|
if ($goods_id) {
|
|
if ($goods_id) {
|
|
- $goods_id = explode(',', $goods_id);
|
|
|
|
- $sku_id = Dever::input('price_id');
|
|
|
|
- if ($sku_id) {
|
|
|
|
- $sku_id = explode(',', $sku_id);
|
|
|
|
- }
|
|
|
|
- $num = Dever::input('num');
|
|
|
|
- if (!$num) {
|
|
|
|
- Dever::alert('请传入商品数量');
|
|
|
|
- }
|
|
|
|
- $num = explode(',', $num);
|
|
|
|
|
|
+ $data = array();
|
|
|
|
+ Dever::load('shop/lib/sell')->goods($data);
|
|
}
|
|
}
|
|
|
|
|
|
$config = Dever::db('main/sell_config')->find();
|
|
$config = Dever::db('main/sell_config')->find();
|
|
@@ -315,7 +307,58 @@ class Api extends Core
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
# 验证是否符合当前商品
|
|
# 验证是否符合当前商品
|
|
-
|
|
|
|
|
|
+ $card_goods = array();
|
|
|
|
+ $check = false;
|
|
|
|
+ $goods = Dever::db('card/info_goods')->getData(array('card_id' => $v['info']['id']));
|
|
|
|
+ if ($goods || $v['info']['category']) {
|
|
|
|
+ $check = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($check) {
|
|
|
|
+ $price = 0;
|
|
|
|
+ $v['info']['category'] = explode(',', $v['info']['category']);
|
|
|
|
+ if ($goods) {
|
|
|
|
+ $goods = array_keys($goods);
|
|
|
|
+ }
|
|
|
|
+ # 检测当前商品是否符合该卡的限制
|
|
|
|
+ foreach ($data['list'] as $k => $v) {
|
|
|
|
+ if (!isset($v['cash'])) {
|
|
|
|
+ $v['cash'] = $v['price'];
|
|
|
|
+ }
|
|
|
|
+ if ($goods) {
|
|
|
|
+ if (in_array($v['id'], $goods)) {
|
|
|
|
+ $price += ($v['cash'] * $v['num']);
|
|
|
|
+ $card_goods[] = $v;
|
|
|
|
+ }
|
|
|
|
+ } elseif ($card_info['category']) {
|
|
|
|
+ if (in_array($v['top_category_id'], $card_info['category'])) {
|
|
|
|
+ $price += ($v['cash'] * $v['num']);
|
|
|
|
+ $card_goods[] = $v;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $price = $data['price'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($v['info']['min'] > 0 && $price < $v['info']['min']) {
|
|
|
|
+ # 不满足限额 不可用
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
|
|
|
+ $data['card'] = array();
|
|
|
|
+ $data['card']['goods'] = $card_goods;
|
|
|
|
+ $data['card']['id'] = $check['id'];
|
|
|
|
+ $data['card']['card'] = $check['card'];
|
|
|
|
+ if ($card_cash >= $price) {
|
|
|
|
+ $data['card']['cash'] = $price;
|
|
|
|
+ $data['price'] = 0;
|
|
|
|
+ } else {
|
|
|
|
+ $data['card']['cash'] = $card_cash;
|
|
|
|
+ $data['price'] -= $data['card']['cash'];
|
|
|
|
+ }
|
|
|
|
+ $data['card']['cash'] = round($data['card']['cash'], 2);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
$v['type'] = $type = Dever::db('card/type')->find($v['info']['type_id']);
|
|
$v['type'] = $type = Dever::db('card/type')->find($v['info']['type_id']);
|
|
|
|
|