本文整理汇总了PHP中Tab::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Tab::model方法的具体用法?PHP Tab::model怎么用?PHP Tab::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tab
的用法示例。
在下文中一共展示了Tab::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
public function actionEdit()
{
if (empty($_POST)) {
$info = Zine::model()->findByPk($_REQUEST['id']);
$viewData = array();
$viewData['info'] = $info;
$this->render('edit', $viewData);
exit;
}
$res = array('statusCode' => 200, 'message' => '修改成功!');
try {
$m = Tab::model()->findByPk($_REQUEST['id']);
if (empty($m)) {
throw new Exception('该谱子不存在');
}
$m->name = $_REQUEST['name'];
//谱子名称
$m->class = $_REQUEST['class'];
//歌曲名称
$m->scover = $_REQUEST['scover'];
//专辑id
$m->mcover = $_REQUEST['mcover'];
$m->bcover = $_REQUEST['bcover'];
$m->content = $_REQUEST['content'];
$m->poptab = $_REQUEST['poptab'];
$m->solotab = $_REQUEST['solotab'];
$m->views = $_REQUEST['views'];
//自建分类
$m->downs = $_REQUEST['downs'];
$m->replys = $_REQUEST['replys'];
$m->date = $_REQUEST['date'];
$m->editor = $_REQUEST['editor'];
$m->intro = $_REQUEST['intro'];
$m->link1 = $_REQUEST['link1'];
$m->link2 = $_REQUEST['link2'];
$m->link3 = $_REQUEST['link3'];
$m->link4 = $_REQUEST['link4'];
$m->veditor = $_REQUEST['veditor'];
$m->peditor = $_REQUEST['peditor'];
$m->team = $_REQUEST['team'];
$m->taobaolink = $_REQUEST['taobaolink'];
$m->bbslink = $_REQUEST['bbslink'];
$m->qita = $_REQUEST['qita'];
$m->market_price = $_REQUEST['market_price'];
$m->cost_price = $_REQUEST['cost_price'];
$m->sell_price = $_REQUEST['sell_price'];
$m->quantity = $_REQUEST['quantity'];
$m->virtual_price = $_REQUEST['virtual_price'];
$flag = $m->save();
if (!$flag) {
throw new exception('修改失败');
}
} catch (Exception $e) {
$res['statusCode'] = 300;
$res['message'] = '失败【' . $e->getMessage() . '】';
}
$res['navTabId'] = 'zineList';
$res['callbackType'] = 'closeCurrent';
$res['forwardUrl'] = '/manage/zine/index';
$this->ajaxDwzReturn($res);
}
示例2: dealWithCancelOrderProductStock
/**
* 处理取消订单的库存
* @param $orderId
*/
public function dealWithCancelOrderProductStock($orderId)
{
if (!$orderId) {
throw new exception('订单的id不能为空!');
}
$list = OrderProduct::model()->findAllByAttributes(array('order_id' => $orderId));
if (empty($list)) {
throw new exception('订单商品为空!');
}
foreach ($list as $row) {
if ($row['type'] == 1) {
$pInfo = Tab::model()->findByPk($row['product_id']);
} elseif ($row['type'] == 2) {
$pInfo = Zine::model()->findByPk($row['product_id']);
} else {
$pInfo = Product::model()->findByPk($row['product_id']);
}
if (empty($pInfo)) {
throw new exception('商品【' . $row['product_name'] . '】不存在!');
}
$pInfo->quantity += $row['quantity'];
$flag = $pInfo->save();
if (empty($flag)) {
throw new exception('商品【' . $row['product_name'] . '】库存恢复失败!');
}
if (!$row['type']) {
$stockInfo = ProductStock::model()->findByAttributes(array('product_id' => $row['product_id'], 'attr_id' => $row['size_id']));
if (empty($stockInfo)) {
throw new exception('商品【' . $row['product_name'] . '】库存不存在!');
}
$stockInfo->quantity += $row['quantity'];
$flag = $stockInfo->save();
if (empty($flag)) {
throw new exception('订单【' . $row['product_name'] . '】库存恢复失败!');
}
}
}
return true;
}
示例3: saveOrderProduct
/**
* 保存订单商品信息
* @param $oid
* @param $cartinfo
* @return bool
* @throws Exception
*/
protected function saveOrderProduct($userId, $order_id, $cartInfo)
{
$list = $cartInfo['list'];
foreach ($list as $row) {
if ($row['type'] == 1) {
$pInfo = Tab::model()->findByPk($row['product_id']);
if (empty($pInfo)) {
throw new Exception("谱子不存在!", 500);
}
} elseif ($row['type'] == 2) {
$pInfo = Zine::model()->findByPk($row['product_id']);
if (empty($pInfo)) {
throw new Exception("杂志商品不存在!", 500);
}
} else {
$pInfo = Product::model()->findByPk($row['product_id']);
if (empty($pInfo)) {
throw new Exception("订单商品不存在!", 500);
}
}
if ($row['sell_price'] != $pInfo['sell_price']) {
throw new exception('价格错误,请重试');
}
$m = new OrderProduct();
$m->order_id = $order_id;
$m->user_id = $userId;
$m->product_id = $row['product_id'];
$m->type = $row['type'];
$m->product_sn = empty($row['type']) ? $pInfo['product_sn'] : '';
$m->product_name = empty($row['type']) ? $pInfo['product_name'] : ($row['type'] == 1 ? $pInfo['tabname'] : $pInfo['name']);
$m->size_id = $row['size_id'];
$m->brand_id = $row['type'] == 0 ? $pInfo['brand_id'] : 0;
$m->sell_price = $row['sell_price'];
$m->quantity = $row['quantity'];
//$m->shipping_id = 0;
//$m->shipping_code = '';
//$m->shipping_time = 0;
$opid = $m->save();
if (empty($opid)) {
throw new Exception("订单商品生成失败!", 1);
}
$this->updateProductStock($pInfo, $row);
//更新商品的库存
}
return true;
}
示例4: actionChange
public function actionChange()
{
$res = array('statusCode' => 200, 'message' => '修改成功!');
$info = Tab::model()->findByPk($_REQUEST['id']);
try {
if (empty($info)) {
throw new exception('记录不存在了!');
}
$info->is_show = $_REQUEST['is_show'];
$flag = $info->save();
if (empty($flag)) {
throw new exception('修改状态失败!');
}
} catch (Exception $e) {
$res['statusCode'] = 300;
$res['message'] = '删除失败【' . $e->getMessage() . '】';
}
$res['callbackType'] = 'reloadTab';
$res['forwardUrl'] = '/manage/tab/index';
$this->ajaxDwzReturn($res);
}