function adminsetselectedorderAction() { $type = $this->_request->getParam('type'); if ($type == 'orderState') { $idStr = $this->_request->getParam('orderids'); $idStrArray = explode(',', $idStr); $productOrderModel = new ProductOrder(); foreach ($idStrArray as $idAndState) { if (null == $idAndState || '' == $idAndState) { continue; } $idAndStateArray = explode('@', $idAndState); $productOrder = $productOrderModel->fetchRow('id = ' . $idAndStateArray[0]); // consumer cancel order if ($productOrder->state == 'CANCEL') { continue; } // confirm used point in table 'reward_point_transaction_record' $rewardPointTransactionRecordModel = new RewardPointTransactionRecord(); $rewardPointTransactionRecord = $rewardPointTransactionRecordModel->fetchRow('id = ' . $productOrder->reward_point_transaction_record_id); if ($rewardPointTransactionRecord == null) { continue; } else { $productModel = new Product(); $product = $productModel->fetchRow('id = ' . $productOrder->product_id); if ($product == null) { continue; } else { if ($idAndStateArray[1] == 'UNAPPROVED') { $rewardPointTransactionRecord->point_amount = 0; } } $rewardPointTransactionRecord->save(); } // change order state $currenttime = date("Y-m-d H:i:s"); $productOrder->state = $idAndStateArray[1]; $productOrder->handle_date = $currenttime; $productOrder->save(); } } $this->_helper->json('Success'); }
function deleteorderAction() { $this->view->title = $this->view->translate("Wildfire") . " - " . $this->view->translate("GIFT_DELETE_ORDER"); $orderid = $this->_request->getParam('orderid'); $productorderModel = new ProductOrder(); $order = $productorderModel->fetchRow('id = ' . $orderid); if ($order == null || $order->state != 'NEW' || $order->consumer_id != $this->_currentUser->id) { $this->view->message = $this->view->translate("Gift_delete_order_fail"); return; } else { // reward_point_transaction_record table $rewardPointTransactionRecordModel = new RewardPointTransactionRecord(); $rewardPointTransactionRecord = $rewardPointTransactionRecordModel->fetchRow('id = ' . $order->reward_point_transaction_record_id); $rewardPointTransactionRecord->point_amount = 0; $rewardPointTransactionRecord->save(); // product_order table $order->state = 'CANCEL'; $order->save(); // roll back... } $this->view->message = $this->view->translate("Gift_delete_order_successfully"); }