colly_wyx
2018-04-26 40417edce32320cc8f6f558adf9b8ee8b4ff23c2
Yfs/Domain/Data.php
@@ -24,6 +24,7 @@
        $arr['lat'] = $data['lat'];
        $arr['address'] = $data['address'];
        foreach ($data['data'] as $value) {
            $arr['value'] = $value['value'];
            $arr['create_time'] = $value['time'];
            $arr['date'] = date('Y-m-d', strtotime($value['time']));
@@ -34,11 +35,24 @@
                }
            }
            elseif($value['type'] == 1){
                $arr['hour'] = date('H', strtotime($value['time']));
                $hourly = $this->hourly_model->get(array('hour' => $arr['hour'], 'date' => $arr['date'], 'user_id' => $arr['user_id']));
                if($hourly){
                    $_id = $hourly['_id'];
                    //更新原有数据
                    $hourly = $arr;
                    $this->hourly_model->update($hourly, array('_id' => $_id));
                }
                else{
                $this->hourly_model->add($arr);
                }
                $task_arr = array();
                if(!in_arrar($task_arr)){
                $task_date = $this->hourly_model->get(array('date' => $arr['date']));
                if(!$task_date){
                   $task_arr['date'] = $arr['date'];
                   $this->task_model->add($arr);
                   $this->task_model->add($task_arr);
                }
                
            }