| | |
| | | |
| | | /** |
| | | * 创建VIP专区订单记录 |
| | | * @param array $order 订单信息数组 |
| | | * @param int $order_type 订单类型,默认为OrderTypeEnum::MASTER |
| | | * @return bool|\think\Collection 是否成功创建订单 |
| | | */ |
| | | public static function createOrder($order, $order_type = OrderTypeEnum::MASTER) |
| | | { |
| | |
| | | $list=[]; |
| | | // 计算佣金金额 |
| | | $orderPrice = bcsub($order['pay_price'], $order['express_price'], 2); |
| | | $viewpoint_money=0; |
| | | // 获取当前买家的推荐人信息 |
| | | $userModel = UserModel::detail($order['user_id']); |
| | | if (!empty($userModel) && !empty($userModel['referee_id'])) { |
| | |
| | | if (!empty($config['become__buy_product_ids'])) { |
| | | $purchase_count=(new self())->getPurchaseCount($order['user_id']); |
| | | foreach ($order['product'] as $product){ |
| | | if ($product['is_repurchase']==1){ |
| | | $viewpoint_money=bcadd($viewpoint_money,($product['is_viewpoint_money']?$product['viewpoint_money']:$vipGrade['viewpoint_money']),2); |
| | | } |
| | | if (in_array($product['product_id'], $config['become__buy_product_ids'])) { |
| | | // 获取商品数量 |
| | | $quantity = $product['total_num']; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 检查并处理直推佣金 |
| | | $directReferralsCount=0; |
| | | $user=UserModel::detail($order['user_id']); |
| | | if (!empty($user['referee_id'])){ |
| | | // 检查推荐人是否满足直推条件(直推用户数量) |
| | | $directReferralsCount = UserModel::where('referee_id', '=', $user['referee_id'])->count(); |
| | | if ($viewpoint_money>0&&(new User())->getViewpointMoneyQualification($user['referee_id'],$setting)){ |
| | | $list[]=array_merge($data,['vip_area_type'=>60,'vip_area_money'=>$viewpoint_money]); |
| | | } |
| | | } |
| | | $requiredReferralCount = $setting['referee_buy_count'] ?? 0; |
| | | if ($vipGrade['commission']>0 && $directReferralsCount >= $requiredReferralCount){ |
| | |
| | | } |
| | | } |
| | | } |
| | | if( $order['supplier']['referee_id']!=0){ |
| | | // 处理供应商推荐人佣金 |
| | | if($order['supplier']['referee_id']!=0){ |
| | | $supplierReferee=VipUserModel::detail($order['supplier']['referee_id']); |
| | | if ($supplierReferee){ |
| | | $vipGradeSupplier=Grade::detail($supplierReferee['grade_id']); |
| | |
| | | } |
| | | } |
| | | } |
| | | log_write($list); |
| | | if (empty($list)){ |
| | | return true; |
| | | } |