decode($link); if ($video) { Dever::db('service/video')->update(array('where_id' => $id, 'video' => $video)); } } public function showOrderStatus($id) { $info = Dever::db('service/order')->one($id); if ($info) { if ($info['status'] == 1) { #return '*已支付'; return '待支付'; } elseif ($info['status'] == 2) { return '已支付'; } elseif ($info['status'] == 3) { return '支付失败'; } elseif ($info['status'] == 5) { $table['状态'] = '已退款'; $manage = Dever::db('manage/admin')->one($info['tk_admin']); $table['备注'] = $info['tk_desc']; $table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']); $table['操作人'] = $manage['username']; return Dever::table($table); } } } /** * 得到订单时间 * * @return mixed */ public function showOrderTime($id) { $info = Dever::db('service/order')->one($id); if ($info) { $table = array(); $update = array(); $table['订单创建时间'] = date("Y-m-d H:i:s", $info['cdate']); if (!$info['survey_date']) { $user = Dever::db('survey/user_answer')->getOldOne(array('order_id' => $id)); if ($user) { $table['填写问卷时间'] = date("Y-m-d H:i:s", $user['cdate']); $update['survey_date'] = $user['cdate']; } } else { $table['填写问卷时间'] = date("Y-m-d H:i:s", $info['survey_date']); } if ($info['feedback_status'] >= 3) { if (!$info['survey_end_date']) { $user = Dever::db('survey/user_answer')->getNewOne(array('order_id' => $id)); if ($user) { $table['问卷提交时间'] = date("Y-m-d H:i:s", $user['cdate']); $update['survey_end_date'] = $user['cdate']; } } else { $table['问卷提交时间'] = date("Y-m-d H:i:s", $info['survey_end_date']); } } if ($info['feedback_status'] == 4) { if (!$info['feedback_date']) { /* $feedback = Dever::db('service/feedback')->one(array('order_id' => $id)); if ($feedback) { $table['反馈问卷时间'] = date("Y-m-d H:i:s", $feedback['cdate']); $update['feedback_date'] = $feedback['cdate']; } */ } else { $table['反馈问卷时间'] = date("Y-m-d H:i:s", $info['feedback_date']); } } if ($update) { $update['where_id'] = $id; Dever::db('service/order')->update($update); } return Dever::table($table); } return ''; } # 显示反馈方案的状态 public function showFeedbackStatus($id) { $info = Dever::db('service/order')->one($id); $html = ''; if ($info) { $config = Dever::db('service/order')->config['feedback_status']; if (isset($config[$info['feedback_status']])) { $html = $config[$info['feedback_status']]; } $info = Dever::db('service/feedback')->one(array('order_id' => $id)); if ($info && $info['pdf']) { $html .= '
[查看软装服务设计方案]'; } } return $html; } /** * 设计反馈之后,发送短信 (已废弃) * * @return mixed */ public function order($id, $name, $data) { # 更改退款状态 $status = Dever::param('status', $data); $tk_desc = Dever::param('tk_desc', $data); if ($tk_desc && $tk_desc != 'null') { $admin = Dever::load('manage/auth.info'); $update['where_id'] = $id; $update['tk_admin'] = $admin['id']; $update['tk_time'] = time(); $update['status'] = 5; Dever::db('service/order')->update($update); } else { $update['where_id'] = $id; $update['status'] = 2; Dever::db('service/order')->update($update); } /* if ($feedback_status == 2) { $order = Dever::db('service/order')->one($id); $user = Dever::db('passport/user')->one($order['id']); if ($user['mobile'] && $order['order_id']) { Dever::load('passport/applet')->send($user['mobile'], $order['order_id']); } } */ } /** * 完成反馈,发送短信 已废弃 * * @return mixed * public function feedback($id, $name, $data) { $order_id = Dever::param('order_id', $data); $info = Dever::db('service/feedback')->one($id); $order = Dever::db('service/order')->one($order_id); $status = Dever::param('status', $data); if ($status == 1) { if ($order && $order['feedback_status'] == 3) { Dever::db('service/order')->update(array('where_id' => $order_id, 'feedback_status' => 4)); $user = Dever::db('passport/user')->one($order['uid']); if ($user['mobile'] && $order['order_id']) { $skin = 'order'; # 判断是否二次修改 $sms = Dever::param('sms', $data); if ($sms == 2) { $skin = 'feedback'; } Dever::setInput('skin', $skin); Dever::load('passport/applet')->send($user['mobile'], $order['order_id']); } } } else { if ($order) { Dever::db('service/order')->update(array('where_id' => $order_id, 'feedback_status' => 3)); } } # 生成产品的链接 //Dever::daemon('spider/handle.createProduct?id=' . $id, 'service'); //Dever::load('service/spider/handle.createProduct?id=' . $id); } */ public function showQuestion($uid, $product_id, $order_id, $feedback_status) { $link = Dever::url('api.view&uid='.$uid.'&product_id=' . $product_id . '&order_id=' . $order_id, 'survey'); if ($feedback_status == 1) { $html = ''; } else { $html = '查看'; } return $html; } public function showOrderUser($id) { $info = Dever::db('service/order')->one($id); $table = array(); $user = Dever::db('passport/user')->one($info['uid']); $table['订单号'] = $info['order_id']; $table['用户名'] = $user['username']; $table['手机号'] = $user['mobile']; $table['产品名'] = $info['name']; if ($info['type'] == 1) { $table['支付方式'] = '购买'; $table['支付金额'] = $info['cash']; } else { $table['支付方式'] = '兑换'; $table['兑换码'] = $info['code']; } $feedback = Dever::db('service/feedback')->one(array('order_id' => $id)); if($feedback && $feedback['num']) { $table['用户评分'] = $feedback['num']; if ($feedback['msg']) { $table['用户建议'] = $feedback['msg']; } } return Dever::table($table); } /** * 导出成excel * * @return mixed */ public function out_api() { $product = Dever::db('service/product')->state(); $header = array(); foreach ($product as $k => $v) { $product[$k]['answer'] = array(); $product[$k]['data'] = array(); $product[$k]['header'] = array(); $product[$k]['header'][0] = '订单号'; $product[$k]['question'] = array ( 0 => array ( 'id' => 0, 'name' => $product[$k]['header'][0], ), ); $product[$k]['question'] += Dever::db('survey/info')->getData(array('product_id' => $v['id'])); if ($product[$k]['question']) { foreach ($product[$k]['question'] as $k1 => $v1) { if (isset($v1['type'])) { if ($v1['type'] == 12 || $v1['type'] == 13) { $product[$k]['question'][$k1]['content'] = Dever::array_decode($v1['content']); } else { $product[$k]['question'][$k1]['content'] = array(); } } $product[$k]['header'][$k1] = $v1['name']; } } $tjr = -10000; $product[$k]['header'][$tjr] = '提交人'; $product[$k]['question'][$tjr] = array ( 'id' => $tjr, 'name' => $product[$k]['header'][$tjr], ); $tjsj = $tjr + 1; $product[$k]['header'][$tjsj] = '提交时间'; $product[$k]['question'][$tjsj] = array ( 'id' => $tjsj, 'name' => $product[$k]['header'][$tjsj] ); $where['product_id'] = $v['id']; $where['feedback_status'] = 3; $product[$k]['order'] = Dever::db('service/order')->getYes($where); if ($product[$k]['order']) { foreach ($product[$k]['order'] as $k1 => $v1) { $user = Dever::db('passport/user')->one($v1['uid']); $answer = Dever::db('survey/user_answer')->getData(array('uid' => $v1['uid'], 'product_id' => $v['id'], 'order_id' => $v1['id'])); if ($answer) { $product[$k]['answer'][$k1][0] = $v1['order_id'] ? $v1['order_id'] : $v1['id']; $product[$k]['order'][$k1]['answer'][0] = $product[$k]['answer'][$k1][0]; $time = ''; foreach ($answer as $k2 => $v2) { $product[$k]['answer'][$k1][$v2['info_id']] = $v2['value']; if (isset($product[$k]['question'][$v2['info_id']]['content']) && $product[$k]['question'][$v2['info_id']]['content']) { $temp = explode(',', $v2['value']); $vvn = array(); $vvp = array(); foreach ($temp as $k3 => $v3) { $d3 = ''; if (strstr($v3, '$$$')) { $t11 = explode('$$$', $v3); $v3 = $t11[0]; $d3 = $t11[1]; } $v3 = $v3-1; if (isset($product[$k]['question'][$v2['info_id']]['content'][$v3])) { $t1 = $product[$k]['question'][$v2['info_id']]['content'][$v3]; if (isset($t1['desc']) && $t1['desc']) { $t1['title'] .= '('.$t1['desc'].')'; } $vvn[$k3] = $t1['title']; if (isset($t1['pic']) && $t1['pic']) { $vvp[$k3] = $t1['pic']; } if ($d3) { $vvn[$k3] .= ':' . $d3; } } } $product[$k]['answer'][$k1][$v2['info_id']] = implode("\r\n", $vvn); if ($vvp) { $product[$k]['answer'][$k1][$v2['info_id']] .= '||' . implode(',', $vvp); } } $product[$k]['order'][$k1]['answer'][$v2['info_id']] = $product[$k]['answer'][$k1][$v2['info_id']]; $time = date('Y-m-d H:i', $v2['cdate']); } $product[$k]['answer'][$k1][$tjr] = $user['username']; $product[$k]['order'][$k1]['answer'][$tjr] = $product[$k]['answer'][$k1][$tjr]; $product[$k]['answer'][$k1][$tjsj] = $time; $product[$k]['order'][$k1]['answer'][$tjsj] = $product[$k]['answer'][$k1][$tjsj]; foreach ($product[$k]['header'] as $k4 => $v4) { if (isset($product[$k]['answer'][$k1][$k4])) { $product[$k]['data'][$k1][$k4] = $product[$k]['answer'][$k1][$k4]; } else { $product[$k]['data'][$k1][$k4] = ''; } } } } } } $time = date('Y-m-d H:i'); $name = '订单列表'; $file = $time . '_' . $name; $test = Dever::input('test'); $sheet = 0; $xls = true; if ($test == 1) { print_r($product);die; } // foreach ($product as $k => $v) { $header = $v['header']; $data = $v['data']; $sheetName = $v['name']; $xls = Dever::excelExport($data, $header, $file, $sheet, $sheetName, $xls); $sheet++; } Dever::excelExport(false, false, $file, 0, false, $xls); die; if (!$test) { ob_get_clean(); ob_start(); $data = Dever::render('excel', array('product' => $product)); echo $data; header('Content-Disposition: attachment; filename='.$file . '.xls'); header('Accept-Ranges:bytes'); header('Content-Length:' . ob_get_length()); header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); ob_end_flush(); die; } if ($test == 1) { return Dever::render('excel', array('product' => $product)); } elseif ($test == 2) { print_r($product);die; } return; $where['feedback_status'] = 3; $order = Dever::db('service/order')->getYes($where); $i = 0; foreach ($order as $k => $v) { if ($v && $v['uid']) { $product = Dever::db('service/product')->one($v['product_id']); $user = Dever::db('passport/user')->one($v['uid']); $v['content'] = $this->question(Dever::load('survey/api.view', $v['uid'], $v['product_id'], $v['id'], true)); if ($v['type'] == 1) { $v['status'] = '已购买'; } else { $v['status'] = '已兑换'; $v['cash'] = $v['code']; } $data[$i] = array ( $v['order_id'], $product['name'], $user['username'], $user['mobile'], $v['status'], $v['cash'], $v['content'], ); $i++; } } $header = array ( '订单号', '产品名', '用户名', '用户手机号', '支付状态', '支付金额/兑换码', '问卷内容' ); $time = date('Y-m-d H:i'); $name = '订单列表'; $file = $time . '_' . $name; $test = Dever::input('test'); if (!$test) { header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="'.$file.'.xls"'); header('Cache-Control: max-age=0'); } if ($test == 1) { return Dever::render('excel', array('header' => $header, 'data' => $data)); } elseif ($test == 2) { print_r($header); print_r($data);die; } //Dever::excelExport($data, $header, $file, $sheet = 0, $sheetName = $name); return; } private function question($data) { $html = array(); if (isset($data['question'])) { foreach ($data['question'] as $k => $v) { $html[$k] = '第' . $k . '题' . '、'. $v['name']; if (isset($v['content']) && $v['content']) { if (is_numeric($v['answer']) && $v['answer'] != '未作答') { $temp = explode(',', $v['answer']); $html[$k] .= "
" . '答:'; $j = 0; foreach ($temp as $k1 => $v1) { $v1 = $v1 - 1; if ($j > 0) { $html[$k] .= '、'; } if (isset($v['content'][$v1]) && $v['content'][$v1]) { $html[$k] .= $v['content'][$v1]['title']; if (isset($v['content'][$v1]['desc']) && $v['content'][$v1]['desc']) { $html[$k] .= '(' . $v['content'][$v1]['desc'] . ')'; } $j++; } } } } else { $html[$k] .= "
" . '答:' . $v['answer']; } } $html = implode("
", $html); } return $html; } # 发送方案 并发送短信 public function sendFeedback_api() { $id = Dever::input('id'); $order = Dever::db('service/order')->one($id); if ($order) { $info = Dever::db('service/feedback')->one(array('order_id' => $id)); $status = 1; if ($status == 1) { if ($order['feedback_status'] == 3) { Dever::db('service/order')->update(array('where_id' => $id, 'feedback_status' => 4, 'feedback_date' => time())); $user = Dever::db('passport/user')->one($order['uid']); if ($user['mobile'] && $order['order_id']) { $skin = 'order'; Dever::setInput('skin', $skin); Dever::load('passport/applet')->send($user['mobile'], $order['order_id']); } } } else { if ($order) { Dever::db('service/order')->update(array('where_id' => $order_id, 'feedback_status' => 3)); } } } Dever::alert('发送成功'); } # 发送短信 public function sendFeedbackSms_api() { $id = Dever::input('id'); $order = Dever::db('service/order')->one($id); if ($order && $order['feedback_status'] == 4) { $user = Dever::db('passport/user')->one($order['uid']); if ($user['mobile'] && $order['order_id']) { $skin = 'feedback'; Dever::setInput('skin', $skin); Dever::load('passport/applet')->send($user['mobile'], $order['order_id']); } } Dever::alert('发送成功'); } }