示例#1
0
 public function add($gid, $type, $qishu = 0)
 {
     $islogin = logincheck();
     if ($islogin == 0) {
         $result['status'] = 1000;
         $result['message'] = '未登录';
         $this->ajaxReturn($result);
         return;
     }
     $db = M('cart');
     $map['gid'] = $gid;
     $map['type'] = $type;
     $map['uid'] = session("_uid");
     $exists = $db->where($map)->find();
     $result = array();
     if (empty($exists)) {
         $data['gid'] = $gid;
         $data['uid'] = get_temp_uid();
         $data['type'] = $type;
         $data['flag'] = home_is_login() ? 1 : 0;
         // 0 没有登陆, 1登陆
         if ($db->add($data)) {
             count_cart(1);
             $result['count'] = 1;
             $result['status'] = 0;
             $result['message'] = '添加成功';
         } else {
             $result['status'] = 1;
             $result['message'] = '添加失败';
         }
     } else {
         if ($exists['paimai']) {
             $result['status'] = 2;
             $result['message'] = '商品已经添加';
         } else {
             if ($exists['good'] && intval($exists['good']['xiangou']) > 0 && intval($exists['good']['xiangou']) == intval($exists['count'])) {
                 $result['status'] = 3;
                 $result['message'] = '该商品限购' . $exists['good']['xiangou'] . '人次';
             } else {
                 if ($exists['good'] && intval($exists['count']) >= intval($exists['good']['shengyurenshu'])) {
                     $result['status'] = 4;
                     $result['message'] = '该商品剩余' . $exists['good']['shengyurenshu'] . '人次';
                 } else {
                     // 存在,累加
                     $data['count'] = intval($exists['count']) + 1;
                     $data['id'] = $exists['id'];
                     if ($db->save($data)) {
                         $result['status'] = 0;
                         $result['message'] = '添加成功';
                     } else {
                         $result['status'] = 1;
                         $result['message'] = '添加失败';
                     }
                 }
             }
         }
     }
     $this->ajaxReturn($result);
 }
示例#2
0
 public function login()
 {
     if (IS_POST) {
         $result["status"] = 0;
         $result["msg"] = "登录成功。";
         $password = md5($_POST['password']);
         $db = M('member');
         $data['mobile'] = $_POST['mobile'];
         $user = $db->where($data)->find();
         if (!$user || $user['password'] != $password) {
             $result["msg"] = '用户名或密码不正确';
         } else {
             $openid = get_user_open_id();
             $data = array('uid' => $user['uid'], 'login' => array('exp', '`login` + 1'), 'login_time' => date('y-m-d-H-i-s'), 'login_ip' => get_client_ip(), 'openid' => $openid);
             $db->save($data);
             // 将临时购物车的记录替换成真的
             $cdb = M('cart');
             $_uid = get_temp_uid();
             // 清空之前的商品
             $cmap['uid'] = $data['uid'];
             $cdb->where($cmap)->delete();
             $sql = 'update `yyg_cart` SET `flag` = 1 ,`uid` = ' . $data['uid'] . ' WHERE `uid` = ' . $_uid;
             $row = M()->execute($sql);
             session("_uid", $user['uid']);
             session('wxUserinfo', $user);
             $url = decode(I('post.redirect'));
             $result["status"] = 1;
             //$this->success('登录成功',U('Person/me', '',''));
         }
         $this->ajaxReturn($result);
     } else {
         $openid = get_user_open_id();
         if (!empty($openid)) {
             if (home_is_login()) {
                 $this->redirect('Person/me');
                 return;
             }
         }
         layout(false);
         $this->assign('redirect', $mobile);
         $this->display();
     }
 }
示例#3
0
 public function view($gid, $qishu = 0)
 {
     //		run_task();
     $this->assign('title', '商品详情');
     $data = $this->getGood($gid, $qishu);
     $data['content'] = htmlspecialchars_decode(html_entity_decode($data['content']));
     $this->assign('data', $data);
     $qishu = $data['qishu'];
     $this->assign('gid', $gid);
     $this->assign('qishu', $qishu);
     // 购买记录
     $mmdb = M('MemberMiaosha');
     $mmmap['gid'] = $gid;
     $mmmap['qishu'] = $qishu;
     $records = $mmdb->join('yyg_member on yyg_member.uid = yyg_member_miaosha.uid')->field(array('yyg_member_miaosha.id' => 'mid', 'yyg_member_miaosha.uid', 'yyg_member.img', 'yyg_member_miaosha.count', 'yyg_member_miaosha.time', 'IFNULL(NULLIF(yyg_member.username, \'\'), INSERT(yyg_member.mobile,4,4,\'****\'))' => 'username'))->where($mmmap)->order('id desc')->page(1, 6)->select();
     if (!empty($records)) {
         $this->assign('records', $records);
     }
     // 本人购买记录
     if (is_login()) {
         $mmmap = array('gid' => $gid, 'qishu' => $qishu, 'yyg_member_miaosha.uid' => get_temp_uid());
         $myrecords = $mmdb->join('yyg_member on yyg_member.uid = yyg_member_miaosha.uid')->field(array('yyg_member_miaosha.id' => 'mid', 'yyg_member_miaosha.uid', 'yyg_member.img', 'yyg_member_miaosha.count', 'yyg_member_miaosha.time', 'IFNULL(NULLIF(yyg_member.username, \'\'), INSERT(yyg_member.mobile,4,4,\'****\'))' => 'username'))->where($mmmap)->order('id desc')->page(1, 9)->select();
         if ($myrecords) {
             $this->assign('myrecords', $myrecords);
         }
     }
     // 图片
     $imgdb = M('GoodsImages');
     $imgmap['gid'] = $gid;
     $images = $imgdb->where($imgmap)->select();
     $this->assign('images', $images);
     if (count($images) > 0) {
         $this->assign('firstImage', $images[0]);
     }
     $this->display();
 }
示例#4
0
 public function login()
 {
     //echo $_SESSION["abc"];
     if (IS_POST) {
         $result["status"] = 0;
         $result["msg"] = "登录成功。";
         $password = md5($_POST['password']);
         $db = M('member');
         //			$data['mobile'] = $_POST['username'];
         //			$user = $db->where($data)->find();
         $m = D('P/Member');
         $user = $m->getByMobile($_POST['username']);
         if (!$user || $user['password'] != $password) {
             $result["msg"] = '用户名或密码不正确';
         } else {
             $data = array('uid' => $user['uid'], 'login' => array('exp', '`login` + 1'), 'login_time' => date('y-m-d-H-i-s'), 'login_ip' => get_client_ip());
             $db->save($data);
             // 将临时购物车的记录替换成真的
             $cdb = M('cart');
             $_uid = get_temp_uid();
             // 清空之前的商品
             $cmap['uid'] = $_uid;
             $cdb->where($cmap)->delete();
             empty_cart();
             $cartCount = $cdb->where(array('uid' => $user['uid']))->count();
             count_cart($cartCount);
             //				$sql = 'update `yyg_cart` SET `flag` = 1 ,`uid` = ' . $data['uid'] .' WHERE `uid` = ' . $_uid;
             //				$row = M()->execute($sql);
             session("_uid", $user['uid']);
             session('wxUserinfo', $user);
             $url = decode(I('post.redirect'));
             $result["status"] = 1;
             session('loginstatus', 1);
             //$this->success('登录成功',U('Person/me', '',''));
         }
         $this->ajaxReturn($result);
     } else {
         layout(false);
         $this->assign('title', '壹圆购物');
         $this->display();
     }
 }
示例#5
0
 public function chujia($gid, $money)
 {
     if (home_is_login()) {
         $pdb = M('paimai');
         $good = $pdb->field('gid,zuigaojia, qipaijia, jiafujia, chujiacishu, status')->find($gid);
         $result = array();
         $mpdb = M('MemberPaimai');
         if (intval($good['status']) < 2) {
             // 如果 商品未结束
             $zuigaojia = floatval($good['zuigaojia']);
             $qipaijia = floatval($good['qipaijia']);
             $jiafujia = floatval($good['jiafujia']);
             $chujiacishu = intval($good['chujiacishu']);
             $money = floatval($money);
             $uid = get_temp_uid();
             // 检测是否缴纳保证金
             $mpmap['gid'] = $good['gid'];
             $mpmap['uid'] = $uid;
             $mpmap['flag'] = 0;
             $record = $mpdb->where($mpmap)->find();
             if (!$record) {
                 $result['status'] = 2;
                 $result['message'] = '操作异常,请先缴纳保证金';
             } else {
                 if ($money < $zuigaojia + $jiafujia) {
                     $result['status'] = 3;
                     $result['message'] = '出价不能低于当前的最高出价与加价幅度之和';
                 } else {
                     if ($money < $qipaijia) {
                         $result['status'] = 4;
                         $result['message'] = '出价不能低于起拍价';
                     } else {
                         $mpdata['uid'] = $uid;
                         $mpdata['gid'] = $good['gid'];
                         $mpdata['flag'] = 1;
                         $mpdata['money'] = $money;
                         if ($mpdb->add($mpdata)) {
                             $good['chujiacishu']++;
                             $good['zuigaojia'] = $money;
                             $good['chujiazhe'] = $uid;
                             if ($pdb->save($good)) {
                                 add_renci(1);
                                 $result['status'] = 0;
                                 $result['message'] = '出价成功';
                             } else {
                                 $result['status'] = 6;
                                 $result['message'] = '出价失败';
                             }
                         } else {
                             $result['status'] = 5;
                             $result['message'] = '出价失败';
                         }
                     }
                 }
             }
         } else {
             // 已结束
             $result['status'] = 1;
             $result['message'] = '拍卖已结束';
         }
         $this->ajaxReturn($result, 'JSON');
     }
 }
示例#6
0
 /**
  * 个人拍卖纪录
  */
 public function pagepaimai($type = 0, $pageNo = 1)
 {
     $pageSize = 12;
     $uid = get_temp_uid();
     $map = array('uid' => $uid);
     switch ($type) {
         case 1:
             //1.待处理
             $map['status'] = 2;
             $map['prizeuid'] = $uid;
             $map['ispay'] = 0;
             $map['flag'] = 1;
             $map['zuigaojia'] = array('exp', ' = money');
             break;
         case 2:
             $map['status'] = 2;
             $map['prizeuid'] = $uid;
             $map['ispay'] = array('neq', 0);
             $map['flag'] = 1;
             $map['zuigaojia'] = array('exp', ' = money');
             break;
     }
     $db = M('MemberPaimai');
     $list = $db->field('p.gid, p.title, p.zuigaojia, p.status, p.prizeuid, p.ispay, p.postcode, p.postcompany, p.ispost, mp.id, mp.uid, mp.flag, mp.money, mp.time')->join('mp inner join __PAIMAI__ p on p.gid=mp.gid')->where($map)->order('mp.time desc')->page($pageNo, $pageSize)->select();
     //		echo $db->getLastSql();
     $this->ajaxReturn($list, 'JSON');
 }
示例#7
0
 public function topay($payid)
 {
     $third = (double) $_POST["third"];
     // 第三方付款
     $money = (double) $_POST["money"];
     // 余额支付
     $score = (int) $_POST["score"];
     // 积分支付
     $uid = get_temp_uid();
     $result['status'] = $this->updatePrePay($payid, $uid, $money, $score, $third);
     if ($status != 0) {
         // 计算余额失败
         $this->ajaxReturn($result, 'JSON');
         return;
     }
     if ($third > 0) {
         // 需要第三方支付
         $this->jubaopay($payid);
         // TODO: 第三方支付接口
     } else {
         // 本地直接支付
         $result['status'] = $this->pay($payid);
     }
     $this->ajaxReturn($result, 'JSON');
 }
示例#8
0
 function getPaimaiUnfixedCount()
 {
     $db = M('Paimai');
     $uid = get_temp_uid();
     $map = array('prizeuid' => $uid, 'ispay' => 0);
     return $db->where($map)->count();
 }
示例#9
0
 public function box()
 {
     $db = D('cart');
     $map['uid'] = get_temp_uid();
     $list = $db->where($map)->relation(true)->select();
     // 检测商品状态
     $total = 0;
     foreach ($list as $cart) {
         $count = intval($cart['count']);
         if ($cart['paimai']) {
             if (intval($cart['paimai']['status']) == 2) {
                 $db->delete($cart['id']);
                 $cart['status'] = 1;
                 // 竞拍已结束
             } else {
                 $total += intval($cart['paimai']['lijijia']);
             }
         } else {
             if ($cart['good']) {
                 if (intval($cart['good']['status']) == 2) {
                     $db->delete($cart['id']);
                     $cart['status'] = 1;
                     // 商品已结束
                 } else {
                     $shengyurenshu = intval($cart['good']['shengyurenshu']);
                     if ($shengyurenshu < $count) {
                         $cart['count'] = $shengyurenshu;
                     }
                     if ($cart['qishu'] != $cart['good']['qishu']) {
                         $data = array();
                         $data['id'] = $cart['id'];
                         $data['qishu'] = $cart['good']['qishu'];
                         $db->save($data);
                         $cart['qishu'] = $cart['good']['qishu'];
                     }
                     $total += $count * intval($cart['good']['danjia']);
                 }
             }
         }
     }
     $result = array('count' => count($list), 'total' => $total, 'list' => $list);
     $this->ajaxReturn($result, 'JSON');
 }