/** * 受注編集用フォーム作成. * * @param Customer $Customer * @param Product $Product * @return array */ public function createFormData(Customer $Customer, Product $Product = null) { $faker = $this->getFaker(); $tel = explode('-', $faker->phoneNumber); $email = $faker->safeEmail; $delivery_date = $faker->dateTimeBetween('now', '+ 5 days'); $OrderDetails = array(); if (is_object($Product)) { $ProductClasses = $Product->getProductClasses(); $OrderDetails[] = array('Product' => $Product->getId(), 'ProductClass' => $ProductClasses[0]->getId(), 'price' => $ProductClasses[0]->getPrice02(), 'quantity' => $faker->randomNumber(2), 'tax_rate' => 8); } $Shippings = array(array('name' => array('name01' => $faker->lastName, 'name02' => $faker->firstName), 'kana' => array('kana01' => $faker->lastKanaName, 'kana02' => $faker->firstKanaName), 'company_name' => $faker->company, 'zip' => array('zip01' => $faker->postcode1(), 'zip02' => $faker->postcode2()), 'address' => array('pref' => $faker->numberBetween(1, 47), 'addr01' => $faker->city, 'addr02' => $faker->streetAddress), 'tel' => array('tel01' => $tel[0], 'tel02' => $tel[1], 'tel03' => $tel[2]), 'fax' => array('fax01' => $tel[0], 'fax02' => $tel[1], 'fax03' => $tel[2]), 'Delivery' => 1, 'DeliveryTime' => 1, 'shipping_delivery_date' => array('year' => $delivery_date->format('Y'), 'month' => $delivery_date->format('n'), 'day' => $delivery_date->format('j')))); $order = array('_token' => 'dummy', 'Customer' => $Customer->getId(), 'OrderStatus' => 1, 'name' => array('name01' => $faker->lastName, 'name02' => $faker->firstName), 'kana' => array('kana01' => $faker->lastKanaName, 'kana02' => $faker->firstKanaName), 'company_name' => $faker->company, 'zip' => array('zip01' => $faker->postcode1(), 'zip02' => $faker->postcode2()), 'address' => array('pref' => '5', 'addr01' => $faker->city, 'addr02' => $faker->streetAddress), 'tel' => array('tel01' => $tel[0], 'tel02' => $tel[1], 'tel03' => $tel[2]), 'fax' => array('fax01' => $tel[0], 'fax02' => $tel[1], 'fax03' => $tel[2]), 'email' => $email, 'message' => $faker->text, 'Payment' => 1, 'discount' => 0, 'delivery_fee_total' => 0, 'charge' => 0, 'note' => $faker->text, 'OrderDetails' => $OrderDetails, 'Shippings' => $Shippings); return $order; }
protected function createSendCustomer(\Plugin\MailMagazine\Entity\MailMagazineSendHistory $SendHistory, \Eccube\Entity\Customer $MailCustomer) { // ----------------------------- // plg_send_customer // ----------------------------- $sendId = $SendHistory->getId(); // Entity $SendCustomer = new MailMagazineSendCustomer(); // data $SendCustomer->setSendId($sendId); $SendCustomer->setCustomerId($MailCustomer->getId()); $SendCustomer->setEmail($MailCustomer->getEmail()); $SendCustomer->setName($MailCustomer->getName01() . " " . $MailCustomer->getName02()); $this->app['eccube.plugin.mail_magazine.repository.mail_magazine_send_customer']->updateSendCustomer($SendCustomer); return $SendCustomer; }
/** * ユーザはクーポン1回のみ利用できる * * @param $couponCd * @param $orderId * @param Customer $Customer * @return bool */ public function checkCouponUsedOrNotBefore($couponCd, $orderId, Customer $Customer) { $repository = $this->app['eccube.plugin.coupon.repository.coupon_order']; if ($this->app->isGranted('ROLE_USER')) { $CouponOrders = $repository->findUseCouponBefore($couponCd, $orderId, $Customer->getId()); } else { $CouponOrders = $repository->findUseCouponBefore($couponCd, $orderId, $Customer->getEmail()); } if ($CouponOrders) { // 存在すれば既に受注として利用されていないかチェック foreach ($CouponOrders as $CouponOrder) { $Order = $this->app['eccube.repository.order']->find($CouponOrder->getOrderId()); if ($Order) { if ($Order->getOrderStatus()->getId() != $this->app['config']['order_processing']) { // 同一のクーポンコードで既に受注データが存在している return true; } } } } return false; }