[新增] first commit
This commit is contained in:
49
.env.example
Normal file
49
.env.example
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=smtp
|
||||||
|
MAIL_HOST=mailhog
|
||||||
|
MAIL_PORT=1025
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
PUSHER_APP_KEY=
|
||||||
|
PUSHER_APP_SECRET=
|
||||||
|
PUSHER_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||||
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
* text=auto
|
||||||
|
*.css linguist-vendored
|
||||||
|
*.scss linguist-vendored
|
||||||
|
*.js linguist-vendored
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/tests/
|
||||||
|
/.idea/
|
||||||
|
.editorconfig
|
||||||
|
.env
|
||||||
|
/vendor
|
||||||
|
/storage/app
|
||||||
|
/storage/logs
|
||||||
|
/storage/framework
|
||||||
|
/storage/debugbar/
|
||||||
|
/bootstrap/cache
|
||||||
13
.styleci.yml
Normal file
13
.styleci.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
disabled:
|
||||||
|
- no_unused_imports
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- index.php
|
||||||
|
- server.php
|
||||||
|
js:
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- webpack.mix.js
|
||||||
|
css: true
|
||||||
62
README.md
Normal file
62
README.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## About Laravel
|
||||||
|
|
||||||
|
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||||
|
|
||||||
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
|
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||||
|
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||||
|
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||||
|
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||||
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
|
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||||
|
|
||||||
|
## Learning Laravel
|
||||||
|
|
||||||
|
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||||
|
|
||||||
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||||
|
|
||||||
|
## Laravel Sponsors
|
||||||
|
|
||||||
|
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||||
|
|
||||||
|
### Premium Partners
|
||||||
|
|
||||||
|
- **[Vehikl](https://vehikl.com/)**
|
||||||
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||||
|
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||||
|
- **[Many](https://www.many.co.uk)**
|
||||||
|
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||||
|
- **[DevSquad](https://devsquad.com)**
|
||||||
|
- **[Curotec](https://www.curotec.com/)**
|
||||||
|
- **[OP.GG](https://op.gg)**
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||||
|
|
||||||
|
## Security Vulnerabilities
|
||||||
|
|
||||||
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
60
app/Admin/Actions/Coupon/Batch.php
Normal file
60
app/Admin/Actions/Coupon/Batch.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?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);
|
||||||
|
})
|
||||||
|
->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('确定打款?');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
42
app/Admin/Actions/User/Callback.php
Normal file
42
app/Admin/Actions/User/Callback.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\User;
|
||||||
|
|
||||||
|
use Encore\Admin\Actions\RowAction;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class Callback extends RowAction
|
||||||
|
{
|
||||||
|
|
||||||
|
public $name = '设置回调地址';
|
||||||
|
|
||||||
|
public function handle(Model $model, Request $request)
|
||||||
|
{
|
||||||
|
$validator = \Validator::make($request->all(), [
|
||||||
|
'callback' => 'required|url',
|
||||||
|
], [
|
||||||
|
'callback.required' => '缺少回调地址',
|
||||||
|
'callback.url' => '回调地址不正确,不是有效的url地址',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->response()->error($validator->errors()->first());
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->callback = $request->callback;
|
||||||
|
|
||||||
|
if ($model->save()) {
|
||||||
|
return $this->response()->success('设置成功')->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()->error('设置失败')->refresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form(Model $model)
|
||||||
|
{
|
||||||
|
$this->text('callback', '回调地址')->default($model->callback)->required();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Admin/Actions/User/ReCode.php
Normal file
45
app/Admin/Actions/User/ReCode.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?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->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
75
app/Admin/Controllers/Account/LogController.php
Normal file
75
app/Admin/Controllers/Account/LogController.php
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Account;
|
||||||
|
|
||||||
|
use App\Models\AccountLog;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\AccountRule;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class LogController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '账户日志';
|
||||||
|
|
||||||
|
function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new AccountLog);
|
||||||
|
$grid->model()->with(['account'])->latest();
|
||||||
|
$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->equal('rule_id', '触发规则')->select(AccountRule::pluck('title', 'id'));
|
||||||
|
$filter->equal('type', '账户类型')->select(config('account.account_type'));
|
||||||
|
});
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('account', function ($query) {
|
||||||
|
$query->whereHasMorph('accountable', 'App\Models\User', function ($query) {
|
||||||
|
$query->where('id', $this->input);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '会员账号', 'id')->select(User::whereHas('identity', function ($q) {
|
||||||
|
$q->where('identity_id', 1);
|
||||||
|
})->get()->pluck('info.nickname', 'id'));
|
||||||
|
});
|
||||||
|
$filter->column(1 / 3, function ($filter) {
|
||||||
|
$filter->equal('frozen', '冻结')->select([
|
||||||
|
0 => '否',
|
||||||
|
1 => '是',
|
||||||
|
]);
|
||||||
|
$filter->between('created_at', '创建时间')->datetime();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('会员账号')->display(function () {
|
||||||
|
return $this->account->accountable->username;
|
||||||
|
});
|
||||||
|
$grid->column('会员昵称')->display(function () {
|
||||||
|
return $this->account->accountable->info->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
108
app/Admin/Controllers/Activity/CouponController.php
Normal file
108
app/Admin/Controllers/Activity/CouponController.php
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Activity;
|
||||||
|
|
||||||
|
use App\Models\ActivityCoupon;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
|
||||||
|
class CouponController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '卡券列表管理';
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new ActivityCoupon);
|
||||||
|
$grid->model()->with(['outlet'])->latest();
|
||||||
|
$grid->disableActions();
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
||||||
|
$filter->between('used_at', '核销时间')->datetime();
|
||||||
|
|
||||||
|
$users = User::whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})->get()->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('outlet', function ($query) {
|
||||||
|
$query->whereHas('info', function ($query) {
|
||||||
|
$query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '网点名称', 'outlet_name');
|
||||||
|
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('code', '卡券编号');
|
||||||
|
$filter->like('mobile', '手机号');
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('activity', function ($query) {
|
||||||
|
$query->whereHas('rule', function ($query) {
|
||||||
|
$query->where('code', $this->input);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '优惠政策', 'rule_code')->select(ActivityRule::where('status', 1)->pluck('title', 'code'));
|
||||||
|
|
||||||
|
$users = User::query()
|
||||||
|
->whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('outlet', function ($query) {
|
||||||
|
$query->whereHas('parent', function ($query) {
|
||||||
|
$query->where('id', $this->input);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '渠道', 'parent_id')->select($users);;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('activity.title', '卡券名称');
|
||||||
|
$grid->column('mobile', '手机号');
|
||||||
|
$grid->column('优惠政策')->display(function () {
|
||||||
|
return $this->activity->rule->title;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('网点名称/编号')->display(function () {
|
||||||
|
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('code', '卡券编号');
|
||||||
|
$grid->column('status', '状态')
|
||||||
|
->using(ActivityCoupon::STATUS)
|
||||||
|
->label([
|
||||||
|
1 => 'default',
|
||||||
|
2 => 'warning',
|
||||||
|
3 => 'info',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('used_at', '核销时间');
|
||||||
|
$grid->column('created_at', '创建时间');
|
||||||
|
|
||||||
|
$grid->disableExport(false);
|
||||||
|
|
||||||
|
$grid->export(function ($export) {
|
||||||
|
$export->column('status', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('mobile', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->filename($this->title . date("YmdHis"));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
282
app/Admin/Controllers/Activity/IndexController.php
Normal file
282
app/Admin/Controllers/Activity/IndexController.php
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Activity;
|
||||||
|
|
||||||
|
use App\Admin\Renderable\Activity\Grants;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Models\ActivityGrant;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\HasResourceActions;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Layout\Content;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use Illuminate\Routing\Controller as AdminController;
|
||||||
|
|
||||||
|
class IndexController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasResourceActions;
|
||||||
|
|
||||||
|
protected $title = '活动管理';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get content title.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function title()
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index interface.
|
||||||
|
* @param Content $content
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
public function index(Content $content)
|
||||||
|
{
|
||||||
|
return $content
|
||||||
|
->title($this->title())
|
||||||
|
->description($this->description['index'] ?? trans('admin.list'))
|
||||||
|
->body($this->grid());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit interface.
|
||||||
|
* @param mixed $id
|
||||||
|
* @param Content $content
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
public function edit($id, Content $content)
|
||||||
|
{
|
||||||
|
return $content
|
||||||
|
->title($this->title())
|
||||||
|
->description($this->description['edit'] ?? trans('admin.edit'))
|
||||||
|
->body($this->form($id)->edit($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create interface.
|
||||||
|
* @param Content $content
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
public function create(Content $content)
|
||||||
|
{
|
||||||
|
return $content
|
||||||
|
->title($this->title())
|
||||||
|
->description($this->description['create'] ?? trans('admin.create'))
|
||||||
|
->body($this->form());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new Activity);
|
||||||
|
$grid->model()->withCount('coupons');
|
||||||
|
|
||||||
|
$grid->actions(function ($actions) {
|
||||||
|
$actions->disableView();
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('status', '状态')->select(Activity::STATUS);
|
||||||
|
$filter->equal('type', '类型')->select(Activity::TYPES);
|
||||||
|
|
||||||
|
$users = User::whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})->get()->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->between('start_at', '开始时间')->datetime();
|
||||||
|
$filter->between('end_at', '结束时间')->datetime();
|
||||||
|
$filter->equal('channel', '核销途径')->select(Activity::CHANNELS);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('title', '活动名称');
|
||||||
|
$grid->column('code', '活动编号');
|
||||||
|
$grid->column('total', '可发券总数');
|
||||||
|
$grid->column('coupons_count', '已发券总数');
|
||||||
|
$grid->column('rule.code', '卡券规则');
|
||||||
|
$grid->column('类型')->display(function () {
|
||||||
|
return $this->type_text;
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('channel', '核销途径')
|
||||||
|
->using(Activity::CHANNELS)
|
||||||
|
->label([
|
||||||
|
Activity::CHANNEL_YSD => 'info',
|
||||||
|
Activity::CHANNEL_UNION => 'success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('days', '延期(天)');
|
||||||
|
$grid->column('rule.full', '满足金额');
|
||||||
|
$grid->column('rule.take', '扣除金额');
|
||||||
|
$grid->column('发券')
|
||||||
|
->display(function () {
|
||||||
|
return $this->grants->pluck('user_nickname');
|
||||||
|
})
|
||||||
|
->label()
|
||||||
|
->hide();
|
||||||
|
|
||||||
|
$grid->column('核券')
|
||||||
|
->display(function () {
|
||||||
|
return $this->verifications->pluck('user_nickname');
|
||||||
|
})
|
||||||
|
->label()
|
||||||
|
->hide();
|
||||||
|
|
||||||
|
$grid->column('开始时间')->display(function () {
|
||||||
|
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
|
||||||
|
});
|
||||||
|
$grid->column('结束时间')->display(function () {
|
||||||
|
return $this->type == Activity::TYPE_SCOPE ? $this->end_at->format('Y-m-d') : '---';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->status('状态')->switch([
|
||||||
|
'on' => ['value' => 1, 'text' => '正常', 'color' => 'primary'],
|
||||||
|
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('created_at', '创建时间');
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a form builder.
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
|
protected function form($id = '')
|
||||||
|
{
|
||||||
|
$form = new Form(new Activity);
|
||||||
|
|
||||||
|
$form->text('title', '活动名称')->required();
|
||||||
|
$form->textarea('description', '活动说明')->required();
|
||||||
|
|
||||||
|
$form->select('activity_rule_id', '所属规则')
|
||||||
|
->options(function ($option, $info) {
|
||||||
|
return ActivityRule::where('status', 1)->pluck('title', 'id');
|
||||||
|
})
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->number('total', '总数')
|
||||||
|
->help('可发券总数,0为不限制')
|
||||||
|
->default(10000)
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->radio('type', '类型')
|
||||||
|
->options(Activity::TYPES)
|
||||||
|
->when(Activity::TYPE_EXTEND, function (Form $form) {
|
||||||
|
$form->number('days', '延期天数')->default(60)->help('到期日期=发券日期+延期天数');
|
||||||
|
})
|
||||||
|
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
||||||
|
$form->dateRange('start_at', 'end_at', '有效时间');
|
||||||
|
})
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->radio('channel', '核销途径')
|
||||||
|
->options(Activity::CHANNELS)
|
||||||
|
->default(Activity::CHANNEL_YSD)
|
||||||
|
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->switch('status', '状态')->default(1);
|
||||||
|
$form->switch('need_check', '多次校验')
|
||||||
|
->default(1)
|
||||||
|
->help('同一订单,多次核销时校验,订单每满100元可核销一笔。');
|
||||||
|
|
||||||
|
$grantdef = $verificationsdef = '';
|
||||||
|
if ($id) {
|
||||||
|
$grantdef = Activity::find($id)->grants()->pluck('user_id')->toArray();
|
||||||
|
$verificationsdef = Activity::find($id)->verifications()->pluck('user_id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
$users = User::with('info')->whereHas('identity', function ($q) {
|
||||||
|
$q->where('identity_id', 1);
|
||||||
|
})->orderBy('id', 'desc')->get()->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
$form->listbox('grants.user_id', '可发券渠道')
|
||||||
|
->options($users)
|
||||||
|
->default($grantdef)
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->listbox('verifications.user_id', '可核券渠道')
|
||||||
|
->options($users)
|
||||||
|
->default($verificationsdef)
|
||||||
|
->required();
|
||||||
|
|
||||||
|
$form->saving(function (Form $form) {
|
||||||
|
$request = request();
|
||||||
|
|
||||||
|
if ($request->total < 0) {
|
||||||
|
$error = new MessageBag([
|
||||||
|
'title' => '错误',
|
||||||
|
'message' => '可发券总数必须大于0',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->withInput()->with(compact('error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == Activity::TYPE_EXTEND && empty($request->days)) {
|
||||||
|
$error = new MessageBag([
|
||||||
|
'title' => '错误',
|
||||||
|
'message' => '必须添加延期天数',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->withInput()->with(compact('error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == Activity::TYPE_SCOPE && (empty($request->start_at) || empty($request->end_at))) {
|
||||||
|
$error = new MessageBag([
|
||||||
|
'title' => '错误',
|
||||||
|
'message' => '必须添加延期天数',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->withInput()->with(compact('error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request()->start) {
|
||||||
|
$form->start_at = $form->start_at . ' 00:00:01';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request()->end_at) {
|
||||||
|
$form->end_at = $form->end_at . ' 23:59:59';
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$form->saved(function (Form $form) {
|
||||||
|
$users = [];
|
||||||
|
foreach ($form->grants['user_id'] as $key => $user_id) {
|
||||||
|
if ($user_id) {
|
||||||
|
$form->model()->grants()->updateOrCreate([
|
||||||
|
'user_id' => $user_id,
|
||||||
|
]);
|
||||||
|
$users[] = $user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$form->model()->grants()->whereNotIn('user_id', $users)->delete();
|
||||||
|
$users = [];
|
||||||
|
foreach ($form->verifications['user_id'] as $key => $user_id) {
|
||||||
|
if ($user_id) {
|
||||||
|
$form->model()->verifications()->updateOrCreate([
|
||||||
|
'user_id' => $user_id,
|
||||||
|
]);
|
||||||
|
$users[] = $user_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$form->model()->verifications()->whereNotIn('user_id', $users)->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
94
app/Admin/Controllers/Activity/LogController.php
Normal file
94
app/Admin/Controllers/Activity/LogController.php
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Activity;
|
||||||
|
|
||||||
|
use App\Admin\Renderable\Activity\Grants;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Models\ActivityCouponLog;
|
||||||
|
use App\Models\ActivityGrant;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\HasResourceActions;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Layout\Content;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use Illuminate\Routing\Controller as AdminController;
|
||||||
|
|
||||||
|
class LogController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
use HasResourceActions;
|
||||||
|
|
||||||
|
protected $title = '回调记录';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get content title.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function title()
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index interface.
|
||||||
|
* @param Content $content
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
|
public function index(Content $content)
|
||||||
|
{
|
||||||
|
return $content
|
||||||
|
->title($this->title())
|
||||||
|
->description($this->description['index'] ?? trans('admin.list'))
|
||||||
|
->body($this->grid());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new ActivityCouponLog);
|
||||||
|
|
||||||
|
$grid->model()->latest();
|
||||||
|
$grid->disableActions();
|
||||||
|
$grid->disableCreateButton();
|
||||||
|
|
||||||
|
$grid->filter(function ($filter) {
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('code', '卡券编号');
|
||||||
|
$filter->equal('type', '分类')->select(ActivityCouponLog::TYPES);
|
||||||
|
});
|
||||||
|
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->equal('status', '状态')->select(ActivityCouponLog::STATUS);
|
||||||
|
|
||||||
|
$filter->between('created_at', '开始时间')->datetime();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('code', '卡券编号');
|
||||||
|
$grid->column('type', '分类')
|
||||||
|
->using(ActivityCouponLog::TYPES)
|
||||||
|
->label([
|
||||||
|
1 => 'default',
|
||||||
|
2 => 'warning',
|
||||||
|
3 => 'info',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('status', '状态')
|
||||||
|
->using(ActivityCouponLog::STATUS)
|
||||||
|
->label([
|
||||||
|
1 => 'default',
|
||||||
|
2 => 'warning',
|
||||||
|
3 => 'info',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('remark', '处理结果');
|
||||||
|
|
||||||
|
$grid->column('created_at', '操作时间');
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
83
app/Admin/Controllers/Activity/RuleController.php
Normal file
83
app/Admin/Controllers/Activity/RuleController.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Activity;
|
||||||
|
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Form;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use RuLong\Identity\Models\Identity;
|
||||||
|
|
||||||
|
class RuleController extends AdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $title = '规则管理';
|
||||||
|
|
||||||
|
protected function grid()
|
||||||
|
{
|
||||||
|
$grid = new Grid(new ActivityRule);
|
||||||
|
|
||||||
|
$grid->actions(function ($actions) {
|
||||||
|
$actions->disableView();
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('title', '规则名称');
|
||||||
|
$grid->column('code', '规则编号');
|
||||||
|
$grid->column('full', '满足金额');
|
||||||
|
$grid->column('take', '扣除金额');
|
||||||
|
$grid->status('状态')->switch([
|
||||||
|
'on' => ['value' => 1, 'text' => '正常', 'color' => 'primary'],
|
||||||
|
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('created_at', '创建时间');
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a form builder.
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
|
protected function form()
|
||||||
|
{
|
||||||
|
$form = new Form(new ActivityRule);
|
||||||
|
|
||||||
|
$form->text('title', '规则名称')->required();
|
||||||
|
$form->text('code', '规则编号')->required()->help('列:YSD-full100-15');
|
||||||
|
|
||||||
|
$form->hidden('full', '满足金额')->required()->default(0);
|
||||||
|
$form->hidden('take', '抵扣金额')->required()->default(0);
|
||||||
|
|
||||||
|
$form->switch('status', '状态')->default(1);
|
||||||
|
$form->saving(function (Form $form) {
|
||||||
|
if ($form->code) {
|
||||||
|
$code = $form->code;
|
||||||
|
|
||||||
|
$ticket = explode('-', $code);
|
||||||
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
|
$error = new MessageBag([
|
||||||
|
'title' => '错误',
|
||||||
|
'message' => '规则编号格式错误',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->withInput()->with(compact('error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
preg_match('/\d+/', $full, $match);
|
||||||
|
|
||||||
|
$form->full = $match[0];
|
||||||
|
$form->take = $price;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
160
app/Admin/Controllers/Coupon/IndexController.php
Normal file
160
app/Admin/Controllers/Coupon/IndexController.php
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Coupon;
|
||||||
|
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
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()
|
||||||
|
->with(['outlet.province', 'outlet.city', 'outlet.district', 'user', 'user.info'])
|
||||||
|
->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::whereHas('identity', function ($query) {
|
||||||
|
$query->where('identity_id', 1);
|
||||||
|
})->get()->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
$filter->equal('thirdPartyGoodsId', '优惠政策')->select(ActivityRule::pluck('title', 'code'));
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$filter->like('redemptionCode', '卡券编号');
|
||||||
|
$filter->where(function ($query) {
|
||||||
|
$query->whereHas('outlet', function ($query) {
|
||||||
|
$query->whereHas('info', function ($query) {
|
||||||
|
$query->where('nickname', 'like', "%{$this->input}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, '网点名称');
|
||||||
|
|
||||||
|
$filter->equal('type', '类型')->select(Coupon::TYPES);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('id', '#ID#');
|
||||||
|
$grid->column('渠道')->display(function () {
|
||||||
|
return $this->user->nickname;
|
||||||
|
});
|
||||||
|
$grid->column('type', '类型')
|
||||||
|
->using(Coupon::TYPES)
|
||||||
|
->label([
|
||||||
|
'1' => 'info',
|
||||||
|
'2' => 'success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$grid->column('网点名称/编号')->display(function () {
|
||||||
|
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||||
|
});
|
||||||
|
|
||||||
|
$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);
|
||||||
|
$total = $query->count();
|
||||||
|
$success = $query->where('status', 2)->count();
|
||||||
|
$faield = $total - $success;
|
||||||
|
|
||||||
|
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||||
|
. '<label class="label label-success">成功:' . $success . '张</label> '
|
||||||
|
. '<label class="label label-success">失败:' . $faield . '张</label> '
|
||||||
|
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||||
|
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||||
|
. '<label class="label label-success">打款金额:' . $query->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('type', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('redemptionCode', 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('资金通道结算', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->filename('卡券列表' . date("YmdHis"));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
99
app/Admin/Controllers/Finance/CensusController.php
Normal file
99
app/Admin/Controllers/Finance/CensusController.php
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Finance;
|
||||||
|
|
||||||
|
use App\Models\AccountRule;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Facades\Admin;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Layout\Content;
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
$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;
|
||||||
|
$rules = ActivityRule::get();
|
||||||
|
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$grid->column($rule->title)->display(function () use ($today, $rule) {
|
||||||
|
return $this->getCouponCount($rule->code, $today);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// $grid->column('100元减10元优惠券')->display(function () use ($today) {
|
||||||
|
// return $this->getCouponCount('YSD-full100-10', $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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
160
app/Admin/Controllers/Finance/IndexController.php
Normal file
160
app/Admin/Controllers/Finance/IndexController.php
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<?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->model()->with(['outlet', 'user', 'user.info'])->where('profit', '>', 0);
|
||||||
|
$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);
|
||||||
|
})
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$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('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) {
|
||||||
|
$total = $query->count();
|
||||||
|
$success = $query->where('status', 2)->count();
|
||||||
|
$faield = $total - $success;
|
||||||
|
|
||||||
|
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||||
|
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||||
|
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||||
|
. '<label class="label label-success">打款金额:' . $query->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('redemptionCode', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('price', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('profit', function ($value, $original) {
|
||||||
|
return strip_tags($value) . "\t";
|
||||||
|
});
|
||||||
|
$export->filename('平安渠道打款处理' . date("YmdHis"));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
110
app/Admin/Controllers/Finance/LogController.php
Normal file
110
app/Admin/Controllers/Finance/LogController.php
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<?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);
|
||||||
|
})
|
||||||
|
->get()
|
||||||
|
->pluck('nickname', 'id');
|
||||||
|
$filter->equal('user_id', '渠道')->select($users);
|
||||||
|
});
|
||||||
|
$filter->column(1 / 2, function ($filter) {
|
||||||
|
$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('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->export(function ($export) {
|
||||||
|
$export->column('状态', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('打款', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('redemptionCode', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('网点名称/编号', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('price', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('profit', function ($value, $original) {
|
||||||
|
return strip_tags($value) . "\t";
|
||||||
|
});
|
||||||
|
$export->filename('已打款记录' . date("YmdHis"));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
204
app/Admin/Controllers/HomeController.php
Normal file
204
app/Admin/Controllers/HomeController.php
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
<?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('数据看版3')
|
||||||
|
->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(
|
||||||
|
'资金通道结算',
|
||||||
|
'',
|
||||||
|
'red',
|
||||||
|
'/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) {
|
||||||
|
|
||||||
|
$lists = [
|
||||||
|
'ysd10' => Coupon::where('status', 2)
|
||||||
|
->whereDate('created_at', now()->format('Y-m-d'))
|
||||||
|
->where('thirdPartyGoodsId', 'YSD-full100-10')
|
||||||
|
->count(),
|
||||||
|
'ysd25' => Coupon::where('status', 2)
|
||||||
|
->whereDate('created_at', now()->format('Y-m-d'))
|
||||||
|
->where('thirdPartyGoodsId', 'YSD-full100-25')
|
||||||
|
->count(),
|
||||||
|
'ysd50' => Coupon::where('status', 2)
|
||||||
|
->whereDate('created_at', now()->format('Y-m-d'))
|
||||||
|
->where('thirdPartyGoodsId', 'YSD-full100-50')
|
||||||
|
->count(),
|
||||||
|
'ysd100' => Coupon::where('status', 2)
|
||||||
|
->whereDate('created_at', now()->format('Y-m-d'))
|
||||||
|
->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) {
|
||||||
|
|
||||||
|
$lists = [
|
||||||
|
'ysd10' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full100-10')->count(),
|
||||||
|
'ysd25' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full100-25')->count(),
|
||||||
|
'ysd50' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full100-50')->count(),
|
||||||
|
'ysd100' => Coupon::where('status', 2)->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']
|
||||||
|
));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
84
app/Admin/Controllers/IdentityController.php
Normal file
84
app/Admin/Controllers/IdentityController.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
106
app/Admin/Controllers/Log/IndexController.php
Normal file
106
app/Admin/Controllers/Log/IndexController.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Log;
|
||||||
|
|
||||||
|
use App\Admin\Renderable\Log\InData;
|
||||||
|
use App\Admin\Renderable\Log\OutData;
|
||||||
|
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(Log::TYPES);
|
||||||
|
$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('created_at', '提交时间');
|
||||||
|
|
||||||
|
$grid->column('method', '模式');
|
||||||
|
// $grid->column('in_source', '请求参数')
|
||||||
|
// ->display(function ($title, $column) {
|
||||||
|
// return '点击展开';
|
||||||
|
// })->modal(InData::class);
|
||||||
|
//
|
||||||
|
// $grid->column('out_source', '返回参数')
|
||||||
|
// ->display(function ($title, $column) {
|
||||||
|
// return '点击展开';
|
||||||
|
// })->modal(OutData::class);
|
||||||
|
$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('返回信息')->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;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
72
app/Admin/Controllers/TestController.php
Normal file
72
app/Admin/Controllers/TestController.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class TestController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$date = $request->date ?? date('Y-m-d');
|
||||||
|
$time = Carbon::parse($date);
|
||||||
|
|
||||||
|
$all = Coupon::where('status', 2)
|
||||||
|
->whereBetween('created_at', [
|
||||||
|
$time->startOfDay()->toDateTimeString(),
|
||||||
|
$time->endOfDay()->toDateTimeString(),
|
||||||
|
])
|
||||||
|
->count();
|
||||||
|
$self = Coupon::where('status', 2)
|
||||||
|
->where('type', Coupon::TYPE_YSD)
|
||||||
|
->whereBetween('created_at', [
|
||||||
|
$time->startOfDay()->toDateTimeString(),
|
||||||
|
$time->endOfDay()->toDateTimeString(),
|
||||||
|
])
|
||||||
|
->count();
|
||||||
|
$pingan = Coupon::where('status', 2)
|
||||||
|
->where('type', Coupon::TYPE_PINGAN)
|
||||||
|
->whereBetween('created_at', [
|
||||||
|
$time->startOfDay()->toDateTimeString(),
|
||||||
|
$time->endOfDay()->toDateTimeString(),
|
||||||
|
])
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$error = Coupon::where('status', 3)
|
||||||
|
->whereBetween('created_at', [
|
||||||
|
$time->startOfDay()->toDateTimeString(),
|
||||||
|
$time->endOfDay()->toDateTimeString(),
|
||||||
|
])
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$lists = DB::table('coupons')
|
||||||
|
->where('status', 2)
|
||||||
|
->whereBetween('created_at', [
|
||||||
|
$time->startOfDay()->toDateTimeString(),
|
||||||
|
$time->endOfDay()->toDateTimeString(),
|
||||||
|
])
|
||||||
|
->select('redemptionCode', DB::raw('COUNT(*) as code_count'))
|
||||||
|
->groupBy('redemptionCode')
|
||||||
|
->having('code_count', '>', 1)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
' 日期为:' . $time->format('Y-m-d'),
|
||||||
|
' 核销总数为:' . $all,
|
||||||
|
' 自有卡券总数为:' . $self,
|
||||||
|
' 平安卡券总数为:' . $pingan,
|
||||||
|
' 核销错误总数为:' . $error,
|
||||||
|
' 核销重复数据数为:' . $lists->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($data as $info) {
|
||||||
|
dump($info);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
279
app/Admin/Controllers/User/IndexController.php
Normal file
279
app/Admin/Controllers/User/IndexController.php
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\User;
|
||||||
|
|
||||||
|
use App\Admin\Actions\User\Callback;
|
||||||
|
use App\Admin\Actions\User\Profit;
|
||||||
|
use App\Admin\Actions\User\ReCode;
|
||||||
|
use App\Admin\Actions\User\RefD3Key;
|
||||||
|
use App\Admin\Renderable\User\Rule;
|
||||||
|
use App\Admin\Renderable\User\ServerKey;
|
||||||
|
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->model()->with(['parent']);
|
||||||
|
$grid->actions(function ($actions) use ($user) {
|
||||||
|
$actions->disableDelete();
|
||||||
|
$actions->disableView();
|
||||||
|
|
||||||
|
if ($actions->row->identity_id == 1) {
|
||||||
|
$actions->add(new RefD3Key);
|
||||||
|
$actions->add(new ReCode);
|
||||||
|
$actions->add(new Callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($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 = [
|
||||||
|
[
|
||||||
|
$this->callback,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
return new Table(['url'], $data);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('密钥')->display(function ($title, $column) {
|
||||||
|
return '点击查看';
|
||||||
|
})->modal(ServerKey::class);
|
||||||
|
|
||||||
|
$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 : '---';
|
||||||
|
});
|
||||||
|
|
||||||
|
$grid->column('分润规则')->display(function ($title, $column) {
|
||||||
|
return '点击展开';
|
||||||
|
})->modal(Rule::class);
|
||||||
|
|
||||||
|
$grid->column('created_at', '注册时间');
|
||||||
|
$grid->disableExport(false);
|
||||||
|
|
||||||
|
$grid->export(function ($export) {
|
||||||
|
$export->except(['密钥', '分润规则', '回调地址']);
|
||||||
|
$export->column('用户身份', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('渠道编号', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->column('网点编号', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
$export->filename($this->title . date("YmdHis"));
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->help('未选择隶属渠道创建渠道账号,选择隶属渠道创建网点账号');
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->parent_id) {
|
||||||
|
if ($user->server_id != $user->parent->server_id) {
|
||||||
|
$user->server_id = $user->parent->server_id;
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
})->get();
|
||||||
|
|
||||||
|
$userRet = $users->map(function ($code) {
|
||||||
|
return [
|
||||||
|
'id' => $code->id,
|
||||||
|
'text' => $code->info->nickname,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
$userRet->prepend(['id' => '', 'text' => '']);
|
||||||
|
|
||||||
|
return $userRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
151
app/Admin/Controllers/Wo/IndexController.php
Normal file
151
app/Admin/Controllers/Wo/IndexController.php
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers\Wo;
|
||||||
|
|
||||||
|
use App\Admin\Actions\Wo\Unsubscribe;
|
||||||
|
use App\Admin\Exporters\WoCouponExport;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\WoCoupon;
|
||||||
|
use Encore\Admin\Controllers\AdminController;
|
||||||
|
use Encore\Admin\Grid;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
|
||||||
|
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->model()->with(['user']);
|
||||||
|
$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元话费券',
|
||||||
|
]);
|
||||||
|
$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('mobile', '手机号')->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('ticketAmt', '电子券面值');
|
||||||
|
$grid->column('status', '状态')->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('status', function ($value, $original) {
|
||||||
|
return strip_tags($value);
|
||||||
|
});
|
||||||
|
$export->column('mobile', function ($value, $original) {
|
||||||
|
return $original . "\t";
|
||||||
|
});
|
||||||
|
$export->column('ticketAmt', function ($value, $original) {
|
||||||
|
return $value . "\t";
|
||||||
|
});
|
||||||
|
|
||||||
|
$export->filename('沃钱包业务' . date("YmdHis"));
|
||||||
|
});
|
||||||
|
|
||||||
|
return $grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
app/Admin/Exporters/CouponExport.php
Normal file
40
app/Admin/Exporters/CouponExport.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?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->redemptionCode,
|
||||||
|
$info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$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->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->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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
39
app/Admin/Imports/User.php
Normal file
39
app/Admin/Imports/User.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?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]);
|
||||||
|
})->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
26
app/Admin/Renderable/Activity/Grants.php
Normal file
26
app/Admin/Renderable/Activity/Grants.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Renderable\Activity;
|
||||||
|
|
||||||
|
use App\Models\Activity;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
|
||||||
|
class Grants implements Renderable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function render($key = null)
|
||||||
|
{
|
||||||
|
$activity = Activity::find($key);
|
||||||
|
$items = $activity->grants->map(function ($info) {
|
||||||
|
return [
|
||||||
|
'id' => $info->id,
|
||||||
|
'nickname' => $info->user_nickname,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
dd($items->toArray());
|
||||||
|
|
||||||
|
return new Table(['Id', '渠道'], $items->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
app/Admin/Renderable/Log/InData.php
Normal file
32
app/Admin/Renderable/Log/InData.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Renderable\Log;
|
||||||
|
|
||||||
|
use App\Models\Log;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
|
||||||
|
class InData implements Renderable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function render($key = null)
|
||||||
|
{
|
||||||
|
$log = Log::find($key);
|
||||||
|
$in_source = $log->in_source;
|
||||||
|
foreach ($in_source as $key => $item) {
|
||||||
|
if (!in_array($key, [])) {
|
||||||
|
|
||||||
|
}
|
||||||
|
if (is_array($item)) {
|
||||||
|
$in_source[$key] = json_encode($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($in_source) && count($in_source) > 1) {
|
||||||
|
$table = new Table(['名称', '值'], $in_source, ['panel', ' panel-default']);
|
||||||
|
|
||||||
|
return $table->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
app/Admin/Renderable/Log/OutData.php
Normal file
25
app/Admin/Renderable/Log/OutData.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Renderable\Log;
|
||||||
|
|
||||||
|
use App\Models\Log;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
|
||||||
|
class OutData implements Renderable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function render($key = null)
|
||||||
|
{
|
||||||
|
$log = Log::find($key);
|
||||||
|
$out_source = $log->out_source;
|
||||||
|
|
||||||
|
if (is_array($out_source) && count($out_source) > 1) {
|
||||||
|
unset($out_source['sign']);
|
||||||
|
$table = new Table(['名称', '值'], $out_source, ['panel ', 'panel-success']);
|
||||||
|
|
||||||
|
return $table->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
app/Admin/Renderable/User/Rule.php
Normal file
23
app/Admin/Renderable/User/Rule.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Renderable\User;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
|
||||||
|
class Rule implements Renderable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function render($key = null)
|
||||||
|
{
|
||||||
|
$user = User::find($key);
|
||||||
|
$codes = $user->code->map(function ($code) {
|
||||||
|
return $code->only(['name', 'code', 'profit']);
|
||||||
|
});
|
||||||
|
$table = new Table(['名称', '规则项', '分润金额(元)'], $codes->toArray());
|
||||||
|
|
||||||
|
return $table->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
app/Admin/Renderable/User/ServerKey.php
Normal file
30
app/Admin/Renderable/User/ServerKey.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Renderable\User;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Encore\Admin\Widgets\Table;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
|
||||||
|
class ServerKey implements Renderable
|
||||||
|
{
|
||||||
|
|
||||||
|
public function render($key = null)
|
||||||
|
{
|
||||||
|
$user = User::find($key);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'服务秘钥', $user->server_key ?? '---',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'DES3秘钥', $user->des3key ?? '---',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$table = new Table(['名称', '参数'], $data);
|
||||||
|
|
||||||
|
return $table->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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();
|
||||||
|
});
|
||||||
58
app/Admin/routes.php
Normal file
58
app/Admin/routes.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?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->get('test', 'TestController@index')->name('test.index');
|
||||||
|
|
||||||
|
$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('identity', 'IdentityController');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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');
|
||||||
|
|
||||||
|
//活动列表
|
||||||
|
$router->resource('activities', 'Activity\IndexController');
|
||||||
|
$router->resource('rules', 'Activity\RuleController');
|
||||||
|
$router->resource('activitycoupons', 'Activity\CouponController');
|
||||||
|
$router->resource('activitycouponlogs', 'Activity\LogController');
|
||||||
|
|
||||||
|
});
|
||||||
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
174
app/Api/Controllers/ApiResponse.php
Normal file
174
app/Api/Controllers/ApiResponse.php
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<?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;
|
||||||
|
use XuanChen\Coupon\Traits\Log as LogTraits;
|
||||||
|
|
||||||
|
trait ApiResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
use LogTraits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [$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 $log
|
||||||
|
* @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];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->updateLog($log, $data); //更新日志
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond(200, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function error($message = '', $log = '')
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'code' => 0,
|
||||||
|
'message' => $message,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($log) {
|
||||||
|
$this->updateLog($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;
|
||||||
|
|
||||||
|
}
|
||||||
16
app/Api/Controllers/IndexController.php
Normal file
16
app/Api/Controllers/IndexController.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Controllers;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return $this->respond('200', [
|
||||||
|
'code' => 200,
|
||||||
|
'message' => 'Json Api is ready',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
208
app/Api/Controllers/UserController.php
Normal file
208
app/Api/Controllers/UserController.php
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Api\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use XuanChen\Coupon\Coupon;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 发券
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2020/6/29 13:57
|
||||||
|
*/
|
||||||
|
public function grant(Request $request)
|
||||||
|
{
|
||||||
|
$inputdata = $request->all();
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
//获取解密后数据
|
||||||
|
$inputdata['jiemi'] = $res;
|
||||||
|
$log = $this->createLog($request->url(), 'POST', $inputdata, 'grant'); //添加日志
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'activityId' => 'required',
|
||||||
|
'outletId' => 'required',
|
||||||
|
'mobile' => 'required',
|
||||||
|
], [
|
||||||
|
'activityId.required' => '缺少活动编码',
|
||||||
|
'outletId.required' => '缺少网点id',
|
||||||
|
'mobile.required' => '缺少手机号',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = Coupon::Grant($res['activityId'], $res['outletId'], $res['mobile']);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($res, $log);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 查询
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2020/7/22 11:23
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
*/
|
||||||
|
public function query(Request $request)
|
||||||
|
{
|
||||||
|
$inputdata = $request->all();
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
$inputdata['jiemi'] = $res;
|
||||||
|
|
||||||
|
$log = $this->createLog($request->url(), 'POST', $inputdata, 'query'); //添加日志
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'redemptionCode' => 'required',
|
||||||
|
'outletId' => 'required',
|
||||||
|
], [
|
||||||
|
'redemptionCode.required' => '缺少卡券兑换码',
|
||||||
|
'outletId.required' => '缺少网点id',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$redemptionCode = $res['redemptionCode'];
|
||||||
|
$outletId = $res['outletId'];
|
||||||
|
|
||||||
|
$res = Coupon::Query($redemptionCode, $outletId);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
//作废
|
||||||
|
public function destroy(Request $request)
|
||||||
|
{
|
||||||
|
$inputdata = $request->all();
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
$inputdata['jiemi'] = $res;
|
||||||
|
$log = $this->createLog($request->url(), 'POST', $inputdata, 'destroy'); //添加日志
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'redemptionCode' => 'required',
|
||||||
|
'outletId' => 'required',
|
||||||
|
], [
|
||||||
|
'redemptionCode.required' => '缺少卡券兑换码',
|
||||||
|
'outletId.required' => '缺少网点id',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$redemptionCode = $res['redemptionCode'];
|
||||||
|
$outletId = $res['outletId'];
|
||||||
|
$res = Coupon::Destroy($redemptionCode, $outletId);
|
||||||
|
|
||||||
|
if ($res !== true) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('作废成功', $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
//核销
|
||||||
|
public function freezecoupon(Request $request)
|
||||||
|
{
|
||||||
|
$inputdata = $request->all();
|
||||||
|
|
||||||
|
$res = $this->checkSign($request);
|
||||||
|
$inputdata['jiemi'] = $res;
|
||||||
|
//插入日志表
|
||||||
|
$log = $this->createLog($request->url(), 'POST', $inputdata, 'freezecoupon'); //添加日志
|
||||||
|
|
||||||
|
if (!is_array($res)) {
|
||||||
|
return $this->error($res, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($res, [
|
||||||
|
'redemptionCode' => 'required',
|
||||||
|
'total' => 'required',
|
||||||
|
'outletId' => 'required',
|
||||||
|
// 'orderid' => 'nullable|min:100',
|
||||||
|
], [
|
||||||
|
'redemptionCode.required' => '缺少卡券兑换码',
|
||||||
|
'total.required' => '缺少订单总额',
|
||||||
|
'outletId.required' => '缺少网点id',
|
||||||
|
'orderid.min' => '订单id长度不能超过100个字符',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return $this->error($validator->errors()->first(), $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
$redemptionCode = $res['redemptionCode'] ?? ''; //'915400693355';
|
||||||
|
$total = $res['total'] ?? ''; //订单总额;
|
||||||
|
$outletId = $res['outletId'] ?? ''; //网点id;
|
||||||
|
$orderid = $res['orderid'] ?? ''; //订单id;
|
||||||
|
$from = $res['from'] ?? ''; //来源;
|
||||||
|
|
||||||
|
$redemptionCode = trim($redemptionCode);
|
||||||
|
$outletId = trim($outletId);
|
||||||
|
|
||||||
|
$coupon = Coupon::Redemption(
|
||||||
|
$this->user,
|
||||||
|
$redemptionCode,
|
||||||
|
$total,
|
||||||
|
$outletId,
|
||||||
|
$orderid,
|
||||||
|
$from
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_string($coupon)) {
|
||||||
|
return $this->error($coupon, $log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($coupon, $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);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Api/routes.php
Normal file
23
app/Api/routes.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'V1'], function () {
|
||||||
|
Route::get('/', 'IndexController@index');
|
||||||
|
|
||||||
|
Route::post('user/get', 'UserController@index');
|
||||||
|
Route::post('user/check', 'UserController@check');
|
||||||
|
|
||||||
|
//平安接口
|
||||||
|
Route::post('user/grant', 'UserController@grant'); //发券
|
||||||
|
Route::post('user/query', 'UserController@query'); //查询
|
||||||
|
Route::post('user/destroy', 'UserController@destroy'); //作废
|
||||||
|
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'); //退业务
|
||||||
|
|
||||||
|
});
|
||||||
41
app/Console/Kernel.php
Normal file
41
app/Console/Kernel.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?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');
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Events/ConponCallback.php
Normal file
20
app/Events/ConponCallback.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\ActivityCoupon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核券之后的回调
|
||||||
|
*/
|
||||||
|
class ConponCallback
|
||||||
|
{
|
||||||
|
|
||||||
|
public $acticity_coupon;
|
||||||
|
|
||||||
|
public function __construct(ActivityCoupon $acticity_coupon)
|
||||||
|
{
|
||||||
|
$this->acticity_coupon = $acticity_coupon;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
app/Exceptions/Handler.php
Normal file
40
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
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',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the exception handling callbacks for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->reportable(function (Throwable $e) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
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()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\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;
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
331
app/Http/Controllers/SkyxuController.php
Normal file
331
app/Http/Controllers/SkyxuController.php
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\TestLog;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Queue\Jobs\Job;
|
||||||
|
use XuanChen\Coupon\Action\pingan\Query;
|
||||||
|
use XuanChen\Coupon\Action\ysd\YsdQuery;
|
||||||
|
|
||||||
|
class SkyxuController
|
||||||
|
{
|
||||||
|
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public $jiemi;
|
||||||
|
|
||||||
|
public $query_coupon;
|
||||||
|
|
||||||
|
public $ticket;
|
||||||
|
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$list = Job::get();
|
||||||
|
dd($list);
|
||||||
|
Coupon::whereBetween('id', ['70091', '70513'])
|
||||||
|
->orderBy('created_at', 'ASC')
|
||||||
|
->chunk(100, function ($logs) {
|
||||||
|
foreach ($logs as $log) {
|
||||||
|
if (preg_match('/^YSD/', $log->redemptionCode, $matches)) {
|
||||||
|
$type = Coupon::TYPE_YSD;
|
||||||
|
} else {
|
||||||
|
$type = Coupon::TYPE_PINGAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
$log->type = $type;
|
||||||
|
$log->save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dd();
|
||||||
|
$count = TestLog::whereBetween('created_at', ['2020-11-10 11:06:40', '2020-11-11 10:42:26'])
|
||||||
|
->where('type', 'freezecoupon')
|
||||||
|
->where('back', '0')
|
||||||
|
->orderBy('created_at', 'ASC')
|
||||||
|
->count();
|
||||||
|
dump($count);
|
||||||
|
// $list = TestLog::whereBetween('created_at', ['2020-11-10 11:06:40', '2020-11-11 10:42:26'])
|
||||||
|
// ->where('type', 'freezecoupon')
|
||||||
|
// ->where('back', '0')
|
||||||
|
// ->orderBy('created_at', 'ASC')
|
||||||
|
// ->get();
|
||||||
|
//
|
||||||
|
//// $data = [];
|
||||||
|
//// foreach ($list as $cou) {
|
||||||
|
//// $data[] = $cou->in_source['jiemi']['redemptionCode'];
|
||||||
|
//// }
|
||||||
|
//// dump($data);
|
||||||
|
|
||||||
|
if ($count > 1) {
|
||||||
|
try {
|
||||||
|
TestLog::whereBetween('created_at', ['2020-11-10 11:06:40', '2020-11-11 10:42:26'])
|
||||||
|
->where('type', 'freezecoupon')
|
||||||
|
->where('back', '0')
|
||||||
|
->orderBy('created_at', 'ASC')
|
||||||
|
->chunk(100, function ($logs) {
|
||||||
|
$su = $er = [];
|
||||||
|
|
||||||
|
foreach ($logs as $log) {
|
||||||
|
|
||||||
|
$this->jiemi = $log->in_source['jiemi'];
|
||||||
|
$this->user = User::where('outlet_id', $this->jiemi['outletId'])->first();
|
||||||
|
$this->getQuery();
|
||||||
|
|
||||||
|
if (is_string($this->queryData)) {
|
||||||
|
$er[$this->jiemi['redemptionCode']] = $this->queryData;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->jiemi['redemptionCode'] == '157922465040') {
|
||||||
|
dump($this->jiemi);
|
||||||
|
dump($this->ticket);
|
||||||
|
dump($this->queryData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->checkCode();
|
||||||
|
if (is_string($this->ticket)) {
|
||||||
|
$er[$this->jiemi['redemptionCode']] = $this->ticket;
|
||||||
|
|
||||||
|
$er[] = $this->jiemi['redemptionCode'];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = isset($log->out_source['code']) ? 2 : 3;
|
||||||
|
$exists = Coupon::where('status', $status)
|
||||||
|
->where('redemptionCode', $this->jiemi['redemptionCode'])->exists();
|
||||||
|
if ($exists && $status != 3) {
|
||||||
|
$er[$this->jiemi['redemptionCode']] = [
|
||||||
|
$log->out_source,
|
||||||
|
];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$couponData = [
|
||||||
|
'user_id' => $this->user->parent->id,
|
||||||
|
'type' => Coupon::TYPE_YSD,
|
||||||
|
'outletId' => $this->user->outlet_id,
|
||||||
|
'orderid' => '',
|
||||||
|
'PaOutletId' => $this->queryData['PaOutletId'],
|
||||||
|
'redemptionCode' => $this->jiemi['redemptionCode'],
|
||||||
|
'thirdPartyGoodsId' => $this->queryData['thirdPartyGoodsId'],
|
||||||
|
'couponName' => $this->queryData['couponName'],
|
||||||
|
'price' => $this->ticket['price'],
|
||||||
|
'total' => $this->jiemi['total'],
|
||||||
|
'profit' => $this->ticket['profit'],
|
||||||
|
'status' => $status,
|
||||||
|
'remark' => isset($log->out_source['code']) ? '核销成功!' : $log->out_source[0],
|
||||||
|
'startTime' => $this->queryData['startTime'],
|
||||||
|
'endTime' => $this->queryData['endTime'],
|
||||||
|
'created_at' => $log->created_at->format('Y-m-d H:i:s'),
|
||||||
|
];
|
||||||
|
|
||||||
|
// dump($this->jiemi);
|
||||||
|
// dump($this->ticket);
|
||||||
|
// dump($couponData);
|
||||||
|
// dd($this->queryData);
|
||||||
|
|
||||||
|
$coupon = Coupon::create($couponData);
|
||||||
|
$coupon->profit();
|
||||||
|
|
||||||
|
$log->back = 1;
|
||||||
|
$log->save();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($er) > 1) {
|
||||||
|
dump($er);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
dd($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQuery()
|
||||||
|
{
|
||||||
|
if (preg_match('/^YSD/', $this->jiemi['redemptionCode'], $matches)) {
|
||||||
|
$this->query_coupon = (new YsdQuery)->setOutletId($this->jiemi['outletId'])
|
||||||
|
->setCode($this->jiemi['redemptionCode'])
|
||||||
|
->start();
|
||||||
|
$this->type = 'ysd';
|
||||||
|
} else {
|
||||||
|
$this->query_coupon = (new Query)->setOutletId($this->jiemi['outletId'])
|
||||||
|
->setCode($this->jiemi['redemptionCode'])
|
||||||
|
->start();
|
||||||
|
$this->type = 'pingan';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->type == 'ysd') {
|
||||||
|
return $this->getYsdPro();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return $this->getPro();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYsdPro()
|
||||||
|
{
|
||||||
|
$rule_code = $this->query_coupon->activity->rule->code;
|
||||||
|
$code = $this->user->parent->code->where('code', $rule_code)->first();
|
||||||
|
|
||||||
|
if (!$code) {
|
||||||
|
$this->queryData = "核销失败,您没有权限使用此卡券优惠活动。";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = explode('-', $rule_code);
|
||||||
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
|
$this->queryData = "核销失败,卡券规则格式不正确";
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
// preg_match('/(\d{3}(\.\d+)?)/is', $full, $match);
|
||||||
|
preg_match('/\d+/', $full, $match);
|
||||||
|
|
||||||
|
if (!is_array($match)) {
|
||||||
|
$this->queryData = "核销失败,卡券规则格式不正确。";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($this->jiemi['total'])) {
|
||||||
|
$this->queryData = "核销失败,订单金额必须是数字";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($match[0] > $this->jiemi['total']) {
|
||||||
|
$this->queryData = '核销失败,订单金额不足。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->queryData = [
|
||||||
|
'couponName' => $this->query_coupon->activity->title,
|
||||||
|
'thirdPartyGoodsId' => $rule_code,
|
||||||
|
'productId' => '',
|
||||||
|
'PaOutletId' => '',
|
||||||
|
'startTime' => $this->query_coupon->start_at->format('Y-m-d H:i:s'),
|
||||||
|
'endTime' => $this->query_coupon->end_at->format('Y-m-d H:i:s'),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->ticket = [
|
||||||
|
'total' => $match[0],
|
||||||
|
'price' => $price,
|
||||||
|
'profit' => $code->profit,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPro()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (is_string($this->query_coupon)) {
|
||||||
|
return $this->query_coupon;
|
||||||
|
}
|
||||||
|
|
||||||
|
$profitOfferItemVersion = $this->query_coupon['profitOfferItemVersion'];
|
||||||
|
|
||||||
|
$productItemList = $this->query_coupon['productItemList'];
|
||||||
|
|
||||||
|
if (!is_array($productItemList) || !is_array($productItemList[0])) {
|
||||||
|
$this->queryData = '核销失败,平安券数据有误,可能是未配置网点。';
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环查找
|
||||||
|
$first = '';
|
||||||
|
foreach ($productItemList as $key => $item) {
|
||||||
|
$productId = $item['productId'];
|
||||||
|
$thirdPartyGoodsId = $item['thirdPartyGoodsId'];
|
||||||
|
$outletList = $item['outletList'];
|
||||||
|
if (!is_array($outletList) || !is_array($outletList[0])) {
|
||||||
|
$this->queryData = '核销失败,网点信息有误!请检查平安券配置信息。';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$outletList = collect($outletList);
|
||||||
|
//判断是新版还是旧版
|
||||||
|
if ($profitOfferItemVersion) {
|
||||||
|
//新版通过第三方查询
|
||||||
|
$first = $outletList->firstWhere('thirdOutletNo', $this->user->outlet_id);
|
||||||
|
|
||||||
|
if ($first) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//旧版通过平安网点查询
|
||||||
|
$first = $outletList->firstWhere('outletNo', $this->user->PaOutletId);
|
||||||
|
if ($first) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$first) {
|
||||||
|
$this->queryData = '核销失败,未找到可用网点信息。';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$thirdPartyGoodsId) {
|
||||||
|
$this->queryData = '核销失败,平安券编号规则有误。';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$productId) {
|
||||||
|
$this->queryData = '核销失败,未查询到平安券商品id。';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->queryData = [
|
||||||
|
'couponName' => $this->query_coupon['couponName'],
|
||||||
|
'thirdPartyGoodsId' => $thirdPartyGoodsId,
|
||||||
|
'productId' => $productId,
|
||||||
|
'PaOutletId' => $first['outletNo'],
|
||||||
|
'startTime' => $this->query_coupon['startTime'],
|
||||||
|
'endTime' => $this->query_coupon['endTime'],
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkCode()
|
||||||
|
{
|
||||||
|
if ($this->type == 'ysd') {
|
||||||
|
return $this->ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = $this->user->parent->code->where('code', $this->queryData['thirdPartyGoodsId'])->first();
|
||||||
|
if (!$code) {
|
||||||
|
$this->ticket = "核销失败,未找到此项平安券规则,请联系管理人员检查渠道配置。";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = explode('-', $this->queryData['thirdPartyGoodsId']);
|
||||||
|
|
||||||
|
if (!is_array($ticket) || count($ticket) != 3) {
|
||||||
|
$this->ticket = "核销失败,平安券规则格式不正确。";
|
||||||
|
}
|
||||||
|
|
||||||
|
$full = $ticket[1]; //full100
|
||||||
|
$price = $ticket[2];
|
||||||
|
preg_match('/\d+/', $full, $result);
|
||||||
|
|
||||||
|
if (empty($result) || !is_array($result)) {
|
||||||
|
$this->ticket = "核销失败,平安券规则格式不正确。";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($this->jiemi['total'])) {
|
||||||
|
$this->ticket = "核销失败,订单金额必须是数字";
|
||||||
|
}
|
||||||
|
if ($result[0] > $this->jiemi['total']) {
|
||||||
|
$this->ticket = '核销失败,订单金额不足,平安券不可使用。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ticket = [
|
||||||
|
'total' => $result[0],
|
||||||
|
'price' => $price,
|
||||||
|
'profit' => $code->profit,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->ticket;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
305
app/Http/Controllers/TestController.php
Normal file
305
app/Http/Controllers/TestController.php
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Api\Controllers\ApiResponse;
|
||||||
|
use App\Models\User;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use XuanChen\Coupon\Coupon;
|
||||||
|
|
||||||
|
class TestController
|
||||||
|
{
|
||||||
|
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public $baseUrl = 'http://unionpay.ysd-bs.com/api/V1/';
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$this->user = User::find(6);
|
||||||
|
$ret = [
|
||||||
|
'redemptionCode' => 'YSD201029312435',
|
||||||
|
'outletId' => '2008030929274',
|
||||||
|
];
|
||||||
|
|
||||||
|
$ret = [
|
||||||
|
'mobile' => '15663876870',
|
||||||
|
'orderid' => '202008105236478',
|
||||||
|
'activityId' => 'ysd202010272',
|
||||||
|
'outletId' => '2008241014458',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->success($ret);
|
||||||
|
dd();
|
||||||
|
$user_id = $request->user_id;
|
||||||
|
$data = $request->data;
|
||||||
|
$this->user = User::find(3);
|
||||||
|
|
||||||
|
$data = '5VehIrHTZsS1BY8V5VcKlhTN9hbutq4j+HIT2zRCbSqgPWvClQSxYSP7mn7PmHuiYQpj55NRC6w4397FfdVTq23wd4BOQ964giie/JForTjt0l7UaY23XzKnNjDSKiGqr7DAbd8P3SzJ75ZjKaqUu7UWu3PVylAeesGRbZgpQEF/XKwOW4XMaJGV2tIsowILZCtF+moqHg7yA6hI4vT7iYU3rTq9vk7kpcnfArLKPQ5dxH9FFIegdr7E1S8NVwpTZrxeQEmjDUsGrBcWe/Q9dRWXSlKF1Hdz2qCUCK94fu3gqvEVSYRllTCa5mwQhlYJLs2UTmWMSism7nsivySseSl1/JOvNH0lyvWaV1XDUMKG8oTC+kOPQKxFA3qp2xO9ohRhN0dkpML4JVgkMF1r6rv+rThYQuOL/rnsuY5Jdh4QdPWCItQ05lqI46s2yPyKROrLx7jQ3/+BOyEmP+Cj5W8/trEAVS1HczMj4Jnl3vrcY879ubokUcEatalAuKGM0uLNAqQF5XfHzgXam4coEMek8MjdbxW+Z9+eZFQp/P1ts7yN5qzpac6Y8CrqSMFJZf1vwowp+1peiEC5tCsXlHCsDLPS8Uh1LNnC3sag0XZu7jX5uVR9nxR2c/ibBJOAHcUO+NcjmzoN+dQOeBkb/aWj9B+9mW5RUQmfUk6O+Vwkb5ruZZbXsoJJULj4tHJv87+mVo30e0mBbaPD47+fTp1+qSJtLOOlLO2nEj1NNDBSBGLM4RxTDQ4ju2r6HY9YyMXsbNC2YB8zrXrDsUoB1WSuu5XcaWx8rzA0NpckzNbEIuv0+6fA69gXOhC9xcGGPyEBbko73XHr7W8MIDtWhGOG8kHf1cAMdjwVGS2OUJ6XKZnBMwIzY8cJn4Fi+jXRMFnt+7BxWLToNQsyOoHbYWypeM8FrAb4VQeaxGhBQUXUmHhmAp00jcGEe/ngxn1oVjq6G+pEq8CxBntvQ+GZ975sPaCqkYOjbuHa9Myd2tT6GWbczL/YcR4RRV96ByYYCEOBy01LsBNeo6SSpWYcK4eoLhc70v8s';
|
||||||
|
$iv = substr($this->user->des3key, 0, 8);
|
||||||
|
$ret = openssl_decrypt($data, 'DES-EDE3-CBC', $this->user->des3key, 0, $iv);
|
||||||
|
if (false === $ret) {
|
||||||
|
return openssl_error_string();
|
||||||
|
}
|
||||||
|
dd($ret);
|
||||||
|
dd();
|
||||||
|
$this->user = User::find(215);
|
||||||
|
$ret = [
|
||||||
|
'redemptionCode' => '951951858070',
|
||||||
|
'total' => 5,
|
||||||
|
'outletId' => '2006151433887',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $this->success($ret);
|
||||||
|
dd(phpinfo());
|
||||||
|
dd();
|
||||||
|
$num = 100;
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $num; $i++) {
|
||||||
|
$data = [
|
||||||
|
'outletId' => '2004020935777',
|
||||||
|
'activityId' => 'ysd20200740',
|
||||||
|
'mobile' => '15663876870',
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->user = User::find(3);
|
||||||
|
|
||||||
|
$data = $this->jiami($data);
|
||||||
|
|
||||||
|
$url = $this->baseUrl . 'user/grant';
|
||||||
|
$res = $this->http($data, $url);
|
||||||
|
|
||||||
|
// if (isset($res['data'])) {
|
||||||
|
// $jiemi = $this->jiemi($res['data']);
|
||||||
|
// dump($jiemi);
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dump($this->getElapsedTime());
|
||||||
|
dump($this->getMemoryUsage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 发券
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2020/6/29 13:57
|
||||||
|
*/
|
||||||
|
public function grant(Request $request)
|
||||||
|
{
|
||||||
|
$this->user = User::find(299);
|
||||||
|
|
||||||
|
$data = $this->jiami($request->all());
|
||||||
|
|
||||||
|
$url = $this->baseUrl . 'user/grant';
|
||||||
|
$res = $this->http($data, $url);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
|
||||||
|
// dump($this->getElapsedTime());
|
||||||
|
// dump($this->getMemoryUsage());
|
||||||
|
//
|
||||||
|
// dd($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询
|
||||||
|
public function query(Request $request)
|
||||||
|
{
|
||||||
|
$this->user = User::find(3);
|
||||||
|
|
||||||
|
$redemptionCode = $request->redemptionCode;
|
||||||
|
$outletId = $request->outletId;
|
||||||
|
|
||||||
|
$data = $this->jiami($request->all());
|
||||||
|
|
||||||
|
$url = $this->baseUrl . 'user/query';
|
||||||
|
$res = $this->http($data, $url);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
if (isset($res['data'])) {
|
||||||
|
$jiemi = $this->jiemi($res['data']);
|
||||||
|
dump($jiemi);
|
||||||
|
}
|
||||||
|
|
||||||
|
dump($this->getElapsedTime());
|
||||||
|
dump($this->getMemoryUsage());
|
||||||
|
|
||||||
|
dump($res);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//卡券作废
|
||||||
|
public function destroy(Request $request)
|
||||||
|
{
|
||||||
|
$this->user = User::find(3);
|
||||||
|
|
||||||
|
$redemptionCode = $request->redemptionCode;
|
||||||
|
$data = $this->jiami($request->all());
|
||||||
|
|
||||||
|
$url = $this->baseUrl . 'user/destroy';
|
||||||
|
$res = $this->http($data, $url);
|
||||||
|
|
||||||
|
dump($this->getElapsedTime());
|
||||||
|
dump($this->getMemoryUsage());
|
||||||
|
if (isset($res['data'])) {
|
||||||
|
$jiemi = $this->jiemi($res['data']);
|
||||||
|
dump($jiemi);
|
||||||
|
}
|
||||||
|
dump($res);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 核销
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2020/6/29 14:01
|
||||||
|
*/
|
||||||
|
public function checkcoupon(Request $request)
|
||||||
|
{
|
||||||
|
$user_id = $request->user_id;
|
||||||
|
|
||||||
|
$this->user = User::find($user_id);
|
||||||
|
|
||||||
|
$data = $this->jiami([
|
||||||
|
'redemptionCode' => $request->redemptionCode,
|
||||||
|
'total' => $request->total,
|
||||||
|
'outletId' => $request->outletId,
|
||||||
|
'orderid' => $request->orderid,
|
||||||
|
'from' => $request->from,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$url = $this->baseUrl . 'user/freezecoupon';
|
||||||
|
$res = $this->http($data, $url);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
|
||||||
|
$redemptionCode = $request->redemptionCode;
|
||||||
|
$total = $request->total;
|
||||||
|
$outletId = $request->outletId;
|
||||||
|
$orderid = $request->orderid ?? '';
|
||||||
|
$from = $request->from ?? '';
|
||||||
|
|
||||||
|
$res = Coupon::Redemption(
|
||||||
|
$this->user,
|
||||||
|
$redemptionCode,
|
||||||
|
$total,
|
||||||
|
$outletId,
|
||||||
|
$orderid,
|
||||||
|
$from
|
||||||
|
);
|
||||||
|
|
||||||
|
if (is_string($res)) {
|
||||||
|
return $this->error($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('核销成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function http($data, $url)
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
$response = $client->request('POST', $url, ['form_params' => $data, 'http_errors' => false]);
|
||||||
|
|
||||||
|
$body = $response->getBody();
|
||||||
|
$content = $body->getContents();
|
||||||
|
$result = json_decode($content, true);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function jiami($ret)
|
||||||
|
{
|
||||||
|
$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,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解密
|
||||||
|
* @param <type> $value
|
||||||
|
* @return <type>
|
||||||
|
*/
|
||||||
|
public function jiemi($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 getMemoryUsage($precision = 2)
|
||||||
|
{
|
||||||
|
$size = memory_get_usage(true);
|
||||||
|
|
||||||
|
$unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
|
||||||
|
|
||||||
|
return round($size / pow(1024, ($i = floor(log($size, 1024)))), $precision) . ' ' . $unit[$i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getElapsedTime(int $decimals = 2)
|
||||||
|
{
|
||||||
|
return number_format(microtime(true) - request()->server('REQUEST_TIME_FLOAT'), $decimals) . ' s';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notes: 测试签名
|
||||||
|
* @Author: 玄尘
|
||||||
|
* @Date : 2020/12/30 11:47
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
*/
|
||||||
|
public function getSign(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
// $data = 'SMyBpCxqBnxAGr/Fk9LOB851Glkgc3ruZnu1Y0ft/R+Ng26ooLXok1Oi1SrwhSJaQ9U75zy3tI7fq3YfTLQxITwUmt4jBiShpeK1whMaYrI=';
|
||||||
|
// $addcode = '1234567812345678';
|
||||||
|
//
|
||||||
|
// return [
|
||||||
|
// 'sign' => $this->keysign($data, $addcode),
|
||||||
|
// 'server_id' => $this->user->server_id,
|
||||||
|
// 'server_key' => $this->user->server_key,
|
||||||
|
// 'data' => $data,
|
||||||
|
// 'addcode' => $addcode,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
$server_id = $request->server_id;
|
||||||
|
$redemptionCode = $request->redemptionCode;
|
||||||
|
$total = $request->total;
|
||||||
|
$outletId = $request->outletId;
|
||||||
|
|
||||||
|
$this->user = User::whereNull('parent_id')
|
||||||
|
->where('server_id', $server_id)
|
||||||
|
->first();
|
||||||
|
if (!$this->user) {
|
||||||
|
return $this->error('未查到到渠道');
|
||||||
|
}
|
||||||
|
$ret = [
|
||||||
|
'redemptionCode' => $redemptionCode,
|
||||||
|
'total' => $total,
|
||||||
|
'outletId' => $outletId,
|
||||||
|
];
|
||||||
|
|
||||||
|
return json_encode($ret);
|
||||||
|
info(json_encode($ret));
|
||||||
|
|
||||||
|
return $this->success($ret);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
66
app/Http/Kernel.php
Normal file
66
app/Http/Kernel.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?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\TrustHosts::class,
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\Fruitcake\Cors\HandleCors::class,
|
||||||
|
\App\Http\Middleware\PreventRequestsDuringMaintenance::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:api',
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
'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,
|
||||||
|
];
|
||||||
|
}
|
||||||
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|null
|
||||||
|
*/
|
||||||
|
protected function redirectTo($request)
|
||||||
|
{
|
||||||
|
if (! $request->expectsJson()) {
|
||||||
|
return route('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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 = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||||
|
|
||||||
|
class PreventRequestsDuringMaintenance extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|null ...$guards
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, ...$guards)
|
||||||
|
{
|
||||||
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
foreach ($guards as $guard) {
|
||||||
|
if (Auth::guard($guard)->check()) {
|
||||||
|
return redirect(RouteServiceProvider::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',
|
||||||
|
];
|
||||||
|
}
|
||||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||||
|
|
||||||
|
class TrustHosts extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the host patterns that should be trusted.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function hosts()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$this->allSubdomainsOfApplicationUrl(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
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|null
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
|
}
|
||||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be excluded from CSRF verification.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
69
app/Listeners/ConponCallbackListener.php
Normal file
69
app/Listeners/ConponCallbackListener.php
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\ConponCallback;
|
||||||
|
use App\Models\ActivityCouponLog;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class ConponCallbackListener implements ShouldQueue
|
||||||
|
{
|
||||||
|
|
||||||
|
public $queue = 'LISTENER';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
* @param RoomLoginDone $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(ConponCallback $event)
|
||||||
|
{
|
||||||
|
$acticity_coupon = $event->acticity_coupon;
|
||||||
|
|
||||||
|
$user = $acticity_coupon->outlet->parent;
|
||||||
|
if ($user->callback) {
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$response = $client->request('post', $user->callback, [
|
||||||
|
'timeout' => 30,
|
||||||
|
'query' => [
|
||||||
|
'code' => $acticity_coupon->code,
|
||||||
|
'status' => $acticity_coupon->status,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'code' => $acticity_coupon->code,
|
||||||
|
'type' => $acticity_coupon->status == 2 ? 'Verification' : 'Destroy',
|
||||||
|
'url' => $user->callback,
|
||||||
|
];
|
||||||
|
|
||||||
|
$error = false;
|
||||||
|
|
||||||
|
if ($response->getStatusCode() == 200) {
|
||||||
|
$body = $response->getBody();
|
||||||
|
$result = json_decode($body->getContents(), true);
|
||||||
|
|
||||||
|
$data['status'] = $result['code'] ?? '';
|
||||||
|
$data['source'] = $result;
|
||||||
|
$data['remark'] = $result['message'] ?? '';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$data['status'] = 0;
|
||||||
|
$data['source'] = '';
|
||||||
|
$data['remark'] = '接口错误';
|
||||||
|
$error = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityCouponLog::create($data);
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
throw new RuntimeException($data['remark']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/Merchant/Controllers/Census/IndexController.php
Normal file
59
app/Merchant/Controllers/Census/IndexController.php
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers\Census;
|
||||||
|
|
||||||
|
use App\Merchant\Controllers\Controller;
|
||||||
|
use App\Merchant\Exporters\CensusExport;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
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']);
|
||||||
|
|
||||||
|
$rules = ActivityRule::get();
|
||||||
|
|
||||||
|
$coupons = $coupons->groupBy('create_day')->map(function ($items, $key) use ($rules) {
|
||||||
|
$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(),
|
||||||
|
];
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$data[$rule->code] = $items->where('thirdPartyGoodsId', $rule->code)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return collect($data);
|
||||||
|
});
|
||||||
|
|
||||||
|
$all = [];
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$all[$rule->code] = $coupons->sum($rule->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
$coupons = $coupons->sortByDesc('day');
|
||||||
|
|
||||||
|
if ($action == 'search') {
|
||||||
|
return view('Merchant::census.index', compact('coupons', 'all', 'rules'));
|
||||||
|
} 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;
|
||||||
|
}
|
||||||
310
app/Merchant/Controllers/Coupon/IndexController.php
Normal file
310
app/Merchant/Controllers/Coupon/IndexController.php
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers\Coupon;
|
||||||
|
|
||||||
|
use App\Merchant\Controllers\Controller;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::guard('merchant')->user();
|
||||||
|
|
||||||
|
if ($request->start) {
|
||||||
|
$request->start = $request->start . ' 00:00:00';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->end) {
|
||||||
|
$request->end = $request->end . ' 23:59:59';
|
||||||
|
}
|
||||||
|
|
||||||
|
$outlet = $request->outlet;
|
||||||
|
$status = $request->status;
|
||||||
|
$redemptionCode = $request->redemptionCode;
|
||||||
|
$start = $request->start;
|
||||||
|
$end = $request->end;
|
||||||
|
$thirdPartyGoodsId = $request->thirdPartyGoodsId;
|
||||||
|
$action = $request->action ?? 'search';
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, function ($query) {
|
||||||
|
$query->whereIn('status', [2, 3]);
|
||||||
|
})
|
||||||
|
->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);
|
||||||
|
})
|
||||||
|
->orderBy('created_at', 'desc')->orderBy('id', 'desc')->paginate();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'all' => $this->getData($request, 'all', $user),
|
||||||
|
'pass' => $this->getData($request, 'pass', $user),
|
||||||
|
'reject' => $this->getData($request, 'reject', $user),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($action == 'search') {
|
||||||
|
$rules = ActivityRule::get();
|
||||||
|
|
||||||
|
return view('Merchant::coupon.index', compact('coupons', 'data', 'rules'));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->excel($request, $user);
|
||||||
|
|
||||||
|
// return (new CouponExport($request->all(), $user))->download();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照日期分润
|
||||||
|
* @author 玄尘 2020-03-11
|
||||||
|
* @param Request $request [description]
|
||||||
|
* @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
|
*/
|
||||||
|
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('分润失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取分数据
|
||||||
|
public function getData($request, $type, $user)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'all':
|
||||||
|
return Coupon::where('user_id', $user->id)
|
||||||
|
->when($request->outlet, function ($q) use ($request) {
|
||||||
|
$q->whereHas('outlet', function ($q) use ($request) {
|
||||||
|
$q->whereHas('info', function ($q) use ($request) {
|
||||||
|
$q->where('nickname', 'like', "%{$request->outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->redemptionCode, function ($q) use ($request) {
|
||||||
|
$q->where('redemptionCode', $request->redemptionCode);
|
||||||
|
})
|
||||||
|
->when($request->thirdPartyGoodsId, function ($q) use ($request) {
|
||||||
|
$q->where('thirdPartyGoodsId', $request->thirdPartyGoodsId);
|
||||||
|
})
|
||||||
|
->when(is_numeric($request->status), function ($query) use ($request) {
|
||||||
|
$query->where('status', $request->status);
|
||||||
|
}, function ($query) {
|
||||||
|
$query->whereIn('status', [2, 3]);
|
||||||
|
})
|
||||||
|
->when($request->start && $request->end, function ($query) use ($request) {
|
||||||
|
$query->whereBetween('created_at', [$request->start, $request->end]);
|
||||||
|
})
|
||||||
|
->when($request->start, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '>', $request->start);
|
||||||
|
})
|
||||||
|
->when($request->end, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '<', $request->end);
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
break;
|
||||||
|
case 'pass':
|
||||||
|
return Coupon::where('user_id', $user->id)
|
||||||
|
->when($request->outlet, function ($q) use ($request) {
|
||||||
|
$q->whereHas('outlet', function ($q) use ($request) {
|
||||||
|
$q->whereHas('info', function ($q) use ($request) {
|
||||||
|
$q->where('nickname', 'like', "%{$request->outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->redemptionCode, function ($q) use ($request) {
|
||||||
|
$q->where('redemptionCode', $request->redemptionCode);
|
||||||
|
})
|
||||||
|
->when($request->thirdPartyGoodsId, function ($q) use ($request) {
|
||||||
|
$q->where('thirdPartyGoodsId', $request->thirdPartyGoodsId);
|
||||||
|
})
|
||||||
|
->when(is_numeric($request->status), function ($query) use ($request) {
|
||||||
|
$query->where('status', $request->status);
|
||||||
|
})
|
||||||
|
->where('status', 2)
|
||||||
|
->when($request->start && $request->end, function ($query) use ($request) {
|
||||||
|
$query->whereBetween('created_at', [$request->start, $request->end]);
|
||||||
|
})
|
||||||
|
->when($request->start, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '>', $request->start);
|
||||||
|
})
|
||||||
|
->when($request->end, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '<', $request->end);
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
break;
|
||||||
|
case 'reject':
|
||||||
|
return Coupon::where('user_id', $user->id)
|
||||||
|
->when($request->outlet, function ($q) use ($request) {
|
||||||
|
$q->whereHas('outlet', function ($q) use ($request) {
|
||||||
|
$q->whereHas('info', function ($q) use ($request) {
|
||||||
|
$q->where('nickname', 'like', "%{$request->outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->redemptionCode, function ($q) use ($request) {
|
||||||
|
$q->where('redemptionCode', $request->redemptionCode);
|
||||||
|
})
|
||||||
|
->when($request->thirdPartyGoodsId, function ($q) use ($request) {
|
||||||
|
$q->where('thirdPartyGoodsId', $request->thirdPartyGoodsId);
|
||||||
|
})
|
||||||
|
->when(is_numeric($request->status), function ($query) use ($request) {
|
||||||
|
$query->where('status', $request->status);
|
||||||
|
})
|
||||||
|
->where('status', 3)
|
||||||
|
->when($request->start && $request->end, function ($query) use ($request) {
|
||||||
|
$query->whereBetween('created_at', [$request->start, $request->end]);
|
||||||
|
})
|
||||||
|
->when($request->start, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '>', $request->start);
|
||||||
|
})
|
||||||
|
->when($request->end, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '<', $request->end);
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//导出数据
|
||||||
|
public function excel($request, $user)
|
||||||
|
{
|
||||||
|
if (!$request->end) {
|
||||||
|
$request->end = now()->toDateTimeString();
|
||||||
|
}
|
||||||
|
set_time_limit(0);
|
||||||
|
ini_set('memory_limit', '1024M');
|
||||||
|
$filename = '卡券记录' . date('YmdHis') . '.csv';
|
||||||
|
$response = function () use ($user, $request) {
|
||||||
|
$handle = fopen('php://output', 'w');
|
||||||
|
$titles = ['ID', '网点名称', '平安券编号', '优惠政策', '核销金额', '状态', '处理结果', '核销时间'];
|
||||||
|
fputcsv($handle, $titles);
|
||||||
|
|
||||||
|
Coupon::where('user_id', $user->id)
|
||||||
|
->when($request->outlet, function ($q) use ($request) {
|
||||||
|
$q->whereHas('outlet', function ($q) use ($request) {
|
||||||
|
$q->whereHas('info', function ($q) use ($request) {
|
||||||
|
$q->where('nickname', 'like', "%{$request->outlet}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->redemptionCode, function ($q) use ($request) {
|
||||||
|
$q->where('redemptionCode', $request->redemptionCode);
|
||||||
|
})
|
||||||
|
->when($request->thirdPartyGoodsId, function ($q) use ($request) {
|
||||||
|
$q->where('thirdPartyGoodsId', $request->thirdPartyGoodsId);
|
||||||
|
})
|
||||||
|
->when(is_numeric($request->status), function ($query) use ($request) {
|
||||||
|
$query->where('status', $request->status);
|
||||||
|
}, function ($query) {
|
||||||
|
$query->whereIn('status', [2, 3]);
|
||||||
|
})
|
||||||
|
->when($request->start && $request->end, function ($query) use ($request) {
|
||||||
|
$query->whereBetween('created_at', [$request->start, $request->end]);
|
||||||
|
})
|
||||||
|
->when($request->start, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '>', $request->start);
|
||||||
|
})
|
||||||
|
->when($request->end, function ($query) use ($request) {
|
||||||
|
$query->where('created_at', '<', $request->end);
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->chunk(5000, function ($coupons) use ($handle) {
|
||||||
|
foreach ($coupons as $index => $info) {
|
||||||
|
fputcsv($handle, [
|
||||||
|
$info->id,
|
||||||
|
$info->outlet ? $info->outlet->nickname : 'Id:' . $info->outletId,
|
||||||
|
$info->redemptionCode . "\t",
|
||||||
|
' ' . $info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$info->status_text,
|
||||||
|
$info->remark,
|
||||||
|
$info->created_at,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fclose($handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
response()->stream($response, 200, [
|
||||||
|
'Content-Encoding' => 'UTF-8',
|
||||||
|
'Content-Type' => 'text/csv;charset=UTF-8',
|
||||||
|
'Content-Disposition' => "attachment;filename=\"{$filename}\"",
|
||||||
|
])->send();
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
83
app/Merchant/Exporters/CensusExport.php
Normal file
83
app/Merchant/Exporters/CensusExport.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Exporters;
|
||||||
|
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
class CensusExport implements FromCollection, WithMapping, WithHeadings
|
||||||
|
{
|
||||||
|
|
||||||
|
use Exportable;
|
||||||
|
|
||||||
|
public $year = '';
|
||||||
|
|
||||||
|
public $month = '';
|
||||||
|
|
||||||
|
public $user = '';
|
||||||
|
|
||||||
|
public $rules;
|
||||||
|
|
||||||
|
public function __construct($date, $user)
|
||||||
|
{
|
||||||
|
$this->year = $date[0];
|
||||||
|
$this->month = $date[1];
|
||||||
|
$this->user = $user;
|
||||||
|
$this->fileName = '核销统计' . $this->year . '-' . $this->month . '.xlsx';
|
||||||
|
$this->rules = ActivityRule::get();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
$titles = ['日期'];
|
||||||
|
foreach ($this->rules as $rule) {
|
||||||
|
$titles[] = $rule->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $titles;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($this->rules as $rule) {
|
||||||
|
$data[$rule->code] = $items->where('thirdPartyGoodsId', $rule->code)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return collect($data);
|
||||||
|
});
|
||||||
|
$coupons = $coupons->sortByDesc('day');
|
||||||
|
|
||||||
|
return $coupons;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($info): array
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($info as $value) {
|
||||||
|
$data[] = '' . $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
111
app/Merchant/Exporters/CouponExport.php
Normal file
111
app/Merchant/Exporters/CouponExport.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?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') . '.csv';
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
if (!empty($serchDatas)) {
|
||||||
|
foreach ($serchDatas as $key => $data) {
|
||||||
|
if ($key == 'start' && !empty($data)) {
|
||||||
|
$data = $data . ' 00:00:01';
|
||||||
|
}
|
||||||
|
if ($key == 'end' && !empty($data)) {
|
||||||
|
$data = $data . ' 23:59:59';
|
||||||
|
}
|
||||||
|
if ($data) {
|
||||||
|
$this->$key = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return ['ID', '网点名称', '平安券编号', '优惠政策', '核销金额', '状态', '处理结果', '核销时间'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function query()
|
||||||
|
{
|
||||||
|
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 . "\t",
|
||||||
|
' ' . $info->couponName,
|
||||||
|
$info->price,
|
||||||
|
$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>
|
||||||
94
app/Merchant/Resources/views/census/index.blade.php
Normal file
94
app/Merchant/Resources/views/census/index.blade.php
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
@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>
|
||||||
|
@foreach ($rules as $rule)
|
||||||
|
<th>{{ $rule->title }}</th>
|
||||||
|
@endforeach
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($coupons as $coupon)
|
||||||
|
<tr>
|
||||||
|
<td> {{ $coupon['day'] }} </td>
|
||||||
|
@foreach ($rules as $rule)
|
||||||
|
<th>{{ $coupon[$rule->code] ??'' }}</th>
|
||||||
|
@endforeach
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('merchant.coupons',['start'=>$coupon['day'],'end'=>$coupon['day']]) }}">查看</a>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
<tr style="color: #f8ac59">
|
||||||
|
<td> 全部</td>
|
||||||
|
@foreach ($rules as $rule)
|
||||||
|
<th>{{ $all[$rule->code] ??'' }}</th>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</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>渠道后台管理系统</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
|
||||||
146
app/Merchant/Resources/views/coupon/index.blade.php
Normal file
146
app/Merchant/Resources/views/coupon/index.blade.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
@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>
|
||||||
|
@foreach ($rules as $rule)
|
||||||
|
<option value="{{ $rule->code }}" @if(request()->thirdPartyGoodsId== $rule->code) selected="" @endif >
|
||||||
|
{{ $rule->title }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</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> --}}
|
||||||
|
</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->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