| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -14,8 +14,10 @@ use App\Models\OrderProductItem; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Models\User; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Common\OrderStatus; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Service\SmsService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Service\WithdrawalService; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Traits\DemandTraits; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Traits\SmsTraits; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use App\Traits\StatementTraits; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use EasyWeChat\Factory; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Support\Facades\DB; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					use Illuminate\Support\Facades\Storage; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -40,12 +42,12 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->error('订单不存在或订单状态不允许核销'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//$mobile = User::where('id', $this->user_id)->value('mobile');
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//$checkMobile = Product::query()->whereIn('id', explode(',', $order->product_ids))->where('verify_mobile', $mobile)->doesntExist();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//if ($checkMobile) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//	return $this->error('对不起,你没有核销权限,请联系管理员');
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							//}
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$mobile = User::where('id', $this->user_id)->value('mobile'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$checkMobile = Product::query()->whereIn('id', explode(',', $order->product_ids))->where('verify_mobile', $mobile)->doesntExist(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($checkMobile) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								return $this->error('对不起,你没有核销权限,请联系管理员'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$order->status = OrderStatus::SUCCESS; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							if ($order->save()) { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -72,6 +74,7 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						public function fund($order) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
						{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							$service = new WithdrawalService(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							DB::beginTransaction(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
							try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//最后批量插入
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -82,13 +85,14 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$guidePrice = $order->guide_price; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$cost = bcadd($cost, $order->guide_price, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									//成本价 加上地接价格
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'price' => $order->guide_price, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'type' => StatementType::ORDER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_id' => $order->guide->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_type' => DemandTraits::$col[2], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->guide_price, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementType::ORDER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->guide->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										DemandTraits::$col[2], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									//抽成
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if ($order->guide->rate > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//计算抽成金额
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -96,21 +100,22 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$cutPrice = $guideCut > 0 ? bcdiv($guideCut, 100, 6) : 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//总后台抽成流水
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										if ($cutPrice > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$adminCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'price' => $cutPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'type' => StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'cut_user_id' => $order->guide->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'cut_user_type' => DemandTraits::$col[2], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$adminCreate[] = $service->createByOrderFormAdmin( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$cutPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->guide->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												DemandTraits::$col[2], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											//地接被抽成流水
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'price' => bcmul($cutPrice, -1, 2), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'type' => StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'user_id' => $order->guide->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'user_type' => DemandTraits::$col[2], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												bcmul($cutPrice, -1, 2), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->guide->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												DemandTraits::$col[2], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$guidePrice = bcsub($order->guide_price, $cutPrice, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$guide = Guide::query()->where('id', $order->guide->id)->lockForUpdate()->first(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$guide->balance = bcadd($guide->balance, $guidePrice, 6); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -131,13 +136,14 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$cost = bcadd($cost, $v->sum_price, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$supplierPrice = $v->sum_price; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'price' => $v->sum_price, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'type' => StatementType::ORDER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_id' => $v->supplier_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_type' => DemandTraits::$col[1], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$v->sum_price, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementType::ORDER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$v->supplier_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										DemandTraits::$col[1], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if ($v->supplier->rate > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//计算抽成金额
 | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -145,21 +151,22 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$cutPrice = $supplierCut > 0 ? bcdiv($supplierCut, 100, 6) : 0; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										if ($cutPrice > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											//总后台抽成流水
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$adminCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'price' => $cutPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'type' => StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'cut_user_id' => $v->supplier_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'cut_user_type' => DemandTraits::$col[1], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$adminCreate[] = $service->createByOrderFormAdmin( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$cutPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$v->supplier_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												DemandTraits::$col[1], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											//供应商被抽成流水
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'price' => bcmul($cutPrice, -1, 6), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'type' => StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'user_id' => $v->supplier_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'user_type' => DemandTraits::$col[1], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												bcmul($cutPrice, -1, 6), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$v->supplier_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												DemandTraits::$col[1], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$supplierPrice = bcsub($supplierPrice, $cutPrice, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										} | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -174,13 +181,14 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								$agentPrice = bcsub($order->price, $cost, 2); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if ($agentPrice > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'price' => $agentPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'type' => StatementType::ORDER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_id' => $order->agent_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_type' => DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$agentPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementType::ORDER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->agent_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									//抽成
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									if ($order->agent->rate > 0) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -190,40 +198,41 @@ class VerificationController extends Controller | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										//总后台抽成流水
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										if ($cutPrice > 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$adminCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'price' => $cutPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'type' => StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'cut_user_id' => $order->agent->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'cut_user_type' => DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$adminCreate[] = $service->createByOrderFormAdmin( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$cutPrice, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->agent->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											//代理商被抽成流水
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'price' => bcmul($cutPrice, -1, 6), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'type' => StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'user_id' => $order->agent->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'user_type' => DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												bcmul($cutPrice, -1, 6), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementType::CUT, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->agent->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
												StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
											$agentPrice = bcsub($agentPrice, $cutPrice, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									//扣除微信支付手续费
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$chargePrice = bcmul($order->price, 0.006, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'price' => bcmul($chargePrice, -1, 6), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'type' => StatementType::CHARGE, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_id' => $order->agent_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'user_type' => DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										'order_id' => $order->id | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$statementCreate[] = $service->createByOrder( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										bcmul($chargePrice, -1, 6), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementType::CHARGE, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->agent_id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										DemandTraits::$col[0], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										$order->id, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
										StatementTraits::$type[0] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$agentPrice = bcsub($agentPrice, $chargePrice, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$agent = Agent::query()->where('id', $order->agent->id)->lockForUpdate()->first(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$agent->balance = bcadd($agent->balance, $agentPrice, 6); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$agent->save(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								//dd($adminCreate,$guideCreate);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								if (!empty($adminCreate)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
									$order->statementAdmin()->createMany($adminCreate); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
								} | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |