first commit
This commit is contained in:
26
.env
Normal file
26
.env
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
APP_NAME=平安券核销管理系统
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=base64:HrWbyXR/0Bh/w5Ij6fx8747z4VvKLupYPhWELuLvVro=
|
||||||
|
APP_DEBUG=false
|
||||||
|
APP_URL=http://pa.ysd-bs.com
|
||||||
|
|
||||||
|
LOG_CHANNEL=daily
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=pingan
|
||||||
|
DB_USERNAME=pingan
|
||||||
|
DB_PASSWORD=vnmrIl3fn5Alahna
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=file
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
|
||||||
58
app/Admin/Actions/Coupon/Batch.php
Normal file
58
app/Admin/Actions/Coupon/Batch.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Coupon;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Actions\Action;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class Batch extends Action
|
||||||
|
{
|
||||||
|
public $name = '批量打款';
|
||||||
|
|
||||||
|
protected $selector = '.import-post';
|
||||||
|
|
||||||
|
public function handle(Request $request)
|
||||||
|
{
|
||||||
|
$user_id = $request->user_id;
|
||||||
|
$date = $request->date;
|
||||||
|
$list = Coupon::where('user_id', $user_id)->whereDate('created_at', $date)->where('status', 2)->get();
|
||||||
|
if ($list->isEmpty()) {
|
||||||
|
return $this->response()->error('打款失败!没有可处理的数据')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
$success = $error = 0;
|
||||||
|
foreach ($list as $key => $coupon) {
|
||||||
|
$res = $coupon->sendMoney();
|
||||||
|
if ($res === true) {
|
||||||
|
$success++;
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->response()->success("处理完成,成功:{$success}条,失败:{$error}条")->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
$users = User::query()
|
||||||
|
->whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})
|
||||||
|
->where('type', 'pingan')
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
$this->select('user_id', '渠道')->options($users)->required();
|
||||||
|
// 时间日期选择
|
||||||
|
$this->date('date', '核销日期')->required();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function html()
|
||||||
|
{
|
||||||
|
return <<<HTML
|
||||||
|
<a class="btn btn-sm btn-default import-post"><i class="fa fa-Yuan"></i>批量打款</a>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Admin/Actions/Coupon/BatchProfit.php
Normal file
33
app/Admin/Actions/Coupon/BatchProfit.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Coupon;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class BatchProfit extends RowAction
|
||||||
|
{
|
||||||
|
public $name = '打款';
|
||||||
|
|
||||||
|
public function handle(Model $model)
|
||||||
|
{
|
||||||
|
if ($model->canProfit()) {
|
||||||
|
$res = $model->sendMoney();
|
||||||
|
if ($res === true) {
|
||||||
|
return $this->response()->success('操作成功')->refresh();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->response()->success($res)->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->response()->success('操作失败')->refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dialog()
|
||||||
|
{
|
||||||
|
$this->confirm('确定分润?');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
app/Admin/Actions/Coupon/BatchProfits.php
Normal file
33
app/Admin/Actions/Coupon/BatchProfits.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Coupon;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\BatchAction;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
|
class BatchProfits extends BatchAction
|
||||||
|
{
|
||||||
|
public $name = '批量打款';
|
||||||
|
|
||||||
|
public function handle(Collection $collection)
|
||||||
|
{
|
||||||
|
$success = $error = 0;
|
||||||
|
|
||||||
|
foreach ($collection as $model) {
|
||||||
|
$res = $model->sendMoney();
|
||||||
|
if ($res === true) {
|
||||||
|
$success++;
|
||||||
|
} else {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()->success('成功' . $success . '条,失败' . $error . '条')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dialog()
|
||||||
|
{
|
||||||
|
$this->confirm('确定打款?');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
app/Admin/Actions/User/Profit.php
Normal file
33
app/Admin/Actions/User/Profit.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class Profit extends RowAction
|
||||||
|
{
|
||||||
|
public $name = '设置分润';
|
||||||
|
|
||||||
|
public function handle(Model $model, Request $request)
|
||||||
|
{
|
||||||
|
$datas = $request->code;
|
||||||
|
|
||||||
|
$codes = $model->code;
|
||||||
|
foreach ($codes as $key => $code) {
|
||||||
|
$code->profit = round($datas[$code->id], 2);
|
||||||
|
$code->save();
|
||||||
|
}
|
||||||
|
return $this->response()->success('操作成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form(Model $model)
|
||||||
|
{
|
||||||
|
$codes = $model->code;
|
||||||
|
foreach ($codes as $key => $code) {
|
||||||
|
$this->text("code[{$code->id}]", $code->name)->value($code->profit)->required();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/Admin/Actions/User/ReCode.php
Normal file
43
app/Admin/Actions/User/ReCode.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use RuLong\Identity\Models\Identity;
|
||||||
|
|
||||||
|
class ReCode extends RowAction
|
||||||
|
{
|
||||||
|
public $name = '重置规则';
|
||||||
|
|
||||||
|
public function handle(Model $model)
|
||||||
|
{
|
||||||
|
if ($model->identity_id != 1) {
|
||||||
|
return $this->response()->error('只有渠道才能刷新');
|
||||||
|
}
|
||||||
|
|
||||||
|
$all_codes = Identity::find(1)->codes;
|
||||||
|
$user_codes = $model->code;
|
||||||
|
|
||||||
|
if ($all_codes->count() == $user_codes->count()) {
|
||||||
|
return $this->response()->success('操作成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($all_codes as $key => $code) {
|
||||||
|
$model->code()->updateOrCreate([
|
||||||
|
'code' => $code->code,
|
||||||
|
], [
|
||||||
|
'name' => $code->name,
|
||||||
|
'code' => $code->code,
|
||||||
|
'profit' => $code->profit,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()->success('操作成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dialog()
|
||||||
|
{
|
||||||
|
$this->confirm('确定要重置卡券规则吗?刷新后将重置此渠道卡券规则');
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Admin/Actions/User/RefD3Key.php
Normal file
24
app/Admin/Actions/User/RefD3Key.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class RefD3Key extends RowAction
|
||||||
|
{
|
||||||
|
public $name = '刷新D3key';
|
||||||
|
|
||||||
|
public function handle(Model $model)
|
||||||
|
{
|
||||||
|
$model->des3key = Str::random(24);
|
||||||
|
$model->save();
|
||||||
|
return $this->response()->success('操作成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dialog()
|
||||||
|
{
|
||||||
|
$this->confirm('确定要刷新D3key吗?');
|
||||||
|
}
|
||||||
|
}
|
||||||
37
app/Admin/Actions/User/UserImport.php
Normal file
37
app/Admin/Actions/User/UserImport.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
use App\Admin\Imports\User;
|
||||||
|
use Encore\Admin\Actions\Action;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
|
class UserImport extends Action
|
||||||
|
{
|
||||||
|
public $name = '导入网点编号';
|
||||||
|
|
||||||
|
protected $selector = '.import-post';
|
||||||
|
public $modelName = '';
|
||||||
|
|
||||||
|
public function handle(Request $request)
|
||||||
|
{
|
||||||
|
$res = Excel::import(new User, $request->file('file'), 'excel');
|
||||||
|
if ($res === true) {
|
||||||
|
return $this->response()->success('导入完成!')->refresh();
|
||||||
|
} else {
|
||||||
|
return $this->response()->error('失败' . $res)->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Admin/Actions/User/UserUpgrade.php
Normal file
31
app/Admin/Actions/User/UserUpgrade.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
|
return $this->response()->success('升级成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form(Model $model)
|
||||||
|
{
|
||||||
|
$identitys = Identity::where('id', '!=', $model->identity_id)->orderBy('id', 'asc')->pluck('title', 'id')->toArray();
|
||||||
|
$this->text('用户名称')->disable()->value($model->info->nickname);
|
||||||
|
$this->text('当前等级')->disable()->value($model->identity_text);
|
||||||
|
$this->select('identity_id', '目标等级')->options($identitys);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
55
app/Admin/Actions/Wo/Unsubscribe.php
Normal file
55
app/Admin/Actions/Wo/Unsubscribe.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Wo;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Wo;
|
||||||
|
|
||||||
|
class Unsubscribe extends RowAction
|
||||||
|
{
|
||||||
|
public $name = '退订';
|
||||||
|
|
||||||
|
public function handle(Model $model)
|
||||||
|
{
|
||||||
|
$postData = [
|
||||||
|
'logNo' => $model->logNo,
|
||||||
|
];
|
||||||
|
//查询状态
|
||||||
|
$res = Wo::ticketQuery($postData, $model->user_id);
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->response()->error($res)->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
$ConfigTicketState = config('wo.ticketState');
|
||||||
|
$ConfigTicketStateText = config('wo.ticketStateText');
|
||||||
|
$ticketState = $res['ticketState'];
|
||||||
|
|
||||||
|
if (!in_array($ticketState, ['A', 'U'])) {
|
||||||
|
$msg = (array_key_exists($ticketState, $ConfigTicketStateText)) ? $ConfigTicketStateText[$ticketState] : '未知状态';
|
||||||
|
return $this->response()->error($msg)->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断数组中是否存在下标
|
||||||
|
if (!array_key_exists($ticketState, $ConfigTicketState)) {
|
||||||
|
return $this->response()->error('未知状态')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
$postData['service'] = $ConfigTicketState[$ticketState];
|
||||||
|
$postData['ologNo'] = $postData['logNo'];
|
||||||
|
|
||||||
|
//退业务
|
||||||
|
$res = Wo::ticketBack($postData, $model->user);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->response()->error($res)->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()->success($res)->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dialog()
|
||||||
|
{
|
||||||
|
$this->confirm('确定要退订吗?');
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Admin/Controllers/Account/IndexController.php
Normal file
47
app/Admin/Controllers/Account/IndexController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Account;
|
||||||
|
|
||||||
|
use App\Models\Account;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '账户管理';
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Account);
|
||||||
|
|
||||||
|
$grid->model()->whereHasMorph(
|
||||||
|
'accountable',
|
||||||
|
User::class,
|
||||||
|
function ($query) {
|
||||||
|
$query->where('type', 'pingan')->whereHas('identity', function ($q) {
|
||||||
|
$q->where('identity_id', 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$grid->disableActions();
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
// $grid->column('所属项目')->display(function () {
|
||||||
|
// return $this->accountable->type_text;
|
||||||
|
// });
|
||||||
|
$grid->column('渠道名称')->display(function () {
|
||||||
|
return $this->accountable->name ?? $this->accountable->nickname;
|
||||||
|
});
|
||||||
|
$grid->column('balance', '总分润');
|
||||||
|
$grid->column('score', '已打款');
|
||||||
|
// $grid->column('updated_at', '更新时间');
|
||||||
|
$grid->column('日志')->display(function () {
|
||||||
|
return '<a href="' . admin_url('accounts/logs?id=' . $this->id) . '">账户日志</a>';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
66
app/Admin/Controllers/Account/LogController.php
Normal file
66
app/Admin/Controllers/Account/LogController.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Account;
|
||||||
|
|
||||||
|
use App\Models\AccountLog;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class LogController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '账户日志';
|
||||||
|
|
||||||
|
function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new AccountLog);
|
||||||
|
$userId = request()->user_id;
|
||||||
|
$grid->model()->when($userId, function ($query, $userId) {
|
||||||
|
$query->where('user_id', $userId);
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->disableActions();
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->like('rule.title', '触发规则');
|
||||||
|
$filter->equal('type', '账户类型')->select(config('account.account_type'));
|
||||||
|
});
|
||||||
|
// $filter->column(1 / 3, function ($filter) {
|
||||||
|
// $filter->where(function ($query) {
|
||||||
|
// $query->whereHas('user', function ($query) {
|
||||||
|
// $query->whereHas('info', function ($query) {
|
||||||
|
// $query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }, '会员姓名');
|
||||||
|
// $filter->between('variable', '变量');
|
||||||
|
// });
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->equal('frozen', '冻结')->select([
|
||||||
|
0 => '否',
|
||||||
|
1 => '是',
|
||||||
|
]);
|
||||||
|
$filter->between('created_at', '创建时间')->datetime();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// $grid->column('user.username', '会员账号');
|
||||||
|
// $grid->column('user.nickname', '会员姓名');
|
||||||
|
$grid->column('rule.title', '触发规则');
|
||||||
|
$grid->column('type', '类型')->using(config('account.account_type'));
|
||||||
|
$grid->column('variable', '变量');
|
||||||
|
$grid->column('balance', '余额');
|
||||||
|
$grid->column('frozen', '冻结')
|
||||||
|
->using([0 => '否', 1 => '是'])
|
||||||
|
->label([
|
||||||
|
0 => 'success',
|
||||||
|
1 => 'warning',
|
||||||
|
]);
|
||||||
|
$grid->column('created_at', '获取时间');
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
107
app/Admin/Controllers/Account/RuleController.php
Normal file
107
app/Admin/Controllers/Account/RuleController.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Account;
|
||||||
|
|
||||||
|
use App\Models\AccountRule;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class RuleController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for current resource.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $title = '账户规则';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a grid builder.
|
||||||
|
*
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new AccountRule);
|
||||||
|
$grid->tools(function (Grid\Tools $tools) {
|
||||||
|
$tools->batch(function ($batch) {
|
||||||
|
$batch->disableDelete();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$grid->quickSearch('title')->placeholder('规则名称');
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->like('title', '规则名称');
|
||||||
|
});
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->like('name', '调用标记');
|
||||||
|
});
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->equal('type', '账户类型')->select([
|
||||||
|
'cash' => '现金账户',
|
||||||
|
'score' => '积分账户',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '编号');
|
||||||
|
$grid->column('title', '规则名称');
|
||||||
|
$grid->column('name', '调用标记');
|
||||||
|
$grid->column('type', '账户类型')->using(config('account.account_type'));
|
||||||
|
$grid->column('variable', '增减变量');
|
||||||
|
$grid->column('trigger', '频率')->display(function () {
|
||||||
|
return $this->trigger_text;
|
||||||
|
});
|
||||||
|
$grid->column('deductions', '立即处理')->bool();
|
||||||
|
$grid->column('remark', '备注');
|
||||||
|
$grid->column('created_at', '创建时间');
|
||||||
|
$grid->column('updated_at', '更新时间');
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a form builder.
|
||||||
|
*
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
|
protected function form()
|
||||||
|
{
|
||||||
|
|
||||||
|
$form = new Form(new AccountRule);
|
||||||
|
$form->text('title', '规则名称')
|
||||||
|
->rules('required|between:2,50');
|
||||||
|
|
||||||
|
$form->text('name', '调用标记')
|
||||||
|
->creationRules('required|alpha_dash|between:2,50|unique:account_rules')
|
||||||
|
->updateRules('required|alpha_dash|between:2,50|unique:account_rules,name,{{id}}');
|
||||||
|
|
||||||
|
$form->select('type', '账户类型')
|
||||||
|
->options(config('account.account_type'))
|
||||||
|
->rules(['required', Rule::in(array_keys(config('account.account_type')))]);
|
||||||
|
|
||||||
|
$form->number('variable', '增减变量')
|
||||||
|
->value(0)
|
||||||
|
->rules('required|numeric');
|
||||||
|
|
||||||
|
$form->number('trigger', '次数限制')->value(0)
|
||||||
|
->help('执行次数限制,小于0则终身一次,等于0不限制,大于0每日N次')
|
||||||
|
->rules('required|integer');
|
||||||
|
|
||||||
|
$states = [
|
||||||
|
'on' => ['value' => 1, 'text' => '打开'],
|
||||||
|
'off' => ['value' => 0, 'text' => '关闭'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$form->switch('deductions', '立即处理')->value(1)->states($states);
|
||||||
|
|
||||||
|
$form->textarea('remark', '备注信息')->rules('nullable|max:255');
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
21
app/Admin/Controllers/Ajax/AreaController.php
Normal file
21
app/Admin/Controllers/Ajax/AreaController.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Ajax;
|
||||||
|
|
||||||
|
use App\Models\Area;
|
||||||
|
use DB;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AreaController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function children(Request $request)
|
||||||
|
{
|
||||||
|
$code = $request->get('q');
|
||||||
|
|
||||||
|
return Area::whereHas('parent', function ($q) use ($code) {
|
||||||
|
$q->where('code', $code);
|
||||||
|
})->get(['code as id', DB::raw('name as text')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
app/Admin/Controllers/AuthController.php
Normal file
10
app/Admin/Controllers/AuthController.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use Encore\Admin\Controllers\AuthController as BaseAuthController;
|
||||||
|
|
||||||
|
class AuthController extends BaseAuthController
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
156
app/Admin/Controllers/Coupon/IndexController.php
Normal file
156
app/Admin/Controllers/Coupon/IndexController.php
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Coupon;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '核销券记录';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Coupon);
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
$grid->disableBatchActions();
|
||||||
|
$grid->disableActions();
|
||||||
|
|
||||||
|
$grid->model()->whereIn('status', [2, 3])->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('status', '状态')->select([
|
||||||
|
'2' => '核销成功',
|
||||||
|
'3' => '核销失败',
|
||||||
|
]);
|
||||||
|
$filter->between('created_at', '核销时间')->datetime();
|
||||||
|
$users = User::query()
|
||||||
|
->whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})
|
||||||
|
->where('type', 'pingan')
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
$filter->equal('thirdPartyGoodsId', '优惠政策')->select([
|
||||||
|
'YSD-full100-10' => '100减10元',
|
||||||
|
'YSD-full100-25' => '100减25元',
|
||||||
|
'YSD-full100-50' => '100减50元',
|
||||||
|
'YSD-full200-100' => '200减100元',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('partnerOrderId', '订单号');
|
||||||
|
$filter->like('redemptionCode', '平安券编号');
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('outlet', function ($query) {
|
||||||
|
$query->whereHas('info', function ($query) {
|
||||||
|
$query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '网点名称');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('渠道')->display(function () {
|
||||||
|
return $this->user->nickname;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('网点名称/编号')->display(function () {
|
||||||
|
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('PaOutletId', '平安网点id')->hide();
|
||||||
|
|
||||||
|
// $grid->column('partnerOrderId', '订单号');
|
||||||
|
$grid->column('redemptionCode', '平安券编号');
|
||||||
|
$grid->column('couponName', '优惠政策');
|
||||||
|
$grid->column('price', '核销金额');
|
||||||
|
$grid->column('total', '订单金额');
|
||||||
|
$grid->column('资金通道结算')->display(function () {
|
||||||
|
$profit = $this->status == 2 ? $this->profit : '0.00';
|
||||||
|
return '<span style="color:red">' . $profit . '</span>';
|
||||||
|
});
|
||||||
|
$grid->column('状态')->display(function () {
|
||||||
|
switch ($this->status) {
|
||||||
|
case 2:
|
||||||
|
return '<span style="color:green">' . $this->status_text . '</span>';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return '<span style="color:red">' . $this->status_text . '</span>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->status_text;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('remark', '处理结果');
|
||||||
|
$grid->column('startTime', '起始时间');
|
||||||
|
$grid->column('endTime', '到期时间');
|
||||||
|
$grid->column('created_at', '核销时间');
|
||||||
|
$grid->column('省')->display(function () {
|
||||||
|
return ($this->outlet && $this->outlet->province) ? $this->outlet->province->name : '';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('市')->display(function () {
|
||||||
|
return ($this->outlet && $this->outlet->province) ? $this->outlet->city->name : '';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('区')->display(function () {
|
||||||
|
return ($this->outlet && $this->outlet->province) ? $this->outlet->district->name : '';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->footer(function ($query) {
|
||||||
|
$all = $query->get();
|
||||||
|
$pass = $all->where('status', 2)->all();
|
||||||
|
$pass = collect($pass);
|
||||||
|
|
||||||
|
return '<label class="label label-success">全部:' . $all->count() . '张</label> '
|
||||||
|
. '<label class="label label-success">成功:' . $pass->count() . '张</label> '
|
||||||
|
. '<label class="label label-success">失败:' . $all->where('status', 3)->count() . '张</label> '
|
||||||
|
. '<label class="label label-success">核销金额:' . $pass->sum('price') . '元</label> '
|
||||||
|
. '<label class="label label-success">资金通道结算:' . $pass->sum('profit') . '元</label> '
|
||||||
|
. '<label class="label label-success">打款金额:' . $pass->where('is_profit', 1)->sum('profit') . '元</label> ';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->disableExport(false);
|
||||||
|
$grid->export(function ($export) {
|
||||||
|
$export->column('状态', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('资金通道结算', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->column('网点名称/编号', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('price', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('total', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('redemptionCode', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->filename($this->title . date("YmdHis"));
|
||||||
|
});
|
||||||
|
// $grid->exporter(new CouponExport());
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
91
app/Admin/Controllers/Finance/CensusController.php
Normal file
91
app/Admin/Controllers/Finance/CensusController.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Finance;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Facades\Admin;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Layout\Content;
|
||||||
|
use RuLong\Identity\Models\IdentityCode;
|
||||||
|
|
||||||
|
class CensusController extends AdminController
|
||||||
|
{
|
||||||
|
protected $today = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index interface.
|
||||||
|
*
|
||||||
|
* @param Content $content
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
public function index(Content $content)
|
||||||
|
{
|
||||||
|
return $content
|
||||||
|
->header('核销总数据')
|
||||||
|
->description('description')
|
||||||
|
->body($this->grid());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今日核销数据
|
||||||
|
* @param Content $content [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function today(Content $content)
|
||||||
|
{
|
||||||
|
$this->today = true;
|
||||||
|
return $content
|
||||||
|
->header('核销今日数据')
|
||||||
|
->description('description')
|
||||||
|
->body($this->grid());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new User);
|
||||||
|
|
||||||
|
$grid->model()->whereHas('identity', function ($q) {
|
||||||
|
$q->where('identity_id', 1);
|
||||||
|
})->where('type', 'pingan');
|
||||||
|
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
$grid->disableBatchActions();
|
||||||
|
$grid->disableActions();
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('info', function ($query) {
|
||||||
|
$query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
});
|
||||||
|
}, '渠道名称');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('渠道')->display(function () {
|
||||||
|
return $this->info->nickname;
|
||||||
|
});
|
||||||
|
$today = $this->today;
|
||||||
|
$codes = IdentityCode::get();
|
||||||
|
foreach ($codes as $key => $code) {
|
||||||
|
$grid->column($code->name)->display(function () use ($today, $code) {
|
||||||
|
return $this->getCouponCount($code->code, $today);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// $grid->column('100元减25元优惠券')->display(function () use ($today) {
|
||||||
|
// return $this->getCouponCount('YSD-full100-25', $today);
|
||||||
|
// });
|
||||||
|
// $grid->column('100元减50元优惠券')->display(function () use ($today) {
|
||||||
|
// return $this->getCouponCount('YSD-full100-50', $today);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $grid->column(' 200元减100元优惠券')->display(function () use ($today) {
|
||||||
|
// return $this->getCouponCount('YSD-full200-100', $today);
|
||||||
|
// });
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
164
app/Admin/Controllers/Finance/IndexController.php
Normal file
164
app/Admin/Controllers/Finance/IndexController.php
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Finance;
|
||||||
|
|
||||||
|
use App\Admin\Actions\Coupon\Batch;
|
||||||
|
use App\Admin\Actions\Coupon\BatchProfit;
|
||||||
|
use App\Admin\Actions\Coupon\BatchProfits;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '平安渠道打款处理';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Coupon);
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
$grid->disableBatchActions(false);
|
||||||
|
|
||||||
|
$grid->tools(function (Grid\Tools $tools) {
|
||||||
|
$tools->append(new Batch);
|
||||||
|
$tools->batch(function ($batch) {
|
||||||
|
$batch->disableDelete();
|
||||||
|
$batch->add(new BatchProfits);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||||
|
$actions->disableView();
|
||||||
|
$actions->disableEdit();
|
||||||
|
$actions->disableDelete();
|
||||||
|
if ($actions->row->canProfit()) {
|
||||||
|
$actions->add(new BatchProfit);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->model()->where('status', 2)->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('is_profit', '打款')->select([
|
||||||
|
'0' => '未打款',
|
||||||
|
'1' => '已打款',
|
||||||
|
]);
|
||||||
|
$filter->between('created_at', '核销时间')->datetime();
|
||||||
|
$filter->between('paid_at', '打款时间')->datetime();
|
||||||
|
$users = User::query()
|
||||||
|
->whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})
|
||||||
|
->where('type', 'pingan')
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('partnerOrderId', '订单号');
|
||||||
|
$filter->like('redemptionCode', '平安券编号');
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('outlet', function ($query) {
|
||||||
|
$query->whereHas('info', function ($query) {
|
||||||
|
$query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '渠道名称');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('渠道')->display(function () {
|
||||||
|
return $this->user->nickname;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('网点名称/编号')->display(function () {
|
||||||
|
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||||
|
});
|
||||||
|
|
||||||
|
// $grid->column('partnerOrderId', '订单号');
|
||||||
|
$grid->column('redemptionCode', '平安券编号');
|
||||||
|
$grid->column('couponName', '优惠政策');
|
||||||
|
$grid->column('price', '核销金额');
|
||||||
|
$grid->column('profit', '资金通道结算');
|
||||||
|
|
||||||
|
$grid->column('状态')->display(function () {
|
||||||
|
switch ($this->status) {
|
||||||
|
case 2:
|
||||||
|
return '<span style="color:green">' . $this->status_text . '</span>';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return '<span style="color:red">' . $this->status_text . '</span>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->status_text;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('打款')->display(function () {
|
||||||
|
switch ($this->is_profit) {
|
||||||
|
case 0:
|
||||||
|
return '<span style="color:green">未打款</span>';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return '<span style="color:red">已打款</span>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return '未知';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('paid_at', '打款时间');
|
||||||
|
$grid->column('created_at', '核销时间');
|
||||||
|
|
||||||
|
$grid->footer(function ($query) {
|
||||||
|
$all = $query->get();
|
||||||
|
$pass = $all->where('status', 2)->all();
|
||||||
|
$reject = $all->where('status', 3)->all();
|
||||||
|
$pass = collect($pass);
|
||||||
|
$reject = collect($reject);
|
||||||
|
return '<label class="label label-success">全部:' . $all->count() . '张</label> '
|
||||||
|
. '<label class="label label-success">核销金额:' . $pass->sum('price') . '元</label> '
|
||||||
|
. '<label class="label label-success">资金通道结算:' . $pass->sum('profit') . '元</label> '
|
||||||
|
. '<label class="label label-success">打款金额:' . $pass->where('is_profit', 1)->sum('profit') . '元</label> ';
|
||||||
|
});
|
||||||
|
$grid->disableExport(false);
|
||||||
|
$grid->export(function ($export) {
|
||||||
|
$export->column('打款', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('状态', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->column('网点名称/编号', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('price', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('profit', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('redemptionCode', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->filename($this->title . date("YmdHis"));
|
||||||
|
});
|
||||||
|
// $grid->exporter(new CouponPassExport());
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
90
app/Admin/Controllers/Finance/LogController.php
Normal file
90
app/Admin/Controllers/Finance/LogController.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Finance;
|
||||||
|
|
||||||
|
use App\Admin\Exporters\CouponProfitExport;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class LogController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '已打款记录';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Coupon);
|
||||||
|
$grid->model()->where('profit', '>', 0);
|
||||||
|
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
$grid->disableBatchActions();
|
||||||
|
$grid->disableActions();
|
||||||
|
|
||||||
|
$grid->model()->where('is_profit', 1)->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->between('paid_at', '打款时间')->datetime();
|
||||||
|
$users = User::query()
|
||||||
|
->whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})
|
||||||
|
->where('type', 'pingan')
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('partnerOrderId', '订单号');
|
||||||
|
$filter->like('redemptionCode', '平安券编号');
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('outlet', function ($query) {
|
||||||
|
$query->whereHas('info', function ($query) {
|
||||||
|
$query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '网点名称');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('渠道')->display(function () {
|
||||||
|
return $this->user->nickname;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('网点名称/编号')->display(function () {
|
||||||
|
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('partnerOrderId', '订单号');
|
||||||
|
$grid->column('redemptionCode', '平安券编号');
|
||||||
|
$grid->column('couponName', '优惠政策');
|
||||||
|
$grid->column('price', '核销金额');
|
||||||
|
$grid->column('profit', '资金通道结算');
|
||||||
|
|
||||||
|
$grid->column('paid_at', '打款时间');
|
||||||
|
|
||||||
|
$grid->footer(function ($query) {
|
||||||
|
$all = $query->get();
|
||||||
|
$pass = $query->where('status', 2)->get();
|
||||||
|
$reject = $query->where('status', 3)->get();
|
||||||
|
return '<label class="label label-success">全部:' . $all->count() . '张</label> '
|
||||||
|
. '<label class="label label-success">核销金额:' . $pass->sum('price') . '元</label> '
|
||||||
|
. '<label class="label label-success">资金通道结算:' . $pass->sum('profit') . '元</label> '
|
||||||
|
. '<label class="label label-success">打款金额:' . $pass->where('is_profit', 1)->sum('profit') . '元</label> ';
|
||||||
|
});
|
||||||
|
$grid->disableExport(false);
|
||||||
|
|
||||||
|
$grid->exporter(new CouponProfitExport());
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
105
app/Admin/Controllers/HomeController.php
Normal file
105
app/Admin/Controllers/HomeController.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Layout\Column;
|
||||||
|
use Encore\Admin\Layout\Content;
|
||||||
|
use Encore\Admin\Layout\Row;
|
||||||
|
use Encore\Admin\Widgets\InfoBox;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(Content $content)
|
||||||
|
{
|
||||||
|
|
||||||
|
return $content
|
||||||
|
->title('数据看版')
|
||||||
|
->row(function (Row $row) {
|
||||||
|
$row->column(2, function (Column $column) {
|
||||||
|
$column->append(new InfoBox('渠道商', 'users', 'yellow', '/admin/users?identity[identity_id]=1', User::whereHas('identity', function ($q) {$q->where('identity_id', 1);})->count()));
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
->row(function (Row $row) {
|
||||||
|
$row->column(2, function (Column $column) {
|
||||||
|
$column->append(new InfoBox('核销卡券总数', '', 'blue', '/admin/coupons', Coupon::whereIn('status', [2, 3])->count()));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) {
|
||||||
|
$column->append(new InfoBox('核销成功', '', 'blue', '/admin/coupons', Coupon::where('status', 2)->count()));
|
||||||
|
});
|
||||||
|
$row->column(2, function (Column $column) {
|
||||||
|
$column->append(new InfoBox('核销失败', '', 'black', '/admin/coupons', Coupon::where('status', 3)->count()));
|
||||||
|
});
|
||||||
|
$row->column(2, function (Column $column) {
|
||||||
|
$column->append(new InfoBox('核销金额', '', 'blue', '/admin/coupons', Coupon::where('status', 2)->sum('price')));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) {
|
||||||
|
$column->append(new InfoBox('资金通道结算', '', 'green', '/admin/coupons', Coupon::where('status', 2)->sum('profit')));
|
||||||
|
});
|
||||||
|
// $row->column(2, function (Column $column) {
|
||||||
|
// $column->append(new InfoBox('已打款金额', '', 'green', '/admin/coupons', Coupon::where('status', 2)->where('is_profit', 1)->sum('profit')));
|
||||||
|
// });
|
||||||
|
})
|
||||||
|
->row(function (Row $row) {
|
||||||
|
|
||||||
|
$coupons = Coupon::where('status', 2)
|
||||||
|
->whereDate('created_at', now()->format('Y-m-d'))
|
||||||
|
->get();
|
||||||
|
$lists = [
|
||||||
|
'ysd10' => $coupons->where('thirdPartyGoodsId', 'YSD-full100-10')->count(),
|
||||||
|
'ysd25' => $coupons->where('thirdPartyGoodsId', 'YSD-full100-25')->count(),
|
||||||
|
'ysd50' => $coupons->where('thirdPartyGoodsId', 'YSD-full100-50')->count(),
|
||||||
|
'ysd100' => $coupons->where('thirdPartyGoodsId', 'YSD-full200-100')->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('100元减10元成功今日总数', '', 'blue', '/admin/coupons', $lists['ysd10']));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('100元减25元成功今日总数', '', 'blue', '/admin/coupons', $lists['ysd25']));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('100元减50元成功今日总数', '', 'blue', '/admin/coupons', $lists['ysd50']));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('200元减100元成功今日总数', '', 'blue', '/admin/coupons', $lists['ysd100']));
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->row(function (Row $row) {
|
||||||
|
|
||||||
|
$coupons = Coupon::where('status', 2)->get();
|
||||||
|
$lists = [
|
||||||
|
'ysd10' => $coupons->where('thirdPartyGoodsId', 'YSD-full100-10')->count(),
|
||||||
|
'ysd25' => $coupons->where('thirdPartyGoodsId', 'YSD-full100-25')->count(),
|
||||||
|
'ysd50' => $coupons->where('thirdPartyGoodsId', 'YSD-full100-50')->count(),
|
||||||
|
'ysd100' => $coupons->where('thirdPartyGoodsId', 'YSD-full200-100')->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('100元减10元成功总数', '', 'blue', '/admin/coupons', $lists['ysd10']));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('100元减25元成功总数', '', 'blue', '/admin/coupons', $lists['ysd25']));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('100元减50元成功总数', '', 'blue', '/admin/coupons', $lists['ysd50']));
|
||||||
|
});
|
||||||
|
|
||||||
|
$row->column(2, function (Column $column) use ($lists) {
|
||||||
|
$column->append(new InfoBox('200元减100元成功总数', '', 'blue', '/admin/coupons', $lists['ysd100']));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
82
app/Admin/Controllers/IdentityController.php
Normal file
82
app/Admin/Controllers/IdentityController.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use RuLong\Identity\Models\Identity;
|
||||||
|
|
||||||
|
class IdentityController extends AdminController
|
||||||
|
{
|
||||||
|
protected $title = '用户身份配置';
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Identity);
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
$grid->disableFilter();
|
||||||
|
$grid->disableExport();
|
||||||
|
$grid->disableRowSelector();
|
||||||
|
$grid->tools(function ($tools) {
|
||||||
|
$tools->batch(function ($batch) {
|
||||||
|
$batch->disableDelete();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$grid->actions(function ($actions) {
|
||||||
|
$actions->disableDelete();
|
||||||
|
$actions->disableView();
|
||||||
|
});
|
||||||
|
$grid->fixColumns(0, 0);
|
||||||
|
|
||||||
|
$grid->model()->orderBy('id', 'asc');
|
||||||
|
$grid->column('id', '身份编号')->sortable();
|
||||||
|
$grid->column('title', '身份');
|
||||||
|
$grid->column('name', '等级');
|
||||||
|
|
||||||
|
$grid->column('分润规则')->display(function ($title, $column) {
|
||||||
|
return '点击查看';
|
||||||
|
})->modal(function ($model) {
|
||||||
|
$codes = $model->codes->map(function ($code) {
|
||||||
|
return $code->only(['name', 'code', 'profit']);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Table(['名称', '规则项', '分润金额(元)'], $codes->toArray());
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('remark', '说明');
|
||||||
|
$grid->column('updated_at', '修改时间');
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function form()
|
||||||
|
{
|
||||||
|
$form = new Form(new Identity);
|
||||||
|
$form->display('id', 'ID');
|
||||||
|
$form->text('title', '级别')->rules('required');
|
||||||
|
$form->text('name', '等级')->rules('required');
|
||||||
|
|
||||||
|
$form->hasMany('codes', '分润项目', function (Form\NestedForm $form) {
|
||||||
|
$form->text('name', '标题');
|
||||||
|
$form->text('code', '分润的项目');
|
||||||
|
$form->text('profit', '分润金额');
|
||||||
|
});
|
||||||
|
|
||||||
|
$form->textarea('remark', '说明')->rules('required');
|
||||||
|
|
||||||
|
$form->tools(function (Form\Tools $tools) {
|
||||||
|
$tools->disableDelete();
|
||||||
|
$tools->disableView();
|
||||||
|
});
|
||||||
|
|
||||||
|
$form->footer(function ($footer) {
|
||||||
|
$footer->disableReset();
|
||||||
|
$footer->disableViewCheck();
|
||||||
|
$footer->disableCreatingCheck();
|
||||||
|
});
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
96
app/Admin/Controllers/Log/IndexController.php
Normal file
96
app/Admin/Controllers/Log/IndexController.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Log;
|
||||||
|
|
||||||
|
use App\Models\Log;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = 'api 日志';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Log);
|
||||||
|
$grid->model()->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$grid->disableActions();
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->equal('type', '接口类型')->select([
|
||||||
|
'pingan' => '平安',
|
||||||
|
'self' => '自己',
|
||||||
|
]);
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->where("out_source->data->profitOfferItemVersion", $this->input);
|
||||||
|
}, '券类型')->select([
|
||||||
|
1 => '新版',
|
||||||
|
0 => '老版',
|
||||||
|
]);
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->where("in_source->query->redemptionCode", $this->input)
|
||||||
|
->orWhere("in_source->jiemi->redemptionCode", $this->input);
|
||||||
|
}, '券码');
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->Where("in_source->jiemi->outletId", $this->input);
|
||||||
|
}, '网点编号');
|
||||||
|
|
||||||
|
$filter->between('created_at', '提交时间')->datetime();
|
||||||
|
|
||||||
|
// $filter->equal('created_at', '提交时间')->date();
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
// $grid->column('path', '请求地址');
|
||||||
|
$grid->column('请求地址')->display(function ($title, $column) {
|
||||||
|
return '展开';
|
||||||
|
})->expand(function ($model) {
|
||||||
|
$header = ['请求地址'];
|
||||||
|
$array = [[$model->path]];
|
||||||
|
|
||||||
|
return new Table($header, $array);
|
||||||
|
});
|
||||||
|
$grid->column('method', '模式');
|
||||||
|
// $grid->column('in_source', '请求参数');
|
||||||
|
$grid->column('请求参数')->display(function () {
|
||||||
|
$in_source = $this->in_source;
|
||||||
|
unset($in_source['merchantSign']);
|
||||||
|
unset($in_source['merchantCert']);
|
||||||
|
unset($in_source['sign']);
|
||||||
|
unset($in_source['data']);
|
||||||
|
unset($in_source['json']);
|
||||||
|
unset($in_source['query']['merchantSign']);
|
||||||
|
unset($in_source['query']['merchantCert']);
|
||||||
|
return $in_source;
|
||||||
|
});
|
||||||
|
// $grid->column('out_source', '返回信息');
|
||||||
|
$grid->column('返回信息')->display(function () {
|
||||||
|
$out_source = $this->out_source;
|
||||||
|
|
||||||
|
if (!is_array($out_source)) {
|
||||||
|
return $out_source;
|
||||||
|
}
|
||||||
|
unset($out_source['merchantSign']);
|
||||||
|
unset($out_source['merchantCert']);
|
||||||
|
unset($out_source['serverCert']);
|
||||||
|
unset($out_source['serverSign']);
|
||||||
|
if (isset($out_source['data']) && is_string($out_source['data'])) {
|
||||||
|
unset($out_source['data']);
|
||||||
|
}
|
||||||
|
return $out_source;
|
||||||
|
});
|
||||||
|
$grid->column('created_at', '提交时间');
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
app/Admin/Controllers/UploadController.php
Normal file
31
app/Admin/Controllers/UploadController.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class UploadController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function editor(Request $request)
|
||||||
|
{
|
||||||
|
$files = $request->file("image");
|
||||||
|
|
||||||
|
if (empty($files)) {
|
||||||
|
return response()->json(['errno' => 5, 'msg' => '请选择文件']);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$path = $file->store(
|
||||||
|
'editor/' . date('Y/m/d'),
|
||||||
|
config('admin.upload.disk')
|
||||||
|
);
|
||||||
|
|
||||||
|
$data[] = Storage::disk(config('admin.upload.disk'))->url($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['errno' => 0, 'data' => $data];
|
||||||
|
}
|
||||||
|
}
|
||||||
261
app/Admin/Controllers/User/IndexController.php
Normal file
261
app/Admin/Controllers/User/IndexController.php
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\User;
|
||||||
|
|
||||||
|
use App\Admin\Actions\User\Profit;
|
||||||
|
use App\Admin\Actions\User\ReCode;
|
||||||
|
use App\Admin\Actions\User\RefD3Key;
|
||||||
|
use App\Admin\Exporters\UsersExport;
|
||||||
|
use App\Models\Area;
|
||||||
|
use App\Models\User;
|
||||||
|
use Auth;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use RuLong\Identity\Models\Identity;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '用户管理';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$user = Auth::guard('admin')->user();
|
||||||
|
$grid = new Grid(new User);
|
||||||
|
|
||||||
|
$grid->actions(function ($actions) use ($user) {
|
||||||
|
$actions->disableDelete();
|
||||||
|
$actions->disableView();
|
||||||
|
|
||||||
|
if ($actions->row->identity_id == 1) {
|
||||||
|
$actions->add(new RefD3Key);
|
||||||
|
}
|
||||||
|
if ($actions->row->identity_id == 1) {
|
||||||
|
$actions->add(new ReCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($actions->row->type == 'pingan' && $actions->row->identity_id == 1 && $user->id == 1) {
|
||||||
|
$actions->add(new Profit);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->tools(function (Grid\Tools $tools) {
|
||||||
|
// $tools->append(new UserImport);
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->model()->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$grid->quickSearch('username')->placeholder('登录账户');
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('username', '登录账户');
|
||||||
|
$filter->like('server_id', '渠道编号');
|
||||||
|
$filter->like('outlet_id', '网点编号');
|
||||||
|
$filter->like('PaOutletId', '平安网点id');
|
||||||
|
$filter->between('created_at', '注册时间')->datetime();
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('info.nickname', '渠道/网点');
|
||||||
|
$filter->like('server_key', '服务秘钥');
|
||||||
|
$filter->equal('identity.identity_id', '用户身份')->select([
|
||||||
|
' ' => '全部',
|
||||||
|
'1' => '渠道商',
|
||||||
|
'2' => '网点',
|
||||||
|
]);
|
||||||
|
$filter->equal('type', '所属项目')->select([
|
||||||
|
' ' => '全部',
|
||||||
|
'pingan' => '平安券',
|
||||||
|
'wo' => '沃支付',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('username', '登录账户');
|
||||||
|
$grid->column('渠道编号')->display(function () {
|
||||||
|
return $this->server_id;
|
||||||
|
});
|
||||||
|
$grid->column('网点编号')->display(function () {
|
||||||
|
return $this->outlet_id ?? '---';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('平安网点id')->display(function () {
|
||||||
|
return $this->PaOutletId ?? '---';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('所属项目')->display(function () {
|
||||||
|
return $this->type_text;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('密钥')->display(function ($title, $column) {
|
||||||
|
return '点击查看';
|
||||||
|
})->modal(function ($model) {
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'服务秘钥', $model->server_key ?? '---',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'DES3秘钥', $model->des3key ?? '---',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
return new Table(['名称', '参数'], $data);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('nickname', '渠道/网点');
|
||||||
|
$grid->column('用户身份')->display(function () {
|
||||||
|
if ($this->identity_id == 1) {
|
||||||
|
return "<p style='color:green'>" . $this->identity_text . "</p>";
|
||||||
|
} else {
|
||||||
|
return $this->identity_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('隶属渠道')->display(function () {
|
||||||
|
return $this->parent ? $this->parent->nickname : '---';
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($user->id == 1) {
|
||||||
|
$grid->column('分润规则')->display(function ($title, $column) {
|
||||||
|
return '点击展开';
|
||||||
|
})->modal(function ($model) {
|
||||||
|
if ($model->code) {
|
||||||
|
$codes = $model->code->map(function ($code) {
|
||||||
|
return $code->only(['name', 'code', 'profit']);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Table(['名称', '规则项', '分润金额(元)'], $codes->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$grid->column('created_at', '注册时间');
|
||||||
|
$grid->disableExport(false);
|
||||||
|
|
||||||
|
$grid->exporter(new UsersExport());
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
|
protected function form()
|
||||||
|
{
|
||||||
|
$province = Area::where('parent_id', 1)->pluck('name', 'code');
|
||||||
|
|
||||||
|
$form = new Form(new User);
|
||||||
|
$identity = Identity::find(1);
|
||||||
|
$form->text('username', '登录账户')
|
||||||
|
->creationRules(['required', "unique:users", 'max:11'], ['max' => '小于11个字符'])
|
||||||
|
->updateRules(['required', "unique:users,username,{{id}}"])->required();
|
||||||
|
|
||||||
|
$form->password('password', '登录密码')->creationRules('required|min:6', [
|
||||||
|
'required' => '必填',
|
||||||
|
'min' => '密码不能少于6个字符',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$form->text('PaOutletId', '平安网点id');
|
||||||
|
|
||||||
|
$form->select('type', '项目')->options(['pingan' => '平安券', 'wo' => '沃支付'])->load('parent_id', '/admin/user/parent')->required();
|
||||||
|
|
||||||
|
$form->select('parent_id', '隶属渠道')
|
||||||
|
->options(function ($option, $info) {
|
||||||
|
$user = $this;
|
||||||
|
if (!$option || ($user && $user->identity_id == 2)) {
|
||||||
|
return User::with('info')->whereHas('identity', function ($q) {
|
||||||
|
$q->where('identity_id', 1);
|
||||||
|
})->when(isset($user->id), function ($q) use ($user) {
|
||||||
|
$q->where('type', $user->type);
|
||||||
|
})->orderBy('id', 'desc')->get()->pluck('nickname', 'id');
|
||||||
|
} else {
|
||||||
|
return [0 => '没有隶属渠道'];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->default(function ($info) {
|
||||||
|
if ($info->model() && $info->model()->parent) {
|
||||||
|
return $info->model()->parent_id;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$form->select('province_id', '行政省份')
|
||||||
|
->options($province)
|
||||||
|
->load('city_id', '/admin/ajax/areas/children')
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->select('city_id', '行政城市')->options(function ($option, $info) {
|
||||||
|
if ($option) {
|
||||||
|
return Area::whereHas('parent', function ($q) use ($info) {
|
||||||
|
$q->where('code', $this->province_id);
|
||||||
|
})->pluck('name', 'code');
|
||||||
|
}
|
||||||
|
})->load('district_id', '/admin/ajax/areas/children')->required();
|
||||||
|
|
||||||
|
$form->select('district_id', '行政区域')->options(function ($option, $info) {
|
||||||
|
if ($option) {
|
||||||
|
return Area::whereHas('parent', function ($q) use ($info) {
|
||||||
|
$q->where('code', $this->city_id);
|
||||||
|
})->pluck('name', 'code');
|
||||||
|
}
|
||||||
|
})->required();
|
||||||
|
|
||||||
|
$form->divider('用户资料');
|
||||||
|
$form->text('info.nickname', '渠道/网点')->placeholder('请输入渠道/网点名称')->required();
|
||||||
|
|
||||||
|
$form->saved(function (Form $form) {
|
||||||
|
$user_id = $form->model()->id;
|
||||||
|
$user = User::find($user_id);
|
||||||
|
if ($user->identity_id == 1 && $user->code()->count() === 0) {
|
||||||
|
$userCodes = Identity::find(1)->codes->map(function ($code) {
|
||||||
|
return $code->only(['name', 'code', 'profit']);
|
||||||
|
});
|
||||||
|
$user->code()->createMany($userCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取隶属
|
||||||
|
* @author 玄尘 2020-03-12
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getParent(Request $request)
|
||||||
|
{
|
||||||
|
$type = $request->get('q');
|
||||||
|
|
||||||
|
$users = User::whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})->where('type', $type)->get();
|
||||||
|
|
||||||
|
$userRet = $users->map(function ($code) {
|
||||||
|
return [
|
||||||
|
'id' => $code->id,
|
||||||
|
'text' => $code->info->nickname,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
$userRet->prepend(['id' => '', 'text' => '']);
|
||||||
|
return $userRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
155
app/Admin/Controllers/Wo/IndexController.php
Normal file
155
app/Admin/Controllers/Wo/IndexController.php
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Wo;
|
||||||
|
|
||||||
|
use App\Admin\Actions\Wo\Unsubscribe;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\WoCoupon;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '沃钱包业务';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes:
|
||||||
|
* @Author: <C.Jason>
|
||||||
|
* @Date: 2019/9/18 14:50
|
||||||
|
* @return Grid
|
||||||
|
*/
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new WoCoupon);
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
$grid->disableBatchActions();
|
||||||
|
// $grid->disableActions();
|
||||||
|
|
||||||
|
$grid->model()->whereIn('status', [1, 2, 3])->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
$grid->actions(function ($actions) {
|
||||||
|
$actions->disableDelete();
|
||||||
|
$actions->disableView();
|
||||||
|
$actions->disableEdit();
|
||||||
|
|
||||||
|
if ($actions->row->status == 1 && $actions->row->service == 'ticketGrant') {
|
||||||
|
$actions->add(new Unsubscribe);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('status', '状态')->select([
|
||||||
|
'1' => '成功',
|
||||||
|
'2' => '失败',
|
||||||
|
'3' => '退订',
|
||||||
|
]);
|
||||||
|
$filter->equal('service', '业务')->select([
|
||||||
|
'ticketGrant' => '发券请求',
|
||||||
|
'ticketBuyback' => '返销请求',
|
||||||
|
'ticketInvalid' => '作废请求',
|
||||||
|
]);
|
||||||
|
$filter->like('mobile', '手机号');
|
||||||
|
$filter->like('logNo', '发券流水号');
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('number', '工号');
|
||||||
|
$users = User::query()
|
||||||
|
->whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})
|
||||||
|
->where('type', 'wo')
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
$filter->equal('activityId', '活动')->select([
|
||||||
|
'97LJ202025' => '25元兑换券',
|
||||||
|
'97LJ202010' => '100元兑换券',
|
||||||
|
'97LJ202018' => '180元话费券',
|
||||||
|
'97LJ202001' => '10元购物券',
|
||||||
|
]);
|
||||||
|
$filter->between('created_at', '处理时间')->datetime();
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('渠道')->display(function () {
|
||||||
|
return $this->user->nickname;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('number', '工号');
|
||||||
|
|
||||||
|
$grid->column('业务')->display(function () {
|
||||||
|
return $this->service_text;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('活动')->display(function () {
|
||||||
|
return $this->activity_text;
|
||||||
|
});
|
||||||
|
// $grid->column('手机号')->display(function ($title, $column) {
|
||||||
|
// return $this->mobile;
|
||||||
|
// })->modal(function ($model) {
|
||||||
|
// $datas = $model->logs->map(function ($data) {
|
||||||
|
// return [
|
||||||
|
// 'mobile' => $data->mobile,
|
||||||
|
// 'service_text' => $data->coupon->service_text ?? '---',
|
||||||
|
// 'activity_text' => $data->coupon->activity_text ?? '---',
|
||||||
|
// 'status_text' => $data->coupon->status_text ?? '---',
|
||||||
|
// 'created_at' => $data->created_at,
|
||||||
|
// ];
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return new Table(['手机号', '业务', '活动', '结果', '时间'], $datas->toArray());
|
||||||
|
// });
|
||||||
|
|
||||||
|
$grid->column('mobile', '手机号');
|
||||||
|
|
||||||
|
$grid->column('ticketAmt', '电子券面值');
|
||||||
|
$grid->column('状态')->display(function () {
|
||||||
|
switch ($this->status) {
|
||||||
|
case 1:
|
||||||
|
return "<span class='label label-success' >" . $this->status_text . "</span>";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return "<span class='label label-warning' >" . $this->status_text . "</span>";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return "<span class='label label-primary' >" . $this->status_text . "</span>";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->status_text;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$grid->column('remark', '处理结果');
|
||||||
|
$grid->column('原发放流水')->display(function () {
|
||||||
|
return $this->ologNo ?? '---';
|
||||||
|
});
|
||||||
|
$grid->column('logNo', '发券流水号');
|
||||||
|
$grid->column('created_at', '处理时间');
|
||||||
|
$grid->disableExport(false);
|
||||||
|
$grid->export(function ($export) {
|
||||||
|
|
||||||
|
$export->column('状态', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->column('number', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('mobile', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('ticketAmt', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->filename($this->title . date("YmdHis"));
|
||||||
|
});
|
||||||
|
// $grid->exporter(new WoCouponExport());
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
41
app/Admin/Exporters/CouponExport.php
Normal file
41
app/Admin/Exporters/CouponExport.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Exporters;
|
||||||
|
|
||||||
|
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class CouponExport extends ExcelExporter implements WithMapping
|
||||||
|
{
|
||||||
|
protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '订单金额', '资金通道结算', '状态', '处理结果', '起始时间', '到期时间', '核销时间', '省', '市', '区'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->fileName = '核销券记录' . date('YmdHis') . '.xlsx';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info->user->nickname,
|
||||||
|
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||||
|
' ' . $info->partnerOrderId,
|
||||||
|
' ' . $info->redemptionCode,
|
||||||
|
$info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$info->total,
|
||||||
|
$info->profit,
|
||||||
|
$info->status_text,
|
||||||
|
$info->remark,
|
||||||
|
$info->startTime,
|
||||||
|
$info->endTime,
|
||||||
|
$info->created_at,
|
||||||
|
($info->outlet && $info->outlet->province) ? $info->outlet->province->name : '',
|
||||||
|
($info->outlet && $info->outlet->province) ? $info->outlet->city->name : '',
|
||||||
|
($info->outlet && $info->outlet->province) ? $info->outlet->district->name : '',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
app/Admin/Exporters/CouponPassExport.php
Normal file
40
app/Admin/Exporters/CouponPassExport.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Exporters;
|
||||||
|
|
||||||
|
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class CouponPassExport extends ExcelExporter implements WithMapping
|
||||||
|
{
|
||||||
|
protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '资金通道结算', '状态', '打款', '打款时间', '核销时间', '省', '市', '区'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->fileName = '平安渠道打款处理' . date('YmdHis') . '.xlsx';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info->user->nickname,
|
||||||
|
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||||
|
' ' . $info->partnerOrderId,
|
||||||
|
' ' . $info->redemptionCode,
|
||||||
|
$info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$info->profit,
|
||||||
|
$info->status_text,
|
||||||
|
$info->profit_text,
|
||||||
|
$info->paid_at,
|
||||||
|
$info->created_at,
|
||||||
|
($info->outlet && $info->outlet->province) ? $info->outlet->province->name : '',
|
||||||
|
($info->outlet && $info->outlet->province) ? $info->outlet->city->name : '',
|
||||||
|
($info->outlet && $info->outlet->province) ? $info->outlet->district->name : '',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
33
app/Admin/Exporters/CouponProfitExport.php
Normal file
33
app/Admin/Exporters/CouponProfitExport.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Exporters;
|
||||||
|
|
||||||
|
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class CouponProfitExport extends ExcelExporter implements WithMapping
|
||||||
|
{
|
||||||
|
protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '分润金额', '打款时间'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->fileName = '已打款记录 ' . date('YmdHis') . '.xlsx';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info->user->nickname,
|
||||||
|
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||||
|
' ' . $info->partnerOrderId,
|
||||||
|
' ' . $info->redemptionCode,
|
||||||
|
$info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$info->profit,
|
||||||
|
$info->paid_at,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
36
app/Admin/Exporters/UsersExport.php
Normal file
36
app/Admin/Exporters/UsersExport.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Exporters;
|
||||||
|
|
||||||
|
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class UsersExport extends ExcelExporter implements WithMapping
|
||||||
|
{
|
||||||
|
protected $headings = ['登录账户', '渠道编号', '网点编号', '平安网点id', '所属项目', '服务秘钥', 'DES3秘钥', '渠道/网点', '用户身份', '隶属渠道', '注册时间'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->fileName = '用户列表' . date('YmdHis') . '.xlsx';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info->username,
|
||||||
|
' ' . $info->server_id ?? $info->parent->server_id,
|
||||||
|
' ' . $info->outlet_id ?? '---',
|
||||||
|
' ' . $info->PaOutletId ?? '---',
|
||||||
|
$info->type_text,
|
||||||
|
$info->server_key ?? '---',
|
||||||
|
$info->des3key ?? '---',
|
||||||
|
$info->nickname,
|
||||||
|
$info->identity_text,
|
||||||
|
$info->parent ? $info->parent->nickname : '---',
|
||||||
|
$info->created_at,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
37
app/Admin/Exporters/WoCouponExport.php
Normal file
37
app/Admin/Exporters/WoCouponExport.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Exporters;
|
||||||
|
|
||||||
|
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class WoCouponExport extends ExcelExporter implements WithMapping
|
||||||
|
{
|
||||||
|
protected $headings = ['渠道', '网点', '工号', '业务', '活动编号', '手机号', '电子券面值', '状态', '处理结果', '原发放流水', '发券流水号', '处理时间'];
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->fileName = '沃支付业务记录' . date('YmdHis') . '.xlsx';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info->user->nickname,
|
||||||
|
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||||
|
' ' . $info->number,
|
||||||
|
' ' . $info->service_text,
|
||||||
|
$info->activityId,
|
||||||
|
' ' . $info->mobile,
|
||||||
|
$info->ticketAmt,
|
||||||
|
$info->status_text,
|
||||||
|
$info->remark,
|
||||||
|
' ' . $info->ologNo,
|
||||||
|
' ' . $info->logNo,
|
||||||
|
$info->created_at,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
app/Admin/Extensions/WangEditor.php
Normal file
43
app/Admin/Extensions/WangEditor.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Extensions;
|
||||||
|
|
||||||
|
use Encore\Admin\Form\Field;
|
||||||
|
|
||||||
|
class WangEditor extends Field
|
||||||
|
{
|
||||||
|
protected $view = 'admin.wang-editor';
|
||||||
|
|
||||||
|
protected static $css = [
|
||||||
|
'/vendor/wangEditor-3.1.1/release/wangEditor.min.css',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $js = [
|
||||||
|
'/vendor/wangEditor-3.1.1/release/wangEditor.min.js',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$_token = csrf_token();
|
||||||
|
$name = $this->formatName($this->column);
|
||||||
|
|
||||||
|
$this->script = <<<EOT
|
||||||
|
|
||||||
|
var E = window.wangEditor
|
||||||
|
var editor = new E('#{$this->id}');
|
||||||
|
editor.customConfig.zIndex = 0
|
||||||
|
editor.customConfig.uploadImgServer = '/admin/uploads/editor'
|
||||||
|
editor.customConfig.uploadImgMaxSize = 2 * 1024 * 1024
|
||||||
|
editor.customConfig.uploadFileName = 'image[]'
|
||||||
|
editor.customConfig.uploadImgParams = {
|
||||||
|
_token: '{$_token}'
|
||||||
|
}
|
||||||
|
editor.customConfig.onchange = function (html) {
|
||||||
|
$('input[name=\'$name\']').val(html);
|
||||||
|
}
|
||||||
|
editor.create()
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
return parent::render();
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Admin/Extensions/mobile.php
Normal file
36
app/Admin/Extensions/mobile.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Admin\Extensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验手机号
|
||||||
|
*/
|
||||||
|
class mobile
|
||||||
|
{
|
||||||
|
|
||||||
|
public function phoneOperator()
|
||||||
|
{
|
||||||
|
$isPhone = "/^1[3-9]\d{9}$/"; //先判断正确手机号格式
|
||||||
|
|
||||||
|
if (preg_match($isPhone, $phone)) {
|
||||||
|
|
||||||
|
$isChinaMobile = "/^134[0-9]\d{7}$|^1703\d{7}$|^170[5-6]\d{7}$|^(?:13[5-9]|147|148|15[0-27-9]|178|18[2-478]|198)\d{8}$/"; //
|
||||||
|
$isChinaUnion = "/^1704\d{7}$|^170[7-9]\d{7}$|^171[0-9]\d{7}$|^(?:13[0-2]|145|15[56]|166|140|175|176|18[56])\d{8}$/"; //
|
||||||
|
$isChinaTelcom = "/^(?:133|153|169|177|173|174|170|179|18[019]|199)\d{8}$|^170[0-2]\d{7}$/"; //
|
||||||
|
|
||||||
|
if (preg_match($isChinaMobile, $phone)) {
|
||||||
|
return 'mobile'; //中国移动
|
||||||
|
} else if (preg_match($isChinaUnion, $phone)) {
|
||||||
|
return 'unicom'; //中国联通
|
||||||
|
} else if (preg_match($isChinaTelcom, $phone)) {
|
||||||
|
return 'telecom'; //中国电信
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
38
app/Admin/Imports/User.php
Normal file
38
app/Admin/Imports/User.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Imports;
|
||||||
|
|
||||||
|
use App\Models\User as UserModel;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
|
||||||
|
class User implements ToCollection
|
||||||
|
{
|
||||||
|
|
||||||
|
public function collection(Collection $rows)
|
||||||
|
{
|
||||||
|
|
||||||
|
$error = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$user = UserModel::whereHas('info', function ($q) use ($row) {
|
||||||
|
$q->where('nickname', $row[1]);
|
||||||
|
})->where('type', 'pingan')->whereNull('PaOutletId')->first();
|
||||||
|
|
||||||
|
if ($user) {
|
||||||
|
$user->PaOutletId = $row[2];
|
||||||
|
$user->save();
|
||||||
|
} else {
|
||||||
|
$error[] = $row['1'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($error) > 0) {
|
||||||
|
dd($error);
|
||||||
|
return implode(' ,', $error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
app/Admin/bootstrap.php
Normal file
32
app/Admin/bootstrap.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Admin\Extensions\WangEditor;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
//Form::forget(['map', 'editor']);
|
||||||
|
Form::extend('editor', WangEditor::class);
|
||||||
|
|
||||||
|
Form::init(function (Form $form) {
|
||||||
|
$form->disableEditingCheck();
|
||||||
|
$form->disableCreatingCheck();
|
||||||
|
$form->disableViewCheck();
|
||||||
|
|
||||||
|
$form->tools(function (Form\Tools $tools) {
|
||||||
|
// $tools->disableDelete();
|
||||||
|
$tools->disableView();
|
||||||
|
// $tools->disableList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Grid::init(function (Grid $grid) {
|
||||||
|
$grid->disableExport();
|
||||||
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||||
|
$actions->disableView();
|
||||||
|
});
|
||||||
|
$grid->disableBatchActions();
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->disableIdFilter();
|
||||||
|
});
|
||||||
|
// $grid->expandFilter();
|
||||||
|
});
|
||||||
59
app/Admin/routes.php
Normal file
59
app/Admin/routes.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Routing\Router;
|
||||||
|
|
||||||
|
Admin::routes();
|
||||||
|
|
||||||
|
Route::group([
|
||||||
|
'prefix' => config('admin.route.prefix'),
|
||||||
|
'namespace' => config('admin.route.namespace'),
|
||||||
|
'middleware' => config('admin.route.middleware'),
|
||||||
|
], function (Router $router) {
|
||||||
|
|
||||||
|
$router->get('/', 'HomeController@index')->name('admin.home');
|
||||||
|
$router->post('uploads/editor', 'UploadController@editor')->name('uploads.editor');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账户管理
|
||||||
|
*/
|
||||||
|
$router->get('accounts', 'Account\IndexController@index');
|
||||||
|
$router->get('accounts/logs', 'Account\LogController@index');
|
||||||
|
$router->resource('accounts/rules', 'Account\RuleController');
|
||||||
|
/**
|
||||||
|
* 用户管理
|
||||||
|
*/
|
||||||
|
$router->get('user/parent', 'User\IndexController@getParent');
|
||||||
|
$router->resource('users', 'User\IndexController');
|
||||||
|
//商品管理
|
||||||
|
$router->resource('goods', 'GoodsController');
|
||||||
|
//身份管理
|
||||||
|
$router->resource('identity', 'IdentityController');
|
||||||
|
|
||||||
|
$router->get('orders', 'Order\IndexController@index');
|
||||||
|
|
||||||
|
$router->get('payments', 'Payment\IndexController@index');
|
||||||
|
|
||||||
|
//用户提现管理
|
||||||
|
$router->get('cashout/logs', 'CashOutController@logs')->name('admin.cashout.logs');
|
||||||
|
$router->resource('cashout', 'CashOutController');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api 日志
|
||||||
|
*/
|
||||||
|
$router->resource('logs', 'Log\IndexController');
|
||||||
|
$router->resource('coupons', 'Coupon\IndexController'); //平安卡券
|
||||||
|
$router->resource('wos', 'Wo\IndexController'); //沃钱包业务
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 财务管理
|
||||||
|
*/
|
||||||
|
$router->resource('finances', 'Finance\IndexController');
|
||||||
|
$router->resource('financelogs', 'Finance\LogController');
|
||||||
|
|
||||||
|
$router->get('census/today', 'Finance\CensusController@today');
|
||||||
|
$router->resource('census', 'Finance\CensusController');
|
||||||
|
|
||||||
|
//省份地址
|
||||||
|
$router->get('ajax/areas/children', 'Ajax\AreaController@children')->name('areas.children');
|
||||||
|
|
||||||
|
});
|
||||||
27
app/Api/ApiServiceProvider.php
Normal file
27
app/Api/ApiServiceProvider.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class ApiServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->loadAdminRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadAdminRoutes()
|
||||||
|
{
|
||||||
|
Route::prefix('api')
|
||||||
|
->namespace('App\Api\Controllers')
|
||||||
|
->group(__DIR__ . '/routes.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
166
app/Api/Controllers/ApiResponse.php
Normal file
166
app/Api/Controllers/ApiResponse.php
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Controllers;
|
||||||
|
|
||||||
|
use App\Facades\PingAn\Log as LogFacade;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Response as FoundationResponse;
|
||||||
|
|
||||||
|
trait ApiResponse
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* [$statusCode description]
|
||||||
|
* @var [type]
|
||||||
|
*/
|
||||||
|
protected $statusCode = FoundationResponse::HTTP_OK;
|
||||||
|
protected $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密
|
||||||
|
* @param <type> $value
|
||||||
|
* @return <type>
|
||||||
|
*/
|
||||||
|
public function keyasc($value)
|
||||||
|
{
|
||||||
|
$iv = substr($this->user->des3key, 0, 8);
|
||||||
|
$ret = openssl_encrypt($value, 'DES-EDE3-CBC', $this->user->des3key, 0, $iv);
|
||||||
|
if (false === $ret) {
|
||||||
|
return openssl_error_string();
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密
|
||||||
|
* @param <type> $value
|
||||||
|
* @return <type>
|
||||||
|
*/
|
||||||
|
public function keydesc($value)
|
||||||
|
{
|
||||||
|
$iv = substr($this->user->des3key, 0, 8);
|
||||||
|
$ret = openssl_decrypt($value, 'DES-EDE3-CBC', $this->user->des3key, 0, $iv);
|
||||||
|
if (false === $ret) {
|
||||||
|
return openssl_error_string();
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkSign(Request $request)
|
||||||
|
{
|
||||||
|
$server_id = $request->server_id ?? false;
|
||||||
|
$key = $request->key ?? false;
|
||||||
|
$data = $request->data ?? false;
|
||||||
|
$addcode = $request->addcode ?? false;
|
||||||
|
$sign = $request->sign ?? false;
|
||||||
|
if (!$server_id) {
|
||||||
|
return '参数server_id不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$key) {
|
||||||
|
return '参数key不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->user = User::where('server_id', $server_id)
|
||||||
|
->where('server_key', $key)->first();
|
||||||
|
|
||||||
|
if (!$this->user) {
|
||||||
|
return '参数server_id与key不匹配';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->user->status != 1) {
|
||||||
|
return '渠道商状态不正确';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$sign) {
|
||||||
|
return '参数sign不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$data) {
|
||||||
|
return '参数data不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$addcode) {
|
||||||
|
return '参数addcode不能为空';
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = str_replace('\\', '', $data);
|
||||||
|
$data = str_replace(' ', '+', $data);
|
||||||
|
$checksign = $this->keysign($data, $addcode);
|
||||||
|
if ($checksign != $sign) {
|
||||||
|
return '参数sign不正确';
|
||||||
|
}
|
||||||
|
$keydesc = $this->keydesc($data);
|
||||||
|
$keydescArr = json_decode($this->keydesc($data), true);
|
||||||
|
if (empty($keydescArr) && !empty($keydesc)) {
|
||||||
|
return '传递的json数据不对';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $keydescArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function keysign($jsonData = '', $addcode = '')
|
||||||
|
{
|
||||||
|
$signStr = 'data=' . $jsonData . '&addcode=' . $addcode . '&key=' . $this->user->server_key;
|
||||||
|
$sign = hash_hmac('sha256', $signStr, $this->user->server_key);
|
||||||
|
return $sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功的返回
|
||||||
|
* @Author:<C.Jason>
|
||||||
|
* @Date:2018-05-22
|
||||||
|
* @param [type] $data [description]
|
||||||
|
* @param string $status [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function success($data, $log = '')
|
||||||
|
{
|
||||||
|
$jsonData = json_encode($data); //数据JSON化
|
||||||
|
$ascdata = $this->keyasc($jsonData); //加密
|
||||||
|
$addcode = sprintf("%08d", mt_rand(0, 99999999)); //随机code 验证签名用
|
||||||
|
$sign = $this->keysign($ascdata, $addcode);
|
||||||
|
$data = [
|
||||||
|
'code' => 1,
|
||||||
|
'message' => 'SUCCESS',
|
||||||
|
'data' => $ascdata,
|
||||||
|
'addcode' => $addcode,
|
||||||
|
'sign' => $sign,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($log) {
|
||||||
|
if (!is_array($data)) {
|
||||||
|
$data = [$data];
|
||||||
|
}
|
||||||
|
|
||||||
|
LogFacade::update($log, $data); //更新日志
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond(200, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function error($message = '', $log = '')
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'code' => 0,
|
||||||
|
'message' => $message,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($log) {
|
||||||
|
$message = [$message];
|
||||||
|
LogFacade::update($log, $message); //更新日志
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond(200, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function respond($code, $data, $header = [])
|
||||||
|
{
|
||||||
|
$rt = microtime(true) - LARAVEL_START;
|
||||||
|
|
||||||
|
$header = array_merge($header, ['rt' => round($rt * 1000, 2) . 'ms', 'qps' => round(1 / $rt, 1)]);
|
||||||
|
return Response::json($data, $code, $header);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
app/Api/Controllers/Controller.php
Normal file
12
app/Api/Controllers/Controller.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use ValidatesRequests, ApiResponse;
|
||||||
|
|
||||||
|
}
|
||||||
79
app/Api/Controllers/UserController.php
Normal file
79
app/Api/Controllers/UserController.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Controllers;
|
||||||
|
|
||||||
|
use App\Facades\PingAn\Log as LogFacade;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use PingAn;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$this->user = User::find(1);
|
||||||
|
$data = [
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'nickname' => $this->user->info->nickname,
|
||||||
|
];
|
||||||
|
return $this->success($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check(Request $request)
|
||||||
|
{
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res);
|
||||||
|
}
|
||||||
|
$user_id = $res['user_id'];
|
||||||
|
$user = User::find($user_id);
|
||||||
|
return $this->success($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
//核销
|
||||||
|
public function freezecoupon(Request $request)
|
||||||
|
{
|
||||||
|
$inputdata = $request->all();
|
||||||
|
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
$inputdata['jiemi'] = $res;
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $inputdata, 'self'); //添加日志
|
||||||
|
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'redemptionCode' => 'required',
|
||||||
|
'total' => 'required',
|
||||||
|
'outletId' => 'required',
|
||||||
|
], [
|
||||||
|
'redemptionCode.required' => '缺少卡券兑换码',
|
||||||
|
'total.required' => '缺少订单总额',
|
||||||
|
'outletId.required' => '缺少网点id',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$redemptionCode = $res['redemptionCode'] ?? ''; //'915400693355';
|
||||||
|
$total = $res['total'] ?? ''; //订单总额;
|
||||||
|
$outletId = $res['outletId'] ?? ''; //网点id;
|
||||||
|
$redemptionCode = trim($redemptionCode);
|
||||||
|
$outletId = trim($outletId);
|
||||||
|
|
||||||
|
$coupon = PingAn::coupondetail($redemptionCode, $total, $this->user, $outletId);
|
||||||
|
if (is_string($coupon)) {
|
||||||
|
return $this->error($coupon, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$freezecoupon = PingAn::freezecoupon($coupon, $this->user->id);
|
||||||
|
if (!is_array($freezecoupon)) {
|
||||||
|
return $this->error($freezecoupon, $log);
|
||||||
|
}
|
||||||
|
return $this->success($freezecoupon, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
263
app/Api/Controllers/WoController.php
Normal file
263
app/Api/Controllers/WoController.php
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Controllers;
|
||||||
|
|
||||||
|
use App\Facades\Wo\Log as LogFacade;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Wo;
|
||||||
|
|
||||||
|
class WoController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 180元的话费券 一次发放 活动编号 97LJ202018
|
||||||
|
* @author 玄尘 2020-03-09
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function grant180(Request $request)
|
||||||
|
{
|
||||||
|
$type = 'phoneTicket';
|
||||||
|
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $request->all(), $type); //添加日志
|
||||||
|
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'mobile' => 'required',
|
||||||
|
], [
|
||||||
|
'mobile.required' => '缺少手机号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res['user'] = $this->user;
|
||||||
|
$res['activity'] = '97LJ202018';
|
||||||
|
$res['ticketAmt'] = '180';
|
||||||
|
$res['type'] = $type;
|
||||||
|
|
||||||
|
$res = Wo::ticketGrant($res);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子提货券 一共600 每期发放25元 活动编号 97LJ202025
|
||||||
|
* @author 玄尘 2020-03-09
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function grant25(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$type = 'pickTicket25';
|
||||||
|
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $request->all(), $type); //添加日志
|
||||||
|
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'mobile' => 'required',
|
||||||
|
], [
|
||||||
|
'mobile.required' => '缺少手机号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res['user'] = $this->user;
|
||||||
|
$res['activity'] = '97LJ202025';
|
||||||
|
$res['ticketAmt'] = '25';
|
||||||
|
$res['type'] = $type;
|
||||||
|
|
||||||
|
$res = Wo::ticketGrant($res);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
return $this->success($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子提货券 每次100元 活动编号 97LJ202010
|
||||||
|
* @author 玄尘 2020-03-09
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function grant100(Request $request)
|
||||||
|
{
|
||||||
|
$type = 'pickTicket100';
|
||||||
|
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $request->all(), $type); //添加日志
|
||||||
|
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'mobile' => 'required',
|
||||||
|
], [
|
||||||
|
'mobile.required' => '缺少手机号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res['user'] = $this->user;
|
||||||
|
$res['activity'] = '97LJ202010';
|
||||||
|
$res['ticketAmt'] = '100';
|
||||||
|
$res['type'] = $type;
|
||||||
|
|
||||||
|
$res = Wo::ticketGrant($res);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($res, $log);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 10元购物券
|
||||||
|
* @author 玄尘 2020-06-11
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function grant10(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$type = 'pickTicket10';
|
||||||
|
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $request->all(), $type); //添加日志
|
||||||
|
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'mobile' => 'required',
|
||||||
|
], [
|
||||||
|
'mobile.required' => '缺少手机号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res['user'] = $this->user;
|
||||||
|
$res['activity'] = '97LJ202001';
|
||||||
|
$res['ticketAmt'] = '10';
|
||||||
|
$res['type'] = $type;
|
||||||
|
|
||||||
|
$res = Wo::ticketGrant($res);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
return $this->success($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
//退业务
|
||||||
|
public function cancel(Request $request)
|
||||||
|
{
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $request->all(), 'refund'); //添加日志
|
||||||
|
|
||||||
|
$postData = $this->checkSign($request);
|
||||||
|
if (!is_array($postData)) {
|
||||||
|
return $this->error($postData, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($postData, [
|
||||||
|
'logNo' => 'required',
|
||||||
|
], [
|
||||||
|
'logNo.required' => '缺少发券流水号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询状态
|
||||||
|
$res = Wo::ticketQuery($postData, $this->user->id);
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ConfigTicketState = config('wo.ticketState');
|
||||||
|
$ConfigTicketStateText = config('wo.ticketStateText');
|
||||||
|
$ticketState = $res['ticketState'];
|
||||||
|
|
||||||
|
if (!in_array($ticketState, ['A', 'U'])) {
|
||||||
|
$msg = (array_key_exists($ticketState, $ConfigTicketStateText)) ? $ConfigTicketStateText[$ticketState] : '未知状态';
|
||||||
|
return $this->error($msg, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断数组中是否存在下标
|
||||||
|
if (!array_key_exists($ticketState, $ConfigTicketState)) {
|
||||||
|
return $this->error('未知状态', $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$postData['service'] = $ConfigTicketState[$ticketState];
|
||||||
|
$postData['ologNo'] = $postData['logNo'];
|
||||||
|
$postData['user'] = $this->user;
|
||||||
|
|
||||||
|
//退业务
|
||||||
|
$res = Wo::ticketBack($postData, $this->user);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
return $this->success($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询状态
|
||||||
|
* @author 玄尘 2020-03-13
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function query(Request $request)
|
||||||
|
{
|
||||||
|
$log = LogFacade::insert($request->url(), 'POST', $request->all(), 'refund'); //添加日志
|
||||||
|
|
||||||
|
$postData = $this->checkSign($request);
|
||||||
|
if (!is_array($postData)) {
|
||||||
|
return $this->error($postData, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($postData, [
|
||||||
|
'logNo' => 'required',
|
||||||
|
], [
|
||||||
|
'logNo.required' => '缺少发券流水号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询状态
|
||||||
|
$res = Wo::ticketQuery($postData, $this->user->id);
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
return $this->success($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
app/Api/Middleware/Authenticate.php
Normal file
25
app/Api/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Middleware;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Closure;
|
||||||
|
use Response;
|
||||||
|
|
||||||
|
class Authenticate
|
||||||
|
{
|
||||||
|
|
||||||
|
// Authorization
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
if (Auth::guard('api')->guest()) {
|
||||||
|
return Response::json([
|
||||||
|
'status' => 'Unauthenticated',
|
||||||
|
'status_code' => 401,
|
||||||
|
'message' => '没有权限访问',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Api/routes.php
Normal file
17
app/Api/routes.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'V1'], function () {
|
||||||
|
Route::post('user/get', 'UserController@index');
|
||||||
|
Route::post('user/check', 'UserController@check');
|
||||||
|
|
||||||
|
//平安接口
|
||||||
|
Route::any('user/freezecoupon', 'UserController@freezecoupon');
|
||||||
|
//沃支付接口
|
||||||
|
Route::post('ticket/grant10', 'WoController@grant10'); //发券
|
||||||
|
Route::post('ticket/grant25', 'WoController@grant25'); //发券
|
||||||
|
Route::post('ticket/grant100', 'WoController@grant100'); //发券
|
||||||
|
Route::post('ticket/grant180', 'WoController@grant180'); //发券
|
||||||
|
Route::post('ticket/cancel', 'WoController@cancel'); //退业务
|
||||||
|
Route::post('ticket/query', 'WoController@query'); //退业务
|
||||||
|
|
||||||
|
});
|
||||||
42
app/Console/Kernel.php
Normal file
42
app/Console/Kernel.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Artisan commands provided by your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $commands = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
// $schedule->command('inspire')
|
||||||
|
// ->hourly();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
51
app/Exceptions/Handler.php
Normal file
51
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of the exception types that are not reported.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the inputs that are never flashed for validation exceptions.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report or log an exception.
|
||||||
|
*
|
||||||
|
* @param \Exception $exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function report(Exception $exception)
|
||||||
|
{
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Exception $exception
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function render($request, Exception $exception)
|
||||||
|
{
|
||||||
|
return parent::render($request, $exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Facades/PingAn/Facade.php
Normal file
13
app/Facades/PingAn/Facade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade as BaseFacade;
|
||||||
|
|
||||||
|
class Facade extends BaseFacade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return Partner::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
38
app/Facades/PingAn/Log.php
Normal file
38
app/Facades/PingAn/Log.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
use App\Models\Log as LogModel;
|
||||||
|
|
||||||
|
class Log
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入日志
|
||||||
|
* @param [type] $url [description]
|
||||||
|
* @param [type] $method [description]
|
||||||
|
* @param [type] $params [description]
|
||||||
|
* @param string $type [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public static function insert($url, $method, $params, $type = 'pingan')
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'path' => $url,
|
||||||
|
'method' => $method,
|
||||||
|
'type' => $type,
|
||||||
|
'in_source' => $params,
|
||||||
|
];
|
||||||
|
|
||||||
|
$info = LogModel::create($data);
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新日志
|
||||||
|
public static function update($log, $params)
|
||||||
|
{
|
||||||
|
$log->out_source = $params;
|
||||||
|
$log->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
211
app/Facades/PingAn/Partner--old.php--
Normal file
211
app/Facades/PingAn/Partner--old.php--
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class Partner extends PingAn
|
||||||
|
{
|
||||||
|
|
||||||
|
public function action()
|
||||||
|
{
|
||||||
|
$this->getToken();
|
||||||
|
return $this->getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验平安券编号
|
||||||
|
* @param [type] $redemptionCode 平安券编号
|
||||||
|
* @param [type] $total 订单金额
|
||||||
|
* @param [type] $user 登陆的用户
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function checkCode($redemptionCode, $total, $user)
|
||||||
|
{
|
||||||
|
$code = $user->code()->where('code', $redemptionCode)->first();
|
||||||
|
|
||||||
|
if (!$code) {
|
||||||
|
return "未找到此项平安券编号";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = explode('-', $redemptionCode);
|
||||||
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
|
return "平安券编号码格式不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
preg_match('/(\d{3}(\.\d+)?)/is', $full, $result);
|
||||||
|
|
||||||
|
if (!is_array($result)) {
|
||||||
|
return "平安券编号不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($total)) {
|
||||||
|
return "订单金额必须是数字";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result[0] > $total) {
|
||||||
|
return '订单金额不足,平安券编号不可使用。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = [
|
||||||
|
'total' => $result[0],
|
||||||
|
'price' => $price,
|
||||||
|
'profit' => $code->profit,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过兑换码查询平安券编号详情V2
|
||||||
|
* @param [type] $redemptionCode 平安券编号
|
||||||
|
* @param [type] $total [订单金额]
|
||||||
|
* @param [type] $user [用户模型]
|
||||||
|
* @param [type] $outletId [提交的网点id]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function coupondetail($redemptionCode, $total, $user, $outletId)
|
||||||
|
{
|
||||||
|
|
||||||
|
//查询网点是否存在
|
||||||
|
$info = User::where('outlet_id', $outletId)->first();
|
||||||
|
|
||||||
|
if (!$info) {
|
||||||
|
return '网点编号错误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->baseUri . 'partner/v2/coupondetail';
|
||||||
|
$params = [
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
];
|
||||||
|
|
||||||
|
$res = $this->getPingAnData($url, $params);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
if ($res['code'] != 200) {
|
||||||
|
return $res['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$coupon = $res['data'];
|
||||||
|
if ($coupon['status'] > 0) {
|
||||||
|
return '平安券编号不可用';
|
||||||
|
}
|
||||||
|
|
||||||
|
$startTime = Carbon::parse($coupon['startTime']);
|
||||||
|
$endTime = Carbon::parse($coupon['endTime']);
|
||||||
|
$now = now();
|
||||||
|
if ($startTime->gt($now)) {
|
||||||
|
return '平安券编号未开始使用';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($now->gt($endTime)) {
|
||||||
|
return '平安券编号已过期';
|
||||||
|
}
|
||||||
|
|
||||||
|
$productItemList = $coupon['productItemList'];
|
||||||
|
if (!is_array($productItemList) || !is_array($productItemList[0])) {
|
||||||
|
return '平安券编号数据有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$thirdPartyGoodsId = $productItemList[0]['thirdPartyGoodsId'] ?? ''; //YSD-full100-25
|
||||||
|
$productId = $productItemList[0]['productId'] ?? '';
|
||||||
|
$outletList = $productItemList[0]['outletList'];
|
||||||
|
if (!is_array($outletList) || !is_array($outletList[0])) {
|
||||||
|
return '网点信息有误!';
|
||||||
|
}
|
||||||
|
|
||||||
|
$PaOutletId = $outletList[0]['outletNo'];
|
||||||
|
if (!$thirdPartyGoodsId) {
|
||||||
|
return '平安券编号id有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$productId) {
|
||||||
|
return '商品id有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = $this->checkCode($thirdPartyGoodsId, $total, $user);
|
||||||
|
if (!is_array($ticket)) {
|
||||||
|
return $ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
$couponData = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'outletId' => $outletId,
|
||||||
|
'productId' => $productId,
|
||||||
|
'PaOutletId' => $PaOutletId,
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
'thirdPartyGoodsId' => $thirdPartyGoodsId,
|
||||||
|
'couponId' => $coupon['couponId'],
|
||||||
|
'couponName' => $coupon['couponName'],
|
||||||
|
'price' => $ticket['price'],
|
||||||
|
'total' => $total,
|
||||||
|
'profit' => $ticket['profit'],
|
||||||
|
'status' => $coupon['status'],
|
||||||
|
'conponType' => $coupon['conponType'],
|
||||||
|
'startTime' => $coupon['startTime'],
|
||||||
|
'endTime' => $coupon['endTime'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$couponModel = Coupon::create($couponData);
|
||||||
|
return $couponModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过兑换码核销卡卷(直接核销)
|
||||||
|
* @param [type] $redemptionCode 平安券编号码
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function freezecoupon($coupon)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'couponNo' => $coupon->redemptionCode,
|
||||||
|
'partnerOrderId' => date('ymdHis') . sprintf("%0" . strlen(999999) . "d", mt_rand(0, 999999)),
|
||||||
|
'outletId' => $coupon->PaOutletId,
|
||||||
|
'productId' => $coupon->productId,
|
||||||
|
'timestamp' => $this->getMsecTime(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$url = $this->baseUri . 'partner/redemption';
|
||||||
|
$str = $this->encrypt($params);
|
||||||
|
$res = $this->getPingAnData($url, [], ['data' => $str]);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
$coupon->remark = $res;
|
||||||
|
$coupon->status = 3;
|
||||||
|
$coupon->save();
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($res['code'] != 200) {
|
||||||
|
$coupon->remark = $res['code'] . '--' . $res['message'];
|
||||||
|
$coupon->status = 3;
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
return $res['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $res['data'];
|
||||||
|
|
||||||
|
$coupon->remark = $data['message'];
|
||||||
|
$coupon->partnerOrderId = $params['partnerOrderId'];
|
||||||
|
$coupon->orderId = $data['orderId'];
|
||||||
|
$coupon->subOrderId = $data['subOrderId'];
|
||||||
|
$coupon->totalPoints = $data['totalPoints'];
|
||||||
|
$coupon->totalAmount = $data['totalAmount'];
|
||||||
|
$coupon->status = ($data['status'] == 1) ? 2 : 3;
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
//返回的数据
|
||||||
|
$resdata = [
|
||||||
|
'price' => $coupon->price,
|
||||||
|
];
|
||||||
|
//核销成功 执行分润
|
||||||
|
$coupon->profit();
|
||||||
|
return $resdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
271
app/Facades/PingAn/Partner.php
Normal file
271
app/Facades/PingAn/Partner.php
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class Partner extends PingAn
|
||||||
|
{
|
||||||
|
|
||||||
|
public function action()
|
||||||
|
{
|
||||||
|
$this->getToken();
|
||||||
|
return $this->getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验平安券编号
|
||||||
|
* @param [type] $thirdPartyGoodsId 平安券规则 YSD-full100-10
|
||||||
|
* @param [type] $total 订单金额
|
||||||
|
* @param [type] $user 登陆的用户
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function checkCode($thirdPartyGoodsId, $total, $user)
|
||||||
|
{
|
||||||
|
$code = $user->code()->where('code', $thirdPartyGoodsId)->first();
|
||||||
|
|
||||||
|
if (!$code) {
|
||||||
|
return "未找到此项平安券规则";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = explode('-', $thirdPartyGoodsId);
|
||||||
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
|
return "平安券规则格式不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
// preg_match('/(\d{3}(\.\d+)?)/is', $full, $result);
|
||||||
|
preg_match('/\d+/', $full, $result);
|
||||||
|
|
||||||
|
if (empty($result)) {
|
||||||
|
return "平安券规则格式不正确.";
|
||||||
|
}
|
||||||
|
if (!is_array($result)) {
|
||||||
|
return "平安券编号不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($total)) {
|
||||||
|
return "订单金额必须是数字";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result[0] > $total) {
|
||||||
|
return '订单金额不足,平安券编号不可使用。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = [
|
||||||
|
'total' => $result[0],
|
||||||
|
'price' => $price,
|
||||||
|
'profit' => $code->profit,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过兑换码查询平安券编号详情V2
|
||||||
|
* @param [type] $redemptionCode 平安券编号
|
||||||
|
* @param [type] $total [订单金额]
|
||||||
|
* @param [type] $user [用户模型]
|
||||||
|
* @param [type] $outletId [提交的网点id]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function coupondetail($redemptionCode, $total, $user, $outletId)
|
||||||
|
{
|
||||||
|
|
||||||
|
//查询网点是否存在
|
||||||
|
$info = User::where('outlet_id', $outletId)->first();
|
||||||
|
|
||||||
|
if (!$info) {
|
||||||
|
return '网点编号错误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->baseUri . 'partner/v2/coupondetail';
|
||||||
|
$params = [
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
'outletNo' => $info->PaOutletId,
|
||||||
|
'thirdOutletNo' => $info->outlet_id,
|
||||||
|
];
|
||||||
|
$res = $this->getPingAnData($url, $params);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($res['code'] != 200) {
|
||||||
|
return $res['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$coupon = $res['data'];
|
||||||
|
|
||||||
|
if ($coupon['status'] > 0) {
|
||||||
|
if (isset(config('pingan.coupon_status')[$coupon['status']])) {
|
||||||
|
return '平安券' . config('pingan.coupon_status')[$coupon['status']];
|
||||||
|
}
|
||||||
|
return '平安券编号不可用';
|
||||||
|
}
|
||||||
|
|
||||||
|
$startTime = Carbon::parse($coupon['startTime']);
|
||||||
|
$endTime = Carbon::parse($coupon['endTime']);
|
||||||
|
$now = now();
|
||||||
|
if ($startTime->gt($now)) {
|
||||||
|
return '平安券编号未开始使用';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($now->gt($endTime)) {
|
||||||
|
return '平安券编号已过期';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pinganData = $this->getPinganProduct($coupon, $info);
|
||||||
|
|
||||||
|
if (is_string($pinganData)) {
|
||||||
|
return $pinganData;
|
||||||
|
}
|
||||||
|
|
||||||
|
$thirdPartyGoodsId = $pinganData['thirdPartyGoodsId'];
|
||||||
|
$productId = $pinganData['productId'];
|
||||||
|
$PaOutletId = $pinganData['PaOutletId'];
|
||||||
|
|
||||||
|
$ticket = $this->checkCode($thirdPartyGoodsId, $total, $user);
|
||||||
|
if (!is_array($ticket)) {
|
||||||
|
return $ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
$couponData = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'outletId' => $outletId,
|
||||||
|
'productId' => $productId,
|
||||||
|
'PaOutletId' => $PaOutletId,
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
'thirdPartyGoodsId' => $thirdPartyGoodsId,
|
||||||
|
'couponName' => $coupon['couponName'],
|
||||||
|
'price' => $ticket['price'],
|
||||||
|
'total' => $total,
|
||||||
|
'profit' => $ticket['profit'],
|
||||||
|
'status' => $coupon['status'],
|
||||||
|
'startTime' => $coupon['startTime'],
|
||||||
|
'endTime' => $coupon['endTime'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$couponModel = Coupon::create($couponData);
|
||||||
|
return $couponModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找平安商品id
|
||||||
|
* @author 玄尘 2020-04-04
|
||||||
|
* @param [type] $coupon 平安返回的券信息
|
||||||
|
* @param [type] $user 网点用户数据
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getPinganProduct($coupon, $user)
|
||||||
|
{
|
||||||
|
$PaOutletId = $user->PaOutletId;
|
||||||
|
$outlet_id = $user->outlet_id;
|
||||||
|
$profitOfferItemVersion = $coupon['profitOfferItemVersion'];
|
||||||
|
if (!$PaOutletId && $profitOfferItemVersion != 1) {
|
||||||
|
return '参数错误,缺少平安网点信息';
|
||||||
|
}
|
||||||
|
|
||||||
|
$productItemList = $coupon['productItemList'];
|
||||||
|
if (!is_array($productItemList) || !is_array($productItemList[0])) {
|
||||||
|
return '平安券编号数据有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环查找
|
||||||
|
foreach ($productItemList as $key => $item) {
|
||||||
|
$productId = $item['productId'];
|
||||||
|
$thirdPartyGoodsId = $item['thirdPartyGoodsId'];
|
||||||
|
$outletList = $item['outletList'];
|
||||||
|
if (!is_array($outletList) || !is_array($outletList[0])) {
|
||||||
|
return '网点信息有误!';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$outletList = collect($outletList);
|
||||||
|
//判断是新版还是旧版
|
||||||
|
if ($profitOfferItemVersion) {
|
||||||
|
//新版通过第三方查询
|
||||||
|
$first = $outletList->firstWhere('thirdOutletNo', $outlet_id);
|
||||||
|
|
||||||
|
if ($first) {
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//旧版通过平安网点查询
|
||||||
|
$first = $outletList->firstWhere('outletNo', $PaOutletId);
|
||||||
|
if ($first) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$thirdPartyGoodsId) {
|
||||||
|
return '平安券编号规则有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$productId) {
|
||||||
|
return '商品id有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'thirdPartyGoodsId' => $thirdPartyGoodsId,
|
||||||
|
'productId' => $productId,
|
||||||
|
'PaOutletId' => $first['outletNo'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过兑换码核销卡卷(直接核销)
|
||||||
|
* @param [type] $redemptionCode 平安券编号码
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function freezecoupon($coupon)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'couponNo' => $coupon->redemptionCode,
|
||||||
|
'partnerOrderId' => date('ymdHis') . sprintf("%0" . strlen(999999) . "d", mt_rand(0, 999999)),
|
||||||
|
'outletId' => $coupon->PaOutletId,
|
||||||
|
'productId' => $coupon->productId,
|
||||||
|
'timestamp' => $this->getMsecTime(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$url = $this->baseUri . 'partner/redemption';
|
||||||
|
$str = $this->encrypt($params);
|
||||||
|
$res = $this->getPingAnData($url, [], ['data' => $str]);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
$coupon->remark = $res;
|
||||||
|
$coupon->status = 3;
|
||||||
|
$coupon->save();
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($res['code'] != 200) {
|
||||||
|
$coupon->remark = $res['code'] . '--' . $res['message'];
|
||||||
|
$coupon->status = 3;
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
return $res['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $res['data'];
|
||||||
|
|
||||||
|
$coupon->remark = $data['message'];
|
||||||
|
$coupon->partnerOrderId = $params['partnerOrderId'];
|
||||||
|
$coupon->status = ($data['status'] == 1) ? 2 : 3;
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
//返回的数据
|
||||||
|
$resdata = [
|
||||||
|
'price' => $coupon->price,
|
||||||
|
'name' => $coupon->couponName,
|
||||||
|
'total' => $coupon->total,
|
||||||
|
];
|
||||||
|
//核销成功 执行分润
|
||||||
|
$coupon->profit();
|
||||||
|
return $resdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
252
app/Facades/PingAn/Partner.php0520
Normal file
252
app/Facades/PingAn/Partner.php0520
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class Partner extends PingAn
|
||||||
|
{
|
||||||
|
|
||||||
|
public function action()
|
||||||
|
{
|
||||||
|
$this->getToken();
|
||||||
|
return $this->getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验平安券编号
|
||||||
|
* @param [type] $redemptionCode 平安券编号
|
||||||
|
* @param [type] $total 订单金额
|
||||||
|
* @param [type] $user 登陆的用户
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function checkCode($redemptionCode, $total, $user)
|
||||||
|
{
|
||||||
|
$code = $user->code()->where('code', $redemptionCode)->first();
|
||||||
|
|
||||||
|
if (!$code) {
|
||||||
|
return "未找到此项平安券编号";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = explode('-', $redemptionCode);
|
||||||
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
|
return "平安券编号码格式不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
preg_match('/(\d{3}(\.\d+)?)/is', $full, $result);
|
||||||
|
|
||||||
|
if (!is_array($result)) {
|
||||||
|
return "平安券编号不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($total)) {
|
||||||
|
return "订单金额必须是数字";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($result[0] > $total) {
|
||||||
|
return '订单金额不足,平安券编号不可使用。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = [
|
||||||
|
'total' => $result[0],
|
||||||
|
'price' => $price,
|
||||||
|
'profit' => $code->profit,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过兑换码查询平安券编号详情V2
|
||||||
|
* @param [type] $redemptionCode 平安券编号
|
||||||
|
* @param [type] $total [订单金额]
|
||||||
|
* @param [type] $user [用户模型]
|
||||||
|
* @param [type] $outletId [提交的网点id]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function coupondetail($redemptionCode, $total, $user, $outletId)
|
||||||
|
{
|
||||||
|
|
||||||
|
//查询网点是否存在
|
||||||
|
$info = User::where('outlet_id', $outletId)->first();
|
||||||
|
|
||||||
|
if (!$info) {
|
||||||
|
return '网点编号错误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->baseUri . 'partner/v2/coupondetail';
|
||||||
|
$params = [
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
];
|
||||||
|
|
||||||
|
$res = $this->getPingAnData($url, $params);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
if ($res['code'] != 200) {
|
||||||
|
return $res['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$coupon = $res['data'];
|
||||||
|
if ($coupon['status'] > 0) {
|
||||||
|
return '平安券编号不可用';
|
||||||
|
}
|
||||||
|
|
||||||
|
$startTime = Carbon::parse($coupon['startTime']);
|
||||||
|
$endTime = Carbon::parse($coupon['endTime']);
|
||||||
|
$now = now();
|
||||||
|
if ($startTime->gt($now)) {
|
||||||
|
return '平安券编号未开始使用';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($now->gt($endTime)) {
|
||||||
|
return '平安券编号已过期';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pinganData = $this->getPinganProduct($coupon, $info);
|
||||||
|
|
||||||
|
if (is_string($pinganData)) {
|
||||||
|
return $pinganData;
|
||||||
|
}
|
||||||
|
|
||||||
|
$thirdPartyGoodsId = $pinganData['thirdPartyGoodsId'];
|
||||||
|
$productId = $pinganData['productId'];
|
||||||
|
$PaOutletId = $pinganData['PaOutletId'];
|
||||||
|
|
||||||
|
$ticket = $this->checkCode($thirdPartyGoodsId, $total, $user);
|
||||||
|
if (!is_array($ticket)) {
|
||||||
|
return $ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
$couponData = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'outletId' => $outletId,
|
||||||
|
'productId' => $productId,
|
||||||
|
'PaOutletId' => $PaOutletId,
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
'thirdPartyGoodsId' => $thirdPartyGoodsId,
|
||||||
|
'couponId' => $coupon['couponId'],
|
||||||
|
'couponName' => $coupon['couponName'],
|
||||||
|
'price' => $ticket['price'],
|
||||||
|
'total' => $total,
|
||||||
|
'profit' => $ticket['profit'],
|
||||||
|
'status' => $coupon['status'],
|
||||||
|
'conponType' => $coupon['conponType'],
|
||||||
|
'startTime' => $coupon['startTime'],
|
||||||
|
'endTime' => $coupon['endTime'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$couponModel = Coupon::create($couponData);
|
||||||
|
return $couponModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找平安商品id
|
||||||
|
* @author 玄尘 2020-04-04
|
||||||
|
* @param [type] $coupon 平安返回的券信息
|
||||||
|
* @param [type] $user 网点用户数据
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getPinganProduct($coupon, $user)
|
||||||
|
{
|
||||||
|
$PaOutletId = $user->PaOutletId;
|
||||||
|
|
||||||
|
if (!$PaOutletId) {
|
||||||
|
return '参数错误,缺少平安网点信息';
|
||||||
|
}
|
||||||
|
|
||||||
|
$productItemList = $coupon['productItemList'];
|
||||||
|
if (!is_array($productItemList) || !is_array($productItemList[0])) {
|
||||||
|
return '平安券编号数据有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环查找
|
||||||
|
foreach ($productItemList as $key => $item) {
|
||||||
|
$productId = $item['productId'];
|
||||||
|
$thirdPartyGoodsId = $item['thirdPartyGoodsId'];
|
||||||
|
$outletList = $item['outletList'];
|
||||||
|
if (!is_array($outletList) || !is_array($outletList[0])) {
|
||||||
|
return '网点信息有误!';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$outletList = collect($outletList);
|
||||||
|
$first = $outletList->firstWhere('outletNo', $PaOutletId);
|
||||||
|
if ($first) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$thirdPartyGoodsId) {
|
||||||
|
return '平安券编号规则有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$productId) {
|
||||||
|
return '商品id有误';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'thirdPartyGoodsId' => $thirdPartyGoodsId,
|
||||||
|
'productId' => $productId,
|
||||||
|
'PaOutletId' => $PaOutletId,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过兑换码核销卡卷(直接核销)
|
||||||
|
* @param [type] $redemptionCode 平安券编号码
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function freezecoupon($coupon)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'couponNo' => $coupon->redemptionCode,
|
||||||
|
'partnerOrderId' => date('ymdHis') . sprintf("%0" . strlen(999999) . "d", mt_rand(0, 999999)),
|
||||||
|
'outletId' => $coupon->PaOutletId,
|
||||||
|
'productId' => $coupon->productId,
|
||||||
|
'timestamp' => $this->getMsecTime(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$url = $this->baseUri . 'partner/redemption';
|
||||||
|
$str = $this->encrypt($params);
|
||||||
|
$res = $this->getPingAnData($url, [], ['data' => $str]);
|
||||||
|
if (!is_array($res)) {
|
||||||
|
$coupon->remark = $res;
|
||||||
|
$coupon->status = 3;
|
||||||
|
$coupon->save();
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($res['code'] != 200) {
|
||||||
|
$coupon->remark = $res['code'] . '--' . $res['message'];
|
||||||
|
$coupon->status = 3;
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
return $res['message'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $res['data'];
|
||||||
|
|
||||||
|
$coupon->remark = $data['message'];
|
||||||
|
$coupon->partnerOrderId = $params['partnerOrderId'];
|
||||||
|
$coupon->orderId = $data['orderId'];
|
||||||
|
$coupon->subOrderId = $data['subOrderId'];
|
||||||
|
$coupon->totalPoints = $data['totalPoints'];
|
||||||
|
$coupon->totalAmount = $data['totalAmount'];
|
||||||
|
$coupon->status = ($data['status'] == 1) ? 2 : 3;
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
//返回的数据
|
||||||
|
$resdata = [
|
||||||
|
'price' => $coupon->price,
|
||||||
|
];
|
||||||
|
//核销成功 执行分润
|
||||||
|
$coupon->profit();
|
||||||
|
return $resdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
188
app/Facades/PingAn/PingAn.php
Normal file
188
app/Facades/PingAn/PingAn.php
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
use App\Facades\PingAn\Log as LogFacade;
|
||||||
|
use App\Models\PinganToken;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\RequestException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超市购物券
|
||||||
|
*/
|
||||||
|
class PingAn
|
||||||
|
{
|
||||||
|
protected $this_type;
|
||||||
|
protected $baseUri;
|
||||||
|
protected $tokenUri;
|
||||||
|
protected $client_id;
|
||||||
|
protected $grant_type;
|
||||||
|
protected $client_secret;
|
||||||
|
protected $access_token;
|
||||||
|
protected $userName;
|
||||||
|
protected $error;
|
||||||
|
protected $aes_code; //aes 密钥
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->this_type = config('pingan.this_type');
|
||||||
|
$pingan = config('pingan.' . $this->this_type);
|
||||||
|
|
||||||
|
$this->baseUri = $pingan['Uri'];
|
||||||
|
$this->tokenUri = $pingan['tokenUri'];
|
||||||
|
$this->client_id = $pingan['client_id'];
|
||||||
|
$this->grant_type = $pingan['grant_type'];
|
||||||
|
$this->userName = $pingan['userName'];
|
||||||
|
$this->client_secret = $pingan['client_secret'];
|
||||||
|
$this->aes_code = $pingan['AES_CODE'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取access_token
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getToken()
|
||||||
|
{
|
||||||
|
//从数据库里找token
|
||||||
|
$token = PinganToken::where('type', $this->this_type)->orderBy('id', 'desc')->first();
|
||||||
|
if ($token) {
|
||||||
|
$access_token = $token->access_token;
|
||||||
|
$expires_in = $token->expires_in;
|
||||||
|
$get_token_time = $token->get_token_time;
|
||||||
|
$diffMinutes = $get_token_time->diffInMinutes(now(), false);
|
||||||
|
if ($diffMinutes < $expires_in) {
|
||||||
|
$this->access_token = $access_token;
|
||||||
|
} else {
|
||||||
|
$this->getAjaxToken();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->getAjaxToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取毫秒级别的时间戳
|
||||||
|
*/
|
||||||
|
public function getMsecTime()
|
||||||
|
{
|
||||||
|
list($msec, $sec) = explode(' ', microtime());
|
||||||
|
$msectime = (float) sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
|
||||||
|
$msectime = explode('.', $msectime);
|
||||||
|
|
||||||
|
return $msectime[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求平台 access_token
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getAjaxToken()
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
'client_id' => $this->client_id,
|
||||||
|
'grant_type' => $this->grant_type,
|
||||||
|
'client_secret' => $this->client_secret,
|
||||||
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$log = LogFacade::insert($this->tokenUri, 'POST', $params, 'pingan'); //日志
|
||||||
|
$client = new Client();
|
||||||
|
$response = $client->request('POST', $this->tokenUri, [
|
||||||
|
'form_params' => $params,
|
||||||
|
]);
|
||||||
|
$body = $response->getBody();
|
||||||
|
$content = $body->getContents();
|
||||||
|
$result = json_decode($content, true);
|
||||||
|
LogFacade::update($log, $result); //更新日志
|
||||||
|
if ($result['ret'] > 0) {
|
||||||
|
$this->error = $result['msg'];
|
||||||
|
} else {
|
||||||
|
$data = $result['data'];
|
||||||
|
$token = PinganToken::create([
|
||||||
|
'type' => $this->this_type,
|
||||||
|
'access_token' => $data['access_token'],
|
||||||
|
'expires_in' => $data['expires_in'],
|
||||||
|
'get_token_time' => now(),
|
||||||
|
]);
|
||||||
|
$this->access_token = $data['access_token'];
|
||||||
|
$this->error = '';
|
||||||
|
}
|
||||||
|
} catch (RequestException $e) {
|
||||||
|
LogFacade::update($log, [$e->getMessage()]); //更新日志
|
||||||
|
$this->error = $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用获取数据接口
|
||||||
|
* @param [type] $url 请求地址
|
||||||
|
* @param array $query 传递参数
|
||||||
|
* @param array $json 需要传的json数据
|
||||||
|
* @param string $method 方式
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getPingAnData($url, $query = [], $json = [], $method = 'POST')
|
||||||
|
{
|
||||||
|
$this->getToken();
|
||||||
|
|
||||||
|
if ($this->error) {
|
||||||
|
return $this->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$postData = [
|
||||||
|
'query' => array_merge([
|
||||||
|
'access_token' => $this->access_token,
|
||||||
|
'request_id' => $this->getMsecTime(),
|
||||||
|
'userName' => $this->userName,
|
||||||
|
], $query),
|
||||||
|
'json' => $json,
|
||||||
|
'headers' => [
|
||||||
|
'Content-Type' => 'application/json;charset=utf-8',
|
||||||
|
'accept' => 'application/json;charset=utf-8',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$log = LogFacade::insert($url, $method, $postData, 'pingan'); //日志
|
||||||
|
|
||||||
|
try {
|
||||||
|
$client = new Client();
|
||||||
|
$response = $client->request($method, $url, $postData);
|
||||||
|
$body = $response->getBody();
|
||||||
|
$content = $body->getContents();
|
||||||
|
$result = json_decode($content, true);
|
||||||
|
|
||||||
|
$retData = '';
|
||||||
|
|
||||||
|
if ($result['ret'] > 0) {
|
||||||
|
$retData = $result['msg'];
|
||||||
|
} else {
|
||||||
|
$retData = $result['data'];
|
||||||
|
}
|
||||||
|
LogFacade::update($log, $retData); //更新日志
|
||||||
|
|
||||||
|
return $retData;
|
||||||
|
} catch (RequestException $e) {
|
||||||
|
LogFacade::update($log, [$e->getMessage()]); //更新日志
|
||||||
|
return ['ret' => '99999', $e->getMessage()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//加密
|
||||||
|
public function encrypt($str)
|
||||||
|
{
|
||||||
|
if (is_array($str)) {
|
||||||
|
$str = json_encode($str);
|
||||||
|
}
|
||||||
|
$data = openssl_encrypt($str, 'aes-128-ecb', $this->aes_code, OPENSSL_RAW_DATA);
|
||||||
|
return base64_encode($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//解密
|
||||||
|
public function decrypt($str)
|
||||||
|
{
|
||||||
|
$encrypted = base64_decode($str);
|
||||||
|
return openssl_decrypt($encrypted, 'aes-128-ecb', $this->aes_code, OPENSSL_RAW_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
app/Facades/PingAn/Profit.php
Normal file
25
app/Facades/PingAn/Profit.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\PingAn;
|
||||||
|
|
||||||
|
class Profit
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行分润
|
||||||
|
* @author 玄尘 2020-03-12
|
||||||
|
* @param [type] $user [description]
|
||||||
|
* @param [type] $price [description]
|
||||||
|
* @param string $rule [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public static function insert($user, $coupon, $rule = 'freeze')
|
||||||
|
{
|
||||||
|
$source = [
|
||||||
|
'coupon_id' => $coupon->id,
|
||||||
|
'redemptionCode' => $coupon->redemptionCode,
|
||||||
|
];
|
||||||
|
return $user->account->rule($rule, $coupon->profit, false, $source);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
290
app/Facades/Wo/Action.php
Normal file
290
app/Facades/Wo/Action.php
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\Wo;
|
||||||
|
|
||||||
|
use App\Jobs\TicketBack;
|
||||||
|
use App\Models\WoCoupon;
|
||||||
|
|
||||||
|
class Action extends Wo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* [ticketGrant 沃支付发券接口]
|
||||||
|
* @author 玄尘 2020-02-13
|
||||||
|
* @param [type] $data [post 过来的数据 array]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function ticketGrant($data)
|
||||||
|
{
|
||||||
|
$mobile = $data['mobile'];
|
||||||
|
$activity = $data['activity'];
|
||||||
|
$type = $data['type'];
|
||||||
|
$user = $data['user'];
|
||||||
|
|
||||||
|
// $activity .= '--';
|
||||||
|
|
||||||
|
//如果是话费券
|
||||||
|
if ($type == 'phoneTicket') {
|
||||||
|
$info = WoCoupon::where('mobile', $mobile)->where('status', 1)->where('activityId', $activity)->first();
|
||||||
|
if ($info) {
|
||||||
|
return '已经领取过了';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$logNo = 'YSD' . $this->getMsecTime();
|
||||||
|
$params = [
|
||||||
|
'charset' => $this->charset,
|
||||||
|
'version' => $this->version,
|
||||||
|
'merchantSign' => '',
|
||||||
|
'merchantCert' => '',
|
||||||
|
'signType' => $this->signType,
|
||||||
|
'service' => 'ticketGrant',
|
||||||
|
'requestId' => $logNo,
|
||||||
|
'merchantId' => $this->merchant_id,
|
||||||
|
'activityId' => $activity,
|
||||||
|
'mobilepNo' => $mobile,
|
||||||
|
'ticketAmt' => $data['ticketAmt'],
|
||||||
|
'logNo' => $logNo,
|
||||||
|
'channelType' => $this->channelType,
|
||||||
|
'transactionDate' => now()->format('Ymd'),
|
||||||
|
'effectDate' => now()->format('Ymd'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$merchantCert = $this->merchantCert();
|
||||||
|
if (!$merchantCert) {
|
||||||
|
return '证书文件有错误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$couponData = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'number' => $data['number'] ?? '',
|
||||||
|
'service' => 'ticketGrant',
|
||||||
|
'ticketAmt' => $data['ticketAmt'] ?? '0.00',
|
||||||
|
'mobile' => $mobile,
|
||||||
|
'logNo' => $params['logNo'],
|
||||||
|
'activityId' => $activity,
|
||||||
|
];
|
||||||
|
|
||||||
|
//记录
|
||||||
|
$coupon = WoCoupon::create($couponData);
|
||||||
|
|
||||||
|
//签名
|
||||||
|
$merchantSign = $this->rsaSign($params);
|
||||||
|
if (is_array($merchantSign)) {
|
||||||
|
return $merchantSign['msg'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//验签
|
||||||
|
// $checkdata = $params;
|
||||||
|
// $res = $this->rsaCheck($checkdata, $merchantSign);
|
||||||
|
// dd($res);
|
||||||
|
$params['merchantSign'] = $merchantSign;
|
||||||
|
$params['merchantCert'] = $merchantCert;
|
||||||
|
|
||||||
|
$res = $this->getWoData($params);
|
||||||
|
|
||||||
|
//判断是否是数组,不是数组返回错误信息
|
||||||
|
if (!is_array($res)) {
|
||||||
|
$coupon->remark = $res;
|
||||||
|
$coupon->status = 2;
|
||||||
|
$coupon->save();
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否成功
|
||||||
|
$status = ($res['rspCode'] == 'MKM00000') ? 1 : 2;
|
||||||
|
$coupon->remark = $res['rspMessage'];
|
||||||
|
$coupon->status = $status;
|
||||||
|
$coupon->ticketId = $res['ticketId'] ?? '';
|
||||||
|
$coupon->serialNo = $res['serialNo'] ?? '';
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
if ($status == 1) {
|
||||||
|
$ret = [
|
||||||
|
'logNo' => $coupon->logNo,
|
||||||
|
'rspMessage' => $res['rspMessage'],
|
||||||
|
];
|
||||||
|
return $ret;
|
||||||
|
} else {
|
||||||
|
// PhoneTicket::dispatch($data);
|
||||||
|
return $res['rspMessage'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询券
|
||||||
|
* @param [type] $data [description]
|
||||||
|
* @param [type] $user_id [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function ticketQuery($data, $user_id)
|
||||||
|
{
|
||||||
|
$logNo = $data['logNo'];
|
||||||
|
|
||||||
|
if (!$logNo) {
|
||||||
|
return '缺少发券流水号';
|
||||||
|
}
|
||||||
|
|
||||||
|
$info = WoCoupon::where('logNo', $logNo)->first();
|
||||||
|
|
||||||
|
if (!$info) {
|
||||||
|
return '没有查询到信息';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($info->user_id != $user_id) {
|
||||||
|
return '这不是您的券。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
'charset' => $this->charset,
|
||||||
|
'version' => $this->version,
|
||||||
|
'merchantCert' => '',
|
||||||
|
'merchantSign' => '',
|
||||||
|
'signType' => $this->signType,
|
||||||
|
'service' => 'ticketQuery',
|
||||||
|
'requestId' => $this->getMsecTime(),
|
||||||
|
'merchantId' => $this->merchant_id,
|
||||||
|
'logNo' => $info->logNo,
|
||||||
|
'channelType' => $this->channelType,
|
||||||
|
];
|
||||||
|
|
||||||
|
$merchantCert = $this->merchantCert();
|
||||||
|
if (!$merchantCert) {
|
||||||
|
return '证书文件有错误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$merchantSign = $this->rsaSign($params);
|
||||||
|
if (is_array($merchantSign)) {
|
||||||
|
return $merchantSign['msg'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['merchantSign'] = $merchantSign;
|
||||||
|
$params['merchantCert'] = $merchantCert;
|
||||||
|
$res = $this->getWoData($params);
|
||||||
|
|
||||||
|
if (is_array($res)) {
|
||||||
|
if ($res['rspCode'] == 'MKM00000') {
|
||||||
|
$ret = [
|
||||||
|
'ticketState' => $res['ticketState'],
|
||||||
|
'ticketBalance' => $res['ticketBalance'],
|
||||||
|
'ticketAmt' => $res['ticketAmt'],
|
||||||
|
'expireDate' => $res['expireDate'],
|
||||||
|
'ticketId' => $res['ticketId'],
|
||||||
|
'ticketName' => $res['ticketName'],
|
||||||
|
'activityId' => $res['activityId'],
|
||||||
|
'logNo' => $params['logNo'],
|
||||||
|
'mobile' => $info->mobile,
|
||||||
|
];
|
||||||
|
return $ret;
|
||||||
|
} else {
|
||||||
|
return $res['rspMessage'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退业务
|
||||||
|
* @author 玄尘 2020-02-13
|
||||||
|
* @param [type] $data [description]
|
||||||
|
* @param [type] $user [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function ticketBack($data, $user)
|
||||||
|
{
|
||||||
|
$ologNo = $data['ologNo'];
|
||||||
|
|
||||||
|
$info = WoCoupon::where('logNo', $ologNo)->where('status', 1)->first();
|
||||||
|
|
||||||
|
if (!$info) {
|
||||||
|
return '没有查询到信息';
|
||||||
|
}
|
||||||
|
|
||||||
|
$logNo = 'YSD' . $this->getMsecTime();
|
||||||
|
$params = [
|
||||||
|
'charset' => $this->charset,
|
||||||
|
'version' => $this->version,
|
||||||
|
'merchantSign' => '',
|
||||||
|
'merchantCert' => '',
|
||||||
|
'signType' => $this->signType,
|
||||||
|
'service' => $data['service'],
|
||||||
|
'requestId' => $logNo,
|
||||||
|
'merchantId' => $this->merchant_id,
|
||||||
|
'activityId' => $info->activityId,
|
||||||
|
'mobilepNo' => $info->mobile,
|
||||||
|
'ologNo' => $data['ologNo'] ?? '',
|
||||||
|
'logNo' => $logNo,
|
||||||
|
'channelType' => $this->channelType,
|
||||||
|
'transactionDate' => now()->format('Ymd'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!empty($data['ticketAmt'])) {
|
||||||
|
// $params['ticketAmt'] = $data['ticketAmt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$merchantCert = $this->merchantCert();
|
||||||
|
if (!$merchantCert) {
|
||||||
|
return '证书文件有错误';
|
||||||
|
}
|
||||||
|
|
||||||
|
$couponData = [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'number' => $data['number'] ?? '',
|
||||||
|
'service' => $params['service'],
|
||||||
|
'ticketAmt' => $info->ticketAmt ?? '0.00',
|
||||||
|
'mobile' => $params['mobilepNo'],
|
||||||
|
'ologNo' => $params['ologNo'],
|
||||||
|
'logNo' => $params['logNo'],
|
||||||
|
'activityId' => $params['activityId'],
|
||||||
|
];
|
||||||
|
|
||||||
|
//记录
|
||||||
|
$coupon = WoCoupon::create($couponData);
|
||||||
|
|
||||||
|
//签名
|
||||||
|
$merchantSign = $this->rsaSign($params);
|
||||||
|
if (is_array($merchantSign)) {
|
||||||
|
return $merchantSign['msg'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['merchantSign'] = $merchantSign;
|
||||||
|
$params['merchantCert'] = $merchantCert;
|
||||||
|
|
||||||
|
$res = $this->getWoData($params);
|
||||||
|
|
||||||
|
//判断是否是数组,不是数组返回错误信息
|
||||||
|
if (!is_array($res)) {
|
||||||
|
$coupon->remark = $res;
|
||||||
|
$coupon->status = 2;
|
||||||
|
$coupon->save();
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否成功
|
||||||
|
$status = ($res['rspCode'] == 'MKM00000') ? 1 : 2;
|
||||||
|
$coupon->remark = $res['rspMessage'];
|
||||||
|
$coupon->status = $status;
|
||||||
|
$coupon->ticketId = $res['ticketId'] ?? '';
|
||||||
|
$coupon->serialNo = $res['serialNo'] ?? '';
|
||||||
|
$coupon->save();
|
||||||
|
|
||||||
|
if ($status == 1) {
|
||||||
|
//退订成功
|
||||||
|
// $info->ticketAmt = $info->ticketAmt . '/' . $res['ticketAmt'];
|
||||||
|
$info->status = 3;
|
||||||
|
$info->remark = $info->remark . '/已经退订';
|
||||||
|
$info->save();
|
||||||
|
|
||||||
|
$ret = [
|
||||||
|
'alreadyconAmt' => $res['alreadyconAmt'],
|
||||||
|
'ticketAmt' => $res['ticketAmt'],
|
||||||
|
'rspMessage' => $res['rspMessage'],
|
||||||
|
];
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// TicketBack::dispatch($data);
|
||||||
|
return $res['rspMessage'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Facades/Wo/Facade.php
Normal file
13
app/Facades/Wo/Facade.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\Wo;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade as BaseFacade;
|
||||||
|
|
||||||
|
class Facade extends BaseFacade
|
||||||
|
{
|
||||||
|
protected static function getFacadeAccessor()
|
||||||
|
{
|
||||||
|
return Action::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Facades/Wo/Log.php
Normal file
40
app/Facades/Wo/Log.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\Wo;
|
||||||
|
|
||||||
|
use App\Models\Log as LogModel;
|
||||||
|
|
||||||
|
class Log
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入日志
|
||||||
|
* @param [type] $url [description]
|
||||||
|
* @param [type] $method [description]
|
||||||
|
* @param [type] $params [description]
|
||||||
|
* @param string $type [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public static function insert($url, $method, $params, $type = 'pingan')
|
||||||
|
{
|
||||||
|
$params['form_params']['merchantCert'] = '';
|
||||||
|
$params['form_params']['merchantSign'] = '';
|
||||||
|
$data = [
|
||||||
|
'path' => $url,
|
||||||
|
'method' => $method,
|
||||||
|
'type' => $type,
|
||||||
|
'in_source' => $params,
|
||||||
|
];
|
||||||
|
|
||||||
|
$info = LogModel::create($data);
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新日志
|
||||||
|
public static function update($log, $params)
|
||||||
|
{
|
||||||
|
$log->out_source = $params;
|
||||||
|
$log->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
158
app/Facades/Wo/Wo.php
Normal file
158
app/Facades/Wo/Wo.php
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Facades\Wo;
|
||||||
|
|
||||||
|
use App\Facades\Wo\Log as LogFacade;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\RequestException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 花呗分期业务
|
||||||
|
*/
|
||||||
|
class Wo
|
||||||
|
{
|
||||||
|
protected $baseUri;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$config = config('wo');
|
||||||
|
|
||||||
|
$this->merchantCert = $config['merchantCert'];
|
||||||
|
$this->merchant_id = $config['merchant_id'];
|
||||||
|
$this->charset = $config['charset'];
|
||||||
|
$this->version = $config['version'];
|
||||||
|
$this->signType = $config['signType'];
|
||||||
|
$this->channelType = $config['channelType'];
|
||||||
|
$this->baseUri = $config['baseUri'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取私钥
|
||||||
|
public function getPrivate()
|
||||||
|
{
|
||||||
|
$config = config('wo');
|
||||||
|
return file_get_contents($config['private']);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取公钥
|
||||||
|
public function getPublic()
|
||||||
|
{
|
||||||
|
$config = config('wo');
|
||||||
|
return file_get_contents($config['public']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取毫秒级别的时间戳
|
||||||
|
*/
|
||||||
|
public function getMsecTime()
|
||||||
|
{
|
||||||
|
list($msec, $sec) = explode(' ', microtime());
|
||||||
|
$msectime = (float) sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
|
||||||
|
$msectime = explode('.', $msectime);
|
||||||
|
|
||||||
|
return $msectime[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//签名
|
||||||
|
public function rsaSign($params)
|
||||||
|
{
|
||||||
|
$signStr = $this->getSignString($params);
|
||||||
|
$private_key = $this->getPrivate();
|
||||||
|
$privKeyId = openssl_pkey_get_private($private_key);
|
||||||
|
if (!$privKeyId) {
|
||||||
|
return ['msg' => '私钥格式有误'];
|
||||||
|
}
|
||||||
|
$signature = '';
|
||||||
|
openssl_sign($signStr, $signature, $privKeyId, OPENSSL_ALGO_SHA1);
|
||||||
|
openssl_free_key($privKeyId);
|
||||||
|
|
||||||
|
return bin2hex($signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA验签
|
||||||
|
* @param $params 待签名数据
|
||||||
|
* @param $public_key 公钥字符串
|
||||||
|
* @param $sign 要校对的的签名结果
|
||||||
|
* return 验证结果
|
||||||
|
*/
|
||||||
|
public function rsaCheck($params, $sign)
|
||||||
|
{
|
||||||
|
$public_key = $this->getPublic();
|
||||||
|
$res = openssl_get_publickey($public_key);
|
||||||
|
$signStr = $this->getSignString($params);
|
||||||
|
|
||||||
|
if ($res) {
|
||||||
|
$result = (bool) openssl_verify($signStr, $sign, $res);
|
||||||
|
openssl_free_key($res);
|
||||||
|
} else {
|
||||||
|
return '公钥格式有误!';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取待签名字符串
|
||||||
|
* @param array $params 参数数组
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSignString($params)
|
||||||
|
{
|
||||||
|
$params = array_filter($params);
|
||||||
|
ksort($params);
|
||||||
|
$signStr = http_build_query($params);
|
||||||
|
return $signStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取证书
|
||||||
|
public function merchantCert()
|
||||||
|
{
|
||||||
|
if (!file_exists($this->merchantCert)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$cert = file_get_contents($this->merchantCert);
|
||||||
|
$cer_key = bin2hex($cert);
|
||||||
|
return $cer_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用获取数据接口
|
||||||
|
* @param [type] $url 请求地址
|
||||||
|
* @param array $query 传递参数
|
||||||
|
* @param array $json 需要传的json数据
|
||||||
|
* @param string $method 方式
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function getWoData($params = [], $method = 'POST')
|
||||||
|
{
|
||||||
|
$url = $this->baseUri;
|
||||||
|
$postData = [
|
||||||
|
'form_params' => $params,
|
||||||
|
];
|
||||||
|
|
||||||
|
$log = LogFacade::insert($url, $method, $postData, 'wo'); //日志
|
||||||
|
|
||||||
|
try {
|
||||||
|
$client = new Client();
|
||||||
|
$response = $client->request($method, $url, $postData);
|
||||||
|
$body = $response->getBody();
|
||||||
|
$content = $body->getContents();
|
||||||
|
$result = json_decode($content, true);
|
||||||
|
|
||||||
|
if (is_array($result)) {
|
||||||
|
return '发券失败';
|
||||||
|
LogFacade::update($log, $result); //更新日志
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_str($content, $res);
|
||||||
|
|
||||||
|
LogFacade::update($log, $res); //更新日志
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
} catch (RequestException $e) {
|
||||||
|
LogFacade::update($log, [$e->getMessage()]); //更新日志
|
||||||
|
return ['ret' => '99999', $e->getMessage()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
28
app/Http/Controllers/AjaxResponse.php
Normal file
28
app/Http/Controllers/AjaxResponse.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
trait AjaxResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
public function success($message = '', $redirect = null)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'status' => 'SUCCESS',
|
||||||
|
'statusCode' => 200,
|
||||||
|
'message' => $message,
|
||||||
|
'redirect' => $redirect,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function error($message = '', $redirect = null)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'status' => 'ERROR',
|
||||||
|
'statusCode' => 400,
|
||||||
|
'message' => $message,
|
||||||
|
'redirect' => $redirect,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
27
app/Http/Controllers/Controller.php
Normal file
27
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, AjaxResponse;
|
||||||
|
|
||||||
|
public function checkUserAuth($identity_id = 0)
|
||||||
|
{
|
||||||
|
$url = 'wxlogin';
|
||||||
|
if ($identity_id > 0) {
|
||||||
|
$url = 'login';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Auth::user() || ($identity_id && Auth::user()->identity_id != $identity_id)) {
|
||||||
|
return route($url) . '?callback=' . url()->current();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Http/Controllers/CouponController.php
Normal file
20
app/Http/Controllers/CouponController.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
class CouponController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$tick = 'YSD' . date('ymdHi') . mt_rand(100, 999);
|
||||||
|
$tick = strtotime(date('YmdHi', time())) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999));
|
||||||
|
$data = [
|
||||||
|
'code' => 200,
|
||||||
|
'couponCode' => $tick,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
27
app/Http/Controllers/IndexController.php
Normal file
27
app/Http/Controllers/IndexController.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Image;
|
||||||
|
use QrCode;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
return view('index.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function makeCode(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$shareimg = Image::make(QrCode::size(3000)->format('png')->margin(0)->generate(route('checkcode', $user)))
|
||||||
|
->resize(240, 240)
|
||||||
|
->encode('data-url');
|
||||||
|
|
||||||
|
return view('index.makeCode', compact('shareimg', 'user'));
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Http/Controllers/SkyxuController.php
Normal file
45
app/Http/Controllers/SkyxuController.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Api\Controllers\ApiResponse;
|
||||||
|
|
||||||
|
class SkyxuController
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$postData = [
|
||||||
|
'server_id' => '20200103490104',
|
||||||
|
'key' => 'rRhHO7Jbao2SSxAH8VygV4DgS4L2WESa',
|
||||||
|
'addcode' => '69198663',
|
||||||
|
'sign' => '6cd2232e9aa853219a0dff80430567796d0ae33d6c0289dfa835813def08ed8c',
|
||||||
|
'data' => 'DBEgnb5HidvKQDyxL0BAcCwuMkVdbTZRVu4mxwwzAM5TWj\/HAQfcrH9VzcgdG42lINsHYvI2Tv+MJfyP9eXVEQ==',
|
||||||
|
];
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
|
curl_setopt_array($curl, array(
|
||||||
|
CURLOPT_URL => "http://pa.cnskl.com/api/V1/user/freezecoupon",
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_ENCODING => "",
|
||||||
|
CURLOPT_MAXREDIRS => 10,
|
||||||
|
CURLOPT_TIMEOUT => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
|
CURLOPT_CUSTOMREQUEST => "POST",
|
||||||
|
CURLOPT_POSTFIELDS => $postData,
|
||||||
|
CURLOPT_HTTPHEADER => array(
|
||||||
|
"Content-Type: multipart/form-data;",
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
curl_close($curl);
|
||||||
|
echo $response;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
41
app/Http/Controllers/StorageController.php
Normal file
41
app/Http/Controllers/StorageController.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use File;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Storage;
|
||||||
|
|
||||||
|
class StorageController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$File = $request->file('image');
|
||||||
|
$oldName = $File->getClientOriginalName();
|
||||||
|
$hash = File::hash($File->path());
|
||||||
|
$size = File::size($File->path());
|
||||||
|
if ($size > (10 * 1024 * 1024)) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'message' => '文件不能超过10M',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$pathUrl = 'images' . date('/Y-m/d');
|
||||||
|
$fileName = $hash . '.' . $File->getClientOriginalExtension();
|
||||||
|
$path = Storage::disk('public')->putFileAs(
|
||||||
|
$pathUrl, $File, $fileName
|
||||||
|
);
|
||||||
|
if (!$path) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'message' => '文件上传失败',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'message' => '文件上传成功',
|
||||||
|
'path' => '/' . $pathUrl . '/' . $fileName,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
58
app/Http/Controllers/TestController.php
Normal file
58
app/Http/Controllers/TestController.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Api\Controllers\ApiResponse;
|
||||||
|
use App\Models\User;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
// use Wo;
|
||||||
|
|
||||||
|
class TestController
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$this->user = User::find(3);
|
||||||
|
$ret = [
|
||||||
|
'redemptionCode' => '951117396307',
|
||||||
|
'total' => 5,
|
||||||
|
'outletId' => '2004011649602',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->success($ret);
|
||||||
|
|
||||||
|
dd();
|
||||||
|
|
||||||
|
$jsonData = json_encode($ret); //数据JSON化
|
||||||
|
$ascdata = $this->keyasc($jsonData); //加密
|
||||||
|
$addcode = sprintf("%08d", mt_rand(0, 99999999)); //随机code 验证签名用
|
||||||
|
$sign = $this->keysign($ascdata, $addcode);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'server_id' => $this->user->server_id,
|
||||||
|
'key' => $this->user->server_key,
|
||||||
|
'addcode' => $addcode,
|
||||||
|
'sign' => $sign,
|
||||||
|
'data' => $ascdata,
|
||||||
|
];
|
||||||
|
|
||||||
|
$res = self::http($data);
|
||||||
|
dd($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function http($data)
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
$response = $client->request('POST', 'http://pa.ysd-bs.com/api/V1/user/freezecoupon', ['form_params' => $data, 'http_errors' => false]);
|
||||||
|
|
||||||
|
$body = $response->getBody();
|
||||||
|
$content = $body->getContents();
|
||||||
|
dump($content);
|
||||||
|
$result = json_decode($content, true);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
82
app/Http/Kernel.php
Normal file
82
app/Http/Kernel.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* These middleware are run during every request to your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\App\Http\Middleware\CheckForMaintenanceMode::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
'throttle:60,1',
|
||||||
|
'bindings',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The priority-sorted list of middleware.
|
||||||
|
*
|
||||||
|
* This forces non-global middleware to always be in the given order.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $middlewarePriority = [
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\Authenticate::class,
|
||||||
|
\Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
\Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
|
||||||
|
class Authenticate extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function redirectTo($request)
|
||||||
|
{
|
||||||
|
if (! $request->expectsJson()) {
|
||||||
|
return route('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Http/Middleware/CheckForMaintenanceMode.php
Normal file
17
app/Http/Middleware/CheckForMaintenanceMode.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||||
|
|
||||||
|
class CheckForMaintenanceMode extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||||
|
|
||||||
|
class EncryptCookies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the cookies that should not be encrypted.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
26
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
26
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|null $guard
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next, $guard = null)
|
||||||
|
{
|
||||||
|
if (Auth::guard($guard)->check()) {
|
||||||
|
return redirect('/home');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
app/Http/Middleware/TrimStrings.php
Normal file
18
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||||
|
|
||||||
|
class TrimStrings extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the attributes that should not be trimmed.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
}
|
||||||
23
app/Http/Middleware/TrustProxies.php
Normal file
23
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TrustProxies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trusted proxies for this application.
|
||||||
|
*
|
||||||
|
* @var array|string
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||||
|
}
|
||||||
24
app/Http/Middleware/VerifyCsrfToken.php
Normal file
24
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $addHttpCookie = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URIs that should be excluded from CSRF verification.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'payment/notify', 'wechat',
|
||||||
|
];
|
||||||
|
}
|
||||||
109
app/Http/WechatHandlers/EventMessageHandler.php
Normal file
109
app/Http/WechatHandlers/EventMessageHandler.php
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
use EasyWeChat\Kernel\Messages\Text;
|
||||||
|
|
||||||
|
class EventMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
private $payload;
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
if (method_exists($this, $payload['Event'])) {
|
||||||
|
$this->payload = $payload;
|
||||||
|
return call_user_func_array([$this, $payload['Event']], []);
|
||||||
|
} else {
|
||||||
|
return '暂不支持的消息类型';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扫码事件
|
||||||
|
* @Author:<C.Jason>
|
||||||
|
* @Date:2018-11-12T16:28:19+0800
|
||||||
|
*/
|
||||||
|
private function SCAN()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主菜单点击
|
||||||
|
* @Author:<C.Jason>
|
||||||
|
* @Date:2018-11-12T16:28:06+0800
|
||||||
|
*/
|
||||||
|
private function CLICK()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关注事件
|
||||||
|
* @Author:<C.Jason>
|
||||||
|
* @Date:2018-11-12T16:27:51+0800
|
||||||
|
*/
|
||||||
|
private function subscribe()
|
||||||
|
{
|
||||||
|
$app = app('wechat.official_account');
|
||||||
|
$user = $app->user->get($this->payload['FromUserName']);
|
||||||
|
|
||||||
|
// 先查找用户是否存在,不存在再注册
|
||||||
|
$existUser = User::where('openid', $this->payload['FromUserName'])->first();
|
||||||
|
if ($existUser) {
|
||||||
|
$existUser->update([
|
||||||
|
'info' => [
|
||||||
|
'headimgurl' => $user['headimgurl'],
|
||||||
|
'sex' => $user['sex'],
|
||||||
|
'country' => $user['country'],
|
||||||
|
'province' => $user['province'],
|
||||||
|
'city' => $user['city'],
|
||||||
|
'subscribe_at' => $user['subscribe_time'],
|
||||||
|
'subscribe_scene' => $user['subscribe_scene'],
|
||||||
|
// 'qr_scene' => $user['qr_scene'],
|
||||||
|
// 'qr_scene_str' => $user['qr_scene_str'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->firstSubscribeMessage($existUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function VIEW()
|
||||||
|
{
|
||||||
|
#Todo..
|
||||||
|
}
|
||||||
|
|
||||||
|
public function LOCATION()
|
||||||
|
{
|
||||||
|
#Todo..
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消关注事件
|
||||||
|
* @Author:<Leady>
|
||||||
|
* @Date:2018-12-12T13:44:54+0800
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
private function unsubscribe()
|
||||||
|
{
|
||||||
|
$existUser = User::where('openid', $this->payload['FromUserName'])->first();
|
||||||
|
if ($existUser) {
|
||||||
|
$existUser->update([
|
||||||
|
'info' => [
|
||||||
|
'subscribe_at' => null,
|
||||||
|
// 'subscribe_scene' => null,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function firstSubscribeMessage($user)
|
||||||
|
{
|
||||||
|
$text = new Text('您好,欢迎关注连卡蝠');
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Http/WechatHandlers/FileMessageHandler.php
Normal file
26
app/Http/WechatHandlers/FileMessageHandler.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class FileMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->Title;
|
||||||
|
$payload->Description;
|
||||||
|
$payload->FileKey;
|
||||||
|
$payload->FileMd5;
|
||||||
|
$payload->FileTotalLen;
|
||||||
|
|
||||||
|
return '文件消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Http/WechatHandlers/ImageMessageHandler.php
Normal file
23
app/Http/WechatHandlers/ImageMessageHandler.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class ImageMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->MediaId;
|
||||||
|
$payload->PicUrl;
|
||||||
|
|
||||||
|
return '图片消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Http/WechatHandlers/LinkMessageHandler.php
Normal file
24
app/Http/WechatHandlers/LinkMessageHandler.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class LinkMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->Title;
|
||||||
|
$payload->Description;
|
||||||
|
$payload->Url;
|
||||||
|
|
||||||
|
return '链接消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Http/WechatHandlers/LocationMessageHandler.php
Normal file
24
app/Http/WechatHandlers/LocationMessageHandler.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class LocationMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->Latitude;
|
||||||
|
$payload->Longitude;
|
||||||
|
$payload->Precision;
|
||||||
|
|
||||||
|
return '上报位置消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Http/WechatHandlers/ShortVideoMessageHandler.php
Normal file
23
app/Http/WechatHandlers/ShortVideoMessageHandler.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class ShortVideoMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->MediaId;
|
||||||
|
$payload->ThumbMediaId;
|
||||||
|
|
||||||
|
return '短视频消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Http/WechatHandlers/TextMessageHandler.php
Normal file
15
app/Http/WechatHandlers/TextMessageHandler.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class TextMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
return '您的留言已经收到';
|
||||||
|
return $payload->Content;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
app/Http/WechatHandlers/TransferMessageHandler.php
Normal file
14
app/Http/WechatHandlers/TransferMessageHandler.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class TransferMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
return '客服消息' . json_encode($payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Http/WechatHandlers/VideoMessageHandler.php
Normal file
23
app/Http/WechatHandlers/VideoMessageHandler.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class VideoMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->MediaId;
|
||||||
|
$payload->ThumbMediaId;
|
||||||
|
|
||||||
|
return '视频消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Http/WechatHandlers/VoiceMessageHandler.php
Normal file
24
app/Http/WechatHandlers/VoiceMessageHandler.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\WechatHandlers;
|
||||||
|
|
||||||
|
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||||
|
|
||||||
|
class VoiceMessageHandler implements EventHandlerInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($payload = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$payload->ToUserName;
|
||||||
|
$payload->FromUserName;
|
||||||
|
$payload->CreateTime;
|
||||||
|
$payload->MsgId;
|
||||||
|
|
||||||
|
$payload->MediaId;
|
||||||
|
$payload->Format;
|
||||||
|
$payload->Recognition;
|
||||||
|
|
||||||
|
return '语音消息';
|
||||||
|
}
|
||||||
|
}
|
||||||
67
app/Merchant/Controllers/AuthController.php
Normal file
67
app/Merchant/Controllers/AuthController.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
|
class AuthController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
if ($request->isMethod('post')) {
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'username' => 'required|min:4',
|
||||||
|
'password' => 'required|min:6',
|
||||||
|
], [
|
||||||
|
'username.requird' => '用户名不能为空',
|
||||||
|
'username.min' => '用户名不能小于:min字符',
|
||||||
|
'password.requird' => '密码不能为空',
|
||||||
|
'password.min' => '密码不能小于:min字符',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => $validator->errors()->first(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$remember = $request->remember ?: false;
|
||||||
|
if (Auth::guard('merchant')->attempt(['username' => $request->username, 'password' => $request->password], $remember)) {
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
if (in_array($user->identity->identity_id, ['1'])) {
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => '登录成功',
|
||||||
|
'url' => route('merchant.index'),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
Auth::guard('merchant')->logout();
|
||||||
|
session()->flush();
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '没有登录权限',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => '用户名或密码错误',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return view('Merchant::auth.login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
Auth::guard('merchant')->logout();
|
||||||
|
session()->flush();
|
||||||
|
return $this->success('注销成功', 'merchant.login');
|
||||||
|
}
|
||||||
|
}
|
||||||
53
app/Merchant/Controllers/Census/IndexController.php
Normal file
53
app/Merchant/Controllers/Census/IndexController.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers\Census;
|
||||||
|
|
||||||
|
use App\Merchant\Controllers\Controller;
|
||||||
|
use App\Merchant\Exporters\CensusExport;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
$month = $request->month ?? now()->format('Y-m');
|
||||||
|
$action = $request->action ?? 'search';
|
||||||
|
$month = explode('-', $month);
|
||||||
|
|
||||||
|
$coupons = Coupon::where('user_id', $user->id)
|
||||||
|
->whereYear('created_at', $month[0])
|
||||||
|
->whereMonth('created_at', $month[1])
|
||||||
|
->where('status', 2)
|
||||||
|
->get(['id', 'thirdPartyGoodsId', 'created_at']);
|
||||||
|
|
||||||
|
$coupons = $coupons->groupBy('create_day')->map(function ($items, $key) {
|
||||||
|
$data = [
|
||||||
|
'day' => $key,
|
||||||
|
'ysd10' => $items->where('thirdPartyGoodsId', 'YSD-full100-10')->count(),
|
||||||
|
'ysd25' => $items->where('thirdPartyGoodsId', 'YSD-full100-25')->count(),
|
||||||
|
'ysd50' => $items->where('thirdPartyGoodsId', 'YSD-full100-50')->count(),
|
||||||
|
'ysd100' => $items->where('thirdPartyGoodsId', 'YSD-full200-100')->count(),
|
||||||
|
];
|
||||||
|
return collect($data);
|
||||||
|
});
|
||||||
|
|
||||||
|
$all = [
|
||||||
|
'ysd10' => $coupons->sum('ysd10'),
|
||||||
|
'ysd25' => $coupons->sum('ysd25'),
|
||||||
|
'ysd50' => $coupons->sum('ysd50'),
|
||||||
|
'ysd100' => $coupons->sum('ysd100'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$coupons = $coupons->sortByDesc('day');
|
||||||
|
|
||||||
|
if ($action == 'search') {
|
||||||
|
return view('Merchant::census.index', compact('coupons', 'all'));
|
||||||
|
} else {
|
||||||
|
return (new CensusExport($month, $user))->download();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
13
app/Merchant/Controllers/Controller.php
Normal file
13
app/Merchant/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, Traits\AjaxResponse;
|
||||||
|
}
|
||||||
160
app/Merchant/Controllers/Coupon/IndexController.php
Normal file
160
app/Merchant/Controllers/Coupon/IndexController.php
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers\Coupon;
|
||||||
|
|
||||||
|
use App\Merchant\Controllers\Controller;
|
||||||
|
use App\Merchant\Exporters\CouponExport;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
|
||||||
|
$outlet = $request->outlet;
|
||||||
|
$status = $request->status;
|
||||||
|
$redemptionCode = $request->redemptionCode;
|
||||||
|
$start = $request->start;
|
||||||
|
$end = $request->end;
|
||||||
|
$thirdPartyGoodsId = $request->thirdPartyGoodsId;
|
||||||
|
$action = $request->action ?? 'search';
|
||||||
|
if ($action == 'excel') {
|
||||||
|
return (new CouponExport($request->all(), $user))->download();
|
||||||
|
}
|
||||||
|
if ($start) {
|
||||||
|
$start = $start . ' 00:00:00';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($end) {
|
||||||
|
$end = $end . ' 23:59:59';
|
||||||
|
}
|
||||||
|
|
||||||
|
$coupons = Coupon::where('user_id', $user->id)
|
||||||
|
->when($outlet, function ($q) use ($outlet) {
|
||||||
|
$q->whereHas('outlet', function ($q) use ($outlet) {
|
||||||
|
$q->whereHas('info', function ($q) use ($outlet) {
|
||||||
|
$q->where('nickname', 'like', "%{$outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($redemptionCode, function ($q) use ($redemptionCode) {
|
||||||
|
$q->where('redemptionCode', $redemptionCode);
|
||||||
|
})
|
||||||
|
->when($thirdPartyGoodsId, function ($q) use ($thirdPartyGoodsId) {
|
||||||
|
$q->where('thirdPartyGoodsId', $thirdPartyGoodsId);
|
||||||
|
})
|
||||||
|
->when(is_numeric($status), function ($query) use ($status) {
|
||||||
|
if ($status == 4) {
|
||||||
|
$query->where('is_profit', 1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$query->where('status', $status);
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
->when($start && $end, function ($query) use ($start, $end) {
|
||||||
|
$query->whereBetween('created_at', [$start, $end]);
|
||||||
|
})
|
||||||
|
->when($start && !$end, function ($query) use ($start) {
|
||||||
|
$query->where('created_at', '>', $start);
|
||||||
|
})
|
||||||
|
->when(!$start && $end, function ($query) use ($end) {
|
||||||
|
$query->where('created_at', '<', $end);
|
||||||
|
})
|
||||||
|
->whereIn('status', [2, 3])
|
||||||
|
->orderBy('created_at', 'desc')->orderBy('id', 'desc')->paginate();
|
||||||
|
|
||||||
|
$all = Coupon::query()
|
||||||
|
->where('user_id', $user->id)
|
||||||
|
->when($outlet, function ($q) use ($outlet) {
|
||||||
|
$q->whereHas('outlet', function ($q) use ($outlet) {
|
||||||
|
$q->whereHas('info', function ($q) use ($outlet) {
|
||||||
|
$q->where('nickname', 'like', "%{$outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($redemptionCode, function ($q) use ($redemptionCode) {
|
||||||
|
$q->where('redemptionCode', $redemptionCode);
|
||||||
|
})
|
||||||
|
->when(is_numeric($status), function ($query) use ($status) {
|
||||||
|
$query->where('status', $status);
|
||||||
|
}, function ($query) {
|
||||||
|
$query->whereIn('status', [2, 3]);
|
||||||
|
})
|
||||||
|
->when($start && $end, function ($query) use ($start, $end) {
|
||||||
|
$query->whereBetween('created_at', [$start, $end]);
|
||||||
|
})
|
||||||
|
->when($start, function ($query) use ($start) {
|
||||||
|
$query->where('created_at', '>', $start);
|
||||||
|
})
|
||||||
|
->when($end, function ($query) use ($end) {
|
||||||
|
$query->where('created_at', '<', $end);
|
||||||
|
})
|
||||||
|
->orderBy('created_at', 'desc')->orderBy('id', 'desc')->get();
|
||||||
|
|
||||||
|
$pass = $all->whereIn('status', [2, 4])->all();
|
||||||
|
$reject = $all->where('status', 3)->all();
|
||||||
|
$pass = collect($pass);
|
||||||
|
$reject = collect($reject);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'all' => $all->count(),
|
||||||
|
'pass' => $pass->count(),
|
||||||
|
'reject' => $reject->count(),
|
||||||
|
'price' => $pass->sum('price'),
|
||||||
|
'profit' => $pass->sum('profit'),
|
||||||
|
'hasPrice' => $pass->where('is_profit', 1)->sum('profit'),
|
||||||
|
];
|
||||||
|
|
||||||
|
return view('Merchant::coupon.index', compact('coupons', 'data'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照日期分润
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
* @author 玄尘 2020-03-11
|
||||||
|
*/
|
||||||
|
public function profits(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
|
||||||
|
if ($request->isMethod('POST')) {
|
||||||
|
$date = $request->date;
|
||||||
|
|
||||||
|
$list = Coupon::where('user_id', $user->id)->whereDate('created_at', $date)->where('status', 2)->get();
|
||||||
|
if ($list->isEmpty()) {
|
||||||
|
return $this->error('分润失败!没有可处理的数据');
|
||||||
|
}
|
||||||
|
if (Coupon::where('user_id', $user->id)->whereDate('created_at', $date)->where('status', 2)->update(['status' => 4])) {
|
||||||
|
return $this->success('分润成功!');
|
||||||
|
} else {
|
||||||
|
return $this->error('分润失败!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return view('Merchant::coupon.profits');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分润
|
||||||
|
* @author 玄尘 2020-03-11
|
||||||
|
* @param Coupon $coupon [description]
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function profit(Coupon $coupon)
|
||||||
|
{
|
||||||
|
if ($coupon->status == 2) {
|
||||||
|
$coupon->status = 4;
|
||||||
|
$coupon->save();
|
||||||
|
return $this->success('分润成功');
|
||||||
|
} else {
|
||||||
|
return $this->error('分润失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
20
app/Merchant/Controllers/IndexController.php
Normal file
20
app/Merchant/Controllers/IndexController.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('Merchant::index.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dashboard()
|
||||||
|
{
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
return view('Merchant::index.dashboard', compact('user'));
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/Merchant/Controllers/Setting/IndexController.php
Normal file
55
app/Merchant/Controllers/Setting/IndexController.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
// +------------------------------------------------+
|
||||||
|
// |http://www.cjango.com |
|
||||||
|
// +------------------------------------------------+
|
||||||
|
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||||
|
// +------------------------------------------------+
|
||||||
|
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||||
|
// +------------------------------------------------+
|
||||||
|
namespace App\Merchant\Controllers\Setting;
|
||||||
|
|
||||||
|
use App\Merchant\Controllers\Controller;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Validator;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改密码
|
||||||
|
* @param Request $request 数据集
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function password(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
|
||||||
|
if ($request->isMethod('post')) {
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'password' => 'required|confirmed',
|
||||||
|
'password_confirmation' => 'required',
|
||||||
|
], [
|
||||||
|
'password.required' => '新密码必须填写',
|
||||||
|
'password_confirmation.required' => '确认密码必须填写',
|
||||||
|
'password.confirmed' => '两次密码不一致',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first());
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->password = $request->password;
|
||||||
|
$res = $user->save();
|
||||||
|
if ($res === true) {
|
||||||
|
return $this->success('修改成功');
|
||||||
|
} else {
|
||||||
|
return $this->error('修改失败');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return view('Merchant::setting.password');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
app/Merchant/Controllers/Traits/AjaxResponse.php
Normal file
26
app/Merchant/Controllers/Traits/AjaxResponse.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Merchant\Controllers\Traits;
|
||||||
|
|
||||||
|
trait AjaxResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function success($message = '', $url = null, $data = null)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'code' => 1,
|
||||||
|
'msg' => $message ?: '操作成功',
|
||||||
|
'url' => is_null($url) ? '' : route($url),
|
||||||
|
'data' => $data,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function error($message = '', $url = null, $data = null)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'code' => 0,
|
||||||
|
'msg' => $message ?: '操作失败',
|
||||||
|
'url' => is_null($url) ? '' : route($url),
|
||||||
|
'data' => $data,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/Merchant/Exporters/CensusExport.php
Normal file
70
app/Merchant/Exporters/CensusExport.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Exporters;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class CensusExport implements FromCollection, WithMapping, WithHeadings
|
||||||
|
{
|
||||||
|
use Exportable;
|
||||||
|
|
||||||
|
public $year = '';
|
||||||
|
public $month = '';
|
||||||
|
public $user = '';
|
||||||
|
|
||||||
|
public function __construct($date, $user)
|
||||||
|
{
|
||||||
|
$this->year = $date[0];
|
||||||
|
$this->month = $date[1];
|
||||||
|
$this->user = $user;
|
||||||
|
$this->fileName = '核销统计' . $this->year . '-' . $this->month . '.xlsx';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return ['日期', '100元减10元优惠券', '100元减25元优惠券', '100元减50元优惠券', '200元减100元优惠券'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
$coupons = Coupon::where('user_id', $this->user->id)
|
||||||
|
->whereYear('created_at', $this->year)
|
||||||
|
->whereMonth('created_at', $this->month)
|
||||||
|
->where('status', 2)
|
||||||
|
->get(['id', 'thirdPartyGoodsId', 'created_at']);
|
||||||
|
|
||||||
|
$coupons = $coupons->groupBy('create_day')->map(function ($items, $key) {
|
||||||
|
$data = [
|
||||||
|
'day' => $key,
|
||||||
|
'ysd10' => $items->where('thirdPartyGoodsId', 'YSD-full100-10')->count() ?? 0,
|
||||||
|
'ysd25' => $items->where('thirdPartyGoodsId', 'YSD-full100-25')->count() ?? 0,
|
||||||
|
'ysd50' => $items->where('thirdPartyGoodsId', 'YSD-full100-50')->count() ?? 0,
|
||||||
|
'ysd100' => $items->where('thirdPartyGoodsId', 'YSD-full200-100')->count() ?? 0,
|
||||||
|
];
|
||||||
|
return collect($data);
|
||||||
|
});
|
||||||
|
$coupons = $coupons->sortByDesc('day');
|
||||||
|
|
||||||
|
return $coupons;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info['day'],
|
||||||
|
' ' . $info['ysd10'],
|
||||||
|
' ' . $info['ysd25'],
|
||||||
|
' ' . $info['ysd50'],
|
||||||
|
' ' . $info['ysd100'],
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
105
app/Merchant/Exporters/CouponExport.php
Normal file
105
app/Merchant/Exporters/CouponExport.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Exporters;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class CouponExport implements FromQuery, WithMapping, WithHeadings
|
||||||
|
{
|
||||||
|
use Exportable;
|
||||||
|
|
||||||
|
public $outlet = '';
|
||||||
|
public $status = '';
|
||||||
|
public $redemptionCode = '';
|
||||||
|
public $start = '';
|
||||||
|
public $end = '';
|
||||||
|
public $user = '';
|
||||||
|
public $thirdPartyGoodsId = '';
|
||||||
|
|
||||||
|
public function __construct($serchDatas, $user)
|
||||||
|
{
|
||||||
|
$this->fileName = '卡券记录' . date('YmdHis') . '.xlsx';
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
if (!empty($serchDatas)) {
|
||||||
|
foreach ($serchDatas as $key => $data) {
|
||||||
|
if ($data) {
|
||||||
|
$this->$key = $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return ['ID', '网点名称', '平安券编号', '优惠政策', '核销金额', '订单金额', '状态', '处理结果', '核销时间'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function query()
|
||||||
|
{
|
||||||
|
if ($this->start) {
|
||||||
|
$this->start = $this->start . ' 00:00:00';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->end) {
|
||||||
|
$this->end = $this->end . ' 23:59:59';
|
||||||
|
}
|
||||||
|
|
||||||
|
return Coupon::where('user_id', $this->user->id)
|
||||||
|
->when($this->outlet, function ($q) {
|
||||||
|
$q->whereHas('outlet', function ($q) {
|
||||||
|
$q->whereHas('info', function ($q) {
|
||||||
|
$q->where('nickname', 'like', "%{$this->outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($this->redemptionCode, function ($q) {
|
||||||
|
$q->where('redemptionCode', $this->redemptionCode);
|
||||||
|
})
|
||||||
|
->when($this->thirdPartyGoodsId, function ($q) {
|
||||||
|
$q->where('thirdPartyGoodsId', $this->thirdPartyGoodsId);
|
||||||
|
})
|
||||||
|
->when(is_numeric($this->status), function ($query) {
|
||||||
|
if ($this->status == 4) {
|
||||||
|
$query->where('is_profit', 1);
|
||||||
|
} else {
|
||||||
|
$query->where('status', $this->status);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->when($this->start && $this->end, function ($query) {
|
||||||
|
$query->whereBetween('created_at', [$this->start, $this->end]);
|
||||||
|
})
|
||||||
|
->when($this->start, function ($query) {
|
||||||
|
$query->where('created_at', '>', $this->start);
|
||||||
|
})
|
||||||
|
->when($this->end, function ($query) {
|
||||||
|
$query->where('created_at', '<', $this->end);
|
||||||
|
})
|
||||||
|
->whereIn('status', [2, 3])
|
||||||
|
->orderBy('created_at', 'desc');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
$info->id,
|
||||||
|
$info->outlet ? $info->outlet->nickname : 'Id:' . $info->outletId,
|
||||||
|
' ' . $info->redemptionCode,
|
||||||
|
' ' . $info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$info->total,
|
||||||
|
$info->status_text,
|
||||||
|
$info->remark,
|
||||||
|
$info->created_at,
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
49
app/Merchant/MerchantServiceProvider.php
Normal file
49
app/Merchant/MerchantServiceProvider.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class MerchantServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
'merchant.auth' => Middleware\Authenticate::class,
|
||||||
|
'merchant.guest' => Middleware\Guest::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'merchant' => [
|
||||||
|
'merchant.auth',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->publishes([__DIR__ . '/Resources/assets' => public_path('assets/merchant')]);
|
||||||
|
|
||||||
|
$this->loadViewsFrom(__DIR__ . '/Resources/views', 'Merchant');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->registerRouteMiddleware();
|
||||||
|
$this->loadAdminRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerRouteMiddleware()
|
||||||
|
{
|
||||||
|
foreach ($this->routeMiddleware as $key => $middleware) {
|
||||||
|
Route::aliasMiddleware($key, $middleware);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadAdminRoutes()
|
||||||
|
{
|
||||||
|
Route::middleware('web')
|
||||||
|
->prefix('merchant')
|
||||||
|
->name('merchant.')
|
||||||
|
->namespace('App\Merchant\Controllers')
|
||||||
|
->group(__DIR__ . '/routes.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
18
app/Merchant/Middleware/Authenticate.php
Normal file
18
app/Merchant/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class Authenticate
|
||||||
|
{
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
if (Auth::guard('merchant')->guest()) {
|
||||||
|
return redirect()->route('merchant.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
app/Merchant/Middleware/Guest.php
Normal file
18
app/Merchant/Middleware/Guest.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class Guest
|
||||||
|
{
|
||||||
|
public function handle($request, Closure $next, $guard = null)
|
||||||
|
{
|
||||||
|
if (Auth::guard('merchant')->check()) {
|
||||||
|
return redirect()->route('merchant.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
98
app/Merchant/Resources/views/auth/login.blade.php
Normal file
98
app/Merchant/Resources/views/auth/login.blade.php
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
|
<title>{{ config('app.name', '') }} --渠道管理系统登录</title>
|
||||||
|
<link rel="stylesheet" href="{{ asset('assets/merchant/js/plugins/layui/css/layui.css') }}" />
|
||||||
|
<link rel="stylesheet" href="{{ asset('assets/merchant/css/login.css') }}" />
|
||||||
|
<link rel="stylesheet" href="{{ asset('assets/merchant/css/animate.min.css') }}" />
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
background-image: url({{ asset('assets/merchant/img/bg'.rand(1,3).'.jpg') }});
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
if (window.top !== window.self) {
|
||||||
|
window.top.location = window.location;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="mask"></div>
|
||||||
|
<div class="main">
|
||||||
|
<h1><span style="font-size: 84px;">{{ config('app.name', '') }} 渠道管理</span><span style="font-size:20px;">{{ env('APP_VERSION') }}</span></h1>
|
||||||
|
<div class="enter">
|
||||||
|
<h2 class="animated">Click Here To Login</h2>
|
||||||
|
<form action="{{ route('merchant.login') }}" class="layui-form animated bounceInLeft" method="post">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="login-icon"> <i class="layui-icon"></i> </label>
|
||||||
|
<input type="text" name="username" lay-verify="username" autocomplete="off" placeholder="请输入登录名" class="layui-input" value="" />
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="login-icon"> <i class="layui-icon"></i> </label>
|
||||||
|
<input type="password" name="password" lay-verify="password" autocomplete="off" placeholder="请输入密码" class="layui-input" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<div class="pull-left login-remember">
|
||||||
|
<label>记住帐号?</label>
|
||||||
|
<input type="checkbox" name="remember" value="true" checked lay-skin="switch" title="保持登录">
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
@csrf
|
||||||
|
<button class="layui-btn layui-btn-primary" lay-submit lay-filter="login"> <i class="layui-icon"></i> 登录 </button>
|
||||||
|
</div>
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" src="{{ asset('assets/merchant/js/plugins/layui/layui.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
layui.use(['form'], function() {
|
||||||
|
var $ = layui.jquery, form = layui.form();
|
||||||
|
$("h2").on('click', function(){
|
||||||
|
$(this).hide();
|
||||||
|
$('.layui-form').show();
|
||||||
|
});
|
||||||
|
layer.config({
|
||||||
|
time: 1000
|
||||||
|
});
|
||||||
|
form.verify({
|
||||||
|
username: function (value) {
|
||||||
|
if (value.length < 4 || value.length > 20) {
|
||||||
|
return "账号应在4-20位之间"
|
||||||
|
}
|
||||||
|
var reg = /^[a-zA-Z0-9]*$/;
|
||||||
|
if (!reg.test(value)) {
|
||||||
|
return "账号只能为英文或数字";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
password: [/^[\S]{4,20}$/, '密码应在4-20位之间'],
|
||||||
|
verify: [/^[\S]{4}$/, '验证码长度有误']
|
||||||
|
});
|
||||||
|
form.on('submit(login)', function(data) {
|
||||||
|
layer.load(2);
|
||||||
|
$('form').removeClass('bounceInLeft');
|
||||||
|
$.post(data.form.action, data.field, function(res) {
|
||||||
|
layer.closeAll('loading');
|
||||||
|
if (res.code == 1) {
|
||||||
|
layer.msg(res.msg, {icon: 1, time: 1000}, function() {
|
||||||
|
location.href = res.url;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('form').addClass('shake');
|
||||||
|
layer.msg(res.msg, {icon: 5}, function() {
|
||||||
|
$('form').removeClass('shake');
|
||||||
|
});
|
||||||
|
$('.code').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
97
app/Merchant/Resources/views/census/index.blade.php
Normal file
97
app/Merchant/Resources/views/census/index.blade.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
@extends('Merchant::layouts.app')
|
||||||
|
|
||||||
|
@section('title', '核销统计')
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
<link rel="stylesheet" href="{{ asset('assets/merchant/css/plugins/datapicker/datepicker3.css') }}" />
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('script')
|
||||||
|
<script type="text/javascript" src="{{ asset('assets/merchant/js/plugins/datapicker/bootstrap-datepicker.js') }}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#time-interval .input-daterange").datepicker({
|
||||||
|
autoclose: true, //自动关闭
|
||||||
|
beforeShowDay: $.noop, //在显示日期之前调用的函数
|
||||||
|
clearBtn: true, //显示清除按钮
|
||||||
|
forceParse: true, //是否强制转换不符合格式的字符串
|
||||||
|
format: 'yyyy-mm', //日期格式
|
||||||
|
language: 'cn', //语言
|
||||||
|
minViewMode: 1, // 最小精度选择
|
||||||
|
startView: 1, //开始显示
|
||||||
|
WeekHighlighted:true, // 本周高亮
|
||||||
|
endDate:new Date()
|
||||||
|
});
|
||||||
|
|
||||||
|
$("button").click(function(){
|
||||||
|
var $this = $(this);
|
||||||
|
var $form = $this.parents('form');
|
||||||
|
$("input[name='action']").val($this.data('action'));
|
||||||
|
$form.submit();
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="ibox">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 m-b">
|
||||||
|
<form action="{{ route('merchant.census')}}" class="form-inline pull-right" method="get" accept-charset="utf-8">
|
||||||
|
<div class="form-group" id="time-interval">
|
||||||
|
<div class="input-daterange input-group">
|
||||||
|
<input type="text" class="input-sm form-control" placeholder="核销月份" readonly name="month" value="{{ Request::input('month')??now()->format('Y-m') }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<input type="hidden" name="action" value="search">
|
||||||
|
<button type="button" class="btn btn-sm btn-primary" data-action="search" ><i class="fa fa-check"></i> 刷新</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-warning confirm" tip='确认要导出当前条件内容?' data-action="excel"><i class="fa fa-paste"></i> 导出</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ibox-content">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>日期</th>
|
||||||
|
<th>100元减10元优惠券</th>
|
||||||
|
<th>100元减25元优惠券</th>
|
||||||
|
<th>100元减50元优惠券</th>
|
||||||
|
<th>200元减100元优惠券</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($coupons as $coupon)
|
||||||
|
<tr>
|
||||||
|
<td> {{ $coupon['day'] }} </td>
|
||||||
|
<td> {{ $coupon['ysd10'] ??''}} </td>
|
||||||
|
<td> {{ $coupon['ysd25'] ??''}} </td>
|
||||||
|
<td> {{ $coupon['ysd50'] ??''}} </td>
|
||||||
|
<td> {{ $coupon['ysd100']??'' }} </td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('merchant.coupons',['start'=>$coupon['day'],'end'=>$coupon['day']]) }}">查看</a>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
<tr style="color: #f8ac59">
|
||||||
|
<td> 全部</td>
|
||||||
|
<td> {{ $all['ysd10'] ??''}} </td>
|
||||||
|
<td> {{ $all['ysd25'] ??''}} </td>
|
||||||
|
<td> {{ $all['ysd50'] ??''}} </td>
|
||||||
|
<td> {{ $all['ysd100']??'' }} </td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
57
app/Merchant/Resources/views/common/menu.blade.php
Normal file
57
app/Merchant/Resources/views/common/menu.blade.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<!--左侧导航开始-->
|
||||||
|
<nav class="navbar-default navbar-static-side" role="navigation">
|
||||||
|
<div class="nav-close">
|
||||||
|
<i class="fa fa-times-circle"></i>
|
||||||
|
</div>
|
||||||
|
<div class="sidebar-collapse">
|
||||||
|
<ul class="nav" id="side-menu">
|
||||||
|
<li class="nav-header">
|
||||||
|
<div class="dropdown profile-element">
|
||||||
|
<span><img alt="image" class="img-circle" src="{{ asset('assets/merchant/img/avatar.jpg') }}" width="70" height ="70" /></span>
|
||||||
|
<a data-toggle="dropdown" class="dropdown-toggle" href="javascript:void(0);">
|
||||||
|
<span class="clear">
|
||||||
|
<span class="block m-t-xs">
|
||||||
|
<strong class="font-bold">{{ Auth::guard('merchant')->user()->info->nickname }}({{ Auth::guard('merchant')->user()->username }})</strong>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="text-muted text-xs block">修改密码 <b class="caret"></b></span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu m-t-xs">
|
||||||
|
<li><a data-toggle="layer" data-height="360" data-width="700" href="{{ route('merchant.setting.password') }}" class ="password">修改密码</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="logo-element">FX</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{{-- <li>--}}
|
||||||
|
{{-- <a href="#">--}}
|
||||||
|
{{-- <i class="fa fa-user"></i>--}}
|
||||||
|
{{-- <span class="nav-label">个人信息</span>--}}
|
||||||
|
{{-- <span class="fa arrow"></span>--}}
|
||||||
|
{{-- </a>--}}
|
||||||
|
{{-- <ul class="nav nav-second-level">--}}
|
||||||
|
{{-- <li>--}}
|
||||||
|
{{-- <a class="J_menuItem" href="{{ route('merchant.setting.password') }}"><i class="fa fa-list"></i>修改登陆密码</a>--}}
|
||||||
|
{{-- </li>--}}
|
||||||
|
{{-- </ul>--}}
|
||||||
|
{{-- </li>--}}
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="#">
|
||||||
|
<i class="fa fa-users"></i>
|
||||||
|
<span class="nav-label">平安券管理</span>
|
||||||
|
<span class="fa arrow"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="nav nav-second-level">
|
||||||
|
<li>
|
||||||
|
<a class="J_menuItem" href="{{ route('merchant.coupons') }}"><i class="fa fa-list"></i>核销记录</a>
|
||||||
|
<a class="J_menuItem" href="{{ route('merchant.census') }}"><i class="fa fa-list"></i>核销统计</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<!--左侧导航结束-->
|
||||||
9
app/Merchant/Resources/views/common/msg.blade.php
Normal file
9
app/Merchant/Resources/views/common/msg.blade.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<ul class="nav navbar-top-links navbar-right">
|
||||||
|
<li><h3>{{ config('app.name', '') }} 渠道管理</h3></li>
|
||||||
|
{{-- <li>
|
||||||
|
<a href="/" target="_blank" title="网站主页"><i class="fa fa-home"></i></a>
|
||||||
|
</li> --}}
|
||||||
|
<li>
|
||||||
|
<a href="javascript:void(0);" id="refreshActive" title="刷新当前页面"><i class="fa fa-refresh"></i></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
53
app/Merchant/Resources/views/common/pagination.blade.php
Normal file
53
app/Merchant/Resources/views/common/pagination.blade.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
@if ($paginator->hasPages())
|
||||||
|
<form action="{{ url()->current() }}" method="get" accept-charset="utf-8">
|
||||||
|
<ul class="pagination" role="navigation">
|
||||||
|
{{-- Previous Page Link --}}
|
||||||
|
@if ($paginator->onFirstPage())
|
||||||
|
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
|
||||||
|
<span class="page-link" aria-hidden="true">‹</span>
|
||||||
|
</li>
|
||||||
|
@else
|
||||||
|
<li class="page-item">
|
||||||
|
<a class="page-link" href="{{ $paginator->previousPageUrl() }}" rel="prev" aria-label="@lang('pagination.previous')">‹</a>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Pagination Elements --}}
|
||||||
|
@foreach ($elements as $element)
|
||||||
|
{{-- "Three Dots" Separator --}}
|
||||||
|
@if (is_string($element))
|
||||||
|
<li class="page-item disabled" aria-disabled="true"><span class="page-link">{{ $element }}</span></li>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Array Of Links --}}
|
||||||
|
@if (is_array($element))
|
||||||
|
@foreach ($element as $page => $url)
|
||||||
|
@if ($page == $paginator->currentPage())
|
||||||
|
<li class="page-item active" aria-current="page"><span class="page-link">{{ $page }}</span></li>
|
||||||
|
@else
|
||||||
|
<li class="page-item"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
{{-- Next Page Link --}}
|
||||||
|
@if ($paginator->hasMorePages())
|
||||||
|
<li class="page-item">
|
||||||
|
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next" aria-label="@lang('pagination.next')">›</a>
|
||||||
|
</li>
|
||||||
|
@else
|
||||||
|
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.next')">
|
||||||
|
<span class="page-link" aria-hidden="true">›</span>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
<li class="page-item disabled" aria-disabled="true">
|
||||||
|
<span class="page-link" aria-hidden="true">共{{ $paginator->total() }}条</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<input type="text" style="width:50px;height:28px;border:1px solid #DDD;border-left:none;vertical-align:top;text-align:center" name="page" value="{{ $paginator->currentPage() }}"><button type="submit" class="btn btn-sm" style="border-radius: 0 3px 3px 0;padding: 4px;">跳转</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
150
app/Merchant/Resources/views/coupon/index.blade.php
Normal file
150
app/Merchant/Resources/views/coupon/index.blade.php
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
@extends('Merchant::layouts.app')
|
||||||
|
|
||||||
|
@section('title', '核销列表')
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
<link rel="stylesheet" href="{{ asset('assets/merchant/css/plugins/datapicker/datepicker3.css') }}" />
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('script')
|
||||||
|
<script type="text/javascript" src="{{ asset('assets/merchant/js/plugins/datapicker/bootstrap-datepicker.js') }}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#time-interval .input-daterange").datepicker({
|
||||||
|
keyboardNavigation: !1,
|
||||||
|
forceParse: !1,
|
||||||
|
autoclose: !0,
|
||||||
|
clearBtn: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
$("button").click(function(){
|
||||||
|
var $this = $(this);
|
||||||
|
var $form = $this.parents('form');
|
||||||
|
$("input[name='action']").val($this.data('action'));
|
||||||
|
$form.submit();
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="ibox">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12 m-b">
|
||||||
|
<form action="{{ route('merchant.coupons')}}" class="form-inline pull-right" method="get" accept-charset="utf-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" placeholder="网点名称" name="outlet" class="input-sm form-control" value="{{ Request::input('outlet') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" placeholder="平安券编号" name="redemptionCode" class="input-sm form-control" value="{{ Request::input('redemptionCode') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<select class="form-control m-b" name="status">
|
||||||
|
<option value="">状态</option>
|
||||||
|
<option value="2" @if(request()->status==2) selected="" @endif >核销成功</option>
|
||||||
|
<option value="3" @if(request()->status==3) selected="" @endif >核销失败</option>
|
||||||
|
{{-- <option value="4" @if(request()->status==4) selected="" @endif >已分润</option> --}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<select class="form-control m-b" name="thirdPartyGoodsId">
|
||||||
|
<option value="" >全部</option>
|
||||||
|
<option value="YSD-full2-2" @if(request()->thirdPartyGoodsId=='YSD-full2-2') selected="" @endif >2减2元</option>
|
||||||
|
<option value="YSD-full3-3" @if(request()->thirdPartyGoodsId=='YSD-full3-3') selected="" @endif >3减3元</option>
|
||||||
|
<option value="YSD-full5-5" @if(request()->thirdPartyGoodsId=='YSD-full5-5') selected="" @endif >5减5元</option>
|
||||||
|
<option value="YSD-full100-10" @if(request()->thirdPartyGoodsId=='YSD-full100-10') selected="" @endif >100减10元</option>
|
||||||
|
<option value="YSD-full100-25" @if(request()->thirdPartyGoodsId=='YSD-full100-25') selected="" @endif >100减25元</option>
|
||||||
|
<option value="YSD-full100-50" @if(request()->thirdPartyGoodsId=='YSD-full100-50') selected="" @endif >100减50元</option>
|
||||||
|
<option value="YSD-full200-100" @if(request()->thirdPartyGoodsId=='YSD-full200-100') selected="" @endif >200减100元</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group" id="time-interval">
|
||||||
|
<div class="input-daterange input-group">
|
||||||
|
<input type="text" class="input-sm form-control" placeholder="核销时间" readonly name="start" value="{{ Request::input('start') }}" />
|
||||||
|
<span class="input-group-addon">~</span>
|
||||||
|
<input type="text" class="input-sm form-control" placeholder="核销时间" readonly name="end" value="{{ Request::input('end') }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<input type="hidden" name="action" value="search">
|
||||||
|
<button type="button" class="btn btn-sm btn-primary" data-action="search" ><i class="fa fa-check"></i> 搜索</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-warning confirm" tip='确认要导出当前条件内容?' data-action="excel"><i class="fa fa-paste"></i> 导出</button>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="input-group-btn">
|
||||||
|
{{-- <button type="submit" class="btn btn-sm btn-primary " ><i class="fa fa-check"></i> 搜索</button>--}}
|
||||||
|
|
||||||
|
{{-- <button class="btn btn-sm btn-primary" type="button" data-toggle="layer" data-height="360" data-width="700" href="{{ route('merchant.coupons.profits') }}">
|
||||||
|
<i class="fa fa-plus"></i>
|
||||||
|
批量分润
|
||||||
|
</button> --}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th width="100">ID</th>
|
||||||
|
<th>网点名称</th>
|
||||||
|
{{-- <th>订单号</th> --}}
|
||||||
|
<th>平安券编号</th>
|
||||||
|
<th>优惠政策</th>
|
||||||
|
<th>核销金额</th>
|
||||||
|
<th>订单金额</th>
|
||||||
|
<th>状态</th>
|
||||||
|
<th>处理结果</th>
|
||||||
|
<th>核销时间</th>
|
||||||
|
{{-- <th>操作</th> --}}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($coupons as $coupon)
|
||||||
|
<tr>
|
||||||
|
<td> {{ $coupon->id }} </td>
|
||||||
|
<td>{{ $coupon->outlet ? $coupon->outlet->nickname : 'Id:' . $coupon->outletId }}</td>
|
||||||
|
{{-- <td>{{ $coupon->partnerOrderId }}</td> --}}
|
||||||
|
<td>{{ $coupon->redemptionCode }}</td>
|
||||||
|
<td>{{ $coupon->couponName }}</td>
|
||||||
|
<td>{{ $coupon->price }}</td>
|
||||||
|
<td>{{ $coupon->total }}</td>
|
||||||
|
<td>{{ $coupon->status_text }}</td>
|
||||||
|
<td>{{ $coupon->remark }}</td>
|
||||||
|
<td>{{ $coupon->created_at }}</td>
|
||||||
|
{{-- <td>
|
||||||
|
<a class="btn btn-sm btn-primary ajax-get confirm" tip="您确定要分润吗" href="{{ route('merchant.coupons.profit',$coupon)}}">分润</a>
|
||||||
|
</td> --}}
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="badge badge-primary">全部:{{ $data['all'] }}张 </span>
|
||||||
|
<span class="badge badge-success">成功:{{ $data['pass'] }}张 </span>
|
||||||
|
<span class="badge badge-error">失败:{{ $data['reject'] }}张 </span>
|
||||||
|
{{-- <span class="badge badge-primary">核销金额:{{ $data['price'] }}元 </span> --}}
|
||||||
|
{{-- <span class="badge badge-primary">分润金额:{{ $data['profit'] }}元 </span> --}}
|
||||||
|
{{-- <span class="badge badge-primary">打款金额:{{ $data['hasPrice'] }}元 </span> --}}
|
||||||
|
</div>
|
||||||
|
<div class="text-right">
|
||||||
|
{{
|
||||||
|
$coupons->appends([
|
||||||
|
'outlet'=>Request::input('outlet'),
|
||||||
|
'status'=>Request::input('status'),
|
||||||
|
'redemptionCode'=>Request::input('redemptionCode'),
|
||||||
|
'start'=>Request::input('start'),
|
||||||
|
'end'=>Request::input('end'),
|
||||||
|
])->links('Merchant::common.pagination')
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
39
app/Merchant/Resources/views/coupon/profits.blade.php
Normal file
39
app/Merchant/Resources/views/coupon/profits.blade.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
|
||||||
|
@extends('Merchant::layouts.app')
|
||||||
|
|
||||||
|
@section('title', '订单列表')
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
<link rel="stylesheet" href="{{ asset('assets/merchant/css/plugins/datapicker/datepicker3.css') }}" />
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('script')
|
||||||
|
<script type="text/javascript" src="{{ asset('assets/merchant/js/plugins/datapicker/bootstrap-datepicker.js') }}"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#time-interval .input-daterange").datepicker({
|
||||||
|
keyboardNavigation: !1,
|
||||||
|
forceParse: !1,
|
||||||
|
autoclose: !0,
|
||||||
|
clearBtn: true,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
@section('content')
|
||||||
|
<form method="post" class="form-horizontal">
|
||||||
|
|
||||||
|
<div class="form-group" id="time-interval">
|
||||||
|
<label class="col-xs-3 control-label">日期</label>
|
||||||
|
<div class="col-xs-8 input-daterange">
|
||||||
|
<input type="text" class="input-sm form-control" placeholder="核销时间" readonly name="date" value="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-xs-8 col-xs-offset-3">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<button class="btn btn-primary ajax-post" type="submit">确认分润</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@endsection
|
||||||
21
app/Merchant/Resources/views/index/dashboard.blade.php
Normal file
21
app/Merchant/Resources/views/index/dashboard.blade.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
@extends('Merchant::layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'dashboard - index')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-title">
|
||||||
|
<h5>商户信息</h5>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="ibox-content">
|
||||||
|
<p><i class="fa "></i> 登录账户:{{ $user->username}}</p>
|
||||||
|
<p><i class="fa "></i> 用户昵称:{{ $user->nickname}}</p>
|
||||||
|
<p><i class="fa "></i> 用户身份:{{ $user->identity_text}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user