|
@@ -81,6 +81,7 @@ class PaymentReceived extends BaseModel
|
|
|
$paid = 1;
|
|
$paid = 1;
|
|
|
$pay_time = time();
|
|
$pay_time = time();
|
|
|
$transfer = bcdiv(bcmul($amount, sys_config('pay_collection_commission'), 2), 100, 2);
|
|
$transfer = bcdiv(bcmul($amount, sys_config('pay_collection_commission'), 2), 100, 2);
|
|
|
|
|
+ $recommend = bcdiv(bcmul($amount, sys_config('pay_collection_recommend'), 2), 100, 2);
|
|
|
$service_charge = $transfer;
|
|
$service_charge = $transfer;
|
|
|
$res = self::create(compact('pay_type', 'pay_uid', 'code', 'collect_uid', 'amount', 'order_id', 'add_time', 'paid', 'pay_time', 'service_charge', 'type'));
|
|
$res = self::create(compact('pay_type', 'pay_uid', 'code', 'collect_uid', 'amount', 'order_id', 'add_time', 'paid', 'pay_time', 'service_charge', 'type'));
|
|
|
if ($res) {
|
|
if ($res) {
|
|
@@ -91,9 +92,14 @@ class PaymentReceived extends BaseModel
|
|
|
$str = sprintf("收到%s用户%.2f%s,到账:%.2f%s,手续费:%.2f", $pay_user['nickname'], $amount, $title, $now_money, $title, $transfer);
|
|
$str = sprintf("收到%s用户%.2f%s,到账:%.2f%s,手续费:%.2f", $pay_user['nickname'], $amount, $title, $now_money, $title, $transfer);
|
|
|
$res1 = UserBill::income('扫码收款-' . $title, $collect_uid, 'now_money', 'qr_add_' . $field, $now_money, $res['id'], bcadd($collect_user[$field], $now_money, 2), $str);
|
|
$res1 = UserBill::income('扫码收款-' . $title, $collect_uid, 'now_money', 'qr_add_' . $field, $now_money, $res['id'], bcadd($collect_user[$field], $now_money, 2), $str);
|
|
|
$res2 = UserBill::expend("扫码付款-" . $title, $pay_uid, 'now_money', 'qr_des_' . $field, $amount, $res['id'], bcsub($pay_user[$field], $amount, 2), '支付给' . $collect_user['nickname'] . $amount . $title, 1);
|
|
$res2 = UserBill::expend("扫码付款-" . $title, $pay_uid, 'now_money', 'qr_des_' . $field, $amount, $res['id'], bcsub($pay_user[$field], $amount, 2), '支付给' . $collect_user['nickname'] . $amount . $title, 1);
|
|
|
-
|
|
|
|
|
|
|
+ $spread = User::get($collect_user['m_spread_uid']);
|
|
|
|
|
+ $res3 = true;
|
|
|
|
|
+ if ($spread && $recommend > 0) {
|
|
|
|
|
+ User::where('uid', $spread['uid'])->inc($field, $recommend)->update();
|
|
|
|
|
+ $res3 = UserBill::income("扫码付款推荐奖-" . $title, $spread['uid'], 'now_money', 'qr_recommend_' . $field, $recommend, $res['id'], bcadd($spread[$field], $recommend, 2), '推荐用户收款' . $title . '获得推荐奖', 1);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if ($res && $res1 && $res2) {
|
|
|
|
|
|
|
+ if ($res && $res1 && $res2 && $res3) {
|
|
|
self::commitTrans();
|
|
self::commitTrans();
|
|
|
} else {
|
|
} else {
|
|
|
self::rollbackTrans();
|
|
self::rollbackTrans();
|