Exemple #1
0
 public function makeorder()
 {
     $subtype = intval(IReq::get("subtype"));
     $info['shopid'] = intval(IReq::get("shopid"));
     $info['remark'] = IFilter::act(IReq::get("content"));
     $info['paytype'] = IFilter::act(IReq::get("paytype"));
     $info['username'] = IFilter::act(IReq::get("contactname"));
     $info['mobile'] = IFilter::act(IReq::get("phone"));
     $info['addressdet'] = IFilter::act(IReq::get("addressdet"));
     $info['senddate'] = IFilter::act(IReq::get("senddate"));
     $info['minit'] = IFilter::act(IReq::get("orderTime"));
     $info['juanid'] = intval(IReq::get("juanid"));
     $info['ordertype'] = 1;
     $peopleNum = IFilter::act(IReq::get("personcount"));
     $info['othercontent'] = empty($peopleNum) ? "" : serialize(array("人数" => $peopleNum));
     $info['userid'] = !isset($this->member['score']) ? "0" : $this->member['uid'];
     if (Mysite::$app->config['allowedguestbuy'] != 1 && $info['userid'] == 0) {
         $this->message("member_nologin");
     }
     $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopfast as a left join " . Mysite::$app->config['tablepre'] . "shop as b  on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "'    ");
     if (empty($shopinfo)) {
         $this->message("店铺不存在");
     }
     $checksend = Mysite::$app->config['ordercheckphone'];
     if ($checksend == 1 && empty($this->member['uid'])) {
         $checkphone = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "mobile where phone ='" . $info['mobile'] . "'   order by addtime desc limit 0,50");
         if (empty($checkphone)) {
             $this->message("member_emailyan");
         }
         if (empty($checkphone['is_send'])) {
             $mycode = IFilter::act(IReq::get("phonecode"));
             if ($mycode == $checkphone['code']) {
                 $this->mysql->update(Mysite::$app->config['tablepre'] . "mobile", array("is_send" => 1), "phone='" . $info['mobile'] . "'");
             } else {
                 $this->message("member_emailyan");
             }
         }
     }
     if (empty($info['username'])) {
         $this->message("emptycontact");
     }
     if (!IValidate::suremobi($info['mobile'])) {
         $this->message("errphone");
     }
     $info['ipaddress'] = "";
     $ip_l = new iplocation();
     $ipaddress = $ip_l->getaddress($ip_l->getIP());
     if (isset($ipaddress['area1'])) {
         $info['ipaddress'] = $ipaddress['ip'] . mb_convert_encoding($ipaddress['area1'], "UTF-8", "GB2312");
     }
     $info['cattype'] = 0;
     $senddate = $info['senddate'];
     $minit = $info['minit'];
     $nowpost = strtotime($senddate . " " . $minit . ":00");
     $settime = time() - 600;
     if ($nowpost < $settime) {
         $this->message("提交配送时间和服务器时间相差超过10分钟下单失败");
     }
     $temp = strtotime($minit . ":00");
     $is_orderbefore = $shopinfo['is_orderbefore'] == 0 ? 0 : $shopinfo['befortime'];
     $tempinfo = $this->checkshopopentime($is_orderbefore, $nowpost, $shopinfo['starttime']);
     if (!$tempinfo) {
         $this->message("配送时间不在有效配送时间范围");
     }
     if ($shopinfo['is_open'] != 1) {
         $this->message("店铺暂停营业");
     }
     $info['paytype'] = $info['paytype'] == 1 ? 1 : 0;
     $info['areaids'] = "";
     $info['shopinfo'] = $shopinfo;
     if ($subtype == 1) {
         $info['allcost'] = 0;
         $info['bagcost'] = 0;
         $info['allcount'] = 0;
         $info['goodslist'] = array();
     } else {
         if (empty($info['shopid'])) {
             $this->message("shop_noexit");
         }
         $Cart = new smCart();
         $Cart->cartName = 'platesmcart';
         $carinfo = $Cart->getMyCart();
         if (!isset($carinfo['list'][$info['shopid']]['data'])) {
             $this->message("shop_emptycart");
         }
         $info['allcost'] = $carinfo['list'][$info['shopid']]['sum'];
         $info['goodslist'] = $carinfo['list'][$info['shopid']]['data'];
         $info['bagcost'] = 0;
         $info['allcount'] = 0;
     }
     $info['shopps'] = 0;
     $info['pstype'] = 0;
     $info['cattype'] = 1;
     $info['is_goshop'] = 1;
     $info['subtype'] = $subtype;
     $info['sendtime'] = $nowpost;
     $orderclass = new orderclass($this->mysql);
     $orderclass->orderyuding($info);
     $orderid = $orderclass->getorder();
     if ($info['userid'] == 0) {
         ICookie::set("orderid", $orderid, 86400);
     }
     if ($subtype == 2) {
         $Cart->delshop($info['shopid']);
     }
     $this->success($orderid);
     exit;
 }