url() . 'respond.php?code=' . $code; } /** * 取得某支付方式信息 * @param string $code 支付方式代码 */ function get_payment($code) { $sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('payment'). " WHERE pay_code = '$code' AND enabled = '1'"; $payment = $GLOBALS['db']->getRow($sql); if ($payment) { $config_list = unserialize($payment['pay_config']); foreach ($config_list AS $config) { $payment[$config['name']] = $config['value']; } } return $payment; } /** * 通过订单sn取得订单ID * @param string $order_sn 订单sn * @param blob $voucher 是否为会员充值 */ function get_order_id_by_sn($order_sn, $voucher = 'false') { if ($voucher == 'true') { if(is_numeric($order_sn)) { return $GLOBALS['db']->getOne("SELECT log_id FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE order_id=" . $order_sn . ' AND order_type=1'); } else { return ""; } } else { if(is_numeric($order_sn)) { $sql = 'SELECT order_id FROM ' . $GLOBALS['ecs']->table('order_info'). " WHERE order_sn = '$order_sn'"; $order_id = $GLOBALS['db']->getOne($sql); } if (!empty($order_id)) { $pay_log_id = $GLOBALS['db']->getOne("SELECT log_id FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE order_id='" . $order_id . "'"); return $pay_log_id; } else { return ""; } } } /** * 通过订单ID取得订单商品名称 * @param string $order_id 订单ID */ function get_goods_name_by_id($order_id) { $sql = 'SELECT goods_name FROM ' . $GLOBALS['ecs']->table('order_goods'). " WHERE order_id = '$order_id'"; $goods_name = $GLOBALS['db']->getCol($sql); return implode(',', $goods_name); } /** * 检查支付的金额是否与订单相符 * * @access public * @param string $log_id 支付编号 * @param float $money 支付接口返回的金额 * @return true */ function check_money($log_id, $money) { if(is_numeric($log_id)) { $sql = 'SELECT order_amount FROM ' . $GLOBALS['ecs']->table('pay_log') . " WHERE log_id = '$log_id'"; $amount = $GLOBALS['db']->getOne($sql); } else { return false; } if ($money == $amount) { return true; } else { return false; } } /** * 修改订单的支付状态 * * @access public * @param string $log_id 支付编号 * @param integer $pay_status 状态 * @param string $note 备注 * @return void */ function order_paid($log_id, $pay_status = PS_PAYED, $note = '') { /* 取得支付编号 */ $log_id = intval($log_id); if ($log_id > 0) { /* 取得要修改的支付记录信息 */ $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('pay_log') . " WHERE log_id = '$log_id'"; $pay_log = $GLOBALS['db']->getRow($sql); if ($pay_log && $pay_log['is_paid'] == 0) { /* 修改此次支付操作的状态为已付款 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('pay_log') . " SET is_paid = '1' WHERE log_id = '$log_id'"; $GLOBALS['db']->query($sql); /* 根据记录类型做相应处理 */ if ($pay_log['order_type'] == PAY_ORDER) { /* 取得订单信息 */ $sql = 'SELECT order_id, user_id, order_sn, consignee, address, tel, shipping_id, extension_code, extension_id, goods_amount ' . 'FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '$pay_log[order_id]'"; $order = $GLOBALS['db']->getRow($sql); $order_id = $order['order_id']; $order_sn = $order['order_sn']; /* 修改订单状态为已付款 */ $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET order_status = '" . OS_CONFIRMED . "', " . " confirm_time = '" . gmtime() . "', " . " pay_status = '$pay_status', " . " pay_time = '".gmtime()."', " . " money_paid = order_amount," . " order_amount = 0 ". "WHERE order_id = '$order_id'"; $GLOBALS['db']->query($sql); /* 记录订单操作记录 */ order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']); //互亿无线修改 global $smarty; /* 客户付款时给商家发送短信提醒 */ if ($GLOBALS['_CFG']['ihuyi_sms_order_payed'] == '1' && $GLOBALS['_CFG']['ihuyi_sms_shop_mobile'] != '') { require_once(ROOT_PATH . 'includes/lib_sms.php'); $smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']); $smarty->assign('order_sn', $order['order_sn']); $smarty->assign('consignee', $order['consignee']); $smarty->assign('tel', $order['tel']); $content = $smarty->fetch('str:' . $GLOBALS['_CFG']['ihuyi_sms_order_payed_value']); $ret = sendsms($GLOBALS['_CFG']['ihuyi_sms_shop_mobile'], $content); } /* 获取用户手机号 */ $sql = "SELECT user_id, mobile_phone FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id='$order[user_id]' LIMIT 1"; $row = $GLOBALS['db']->getRow($sql); /* 客户付款时给客户发送短信提醒 */ if ($GLOBALS['_CFG']['ihuyi_sms_customer_payed'] == '1' && $row['mobile_phone'] != '') { require_once(ROOT_PATH . 'includes/lib_sms.php'); $smarty->assign('shop_name', $GLOBALS['_CFG']['shop_name']); $smarty->assign('order_sn', $order['order_sn']); $smarty->assign('time', local_date(date('Y-m-d H:i:s', time()))); $content = $smarty->fetch('str:' . $GLOBALS['_CFG']['ihuyi_sms_customer_payed_value']); $ret = sendsms($row['mobile_phone'], $content); } //互亿无线修改 /* 对虚拟商品的支持 */ $virtual_goods = get_virtual_goods($order_id); if (!empty($virtual_goods)) { $msg = ''; if (!virtual_goods_ship($virtual_goods, $msg, $order_sn, true)) { $GLOBALS['_LANG']['pay_success'] .= '