/** * @brief 构造函数 */ public function __construct($paymentId = 0) { //同步回调地址 $this->callbackUrl = str_replace('plugins/', '', Url::fullUrlFormat("/payment/callback/payment_id/{$paymentId}")); //异步回调地址 $this->asyncCallbackUrl = str_replace('plugins/', '', Url::fullUrlFormat("/payment/async_callback/payment_id/{$paymentId}")); $this->paymentId = $paymentId; }
public function get_pic_url() { $this->apiModel = new ApiModel(); // 取得欢迎页面图片的URL $data = $this->apiModel->getWelPicUrl(); $url = $data['url']; Tiny::log($url); $retData = array("modifiedTime" => "", "imgUrl" => ""); if (isset($url)) { $picUrl = Url::fullUrlFormat("/{$url}"); Tiny::log($picUrl); $picTime = strtotime($data['last_update_time']); $time = date('YmdHis', $picTime); $retData["modifiedTime"] = $time; $retData["imgUrl"] = $picUrl; } // echo JSON::encode($retData,JSON_UNESCAPED_SLASHES); echo json_encode($retData, JSON_UNESCAPED_SLASHES); }
public function forget_act() { $email = Filter::sql(Req::args('email')); $model = $this->model->table('user'); $obj = $model->where("email = '" . $email . "'")->find(); if (!empty($obj)) { $model = $this->model->table('reset_password'); $obj = $model->where("email = '" . $email . "'")->find(); $safecode = md5(md5($email) . md5(CHash::random(32))); if (!empty($obj)) { $obj['safecode'] = $safecode; $model->data($obj)->update(); } else { $model->data(array('email' => $email, 'safecode' => $safecode))->add(); } $reset_url = Url::fullUrlFormat("/simple/reset_password/safecode/{$safecode}"); $msg_content = ''; $site_url = Url::fullUrlFormat('/'); $msg_title = '找回密码--' . $this->site_name; $msg_template_model = new Model("msg_template"); $msg_template = $msg_template_model->where('id=3')->find(); if ($msg_template) { $msg_content = str_replace(array('{$site_name}', '{$reset_url}', '{$site_url}', '{$current_time}'), array($this->site_name, $reset_url, $site_url, date('Y-m-d H:i:s')), $msg_template['content']); $msg_title = $msg_template['title']; } else { $msg_content .= '<p>亲爱的用户:</p>'; $msg_content .= '<p>感谢您注册' . $this->site_name . ',请点击以下链接重置您的密码。<br/><br/>'; $msg_content .= "<a href='{$reset_url}' target='_blank'>{$reset_url}</a><br/><br/>"; $msg_content .= '愿您在' . $this->site_name . '度过愉快的时光。<br/><br/>'; $msg_content .= "<a href='" . $site_url . "'>" . $this->site_name . "</a></p>"; } $mail = new Mail(); $flag = $mail->send_email($email, $msg_title, $msg_content); if ($flag) { $this->assign('status', 'success'); } else { $this->assign('status', 'error'); } } else { $this->assign('status', 'fail'); } $this->redirect('forget_result', false); }
public function order_status() { $parse_status = array('3' => '审核订单', '4' => '完成订单成功', '6' => '作废订单'); $id = Filter::int(Req::args("id")); $status = Req::args("status"); $admin_remark = Req::args("remark"); $model = new Model("order"); $order = $model->where("id={$id}")->find(); $flag = false; $info = array(); if ($order) { if ($status) { if ($order['status'] == 1 || $order['status'] == 2) { if ($status == 3 || $status == 6) { $flag = true; } /* S 二次开发 */ if ($status == 3) { //发送邮件 $user_id = $order['user_id']; $user_model = new Model('user'); $user = $user_model->where('id=' . $user_id)->find(); $order_url = Url::fullUrlFormat("/ucenter/order_detail/id/{$order['id']}"); $email_message_model = new Model('email_message'); $email_message = $email_message_model->where('`trigger`=2 and status=1')->find(); if ($email_message) { $body = str_replace(array('{$order_no}', '{$user_name}', '{$current_time}', '{$order_url}'), array($order['order_no'], $user['name'], date('Y-m-d H:i:s'), $order_url), $email_message['content']); $mail = new Mail(); $mail->send_email($user['email'], $email_message['title'], $body); } } /* E 二次开发*/ } if ($order['status'] == 3) { if ($status == 4 || $status == 6) { $flag = true; } if ($status == 4) { //货到付款的订单处理 $payment_plugin = Common::getPaymentInfo($order['payment']); if ($payment_plugin != null && $payment_plugin['class_name'] == 'received') { Order::updateStatus($order['order_no']); } //订单完成 $model_tem = new Model('order'); $model_tem->where("id={$id}")->data(array('delivery_status' => 2, 'status' => 4, 'completion_time' => date('Y-m-d H:i:s')))->update(); //允许评价 $model_tem = new Model('order as od'); $products = $model_tem->join('left join order_goods as og on od.id=og.order_id')->where('od.id=' . $id)->findAll(); foreach ($products as $product) { $data = array('goods_id' => $product['goods_id'], 'user_id' => $order['user_id'], 'order_no' => $product['order_no'], 'buy_time' => $product['create_time']); $model_tem->table('review')->data($data)->insert(); } } } if ($order['status'] == 4 && $status == 6) { $flag = true; } if ($flag) { $model->where("id={$id}")->data(array('status' => $status, 'admin_remark' => $admin_remark))->update(); $info = array('status' => 'success', 'msg' => $parse_status[$status]); } else { $info = array('status' => 'fail', 'msg' => $parse_status[$status]); } } else { $op = Req::args("op"); if ($op == 'note') { $model->where("id={$id}")->data(array('admin_remark' => $admin_remark))->update(); $info = array('status' => 'success', 'msg' => '备注'); } else { if ($op == 'del') { $model->where("id={$id}")->delete(); $info = array('status' => 'success', 'msg' => '删除'); } } } } else { $info = array('status' => 'fail', 'msg' => '不存在此订单'); } echo JSON::encode($info); }
public function submitUrl() { return Url::fullUrlFormat("/payment/pay_balance"); }
public static function updateStatus($orderNo, $payment_id = 0, $callback_info = null) { //SKM-ORDER-STATUS 这个方法得大改 $model = new Model("order"); $order = $model->where("order_no='" . $orderNo . "'")->find(); if (isset($callback_info['trade_no'])) { $trading_info = $callback_info['trade_no']; } else { $trading_info = ''; } if (empty($order)) { return false; } if ($order['pay_status'] == 1) { return $order['id']; } else { if ($order['pay_status'] == 0) { //更新订单信息 $data = array('status' => 3, 'pay_time' => date('Y-m-d H:i:s'), 'trading_info' => $trading_info, 'pay_status' => 1); //修改用户最后选择的支付方式 if ($payment_id != 0) { $data['payment'] = $payment_id; } else { $payment_id = $order['payment']; } //更新订单支付状态 $model->table("order")->data($data)->where("id=" . $order['id'])->update(); //SKM-SMS 支付成功 发送支付完成信息 $sms_inst = new Sms(); $orderNo = $order['order_no']; $text = "【全品电台】感谢您使用全品电台。您的订单 {$orderNo} 已经支付成功,我们将会在24小时内给您发货。"; $mobile = $order['mobile']; if ($mobile != "") { // 测试时 不发送SMS $sms_inst->sendSms($text, $mobile); } /* S 二次开发 */ //发送邮件 $order_url = Url::fullUrlFormat("/ucenter/order_detail/id/{$order['id']}"); $safebox = Safebox::getInstance(); $user = $safebox->get('user'); $email_message_model = new Model('email_message'); $email_message = $email_message_model->where('`trigger`=2 and status=1')->find(); if ($email_message) { $body = str_replace(array('{$order_no}', '{$user_name}', '{$current_time}', '{$order_url}'), array($orderNo, $user['name'], date('Y-m-d H:i:s'), $order_url), $email_message['content']); $mail = new Mail(); $mail->send_email($user['email'], $email_message['title'], $body); } /* E 二次开发 */ //商品中优惠券的处理 $products = $model->table("order_goods")->where("order_id=" . $order['id'])->findAll(); $goods_ids = array(); foreach ($products as $pro) { //SKM-ORDER-STATUS 添加捆绑促销的处理 if ($pro['prom_type'] == 'bundling') { // 添加 } else { $prom = unserialize($pro['prom_goods']); if (isset($prom['prom'])) { $prom_series = isset($prom['series']['prom']) ? $prom['series']['prom'] : null; $prom = $prom['prom']; //商品中优惠券的处理 if (isset($prom['type']) && $prom['type'] == 3 && $order['type'] == 0) { $voucher_template_id = $prom['expression']; $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find(); Common::paymentVoucher($voucher_template, $order['user_id']); //优惠券发放日志 } //二次开发部分 //系列中的优惠券 if (isset($prom_series['type']) && $prom_series['type'] == 3 && $order['type'] == 0) { $voucher_template_id = $prom_series['expression']; $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find(); Common::paymentVoucher($voucher_template, $order['user_id']); //优惠券发放日志 } } //更新货品中的库存信息 $goods_nums = $pro['goods_nums']; $product_id = $pro['product_id']; $model->table("products")->where("id=" . $product_id)->data(array('store_nums' => "`store_nums`-" . $goods_nums))->update(); $goods_ids[$pro['goods_id']] = $pro['goods_id']; } } //更新商品表里的库存信息 foreach ($goods_ids as $id) { $objs = $model->table('products')->fields('sum(store_nums) as store_nums')->where('goods_id=' . $id)->query(); if ($objs) { $num = $objs[0]['store_nums']; $model->table('goods')->data(array('store_nums' => $num))->where('id=' . $id)->update(); } } //普通订单的处理 foreach ($products as $pro) { //SKM-ORDER-STATUS 添加捆绑促销的处理 if ($pro['prom_type'] == 'bundling') { } else { if ($order['type'] == 0) { //订单优惠券活动事后处理 $prom = unserialize($order['prom']); if (!empty($prom) && $prom['type'] == 3) { $voucher_template_id = $prom['expression']; $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find(); Common::paymentVoucher($voucher_template, $order['user_id']); } } else { if ($order['type'] == 1) { //更新团购信息 $prom = unserialize($order['prom']); if (isset($prom['id'])) { $groupbuy = $model->table("groupbuy")->where("id=" . $prom['id'])->find(); if ($groupbuy) { $goods_num = $groupbuy['goods_num']; $order_num = $groupbuy['order_num']; $max_num = $groupbuy['max_num']; $end_time = $groupbuy['end_time']; $time_diff = time() - strtotime($end_time); foreach ($products as $pro) { $data = array('goods_num' => $goods_num + $pro['goods_nums'], 'order_num' => $order_num + 1); } if ($time_diff >= 0 || $max_num <= $data['goods_num']) { $data['is_end'] = 1; } $model->table("groupbuy")->where("id=" . $prom['id'])->data($data)->update(); } } } else { if ($order['type'] == 2) { //更新抢购信息 $prom = unserialize($order['prom']); if (isset($prom['id'])) { $flashbuy = $model->table("flash_sale")->where("id=" . $prom['id'])->find(); if ($flashbuy) { $goods_num = $flashbuy['goods_num']; $order_num = $flashbuy['order_num']; $max_num = $flashbuy['max_num']; $end_time = $flashbuy['end_time']; $time_diff = time() - strtotime($end_time); foreach ($products as $pro) { $data = array('goods_num' => $goods_num + $pro['goods_nums'], 'order_num' => $order_num + 1); } if ($time_diff >= 0 || $max_num <= $data['goods_num']) { $data['is_end'] = 1; } $model->table("flash_sale")->where("id=" . $prom['id'])->data($data)->update(); } } } } } } } //送积分 Pointlog::write($order['user_id'], $order['point'], '购买商品,订单:' . $order['order_no'] . ' 赠送' . $order['point'] . '积分'); //对使用代金券的订单,修改代金券的状态 if ($order['voucher_id']) { $model->table("voucher")->where("id=" . $order['voucher_id'])->data(array('status' => 1))->update(); } //生成收款单 $receivingData = array('order_id' => $order['id'], 'user_id' => $order['user_id'], 'amount' => $order['order_amount'], 'create_time' => date('Y-m-d H:i:s'), 'payment_time' => date('Y-m-d H:i:s'), 'doc_type' => 0, 'payment_id' => $payment_id, 'pay_status' => 1); $model->table("doc_receiving")->data($receivingData)->insert(); //统计会员规定时间内的消费金额,进行会员升级。 $config = Config::getInstance(); $config_other = $config->get('other'); $grade_days = isset($config_other['other_grade_days']) ? intval($config_other['other_grade_days']) : 365; $time = date("Y-m-d H:i:s", strtotime("-" . $grade_days . " day")); $obj = $model->table("doc_receiving")->fields("sum(amount) as amount")->where("user_id=" . $order['user_id'] . " and doc_type=0 and payment_time > '{$time}'")->query(); if (isset($obj[0])) { $amount = $obj[0]['amount']; $grade = $model->table('grade')->where('money < ' . $amount)->order('money desc')->find(); if ($grade) { $model->table('customer')->data(array('group_id' => $grade['id']))->where("user_id=" . $order['user_id'])->update(); } } return $order['id']; } else { return false; } } }
public function submitUrl() { return Url::fullUrlFormat("/payment/pay_received"); }
public function js() { $id = Filter::sql(Req::args("id")); $model = new Model("ad"); $time = date('Y-m-d'); $ad = $model->where("number = '{$id}' and start_time<='{$time}' and end_time >='{$time}'")->find(); if ($ad == null) { return; } if ($ad['is_open'] == 0) { return; } if ($ad['type'] != 5) { $ad['content'] = unserialize($ad['content']); } $str = ''; if ($ad['type'] == 1) { foreach ($ad['content'] as $key => $item) { if ($item['url']) { $str = '<a href="' . $item['url'] . '" target="_blank"><img src="' . Url::fullUrlFormat('@' . $item['path']) . '" title="' . $item['title'] . '"></a>'; } else { $str = '<img src="' . Url::fullUrlFormat('@' . $item['path']) . '" title="' . $item['title'] . '">'; } } } else { if ($ad['type'] == 2) { $str = ''; foreach ($ad['content'] as $key => $item) { if ($item['url']) { $str .= '<div style="background: url(' . Url::fullUrlFormat('@' . $item['path']) . ') no-repeat center top;height: ' . $ad['height'] . 'px;width: 100%;"><a href="' . $item['url'] . '" target="_blank" title="' . $item['title'] . '" style="height: ' . $ad['height'] . 'px;width: 100%;"></a></div>'; } else { $str .= '<div style="background: url(' . Url::fullUrlFormat('@' . $item['path']) . ') no-repeat center top;height: ' . $ad['height'] . 'px;width: 100%;"></div>'; } } $str = '<div id="slider-' . $ad['number'] . '" class="slider" style="margin-top:10px; height: ' . $ad['height'] . 'px;width: 100%;"><div style="width: 100%;">' . $str . '</div></div>'; } else { if ($ad['type'] == 3) { $content = $ad['content']; $str = '<a href="' . $content['url'] . '" style="color:' . $content['color'] . '" target="_blank">' . $content['title'] . '</a>'; } else { if ($ad['type'] == 4) { foreach ($ad['content'] as $key => $item) { if ($item['url']) { $str = '<a href="' . $item['url'] . '" target="_blank"><img src="' . Url::fullUrlFormat('@' . $item['path']) . '" title="' . $item['title'] . '"></a>'; } else { $str = '<img src="' . Url::fullUrlFormat('@' . $item['path']) . '" title="' . $item['title'] . '">'; } } //$str = '<div style="position: fixed;left:0;bottom:0">'.$str.'</div>'; } else { $str = preg_replace('/(\\n|\\r)/i', ' ', $ad['content']); $str = preg_replace("/'/i", "\\'", $str); } } } } $css = ''; if ($ad['type'] == 4) { $info = $ad['content'][0]; switch ($info['position']) { case 0: $css = "{left:0,top:0,right:'',bottom:'','z-index': 10000}"; break; case 1: $css = "{left:w_middle,top:0,right:'',bottom:'','z-index': 10000}"; break; case 2: $css = "{right:0,top:0,left:'',bottom:'','z-index': 10000}"; break; case 3: $css = "{right:'',top:h_middle,left:0,bottom:'','z-index': 10000}"; break; case 4: $css = "{right:'',top:h_middle,left:w_middle,bottom:'','z-index': 10000}"; break; case 5: $css = "{right:0,top:h_middle,left:'',bottom:'','z-index': 10000}"; break; case 6: $css = "{right:'',top:'',left:0,bottom:0,'z-index': 10000}"; break; case 7: $css = "{right:'',top:'',left:w_middle,bottom:0,'z-index': 10000}"; break; case 8: $css = "{right:0,top:'',left:'',bottom:0,'z-index': 10000}"; break; } if ($info['is_close'] == 1) { $str .= '<a style="dispaly:block;border:red 1px solid;text-decoration: none; background: #f1f1f1; width:12px;height:12px; position:absolute;top:2px;right:2px;font-size:12px;font-family: serif;color:red;" href="javascript:$(\\\'#ad-' . $ad['number'] . '\\\').remove()">×</a>'; } $str = '<div id="ad-' . $ad['number'] . '" style="position: fixed;left:0;bottom:0;width:' . $ad['width'] . 'px;height:' . $ad['height'] . 'px;overflow: hidden;">' . $str . '</div>'; } else { if ($ad['type'] == 2) { $str = '<div id="ad-' . $ad['number'] . '" style="width:100%;height:' . $ad['height'] . 'px;overflow: hidden;">' . $str . '</div>'; } else { $str = '<div id="ad-' . $ad['number'] . '" style="width:' . $ad['width'] . 'px;height:' . $ad['height'] . 'px;overflow: hidden;">' . $str . '</div>'; } } if ($ad['type'] == 2) { $str .= '<script type="text/javascript">$("#slider-' . $ad['number'] . '").Slider();</script>'; } else { if ($ad['type'] == 4) { $css = preg_replace('/\'/', '"', $css); $str .= '<script type="text/javascript"> var w_middle = ($(window).width()-$("#ad-' . $ad['number'] . '").width())/2+"px";var h_middle = ($(window).height()-$("#ad-' . $ad['number'] . '").height())/2+"px";var css=' . $css . ';$("#ad-' . $ad['number'] . '").css(css);</script>'; } } header('Content-type: text/javascript'); echo "document.write('" . $str . "');"; // exit; }