public function postComments() { if ($this->user) { $user_id = $this->user['id']; $goods_id = $_POST['goods_id']; $the_date = $_POST['the_date']; $starts = $_POST['starts']; $comments = $_POST['comments']; if (!verify::vIsNNUll($comments)) { core::outPut(-1, "评论内容输入不能为空"); } if (!verify::vIsNumber($starts)) { core::outPut(-1, "评论星级选择不能为空"); } if (!verify::vIsNumber($goods_id)) { core::outPut(-1, "商品ID不能为空"); } //先判断该用户是否有购买过该商品 $this->CT_Api->api = "en.order.checkComments"; $this->CT_Api->user_id = $user_id; $this->CT_Api->goods_id = $goods_id; $result = $this->CT_Api->get(); if ($result != 1) { core::outPut(-1, "必须购买了该产品才能评论"); } $this->CT_Api->api = "en.comments.save"; $this->CT_Api->setParams(array('line_id' => $result['response']['id'], 'user_id' => $user_id, 'goods_id' => $goods_id, 'the_date' => $the_date, 'starts' => $starts, 'content' => $comments)); $result = $this->CT_Api->post(); if ($result['code'] == 1) { core::outPut(1, "评论发表成功"); } else { core::outPut(-1); } } else { core::outPut(1001, "Please login"); } }
public function saveOrder() { if ($this->user) { $billing_id = $_GET['billing_id']; $recipient_id = $_GET['recipient_id']; $comments = $_GET['comments']; $the_date = date("Y-m-d H:i:s"); if (!verify::vIsNNUll($billing_id)) { alert("账单ID不能为空"); } if (!verify::vIsNumber($billing_id)) { alert("账单ID格式错误"); } if (!verify::vIsNNUll($recipient_id)) { alert("收件人ID不能为空"); } if (!verify::vIsNumber($recipient_id)) { alert("收件人ID格式错误"); } //保存订单 $this->CT_Api->api = "en.order.save"; $this->CT_Api->setParams(array('user_id' => $this->user['id'], 'the_date' => $the_date, 'pay_date' => "0000-00-00 00:00:00", 'billing_id' => $billing_id, 'recipient_id' => $recipient_id, 'status' => "录入", 'comments' => $comments, 'ship_fee' => 0.0, 'logistic' => "Fedex", 'payerid' => "", 'token' => "", 'goods_qty' => $this->shopcart->getQtyScr())); $orderResponse = $this->CT_Api->post(); $order = $orderResponse['response']; if (strtolower(substr($order['msg'], 0, 7)) != "success") { alert("订单提交失败:" . $order['msg']); } else { $this->shopcart->flush(); } // save to paylog table (with discount already) $order_code = $order['order_code']; $the_amount = $order['the_amount']; $payment = payment::getInstance(); $result = $payment->GetToken($the_amount, $order_code, $this->shopcart->getList()); //记录操作日志 $user_id = $this->user['id']; $this->CT_Api->api = 'en.ucenter.getByUID'; $this->CT_Api->id = $user_id; $dataPromo = $this->CT_Api->get(); $this->assign('dataPromo', $dataPromo['response']); if ($dataPromo['response']['promo'] != '') { $percentage = 10; } else { $percentage = 0; } $percentage10 = $percentage / 100; $amount_before = $the_amount; $ammount_percentage = $percentage10 * $amount_before; $new_sum = $amount_before - $ammount_percentage; $new_sum = round($new_sum, 2); $this->CT_Api->api = "en.paylog.save"; $this->CT_Api->setParams(array('api_name' => 'SetExpressCheckout', 'order_code' => $order_code, 'the_time' => time(), 'response' => http_build_query($result), 'amount' => $new_sum, 'token' => $result['TOKEN'], 'ack' => $result['ACK'], 'ip' => getIP())); $this->CT_Api->post(); if ($result['ACK'] != "Success") { alert("An error occurred while pay PayPal"); } $url = $payment->buildPayPaiUrl($result['TOKEN']); //print_r($url); die(); redirect($url); } else { redirect("/index.php?m=user&c=index&a=login&ReturnUrl=" . getRequest()); } }