feat: 修改支付通知逻辑以增加新的用户签到功能

This commit is contained in:
mkm 2024-06-18 09:21:17 +08:00
parent d43d26163f
commit 4292c80301

View File

@ -155,10 +155,10 @@ class PayNotifyLogic extends BaseLogic
$extra['create_time'] = $order['create_time'];
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
Redis::send('push-platform-print', ['id' => $order['id']]);
}
}
// else {
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
// }
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5);
@ -276,14 +276,13 @@ class PayNotifyLogic extends BaseLogic
if ($order->pay_type == 9) {
$order->status = 2;
self::afterPay($order);
}
if ($order->pay_type == 9) {
$extra['create_time'] = $order['create_time'];
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
Redis::send('push-platform-print', ['id' => $order['id']]);
}
}
// else {
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
// }
@ -298,6 +297,8 @@ class PayNotifyLogic extends BaseLogic
public static function afterPay($order, $transaction_id = 0)
{
$financeLogic = new StoreFinanceFlowLogic();
$user_sing = new UserSign();
$financeLogic->order = $order;
$financeLogic->user = ['uid' => $order['uid']];
// if ($order->pay_type != 9 || $order->pay_type != 10) {
@ -305,6 +306,15 @@ class PayNotifyLogic extends BaseLogic
$count_frees = 0;
//商户应该获得的钱 每个商品的price-ot_price 利润
// if (isset($order->profit) && $order->profit > 0) {
if($order['uid']>0){
$sing = [
'uid' => $order['uid'],
'title' => '购买商品获得兑换券',
'store_id' => $order['store_id'],
'number' => bcmul($order['pay_price'], '0.01', 2),
];
$user_sing->save($sing);
}
//平台手续费
$fees = bcdiv(bcmul($order['pay_price'], '0.02', 2), 1, 2);
@ -362,14 +372,14 @@ class PayNotifyLogic extends BaseLogic
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
if($village_uid){
if ($village_uid) {
User::where('id', $village_uid)->inc('integral', $fees)->update();
}
}
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
if ($arr2) {
$brigade_uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
if($brigade_uid){
if ($brigade_uid) {
User::where('id', $brigade_uid)->inc('integral', $fees)->update();
}
}
@ -377,23 +387,22 @@ class PayNotifyLogic extends BaseLogic
}
if ($fees > 0) {
//村长获得
$sing=[];
$user_sing=new UserSign();
$sing = [];
$sing[]=[
'uid'=>$village_uid,
'title'=>'村长订单获得兑换券',
'store_id'=>$order['store_id'],
'number'=>$fees,
$sing[] = [
'uid' => $village_uid,
'title' => '村长订单获得兑换券',
'store_id' => $order['store_id'],
'number' => $fees,
];
$sing[]=[
'uid'=>$brigade_uid,
'title'=>'队长订单获得兑换券',
'store_id'=>$order['store_id'],
'number'=>$fees,
$sing[] = [
'uid' => $brigade_uid,
'title' => '队长订单获得兑换券',
'store_id' => $order['store_id'],
'number' => $fees,
];
// if ($village_uid > 0) {
// $financeLogic->other_arr['vip_uid'] = $village_uid;
// $financeLogic->other_arr['vip_uid'] = $village_uid;
// }
// $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
// $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
@ -410,14 +419,13 @@ class PayNotifyLogic extends BaseLogic
$financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
}
}
$fees=bcsub($order['pay_price'], $count_frees, 2);
$fees = bcsub($order['pay_price'], $count_frees, 2);
//供应链订单获得
if ($fees > 0) {
$financeLogic->in($transaction_id,$fees , OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
}
// }
// }
$financeLogic->save();
// }
}