本文整理汇总了PHP中EnmasseHelper::orderItemDelivered方法的典型用法代码示例。如果您正苦于以下问题:PHP EnmasseHelper::orderItemDelivered方法的具体用法?PHP EnmasseHelper::orderItemDelivered怎么用?PHP EnmasseHelper::orderItemDelivered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnmasseHelper
的用法示例。
在下文中一共展示了EnmasseHelper::orderItemDelivered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doNotify
public static function doNotify($orderId)
{
$order = JModel::getInstance('order', 'enmasseModel')->getById($orderId);
JModel::getInstance('order', 'enmasseModel')->updateStatus($order->id, 'Paid');
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderId);
$totalQty = 0;
for ($count = 0; $count < count($orderItemList); $count++) {
$orderItem = $orderItemList[$count];
// only add total sold when order has status of delivered
//JModel::getInstance('deal', 'enmasseModel')->addQtySold($orderItem->pdt_id, $orderItem->qty);
JModel::getInstance('orderItem', 'enmasseModel')->updateStatus($orderItem->id, 'Paid');
JModel::getInstance('invty', 'enmasseModel')->updateStatusByOrderItemId($orderItem->id, 'Sold');
if ($count == 0) {
$dealName = $orderItem->description;
} elseif ($count == count($orderItemList) - 1) {
$dealName .= " & " . $orderItem->description;
} else {
$dealName .= " , " . $orderItem->description;
}
$totalQty += $orderItem->qty;
}
//---------------------------
//Create the receipt with pdf format
//just create bill if the order is not free and buyer have full paid
//remember full paid = order->status = "paid" and order->paid_amount == 0.0
if ($order->total_buyer_paid > 0 && $order->paid_amount == 0.0) {
$sBillName = BillHelper::createPDF($orderId);
} else {
$sBillName = "";
}
//--------------------------
// Sending email
$payment = json_decode($order->pay_detail);
$buyer = json_decode($order->buyer_detail);
$delivery = json_decode($order->delivery_detail);
$params = array();
$params['$buyerName'] = $buyer->name;
$params['$buyerEmail'] = $buyer->email;
$buyerEmail = $buyer->email;
$params['$deliveryName'] = $delivery->name;
$params['$deliveryEmail'] = $delivery->email;
$params['$orderId'] = self::displayOrderDisplayId($order->id);
$params['$dealName'] = $dealName;
$params['$totalPrice'] = self::displayCurrency($order->paid_amount);
$params['$totalQty'] = $totalQty;
$params['$createdAt'] = DatetimeWrapper::getDisplayDatetime($order->created_at);
if (self::getSetting()->sending_bill_auto == 1) {
self::sendMailByTemplate($buyerEmail, 'receipt', $params, $sBillName);
//send mail with bill attachment
} else {
self::sendMailByTemplate($buyerEmail, 'receipt', $params);
//send mail with no attachment
}
foreach ($orderItemList as $orderItem) {
$deal = JModel::getInstance('deal', 'enmasseModel')->getById($orderItem->pdt_id);
if ($deal->status == "Confirmed" && $deal->prepay_percent == 100.0) {
self::orderItemDelivered($orderItem);
}
//--- auto confirm deal
if ($deal->auto_confirm && $deal->status != "Confirmed" && $deal->min_needed_qty <= $deal->cur_sold_qty) {
//------------------------
//generate integration class
$isPointSystemEnabled = EnmasseHelper::isPointSystemEnabled();
if ($isPointSystemEnabled == true) {
$integrationClass = EnmasseHelper::getPointSystemClassFromSetting();
$integrateFileName = $integrationClass . '.class.php';
require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "pointsystem" . DS . $integrationClass . DS . $integrateFileName;
}
//--- update deal status to "Confirmed"
JModel::getInstance('deal', 'enmasseModel')->updateStatus($deal->id, 'Confirmed');
//--- delivery coupon by email if the deal is not partial payment
if ($deal->prepay_percent == 100.0) {
$arOrderItemDelivery = JModel::getInstance('orderItem', 'enmasseModel')->listByPdtIdAndStatus($deal->id, "Paid");
foreach ($arOrderItemDelivery as $oOrderItem) {
EnmasseHelper::orderItemDelivered($oOrderItem);
//------------------------
//generate integration class
if ($isPointSystemEnabled == true) {
$buyerId = EnmasseHelper::getUserIdByOrderId($oOrderItem->order_id);
$referralId = EnmasseHelper::getReferralIdByOrderId($oOrderItem->order_id);
$integrationObject = new $integrationClass();
$integrationObject->integration($buyerId, 'confirmdeal');
if (!empty($referralId)) {
$integrationObject->integration($referralId, 'referralbonus');
}
}
sleep(1);
}
}
//--- Refund point to who paid with point but without paying by cash
if ($isPointSystemEnabled == true) {
$buyerList = EnmasseHelper::getBuyerRefundConfirmDeal($deal->id);
$integrationObject = new $integrationClass();
foreach ($buyerList as $buyer) {
$integrationObject->integration($buyer['buyer_id'], 'refunddeal', $buyer['point_used_to_pay']);
}
}
}
}
}
示例2: confirmDeal
function confirmDeal()
{
$db = JFactory::getDBO();
$option = 'com_enmasse';
$cid = JRequest::getVar('cid', array(), '', 'array');
$name = "";
$appication = JFactory::getApplication();
if ($cid == null) {
$appication->redirect('index.php?option=' . $option . '&controller=deal', JText::_('CHOOSE_DEAL_TO_CONFIRM'), 'error');
}
for ($i = 0; $i < count($cid); $i++) {
$status = JModel::getInstance('deal', 'enmasseModel')->getStatus($cid[$i]);
if ($status == "Confirmed") {
$appication->redirect('index.php?option=' . $option . '&controller=deal', JText::_('CANNOT_CONFIM_DEAL_CONFIRMED'), 'error');
} elseif ($status == "Voided") {
$appication->redirect('index.php?option=' . $option . '&controller=deal', JText::_('CANNOT_CONFIM_DEAL_VOIDED'), 'error');
} elseif ($status == "Pending") {
$appication->redirect('index.php?option=' . $option . '&controller=deal', JText::_('CANNOT_CONFIM_DEAL_PENDING'), 'error');
}
}
//------------------------
//generate integration class
$isPointSystemEnabled = EnmasseHelper::isPointSystemEnabled();
if ($isPointSystemEnabled == true) {
$integrationClass = EnmasseHelper::getPointSystemClassFromSetting();
$integrateFileName = $integrationClass . '.class.php';
require_once JPATH_SITE . DS . "components" . DS . "com_enmasse" . DS . "helpers" . DS . "pointsystem" . DS . $integrationClass . DS . $integrateFileName;
}
for ($i = 0; $i < count($cid); $i++) {
$dealId = $cid[$i];
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByPdtIdAndStatus($dealId, "Paid");
foreach ($orderItemList as $orderItem) {
EnmasseHelper::orderItemDelivered($orderItem);
//------------------------
//generate integration class
if ($isPointSystemEnabled == true) {
$buyerId = EnmasseHelper::getUserIdByOrderId($orderItem->order_id);
$referralId = EnmasseHelper::getReferralIdByOrderId($orderItem->order_id);
$integrationObject = new $integrationClass();
$integrationObject->integration($buyerId, 'confirmdeal');
if (!empty($referralId)) {
$integrationObject->integration($referralId, 'referralbonus');
}
}
sleep(1);
}
JModel::getInstance('deal', 'enmasseModel')->updateStatus($dealId, 'Confirmed');
if ($isPointSystemEnabled == true) {
$buyerList = EnmasseHelper::getBuyerRefundConfirmDeal($dealId);
$integrationObject = new $integrationClass();
foreach ($buyerList as $buyer) {
$integrationObject->integration($buyer['buyer_id'], 'refunddeal', $buyer['point_used_to_pay']);
}
}
}
$appication->redirect('index.php?option=' . $option . '&controller=deal', JText::_('CONFIRM_DEAL_SUCCESS_MSG'));
}
示例3: save
function save()
{
$status = JRequest::getVar('status', '', 'post');
$partial = JRequest::getVar('partial', 0, 'method', 'int');
$orderData = new JObject();
$orderData->id = JRequest::getInt('id', '', 'post');
$orderData->description = JRequest::getVar('description', '', 'post', 'text', JREQUEST_ALLOWRAW);
//
$orderData->buyerid = JRequest::getInt('buyerid', '', 'post');
$model = JModel::getInstance('order', 'enmasseModel');
if (empty($status)) {
if ($model->store($orderData)) {
$msg = JText::_('SAVE_SUCCESS_MSG');
if ($partial) {
$this->setRedirect('index.php?option=com_enmasse&controller=partialOrder', $msg);
} else {
$this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller'), $msg);
}
} else {
$msg = JText::_('SAVE_ERROR_MSG') . ": " . $model->getError();
if ($orderData->id == null) {
$this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=add', $msg, 'error');
} else {
$this->setRedirect('index.php?option=com_enmasse&controller=' . JRequest::getVar('controller') . '&task=edit&cid[0]=' . $orderData->id . '&partial=' . $partial, $msg, 'error');
}
}
} else {
//------------------------------
// send email and update total sold qty for each case of when change status of order
if ($status == EnmasseHelper::$ORDER_STATUS_LIST["Paid"]) {
EnmasseHelper::doNotify($orderData->id);
$msg = JTEXT::_('SAVE_SUCCESS_MSG_AND_SEND_RECEIPT');
} else {
if ($status == EnmasseHelper::$ORDER_STATUS_LIST["Cancelled"]) {
$orderId = $orderData->id;
$order = JModel::getInstance('order', 'enmasseModel')->getById($orderId);
JModel::getInstance('order', 'enmasseModel')->updateStatus($order->id, 'Cancelled');
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderId);
for ($count = 0; $count < count($orderItemList); $count++) {
$orderItem = $orderItemList[$count];
JModel::getInstance('orderItem', 'enmasseModel')->updateStatus($orderItem->id, 'Unpaid');
JModel::getInstance('invty', 'enmasseModel')->freeCouponByOrderItemId($orderItem->id, 'Free');
}
$msg = JTEXT::_('SAVE_SUCCESS_MSG');
} else {
if ($status == EnmasseHelper::$ORDER_STATUS_LIST["Waiting_For_Refund"]) {
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderData->id);
foreach ($orderItemList as $orderItem) {
EnmasseHelper::orderItemWaitingForRefund($orderItem);
sleep(1);
}
$msg = JTEXT::_('SAVE_SUCCESS_MSG_AND_SEND_REFUND');
} else {
if ($status == EnmasseHelper::$ORDER_STATUS_LIST["Refunded"]) {
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderData->id);
foreach ($orderItemList as $orderItem) {
// reduce deal quality sold
// only reduce when order item was delivered
$isDelivered = intVal($orderItem->is_delivered);
if ($isDelivered) {
JModel::getInstance('deal', 'enmasseModel')->reduceQtySold($orderItem->pdt_id, $orderItem->qty);
}
EnmasseHelper::orderItemRefunded($orderItem);
sleep(1);
}
$msg = JTEXT::_('SAVE_SUCCESS_MSG');
} else {
if ($status == 'Delivered') {
$orderItemList = JModel::getInstance('orderItem', 'enmasseModel')->listByOrderId($orderData->id);
//update paid_amount of coupon to 100%
$model->updateToFullPaid($orderData->id);
JModel::getInstance("orderDeliverer", 'EnmasseModel')->updateStatus($orderData->id, "Delivered");
foreach ($orderItemList as $orderItem) {
// update deal quality sold
JModel::getInstance('deal', 'enmasseModel')->addQtySold($orderItem->pdt_id, $orderItem->qty);
EnmasseHelper::orderItemDelivered($orderItem);
sleep(1);
}
$msg = JTEXT::_('SAVE_SUCCESS_MSG_AND_SEND_DELIVERY');
}
}
}
}
}
if ($partial) {
$this->setRedirect('index.php?option=com_enmasse&controller=partialOrder', $msg);
} else {
$this->setRedirect('index.php?option=com_enmasse&controller=order', $msg);
}
}
}