From 40417edce32320cc8f6f558adf9b8ee8b4ff23c2 Mon Sep 17 00:00:00 2001
From: colly_wyx <wangyixiong_007@163.com>
Date: Thu, 26 Apr 2018 16:44:14 +0800
Subject: [PATCH] 调整上传接口

---
 Yfs/Domain/Data.php |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Yfs/Domain/Data.php b/Yfs/Domain/Data.php
index b70b495..6cfa98c 100644
--- a/Yfs/Domain/Data.php
+++ b/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){
-                $this->hourly_model->add($arr);
+
+                $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); 
                 }
                 
             }

--
Gitblit v1.8.0