|
@@ -249,7 +249,7 @@ class Pay
|
|
$this->order['name'] = implode('、', $this->order['name']);
|
|
$this->order['name'] = implode('、', $this->order['name']);
|
|
}
|
|
}
|
|
$this->order['order_num'] = Dever::load(\Api\Lib\Util::class)->createNumber($prefix, $table);
|
|
$this->order['order_num'] = Dever::load(\Api\Lib\Util::class)->createNumber($prefix, $table);
|
|
- $this->order['notify'] = $table . '/pay.notify|' . $this->place->sector['id'] . '|' . $this->place->info['id'] . '|' . $this->order['order_num'];
|
|
|
|
|
|
+ $this->order['notify'] = 'Porder/Lib/Notify.handle|' . $this->place->sector['id'] . '|' . $this->place->info['id'] . '|' . $this->type . '|' . $this->order['order_num'];
|
|
$this->order['buy_info'] = Dever::input('remark');
|
|
$this->order['buy_info'] = Dever::input('remark');
|
|
|
|
|
|
$this->check();
|
|
$this->check();
|
|
@@ -258,9 +258,9 @@ class Pay
|
|
if ($this->order['pay_money_cash'] > 0) {
|
|
if ($this->order['pay_money_cash'] > 0) {
|
|
$result['pay'] = Dever::load(\Place\Lib\Account::class)->pay($this->order);
|
|
$result['pay'] = Dever::load(\Place\Lib\Account::class)->pay($this->order);
|
|
if (isset($result['pay']['link']) && $result['pay']['link']) {
|
|
if (isset($result['pay']['link']) && $result['pay']['link']) {
|
|
- //return $result;
|
|
|
|
|
|
+ return $result;
|
|
}
|
|
}
|
|
- $result['pay'] = true;
|
|
|
|
|
|
+ //$result['pay'] = true;
|
|
} else {
|
|
} else {
|
|
$result['pay'] = true;
|
|
$result['pay'] = true;
|
|
}
|
|
}
|
|
@@ -270,7 +270,7 @@ class Pay
|
|
$result['order_num'] = $this->order['order_num'];
|
|
$result['order_num'] = $this->order['order_num'];
|
|
$this->success($result['order_id']);
|
|
$this->success($result['order_id']);
|
|
if ($result['pay'] === true) {
|
|
if ($result['pay'] === true) {
|
|
- $this->notify($this->place->sector['id'], $this->place->info['id'], $result['order_num'], 1);
|
|
|
|
|
|
+ Dever::load(\Porder\Lib\Notify::class)->notify_end($this->place->sector['id'], $this->place->info['id'], $this->type, $result['order_num'], 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -341,109 +341,4 @@ class Pay
|
|
# 设置活跃
|
|
# 设置活跃
|
|
Dever::db('place/code')->update(['code' => $this->place->code], ['status' => 1]);
|
|
Dever::db('place/code')->update(['code' => $this->place->code], ['status' => 1]);
|
|
}
|
|
}
|
|
-
|
|
|
|
- # 支付回调
|
|
|
|
- public function notify($sector_id, $place_id, $order_num, $status, $body = [])
|
|
|
|
- {
|
|
|
|
- //Dever::input('authorization', 'is_string', '访问码', $place);
|
|
|
|
- //Dever::input('authorization', 'set', $place);
|
|
|
|
- Dever::load(\Manage\Lib\Util::class)->setAuth('sector', 'sector_place', $sector_id, $place_id);
|
|
|
|
- $order = Dever::db('porder/' . $this->type)->find(['order_num' => $order_num]);
|
|
|
|
- if ($order && $order['status'] == 1) {
|
|
|
|
- if ($status == 1) {
|
|
|
|
- # 抵扣
|
|
|
|
- $this->deduct($order);
|
|
|
|
- }
|
|
|
|
- $this->callback($order, $status);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- # 抵扣
|
|
|
|
- private function deduct($order)
|
|
|
|
- {
|
|
|
|
- # 使用优惠券
|
|
|
|
- if (isset($order['user_coupon_id']) && $order['user_coupon_id'] > 0) {
|
|
|
|
- Dever::load(\Puser\Lib\Coupon::class)->use($this->type, $order, $this->set['score']);
|
|
|
|
- }
|
|
|
|
- # 使用礼品卡
|
|
|
|
- if (isset($order['user_gift_id']) && $order['user_gift_id'] > 0) {
|
|
|
|
- Dever::load(\Puser\Lib\Gift::class)->use($this->type, $order, $this->set['score']);
|
|
|
|
- }
|
|
|
|
- # 使用钱包支付
|
|
|
|
- if (isset($order['wallet_cash']) && $order['wallet_cash'] > 0) {
|
|
|
|
- $name = Dever::db('porder/' . $this->type . '_detail')->columns(['order_id' => $order['id']], 'name');
|
|
|
|
- Dever::load(\Pscore\Lib\Log::class)->action('购买', $order['score_id'])->add($order['uid'], implode('、', $name), $order['wallet_cash']*-1);
|
|
|
|
- }
|
|
|
|
- # 返利
|
|
|
|
- $rebate = Dever::db('porder/rebate')->select(['table' => $this->type, 'table_id' => $order['id']]);
|
|
|
|
- if ($rebate) {
|
|
|
|
- $status = 1;
|
|
|
|
- if ($this->type == 'source') {
|
|
|
|
- $status = 2;
|
|
|
|
- }
|
|
|
|
- foreach ($rebate as $k => $v) {
|
|
|
|
- if ($v['level'] == 0) {
|
|
|
|
- # 给自己返利
|
|
|
|
- Dever::load(\Pscore\Lib\Log::class)->action('返利', $v['score_id'])->add($order['uid'], $v['name'], $v['value'], $status, $this->type . '_order_' . $order['id']);
|
|
|
|
- } else {
|
|
|
|
- # 给上级返利
|
|
|
|
- $parent = Dever::load(\Invite\Lib\Relation::class)->getParent($order['uid'], $v['level']);
|
|
|
|
- if ($parent) {
|
|
|
|
- Dever::load(\Pscore\Lib\Log::class)->action('返利', $v['score_id'])->add($parent['uid'], $v['name'], $v['value'], $status, $this->type . '_order_' . $order['id']);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function sales($order, $type = 'source')
|
|
|
|
- {
|
|
|
|
- # 发放销售渠道收益
|
|
|
|
- if ($order['sales_type'] && $order['sales_id']) {
|
|
|
|
- $sales = Dever::load(\Psales\Lib\Info::class)->get($order['sales_type'], $order['sales_id']);
|
|
|
|
- if ($sales && $sales['uid']) {
|
|
|
|
- $benefit = Dever::db('pbenefit/sales')->find(['sales_cate_id' => $sales['cate_id'], 'status' => 1]);
|
|
|
|
- if ($benefit && $benefit['score_id']) {
|
|
|
|
- # 平台发货
|
|
|
|
- $table = 'sales_rebate_platform';
|
|
|
|
- if (isset($order['method']) && $order['method'] >= 2) {
|
|
|
|
- # 店铺发货
|
|
|
|
- $table = 'sales_rebate';
|
|
|
|
- }
|
|
|
|
- $rebate = Dever::db('pbenefit/' . $table)->select(['sales_id' => $benefit['id']]);
|
|
|
|
- if ($rebate) {
|
|
|
|
- $detail = Dever::db('porder/' . $type . '_detail')->select(['order_id' => $order['id']]);
|
|
|
|
- $score = Dever::load(\Pscore\Lib\Info::class)->get($order['score_id']);
|
|
|
|
- foreach ($rebate as $k => $v) {
|
|
|
|
- # 先检测购买人等级
|
|
|
|
- if ($v['role']) {
|
|
|
|
- $t = explode(',', $v['role']);
|
|
|
|
- $check = Dever::load(\Prole\Lib\User::class)->check($order['uid'], $t[0], $t[1]);
|
|
|
|
- if (!$check) {
|
|
|
|
- unset($rebate[$k]);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $value = 0;
|
|
|
|
- foreach ($detail as $k => $v) {
|
|
|
|
- if ($v['pay_cash'] > 0) {
|
|
|
|
- if (isset($v['refund_cash']) && $v['refund_cash'] > 0) {
|
|
|
|
- $v['pay_cash'] -= $v['refund_cash'];
|
|
|
|
- }
|
|
|
|
- if ($v['pay_cash'] > 0) {
|
|
|
|
- $money = Dever::math('mul', $v['pay_cash'], $score['exp']);
|
|
|
|
- $value += Dever::load(\Pbenefit\Lib\Item::class)->load('sales')->rebate($order['uid'], $v['scope'], $v['promotion_id'], $rebate, $money);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if ($value > 0) {
|
|
|
|
- # 给关联用户发收益
|
|
|
|
- Dever::load(\Pscore\Lib\Log::class)->action('店铺收益', $benefit['score_id'])->add($sales['uid'], $sales['name'] . '订单:' . $order['order_num'], $value, 1, $type . '_order_' . $order['id'], $order['sales_type'], $order['sales_id']);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|