|
@@ -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']);
|