渠道后台增加银联券
This commit is contained in:
147
app/Merchant/Controllers/Unionpay/CouponController.php
Normal file
147
app/Merchant/Controllers/Unionpay/CouponController.php
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Merchant\Controllers\Unionpay;
|
||||||
|
|
||||||
|
use App\Merchant\Controllers\Controller;
|
||||||
|
use App\Models\ActivityRule;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use XuanChen\UnionPay\Models\UnionpayCoupon;
|
||||||
|
|
||||||
|
class CouponController 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';
|
||||||
|
}
|
||||||
|
|
||||||
|
$shop_no = $request->shop_no;
|
||||||
|
$shop_name = $request->shop_name;
|
||||||
|
$coupon_no = $request->coupon_no;
|
||||||
|
$start = $request->start;
|
||||||
|
$end = $request->end;
|
||||||
|
$action = $request->action ?? 'search';
|
||||||
|
|
||||||
|
$coupons = UnionpayCoupon::query()
|
||||||
|
->whereHas('outlet', function ($q) use ($shop_name, $user) {
|
||||||
|
$q->where('parent_id', $user->id)
|
||||||
|
->when($shop_name, function ($q) use ($shop_name) {
|
||||||
|
$q->whereHas('info', function ($q) use ($shop_name) {
|
||||||
|
$q->where('nickname', 'like', "%{$shop_name}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($coupon_no, function ($q) use ($coupon_no) {
|
||||||
|
$q->where('coupon_no', $coupon_no);
|
||||||
|
})
|
||||||
|
->when($shop_no, function ($q) use ($shop_no) {
|
||||||
|
$q->where('shop_no', $shop_no);
|
||||||
|
})
|
||||||
|
->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);
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->paginate();
|
||||||
|
|
||||||
|
if ($action == 'search') {
|
||||||
|
return view('Merchant::unionpay.coupon', compact('coupons',));
|
||||||
|
} else {
|
||||||
|
$this->excel($request, $user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//导出数据
|
||||||
|
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);
|
||||||
|
|
||||||
|
$shop_no = $request->shop_no;
|
||||||
|
$shop_name = $request->shop_name;
|
||||||
|
$coupon_no = $request->coupon_no;
|
||||||
|
$start = $request->start;
|
||||||
|
$end = $request->end;
|
||||||
|
|
||||||
|
UnionpayCoupon::query()
|
||||||
|
->whereHas('outlet', function ($q) use ($shop_name, $user) {
|
||||||
|
$q->where('parent_id', $user->id)
|
||||||
|
->when($shop_name, function ($q) use ($shop_name) {
|
||||||
|
$q->whereHas('info', function ($q) use ($shop_name) {
|
||||||
|
$q->where('nickname', 'like', "%{$shop_name}%");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($coupon_no, function ($q) use ($coupon_no) {
|
||||||
|
$q->where('coupon_no', $coupon_no);
|
||||||
|
})
|
||||||
|
->when($shop_no, function ($q) use ($shop_no) {
|
||||||
|
$q->where('shop_no', $shop_no);
|
||||||
|
})
|
||||||
|
->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);
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->chunk(5000, function ($coupons) use ($handle) {
|
||||||
|
foreach ($coupons as $index => $coupon) {
|
||||||
|
fputcsv($handle, [
|
||||||
|
$coupon->id,
|
||||||
|
$coupon->mobile,
|
||||||
|
$coupon->outlet ? $coupon->outlet->nickname : 'Id:' . $coupon->outletId,
|
||||||
|
$coupon->coupon_no,
|
||||||
|
$coupon->orig_amt / 100,
|
||||||
|
$coupon->discount_amt / 100,
|
||||||
|
$coupon->pay_amt / 100,
|
||||||
|
$coupon->effective_date_time,
|
||||||
|
$coupon->expire_date_time,
|
||||||
|
$coupon->shop_no,
|
||||||
|
$coupon->status_text,
|
||||||
|
$coupon->updated_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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
<ul class="nav" id="side-menu">
|
<ul class="nav" id="side-menu">
|
||||||
<li class="nav-header">
|
<li class="nav-header">
|
||||||
<div class="dropdown profile-element">
|
<div class="dropdown profile-element">
|
||||||
<span><img alt="image" class="img-circle" src="{{ asset('assets/merchant/img/avatar.jpg') }}" width="70" height ="70" /></span>
|
<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);">
|
<a data-toggle="dropdown" class="dropdown-toggle" href="javascript:void(0);">
|
||||||
<span class="clear">
|
<span class="clear">
|
||||||
<span class="block m-t-xs">
|
<span class="block m-t-xs">
|
||||||
@@ -18,24 +19,25 @@
|
|||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu m-t-xs">
|
<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>
|
<li><a data-toggle="layer" data-height="360" data-width="700"
|
||||||
|
href="{{ route('merchant.setting.password') }}" class="password">修改密码</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="logo-element">FX</div>
|
<div class="logo-element">FX</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{{-- <li>--}}
|
{{-- <li>--}}
|
||||||
{{-- <a href="#">--}}
|
{{-- <a href="#">--}}
|
||||||
{{-- <i class="fa fa-user"></i>--}}
|
{{-- <i class="fa fa-user"></i>--}}
|
||||||
{{-- <span class="nav-label">个人信息</span>--}}
|
{{-- <span class="nav-label">个人信息</span>--}}
|
||||||
{{-- <span class="fa arrow"></span>--}}
|
{{-- <span class="fa arrow"></span>--}}
|
||||||
{{-- </a>--}}
|
{{-- </a>--}}
|
||||||
{{-- <ul class="nav nav-second-level">--}}
|
{{-- <ul class="nav nav-second-level">--}}
|
||||||
{{-- <li>--}}
|
{{-- <li>--}}
|
||||||
{{-- <a class="J_menuItem" href="{{ route('merchant.setting.password') }}"><i class="fa fa-list"></i>修改登陆密码</a>--}}
|
{{-- <a class="J_menuItem" href="{{ route('merchant.setting.password') }}"><i class="fa fa-list"></i>修改登陆密码</a>--}}
|
||||||
{{-- </li>--}}
|
{{-- </li>--}}
|
||||||
{{-- </ul>--}}
|
{{-- </ul>--}}
|
||||||
{{-- </li>--}}
|
{{-- </li>--}}
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#">
|
<a href="#">
|
||||||
@@ -51,6 +53,19 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</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.unionpay.coupons') }}"><i class="fa fa-list"></i>核销记录</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
128
app/Merchant/Resources/views/unionpay/coupon.blade.php
Normal file
128
app/Merchant/Resources/views/unionpay/coupon.blade.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
@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.unionpay.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="shop_no" class="input-sm form-control"
|
||||||
|
value="{{ Request::input('shop_no') }}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" placeholder="门店名称" name="shop_name" class="input-sm form-control"
|
||||||
|
value="{{ Request::input('shop_name') }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" placeholder="优惠券券编号" name="coupon_no"
|
||||||
|
class="input-sm form-control" value="{{ Request::input('coupon_no') }}">
|
||||||
|
</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">
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th width="100">ID</th>
|
||||||
|
<th>手机号</th>
|
||||||
|
<th>门店名称</th>
|
||||||
|
<th>优惠券券编号</th>
|
||||||
|
<th>原始金额</th>
|
||||||
|
<th>优惠的金额</th>
|
||||||
|
<th>支付金额</th>
|
||||||
|
<th>券码生效时间</th>
|
||||||
|
<th>券码过期时间</th>
|
||||||
|
<th>门店号</th>
|
||||||
|
<th>状态</th>
|
||||||
|
<th>核销时间</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach ($coupons as $coupon)
|
||||||
|
<tr>
|
||||||
|
<td> {{ $coupon->id }} </td>
|
||||||
|
<td> {{ $coupon->mobile }} </td>
|
||||||
|
<td>{{ $coupon->outlet ? $coupon->outlet->nickname : 'Id:' . $coupon->outletId }}</td>
|
||||||
|
<td>{{ $coupon->coupon_no }}</td>
|
||||||
|
<td>{{ $coupon->orig_amt/100 }}</td>
|
||||||
|
<td>{{ $coupon->discount_amt/100 }}</td>
|
||||||
|
<td>{{ $coupon->pay_amt/100 }}</td>
|
||||||
|
<td>{{ $coupon->effective_date_time }}</td>
|
||||||
|
<td>{{ $coupon->expire_date_time }}</td>
|
||||||
|
<td>{{ $coupon->shop_no }}</td>
|
||||||
|
<td>{{ $coupon->status_text }}</td>
|
||||||
|
<td>{{ $coupon->updated_at }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="text-right">
|
||||||
|
{{
|
||||||
|
$coupons->appends([
|
||||||
|
'shop_no'=>Request::input('shop_no'),
|
||||||
|
'shop_name'=>Request::input('shop_name'),
|
||||||
|
'coupon_no'=>Request::input('coupon_no'),
|
||||||
|
'start'=>Request::input('start'),
|
||||||
|
'end'=>Request::input('end'),
|
||||||
|
])->links('Merchant::common.pagination')
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -16,4 +16,6 @@ Route::middleware(['merchant.auth'])->group(function ($route) {
|
|||||||
|
|
||||||
$route->get('census', 'Census\IndexController@index')->name('census');
|
$route->get('census', 'Census\IndexController@index')->name('census');
|
||||||
|
|
||||||
|
$route->get('unionpay/coupons', 'Unionpay\CouponController@index')->name('unionpay.coupons');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
22
composer.lock
generated
22
composer.lock
generated
@@ -5802,23 +5802,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "xuanchen/unionpay",
|
"name": "xuanchen/unionpay",
|
||||||
"version": "3.0.3",
|
"version": "3.3.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/xuanchen120/unionpay.git",
|
"url": "https://github.com/xuanchen120/unionpay.git",
|
||||||
"reference": "c9894107cde8d524fcabeddbcbb3a287f091ab07"
|
"reference": "9728794099333ea9fac1a48f43c2b8eaa9cf3ecc"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/xuanchen120/unionpay/zipball/c9894107cde8d524fcabeddbcbb3a287f091ab07",
|
"url": "https://api.github.com/repos/xuanchen120/unionpay/zipball/9728794099333ea9fac1a48f43c2b8eaa9cf3ecc",
|
||||||
"reference": "c9894107cde8d524fcabeddbcbb3a287f091ab07",
|
"reference": "9728794099333ea9fac1a48f43c2b8eaa9cf3ecc",
|
||||||
"shasum": "",
|
"shasum": ""
|
||||||
"mirrors": [
|
|
||||||
{
|
|
||||||
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
|
||||||
"preferred": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"laravel/framework": "*",
|
"laravel/framework": "*",
|
||||||
@@ -5851,9 +5845,9 @@
|
|||||||
"description": "第三方银联对接",
|
"description": "第三方银联对接",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/xuanchen120/unionpay/issues",
|
"issues": "https://github.com/xuanchen120/unionpay/issues",
|
||||||
"source": "https://github.com/xuanchen120/unionpay/tree/3.0.3"
|
"source": "https://github.com/xuanchen120/unionpay/tree/3.3.6"
|
||||||
},
|
},
|
||||||
"time": "2021-03-08T07:09:17+00:00"
|
"time": "2021-07-28T08:42:00+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
@@ -8431,5 +8425,5 @@
|
|||||||
"php": "^7.3|^8.0"
|
"php": "^7.3|^8.0"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.0.0"
|
"plugin-api-version": "2.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user