示例#1
0
 /**
  * 售后服务申请
  */
 public function newrequest($order_id, $product_id, $action = 'input')
 {
     if ($action == 'save') {
         $mdl_as_request = $this->app_current->model('request');
         $image_upload_arr = array('name' => $_FILES['images']['name'], 'tmp_name' => $_FILES['images']['tmp_name'], 'error' => $_FILES['images']['error'], 'size' => $_FILES['images']['size'], 'type' => $_FILES['images']['type']);
         $ready_upload = array();
         $success_upload_images = array();
         foreach ($image_upload_arr['tmp_name'] as $key => $value) {
             if (!isset($value) || empty($value)) {
                 continue;
             }
             $size = $image_upload_arr['size'][$key];
             $max_conf = $this->app_current->getConf('request_image_size') . 'M';
             $max_size = utils::parse_str_size($max_conf);
             //byte
             if (isset($image_upload_arr['error'][$key]) && !empty($image_upload_arr['error'][$key]) && $image_upload_arr['error'][$key] > 0) {
                 $this->_upload_error($key, '文件上传失败!' . $image_upload_arr['error'][$key]);
             }
             if ($size > $max_size) {
                 $this->_upload_error($key, '文件大小不能超过' . $max_conf);
             }
             list($w, $h, $t) = getimagesize($value);
             if (!in_array($t, array(1, 2, 3, 6))) {
                 //1 = GIF,2 = JPG,3 = PNG,6 = BMP
                 $this->_upload_error($key, '文件类型错误');
             }
             $ready_upload[] = array('tmp' => $value, 'name' => $image_upload_arr['name'][$key]);
         }
         $mdl_image = app::get('image')->model('image');
         foreach ($ready_upload as $k => $item) {
             $image_id = $mdl_image->store($item['tmp'], null, null, $item['name']);
             $success_upload_images[] = array('target_type' => 'asrequest', 'image_id' => $image_id);
             logger::info('前台售后服务图片上传操作' . 'TMP_NAME:' . $item['tmp'] . ',FILE_NAME:' . $item['name']);
         }
         $new_request = array_merge(array('request_id' => $mdl_as_request->apply_id(), 'member_id' => $this->member['member_id'], 'order_id' => $order_id, 'createtime' => time(), 'images' => $success_upload_images, 'product' => array('product_id' => $product_id, 'quantity' => $_POST['product_return_num'])), $_POST['request']);
         $new_request['subject'] = substr(preg_replace('/\\s/', '', $new_request['description']), 0, 100) . '...';
         if ($mdl_as_request->save($new_request)) {
             $this->_send('success', $new_request);
         }
     } else {
         //表单
         $redirect_order = array('app' => 'aftersales', 'ctl' => 'mobile_member', 'act' => 'order');
         if (!$order_id || !$product_id) {
             $this->redirect(array('app' => 'aftersales', 'ctl' => 'mobile_member', 'act' => 'order'));
         }
         $mdl_order = app::get('b2c')->model('orders');
         $order = $mdl_order->dump($order_id, '*', array('items' => array('*')));
         $order_items = $order['items'];
         $order_items = utils::array_change_key($order_items, 'product_id');
         if ($order['member_id'] != $this->member['member_id'] || !isset($order_items[$product_id])) {
             $this->splash('error', $redirect_order, '非法操作!');
         }
         $this->pagedata['order'] = $order;
         $this->pagedata['request_item'] = $order_items[$product_id];
         $goods = app::get('b2c')->model('goods')->getRow('type_id', array('type_id|than' => 0, 'goods_id' => $this->pagedata['request_item']['goods_id']));
         if ($goods) {
             $type_info = app::get('b2c')->model('goods_type')->dump($goods['type_id']);
         }
         $this->pagedata['gtype_assrule'] = $type_info['setting']['assrule'];
         $this->output('aftersales');
     }
 }
示例#2
0
文件: comment.php 项目: noikiy/snk
 public function save($type = 'comment')
 {
     $this->verify_member();
     $this->member = $this->get_current_member();
     $mdl_mcomment = app::get('b2c')->model('member_comment');
     $new_comment_id = $mdl_mcomment->apply_id($type);
     $fipt_idx = -1;
     $max_conf = $this->app->getConf('comment_image_size') . 'M';
     $max_size = utils::parse_str_size($max_conf);
     //byte
     if (!$_POST) {
         $this->end(false, '缺少参数!', 'json_response');
     }
     //新评价
     if ($comment_data = $_POST[$type]) {
         /**
          * $word = array($product_id => $content);.
          */
         foreach ($comment_data['word'] as $goods_id => $word) {
             $product_id = key($word);
             $content = current($word);
             $new_comment = array('comment_id' => $new_comment_id++, 'goods_id' => $goods_id, 'product_id' => $product_id, 'member_id' => $this->member['member_id'], 'order_id' => $_POST['order_id'], 'author_name' => $this->member['uname'], 'createtime' => time(), 'content' => htmlspecialchars($content));
             $new_comment['content'] = preg_replace("/\n/is", '<br>', $new_comment['content']);
             if (empty($new_comment['content']) || trim($new_comment['content']) == '') {
                 continue;
             }
             $new_comment['title'] = substr(preg_replace('/\\s/', '', $new_comment['content']), 0, 100) . '...';
             if ($mark = $comment_data['mark'][$goods_id]) {
                 //评分
                 $new_comment['mark'] = array('mark_star' => floatval($mark), 'goods_id' => $goods_id, 'comment_id' => $new_comment['comment_id']);
             }
             //晒一晒处理
             $image_upload_arr = array('name' => $_FILES[$type]['name'][$product_id], 'tmp_name' => $_FILES[$type]['tmp_name'][$product_id], 'error' => $_FILES[$type]['error'][$product_id], 'size' => $_FILES[$type]['size'][$product_id], 'type' => $_FILES[$type]['type'][$product_id]);
             $ready_upload = array();
             $success_upload_images = array();
             //图片上传验证
             foreach ($image_upload_arr['tmp_name'] as $i => $v) {
                 $fipt_idx++;
                 if (!isset($v) || empty($v)) {
                     continue;
                 }
                 $size = $image_upload_arr['size'][$i];
                 if (isset($image_upload_arr['error'][$i]) && !empty($image_upload_arr['error'][$i]) && $image_upload_arr['error'][$i] > 0) {
                     $this->_upload_error($fipt_idx, '文件上传失败!' . $image_upload_arr['error'][$i]);
                 }
                 if ($size > $max_size) {
                     $this->_upload_error($fipt_idx, '文件大小不能超过' . $max_conf);
                 }
                 list($w, $h, $t) = getimagesize($v);
                 if (!in_array($t, array(1, 2, 3, 6))) {
                     //1 = GIF,2 = JPG,3 = PNG,6 = BMP
                     $this->_upload_error($fipt_idx, '文件类型错误');
                 }
                 $ready_upload[] = array('tmp' => $v, 'name' => $image_upload_arr['name'][$i]);
             }
             $mdl_image = app::get('image')->model('image');
             foreach ($ready_upload as $k => $item) {
                 $image_id = $mdl_image->store($item['tmp'], null, null, $item['name']);
                 //保存图片
                 $mdl_image->rebuild($image_id, array('L', 'XS'));
                 //缩略图片
                 $new_comment['images'][] = array('target_type' => 'comment', 'image_id' => $image_id, 'target_id' => $new_comment['comment_id']);
                 logger::info('前台评价晒一晒图片上传操作' . 'TMP_NAME:' . $item['tmp'] . ',FILE_NAME:' . $item['name']);
             }
             if (!$mdl_mcomment->save($new_comment)) {
                 $this->_send('error', '提交失败!');
             } else {
                 //商品评价计数
                 vmc::singleton('b2c_openapi_goods', false)->counter(array('goods_id' => $goods_id, 'comment_count' => 1, 'comment_count_sign' => md5($goods_id . 'comment_count' . 1 * 1024)));
             }
         }
     }
     //评价追加、回复
     if (isset($_POST['reply']) && !empty($_POST['reply'])) {
         foreach ($_POST['reply'] as $key => $value) {
             $new_reply = array('comment_id' => $new_comment_id++, 'for_comment_id' => $key, 'order_id' => $_POST['order_id'], 'goods_id' => $value['goods_id'], 'product_id' => $value['product_id'], 'member_id' => $this->member['member_id'], 'author_name' => $this->member['uname'], 'createtime' => time(), 'content' => htmlspecialchars($value['content']));
             if (empty($new_reply['content']) || trim($new_reply['content']) == '') {
                 continue;
             }
             $new_reply['title'] = substr(preg_replace('/\\s/', '', $new_reply['content']), 0, 100) . '...';
             if (!$mdl_mcomment->save($new_reply)) {
                 $this->_send('error', '追加评价失败');
             } else {
                 //更新最后回复时间
                 $mdl_mcomment->update(array('lastreply' => time()), array('comment_id' => $key));
                 //商品评价计数
                 vmc::singleton('b2c_openapi_goods', false)->counter(array('goods_id' => $value['goods_id'], 'comment_count' => 1, 'comment_count_sign' => md5($value['goods_id'] . 'comment_count' . 1 * 1024)));
             }
         }
     }
     $this->_send('success', '提交成功');
 }
示例#3
0
 public function save($type = 'comment')
 {
     $this->verify_member();
     $this->member = $this->get_current_member();
     $mdl_mcomment = app::get('b2c')->model('member_comment');
     $new_comment_id = $mdl_mcomment->apply_id($type);
     $redirect = $this->gen_url(array('app' => 'b2c', 'ctl' => 'mobile_comment', 'act' => 'form', 'args' => array($_POST['order_id'])));
     $fipt_idx = -1;
     $max_conf = $this->app->getConf('comment_image_size') . 'M';
     $max_size = utils::parse_str_size($max_conf);
     //byte
     if (!$_POST) {
         $this->splash('error', $redirect, '缺少参数!');
     }
     //新评价
     if ($comment_data = $_POST[$type]) {
         /**
          * $word = array($product_id => $content);.
          */
         foreach ($comment_data['word'] as $goods_id => $word) {
             $product_id = key($word);
             $content = current($word);
             $new_comment = array('comment_id' => $new_comment_id++, 'goods_id' => $goods_id, 'product_id' => $product_id, 'member_id' => $this->member['member_id'], 'order_id' => $_POST['order_id'], 'author_name' => $this->member['uname'], 'createtime' => time(), 'content' => htmlspecialchars($content));
             $new_comment['content'] = preg_replace("/\n/is", '<br>', $new_comment['content']);
             if (empty($new_comment['content']) || trim($new_comment['content']) == '') {
                 continue;
             }
             $new_comment['title'] = substr(preg_replace('/\\s/', '', $new_comment['content']), 0, 100) . '...';
             if ($mark = $comment_data['mark'][$goods_id]) {
                 //评分
                 $new_comment['mark'] = array('mark_star' => floatval($mark), 'goods_id' => $goods_id, 'comment_id' => $new_comment['comment_id']);
             }
             //晒一晒处理
             $image_upload_arr = $comment_data['image'][$product_id];
             //图片上传验证
             foreach ($image_upload_arr as $image_base64) {
                 if (preg_match('/^(data:\\s*image\\/(\\w+);base64,)/', $image_base64, $result)) {
                     $type = $result[2];
                     $ready_tmp_file = tempnam(TMP_DIR, $image_name = 'avatar.' . $type);
                     file_put_contents($ready_tmp_file, base64_decode(str_replace($result[1], '', $image_base64)));
                 } else {
                     continue;
                 }
                 $size = filesize($ready_tmp_file);
                 list($w, $h, $t) = getimagesize($ready_tmp_file);
                 if (!in_array($t, array(1, 2, 3, 6))) {
                     //1 = GIF,2 = JPG,3 = PNG,6 = BMP
                     $this->splash('error', $redirect, '文件上传失败.类型错误');
                 }
                 $ready_upload[] = $ready_tmp_file;
             }
             $mdl_image = app::get('image')->model('image');
             foreach ($ready_upload as $k => $item) {
                 $image_id = $mdl_image->store($item, null, null, $item['name']);
                 //保存图片
                 $new_comment['images'][] = array('target_type' => 'comment', 'image_id' => $image_id, 'target_id' => $new_comment['comment_id']);
                 logger::info('前台评价晒一晒图片上传操作' . 'TMP_NAME:' . $item['tmp'] . ',FILE_NAME:' . $item['name']);
             }
             if (!$mdl_mcomment->save($new_comment)) {
                 $this->splash('error', $redirect, '提交失败');
             } else {
                 //商品评价计数
                 vmc::singleton('b2c_openapi_goods', false)->counter(array('goods_id' => $goods_id, 'comment_count' => 1, 'comment_count_sign' => md5($goods_id . 'comment_count' . 1 * 1024)));
             }
         }
     }
     //评价追加、回复
     if (isset($_POST['reply']) && !empty($_POST['reply'])) {
         foreach ($_POST['reply'] as $key => $value) {
             $new_reply = array('comment_id' => $new_comment_id++, 'for_comment_id' => $key, 'order_id' => $_POST['order_id'], 'goods_id' => $value['goods_id'], 'product_id' => $value['product_id'], 'member_id' => $this->member['member_id'], 'author_name' => $this->member['uname'], 'createtime' => time(), 'content' => htmlspecialchars($value['content']));
             if (empty($new_reply['content']) || trim($new_reply['content']) == '') {
                 continue;
             }
             $new_reply['title'] = substr(preg_replace('/\\s/', '', $new_reply['content']), 0, 100) . '...';
             if (!$mdl_mcomment->save($new_reply)) {
                 $this->splash('error', $redirect, '追加评论失败');
             } else {
                 //更新最后回复时间
                 $mdl_mcomment->update(array('lastreply' => time()), array('comment_id' => $key));
                 //商品评价计数
                 vmc::singleton('b2c_openapi_goods', false)->counter(array('goods_id' => $value['goods_id'], 'comment_count' => 1, 'comment_count_sign' => md5($value['goods_id'] . 'comment_count' . 1 * 1024)));
             }
         }
     }
     $this->splash('success', $redirect, '提交成功!');
 }
示例#4
0
文件: member.php 项目: noikiy/snk
 /**
  * 会员头像
  */
 public function avatar($action = false)
 {
     if ($action == 'upload') {
         $redirect_here = array('app' => 'b2c', 'ctl' => 'mobile_member', 'act' => 'avatar');
         $mdl_image = app::get('image')->model('image');
         $image_name = $_FILES['avatar_file']['name'];
         $ready_tmp_file = $_FILES['avatar_file']['tmp_name'];
         $bt_size = filesize($ready_tmp_file);
         $max_conf = $this->app->getConf('member_avatar_max_size') . 'M';
         $max_size = utils::parse_str_size($max_conf);
         //byte
         if ($_FILES['avatar_file']['error']) {
             $this->splash('error', $redirect_here, '头像上传失败!' . $_FILES['avatar_file']['error']);
         }
         if ($bt_size > $max_size) {
             $this->splash('error', $redirect_here, '头像文件大小不能超过' . $max_conf);
         }
         list($w, $h, $t) = getimagesize($ready_tmp_file);
         if (!in_array($t, array(1, 2, 3, 6))) {
             //1 = GIF,2 = JPG,3 = PNG,6 = BMP
             $this->splash('error', $redirect_here, '文件类型错误');
         }
         $image_id = $mdl_image->store($_FILES['avatar_file']['tmp_name'], $this->member['avatar'], null, $image_name);
         logger::info('前台会员头像上传操作' . 'TMP_NAME:' . $_FILES['avatar_file']['tmp_name'] . ',FILE_NAME:' . $image_name);
         if (!$image_id) {
             $this->splash('error', $redirect_here, '头像上传失败!');
         }
         $mdl_image->rebuild($image_id, array('S', 'XS'));
         if ($this->app->model('members')->update(array('avatar' => $image_id), array('member_id' => $this->member['member_id']))) {
             $this->splash('success', $redirect_here, '上传并保存成功!');
         } else {
             $this->splash('error', $redirect_here, '保存失败!');
         }
     }
     $system_max = get_cfg_var("upload_max_filesize");
     $conf_max = $this->app->getConf('member_avatar_max_size') . 'M';
     if (utils::parse_str_size($conf_max) > utils::parse_str_size($system_max)) {
         $this->pagedata['upload_max'] = $system_max;
     } else {
         $this->pagedata['upload_max'] = $conf_max;
     }
     $this->output();
 }
示例#5
0
 /**
  * 会员头像.
  */
 public function avatar($action = false)
 {
     $this->title = '设置头像';
     if ($action == 'upload') {
         $redirect_here = array('app' => 'b2c', 'ctl' => 'mobile_member', 'act' => 'avatar');
         $mdl_image = app::get('image')->model('image');
         $image_base64 = $_POST['avatar_file_base64'];
         if (preg_match('/^(data:\\s*image\\/(\\w+);base64,)/', $image_base64, $result)) {
             $type = $result[2];
             $ready_tmp_file = tempnam(TMP_DIR, $image_name = 'avatar.' . $type);
             file_put_contents($ready_tmp_file, base64_decode(str_replace($result[1], '', $image_base64)));
         }
         $bt_size = filesize($ready_tmp_file);
         $max_conf = $this->app->getConf('member_avatar_max_size') . 'M';
         $max_size = utils::parse_str_size($max_conf);
         //byte
         if ($bt_size > $max_size) {
             $this->splash('error', $redirect_here, '头像文件大小不能超过' . $max_conf);
         }
         list($w, $h, $t) = getimagesize($ready_tmp_file);
         if (!in_array($t, array(1, 2, 3, 6))) {
             //1 = GIF,2 = JPG,3 = PNG,6 = BMP
             $this->splash('error', $redirect_here, '文件类型错误');
         }
         $image_id = $mdl_image->store($ready_tmp_file, $this->member['avatar'], null, $image_name);
         if ($ready_tmp_file) {
             @unlink($ready_tmp_file);
         }
         logger::info('前台会员头像上传操作' . 'TMP_NAME:' . $_FILES['avatar_file']['tmp_name'] . ',FILE_NAME:' . $image_name);
         if (!$image_id) {
             $this->splash('error', $redirect_here, '头像上传失败!');
         }
         if ($this->app->model('members')->update(array('avatar' => $image_id), array('member_id' => $this->member['member_id']))) {
             $this->splash('success', $redirect_here, '上传并保存成功!');
         } else {
             $this->splash('error', $redirect_here, '保存失败!');
         }
     }
     $system_max = get_cfg_var('upload_max_filesize');
     $conf_max = $this->app->getConf('member_avatar_max_size') . 'M';
     if (utils::parse_str_size($conf_max) > utils::parse_str_size($system_max)) {
         $this->pagedata['upload_max'] = $system_max;
     } else {
         $this->pagedata['upload_max'] = $conf_max;
     }
     $this->output();
 }