本文整理汇总了PHP中EnmasseHelper::checkCupponOfMerchant方法的典型用法代码示例。如果您正苦于以下问题:PHP EnmasseHelper::checkCupponOfMerchant方法的具体用法?PHP EnmasseHelper::checkCupponOfMerchant怎么用?PHP EnmasseHelper::checkCupponOfMerchant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnmasseHelper
的用法示例。
在下文中一共展示了EnmasseHelper::checkCupponOfMerchant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
function update()
{
$dAuthorId = $this->checkAccess();
$action = JRequest::getVar('newStatus');
$coupon = JRequest::getVar('coupon');
//Check whether coupon belong this merchant or not
if (!EnmasseHelper::checkCupponOfMerchant($coupon, $dAuthorId)) {
$msg = JText::_('MERCHANT_INVALID_COUPON_SERIAL');
$this->setRedirect("index.php?option=com_enmasse&controller=merchant&task=dealCouponMgmt", $msg, "error");
return;
}
$invty = JModel::getInstance('invty', 'enmasseModel')->getByName($coupon);
if (!$invty) {
$msg = JText::_('MERCHANT_INVALID_COUPON_SERIAL');
$this->setRedirect("index.php?option=com_enmasse&controller=merchant&task=dealCouponMgmt", $msg, "error");
} else {
$orderItem = JModel::getInstance('orderItem', 'enmasseModel')->getById($invty->order_item_id);
if ($orderItem->status != "Delivered") {
$msg = JText::_('COUPON_STATUS_ERROR') . "(" . $invty->name . " - " . $orderItem->status . ")";
$this->setRedirect("index.php?option=com_enmasse&controller=merchant&task=dealCouponMgmt&filter[deal_id]={$orderItem->pdt_id}", $msg, 'error');
} elseif ($action == "Used") {
$invty = JModel::getInstance('invty', 'enmasseModel')->getByName($coupon);
if ($invty->status == "Used") {
$msg = JText::_('COUPON_ALREADY_IN_USE') . '(' . $invty->name . ")";
$this->setRedirect("index.php?option=com_enmasse&controller=merchant&task=dealCouponMgmt&filter[deal_id]={$orderItem->pdt_id}", $msg, 'error');
} else {
JModel::getInstance('invty', 'enmasseModel')->updateStatusByName($coupon, "Used");
$msg = JText::_('COUPON_STATUS_UPDATE') . '(' . $invty->name . ")";
$this->setRedirect("index.php?option=com_enmasse&controller=merchant&task=dealCouponMgmt&filter[deal_id]={$orderItem->pdt_id}", $msg);
}
} else {
JModel::getInstance('invty', 'enmasseModel')->updateStatusByName($coupon, "Taken");
$msg = JText::_('COUPON_STATUS_UPDATE') . '(' . $invty->name . ")";
$this->setRedirect("index.php?option=com_enmasse&controller=merchant&task=dealCouponMgmt&filter[deal_id]={$orderItem->pdt_id}", $msg);
}
}
}
示例2: markUnused
public function markUnused()
{
//authenticate user
$oSession = $this->authenticate();
$result = array();
$invtyName = JRequest::getVar('qr_code', '', 'post');
if (!EnmasseHelper::checkCupponOfMerchant($invtyName, $oSession->merchant_id)) {
$result[EM_WS_FIELD_TYPE] = EM_WS_TYPE_ERROR;
$result[EM_WS_FIELD_MESSAGE] = JText::_("MERCHANT_WS_INVALID_COUPON_CODE");
$result[EM_WS_FIELD_DATA] = "";
} else {
$oInvty = JModel::getInstance('invty', 'enmasseModel')->getByName($invtyName);
$orderItem = JModel::getInstance('orderItem', 'enmasseModel')->getById($oInvty->order_item_id);
if ($orderItem->status != "Delivered") {
$result[EM_WS_FIELD_TYPE] = EM_WS_TYPE_ERROR;
$result[EM_WS_FIELD_MESSAGE] = JText::_('COUPON_STATUS_ERROR') . "(" . $oInvty->name . " - " . $orderItem->status . ")";
$result[EM_WS_FIELD_DATA] = "";
}
if ($oInvty->status == "Taken") {
$result[EM_WS_FIELD_TYPE] = EM_WS_TYPE_ERROR;
$result[EM_WS_FIELD_MESSAGE] = JText::_('COUPON_ALREADY_IN_TAKEN') . '(' . $oInvty->name . ")";
$result[EM_WS_FIELD_DATA] = "";
} else {
JModel::getInstance('invty', 'enmasseModel')->updateStatusByName($invtyName, "Taken");
$result[EM_WS_FIELD_TYPE] = EM_WS_TYPE_OK;
$result[EM_WS_FIELD_MESSAGE] = JText::_('COUPON_STATUS_UPDATE') . '(' . $oInvty->name . ")";
$result[EM_WS_FIELD_DATA] = "";
}
}
//update user session
$this->updateSession();
//return result
echo json_encode($result);
die;
}