rabin 6 년 전
부모
커밋
b3bd89c87b
3개의 변경된 파일32개의 추가작업 그리고 11개의 파일을 삭제
  1. 10 0
      database/user.php
  2. 10 0
      database/user_answer.php
  3. 12 11
      src/Api.php

+ 10 - 0
database/user.php

@@ -42,6 +42,16 @@ return array
 			'value'		=> Dever::input('search_option_product_id')
 		),
 
+		'order_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订单',
+			'default' 	=> '',
+			'desc' 		=> '订单',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+		),
+
 		'uid'		=> array
 		(
 			'type' 		=> 'varchar-150',

+ 10 - 0
database/user_answer.php

@@ -52,6 +52,16 @@ return array
 			'update'	=> 'text',
 		),
 
+		'order_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订单',
+			'default' 	=> '',
+			'desc' 		=> '订单',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+		),
+
 		'score'		=> array
 		(
 			'type' 		=> 'int-11',

+ 12 - 11
src/Api.php

@@ -11,17 +11,18 @@ class Api
 	 *
 	 * @return mixed
 	 */
-	public function get($uid, $product_id, $page_number = false)
+	public function get($uid, $product_id, $order_id, $page_number = false)
 	{
 		if ($product_id <= 0) {
 			Dever::alert('请传入正确的产品id');
 		}
 
-		$user = Dever::db('survey/user')->one(array('uid' => $uid, 'product_id' => $product_id));
+		$user = Dever::db('survey/user')->one(array('uid' => $uid, 'product_id' => $product_id, 'order_id' => $order_id));
 		if (!$user) {
 			$user['uid'] = $uid;
 			$user['index'] = 1;
 			$user['product_id'] = $product_id;
+			$user['order_id'] = $order_id;
 			$user['status'] = 2;
 			$user['id'] = Dever::db('survey/user')->insert($user);
 		}
@@ -46,7 +47,7 @@ class Api
 
 		if ($result['info']) {
 			foreach ($result['info'] as $k => $v) {
-				$answer = Dever::db('survey/user_answer')->one(array('info_id' => $v['id'], 'uid' => $uid));
+				$answer = Dever::db('survey/user_answer')->one(array('info_id' => $v['id'], 'uid' => $uid, 'product_id' => $product_id, 'order_id' => $order_id));
 				if ($answer) {
 					$result['info'][$k]['answer'] = $answer['value'];
 				} else {
@@ -65,7 +66,7 @@ class Api
 	 *
 	 * @return mixed
 	 */
-	public function submit($uid, $product_id, $page_number, $survey_id, $survey_answer)
+	public function submit($uid, $product_id, $order_id, $page_number, $survey_id, $survey_answer)
 	{
 		if ($survey_id && $survey_answer) {
 			$survey_id = explode('||', $survey_id);
@@ -87,19 +88,19 @@ class Api
 			foreach ($survey_id as $k => $v) {
 				$info = Dever::db('survey/info')->one($v);
 				if ($info) {
-					$answer = Dever::db('survey/user_answer')->one(array('info_id' => $v, 'uid' => $uid));
+					$answer = Dever::db('survey/user_answer')->one(array('info_id' => $v, 'uid' => $uid, 'product_id' => $product_id, 'order_id' => $order_id));
 
 					if ($answer) {
-						Dever::db('survey/user_answer')->update(array('where_id' => $answer['id'], 'value' => $survey_answer[$k], 'product_id' => $product_id));
+						Dever::db('survey/user_answer')->update(array('where_id' => $answer['id'], 'value' => $survey_answer[$k], 'product_id' => $product_id, 'order_id' => $order_id));
 					} else {
-						Dever::db('survey/user_answer')->insert(array('info_id' => $v, 'uid' => $uid, 'value' => $survey_answer[$k], 'product_id' => $product_id));
+						Dever::db('survey/user_answer')->insert(array('info_id' => $v, 'uid' => $uid, 'value' => $survey_answer[$k], 'product_id' => $product_id, 'order_id' => $order_id));
 						$num++;
 					}
 				}
 			}
 
 			if ($num == $total || $page_number > 0) {
-				$user = Dever::db('survey/user')->one(array('uid' => $uid));
+				$user = Dever::db('survey/user')->one(array('uid' => $uid, 'product_id' => $product_id, 'order_id' => $order_id));
 				if ($user) {
 
 					$user['index'] = $user['index'] + 1;
@@ -119,11 +120,11 @@ class Api
 	 *
 	 * @return mixed
 	 */
-	public function view($uid, $product_id)
+	public function view($uid, $product_id, $order_id)
 	{
 		$product = Dever::config('base', 'project')->product;
 
-		$user = Dever::db('survey/user')->one(array('uid' => $uid));
+		$user = Dever::db('survey/user')->one(array('uid' => $uid, 'product_id' => $product_id, 'order_id' => $order_id));
 
 		$data['userinfo'] = Dever::db('passport/user')->one($uid);
 		$data['product'] = Dever::db($product)->one($product_id);
@@ -140,7 +141,7 @@ class Api
 			}
 			$v['content'] = $this->getContent($v['type'], $v['content']);
 
-			$answer = Dever::db('survey/user_answer')->one(array('uid' => $uid, 'info_id' => $v['id']));
+			$answer = Dever::db('survey/user_answer')->one(array('uid' => $uid, 'info_id' => $v['id'], 'product_id' => $product_id, 'order_id' => $order_id));
 			if ($answer) {
 				if (($v['type'] == 3 || $v['type'] == 4) && strstr($answer['value'], 'http')) {
 					$answer['value'] = $this->getImg($answer['id'], $answer['value']);