|
@@ -158,14 +158,23 @@ class Manage extends Auth
|
|
|
$id = Dever::input('order_id');
|
|
|
$order = Dever::db('order', 'seller')->find($id);
|
|
|
|
|
|
+ /*
|
|
|
$code = Dever::load('manage', 'seller')->kmPwd($order['id'], $order['cdate']);
|
|
|
if ($code != $value) {
|
|
|
Dever::error('密码错误');
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if (!$value) {
|
|
|
+ Dever::error('请输入正确的邮箱');
|
|
|
+ }
|
|
|
+ if (!preg_match(Dever::rule('email'), $value)) {
|
|
|
+ Dever::error('请输入正确的邮箱');
|
|
|
}
|
|
|
|
|
|
$result = array();
|
|
|
$result['msg'] = '提取成功';
|
|
|
- $result['url'] = Dever::url('seller/manage.tqKmAct', array('order_id' => $order['id'], 'value' => $value));
|
|
|
+ //$result['url'] = Dever::url('seller/manage.tqKmAct', array('order_id' => $order['id'], 'value' => $value));
|
|
|
+ \Dever\Helper\Cmd::run('seller/manage.tqKmAct', array('order_id' => $order['id'], 'value' => $value));
|
|
|
|
|
|
# 增加提取日志
|
|
|
$log['seller_id'] = $order['seller_id'];
|
|
@@ -173,6 +182,7 @@ class Manage extends Auth
|
|
|
$log['admin_id'] = $this->uid;
|
|
|
$log['system_id'] = $this->system['id'];
|
|
|
$log['admin_name'] = $this->user['name'];
|
|
|
+ $log['email'] = $value;
|
|
|
|
|
|
Dever::db('order_km', 'seller')->insert($log);
|
|
|
return $result;
|
|
@@ -189,13 +199,58 @@ class Manage extends Auth
|
|
|
}
|
|
|
|
|
|
$code = Dever::load('manage', 'seller')->kmPwd($order[0]['id'], $order[0]['cdate']);
|
|
|
+ /*
|
|
|
if ($code != $value) {
|
|
|
Dever::error('密码错误');
|
|
|
}
|
|
|
-
|
|
|
- $order = Dever::db('order', 'seller')->select($id);
|
|
|
+ */
|
|
|
$data = Dever::load('manage', 'seller')->outKm(array('body' => $order));
|
|
|
|
|
|
- Dever::load('export', 'excel')->act($data['body'], $data['head'], '导出卡密', 0, '', false, false, $code);
|
|
|
+ $file = Dever::load('export', 'excel')->act($data['body'], $data['head'], '导出卡密', 0, '', false, false, $code, 'km' . $id);
|
|
|
+
|
|
|
+ $seller = Dever::db('info', 'seller')->find($order[0]['seller_id']);
|
|
|
+ $email = $value;
|
|
|
+ $username = $seller['name'];
|
|
|
+ $title = '您有新的卡密请查收';
|
|
|
+ $content = '请您打开附件提取卡密,提取密码请联系商务人员';
|
|
|
+ $this->send($email, $username, $title, $content, $file);
|
|
|
+ Dever::db('info', 'seller')->update($seller['id'], array('email' => $value));
|
|
|
+ return '卡密提取成功';
|
|
|
+ }
|
|
|
+
|
|
|
+ # 发送邮件
|
|
|
+ public function send($email, $username, $title, $content, $file = '')
|
|
|
+ {
|
|
|
+ $config = Dever::config('setting')['email'];
|
|
|
+
|
|
|
+ Dever::apply('PHPMailer', 'email', 'src');
|
|
|
+ Dever::apply('Exception', 'email', 'src');
|
|
|
+ Dever::apply('SMTP', 'email', 'src');
|
|
|
+ $mail = new \PHPMailer\PHPMailer\PHPMailer();
|
|
|
+
|
|
|
+ $mail->isSMTP();
|
|
|
+ //$mail->SMTPDebug = 2;
|
|
|
+ $mail->CharSet = 'UTF-8';
|
|
|
+ $mail->Host = $config['smtp'];
|
|
|
+ $mail->Port = 465;
|
|
|
+ $mail->SMTPSecure = 'ssl';
|
|
|
+ $mail->SMTPAuth = true;
|
|
|
+ $mail->Username = $config['username'];
|
|
|
+ $mail->Password = $config['password'];
|
|
|
+ $mail->setFrom($config['from'][0], 'API充值系统');
|
|
|
+ $mail->addAddress($email, $username);
|
|
|
+ $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?=";
|
|
|
+ $mail->Body = $content;
|
|
|
+ $mail->isHTML(true);
|
|
|
+ if ($file) {
|
|
|
+ $mail->addAttachment($file);
|
|
|
+ }
|
|
|
+ if (!$mail->send()) {
|
|
|
+ Dever::log($email . '-' . $username . '-' . $mail->ErrorInfo, 'email');
|
|
|
+ Dever::alert("Mailer Error: " . $mail->ErrorInfo);
|
|
|
+ } else {
|
|
|
+ @unlink($file);
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
}
|
|
|
}
|