function makeorder() { $info['shopid'] = intval(IReq::get('shopid')); //店铺ID $info['remark'] = IFilter::act(IReq::get('remark')); //备注 $info['paytype'] = IFilter::act(IReq::get('paytype')); //支付方式 $info['dikou'] = intval(IReq::get('dikou')); //抵扣金额 $info['username'] = IFilter::act(IReq::get('username')); $info['mobile'] = IFilter::act(IReq::get('mobile')); $info['addressdet'] = IFilter::act(IReq::get('addressdet')); $info['senddate'] = IFilter::act(IReq::get('senddate')); $info['minit'] = IFilter::act(IReq::get('minit')); $info['juanid'] = intval(IReq::get('juanid')); //优惠劵ID $info['ordertype'] = 1; //订单类型 $peopleNum = IFilter::act(IReq::get('peopleNum')); $info['othercontent'] = ''; //empty($peopleNum)?'':serialize(array('人数'=>$peopleNum)); if (empty($info['shopid'])) { $this->message('店铺ID错误'); } $Cart = new smCart(); $carinfo = $Cart->getMyCart(); //print_r($carinfo);exit; if (!isset($carinfo['list'][$info['shopid']]['data'])) { $this->message('对应店铺购物车商品为空'); } if ($carinfo['list'][$info['shopid']]['shopinfo']['shoptype'] == 1) { $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shopmarket as a left join " . Mysite::$app->config['tablepre'] . "shop as b on a.shopid = b.id where a.shopid = '" . $info['shopid'] . "' "); } else { $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('店铺获取失败'); } $checkps = $this->pscost($shopinfo, $carinfo['list'][$info['shopid']]['count']); if ($checkps['canps'] != 1) { $this->message('该店铺不在配送范围内'); } $info['cattype'] = 0; // if (empty($info['username'])) { $this->message('联系人不能为空'); } if (!IValidate::suremobi($info['mobile'])) { $this->message('请输入正确的手机号'); } if (empty($info['addressdet'])) { $this->message('详细地址为空'); } $info['userid'] = !isset($this->member['score']) ? '0' : $this->member['uid']; if (Mysite::$app->config['allowedguestbuy'] != 1) { if ($info['userid'] == 0) { $this->message('禁止游客下单'); } } //判断库存 $senddate = $info['senddate']; $minit = $info['minit']; $nowpost = strtotime($senddate . ' ' . $minit); $day = strtotime(date('Y-m-d', $nowpost)); $goods_id_list = []; foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) { $goods_id_list[] = $value['id']; } $goods_ids = implode(',', $goods_id_list); $stock_info_list = $this->mysql->getarr("SELECT goods_id,stock FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id in ({$goods_ids}) AND day={$day}"); $stock_list = []; foreach ($stock_info_list as $key => $value) { $stock_list[$value['goods_id']] = $value['stock']; } foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) { if (!array_key_exists($value['id'], $stock_list)) { $stock_list[$value['id']] = 0; } if ($value['daycount'] - $stock_list[$value['id']] - $value['count'] < 0) { $this->message($valeu['name'] . '库存不足'); exit; } } $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'); //('GB2312','ansi',); } //area1 二级地址名称 area2 三级地址名称 area3 $nowID = intval(ICookie::get('myaddress')); if (!empty($nowid)) { if (empty($nowID)) { $this->message('未选择配送区域'); } $checkareaid = $nowID; $dataareaids = array(); while ($checkareaid > 0) { $temp_check = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "area where id ='" . $checkareaid . "' order by id desc limit 0,50"); if (empty($temp_check)) { break; } if (in_array($checkareaid, $dataareaids)) { break; } $dataareaids[] = $checkareaid; $checkareaid = $temp_check['parent_id']; } $data['areaids'] = join(',', $dataareaids); } else { $data['areaids'] = ''; } $checksend = Mysite::$app->config['ordercheckphone']; if ($checksend == 1) { if (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('短信验证码不能为空'); } 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('验证码不一致'); } } } } $data['shopcost'] = 0; //:店铺商品总价 $data['shopps'] = 0; //店铺配送费 $data['shoptype'] = 0; //: 0:普通订单,1订台订单 $data['bagcost'] = 0; //:打包费 //获取店铺商品总价 获取超市商品总价 $data['shopcost'] = $carinfo['list'][$info['shopid']]['sum']; $data['shopps'] = $checkps['pscost']; $data['bagcost'] = $carinfo['list'][$info['shopid']]['bagcost']; //支付方式检测 $userid = $info['userid']; $data['paytype'] = $info['paytype']; $paytype = $info['paytype']; if ($paytype != 'outpay') { if ($paytype == 'open_acout') { if (Mysite::$app->config['open_acout'] != 1 || $userid == 0) { $data['paytype'] = 'outpay'; } } else { $paylist = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "paylist where loginname='" . $paytype . "' order by id desc "); if ($paylist < 1) { $data['paytype'] = 'outpay'; } } } //判断促销 $data['cxids'] = ''; $data['cxcost'] = 0; $zpin = array(); $cattype = $info['cattype']; if ($data['shopcost'] > 0) { $sellrule = new sellrule(); $sellrule->setdata($info['shopid'], $data['shopcost'], $shopinfo['shoptype'], $day); $ruleinfo = $sellrule->getdata(); $data['cxcost'] = $ruleinfo['downcost']; $data['cxids'] = $ruleinfo['cxids']; $zpin = $ruleinfo['zid']; //赠品 $data['shopps'] = $ruleinfo['nops'] == true ? 0 : $data['shopps']; } //判断优惠劵 $allcost = $data['shopcost']; $data['yhjcost'] = 0; $data['yhjids'] = ''; $juanid = $info['juanid']; if ($juanid > 0 && $userid > 0) { $juaninfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "juan where id= '" . $juanid . "' and uid='" . $userid . "' and status = 1 and endtime > " . time() . " "); if (!empty($juaninfo)) { if ($allcost >= $juaninfo['limitcost']) { $data['yhjcost'] = $juaninfo['cost']; $juandata['status'] = 2; $juandata['usetime'] = time(); $this->mysql->update(Mysite::$app->config['tablepre'] . 'juan', $juandata, "id='" . $juanid . "'"); $data['yhjids'] = $juanid; } } } //积分抵扣 $allcost = $allcost - $data['cxcost'] - $data['yhjcost']; $data['scoredown'] = 0; $dikou = $info['dikou']; if (!empty($userid) && $dikou > 0 && Mysite::$app->config['scoretocost'] > 0 && $allcost > $dikou) { $checkuser = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid='" . $userid . "' "); if (is_array($checkuser)) { $checkscore = $dikou * intval(Mysite::$app->config['scoretocost']); if ($checkuser['score'] >= $checkscore) { $data['scoredown'] = $checkscore; $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`score`=`score`-' . $checkscore, "uid ='" . $userid . "' "); } } } $dikou = $data['scoredown'] > 0 ? $dikou : 0; $allcost = $allcost - $dikou; $data['allcost'] = $allcost + $data['shopps'] + $data['bagcost']; //订单应收费用 $data['shopuid'] = 0; // 店铺UID $data['shopid'] = 0; //店铺ID $data['shopname'] = '商城'; //店铺名称 $data['shopphone'] = Mysite::$app->config['marketphone']; //店铺电话 $data['shopaddress'] = ''; // 店铺地址 $data['pstype'] = $checkps['pstype']; $data['shoptype'] = $shopinfo['shoptype']; //检测店铺 $settime = time() - 600; if ($settime > $nowpost) { $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('店铺暂停营业'); } if ($shopinfo['limitcost'] > $allcost) { $this->message('商品总价低于最小起送价' . $shopinfo['limitcost']); } $data['shopuid'] = $shopinfo['uid']; // 店铺UID $data['shopid'] = $shopinfo['id']; //店铺ID $data['shopname'] = $shopinfo['shopname']; //店铺名称 $data['shopphone'] = $shopinfo['phone']; //店铺电话 $data['shopaddress'] = $shopinfo['address']; // 店铺地址 $data['buyeraddress'] = $info['addressdet']; $data['ordertype'] = $info['ordertype']; //来源方式; $data['buyeruid'] = $userid; // 购买用户ID,0未注册用户 $data['buyername'] = $info['username']; //购买热名称 $data['buyerphone'] = $info['mobile']; // 联系电话 $panduan = Mysite::$app->config['man_ispass']; $data['status'] = $panduan == 1 ? '0' : 1; $data['paystatus'] = 0; // 支付状态1已支付 $data['content'] = $info['remark']; // 订单备注 // daycode 当天订单序号 $data['ipaddress'] = $info['ipaddress']; $data['is_ping'] = 0; // 是否评价字段 1已评完 0未评 $data['addtime'] = time(); $data['posttime'] = $nowpost; //: 配送时间 $data['othertext'] = $info['othercontent']; //其他说明 $data['is_make'] = Mysite::$app->config['allowed_is_make'] == 1 ? 0 : 1; // :审核时间 $data['passtime'] = time(); if ($data['status'] == 1) { $data['passtime'] == 0; } $data['buycode'] = substr(md5(time()), 9, 6); $data['dno'] = time() . rand(1000, 9999); $minitime = strtotime(date('Y-m-d', time())); $tj = $this->mysql->select_one("select count(id) as shuliang from " . Mysite::$app->config['tablepre'] . "order where shopid='" . $info['shopid'] . "' and addtime > " . $minitime . " limit 0,1000"); $data['daycode'] = $tj['shuliang'] + 1; $this->mysql->insert(Mysite::$app->config['tablepre'] . 'order', $data); //写主订单 $orderid = $this->mysql->insertid(); $this->orderid = $orderid; foreach ($carinfo['list'][$info['shopid']]['data'] as $key => $value) { $cmd['order_id'] = $orderid; $cmd['goodsid'] = $value['id']; $cmd['goodsname'] = $value['name']; $cmd['goodscost'] = $value['cost']; $cmd['goodscount'] = $value['count']; $cmd['shopid'] = $value['shopid']; $cmd['status'] = 0; $cmd['is_send'] = 0; $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $cmd); //减少库存pinkky $daystock = $this->mysql->select_one("SELECT * FROM " . Mysite::$app->config['tablepre'] . "daystock WHERE goods_id=" . $value['id'] . " and day=" . $day); if ($daystock) { $this->mysql->update(Mysite::$app->config['tablepre'] . 'daystock', '`stock`=`stock`+1', "id=" . $daystock['id']); } else { $stockdata['goods_id'] = $value['id']; $stockdata['day'] = $day; $stockdata['stock'] = 1; $this->mysql->insert(Mysite::$app->config['tablepre'] . 'daystock', $stockdata); } //$this->mysql->update(Mysite::$app->config['tablepre'].'goods','`count`=`count`-'.$cmd['goodscount'].' ,`sellcount`=`sellcount`+'.$cmd['goodscount'],"id='".$cmd['goodsid']."'"); $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', '`sellcount`=`sellcount`+' . $cmd['goodscount'], "id='" . $cmd['goodsid'] . "'"); } if (is_array($zpin) && count($zpin) > 0) { foreach ($zpin as $key => $value) { $datadet['order_id'] = $orderid; $datadet['goodsid'] = $key; $datadet['goodsname'] = $value['presenttitle']; $datadet['goodscost'] = 0; $datadet['goodscount'] = 1; $datadet['shopid'] = $shopinfo['id']; $datadet['status'] = 0; $datadet['is_send'] = 1; //更新促销规则中 此赠品的数量 $this->mysql->insert(Mysite::$app->config['tablepre'] . 'orderdet', $datadet); $this->mysql->update(Mysite::$app->config['tablepre'] . 'rule', '`controlcontent`=`controlcontent`-1', "id='" . $key . "'"); } } $checkbuyer = Mysite::$app->config['allowedsendbuyer']; $checksend = Mysite::$app->config['man_ispass']; if ($checksend != 1) { $orderCLs = new orderclass($this->mysql); $orderCLs->sendmess($orderid); } if ($userid == 0) { ICookie::set('orderid', $orderid, 86400); } else { //保持地址数据 $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "address where userid='" . $userid . "' "); if (empty($checkinfo)) { $addata['userid'] = $this->member['uid']; $addata['username'] = $this->member['username']; $addata['address'] = $data['buyeraddress']; $addata['phone'] = $data['buyerphone']; $addata['contactname'] = $data['buyername']; $addata['default'] = 1; $this->mysql->insert(Mysite::$app->config['tablepre'] . 'address', $addata); } } $Cart->delshop($info['shopid']); $this->success($orderid); }
function regester($email, $tname, $password, $phone, $group, $userlogo = '', $address = '', $cost = 0, $score = 0) { if (empty($email) && empty($phone)) { $this->error = '邮箱和手机不能同时为空'; return false; } if (!empty($email)) { if (!IValidate::email($email)) { $this->error = '邮箱格式错误'; return false; } $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where email='" . $email . "' "); if (!empty($userinfo)) { $this->error = '邮箱已存在,不可注册'; return false; } } if (!empty($phone)) { if (!IValidate::suremobi($phone)) { $this->error = '手机格式错误'; return false; } $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $phone . "' "); if (!empty($userinfo)) { $this->error = '手机已存在,不可注册'; return false; } } if (!IValidate::len($tname, 3, 20)) { //$this->error = '用户名长度大于3小于20'.$tname; //return false; } if (!IValidate::len($password, 6, 20)) { $this->error = '密码长度大于6小于20'; return false; } $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where username='******' "); if (!empty($userinfo)) { //$this->error = '用户名已存在,不可注册'; //return false; } $arr['username'] = $tname; $arr['phone'] = $phone; $arr['address'] = $address; $arr['password'] = md5($password); $arr['email'] = $email; $arr['creattime'] = time(); $arr['score'] = $score == 0 ? Mysite::$app->config['regesterscore'] : $score; $arr['logintime'] = time(); $arr['logo'] = $userlogo; $arr['loginip'] = IClient::getIp(); $arr['group'] = $group; $arr['cost'] = $cost; $arr['parent_id'] = intval(ICookie::get('logincode')); $this->mysql->insert(Mysite::$app->config['tablepre'] . 'member', $arr); $this->uid = $this->mysql->insertid(); if ($arr['score'] > 0) { $this->addlog($this->uid, 1, 1, $arr['score'], '注册送积分', '注册送积分' . $arr['score'], $arr['score']); } $logintype = ICookie::get('adlogintype'); $token = ICookie::get('adtoken'); $openid = ICookie::get('adopenid'); if (!empty($logintype)) { $apiinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "otherlogin where loginname='" . $logintype . "' "); if (!empty($apiinfo)) { //更新 $tempuid = $this->uid; $this->mysql->update(Mysite::$app->config['tablepre'] . 'oauth', array('uid' => $tempuid), "openid='" . $openid . "' and type = '" . $logintype . "'"); ICookie::set('logintype', $logintype, 86400); } } if (Mysite::$app->config['regester_juan'] == 1) { //注册送优惠券 $nowtime = time(); $endtime = $nowtime + Mysite::$app->config['regester_juanday'] * 24 * 60 * 60; $juandata['card'] = $nowtime . rand(100, 999); $juandata['card_password'] = substr(md5($juandata['card']), 0, 5); $juandata['status'] = 1; // 状态,0未使用,1已绑定,2已使用,3无效 $juandata['creattime'] = $nowtime; // 制造时间 $juandata['cost'] = Mysite::$app->config['regester_juancost']; // 优惠金额 $juandata['limitcost'] = Mysite::$app->config['regester_juanlimit']; // 购物车限制金额下限 $juandata['endtime'] = $endtime; // 失效时间 $juandata['uid'] = $this->uid; // 用户ID $juandata['username'] = $arr['username']; // 用户名 $juandata['name'] = '注册账号赠送优惠券'; // 优惠券名称 $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata); } return true; }
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; }
function starttask() { $taskid = IReq::get('taskid'); $taskinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "task where id='" . $taskid . "' "); if (empty($taskinfo)) { echo '任务不存在'; exit; } if ($taskinfo['status'] > 1) { echo '任务执行完毕,请关闭窗口'; exit; } $data = array('taskmiaoshu' => ''); //执行任务 if ($taskinfo['tasktype'] == 1) { $emailids = ''; //邮箱ID集 $newdata = array(); //任务处理数据 $data['taskmiaoshu'] .= '邮件群发任务'; if ($taskinfo['taskusertype'] == 1) { // echo '根据用户表筛选查询'.$taskinfo['tasklimit'];//tasklimit //构造默认查询 $where = ' where uid > ' . $taskinfo['start_id'] . ' ' . $taskinfo['tasklimit']; //start_id;//起点UID $memberlist = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "member " . $where . " order by uid asc limit 0, 10"); $startid = $taskinfo['start_id']; if (count($memberlist) > 9) { foreach ($memberlist as $key => $value) { if (IValidate::email($value['email'])) { $emailids .= empty($emailids) ? $value['email'] : ',' . $value['email']; } $startid = $value['uid']; } } if (count($memberlist) < 10) { //更新任务执行完毕 $newdata['status'] = 2; $data['taskmiaoshu'] .= ',执行完毕'; } else { // $newdata['status'] = 1; $newdata['start_id'] = $startid; //更新下一页 $data['taskmiaoshu'] .= ',从用户表uid为' . $taskinfo['start_id'] . '执行到uid为' . $startid; } //更新任务 } else { $tasklimit = $taskinfo['tasklimit']; $checklist = explode(',', $tasklimit); foreach ($checklist as $key => $value) { if (IValidate::email($value)) { $emailids .= empty($emailids) ? $value : ',' . $value; } } $newdata['status'] = 2; //更新任务 $data['taskmiaoshu'] .= ',根据指定邮箱地址发送邮件完成'; } //更新任务 $this->mysql->update(Mysite::$app->config['tablepre'] . 'task', $newdata, "id='" . $taskid . "'"); if (!empty($emailids)) { $smtp = new ISmtp(Mysite::$app->config['smpt'], 25, Mysite::$app->config['emailname'], Mysite::$app->config['emailpwd'], false); //$content = iconv('utf-8','gb2312',$content); $info = $smtp->send($emailids, Mysite::$app->config['emailname'], $taskinfo['taskname'], $taskinfo['content'], "", "HTML", "", ""); } $data['taskdata'] = $newdata; $data['showcontent'] = $emailids; } else { $emailids = ''; //邮箱ID集 $newdata = array(); //任务处理数据 $data['taskmiaoshu'] .= '短信群发任务'; if ($taskinfo['taskusertype'] == 1) { // echo '根据用户表筛选查询'.$taskinfo['tasklimit'];//tasklimit //构造默认查询 $where = ' where uid > ' . $taskinfo['start_id'] . ' ' . $taskinfo['tasklimit']; //start_id;//起点UID $memberlist = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "member " . $where . " order by uid asc limit 0, 10"); $startid = $taskinfo['start_id']; if (count($memberlist) > 9) { foreach ($memberlist as $key => $value) { if (IValidate::suremobi($value['phone'])) { $emailids .= empty($emailids) ? $value['phone'] : ',' . $value['phone']; } $startid = $value['uid']; } } if (count($memberlist) < 10) { //更新任务执行完毕 $newdata['status'] = 2; $data['taskmiaoshu'] .= ',执行完毕'; } else { // $newdata['status'] = 1; $newdata['start_id'] = $startid; //更新下一页 $data['taskmiaoshu'] .= ',从用户表uid为' . $taskinfo['start_id'] . '执行到uid为' . $startid; } //更新任务 } else { $tasklimit = $taskinfo['tasklimit']; $checklist = explode(',', $tasklimit); foreach ($checklist as $key => $value) { if (IValidate::suremobi($value)) { $emailids .= empty($emailids) ? $value : ',' . $value; } } $newdata['status'] = 2; //更新任务 $data['taskmiaoshu'] .= ',根据指定手机号发送短信完成'; } //更新任务 $data['showcontent'] = $emailids; if (!empty($emailids)) { $sendmobile = new mobile(); /* $checklogin = $sendmobile->login(); if($checklogin == 'ok') { */ $emailids = explode(',', $emailids); $chekcinfo = $sendmobile->sendsms($emailids, $taskinfo['content']); if ($chekcinfo == 'ok') { //发送成功 //更新任务 $this->mysql->update(Mysite::$app->config['tablepre'] . 'task', $newdata, "id='" . $taskid . "'"); } else { $data['taskmiaoshu'] .= ',短信发送失败,错误代码:' . $chekcinfo; } /* $sendmobile->endsend(); }else{ $data['taskmiaoshu'] .= ',短信发送失败,错误代码:'.$checklogin; } */ } $data['taskdata'] = $newdata; } Mysite::$app->setdata($data); }
function setphone() { $checksend = Mysite::$app->config['ordercheckphone']; if ($checksend == 1) { if (!empty($this->member['uid'])) { echo 'removesend()'; exit; } $phone = IFilter::act(IReq::get('phone')); if (IValidate::suremobi($phone)) { $checkphone = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "mobile where phone ='" . $phone . "' order by addtime desc limit 0,50"); if (!empty($checkphone)) { if ($checkphone['is_send'] == 1) { echo 'removesend()'; exit; } $bijiaotime = time() - 180; if ($checkphone['addtime'] > $bijiaotime) { //验证码还有效 $backtime = 180 - (time() - $checkphone['addtime']); ICookie::set('phonecode', $checkphone['code'], $backtime); echo 'showsend(\'' . $phone . '\',' . $backtime . ')'; exit; } } //重新发送验证码 $data['code'] = mt_rand(10000, 99999); $data['phone'] = $phone; $data['addtime'] = time(); $data['is_send'] = 0; ICookie::set('phonecode', $data['code'], 180); /*调用发送*/ /* usercodetpl*/ $default_tpl = new config('tplset.php', hopedir); $tpllist = $default_tpl->getInfo(); if (!isset($tpllist['usercodetpl']) || empty($tpllist['usercodetpl'])) { // logwrite('短信发送商家模板加载失败'); echo 'alert(\'发送失败,请联系管理员设置模板\')'; exit; } else { $sendmobile = new mobile(); $tempdata['code'] = $data['code']; $tempdata['sitename'] = Mysite::$app->config['sitename']; $contents = Mysite::$app->statichtml($tpllist['usercodetpl'], $tempdata); if (Mysite::$app->config['smstype'] == 2) { //139邮箱转发短信 //使用sms10086cn发送/ $APIServer = 'http://www.sms-10086.cn/Service.asmx/sendsms?'; $weblink = $APIServer . 'zh=' . trim(Mysite::$app->config['sms86ac']) . '&mm=' . trim(Mysite::$app->config['sms86pd']) . '&hm=' . $phone . '&nr=' . urlencode($contents) . '&dxlbid=27'; $contentcccc = file_get_contents($weblink); logwrite('验证短信发送:' . $contentcccc); } else { //使用sms10086cn发送/ $phoneids = array(); $phoneids[] = $phone; $chekcinfo = $sendmobile->sendsms($phoneids, $contents); logwrite('验证短信发送:' . $chekcinfo); } } $this->mysql->insert(Mysite::$app->config['tablepre'] . 'mobile', $data); echo 'showsend(\'' . $phone . '\',180)'; exit; } else { echo 'alert(\'不是手机号\')'; exit; } } else { echo ''; exit; } }
function loginbycode() { $uname = IFilter::act(IReq::get('uname')); $code = IFilter::act(IReq::get('code')); $link = IUrl::creatUrl('member/login'); $logincode = intval(IFilter::act(IReq::get('logincode'))); if (!empty($logincode)) { ICookie::set('logincode', $logincode, 86400 * 365); } if (empty($uname)) { $this->message('手机不能为空', $link); exit; } if (empty($code)) { $this->message('验证码不能为空', $link); exit; } $logintype = IFilter::act(IReq::get('logintype')); if (!IValidate::suremobi($uname)) { $this->message('联系手机格式错误'); } //$checkcode = ICookie::get('regphonecode'); $res = $this->mobilecodecheck($uname, $code); if ($res['success'] == 'no') { $this->message($res['msg']); } //if($code != $checkcode) $this->message('手机验证码错误'); if (!$this->memberCls->login($uname, $pwd = "", $code = true)) { $this->message($this->memberCls->ero(), $link); } $link = IUrl::creatUrl('member/base'); $this->success('', $link); }
function guestorderlist() { $this->setstatus(); $phone = IFilter::act(IReq::get('phone')); $link = IUrl::creatUrl('order/guestorder'); $Captcha = IFilter::act(IReq::get('Captcha')); $type = IFilter::act(IReq::get('type')); if (Mysite::$app->config['allowedcode'] == 1) { if ($Captcha != ICookie::get('Captcha')) { $this->message('验证码错误', $link); } } if (!IValidate::suremobi($phone)) { $this->message('请录入正确的手机号码'); } $data['phone'] = $phone; $data['Captcha'] = $Captcha; $data['where'] = ' buyerphone = \'' . $phone . '\''; $data['where'] .= empty($type) ? ' and shoptype=0' : ' and shoptype=1'; $data['type'] = $type; Mysite::$app->setdata($data); }
function sendmess($orderid) { $smtp = new ISmtp(Mysite::$app->config['smpt'], 25, Mysite::$app->config['emailname'], Mysite::$app->config['emailpwd'], false); $sendmobile = new mobile(); $wx_s = new wx_s(); $orderinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "order where id= '" . $orderid . "' "); $orderdet = $this->mysql->getarr("select * from " . Mysite::$app->config['tablepre'] . "orderdet where order_id= '" . $orderid . "' "); $shopinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where id= '" . $orderinfo['shopid'] . "' "); $tempdata = array('orderinfo' => $orderinfo, 'orderdet' => $orderdet, 'sitename' => Mysite::$app->config['sitename']); $contents = ''; $checknotice = isset($shopinfo['noticetype']) ? explode(',', $shopinfo['noticetype']) : array(); $contents = ''; $appcheck = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "applogin where uid = '" . $orderinfo['shopuid'] . "' "); if (!empty($appcheck)) { /* $appCls = new appclass(); $backinfo = $appCls->sendmsg($appcheck['userid'],$appcheck['channelid'],Mysite::$app->config['sitename'].'订单提醒','您有新的订单,单号:'.$orderinfo['dno'],$messagetype=1); logwrite('APP发送:'.$backinfo);*/ } if (in_array(1, $checknotice)) { if (Mysite::$app->config['allowedsendshop'] == 1) { if (IValidate::suremobi($orderinfo['shopphone'])) { $default_tpl = new config('tplset.php', hopedir); $tpllist = $default_tpl->getInfo(); if (!isset($tpllist['shopphonetpl']) || empty($tpllist['shopphonetpl'])) { // logwrite('短信发送商家模板加载失败'); } else { $contents = Mysite::$app->statichtml($tpllist['shopphonetpl'], $tempdata); if (Mysite::$app->config['smstype'] == 2) { //139邮箱转发短信 //使用sms10086cn发送/ $APIServer = 'http://www.sms-10086.cn/Service.asmx/sendsms?'; $weblink = $APIServer . 'zh=' . trim(Mysite::$app->config['sms86ac']) . '&mm=' . trim(Mysite::$app->config['sms86pd']) . '&hm=' . $orderinfo['shopphone'] . '&nr=' . urlencode($contents) . '&dxlbid=27'; $contentcccc = file_get_contents($weblink); logwrite('短信sms10086cn发送结果:' . $contentcccc); } else { //使用sms10086cn发送/ $phoneids = array(); $phoneids[] = $orderinfo['shopphone']; $chekcinfo = $sendmobile->sendsms($phoneids, $contents); logwrite('亿美短信接口发送结果:' . $chekcinfo); } } } else { logwrite('短信发送商家' . $shopinfo['shopname'] . '联系电话错误'); } } } if (in_array(3, $checknotice)) { $wechat = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop_wechat where shopid=" . $orderinfo['shopid']); $wx_s = array(); if (!empty($wechat)) { $wx_s = new wx_s($wechat['token'], $wechat['appid'], $wechat['secret'], $orderinfo['shopid']); } if (!empty($orderinfo['shopuid']) && !empty($wechat)) { $wechat = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop_wechat where shopid=" . $orderinfo['shopid']); //if (!empty($wechat)) { //$wx_s = new wx_s($wechat['token'], $wechat['appid'], $wechat['secret'],$orderinfo['shopid']); //找到要发送的商户微信openid $openid_list = $this->mysql->getarr("select openid from " . Mysite::$app->config['tablepre'] . "shop_wxuser where shopid=" . $orderinfo['shopid'] . " and is_merchant=1"); $payarrr = array('outpay' => '到付', 'open_acout' => '余额支付'); $orderpastatus = $orderinfo['paystatus'] == 1 ? '已支付' : '未支付'; $orderpaytype = isset($payarrr[$orderinfo['paytype']]) ? $payarrr[$orderinfo['paytype']] : '在线支付'; $tempdata = array('orderinfo' => $orderinfo, 'orderdet' => $orderdet, 'sitename' => Mysite::$app->config['sitename']); $temp_content = $orderinfo['buyername'] . '在' . Mysite::$app->config['sitename'] . '下单成功' . '\\n'; $temp_content .= '下单时间:' . date('m-d H:i', $orderinfo['addtime']) . '\\n'; $temp_content .= '配送时间:' . date('m-d H:i', $orderinfo['posttime']) . '\\n'; $temp_content .= '支付方式' . $orderpaytype . ',' . $orderpastatus . ' ' . '\\n'; $temp_content .= '收货人:' . $orderinfo['buyername'] . '\\n'; $temp_content .= '地址:' . $orderinfo['buyeraddress'] . '\\n'; $temp_content .= '联系电话:' . $orderinfo['buyerphone'] . '\\n'; $temp_content .= '单号:' . $orderinfo['dno'] . '\\n'; $temp_content .= '总价:' . $orderinfo['allcost'] . '元,配送费:' . $orderinfo['shopps'] . '元\\n'; $temp_content .= '备注:' . $orderinfo['content'] . '\\n'; foreach ($orderdet as $km => $vc) { $temp_content .= $vc['goodsname'] . '(' . $vc['goodscount'] . '份)\\n'; } if (!empty($openid_list)) { if (!empty($temp_content)) { foreach ($openid_list as $key => $value) { if ($wx_s->sendmsg($temp_content, $value['openid'])) { } else { logwrite('微信客服发送错误:' . $wx_s->err()); } } } } //} //$wxshop = $this->mysql->select_one("select * from ".Mysite::$app->config['tablepre']."wxuser where uid= '".$orderinfo['shopuid']."' "); /*if(!empty($wxshop)){ $payarrr = array('outpay'=>'到付','open_acout'=>'余额支付'); $orderpastatus = $orderinfo['paystatus'] == 1?'已支付':'未支付'; $orderpaytype = isset($payarrr[$orderinfo['paytype']])?$payarrr[$orderinfo['paytype']]:'在线支付'; $tempdata = array('orderinfo'=>$orderinfo,'orderdet'=>$orderdet,'sitename'=>Mysite::$app->config['sitename']); $temp_content = $orderinfo['buyername'].'在'.Mysite::$app->config['sitename'].'下单成功'.'\n'; $temp_content .='下单时间:'.date('m-d H:i',$orderinfo['addtime']).'\n'; $temp_content .='配送时间:'.date('m-d H:i',$orderinfo['posttime']).'\n'; $temp_content .='支付方式'.$orderpaytype.','.$orderpastatus.' '.'\n'; $temp_content .='收货人:'.$orderinfo['buyername'].'\n'; $temp_content .='地址:'.$orderinfo['buyeraddress'].'\n'; $temp_content .='联系电话:'.$orderinfo['buyerphone'].'\n'; $temp_content .='单号:'.$orderinfo['dno'].'\n'; $temp_content .='总价:'.$orderinfo['allcost'].'元,配送费:'.$orderinfo['shopps'].'元\n'; $temp_content .='备注:'.$orderinfo['content'].'\n'; foreach($orderdet as $km=>$vc){ $temp_content .=$vc['goodsname'].'('.$vc['goodscount'].'份)\n'; } //增加超连接 $time = time(); $tempstr = md5(Mysite::$app->config['wxtoken'].$time); $tempstr = substr($tempstr,3,15); $dolink = Mysite::$app->config['siteurl'].'/index.php?controller=wxsite&action=shopshoworder&id='.$orderinfo['id']; $backinfo = ''; if(!empty($dolink)){ $templink = $dolink; for($i=0;$i<strlen($templink);$i++){ $backinfo .= ord($templink[$i]).','; } } $linkstr = Mysite::$app->config['siteurl'].'/index.php?controller=wxsite&action=index&openid='.$wxshop['openid'].'&actime='.$time.'&sign='.$tempstr.'&backinfo='.$backinfo; $temp_content .= '<a href=\''.trim($linkstr).'\'>查看详情</a>'; if(!empty($temp_content)){ $wx_s = new wx_s($wechat['token'], $wechat['appid'], $wechat['secret'],$orderinfo['shopid']); if($wx_s->sendmsg($temp_content,$wxshop['openid'])){ }else{ logwrite('微信客服发送错误:'.$wx_s->err()); } } }*/ } if (!empty($orderinfo['buyeruid']) && !empty($wechat)) { //2015-06-25查不到$shopid把$shopid改成$shopinfo['id'] $wxbuyer = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop_wxuser where shopid='" . $shopinfo['id'] . "' and uid= '" . $orderinfo['buyeruid'] . "' "); if (!empty($wxbuyer)) { if (empty($contents)) { $default_tpl = new config('tplset.php', hopedir); $tpllist = $default_tpl->getInfo(); if (!isset($tpllist['shopphonetpl']) || empty($tpllist['shopphonetpl'])) { } else { $contents = Mysite::$app->statichtml($tpllist['userbuytpl'], $tempdata); } } if (!empty($contents)) { /*$time = time(); $tempstr = md5(Mysite::$app->config['wxtoken'].$time); $tempstr = substr($tempstr,3,15); $dolink = Mysite::$app->config['siteurl'].'/index.php?controller=wxsite&action=ordershow&orderid='.$orderinfo['id']; $backinfo = ''; if(!empty($dolink)){ $templink = $dolink; for($i=0;$i<strlen($templink);$i++){ $backinfo .= ord($templink[$i]).','; } } // $backinfo = str_replace(array('"',',','&'),array('-','^','@'),json_encode($dolink)); //shopshoworder $linkstr = Mysite::$app->config['siteurl'].'/index.php?controller=wxsite&action=index&openid='.$wxbuyer['openid'].'&actime='.$time.'&sign='.$tempstr.'&backinfo='.$backinfo; $contents .= '<a href=\''.trim($linkstr).'\'>查看详情</a>';*/ if ($wx_s->sendmsg($contents, $wxbuyer['openid'])) { } else { logwrite('微信客服发送错误:' . $wx_s->err()); } } } } } if (!empty($shopinfo['machine_code']) && !empty($shopinfo['mKey'])) { $payarrr = array('outpay' => '到付', 'open_acout' => '余额支付'); $orderpastatus = $orderinfo['paystatus'] == 1 ? '已支付' : '未支付'; $orderpaytype = isset($payarrr[$orderinfo['paytype']]) ? $payarrr[$orderinfo['paytype']] : '在线支付'; $temp_content = ''; foreach ($orderdet as $km => $vc) { $temp_content .= $vc['goodsname'] . '(' . $vc['goodscount'] . '份) \\n '; } $msg = '商家:' . $shopinfo['shopname'] . ' 订餐热线:' . Mysite::$app->config['litel'] . ' 订单状态:' . $orderpaytype . ',(' . $orderpastatus . ') 姓名:' . $orderinfo['buyername'] . ' 电话:' . $orderinfo['buyerphone'] . ' 地址:' . $orderinfo['buyeraddress'] . ' 下单时间:' . date('m-d H:i', $orderinfo['addtime']) . ' 配送时间:' . date('m-d H:i', $orderinfo['posttime']) . ' ******************************* ' . $temp_content . ' ******************************* 配送费:' . $orderinfo['shopps'] . '元 合计:' . $orderinfo['allcost'] . '元 ※※※※※※※※※※※※※※ 谢谢惠顾,欢迎下次光临 订单编号' . $orderinfo['dno'] . ' 备注' . $orderinfo['content'] . ' '; $this->dosengprint($msg, $shopinfo['machine_code'], $shopinfo['mKey']); } if (in_array(2, $checknotice)) { //同时使用邮件通知 if (Mysite::$app->config['noticeshopemail'] == 1) { //同时使用邮件通知 if (IValidate::email($shopinfo['email'])) { $default_tpl = new config('tplset.php', hopedir); $tpllist = $default_tpl->getInfo(); if (!isset($tpllist['emailorder']) || empty($tpllist['emailorder'])) { logwrite('邮件发送商家模板加载失败'); } else { //surelink //算方计算 $time = time(); $tempstr = md5($orderinfo['dno'] . $time); $tempstr = substr($tempstr, 3, 15); $tempstr = md5($orderinfo['shopuid'] . $tempstr); $tempstr = substr($tempstr, 3, 15); $tempdata['surelink'] = Mysite::$app->config['siteurl'] . '/index.php?controller=site&action=makeshow&id=' . $orderinfo['id'] . '&actime=' . $time . '&sign=' . $tempstr . '&status=1'; $tempdata['closelink'] = Mysite::$app->config['siteurl'] . '/index.php?controller=site&action=makeshow&id=' . $orderinfo['id'] . '&actime=' . $time . '&sign=' . $tempstr . '&status=2'; $emailcontent = Mysite::$app->statichtml($tpllist['emailorder'], $tempdata); $title = '您有一笔' . Mysite::$app->config['sitename'] . '新订单,请尽快处理'; $info = $smtp->send($shopinfo['email'], Mysite::$app->config['emailname'], $title, $emailcontent, "", "HTML", "", ""); } } else { logwrite('商家' . $shopinfo['shopname'] . '邮箱地址' . $shopinfo['shopemail'] . '错误'); } } } $contents = ''; if (Mysite::$app->config['allowedsendbuyer'] == 1) { if (IValidate::suremobi($orderinfo['buyerphone'])) { $default_tpl = new config('tplset.php', hopedir); $tpllist = $default_tpl->getInfo(); if (!isset($tpllist['userbuytpl']) || empty($tpllist['userbuytpl'])) { logwrite('短信发送会员模版失败'); } else { $contents = Mysite::$app->statichtml($tpllist['userbuytpl'], $tempdata); if (Mysite::$app->config['smstype'] == 2) { //139邮箱转发短信 //使用sms10086cn发送 $APIServer = 'http://www.sms-10086.cn/Service.asmx/sendsms?'; $weblink = $APIServer . 'zh=' . trim(Mysite::$app->config['sms86ac']) . '&mm=' . trim(Mysite::$app->config['sms86pd']) . '&hm=' . $orderinfo['buyerphone'] . '&nr=' . urlencode($contents) . '&dxlbid=27'; $contentcccc = file_get_contents($weblink); logwrite('短信sms10086cn发送结果:' . $contentcccc); } else { //使用sms10086cn发送 $phoneids = array(); $phoneids[] = $orderinfo['buyerphone']; $chekcinfo = $sendmobile->sendsms($phoneids, $contents); logwrite('亿美短信接口发送结果:' . $chekcinfo); } logwrite($contents); } } } }
function saveGustAddress() { $username = trim(IFilter::act(IReq::get('username'))); $mobile = intval(IFilter::act(IReq::get('mobile'))); $addressdet = trim(IFilter::act(IReq::get('addressdet'))); if (!IValidate::suremobi($mobile)) { echo json_encode(array('success' => 'error', 'msg' => '请输入正确的手机号')); exit; } $value = serialize(array("username" => $username, "mobile" => $mobile, "addressdet" => $addressdet)); $res = setcookie("gustAddress", $value, time() + 31536000); if ($res) { echo json_encode(array('success' => 'yes', 'msg' => '保存成功')); exit; } }