|
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\ContractDistribution;
|
|
|
use App\Http\Controllers\AdminBaseController;
|
|
|
use App\Http\Requests\ContractDistributionCreateRequest;
|
|
|
use App\Http\Requests\ContractDistributionUpdateRequest;
|
|
|
+use App\Models\Contract;
|
|
|
use App\Models\ContractDistribution;
|
|
|
use App\Repositories\Eloquent\ContractDistributionRepositoryEloquent;
|
|
|
use App\Servers\ContractServer;
|
|
|
@@ -41,47 +42,59 @@ class ContractDistributionsController extends AdminBaseController
|
|
|
/**
|
|
|
* 数据检索
|
|
|
*/
|
|
|
- public function _indexScopeQuery()
|
|
|
- {
|
|
|
- $where = [];
|
|
|
- $search = explode(";", request()->input('search', ""));
|
|
|
- $start = $end = null;
|
|
|
- $fieldSearchable=$this->repository->getFieldsSearchable();
|
|
|
- foreach ($search as $value) {
|
|
|
- if (!empty($value)) {
|
|
|
- list($one, $tow) = explode(":", $value);
|
|
|
- if (!empty($fieldSearchable[$one])) {
|
|
|
- if($fieldSearchable[$one]=='like')$tow="%{$tow}%";
|
|
|
- $where[]=[$one,$fieldSearchable[$one],$tow];
|
|
|
- } elseif ($one == 'start') {
|
|
|
- $start = $tow . " 00:00:00";
|
|
|
- } elseif ($one == 'end') {
|
|
|
- $end = $tow . " 23:59:59";
|
|
|
- } else {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ public function _indexScopeQuery()
|
|
|
+ {
|
|
|
+ $where = [];
|
|
|
+ $search = explode(";", request()->input('search', ""));
|
|
|
+ $start = $end = null;
|
|
|
+ $fieldSearchable = $this->repository->getFieldsSearchable();
|
|
|
+ foreach ($search as $value) {
|
|
|
+ if (!empty($value)) {
|
|
|
+ list($one, $tow) = explode(":", $value);
|
|
|
+ if (!empty($fieldSearchable[$one])) {
|
|
|
+ if ($fieldSearchable[$one] == 'like') $tow = "%{$tow}%";
|
|
|
+ $where[] = [$one, $fieldSearchable[$one], $tow];
|
|
|
+ } elseif ($one == 'start') {
|
|
|
+ $start = $tow . " 00:00:00";
|
|
|
+ } elseif ($one == 'end') {
|
|
|
+ $end = $tow . " 23:59:59";
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
- return function ($query) use ($where, $start, $end) {
|
|
|
+ }
|
|
|
+ return function ($query) use ($where, $start, $end) {
|
|
|
+
|
|
|
+ if ($start) $where[] = ['created_at', '>=', $start];
|
|
|
+ if ($end) $where[] = ['created_at', '<=', $end];
|
|
|
+ if ($where) {
|
|
|
+ $query->where($where);
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- if ($start) $where[] = ['created_at', '>=', $start];
|
|
|
- if ($end) $where[] = ['created_at', '<=', $end];
|
|
|
- if ($where) {
|
|
|
- $query->where($where);
|
|
|
- }
|
|
|
|
|
|
- };
|
|
|
+ function _indexGet()
|
|
|
+ {
|
|
|
+ $contractId = request()->input('contractId');
|
|
|
+ $typeArr = ContractServer::creatServer()->getDistributionArr();
|
|
|
+ $contractSn = '';
|
|
|
+ if ($contractId) {
|
|
|
+ $contractSn = Contract::where('id', $contractId)->value('contract_sn');
|
|
|
}
|
|
|
+ return ['contractSn'=>$contractSn,'typeArr'=>$typeArr];
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 数据更新
|
|
|
*/
|
|
|
protected function _indexPost($datum)
|
|
|
{
|
|
|
- $status=['失败','成功','广播失败'];
|
|
|
- foreach ($datum as $value){
|
|
|
- $value->{'type'}=ContractServer::creatServer()->getDistributionArrStr($value->{'type'});
|
|
|
- $value->{'status'}=empty($status[$value->{'status'}])?'状态异常':$status[$value->{'status'}];
|
|
|
+ $status = ['失败', '成功', '广播失败'];
|
|
|
+ foreach ($datum as $value) {
|
|
|
+ $value->{'type'} = ContractServer::creatServer()->getDistributionArrStr($value->{'type'});
|
|
|
+ $value->{'status'} = empty($status[$value->{'status'}]) ? '状态异常' : $status[$value->{'status'}];
|
|
|
}
|
|
|
return $datum;
|
|
|
}
|
|
|
@@ -89,9 +102,9 @@ class ContractDistributionsController extends AdminBaseController
|
|
|
function _indexJoin()
|
|
|
{
|
|
|
return ContractDistribution::from('contract_distributions as cb')
|
|
|
- ->leftJoin('contracts as c','c.id','=','cb.contract_id')
|
|
|
- ->leftJoin('broadcasts as b','b.id','=','cb.broadcast_id')
|
|
|
- ->select(['cb.*','c.contract_sn','b.hash']);
|
|
|
+ ->leftJoin('contracts as c', 'c.id', '=', 'cb.contract_id')
|
|
|
+ ->leftJoin('broadcasts as b', 'b.id', '=', 'cb.broadcast_id')
|
|
|
+ ->select(['cb.*', 'c.contract_sn', 'b.hash']);
|
|
|
}
|
|
|
|
|
|
}
|