|
@@ -107,6 +107,7 @@ class ScheduleService extends Service
|
|
|
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
+
|
|
|
$time = time();
|
|
|
|
|
|
Schedule::where('id',$data['id'])->update(['del_time' => $time]);
|
|
@@ -126,64 +127,34 @@ class ScheduleService extends Service
|
|
|
|
|
|
public function detail($data,$user){
|
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
|
- $customer = ProductActivity::where('del_time',0)
|
|
|
+ $schedule = Schedule::where('del_time',0)
|
|
|
->where('id',$data['id'])
|
|
|
->first();
|
|
|
- if(empty($customer)) return [false,'活动不存在或已被删除'];
|
|
|
- $customer = $customer->toArray();
|
|
|
-
|
|
|
- $detail = ProductActivityPrice::where('del_time',0)
|
|
|
- ->where('product_activity_id',$data['id'])
|
|
|
- ->get()->toArray();
|
|
|
- $title_map = BasicType::whereIn('id',array_column($detail,'basic_type_id'))
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
- $customer['product'] = [];
|
|
|
-
|
|
|
- //产品字典
|
|
|
- $map = (new ProductService())->getProductDetail(array_unique(array_column($detail,'product_id')));
|
|
|
-
|
|
|
- foreach ($detail as $value){
|
|
|
- $basic_tmp = [
|
|
|
- 'basic_type_id' => $value['basic_type_id'],
|
|
|
- 'basic_type_title' => $title_map[$value['basic_type_id']] ?? '',
|
|
|
- 'price' => $value['price'],
|
|
|
- ];
|
|
|
- if(! isset($customer['product'][$value['product_id']])){
|
|
|
- $tmp = $map[$value['product_id']] ?? [];
|
|
|
- $tmp['activity'][] = $basic_tmp;
|
|
|
- $customer['product'][$value['product_id']] = $tmp;
|
|
|
- }else{
|
|
|
- $customer['product'][$value['product_id']]['activity'][] = $basic_tmp;
|
|
|
- }
|
|
|
- }
|
|
|
+ if(empty($schedule)) return [false,'排班设置不存在或已被删除'];
|
|
|
+ $schedule = $schedule->toArray();
|
|
|
|
|
|
- $customer['product'] = array_values($customer['product']);
|
|
|
- $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
|
|
|
- $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
|
|
|
+ $schedule['crt_name'] = Employee::where('id',$schedule['crt_id'])->value('emp_name');
|
|
|
+ $schedule['crt_time'] = $schedule['crt_time'] ? date("Y-m-d H:i:s",$schedule['crt_time']): '';
|
|
|
|
|
|
- return [true, $customer];
|
|
|
+ return [true, $schedule];
|
|
|
}
|
|
|
|
|
|
public function getList($data,$user){
|
|
|
- $model = ProductActivity::TopClear($user,$data);
|
|
|
+ $model = Schedule::TopClear($user,$data);
|
|
|
$model = $model->where('del_time',0)
|
|
|
- ->select('id','title','crt_id','mark','start_time','end_time','crt_time','type')
|
|
|
+ ->select('id','crt_id','mark','start_time','end_time','crt_time')
|
|
|
->orderby('id', 'desc');
|
|
|
|
|
|
- if(! empty($data['type'])) $model->where('type', $data['type']);
|
|
|
- if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
|
|
|
if(! empty($data['mark'])) $model->where('mark', 'LIKE', '%'.$data['mark'].'%');
|
|
|
if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
|
|
|
$return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
|
|
|
$model->where('crt_time','>=',$return[0]);
|
|
|
$model->where('crt_time','<=',$return[1]);
|
|
|
}
|
|
|
- if(! empty($data['activity_time'][0]) && ! empty($data['activity_time'][1])) {
|
|
|
- $start_time = $this->changeDateToDateMin($data['activity_time'][0]);
|
|
|
- $end_time = $this->changeDateToDateMin($data['activity_time'][1]);
|
|
|
- $model->where('start_time','>=',$start_time);
|
|
|
- $model->where('end_time','<=',$end_time);
|
|
|
+ if(! empty($data['schedule'][0]) && ! empty($data['schedule'][1])) {
|
|
|
+ $return = $this->changeDateToTimeStampAboutRange($data['schedule']);
|
|
|
+ $model->where('start_time','>=',$return[0]);
|
|
|
+ $model->where('end_time','<=',$return[1]);
|
|
|
}
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
@@ -236,10 +207,9 @@ class ScheduleService extends Service
|
|
|
foreach ($data['data'] as $key => $value){
|
|
|
$start_time = $value['start_time'] ? date("Y-m-d H:i",$value['start_time']) : '';
|
|
|
$end_time = $value['end_time'] ? date("Y-m-d H:i",$value['end_time']) : '';
|
|
|
- $data['data'][$key]['activity_time'] = $start_time . '——' . $end_time;
|
|
|
+ $data['data'][$key]['schedule'] = $start_time . '——' . $end_time;
|
|
|
$data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
$data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
|
|
|
- $data['data'][$key]['type_title'] = ProductActivity::$type_name[$value['type']] ?? '';
|
|
|
}
|
|
|
|
|
|
return $data;
|