提交代码
This commit is contained in:
97
app/Admin/Actions/AllotCard.php
Normal file
97
app/Admin/Actions/AllotCard.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\Card;
|
||||
use App\Models\CardOrder;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\Action;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AllotCard extends Action
|
||||
{
|
||||
protected $selector = '.report-posts';
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'startNum' => 'required|integer|min:1|lte:endNum',
|
||||
'endNum' => 'required|integer|min:1',
|
||||
], [
|
||||
'startNum.required' => '开始号码必须填写',
|
||||
'startNum.integer' => '开始号码必须是整数',
|
||||
'startNum.min' => '开始号码最小为1',
|
||||
'startNum.lte' => '开始号码要小于结束号码',
|
||||
'endNum.required' => '结束号码必须填写',
|
||||
'endNum.integer' => '结束号码必须是整数',
|
||||
'endNum.min' => '结束号码最小为1',
|
||||
]);
|
||||
$response = $this->response();
|
||||
$startNum = $request->startNum ?: 0;
|
||||
$endNum = $request->endNum ?: 0;
|
||||
$order_id = $request->order_id ?: 0;
|
||||
$company = $request->company;
|
||||
$number = $request->number;
|
||||
|
||||
$order = CardOrder::where('status', 1)->find($order_id);
|
||||
if (!$order) {
|
||||
$response->status = false;
|
||||
return $response->error('订单不存在或状态不正确');
|
||||
}
|
||||
|
||||
$startNum = sprintf("%'.08d", $startNum);
|
||||
$endNum = sprintf("%'.08d", $endNum);
|
||||
|
||||
$count = Card::whereBetween('code', [$startNum, $endNum])->count();
|
||||
|
||||
if ($order->num != $count) {
|
||||
$response->status = false;
|
||||
return $response->error('调拨数量与订单数量不匹配');
|
||||
}
|
||||
$isActive = Card::whereBetween('code', [$startNum, $endNum])->where('status', '!=', 1)->value('code');
|
||||
if ($isActive) {
|
||||
$response->status = false;
|
||||
return $response->error($isActive . '卡号状态不正确');
|
||||
}
|
||||
|
||||
if (!$order->user) {
|
||||
$response->status = false;
|
||||
return $response->error('用户不存在');
|
||||
} elseif ($order->user->identity->identity_id < 2) {
|
||||
$response->status = false;
|
||||
return $response->error($order->user->username . '用户不是代理');
|
||||
}
|
||||
$order->status = 2;
|
||||
$order->save();
|
||||
$order->deliver($company, $number);
|
||||
|
||||
Card::whereBetween('code', [$startNum, $endNum])->update([
|
||||
'user_id' => $order->user_id,
|
||||
'order_id' => $order->id,
|
||||
'status' => 3,
|
||||
]);
|
||||
|
||||
return $response->success('卡分配完毕')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$orders = CardOrder::where('status', 1)->get();
|
||||
$orderData = array();
|
||||
foreach ($orders as $key => $order) {
|
||||
$orderData[$order->id] = '单号:' . $order->order_id . '(用户账号:' . $order->user->username . ',数量:' . $order->num . ')';
|
||||
}
|
||||
|
||||
$options = deliver_list();
|
||||
|
||||
$this->select('order_id', '订单号')->options($orderData)->rules('required');
|
||||
$this->text('startNum', '开始')->rules('required|integer|min:1');
|
||||
$this->text('endNum', '结束')->rules('required|integer|min:1');
|
||||
$this->select('company', '物流名称')->options($options)->required();
|
||||
$this->text('number', '物流单号')->required();
|
||||
}
|
||||
|
||||
public function html()
|
||||
{
|
||||
return "<a class='report-posts btn btn-sm btn-danger'><i class='fa fa-info-circle'></i>分配卡</a>";
|
||||
}
|
||||
}
|
||||
38
app/Admin/Actions/AreaSetManage.php
Normal file
38
app/Admin/Actions/AreaSetManage.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AreaSetManage extends RowAction
|
||||
{
|
||||
public $name = '设置管理人';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$user = User::find($request->user_id);
|
||||
$model->user_id = $user->id;
|
||||
$model->save();
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('user_id', '用户序号')->rules(['required', 'numeric', function ($attribute, $value, $fail) {
|
||||
$user = User::find($value);
|
||||
if (!$user) {
|
||||
return $fail('未找到账号');
|
||||
}
|
||||
if (!in_array($user->identity->identity_id, [4])) {
|
||||
return $fail('账号等级不够');
|
||||
}
|
||||
}], [
|
||||
'required' => '用户序号不能为空',
|
||||
'numeric' => '用户序号必须为整数',
|
||||
], '2');
|
||||
}
|
||||
}
|
||||
40
app/Admin/Actions/CardOrder/OrderDeliver.php
Normal file
40
app/Admin/Actions/CardOrder/OrderDeliver.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\CardOrder;
|
||||
|
||||
use Config;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OrderDeliver extends RowAction
|
||||
{
|
||||
public $name = '提货卡发货';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$company = $request->company;
|
||||
$number = $request->number;
|
||||
$model->deliver($company, $number);
|
||||
return $this->response()->success('发货成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$deliver_list = Config::get('deliver_list');
|
||||
$array = preg_split('/[\r\n]+/', trim($deliver_list, "\r\n"));
|
||||
if (strpos($deliver_list, ':')) {
|
||||
$options = [];
|
||||
foreach ($array as $val) {
|
||||
[$k, $v] = explode(':', $val, 2);
|
||||
$options[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
$options = $array;
|
||||
}
|
||||
$this->select('company','物流名称')->options($options)->required();
|
||||
$this->text('number','物流单号')->required();
|
||||
}
|
||||
|
||||
}
|
||||
42
app/Admin/Actions/Cashout/Audit.php
Normal file
42
app/Admin/Actions/Cashout/Audit.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Cashout;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Storage;
|
||||
|
||||
class Audit extends RowAction
|
||||
{
|
||||
public $name = '审核提现';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$status = $request->status;
|
||||
if (!$status) {
|
||||
return $this->response()->error('请选择审核状态')->refresh();
|
||||
}
|
||||
|
||||
if ($status == 'pass') {
|
||||
$model->pass();
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
} else {
|
||||
$reason = $request->get('reason');
|
||||
$model->reject();
|
||||
$model->user->rule('cashoutreject', $model->variable);
|
||||
return $this->response()->success('驳回成功')->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$this->image('支付宝二维')->value(Storage::disk('admin')->url($model->user->cashAccount->alipay_account_code))->readonly();
|
||||
$this->text('用户账号')->value($model->user->username)->readonly();
|
||||
$this->text('用户名称')->value($model->user->info->nickname)->readonly();
|
||||
$this->text('提现金额')->value($model->variable)->readonly();
|
||||
$this->text('当前状态')->value($model->state_text)->readonly();
|
||||
$this->select('status', '审核')->options(['pass' => '通过', 'reject' => '驳回']);
|
||||
}
|
||||
}
|
||||
33
app/Admin/Actions/MobileImport.php
Normal file
33
app/Admin/Actions/MobileImport.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Admin\Imports\Mobile;
|
||||
use Encore\Admin\Actions\Action;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class MobileImport extends Action
|
||||
{
|
||||
public $name = '导入手机号';
|
||||
|
||||
protected $selector = '.import-post';
|
||||
public $modelName = '';
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$res = Excel::import(new Mobile, $request->file('file'), 'excel');
|
||||
return $this->response()->success('导入完成!')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->file('file', '请选择文件');
|
||||
}
|
||||
|
||||
public function html()
|
||||
{
|
||||
return <<<HTML
|
||||
<a class="btn btn-sm btn-default import-post"><i class="fa fa-upload"></i>导入数据</a>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
40
app/Admin/Actions/Order/OrderDeliver.php
Normal file
40
app/Admin/Actions/Order/OrderDeliver.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Order;
|
||||
|
||||
use Config;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OrderDeliver extends RowAction
|
||||
{
|
||||
public $name = '发货';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$company = $request->company;
|
||||
$number = $request->number;
|
||||
$res = $model->deliver($company, $number);
|
||||
return $this->response()->success('发货成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$deliver_list = Config::get('deliver_list');
|
||||
$array = preg_split('/[\r\n]+/', trim($deliver_list, "\r\n"));
|
||||
if (strpos($deliver_list, ':')) {
|
||||
$options = [];
|
||||
foreach ($array as $val) {
|
||||
[$k, $v] = explode(':', $val, 2);
|
||||
$options[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
$options = $array;
|
||||
}
|
||||
$this->select('company','物流名称')->options($options)->required();
|
||||
$this->text('number','物流单号')->required();
|
||||
}
|
||||
|
||||
}
|
||||
74
app/Admin/Actions/OrderRefundAgree.php
Normal file
74
app/Admin/Actions/OrderRefundAgree.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Actions;
|
||||
|
||||
use Encore\Admin\Admin;
|
||||
|
||||
class OrderRefundAgree
|
||||
{
|
||||
|
||||
protected $row;
|
||||
protected $resource;
|
||||
|
||||
public function __construct($row)
|
||||
{
|
||||
$this->row = $row;
|
||||
$this->resource = url()->current();
|
||||
}
|
||||
|
||||
protected function script()
|
||||
{
|
||||
return <<<SCRIPT
|
||||
$('.grid-deliver-row').unbind('click').click(function() {
|
||||
var id = $(this).data('id');
|
||||
swal({
|
||||
title: "确认要同意退款吗?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "确认",
|
||||
showLoaderOnConfirm: true,
|
||||
cancelButtonText: "取消",
|
||||
preConfirm: function() {
|
||||
return new Promise(function(resolve) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/' + id + '/agree',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
},
|
||||
success: function (data) {
|
||||
$.pjax.reload('#pjax-container');
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function(result) {
|
||||
var data = result.value;
|
||||
console.log(data);
|
||||
if (typeof data === 'object') {
|
||||
if (data.status) {
|
||||
swal(data.message, '', 'success');
|
||||
} else {
|
||||
swal(data.message, '', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
SCRIPT;
|
||||
}
|
||||
|
||||
protected function render()
|
||||
{
|
||||
Admin::script($this->script());
|
||||
|
||||
return "<button type='button' class='btn btn-xs btn-success grid-deliver-row' data-id='{$this->row->orderid}'>确认退款</button>";
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
30
app/Admin/Actions/ProfitStart.php
Normal file
30
app/Admin/Actions/ProfitStart.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use Admin;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProfitStart extends RowAction
|
||||
{
|
||||
public $name = '执行全球分红';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$admin_pass = $request->admin_pass;
|
||||
if (!Admin::guard()->attempt(['username' => Admin::user()->username, 'password' => $admin_pass])) {
|
||||
return $this->response()->error('验证密码失败')->refresh();
|
||||
}
|
||||
\App\Bonus\ProfitStart::settlement($this->row);
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('admin_pass', '当前管理员密码')->rules('required');
|
||||
}
|
||||
}
|
||||
38
app/Admin/Actions/SetParent.php
Normal file
38
app/Admin/Actions/SetParent.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SetParent extends RowAction
|
||||
{
|
||||
public $name = '设置推荐人';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$parent = User::find($request->parent_id);
|
||||
$this->row->UpdateRelation($parent);
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('parent_id', '用户序号')->rules(['required', 'numeric', function ($attribute, $value, $fail) {
|
||||
$parent = User::find($value);
|
||||
if (!$parent) {
|
||||
return $fail('未找到账号');
|
||||
}
|
||||
if (!in_array($parent->identity->identity_id, [2, 3, 4])) {
|
||||
return $fail('账号等级不够');
|
||||
}
|
||||
}], [
|
||||
'required' => '用户序号不能为空',
|
||||
'numeric' => '用户序号必须为整数',
|
||||
], '2');
|
||||
}
|
||||
}
|
||||
69
app/Admin/Actions/UserUpgrade.php
Normal file
69
app/Admin/Actions/UserUpgrade.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\UpgradePayment;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class UserUpgrade extends RowAction
|
||||
{
|
||||
public $name = '空升';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$identity_id = $request->identity_id;
|
||||
$model->identityUpdate($identity_id, 'EmptyUp');
|
||||
if ($identity_id > 1 && !$model->activationd_at) {
|
||||
$model->activationd_at = now();
|
||||
$model->save();
|
||||
}
|
||||
$amount = $model->getIdentityPrice($identity_id);
|
||||
if ($amount) {
|
||||
$upgrade_payment = UpgradePayment::create([
|
||||
'user_id' => $model->id,
|
||||
'type' => 'agent',
|
||||
'pay_type' => 'ADMIN',
|
||||
'amount' => $amount,
|
||||
'total' => 0,
|
||||
'state' => 'SUCCESS',
|
||||
]);
|
||||
|
||||
if ($identity_id == 1) {
|
||||
\App\Bonus\DirectVip::settlement($upgrade_payment);
|
||||
|
||||
$source = [
|
||||
'user_id' => $upgrade_payment->user->id,
|
||||
'type' => 'UpgradeVip',
|
||||
'payment_id' => $upgrade_payment->id,
|
||||
];
|
||||
\App\Bonus\AddPerf::settlement($upgrade_payment->user, $upgrade_payment->amount, $source);
|
||||
} elseif ($identity_id > 1) {
|
||||
\App\Bonus\DirectAgency::settlement($upgrade_payment);
|
||||
|
||||
$source = [
|
||||
'user_id' => $upgrade_payment->user->id,
|
||||
'type' => 'UpgradeAgency',
|
||||
'payment_id' => $upgrade_payment->id,
|
||||
];
|
||||
\App\Bonus\AddPerf::settlement($upgrade_payment->user, $upgrade_payment->amount, $source);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response()->success('升级成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$identitys = Identity::where('id', '!=', $model->identity_id)->orderBy('id', 'asc')->pluck('title', 'id')->toArray();
|
||||
$identitys[0] = '普通用户';
|
||||
ksort($identitys);
|
||||
$this->text('用户名称')->value($model->info->nickname);
|
||||
$this->text('当前等级')->value($model->identity_text);
|
||||
$this->select('identity_id', '目标等级')->options($identitys);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user