Beispiel #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;
 }
Beispiel #2
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;
 }
Beispiel #3
0
 /**
  * Get the specify goods detail information, 這邊其實可以用 JMS  serialize 直接序列物件
  *
  * @Route("/api/{id}", requirements={"id" = "\d+"}, name="api_get_goods_detail", options={"expose"=true})
  * @ParamConverter("goods", class="WoojinGoodsBundle:GoodsPassport")
  * @Method("GET")
  */
 public function apiShowActivityGoodsDetailAction(Request $request, GoodsPassport $goods)
 {
     $rData = array();
     $em = $this->getDoctrine()->getManager();
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $role = $user->getRole();
     $oMt = $goods->getMt();
     $oImg = $goods->getImg();
     $oGoodsLevel = $goods->getLevel();
     $oGoodsSource = $goods->getSource();
     $oGoodsStatus = $goods->getStatus();
     $rData['id'] = $goods->getId();
     $rData['sn'] = $goods->getSn();
     $rData['name'] = $goods->getName();
     $rData['price'] = $goods->getPrice();
     $rData['cost'] = $role->hasAuth('READ_COST_OWN') && $goods->isOwnProduct($user) || $role->hasAuth('READ_COST_ALL') ? $goods->getCost() : null;
     $rData['memo'] = $goods->getMemo();
     $rData['level'] = is_object($oGoodsLevel) ? $oGoodsLevel->getName() : '未設定';
     $rData['material'] = is_object($oMt) ? $oMt->getName() : '未設定';
     $rData['source'] = is_object($oGoodsSource) ? $oGoodsSource->getName() : '未設定';
     $rData['imgURL'] = is_object($oImg) ? $oImg->getPath() : '';
     $rData['status'] = is_object($oGoodsStatus) ? $oGoodsStatus->getName() : '未知';
     $rData['model'] = $goods->getModel();
     $rData['pattern'] = $goods->getPattern()->getName();
     $rData['brand'] = $goods->getBrand()->getName();
     $response = new Response(json_encode($rData));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Beispiel #4
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' => '無閱讀權限');
 }
Beispiel #5
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' => '無閱讀權限');
 }