优化渠道导出

This commit is contained in:
2020-08-28 16:20:36 +08:00
parent 42d56f4c6a
commit e59ceefd16
4 changed files with 59 additions and 53 deletions

View File

@@ -145,14 +145,14 @@ class IndexController extends AdminController
$export->column('redemptionCode', function ($value, $original) { $export->column('redemptionCode', function ($value, $original) {
return $value . "\t"; return $value . "\t";
}); });
$export->column('price', function ($value, $original) { // $export->column('price', function ($value, $original) {
return $value . "\t"; // return $value . "\t";
}); // });
$export->column('total', function ($value, $original) { $export->column('total', function ($value, $original) {
return $value . "\t"; return $value . "\t";
}); });
$export->column('资金通道结算', function ($value, $original) { $export->column('资金通道结算', function ($value, $original) {
return strip_tags($value) . "\t"; return strip_tags($value);
}); });
$export->filename('卡券列表' . date("YmdHis")); $export->filename('卡券列表' . date("YmdHis"));
}); });

View File

@@ -24,19 +24,10 @@ Route::group([
*/ */
$router->get('user/parent', 'User\IndexController@getParent'); $router->get('user/parent', 'User\IndexController@getParent');
$router->resource('users', 'User\IndexController'); $router->resource('users', 'User\IndexController');
//商品管理
$router->resource('goods', 'GoodsController');
//身份管理 //身份管理
$router->resource('identity', 'IdentityController'); $router->resource('identity', 'IdentityController');
$router->get('orders', 'Order\IndexController@index');
$router->get('payments', 'Payment\IndexController@index');
//用户提现管理
$router->get('cashout/logs', 'CashOutController@logs')->name('admin.cashout.logs');
$router->resource('cashout', 'CashOutController');
/** /**
* api 日志 * api 日志
*/ */

View File

@@ -15,12 +15,13 @@ class TestController
{ {
use ApiResponse; use ApiResponse;
public $baseUrl = 'http://pac.ysd-bs.com/api/V1/';
public $baseUrl = 'http://pa.ysd-bs.com/api/V1/';
public function index(Request $request) public function index(Request $request)
{ {
$user_id = $request->user_id; $user_id = $request->user_id;
$data = $request->data; $data = $request->data;
$this->user = User::find(3); $this->user = User::find(3);
$data = '5VehIrHTZsS1BY8V5VcKlhTN9hbutq4j+HIT2zRCbSqgPWvClQSxYSP7mn7PmHuiYQpj55NRC6w4397FfdVTq23wd4BOQ964giie/JForTjt0l7UaY23X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Gqr7DAbd8P3SzJ75ZjKaqUu7UWu3PVylAeesGRbZgpQEF/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';
@@ -54,7 +55,7 @@ class TestController
$data = $this->jiami($data); $data = $this->jiami($data);
$url = $this->baseUrl.'user/grant'; $url = $this->baseUrl . 'user/grant';
$res = $this->http($data, $url); $res = $this->http($data, $url);
// if (isset($res['data'])) { // if (isset($res['data'])) {
@@ -80,7 +81,7 @@ class TestController
$data = $this->jiami($request->all()); $data = $this->jiami($request->all());
$url = $this->baseUrl.'user/grant'; $url = $this->baseUrl . 'user/grant';
$res = $this->http($data, $url); $res = $this->http($data, $url);
return $res; return $res;
@@ -101,7 +102,7 @@ class TestController
$data = $this->jiami($request->all()); $data = $this->jiami($request->all());
$url = $this->baseUrl.'user/query'; $url = $this->baseUrl . 'user/query';
$res = $this->http($data, $url); $res = $this->http($data, $url);
return $res; return $res;
@@ -125,7 +126,7 @@ class TestController
$redemptionCode = $request->redemptionCode; $redemptionCode = $request->redemptionCode;
$data = $this->jiami($request->all()); $data = $this->jiami($request->all());
$url = $this->baseUrl.'user/destroy'; $url = $this->baseUrl . 'user/destroy';
$res = $this->http($data, $url); $res = $this->http($data, $url);
dump($this->getElapsedTime()); dump($this->getElapsedTime());
@@ -156,7 +157,7 @@ class TestController
'orderid' => $request->orderid, 'orderid' => $request->orderid,
]); ]);
$url = $this->baseUrl .'user/freezecoupon'; $url = $this->baseUrl . 'user/freezecoupon';
$res = $this->http($data, $url); $res = $this->http($data, $url);
return $res; return $res;

View File

@@ -10,14 +10,21 @@ use Maatwebsite\Excel\Concerns\WithMapping;
class CouponExport implements FromQuery, WithMapping, WithHeadings class CouponExport implements FromQuery, WithMapping, WithHeadings
{ {
use Exportable; use Exportable;
public $outlet = ''; public $outlet = '';
public $status = ''; public $status = '';
public $redemptionCode = ''; public $redemptionCode = '';
public $start = ''; public $start = '';
public $end = ''; public $end = '';
public $user = ''; public $user = '';
public $thirdPartyGoodsId = ''; public $thirdPartyGoodsId = '';
public function __construct($serchDatas, $user) public function __construct($serchDatas, $user)
@@ -27,9 +34,16 @@ class CouponExport implements FromQuery, WithMapping, WithHeadings
if (!empty($serchDatas)) { if (!empty($serchDatas)) {
foreach ($serchDatas as $key => $data) { foreach ($serchDatas as $key => $data) {
if ($key == 'start') {
$data = $data . ' 00:00:01';
}
if ($key == 'end') {
$data = $data . ' 23:59:59';
}
if ($data) { if ($data) {
$this->$key = $data; $this->$key = $data;
} }
} }
} }
} }
@@ -45,37 +59,37 @@ class CouponExport implements FromQuery, WithMapping, WithHeadings
public function query() public function query()
{ {
return Coupon::where('user_id', $this->user->id) return Coupon::where('user_id', $this->user->id)
->when($this->outlet, function ($q) { ->when($this->outlet, function ($q) {
$q->whereHas('outlet', function ($q) { $q->whereHas('outlet', function ($q) {
$q->whereHas('info', function ($q) { $q->whereHas('info', function ($q) {
$q->where('nickname', 'like', "%{$this->outlet}%"); $q->where('nickname', 'like', "%{$this->outlet}%");
}); });
}); });
}) })
->when($this->redemptionCode, function ($q) { ->when($this->redemptionCode, function ($q) {
$q->where('redemptionCode', $this->redemptionCode); $q->where('redemptionCode', $this->redemptionCode);
}) })
->when($this->thirdPartyGoodsId, function ($q) { ->when($this->thirdPartyGoodsId, function ($q) {
$q->where('thirdPartyGoodsId', $this->thirdPartyGoodsId); $q->where('thirdPartyGoodsId', $this->thirdPartyGoodsId);
}) })
->when(is_numeric($this->status), function ($query) { ->when(is_numeric($this->status), function ($query) {
if ($this->status == 4) { if ($this->status == 4) {
$query->where('is_profit', 1); $query->where('is_profit', 1);
} else { } else {
$query->where('status', $this->status); $query->where('status', $this->status);
} }
}) })
->when($this->start && $this->end, function ($query) { ->when($this->start && $this->end, function ($query) {
$query->whereBetween('created_at', [$this->start, $this->end]); $query->whereBetween('created_at', [$this->start, $this->end]);
}) })
->when($this->start, function ($query) { ->when($this->start, function ($query) {
$query->where('created_at', '>', $this->start); $query->where('created_at', '>', $this->start);
}) })
->when($this->end, function ($query) { ->when($this->end, function ($query) {
$query->where('created_at', '<', $this->end); $query->where('created_at', '<', $this->end);
}) })
->whereIn('status', [2, 3]) ->whereIn('status', [2, 3])
->orderBy('created_at', 'desc'); ->orderBy('created_at', 'desc');
} }
public function map($info): array public function map($info): array