Commit ef6dc563 authored by wuxiaoli's avatar wuxiaoli

商家支付收仓库手续费

parent 52690032
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace Modules\Store\Listeners; namespace Modules\Store\Listeners;
use Illuminate\Support\Facades\Log;
use Modules\Member\Services\PolymerService;
use Modules\Store\Events\PaySuccess; use Modules\Store\Events\PaySuccess;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
...@@ -24,6 +26,50 @@ class PayBlance implements ShouldQueue{ ...@@ -24,6 +26,50 @@ class PayBlance implements ShouldQueue{
$order = $event->payment; $order = $event->payment;
$store = $order->store()->first(); $store = $order->store()->first();
//Log::info("分仓服务费".$store->balance_service_rate);
if($store->balance_service_rate > 0){//分仓服务费
$integral = $order->integral; //店主收入计算
$polymer_money = $order->polymer_money; //店主收入计算
//本金
$cost_money = bcdiv(($order->polymer_money + $order->amount),bcdiv(($store->balance_service_rate + 100),100,2),2);
//Log::info("分仓服务费本金".$cost_money);
//分仓服务费
$balance_service_amount = bcsub(($order->polymer_money + $order->amount), $cost_money, 2);
$amount = bcsub($order->amount, $balance_service_amount, 2); //店主收入计算
if($balance_service_amount > 0 && $store->service_id){
//Log::info("分仓服务费资金".$balance_service_amount);
app(AccountService::class)->createAccount(store_id: $store->id, order_id: $order->id, member_id: $store->service_id, type: 'service_income', account_type: 'payment', amount: $balance_service_amount, remark: '店铺收款分仓服务费');
}
}else{
$amount = $order->amount; //店主收入计算
$integral = $order->integral; //店主收入计算
$polymer_money = $order->polymer_money; //店主收入计算
}
//店主收入
if($amount > 0){
app(AccountService::class)->createAccount(store_id: $order->store_id, order_id: $order->id, member_id: $store->member_id, type: 'income', account_type: 'payment', amount: $amount, remark: '店铺内客户支付');
}
if($integral > 0){
app(ScoreService::class)->createScore(store_id: $store->id, order_id: $order->id, member_id: $store->member_id, amount: $integral, type: 'income', account_type: 'payment', remark: '店铺内客户支付');
}
if($polymer_money > 0){
app(PolymerService::class)->createPolymer(store_id: $store->id, order_id: $order->id, member_id: $store->member_id, type: 'income', account_type: 'payment', amount: $polymer_money, remark: '店铺内客户支付');
}
}
/**原始
* Handle the event.
*/
/*public function handle(PaySuccess $event){
$order = $event->payment;
$store = $order->store()->first();
if($store->invite_uid > 0){ if($store->invite_uid > 0){
$invite = Member::with(['level'])->where('uid', $store->invite_uid)->first(); $invite = Member::with(['level'])->where('uid', $store->invite_uid)->first();
...@@ -83,5 +129,5 @@ class PayBlance implements ShouldQueue{ ...@@ -83,5 +129,5 @@ class PayBlance implements ShouldQueue{
if($order->integral > 0){ if($order->integral > 0){
app(ScoreService::class)->createScore(store_id: $store->id, order_id: $order->id, member_id: $store->member_id, amount: $integral, type: 'income', account_type: 'payment', remark: '店铺内客户支付'); app(ScoreService::class)->createScore(store_id: $store->id, order_id: $order->id, member_id: $store->member_id, amount: $integral, type: 'income', account_type: 'payment', remark: '店铺内客户支付');
} }
} }*/
} }
\ No newline at end of file
...@@ -115,7 +115,6 @@ class PaymentService { ...@@ -115,7 +115,6 @@ class PaymentService {
if($payment->polymer_money > 0){//扣除聚物通资金 if($payment->polymer_money > 0){//扣除聚物通资金
app(\Modules\Member\Services\PolymerService::class)->createPolymer(store_id: $payment->store_id, order_id: $payment->id, member_id: $payment->member['uid'], type: 'pay', account_type: 'payment', amount: $payment->polymer_money, remark: '店铺支付'); app(\Modules\Member\Services\PolymerService::class)->createPolymer(store_id: $payment->store_id, order_id: $payment->id, member_id: $payment->member['uid'], type: 'pay', account_type: 'payment', amount: $payment->polymer_money, remark: '店铺支付');
app(\Modules\Member\Services\PolymerService::class)->createPolymer(store_id: $payment->store_id, order_id: $payment->id, member_id: $payment->store['member_id'], type: 'income', account_type: 'payment', amount: $payment->polymer_money, remark: '店铺内客户支付');
} }
$res = app(\Modules\Wechat\Services\PayService::class)->orderQuery($order_no); $res = app(\Modules\Wechat\Services\PayService::class)->orderQuery($order_no);
...@@ -131,6 +130,9 @@ class PaymentService { ...@@ -131,6 +130,9 @@ class PaymentService {
$payment->payment_status = 1; $payment->payment_status = 1;
$payment->payment_time = date('Y-m-d H:i:s'); $payment->payment_time = date('Y-m-d H:i:s');
$payment->save(); $payment->save();
if($payment->polymer_money > 0) {//入账聚物通资金
app(\Modules\Member\Services\PolymerService::class)->createPolymer(store_id: $payment->store_id, order_id: $payment->id, member_id: $payment->store['member_id'], type: 'income', account_type: 'payment', amount: $payment->polymer_money, remark: '店铺内客户支付');
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment