/** * 订单确认页面 */ function confirm() { $bmobObj = new BmobObject('Cart'); $res = $bmobObj->get('', array('where={"userId":"' . $this->userId . '"}', 'limit=1')); $res = $res->results[0]; $items = $res->items; //json字符串转数组 $items = json_decode($items); if (empty($items)) { header('Location: ' . base_url('user/upload')); } else { //检测文件是否解析完成,若未完成,则返回 $bmobObj = new BmobObject('File_Info'); $num = count($this->cart->getItems()); foreach ($this->cart->getItems() as &$item) { $fileMD5 = $item->fileMD5; $res = $bmobObj->get('', array('where={"fileMD5":"' . $fileMD5 . '"}', 'limit=1')); if (count($res->results) == 1) { $num--; } } if ($num == 0) { //剩余数量为0,载入页面 //载入之前,将page,subtotal信息录入到bmob $k = 0; while (isset($items[$k])) { $item = new MY_Item($items[$k]->filename, $items[$k]->fileMD5); $item->printSettings = $items[$k]->printSettings; $items[$k]->pages = $item->get_pages(); $items[$k]->subtotal = $item->get_subtotal(); $k++; } $this->cart->update_items($items); //更新到数据库 try { } catch (Exception $e) { } $this->load->view('user/confirm_page', array('items' => $items)); } else { //echo $num; header('Location: ' . base_url('user/upload')); } } }
<tr> <td role="order"><?php echo $num; ?> </td> <td role="file-name"> <div><i class="logo-ppt"></i><span class="file-name"><?php echo $item->filename; ?> </span></td> </div> <td role="share pages-amount" class="pages-amount"> <?php echo $item->get_pages(); ?> </td> <td role="page"> <div> <div> <input type="radio" name="page<?php echo $num; ?> " data-role="page" value="single"<?php if (!$item->printSettings->isTwoSides) { echo 'checked'; } ?> >单</div> <div>
/** * 更改打印设定 * 返回单价 */ public function changePrintSetting($fileMD5, $option, $optionValue) { //找到item $items = $this->getItems(); $key = 0; foreach ($items as $one) { if ($one->fileMD5 == $fileMD5) { $isIn = true; break; } $key++; } switch ($option) { case 'paperSize': if (in_array($optionValue, paperSize::getPaperSize())) { $items[$key]->printSettings->paperSize = $optionValue; } break; case 'TwoSides': if ($optionValue == 'double') { $optionValue = true; } else { $optionValue = false; } //echo $optionValue; //if (in_array($optionValue,array(true,false))) { $items[$key]->printSettings->isTwoSides = $optionValue; //} break; case 'pptPerPage': $optionValue = intval($optionValue); if (in_array($optionValue, pptPerPage::getPptPerPage())) { $items[$key]->printSettings->pptPerPage = $optionValue; } break; case 'amount': $optionValue = intval($optionValue); if ($optionValue > 0) { $items[$key]->printSettings->amount = $optionValue; } break; case 'direction': if (in_array($optionValue, printDirection::getPrintDirection())) { $items[$key]->printSettings->direction = $optionValue; } break; default: break; } $newItem = new MY_Item($items[$key]->filename, $items[$key]->fileMD5); $newItem->printSettings = $items[$key]->printSettings; //更新bmob数据,加入价格信息 try { $items[$key]->subtotal = $newItem->get_subtotal(); $items[$key]->pages = $newItem->get_pages(); $this->bmobObject->update($this->cartId, array('items' => json_encode($items))); //var_dump($items); //var_dump($this->getItems()); } catch (Exception $e) { throw new MY_Exception($e->error_msg); } //返回单价和小记 return array('unitPrice' => $newItem->get_price_per_copy() / 100, 'subtotal' => $newItem->get_price_per_copy() * $items[$key]->printSettings->amount / 100); }