public function do_scorecharge() { $modelDevelopRechargeRecord = D('DevelopRechargeRecord', 'develop'); $orderNumber = 'CZ' . getOrderNumber(); // $price = intval($_POST['charge_value']); $price = 0.01; $data['serial_number'] = $orderNumber; $data['charge_type'] = intval($_POST['charge_type']); $data['charge_value'] = $price; $data['uid'] = $this->mid; $data['ctime'] = time(); $result = D('credit_charge')->add($data); $res = array(); if ($result) { $res['status'] = 1; $res['info'] = '充值成功'; $params = array('order_nu' => $orderNumber, 'price' => $price, 'type' => 1, 'explain' => '积分充值'); switch ($data['charge_type']) { case '1': $res['request_url'] = Addons::createAddonUrl('Tenpay', 'tenpay_to', $params); break; case '2': $res['request_url'] = Addons::createAddonUrl('Alipay', 'alipay_to', $params); break; default: $res['request_url'] = ''; break; } } else { $res['status'] = 0; $res['info'] = '充值失败'; } exit(json_encode($res)); }
<?php if (!defined('BASEPATH')) { die('You are not allowed to access this page'); } if ($_SESSION['member'] == true and count($_SESSION['myCart']) > 0) { if ($_POST['doOrder']) { extract($_POST); $cartTotal = cartCountTotalItems(); $member_id = $_SESSION['id']; $no_order = getOrderNumber(); $qry = "INSERT INTO `order` (no_order, tgl_order, member_id, total_order, catatan, `status`)\n\t\t\tVALUES ('" . $no_order . "', NOW(), '" . $member_id . "', '" . $cartTotal . "', '" . $catatan . "', 1)"; $res = mysql_query($qry); $ids = mysql_insert_id(); if (mysql_affected_rows() > 0) { $myCart = $_SESSION['myCart']; if (count($myCart) > 0) { foreach ($myCart as $i => $cart) { $qry2 = "INSERT INTO order_detail(order_id, produk_id, \n\t\t\t\t\t\tatribut_id, satuan, harga, diskon, qty, subtotal) VALUES\n\t\t\t\t\t\t('" . $ids . "', '" . $i . "', '" . $cart['atribut_id'] . "',\n\t\t\t\t\t\t'" . $cart['satuan'] . "', '" . $cart['harga'] . "','" . $cart['diskon'] . "', \n\t\t\t\t\t\t'" . $cart['qty'] . "', '" . $cart['subtotal'] . "')"; mysql_query($qry2); } } $msg = 'Pesanan anda akan kami proses, silahkan cek email anda untuk melihat detail order'; unset($_SESSION['myCart']); if (sendmail_order($ids)) { $msg .= ', Email berhasil dikirim'; } $_SESSION['msg'] = '<div class="success">' . $msg . '</div>'; header("Location: index.php?p=orderdetail&id=" . $ids); } else { header("Location: index.php?p=checkout");
function InseterOrder() { try { $sql = "insert into `order` "; $cart = $_SESSION[constant("SESSION_CART")]; $customer = $_SESSION["customer"]; $custId = $customer->CustId; $hats = $cart->list; $orderArray = array("order_number" => "'" . getOrderNumber($custId) . "'", "order_status" => "'" . constant("ORDER_WAITING") . "'", "order_customer_id" => "'" . $custId . "'", "order_gst" => "'" . constant("GST") . "'", "order_subtotal" => "'" . $cart->subTotal . "'"); $sql .= parent::GetInsertSQL($orderArray); $conn = new MyDb(); $id = $conn->SaveDataWithTransaction($sql, true, false); if ($id != 0) { $items_sql = " insert into order_item "; foreach ($hats as $hat) { $dataArray = array("item_hat_id" => "'" . $hat->HatId . "'", "item_order_id" => "'" . $id . "'", "item_quantity" => "'" . $hat->Quantity . "'", "item_price" => "'" . $hat->Price . "'"); $sqltemp = $items_sql . parent::GetInsertSQL($dataArray); $conn->SaveDataWithTransaction($sqltemp, false, false); } } $conn->CommitTransaction(); $conn->Close(); return $id; } catch (Exception $e) { $conn->Close(); echo $e->getMessage(); } return 0; }