|
@@ -9,7 +9,7 @@ use Dever;
|
|
class Pay
|
|
class Pay
|
|
{
|
|
{
|
|
# 发起支付
|
|
# 发起支付
|
|
- public function action($uid, $id, $sku, $num, $source)
|
|
|
|
|
|
+ public function action($parent_uid, $uid, $id, $sku, $num, $source, $type = false, $type_id = false)
|
|
{
|
|
{
|
|
if (!$uid) {
|
|
if (!$uid) {
|
|
Dever::alert('错误的用户信息');
|
|
Dever::alert('错误的用户信息');
|
|
@@ -43,6 +43,18 @@ class Pay
|
|
$account_id = 1;
|
|
$account_id = 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ($parent_uid) {
|
|
|
|
+ $order_data['parent_uid'] = $parent_uid;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($type) {
|
|
|
|
+ $order_data['type'] = $type;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($type_id) {
|
|
|
|
+ $order_data['type_id'] = $type_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
$order_data['uid'] = $uid;
|
|
$order_data['uid'] = $uid;
|
|
$order_data['status'] = 1;
|
|
$order_data['status'] = 1;
|
|
$order_data['info_id'] = $goods['id'];
|
|
$order_data['info_id'] = $goods['id'];
|
|
@@ -129,16 +141,17 @@ class Pay
|
|
}
|
|
}
|
|
|
|
|
|
# 增加积分
|
|
# 增加积分
|
|
- Dever::score($order['uid'], 'buy_goods', '购买商品');
|
|
|
|
|
|
+ if ($order['parent_uid'] > 0) {
|
|
|
|
+ $uid = $order['parent_uid'] . '_' . $order['uid']
|
|
|
|
+ } else {
|
|
|
|
+ $uid = $order['uid'];
|
|
|
|
+ }
|
|
|
|
+ Dever::score($uid, 'buy_my_goods', '购买自营商品', false, false, false, $order['type'], $order['type_id']);
|
|
|
|
|
|
# 发消息
|
|
# 发消息
|
|
if (Dever::project('message')) {
|
|
if (Dever::project('message')) {
|
|
Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功', 11);
|
|
Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功', 11);
|
|
}
|
|
}
|
|
-
|
|
|
|
- # 增加上级佣金
|
|
|
|
- $cash = $order['cash'] * $order['num'];
|
|
|
|
- $this->rebate($order['uid'], $order['info_id'], $cash);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -150,23 +163,6 @@ class Pay
|
|
return 'ok';
|
|
return 'ok';
|
|
}
|
|
}
|
|
|
|
|
|
- # 增加上级佣金
|
|
|
|
- public function rebate($uid, $goods_id, $cash)
|
|
|
|
- {
|
|
|
|
- $goods = Dever::db('goods/info')->one($goods_id);
|
|
|
|
- $rebate_id = $goods['rebate_id'];
|
|
|
|
- if ($rebate_id > 0) {
|
|
|
|
- $rebate = Dever::db('goods/rebate')->one($rebate_id);
|
|
|
|
- if ($rebate) {
|
|
|
|
- if ($rebate['type'] == 1) {
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
# 生成订单号
|
|
# 生成订单号
|
|
public function getOrderId()
|
|
public function getOrderId()
|
|
{
|
|
{
|