protected function addDesImg(GoodsPassport $product)
 {
     $desimg = $product->getDesimg();
     if (!$desimg) {
         return $this;
     }
     for ($i = 0; $i < Avenue::DESIMG_PIECE_NUM; $i++) {
         $this->parameters['ImageFile' . ($i + 2)] = $this->sourcePath($desimg->getSplitPath($i));
     }
     return $this;
 }
Example #2
0
 protected function getColMap(GoodsPassport $product)
 {
     $order = $product->getValidOutOrder();
     if (!$order) {
         return array('A' => '尚未結清', 'B' => '尚未結清', 'C' => '尚未結清', 'D' => $product->getModel(), 'E' => '尚未結清', 'F' => $product->getName(), 'G' => $product->getSn(), 'H' => '尚未結清', 'I' => '尚未結清', 'J' => '尚未結清', 'K' => '尚未結清', 'L' => '尚未結清', 'M' => '尚未結清', 'N' => '尚未結清', 'O' => '尚未結清', 'P' => '尚未結清', 'Q' => '尚未結清', 'R' => '尚未結清', 'S' => '尚未結清', 'T' => '尚未結清', 'U' => '尚未結清', 'V' => '尚未結清');
     }
     return $product->isOwn($this->user) && $this->user->getRole()->hasAuth('READ_ORDER_OWN') || $this->user->getRole()->hasAuth('READ_ORDER_ALL') ? array('A' => $order->getOpes()->last()->getDatetime()->format('Y-m-d H:i:s'), 'B' => ($brand = $product->getBrand()) ? $brand->getName() : null, 'C' => ($pattern = $product->getPattern()) ? $pattern->getName() : null, 'D' => $product->getModel(), 'E' => $product->getColorSn(), 'F' => $product->getName(), 'G' => $product->getSn(), 'H' => ($level = $product->getLevel()) ? $level->getName() : null, 'I' => $product->getCostVerifyed($this->user), 'J' => $product->getFeedBack(), 'K' => $order->getKind()->getName(), 'L' => $order->getRequired(), 'M' => $product->getCostVerifyed($this->user), 'N' => ($profit = $order->getRequired() - $product->getCostVerifyed($this->user)) > 0 ? $profit : 0, 'O' => $order->getOrgRequired(), 'P' => $order->getRequired() === 0 ? 0 : round($order->getOrgRequired() * ($order->getPaid() / $order->getRequired())), 'Q' => $order->getOrgRequired() - $product->getCostVerifyed($this->user), 'R' => $order->getOpes()->last()->getUser()->getUsername(), 'S' => $order->getMemo(), 'T' => ($activity = $product->getActivity()) ? $activity->getName() : '門市出售', 'U' => $product->getParent()->getSn(), 'V' => $this->map[substr($product->getParent()->getSn(), 0, 1)]->getName()) : array('A' => '無閱讀權限', 'B' => '無閱讀權限', 'C' => '無閱讀權限', 'D' => $product->getModel(), 'E' => '無閱讀權限', 'F' => $product->getName(), 'G' => $product->getSn(), 'H' => '無閱讀權限', 'I' => '無閱讀權限', 'J' => '無閱讀權限', 'K' => '無閱讀權限', 'L' => '無閱讀權限', 'M' => '無閱讀權限', 'N' => '無閱讀權限', 'O' => '無閱讀權限', 'P' => '無閱讀權限', 'Q' => '無閱讀權限', 'R' => '無閱讀權限', 'S' => '無閱讀權限', 'T' => '無閱讀權限', 'U' => '無閱讀權限', 'V' => '無閱讀權限');
 }
Example #3
0
 /**
  * 同步商品護照的客戶,成本資訊,並且更新產編
  * 
  * @param  GoodsPassport $product
  * @return boolean                
  */
 public function sync(GoodsPassport $product)
 {
     $inherits = $product->getInherits();
     $custom = $product->getCustom();
     $price = $product->getPrice();
     $cost = $product->getCost();
     if (empty($inherits)) {
         return false;
     }
     foreach ($inherits as $inherit) {
         $inherit->setCustom($custom)->setCost($cost)->setSn($inherit->genSn(substr($inherit->getSn(), 0, 1)));
         $this->em->persist($inherit);
         $orderIn = $inherit->getOrders()->first();
         if ($orderIn->getKind()->getType() === Avenue::OKT_IN) {
             $orderIn->setRequired($cost);
             $orderIn->setPaid($cost);
         }
         $this->em->persist($orderIn);
     }
     $this->em->flush();
     return true;
 }
Example #4
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);
 }
Example #5
0
 public function getYahooFormAction(GoodsPassport $product)
 {
     $router = $this->container->get('router');
     return $product->getYahooId() ? $router->generate('admin_yahoo_update', array('id' => $product->getId())) : $router->generate('admin_yahoo_create', array('id' => $product->getId()));
 }
Example #6
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;
 }
Example #7
0
 protected function createGoodsUpdateMsg(GoodsPassport $goods, $sn, $cost, $price, $model, $createAt)
 {
     $msgArr = array('title' => 'update-goods', 'id' => $goods->getId(), 'sn' => array($goods->getSn(), $sn), 'cost' => array($goods->getCost(), $cost), 'price' => array($goods->getPrice(), $price), 'model' => array($goods->getModel(), $model));
     return json_encode($msgArr);
 }
Example #8
0
 protected function getColMap(GoodsPassport $product, User $user)
 {
     return $product->isOwn($user) && $user->getRole()->hasAuth('READ_PRODUCT_OWN') || $user->getRole()->hasAuth('READ_PRODUCT_ALL') ? array('A' => $product->getCreatedAt() ? $product->getCreatedAt()->format('Y-m-d H:i:s') : null, 'B' => ($brand = $product->getBrand()) ? $brand->getName() : null, 'C' => ($pattern = $product->getPattern()) ? $pattern->getName() : null, 'D' => $product->getModel(), 'E' => (($color = $product->getColor()) ? $color->getName() . '-' : null) . $product->getColorSn(), 'F' => $product->getOrgSn(), 'G' => ($level = $product->getLevel()) ? $level->getName() : null, 'H' => $product->getName(), 'I' => $product->getSn(), 'J' => $product->getPrice(), 'K' => $product->getCostVerifyed($user), 'L' => ($consigner = $product->getCustom()) ? $consigner->getExcelFormatData() : null, 'M' => $product->getCustomSn()) : array('A' => '無閱讀權限', 'B' => '無閱讀權限', 'C' => '無閱讀權限', 'D' => $product->getModel(), 'E' => '無閱讀權限', 'F' => '無閱讀權限', 'G' => '無閱讀權限', 'H' => $product->getName(), 'I' => $product->getSn(), 'J' => '無閱讀權限', 'K' => '無閱讀權限', 'L' => '無閱讀權限', 'M' => '無閱讀權限');
 }
Example #9
0
 /**
  * Is product status_id equal to Avenue::GS_BSO_SOLD
  *
  * @param  \Woojin\GoodsBundle\Entity\GoodsPassport  $product
  * @return boolean
  */
 protected function isProductBsoSold(GoodsPassport $product)
 {
     return $product->isProductBsoSold();
 }
Example #10
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;
 }
Example #11
0
 protected function getColMap(GoodsPassport $product)
 {
     return array('A' => '無閱讀權限', 'B' => '無閱讀權限', 'C' => '無閱讀權限', 'D' => $product->getModel(), 'E' => '無閱讀權限', 'F' => '無閱讀權限', 'G' => '無閱讀權限', 'H' => $product->getName(), 'I' => $product->getSn(), 'J' => '無閱讀權限', 'K' => '無閱讀權限', 'L' => '無閱讀權限', 'M' => '無閱讀權限');
 }
Example #12
0
 protected function addInNoborderGroup(GoodsPassport $product, array &$files)
 {
     if ($img = $product->getImg()) {
         $files[] = $img->getPathNoBorder(true);
     }
 }
Example #13
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);
 }
Example #14
0
 public function getProductLocate(GoodsPassport $product)
 {
     $maps = array('Z' => '中和', 'Y' => '永和', 'X' => '新莊', 'P' => '板橋', 'L' => '蘆洲', 'T' => '忠孝', '$' => '倉庫');
     $prefix = substr($product->getSn(), 0, 1);
     return array_key_exists($prefix, $maps) ? $maps[$prefix] : null;
 }
Example #15
0
 public function fetchAuctionsByProduct(GoodsPassport $product)
 {
     $qb = $this->getEntityManager()->createQueryBuilder();
     return $qb->select('auction')->from('WoojinStoreBundle:Auction', 'auction')->where($qb->expr()->eq('auction.product', $product->getId()))->orderBy('auction.id', 'DESC')->getQuery()->getResult();
 }
Example #16
0
 protected function assignStoreCategory(GoodsPassport $product)
 {
     // 90: CHANEL > 全新品 現貨區 > 皮夾
     // 91: CHANEL > 全新品 現貨區 > 包包
     // 92: CHANEL > 全新品 現貨區 > 配件
     // 93: CHANEL > 二手品 現貨區 > 皮夾
     // 94: CHANEL > 二手品 現貨區 > 包包
     // 95: CHANEL > 二手品 現貨區 > 配件
     //
     // 104: CHLOE > 全新品 現貨區
     // 105: CHLOE > 二手品 現貨區
     $cts = array(104, 105);
     // 先新舊[新: 0, 舊: 1]
     $levelIndex = $product->getLevel()->isNew() ? 0 : 1;
     return $cts[$levelIndex];
     //     $patternIndex = $this->assignPatternType($product->getPattern());
     //     return ($patternIndex) ? array($cts[$levelIndex][$patternIndex]) : array(null);
 }
Example #17
0
 /**
  * Calculate the auction percentages for each by passing GoodsPassport entity
  *
  * @param  Woojin\GoodsBundle\Entity\GoodsPassport $product
  * @return array $percentages
  */
 public static function calculatePercentage(GoodsPassport $product)
 {
     $stages = array();
     $percentages = array();
     $stages[] = NULL === $product->getCustom() || false === $product->getIsAllowAuction() ? 0 : $product->getBsoCustomPercentage();
     $stages[] = true === $product->getIsAlanIn() ? 0 : self::DEFAULT_STORE_PERCENTAGE;
     $percentages[] = $stages[0];
     $percentages[] = (100 - $stages[0]) * $stages[1] / 100;
     $percentages[] = 100 - $percentages[0] - $percentages[1];
     foreach ($percentages as $key => $val) {
         $percentages[$key] = $val / 100;
     }
     return $percentages;
 }