get_all("select * from tb_jtj_houqing where status = 1 order by id"); foreach($list as $key => $item) { $list[$key]['pic'] = "https://yzms.fsecity.com".$item['pic']; $pjInfo = $db->get_one("select score,content,addtime from tb_jtj_houqing_pj where uid = '{$uid}' and hid = '".$item['id']."' and date = '".date("Y-m-d")."'"); if(!$pjInfo) $pjInfo = null; $list[$key]['pjInfo'] = $pjInfo; } $data = array( 'list' => $list, 'pjDate' => date("Y-m-d"), ); echoRs(1, 'ok', array('data' => $data)); exit; } if($act == 'jtj_houqing_pj') { $user = check_token(); $uid = $user['id']; $hid = intval($_POST['hid']); $score = intval($_POST['score']); $content = trim($_POST['content']); //$hid = 2; //$score = 3; //$content = '测试'; if(!$hid) { echoRs(0, '参数不完整!'); } if($score <= 0 || $score > 5) { echoRs(0, '分数范围只能为1-5'); } $hInfo = $db->get_one("select * from tb_jtj_houqing where id=".$hid); if(!$hInfo) { echoRs(0, '后勤人员不存在!'); } $date = date("Y-m-d"); $row = $db->get_one("select * from tb_jtj_houqing_pj where uid = {$uid} and hid = {$hid} and `date` = '{$date}'"); if($row) { echoRs(0, '您今天已评价过该后勤人员,无需重复提交!'); } $db->query("insert into tb_jtj_houqing_pj set uid = '{$uid}', hid = '{$hid}', `date` = '{$date}', score = '{$score}', content = '{$content}', addtime = now()"); $rid = $db->insert_id(); $row = $db->get_one("select * from tb_jtj_excitation_config where name = 'LOGISTICS_VOTE'"); if($row) { // 判断今天是否已经操作了 菜品投票 $check_dish_vote = $db->get_one("select * from tb_jtj_excitation_log where type='5' and user_id='{$uid}' and to_days(addtime)=to_days(now())"); $excitation_jf = $check_dish_vote ? 0 : $row['value']; $db->query("insert into tb_jtj_excitation_log set type = '5', user_id = '{$uid}', order_id = '{$rid}', jf = '{$excitation_jf}', addtime = now()"); if($check_dish_vote){ // 今天又同类型操作,不再激励 echoRs(1, '提交成功!今天已有同类操作,本次不再获得激励积分'); exit; } $info = array( 'admin_id' => '5', 'rtype' => '1', 'ac_type' => '3', 'oid' => $rid, ); gpay_add_user_account_uid($uid, $row['value'], $info); } echoRs(1, '提交成功!'); exit; } function jtj_savePic($base64) { if(!$base64) return ''; if(stristr($base64, 'image/jpeg')) $ext = 'jpg'; else $ext = 'png'; $base64 = str_ireplace("data:image/jpeg;base64,", '', $base64); $base64 = str_ireplace("data:image/png;base64,", '', $base64); $data = @base64_decode(stripslashes($base64)); if(!$data) return false; $img = @imagecreatefromstring($data); if(!$img) return false; imagedestroy($img); $d = date("Ymd"); $dir = "upload/{$d}"; if(!is_dir($dir)) mkdir($dir); $path = $dir."/".md5(time()."_".rand()).".".$ext; file_put_contents($path, $data); //file_put_contents($path.".base64", $base64); if(file_exists($path)) { return $path; } return false; } if($act == 'jtj_submit_guangpan') { $user = check_token(); $uid = $user['id']; $oid = intval($_POST['oid']); $pic1 = trim($_POST['pic1']); $pic2 = trim($_POST['pic2']); $pic3 = trim($_POST['pic3']); $pic4 = trim($_POST['pic4']); $pic5 = trim($_POST['pic5']); /*$oid = 410506; $pic1 = "data:image/jpeg;base64,".base64_encode(file_get_contents("1.jpg")); $pic3 = "data:image/jpeg;base64,".base64_encode(file_get_contents("2.jpg"));*/ if($oid <= 0) { echoRs(0, '参数不完整!'); } if(!$pic1 && !$pic2 && !$pic3) { echoRs(0, '至少上传一张照片!'); } $oInfo = $db->get_one("select * from tb_order where uid = '{$uid}' and state_id in (3,6) and id =".$oid); if(!$oInfo) { echoRs(0, '订单不存在!'); } // 判断只能当前上传 if(date('Y-m-d', strtotime($oInfo['take_food_time'])) != date('Y-m-d')){ echoRs(0, '该订单只能当天上传光盘照片!'); } $row = $db->get_one("select * from tb_jtj_guangpan where oid = {$oid}"); if($row) { echoRs(0, '该订单已上传过光盘照片!无需重复上传!'); } $pics = ''; for($i = 1; $i <= 5; $i++) { $bl = "pic".$i; if(!$$bl) continue; $path = jtj_savePic($$bl); if(!$path) { echoRs(0, "上传照片{$i}失败!"); } if($pics != '') $pics .= ","; $pics .= $path; } $db->query("insert into tb_jtj_guangpan set oid = '{$oid}', uid = '{$uid}', pics = '{$pics}', status = '0', addtime = now()"); echoRs(1, '提交成功!'); exit; } if($act == 'jtj_get_pj') { $user = check_token(); $uid = $user['id']; $statusInfo = array( '0' => '待审核', '1' => '审核通过', '2' => '审核不通过', ); $oid = intval($_GET['oid']); if(!$oid) { echoRs(0, '参数不完整!'); } $guangpanInfo = null; $row = $db->get_one("select pics, addtime, status from tb_jtj_guangpan where uid = {$uid} and oid={$oid}"); if($row) { $row['statusName'] = $statusInfo[$row['status']]; $pics = $row['pics']; $a = array(); $a2 = explode(",", $pics); foreach($a2 as $path) { $a[] = "https://yzms.fsecity.com/show/".$path; } $row['pics'] = $a; $guangpanInfo = $row; } $pjInfo = null; $row = $db->get_one("select score, content, addtime from tb_jtj_order_pj where uid = {$uid} and oid = {$oid}"); if($row) $pjInfo = $row; $data = array( 'guangpanInfo' => $guangpanInfo, 'pjInfo' => $pjInfo, ); echoRs(1, 'ok', array('data' => $data)); } if($act == 'jtj_order_pj') { $user = check_token(); $uid = $user['id']; $oid = intval($_POST['oid']); $score = intval($_POST['score']); $content = trim($_POST['content']); /*$oid = 410506; $score = 3; $content = '测试';*/ if(!$oid) { echoRs(0, '参数不完整!'); } if($score <= 0 || $score > 5) { echoRs(0, '分数范围只能为1-5'); } $oInfo = $db->get_one("select * from tb_order where uid = '{$uid}' and state_id in (3,6) and id =".$oid); if(!$oInfo) { echoRs(0, '订单不存在!'); } // 判断只能当前上传 if(date('Y-m-d', strtotime($oInfo['take_food_time'])) != date('Y-m-d')){ echoRs(0, '该订单只能当天评价!'); } $row = $db->get_one("select * from tb_jtj_order_pj where uid = {$uid} and oid = {$oid}"); if($row) { echoRs(0, '您今天已评价过该订单,无需重复提交!'); } $db->query("insert into tb_jtj_order_pj set uid = '{$uid}', oid = '{$oid}', score = '{$score}', content = '{$content}', addtime = now()"); $rid = $db->insert_id(); $row = $db->get_one("select * from tb_jtj_excitation_config where name = 'DISH_VOTE'"); if($row) { // 判断今天是否已经操作了 菜品投票 $check_dish_vote = $db->get_one("select * from tb_jtj_excitation_log where type='2' and user_id='{$uid}' and to_days(addtime)=to_days(now())"); // 记录 $excitation_jf = $check_dish_vote ? 0 : $row['value']; $db->query("insert into tb_jtj_excitation_log set type = '2', user_id = '{$uid}', order_id = '{$oid}', jf = '{$excitation_jf}', addtime = now()"); if($check_dish_vote){ // 今天又同类型操作,不再激励 echoRs(1, '提交成功!今天已有同类操作,本次不再获得激励积分'); exit; } $info = array( 'rtype' => '1', 'ac_type' => '3', 'admin_id' => '2', 'oid' => $rid, ); gpay_add_user_account_uid($uid, $row['value'], $info); } echoRs(1, '提交成功!'); exit; } if($act == 'jtj_get_qc_id'){ // 获取用户最新一次取餐订单id $user = check_token(); $uid = $user['id']; $oInfo = $db->get_one("SELECT a.* FROM `tb_order` a left join tb_jtj_order_pj b on a.id=b.oid where a.uid='{$uid}' and a.state_id=3 and to_days(date_format(take_food_time,'%Y-%m-%d')) = to_days(now()) and b.id is null GROUP BY a.id order by take_food_time desc"); if(empty($oInfo)) { echoRs(0, '今天内,没有可评价订单!'); } echoRs(1, '获取成功!', array( 'data' => array('oid' => $oInfo['id']) )); }