/** * 发送邮件 */ public function send($limit = 5) { $this->clear(); //根据优先级排序获取 $mails = $this->where(array('lock_expiry' => array('lt', time())))->order('priority DESC,id,err_num')->limit($limit)->select(); if (!$mails) { return false; } //增加一次发送错误并且把锁定时间延长避免多个发送请求冲突 $qids = array(); foreach ($mails as $_mail) { $qids[] = $_mail['id']; } $this->where(array('id' => array('in', $qids)))->save(array('err_num' => array('exp', 'err_num+1'), 'lock_expiry' => array('exp', 'lock_expiry+' . $this->_send_lock))); //发送 $mailer = mailer::get_instance(); foreach ($mails as $_mail) { if ($mailer->send($_mail['mail_to'], $_mail['mail_subject'], $_mail['mail_body'])) { //删除队列 $this->delete($_mail['id']); } else { //失败暂不处理 } } }
public function ajax_mail_test() { $email = $this->_get('email', 'trim'); !$email && $this->ajaxReturn(0); //发送 $mailer = mailer::get_instance(); if ($mailer->send($email, L('send_test_email_subject'), L('send_test_email_body'))) { $this->ajaxReturn(1); } else { $this->ajaxReturn(0); } }
public function ajax_mail_test() { $email = $this->_get('email', 'trim'); !$email && $this->ajaxReturn(0); //发送 $mailer = mailer::get_instance(); if ($mailer->send($email, '这是一封测试邮件', '这是一封飞天侠秒杀程序自动发送的测试邮件')) { $this->ajaxReturn(1); } else { $this->ajaxReturn(0); } }
public function ajax_mail_test() { $email = $this->_get('email', 'trim'); !$email && $this->ajaxReturn(0); //发送 $mailer = mailer::get_instance(); if ($mailer->send($email, '这是一封测试邮件', '您好,此邮件由杨他他淘宝客皮卷淘宝客程序系统发送,请勿回复,收到此邮件证明你的邮箱已配置正确,技术支持论坛:http://bbs.yangtata.com。感谢对杨他他论坛的支持!')) { $this->ajaxReturn(1); } else { $this->ajaxReturn(0); } }
public function pay() { if (IS_POST && count($_SESSION['cart']) > 0) { $_SESSION['end'] = 0; import('Think.ORG.Cart'); // 导入分页类 $cart = new Cart(); $user_address = M('user_address'); $item_order = M('item_order'); $order_detail = M('order_detail'); $item_goods = M('item'); $this->visitor->info['id']; //用户ID $this->visitor->info['username']; //用户账号 //生成订单号 $dingdanhao = date("Y-m-dH-i-s"); $dingdanhao = str_replace("-", "", $dingdanhao); $dingdanhao .= rand(1000, 2000); $time = time(); //订单添加时间 $address_options = $this->_post('address_options', 'intval'); //地址 0:刚填的地址 大于0历史的地址 $shipping_id = $this->_post('shipping_id', 'intval'); //配送方式 $postscript = $this->_post('postscript', 'trim'); //卖家留言 if (!empty($postscript)) { $data['note'] = $postscript; } if (empty($shipping_id)) { $data['freetype'] = 0; $data['order_sumPrice'] = $cart->getPrice(); } else { $data['freetype'] = $shipping_id; $data['freeprice'] = $this->getFree($shipping_id); //取到运费 $data['order_sumPrice'] = $cart->getPrice() + $this->getFree($shipping_id); //echo $cart->getPrice()+$this->getFree($shipping_id);exit; } $data['orderId'] = $dingdanhao; //订单号 $data['add_time'] = $time; //添加时间 $data['goods_sumPrice'] = $cart->getPrice(); //商品总额 $data['color'] = $cart->getColor(); //商品颜色 //$data['userId']=$this->visitor->info['id'];//用户ID //$data['userName']=$this->visitor->info['username'];//用户名 $data['userId'] = '123'; //用户ID $data['userName'] = '******'; //用户名 if ($address_options == 0) { $consignee = $this->_post('consignee', 'trim'); //真实姓名 $sheng = $this->_post('sheng', 'trim'); //省 $shi = $this->_post('shi', 'trim'); //市 $qu = $this->_post('qu', 'trim'); //区 $address = $this->_post('address', 'trim'); //详细地址 $phone_mob = $this->_post('phone_mob', 'trim'); //电话号码 $save_address = $this->_post('save_address', 'trim'); //是否保存地址 $data['address_name'] = $consignee; //收货人姓名 $data['mobile'] = $phone_mob; //电话号码 $data['address'] = $sheng . $shi . $qu . $address; //地址 if ($save_address) { $add_address['uid'] = $this->visitor->info['id']; $add_address['consignee'] = $consignee; $add_address['address'] = $address; $add_address['mobile'] = $phone_mob; $add_address['sheng'] = $sheng; $add_address['shi'] = $shi; $add_address['qu'] = $qu; $user_address->data($add_address)->add(); } } else { $userId = $this->visitor->info['id']; $address = $user_address->where("uid='{$userId}'")->find($address_options); //取到地址 $data['address_name'] = $address['consignee']; //收货人姓名 $data['mobile'] = $address['mobile']; //电话号码 $data['address'] = $address['sheng'] . $address['shi'] . $address['qu'] . $address['address']; //地址 } if ($orderid = $item_order->data($data)->add()) { $orders['orderId'] = $dingdanhao; foreach ($_SESSION['cart'] as $item) { $item_goods->where('id=' . $item['id'])->setDec('goods_stock', $item['num']); $orders['itemId'] = $item['id']; //商品ID $orders['title'] = $item['name']; //商品名称 $orders['img'] = $item['img']; //商品图片 $orders['price'] = $item['price']; //商品价格 $orders['quantity'] = $item['num']; //购买数量 $orders['color'] = $item['color']; //购买数量 $order_detail->data($orders)->add(); } $cart->clear(); //清空购物车 $payment_id = $_POST['payment_id']; $item_order = M('item_order')->where(" orderId='{$dingdanhao}'")->find(); !$item_order && $this->_404(); $title = '新订单' . $data['goods_sumPrice'] . '元'; $content = '您收到订单' . $dingdanhao . ',商品' . $orders['quantity'] . '件,总价格' . $data['goods_sumPrice'] . '元。购买者姓名:' . $consignee . '。收货人地址:' . $data['address']; $tips_data = M('setting')->where(" name='tips'")->find(); $emails = unserialize($tips_data['data']); if ($payment_id == 2) { $data['status'] = 2; $data['supportmetho'] = 2; $data['support_time'] = time(); if (M('item_order')->where("orderId='{$dingdanhao}'")->data($data)->save()) { $_SESSION['end'] = 1; if ($emails && !empty($emails)) { $mailer = mailer::get_instance(); $mailer->send($emails, $title, $content); } $this->redirect('Shopcart/index'); } else { $this->error('操作失败!'); } } elseif ($payment_id == 1) { $data['supportmetho'] = 1; $userId = $this->visitor->info['id']; if (M('item_order')->where("and orderId='{$dingdanhao}'")->data($data)->save()) { $alipay = M('alipay')->find(); echo "<script>location.href='api/wapalipay/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $dingdanhao . "&WIDsubject=" . $dingdanhao . "&WIDtotal_fee=" . $item_order['order_sumPrice'] . "'</script>"; } else { $this->error('操作失败!'); } } else { $this->error('操作失败!'); } $this->assign('orderid', $orderid); //订单ID $this->assign('dingdanhao', $dingdanhao); //订单号 $this->assign('order_sumPrice', $data['order_sumPrice']); } else { $this->error('生成订单失败!'); } } else { if (isset($_GET['orderId'])) { $item_order = M('item_order'); $orderId = $_GET['orderId']; //订单号 $userId = $this->visitor->info['id']; $orders = $item_order->where("userId='{$userId}' and orderId='{$orderId}'")->find(); if (!is_array($orders)) { $this->_404(); } if (empty($orders['supportmetho'])) { $this->assign('orderid', $orders['id']); //订单ID $this->assign('dingdanhao', $orders['orderId']); //订单号 $this->assign('order_sumPrice', $orders['order_sumPrice']); } else { $alipay = M('alipay')->find(); echo "<script>location.href='api/wapalipay/alipayapi.php?WIDseller_email=" . $alipay['alipayname'] . "&WIDout_trade_no=" . $orderId . "&WIDsubject=" . $orderId . "&WIDtotal_fee=" . $orders['order_sumPrice'] . "'</script>"; exit; } } else { $this->redirect('Index/index?m=Item&a=index&id=127'); } } $this->display(); }