/** * 评论 */ public function index(){ $model = M('Feedback'); $data = $this->_search(); $data['product_id'] = $_GET['product_id']; $count = $model->where($data)->count(); $page_size = $_REQUEST ['page_size'] ? $_REQUEST ['page_size'] : C('page_size'); //$page_size = 1; $page_count = ceil($count/$page_size); $pageno = $_REQUEST['p'] ? $_REQUEST['p'] : 1; $offset = ($pageno - 1) * $page_size; $list = $model->where($data)->limit($offset. ',' . $page_size)->order('id desc')->select(); foreach($list as $key=>$val){ $list[$key]['create_time'] = date('Y-m-d H:i:s',$val['create_time']); $list[$key]['grade'] = ceil($val['grade']); } if(IS_AJAX){ $msg['feedback_list'] = $list; ajaxSucReturn($msg); } $this->assign('list',$list); $this->assign('page_count',$page_count); $this->assign('headerTitle','商品评价'); $this->assign('headerKeywords','商品评价'); $this->assign('headerDescription','商品评价'); $this->assign('wx_title','商品评价'); $this->assign('wx_desc','微信分享'); $this->display(); }
/** * 删除收藏 */ public function delete(){ $model = D('Collect'); $data['id'] = $_POST['id']; $vo = $model->field('id,source,sourceid')->where($data)->find(); $data['member_id'] = $this->user['id']; $result = $model->where($data)->delete(); if($result){ $msg['error_code'] = 0; $msg['notice'] = '删除成功'; if($vo['source']=='Product'){ update_product('collect_num',2,$vo['sourceid']); } ajaxSucReturn($msg); }else{ ajaxErrReturn('删除失败'); } }
/** * 删除地域 */ public function ajax_del() { $id = intval($_POST['id']); if ($id > 0) { if (!$this->has_child($id)) { $this->db->where('id=' . $id)->delete(); //$this->db->build_cache(); $msg['callback'] = "remove('row_" . $id . "');"; $msg['notice'] = '恭喜你,删除区域成功!'; ajaxSucReturn($msg); } else { ajaxErrReturn('请先删除子地区!'); } } else { ajaxErrReturn('非法操作,请联系管理员!'); } }
/** * 添加或编辑商品时:新增属性 */ public function add_spec_value() { $model = M('Attr_val'); $data = array(); $data['attr_id'] = (int) $_POST['spec_id']; $new_value = str_replace(',', ',', trim($_POST['new_value'])); $values = explode(',', $new_value); if (empty($new_value)) { ajaxErrReturn('请填写要添加的属性值'); } if ($_POST['spec_id'] < 1) { ajaxErrReturn('该规格不存在或规格ID有误'); } foreach ($values as $val) { $data['attr_value'] = $val; $result = $model->add($data); } if ($result) { $msg['notice'] = '规则添加成功'; ajaxSucReturn($msg); } else { $this->ajaxErrReturn('新增属性失败'); } }
/** +---------------------------------------------------------- * 增加组操作权限 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return void +---------------------------------------------------------- * @throws FcsException +---------------------------------------------------------- */ public function setUser() { $id = $_POST['groupUserId']; $groupId = $_POST['groupId']; $group = D("Role"); $group->delGroupUser($groupId); $result = $group->setGroupUsers($groupId, $id); if ($result === false) { ajaxErrReturn('授权失败!'); } else { ajaxSucReturn('授权成功!'); } }
/** * 删除物流配置信息 */ public function ajax_del_sr() { $data['id'] = $_POST['id']; $vo = $this->srdb->where($data)->find(); $this->up_shipping_region($vo['shipping_id']); $result = $this->srdb->where($data)->delete(); if ($result) { $this->history($_POST['id'], 'delete', 'Shipping_region'); ajaxSucReturn('删除成功!'); } else { ajaxErrReturn('删除失败!'); } }
/** * 删除属性值 */ public function ajax_del_val() { $model = M('Attr_val'); $data['id'] = $_POST['id']; $result = $model->where($data)->delete(); if ($result) { ajaxSucReturn('删除成功!'); } else { ajaxErrReturn('删除失败!'); } }
/** * 列表页 */ function get_more_msg(){ $model = M(CONTROLLER_NAME); $page_size = $_REQUEST ['page_size'] ? $_REQUEST ['page_size'] : C('page_size'); $pageno = $_POST['p'] ? $_POST['p'] : 1; $offset = ($pageno - 1) * $page_size; $list = $model->where($data)->order('id desc')->limit($offset.','.$page_size)->select(); foreach($list as $key=>$val){ if($val['content'])$list[$key]['content'] = str_cut(htmlspecialchars_decode($val['content']),45); } ajaxSucReturn($list); }
/** * 注册短信 */ public function reg_sms(){ $tel = $_POST['mobile']; $type = $_POST['type'] ? $_POST['type'] : 'reg'; if(!validateMobile($tel)){ $msg['notice'] = '手机号码不对!'; ajaxErrReturn($msg); } $code = str_pad(rand(0,9999),4,0,STR_PAD_LEFT); $content = '验证码:'.$code.',请勿将验证码泄漏给其他人'; $model = M('Member_verify'); $data['mobile'] = $tel; $data['type'] = $type; $v_vo = $model->where($data)->find(); if($v_vo['status']==1){ $msg['notice'] = '短信已验证'; ajaxErrReturn($msg); } if($v_vo){ if(time()-$v_vo['update']<60){ $msg['notice'] = '请稍后再发'; ajaxSucReturn($msg); }else{ if($v_vo['m']==date('m') && $v_vo['d']==date('d')){ if($v_vo['sent_num']>4){ $msg['notice'] = '每天最多发送5次,请明天再来'; ajaxErrReturn($msg); } $sdata['sent_num'] = $v_vo['sent_num']+1; //今天+1 }else{ $sdata['sent_num'] = 1; //其他重新统计 } $sdata['y'] = date('Y'); $sdata['m'] = date('m'); $sdata['d'] = date('d'); $sdata['code'] = $code; $sdata['tel'] = $tel; $sdata['msg'] = $content; $sdata['status'] = 0; $sdata['update_time'] = time(); $model->where($data)->save($sdata); //echo $model->getlastsql();exit; } }else{ $sdata['member_id'] = $this->user['id'] ? $this->user['id'] : 0; $sdata['code'] = $code; $sdata['type'] = $type; $sdata['mobile'] = $tel; $sdata['y'] = date('Y'); $sdata['m'] = date('m'); $sdata['d'] = date('d'); $sdata['sent_num'] = 1; $sdata['msg'] = $content; $sdata['status'] = 0; $sdata['ip'] = _get_ip(); $sdata['update_time'] = time(); $v_vo['id'] = $model->add($sdata); } $result = sent_msm($tel,$content); $result = true; if($result){ $msg['notice'] = '发送成功'; ajaxSucReturn($msg); }else{ $msg['notice'] = '发送失败'; ajaxErrReturn($msg); } }
/** * 手机绑定 */ public function bindingmb(){ if(IS_POST){ if($this->user['mobile']){ ajaxErrReturn('手机已绑定'); } $mv_model = M('Member_verify'); $mv_data['mobile'] = $_POST['mobile']; $mv_data['type'] = 'bdmb'; $mv = $mv_model->where($mv_data)->find(); if(!$mv){ ajaxErrReturn('短信未发送,请重试'); } if($mv['status']==1){ ajaxErrReturn('短信验证码已使用'); } if($mv['verify_num']>10){ ajaxErrReturn('短信验证码已失效'); } $model = M('Member'); $wdata['id'] = $this->user['id']; $salt = $this->user['salt']; $sdata['mobile'] = $_POST['mobile']; //判断手机号码是否存在 $count = $model->where($sdata)->count(); if($count>0){ ajaxErrReturn('手机号码已被注册'); } $sdata['password'] = md5($_POST['password'].$salt.$salt[1]); $result = $model->where($wdata)->save($sdata); if($result){ $mv_sdata['status'] = 1; $mv_model->where($mv_data)->save($mv_sdata);//验证码失效 $msg['notice'] = '绑定成功'; $msg['gourl'] = $_SESSION['self_url']; ajaxSucReturn($msg); }else{ ajaxErrReturn('绑定失败'); } } $_SESSION['self_url'] = $_GET['redirectURL'] ? $_GET['redirectURL'] : __APP__.'/Member'; //dump($_SESSION['self_url']); $this->assign('headerTitle','绑定手机'); $this->assign('headerKeywords','绑定手机'); $this->assign('headerDescription','绑定手机'); $this->assign('wx_title','绑定手机'); $this->assign('wx_desc','微信分享'); $this->display(); }
/** * 确认退款 */ public function return_refund() { $id = $_POST['id']; $data2['id'] = $data['a.id'] = $id; $vo = $this->db->table('`' . C('DB_PREFIX') . 'order_detail` as a')->join('`' . C('DB_PREFIX') . 'order` as b on a.order_id=b.id')->field('a.id,a.product_name,a.price,a.num,a.order_id,a.status,a.refund_status,b.payment_mode,payment_company,b.delivery_status,b.order_sn,b.member_id,b.member_name')->where($data)->find(); $result = $this->db->validate($vo); $this->db->startTrans(); //启用事务 if (!$result) { ajaxErrReturn($this->db->get_error_msg()); } $sdata['refund_status'] = 5; $result = $this->oddb->where($data2)->save($sdata); if ($result) { //记录退款金额 $o_data['id'] = $vo['order_id']; //$refund_fee = $vo['price']*$vo['num']; $refund_fee = $this->refund_fee($vo); $result = $this->db->where($o_data)->setDec('actual_refund', $refund_fee); //退款信息记录 $model = M('Member_wallet'); $mw_wdata['member_id'] = $vo['member_id']; $wallet = $model->where($mw_wdata)->find(); $r_data['member_id'] = $vo['member_id']; $r_data['member_name'] = $vo['member_name']; $r_data['payment_mode'] = $_POST['payment_mode']; $r_data['payment_company'] = $_POST['payment_company']; $r_data['order_sn'] = $vo['order_sn']; $r_data['pay_order_sn'] = $_POST['pay_order_sn'] ? $_POST['pay_order_sn'] : build_order_no($vo['member_id']); $r_data['pay_type'] = 5; $r_data['amount'] = $refund_fee; if ($vo['payment_company'] == '余额支付') { //退款至账户 $mw_sdata['balance'] = $wallet['balance'] + $refund_fee; $result = $model->where($mw_wdata)->save($mw_sdata); $balance = $wallet['balance'] + $refund_fee; } else { $balance = $wallet['balance']; } $r_data['balance'] = $balance; $r_data['ip'] = _get_ip(); $r_data['content'] = '退款 商品' . $vo['product_name'] . '*' . $vo['num'] . '退款'; $r_data['create_time'] = time(); $r_data['pay_time'] = time(); $r_data['status'] = 1; if ($result) { $result = $this->rdb->add($r_data); } if ($result) { $this->db->commit(); } else { $this->db->rollback(); ajaxErrReturn('操作失败'); } //记录订单操作日志 $this->log_track($vo['order_sn'], '确认退款'); $msg['obj_id'] = 'item_' . $id; $msg['callback'] = '<strong><font color="blue">完成退款</font></strong>'; $msg['notice'] = '完成退款'; ajaxSucReturn($msg); } else { $this->db->rollback(); ajaxErrReturn('操作失败'); } }
/** * 删除购物车 */ public function clear(){ $model = D('Cart'); $data['member_id'] = $this->user['id']; $result = $model->where($data)->delete(); if($result){ $msg['error_code'] = 0; $msg['notice'] = '删除成功'; ajaxSucReturn($msg); }else{ ajaxErrReturn('删除失败'); } }
/** * 删除节点内容 */ public function ajax_sub_del() { $data['id'] = $_POST['id']; $result = $this->ddb->where($data)->delete(); if ($result) { $msg['notice'] = '删除成功!'; ajaxSucReturn($msg); } else { ajaxErrReturn('删除失败!'); } }
/** * 我的二维码 */ public function qrcode() { $r = base64_encode($this->user['mobile']); $url = C('PRO_URL') . "/index.php?m=Public&a=register&r={$r}"; $IMG_ROOT = C('IMG_ROOT') . 'avatar/' . get_dir($this->user['id']); $IMG_URL = C('IMG_URL') . 'avatar/' . get_dir($this->user['id']); $img_dir = $IMG_ROOT . '/qrcode.png'; $img_url = $IMG_URL . '/qrcode.png'; if (!file_exists($img_dir)) { include C('PUBLIC_INCLUDE') . 'phpqrcode.php'; mk_dir($IMG_ROOT); QRcode::png($url, $img_dir, 'L', 8, 2); } //echo $img_url;exit; $data['img_url'] = $img_url; ajaxSucReturn($data); }
/** * 设置默认地址 */ public function setdefault(){ $wdata['member_id'] = $this->user['id']; $sdata['default'] = 0; $result = $this->db->where($wdata)->save($sdata);//其他设置非默认 $wdata['id'] = $_POST['id']; $sdata['default'] = 1; $result = $this->db->where($wdata)->save($sdata);//设置默认 if($result){ ajaxSucReturn('设置成功'); }else{ ajaxErrReturn('设置失败'); } }
/** * 删除订单 */ public function delete(){ $model = M('Order'); $wdata['member_id'] = $this->user['id']; $wdata['order_sn'] = $_REQUEST['order_sn']; $sdata['is_display'] = 0; $result = $model->where($wdata)->save($sdata); if($result){ ajaxSucReturn('操作成功'); }else{ ajaxErrReturn($model->getlastsql()); ajaxErrReturn('操作失败'); } }
public function balance_pay() { $time = time(); if (!$_REQUEST['order_id'] && $_REQUEST['mo_id']) { ajaxErrReturn('订单号必须'); } $model = M('Order'); $od_model = M('OrderDetail'); if ($_REQUEST['order_id']) { $data['order_id'] = $_REQUEST['order_id']; $out_trade_no = $_REQUEST['order_id']; } if ($_GET['mo_id']) { $data['mo_id'] = $_REQUEST['mo_id']; $out_trade_no = $_REQUEST['mo_id']; } $data['member_id'] = $this->user['id']; $orders = $model->field('id,title,order_id,actual_paid,status')->where($data)->select(); if (!$orders) { ajaxErrReturn('订单不存在'); } $total_fee = 0; foreach ($orders as $vo) { $total_fee += $vo['actual_paid']; } if ($this->user['balance'] < $total_fee) { ajaxErrReturn('可用余额不足'); } $po_model = M('PayNotify'); foreach ($orders as $vo) { $po_data['order_id'] = $vo['order_id']; $po_data['out_trade_no'] = $vo['order_id']; $po_data['info'] = serialize($vo); $po_data['notice'] = '支付回调'; $po_data['create_time'] = $time; $po_model->add($po_data); } $model->startTrans(); //启用事务 foreach ($orders as $vo) { $order_id = $vo['id']; if (!$vo) { $this->pay_notice($order_id, '订单不存在'); ajaxErrReturn('订单不存在!'); } if ($vo['order_time'] && time() > $vo['order_time']) { $this->pay_notice($order_id, '订单已过期'); ajaxErrReturn('订单已过期!'); } if ($vo['pay_status'] > 0) { $this->pay_notice($order_id, '已支付!'); ajaxErrReturn('已支付!'); } $trade_no = build_order_no($this->user['id']); //$goods = unserialize($vo['goods']); $od_data['order_id'] = $vo['id']; $goods = $od_model->field('product_name')->where($od_data)->select(); $subject = '购买商品:'; $body = '购买商品'; foreach ($goods as $g) { $subject .= $g['product_name'] . ','; $body .= $g['product_name'] . ','; } $subject = substr($subject, 0, -1); $body = substr($subject, 0, -1); $body .= ',共消费' . $total_fee; //订单状态修改 $wdata['id'] = $vo['id']; $sdata['pay_status'] = 1; $sdata['order_id_third'] = $trade_no; $sdata['pay_time'] = $time; $result = $model->where($wdata)->save($sdata); if (!$result) { $model->rollback(); $this->pay_notice($order_id, '订单状态修改失败'); ajaxErrReturn('支付失败!'); } //修改余额 $wallet_data['member_id'] = $vo['member_id']; $result = $wallet_model->where($wallet_data)->setDec('balance', $vo['actual_paid']); if (!$result) { $model->rollback(); $this->pay_notice($order_id, '用户账号余额修改失败'); ajaxErrReturn('支付失败!'); } $content = '共支付' . $total_fee; //记录买家财务账单 unset($rdata); $rmodel = M('Record'); $rdata['member_id'] = $vo['member_id']; $wallet = $wallet_model->where($wallet_data)->find(); $rdata['member_name'] = $vo['member_name']; $rdata['realname'] = $vo['realname']; $rdata['order_id'] = $vo['order_id']; $rdata['pay_type'] = 2; $rdata['payment_mode'] = 1; $rdata['payment_company'] = $this->configs['company_name']; $rdata['payment_channel'] = '网站余额'; $rdata['pay_order_sn'] = $trade_no; $rdata['buyer'] = $vo['member_name']; $rdata['content'] = $content; $rdata['balance'] = $wallet['balance'] ? $wallet['balance'] : 0; $rdata['pay'] = $vo['actual_paid']; $rdata['create_time'] = $time; $rdata['status'] = 1; $rdata['pay_time'] = time(); if ($result) { $result = $rmodel->add($rdata); } else { $model->rollback(); $this->pay_notice($order_id, '买家财务账单记录失败'); ajaxErrReturn('支付失败!'); } if (!$result) { $model->rollback(); ajaxErrReturn('支付失败!'); } } if ($result) { $model->commit(); $msg['notice'] = '完成支付'; ajaxSucReturn($msg); } else { $model->rollback(); ajaxErrReturn('支付失败!'); } }
/** * ajax删除 */ public function ajax_del() { //删除指定记录 $id = $_REQUEST['id']; if (isset($id)) { $condition = array('id' => array('in', explode(',', $id))); //被删除促销的产品列表 $list = $this->ppldb->field('product_id')->where($condition)->group('product_id')->select(); if (false !== $this->ppldb->where($condition)->delete()) { //echo $model->getlastsql();exit; $ids = explode(',', $id); foreach ($ids as $id) { $this->history($id); } $this->check_product_prom($list); $msg['callback'] = 'remove("tr_' . $id . '")'; //$msg['notice'] = '删除成功!'; ajaxSucReturn($msg); } else { ajaxErrReturn('删除失败!'); } } else { ajaxErrReturn('非法操作'); } }
/** * 快递查询 */ public function detail() { $data['id'] = $_GET['id']; $vo = $this->db->where($data)->find(); $this->assign('vo', $vo); if (!$vo) { $this->error('物流信息不存在'); } $dir = get_dir($vo['id']); if (file_exists(C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/list.php')) { $list = (include C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/list.php'); } else { include C('PUBLIC_INCLUDE') . "kuaidi.class.php"; $kuaidi = new kuaidi(); $list = $kuaidi->query($vo['shipping_code'], $vo['shipping_no']); krsort($list['data']); mk_dir(C('DATA_CACHE_PATH') . '/delivery/'); if ($list['state'] == 3) { mk_dir(C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/'); F('list', $list, C('DATA_CACHE_PATH') . '/delivery/' . $dir . '/'); } } if ($list) { $list['count'] = count($list['data']); } else { $list['message'] = $kuaidi->error; } if (!$list) { $this->error($kuaidi->getError()); } else { $result['data'] = $list; $result['notice'] = '查询成功'; ajaxSucReturn($result); } }
/** * 子分类信息 */ public function get_cat(){ //$model = M('Product_category'); //$data['pid'] = $_POST['pid']; $catList = getCache('Product_category:sc_list_'.$_POST['pid']); if(IS_AJAX){ $msg['cate_list'] = $catList; ajaxSucReturn($msg); }else{ return $catList; } }