|
@@ -7,9 +7,12 @@ use App\Helper\ByteDance;
|
|
use App\Helper\UniPlatform\Bytedance\Payment as BytedancePayment;
|
|
use App\Helper\UniPlatform\Bytedance\Payment as BytedancePayment;
|
|
use App\Helper\UniPlatform\Kuaishou\Payment as KuaishouPayment;
|
|
use App\Helper\UniPlatform\Kuaishou\Payment as KuaishouPayment;
|
|
use App\Models\Pay;
|
|
use App\Models\Pay;
|
|
|
|
+use App\Models\ShareConfig;
|
|
|
|
+use App\Models\User;
|
|
use App\Models\UserConsumeRecord;
|
|
use App\Models\UserConsumeRecord;
|
|
use App\Models\UserInfo;
|
|
use App\Models\UserInfo;
|
|
use App\Models\UserRechargeRecord;
|
|
use App\Models\UserRechargeRecord;
|
|
|
|
+use App\Models\UserShare;
|
|
use App\Models\UserVipRecord;
|
|
use App\Models\UserVipRecord;
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
@@ -174,6 +177,9 @@ class PayNoticeController extends Controller
|
|
$record->status = 1;
|
|
$record->status = 1;
|
|
$record->save();
|
|
$record->save();
|
|
|
|
|
|
|
|
+ // 分销
|
|
|
|
+ $this->share($record ,2);
|
|
|
|
+
|
|
return [
|
|
return [
|
|
'id' => $record->combo_id,
|
|
'id' => $record->combo_id,
|
|
'title' => $record->combo->name,
|
|
'title' => $record->combo->name,
|
|
@@ -204,6 +210,9 @@ class PayNoticeController extends Controller
|
|
$record->status = 1;
|
|
$record->status = 1;
|
|
$record->save();
|
|
$record->save();
|
|
|
|
|
|
|
|
+ // 分销
|
|
|
|
+ $this->share($record,1);
|
|
|
|
+
|
|
return [
|
|
return [
|
|
'id' => $record->combo_id,
|
|
'id' => $record->combo_id,
|
|
'title' => $record->combo->name,
|
|
'title' => $record->combo->name,
|
|
@@ -212,5 +221,39 @@ class PayNoticeController extends Controller
|
|
];
|
|
];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param UserVipRecord | UserRechargeRecord $record
|
|
|
|
+ * @param $type
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ private function share($record ,$type)
|
|
|
|
+ {
|
|
|
|
+ $user = User::find($record->user_id);
|
|
|
|
+ // 一级分销
|
|
|
|
+ if($user->parent_id){
|
|
|
|
+ $config = ShareConfig::first();
|
|
|
|
+ $pay = Pay::find($record->pay_id);
|
|
|
|
+ if($config->share_type == 1){ // 百分比
|
|
|
|
+ $income = $pay->order_fee * $config->share_number / 100;
|
|
|
|
+ }else{ // 固定
|
|
|
|
+ $income = $config->share_number;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $share = new UserShare();
|
|
|
|
+ $share->user_id = $user->parent_id;
|
|
|
|
+ $share->child_id = $user->id;
|
|
|
|
+ $share->order_type = $type;
|
|
|
|
+ $share->order_id = $record->pay_id;
|
|
|
|
+ $share->income = $income;
|
|
|
|
+ $share->save();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $user->income = $user->income + $income;
|
|
|
|
+ $user->total_income = $user->total_income + $income;
|
|
|
|
+ $user->save();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|