Ejemplo n.º 1
0
 public function groupbuyorderOp()
 {
     if (isset($_POST) && !empty($_POST)) {
         //表单验证
         $obj_validate = new Validate();
         $obj_validate->validateparam = array(array("input" => intval($_POST['q_number']), "require" => "true", "validator" => "number", "message" => L('nc_groupbuy_is_not_null_and_number')));
         $error = $obj_validate->validate();
         if ($error != '') {
             $this->showTip(Language::get('error') . $error, '', 'html', 'error');
         }
         $group_id = intval($_POST['group_id']);
         $group_model = Model('groupbuy');
         $group = $group_model->getOne(array('group_id' => $group_id));
         $storeinfo = $this->getStoreInfo($group['store_id']);
         if ($storeinfo['store_state'] == 3) {
             $this->showTip('店铺已关闭', '', 'html', 'error');
         }
         //检测是否登录
         if (!isset($_SESSION['member_id'])) {
             $this->showTip(L('nc_groupbuy_is_not_login'), 'index.php?act=login', 'html', 'error');
         }
         //验证团购是否存在
         if (empty($group)) {
             $this->showTip(L('nc_groupbuy_is_not_exists'), '', 'html', 'error');
         }
         //验证团购是否开始
         if ($group['start_time'] > time()) {
             $this->showTip(L('nc_groupbuy_is_not_start'), '', 'html', 'error');
         }
         //验证团购是否结束
         if ($group['end_time'] < time()) {
             $this->showTip(L('nc_groupbuy_is_already_end'), '', 'html', 'error');
         }
         //验证团购数量
         if (intval($_POST['q_number']) > $group['buyer_limit']) {
             $this->showTip(L('nc_groupbuy_quantity_is_not_limit'), '', 'html', 'error');
         }
         if (intval($_POST['q_number']) + $group['buyer_num'] > $group['buyer_count']) {
             $this->showTip('团购券库存不足', '', 'html', 'error');
         }
         $store_id = $group['store_id'];
         $storeinfo = $this->getStoreInfo($store_id);
         $member_model = Model('member');
         $member = $member_model->getOne(array('member_id' => $_SESSION['member_id']));
         //生成团购订单
         $params = array();
         $params['order_sn'] = $this->snOrder();
         $params['member_id'] = $member['member_id'];
         $params['member_name'] = $member['member_name'];
         $params['mobile'] = $member['mobile'];
         $params['store_id'] = $storeinfo['store_id'];
         $params['store_name'] = $storeinfo['store_name'];
         $params['add_time'] = time();
         $params['order_type'] = 1;
         //未支付状态
         $params['item_id'] = intval($_POST['group_id']);
         $params['item_name'] = $group['group_name'];
         $params['number'] = intval($_POST['q_number']);
         $params['price'] = intval($_POST['q_number']) * $group['group_price'];
         $params['state'] = 1;
         $params['order_out'] = $this->order_sn;
         $order_model = Model('order');
         $result = $order_model->save($params);
         if ($result) {
             //计入分数
             member_point_add('groupbuy');
             //修改团购购买数量
             $model = Model();
             $model->table('groupbuy')->where(array('group_id' => $group_id))->setInc('buyer_num', intval($_POST['q_number']));
             header("Location:index.php?act=groupbuy&op=grouppayment&order_id=" . $result);
             exit;
         } else {
             $this->showTip(L('nc_groupbuy_operation_is_wrong'), '', 'html', 'error');
         }
     }
     //团购信息
     $group_id = intval($_GET['group_id']);
     $group_model = Model('groupbuy');
     $group = $group_model->getOne(array('group_id' => $group_id));
     if (empty($group)) {
         $this->showTip(L('nc_home_groupbuy_is_not_exists'), 'index.php', 'html', 'error');
     }
     $storeinfo = $this->getStoreInfo($group['store_id']);
     if ($storeinfo['store_state'] == 3) {
         $this->showTip('店铺已关闭', '', 'html', 'error');
     }
     Tpl::output('group', $group);
     Tpl::showpage('groupbuy.order');
 }
Ejemplo n.º 2
0
 /**
  * 添加预约
  * */
 public function orderOp()
 {
     if (isset($_POST) && !empty($_POST)) {
         $model = Model();
         $store = $model->table('store')->where(array('store_id' => intval($_POST['store_id'])))->find();
         if (empty($store)) {
             //验证店铺是否存在
             $this->showTip(L('nc_appointment_op_fail'), '', 'html', 'error');
         }
         if ($store['store_id'] == $_SESSION['store_id']) {
             $this->showTip('无法预约自己的店铺', '', 'html', 'error');
         }
         $time = $_POST['appointtime'] . ' ' . $_POST['hour'] . ':00:00';
         $appoint_time = strtotime($time);
         if ($appoint_time <= time()) {
             $this->showTip('请不要预约过去的时间', '', 'html', 'error');
         }
         $appointment = $model->table('appointment')->where(array('member_id' => $_SESSION['member_id'], 'appointtime' => $appoint_time))->find();
         if (!empty($appointment)) {
             //检测是否重复预约
             $this->showTip(L('nc_appointment_already_appointment'), '', 'html', 'error');
         }
         $data = array('store_id' => $store['store_id'], 'store_name' => $store['store_name'], 'person_num' => intval($_POST['person_num']), 'appointtime' => $appoint_time, 'mobile' => trim($_POST['mobile']), 'member_id' => $_SESSION['member_id'], 'contact' => $_POST['contact']);
         $result = $model->table('appointment')->insert($data);
         if ($result) {
             //计入分数
             member_point_add('appointment');
             $this->showTip(L('nc_appointment_op_succ'), '', 'succ');
         } else {
             $this->showTip(L('nc_appointment_op_fail'), '', 'html', 'error');
         }
     }
     $model = Model();
     $store = $model->table('store')->where(array('store_id' => intval($_GET['store_id']), 'is_audit' => 2))->find();
     //审核通过的店铺
     Tpl::output('store', $store);
     Tpl::showpage('appointment.order', 'null_layout');
 }
Ejemplo n.º 3
0
 /**
  * 图片裁剪
  */
 public function cutOp()
 {
     if (chksubmit()) {
         $thumb_width = 120;
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         $scale = $thumb_width / $w;
         $_POST['newfile'] = str_replace('..', '', $_POST['newfile']);
         $src = BASE_UPLOAD_PATH . DS . 'shop/member' . DS . $_POST['newfile'];
         $avatarfile = BASE_UPLOAD_PATH . DS . 'shop/member' . DS . "avatar_{$_SESSION['member_id']}.jpg";
         import('function.thumb');
         $cropped = resize_thumb($avatarfile, $src, $w, $h, $x1, $y1, $scale);
         @unlink($src);
         Model()->table('member')->where(array('member_id' => $_SESSION['member_id']))->update(array('avatar' => 'avatar_' . $_SESSION['member_id'] . '.jpg'));
         if ($_SESSION['avatar'] == '') {
             //计入分数
             member_point_add('avatar_upload');
         }
         $_SESSION['avatar'] = 'avatar_' . $_SESSION['member_id'] . '.jpg';
         redirect('index.php?act=memberaccount&op=avatar');
     }
 }
Ejemplo n.º 4
0
 /**
  * 打印优惠券
  */
 public function printOp()
 {
     $coupon_id = intval($_GET['coupon_id']);
     //优惠券详情
     $coupon_info = $this->couponinfo($coupon_id);
     $store_info = $this->getStoreInfo($coupon_info['store_id']);
     if ($store_info['store_state'] == 3) {
         $this->showTip('该店铺已经关闭', '', 'html', 'error');
     }
     if (empty($coupon_info)) {
         $this->showTip(L('nc_coupon_is_not_exists'), '', 'html', 'error');
     }
     if ($coupon_info['download_type'] == 2) {
         $this->showTip('该优惠券不支持打印下载', '', 'html', 'error');
     }
     Tpl::output('coupon_info', $coupon_info);
     $model = Model();
     $params = array('member_id' => isset($_SESSION['member_id']) ? $_SESSION['member_id'] : '', 'member_name' => isset($_SESSION['member_name']) ? $_SESSION['member_name'] : '', 'coupon_id' => $coupon_id, 'coupon_name' => $coupon_info['coupon_name'], 'download_time' => time(), 'download_type' => 1);
     $model->table('coupon_download')->insert($params, true);
     $model->table('coupon')->where(array('coupon_id' => $coupon_id))->setInc('download_count', 1);
     //计入分数
     member_point_add('coupon');
     Tpl::showpage('coupon.print', 'null_layout');
 }
Ejemplo n.º 5
0
 public function applycardOp()
 {
     if (isset($_GET['type']) && $_GET['type'] == 'card') {
         $member_id = $_SESSION['member_id'];
         $member_name = $_SESSION['member_name'];
         $store_id = intval($_GET['store_id']);
         $store = $this->getStoreInfo($store_id);
         $param = array('member_id' => $member_id, 'store_id' => $store_id);
         $model = Model();
         $card_member = $model->table('card_member')->where($param)->find();
         if (!empty($card_member)) {
             //会员卡已经存在
             echo json_encode(array('result' => L('nc_card_apply_card_exists')));
             exit;
         }
         $params = array('is_use' => 2, 'card_number' => $store['city_id'] . $store_id . $member_id . rand(00, 999), 'member_id' => $member_id, 'member_name' => $member_name, 'store_id' => $store_id, 'store_name' => $store['store_name']);
         $result = $model->table('card_member')->insert($params);
         //添加会员卡
         //计入分数
         member_point_add('member_card');
         echo json_encode(array('result' => L('nc_member_apply_succ')));
         exit;
     }
     //申请会员卡页面
     $storeinfo = $this->getStoreInfo(intval($_GET['store_id']));
     Tpl::output('storeinfo', $storeinfo);
     Tpl::showpage('apply.card', 'null_layout');
 }
Ejemplo n.º 6
0
 /**
  * 申请活动
  */
 public function applyOp()
 {
     $activity_id = intval($_GET['activity_id']);
     $activity_model = Model('activity');
     $activityArr = $activity_model->getOne(array('activity_id' => $activity_id));
     //检测活动是否存在
     if (empty($activityArr)) {
         echo json_encode(array('result' => 'fail', 'msg' => L('nc_store_activity_is_not_exists')));
         exit;
     }
     //会员是否登录
     if ($_SESSION['is_login'] != 1) {
         echo json_encode(array('result' => 'fail', 'msg' => '请您先登录'));
         exit;
     }
     //报名截止日期
     if ($activityArr['apply_time'] < time()) {
         echo json_encode(array('result' => 'fail', 'msg' => '活动报名已截止'));
         exit;
     }
     //检查会员是否已经申请
     $model = Model();
     $memberArr = $model->table('activity_member')->where(array('member_id' => $_SESSION['member_id'], 'activity_id' => $activity_id))->find();
     if (!empty($memberArr)) {
         echo json_encode(array('result' => 'fail', 'msg' => L('nc_store_activity_member_already_apply')));
         exit;
     }
     //申请活动
     $model = Model();
     $params = array();
     $params['member_id'] = $_SESSION['member_id'];
     $params['member_name'] = $_SESSION['member_name'];
     $params['activity_id'] = $activity_id;
     $params['apply_time'] = time();
     $params['member_avator'] = $_SESSION['avatar'];
     $params['activity_item'] = trim($_GET['item'], ',');
     $result = $model->table('activity_member')->insert($params, true);
     if ($result) {
         //计入分数
         member_point_add('activity');
         $model->table('activity')->where(array('activity_id' => $activity_id))->setInc('apply_num', 1);
         echo json_encode(array('result' => 'succ', 'msg' => Language::get('nc_store_activity_apply_succ')));
         exit;
     } else {
         echo json_encode(array('result' => 'fail', 'msg' => Language::get('nc_store_activity_apply_fail')));
         exit;
     }
 }