Exemplo n.º 1
0
 public function _clone(GoodsPassport $product)
 {
     $this->product = new GoodsPassport();
     $this->product->setImg($product->getImg())->setModel($product->getModel())->setColor($product->getColor())->setPattern($product->getPattern())->setColorSn($product->getColorSn())->setBrand($product->getBrand())->setMt($product->getMt())->setStatus($product->getStatus())->setLevel($product->getLevel())->setSource($product->getSource())->setName($product->getName())->setParent($product->getParent())->setCost($product->getCost())->setPrice($product->getPrice())->setOrgSn($product->getOrgSn())->setMemo($product->getMemo())->setCustom($product->getCustom())->setPromotion($product->getPromotion())->setIsBehalf($product->getIsBehalf())->setWebPrice($product->getWebPrice())->setDesimg($product->getDesimg())->setBrief($product->getBrief())->setDescription($product->getDescription())->setIsAllowWeb($product->getIsAllowWeb())->setSeoSlogan($product->getSeoSlogan())->setSeoSlogan2($product->getSeoSlogan2())->setIsAllowCreditCard($product->getIsAllowCreditCard())->setYahooId($product->getYahooId())->setIsAlanIn(false)->setIsAllowAuction(false)->setBsoCustomPercentage(NULL);
     foreach ($product->getCategorys() as $category) {
         $this->product->addCategory($category);
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @Route("/product/{id}", requirements={"id" = "\d+"}, name="front_product_show", options={"expose"=true})
  * @ParamConverter("goods", class="WoojinGoodsBundle:GoodsPassport")
  * @Template()
  */
 public function productAction(Request $request, GoodsPassport $goods)
 {
     // if (!$goods->getIsAllowWeb() || !in_array($goods->getStatus()->getId(), array(Avenue::GS_ONSALE, Avenue::GS_SOLDOUT, Avenue::GS_ACTIVITY, Avenue::GS_BEHALF) )) {
     //     throw $this->createNotFoundException('The product does not exist');
     // }
     if (!$goods->getIsAllowWeb()) {
         throw $this->createNotFoundException('The product does not exist');
     }
     $mobileDetector = $this->get('resolver.device');
     $mobileDetector->setForce($request);
     if ($mobileDetector->isM()) {
         return $this->redirect($this->generateUrl('mobile_front_product', array('id' => $goods->getId())));
     }
     $historys = array();
     $relatives = array();
     $em = $this->getDoctrine()->getManager();
     $relatives = $em->getRepository('WoojinGoodsBundle:GoodsPassport')->getRandOnSale(10);
     $historyIds = json_decode($request->cookies->get('avenueHistory', '[]'), true);
     $historyIds = array_unique($historyIds);
     $historyIds = array_values($historyIds);
     if (!empty($historyIds)) {
         $qb = $em->createQueryBuilder();
         $historys = $qb->select('g')->from('WoojinGoodsBundle:GoodsPassport', 'g')->where($qb->expr()->andX($qb->expr()->in('g.id', $historyIds), $qb->expr()->eq('g.isAllowWeb', true)))->groupBy('g.id')->getQuery()->getResult();
         $returns = array();
         for ($i = 0; $i < count($historys); $i++) {
             $returns[$i] = null;
         }
         foreach ($historys as $key => $history) {
             $pos = array_search($history->getId(), $historyIds);
             if ($pos !== false) {
                 $returns[$pos] = $history;
             }
         }
         $historys = $returns;
     }
     return array('goods' => $goods, 'relatives' => $relatives, 'historys' => $historys);
 }
Exemplo n.º 3
0
 protected function genArr(GoodsPassport $product)
 {
     $arr = array();
     $arr['auth_key'] = 'jasodijQQ3Eoinaaoidll';
     // GoodsPassport (分類???)
     $arr['GoodsPassport']['id'] = $product->getId();
     $arr['GoodsPassport']['status_id'] = $product->getStatus()->getId();
     $arr['GoodsPassport']['source_id'] = $product->getSource() ? $product->getSource()->getId() : 0;
     $arr['GoodsPassport']['img_id'] = $product->getImg() ? $product->getImg()->getId() : 0;
     $arr['GoodsPassport']['level_id'] = $product->getLevel() ? $product->getLevel()->getId() : 0;
     $arr['GoodsPassport']['inherit_id'] = $product->getParent()->getId();
     $arr['GoodsPassport']['sn'] = $product->getSn();
     $arr['GoodsPassport']['name'] = $product->getName();
     $arr['GoodsPassport']['cost'] = $product->getCost();
     $arr['GoodsPassport']['price'] = $product->getPrice();
     $arr['GoodsPassport']['org_sn'] = $product->getOrgSn();
     $arr['GoodsPassport']['memo'] = $product->getMemo();
     $arr['GoodsPassport']['created_at'] = $product->getCreatedAt()->format('Y-m-d H:i:s');
     $arr['GoodsPassport']['mt_id'] = $product->getMt() ? $product->getMt()->getId() : 0;
     $arr['GoodsPassport']['activity_id'] = $product->getActivity() ? $product->getActivity()->getId() : 0;
     $arr['GoodsPassport']['custom_id'] = $product->getCustom() ? $product->getCustom()->getId() : 0;
     $arr['GoodsPassport']['brand_id'] = $product->getBrand() ? $product->getBrand()->getId() : 0;
     //$arr['GoodsPassport']['color_id'] = $product->;
     $arr['GoodsPassport']['pattern_id'] = $product->getPattern() ? $product->getPattern()->getId() : 0;
     $arr['GoodsPassport']['colorSn'] = $product->getColorSn();
     $arr['GoodsPassport']['model'] = $product->getModel();
     $arr['GoodsPassport']['customSn'] = $product->getCustomSn();
     $arr['GoodsPassport']['desimg_id'] = $product->getDesimg() ? $product->getDesimg()->getId() : 0;
     $arr['GoodsPassport']['description_id'] = $product->getDescription() ? $product->getDescription()->getId() : 0;
     $arr['GoodsPassport']['brief_id'] = $product->getBrief() ? $product->getBrief()->getId() : 0;
     $arr['GoodsPassport']['store_id'] = $product->getStore() ? $product->getStore()->getId() : 0;
     $arr['GoodsPassport']['promotion_id'] = $product->getPromotion() ? $product->getPromotion()->getId() : 0;
     $arr['GoodsPassport']['is_allow_web'] = $product->getIsAllowWeb();
     $arr['GoodsPassport']['update_at'] = $product->getUpdateAt() ? $product->getUpdateAt()->format('Y-m-d H:i:s') : null;
     $arr['GoodsPassport']['web_price'] = $product->getWebPrice();
     $arr['GoodsPassport']['categorys'] = array(0);
     foreach ($product->getCategorys() as $category) {
         $arr['GoodsPassport']['categorys'][] = $category->getId();
     }
     $i = 0;
     // Orders
     foreach ($product->getOrders() as $order) {
         $arr['Orders'][$i]['id'] = $order->getId();
         $arr['Orders'][$i]['goods_passport_id'] = $product->getId();
         $arr['Orders'][$i]['pay_type_id'] = $order->getPayType() ? $order->getPayType()->getId() : 0;
         $arr['Orders'][$i]['status_id'] = $order->getStatus()->getId();
         $arr['Orders'][$i]['kind_id'] = $order->getKind()->getId();
         $arr['Orders'][$i]['custom_id'] = $order->getCustom() ? $order->getCustom()->getId() : 0;
         $arr['Orders'][$i]['memo'] = $order->getMemo();
         $arr['Orders'][$i]['required'] = $order->getRequired();
         $arr['Orders'][$i]['paid'] = $order->getPaid();
         $arr['Orders'][$i]['relate_id'] = $order->getParent() ? $order->getParent()->getId() : 0;
         $arr['Orders'][$i]['invoice_id'] = $order->getInvoice() ? $order->getInvoice()->getId() : 0;
         $arr['Orders'][$i]['org_required'] = $order->getOrgRequired();
         $arr['Orders'][$i]['org_paid'] = $order->getOrgPaid();
         // Ope
         $j = 0;
         foreach ($order->getOpes() as $ope) {
             //$arr['Ope'][]['orders_id'] = $order->get;
             $arr['Ope'][$order->getId()][$j]['user_id'] = $ope->getUser() ? $ope->getUser()->getId() : 0;
             $arr['Ope'][$order->getId()][$j]['act'] = $ope->getAct();
             $arr['Ope'][$order->getId()][$j]['datetime'] = $ope->getDatetime()->format('Y-m-d H:i:s');
             $arr['Ope'][$order->getId()][$j]['memo'] = $ope->getMemo();
             $j++;
         }
         $i++;
     }
     return $arr;
 }
Exemplo n.º 4
0
 /**
  * @Route("/product/{id}", requirements={"id"="\d+"}, name="mobile_front_product")
  * @ParamConverter("product", class="WoojinGoodsBundle:GoodsPassport")
  * @Method("GET")
  * @Template()
  */
 public function productAction(GoodsPassport $product)
 {
     if (!$product->getIsAllowWeb()) {
         throw $this->createNotFoundException('The product does not exist');
     }
     $desimg = $product->getDesimg();
     if ($desimg) {
         for ($i = 0; $i < 5; $i++) {
             if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $desimg->getSplitPath($i))) {
                 // 切圖片, 把 desimg 切成五張小圖
                 $this->get('factory.desimg')->spliceDesImage($desimg);
                 break;
             }
         }
     }
     return array('product' => $product);
 }