|
@@ -173,6 +173,9 @@ class Sell
|
|
|
if (!$info['coupon_cash']) {
|
|
|
$info['coupon_cash'] = 0;
|
|
|
}
|
|
|
+ if (!$info['discount_cash']) {
|
|
|
+ $info['discount_cash'] = 0;
|
|
|
+ }
|
|
|
if (!$info['refund_cash']) {
|
|
|
$info['refund_cash'] = 0;
|
|
|
}
|
|
@@ -821,6 +824,13 @@ class Sell
|
|
|
$data['num'] = 0;
|
|
|
$data['name'] = array();
|
|
|
$count = count($goods_id);
|
|
|
+
|
|
|
+ # 获取角色
|
|
|
+ $role = $this->getRole($data);
|
|
|
+ $data['discount_goods'] = array();
|
|
|
+ $data['discount_cash'] = 0;
|
|
|
+ $data['discount_id'] = 0;
|
|
|
+
|
|
|
# 计算总价格
|
|
|
foreach ($goods_id as $k => $v) {
|
|
|
$s = isset($sku_id[$k]) ? $sku_id[$k] : -1;
|
|
@@ -860,6 +870,30 @@ class Sell
|
|
|
if ($data['list'][$k]['ku_state'] == 1) {
|
|
|
$data['list'][$k]['buy_num'] = $n;
|
|
|
$data['num'] += $n;
|
|
|
+
|
|
|
+ # 根据角色设置折扣
|
|
|
+ if ($role) {
|
|
|
+ $role_state = false;
|
|
|
+ $discount_goods = Dever::db('act/discount_goods')->getData(array('discount_id' => $role['id']));
|
|
|
+ if ($discount_goods) {
|
|
|
+ $discount_goods = array_keys($discount_goods);
|
|
|
+ if (in_array($data['list'][$k]['id'], $discount_goods)) {
|
|
|
+ $role_state = true;
|
|
|
+ }
|
|
|
+ } elseif ($role['category'] && in_array($data['list'][$k]['top_category_id'], $role['category'])) {
|
|
|
+ $role_state = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($role_state) {
|
|
|
+ $discount_cash = round($data['list'][$k]['price'] * ($role['num']/10), 2);
|
|
|
+ $data['list'][$k]['discount_id'] = $role['id'];
|
|
|
+ $data['discount_goods'][] = $data['list'][$k];
|
|
|
+ $data['discount_id'] = $role['id'];
|
|
|
+ $data['list'][$k]['discount_cash'] = ($data['list'][$k]['price'] - $data['list'][$k]['discount_cash']) * $n;
|
|
|
+ $data['discount_cash'] += $data['list'][$k]['discount_cash'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$data['price'] += $data['list'][$k]['price'] * $n;
|
|
|
$data['name'][] = $data['list'][$k]['name'];
|
|
|
}
|
|
@@ -882,8 +916,16 @@ class Sell
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ public function getRole($data)
|
|
|
+ {
|
|
|
+ if(isset($data['uid']) && $data['uid'] > 0) {
|
|
|
+ return Dever::load('shop/lib/info')->getRole($data['uid']);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
# 发起支付
|
|
|
- public function pay($method, $pay_method, $pay_type, $user, $shop, $name, $num, $goods, $oprice, $price, $cash, $address_id, $invoice_id, $info, $card, $wallet_cash, $coupon_id, $user_coupon_id, $coupon_cash, $cart = false, $system_source = 5, $refer = '')
|
|
|
+ public function pay($method, $pay_method, $pay_type, $user, $shop, $name, $num, $goods, $oprice, $price, $cash, $address_id, $invoice_id, $info, $card, $wallet_cash, $coupon_id, $user_coupon_id, $coupon_cash, $discount_id, $discount_cash, $cart = false, $system_source = 5, $refer = '')
|
|
|
{
|
|
|
if (!$user) {
|
|
|
Dever::alert('错误的用户信息');
|
|
@@ -954,6 +996,13 @@ class Sell
|
|
|
$order_data['coupon_cash'] = $coupon_cash;
|
|
|
}
|
|
|
|
|
|
+ if ($discount_id) {
|
|
|
+ $order_data['discount_id'] = $discount_id;
|
|
|
+ }
|
|
|
+ if ($discount_cash) {
|
|
|
+ $order_data['discount_cash'] = $discount_cash;
|
|
|
+ }
|
|
|
+
|
|
|
$order_data['order_num'] = $this->getOrderId();
|
|
|
$id = Dever::db('shop/sell_order')->insert($order_data);
|
|
|
|
|
@@ -983,6 +1032,14 @@ class Sell
|
|
|
$data['coupon_cash'] = 0;
|
|
|
}
|
|
|
|
|
|
+ if (isset($v['discount_id']) && $v['discount_id']) {
|
|
|
+ $data['discount_id'] = $v['discount_id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($v['discount_cash']) && $v['discount_cash']) {
|
|
|
+ $data['discount_cash'] = $v['discount_cash'];
|
|
|
+ }
|
|
|
+
|
|
|
Dever::db('shop/sell_order_goods')->insert($data);
|
|
|
}
|
|
|
}
|
|
@@ -1480,6 +1537,10 @@ class Sell
|
|
|
$info['coupon_cash'] = 0;
|
|
|
}
|
|
|
|
|
|
+ if (!$info['discount_cash']) {
|
|
|
+ $info['discount_cash'] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
if (!$info['kou_cash']) {
|
|
|
$info['kou_cash'] = 0;
|
|
|
}
|
|
@@ -1576,6 +1637,7 @@ class Sell
|
|
|
array('礼品卡抵扣', '¥ ' . round($info['card_code_cash'], 2) . $info['card']),
|
|
|
array('钱包抵扣', '¥ ' . round($info['wallet_cash'], 2)),
|
|
|
array('抹零', '¥ ' . round($info['kou_cash'], 2)),
|
|
|
+ array('代理优惠', '¥ ' . round($info['discount_cash'], 2)),
|
|
|
),
|
|
|
|
|
|
$time,
|