<?php
namespace Lm\Entity\Cart;
use Lm\Entity\Common\Entity;
use Lm\Entity\Customer;
use Lm\Entity\CustomerShippingAddress;
use Lm\Entity\Order\TransactionInterface;
use Lm\Entity\OrderHeader;
use Lm\Entity\PaymentType;
use Lm\Entity\Shipping;
use Lm\Service\Db\SqlService;
class CartHeader extends Entity implements TransactionInterface
{
const CART_TYPE_NORMAL = 1; // 購入(加工なし)
const CART_TYPE_ESTIMATE = 2; // 見積シミュ(加工あり)
const CART_TYPE_SAMPLE = 3; // 貸出しサンプル
const CART_TYPE_CATALOG = 4;// カタログ請求
/**
* @var string
*/
protected $orderSamNouki;
/**
* @var string
*/
protected $orderSamNoukiComment;
/**
* @var string
*/
protected $orderSamSuuryou;
/**
* @var string
*/
protected $orderSamSuuryouComment;
/**
* @var string
*/
protected $orderSamNaire;
/**
* @var string
*/
protected $orderSamNaireDetail;
/**
* @var string
*/
protected $orderSamNaireComment;
/**
* @var int
*/
protected $inputEigyou;
/**
* @var string
*/
protected $userAgent;
/**
* @var int
*/
protected $eccubePaymentId;
/**
* @var int
*/
protected $taxRate;
/**
* @var int
*/
protected $device;
/**
* @var int
*/
protected $siteType;
/**
* @var int
*/
protected $jhouhou;
/**
* @var int
*/
protected $faId;
/**
* @var int
*/
protected $landingPageId;
/**
* @var int
*/
protected $mmagId;
/**
* @var int|null
*/
protected $shubetsu;
/**
* @var int
*/
protected $customerId;
/**
* @var int
*/
protected $zeusTransferType;
/**
* @var int
*/
protected $zeusLinkpointFlg = OrderHeader::ZEUS_LINKPOINT_FLG_NO;
/**
* @var string
*/
protected $zeusOrdd;
/**
* @var string
*/
protected $amazonPayId;
/**
* @var string
*/
protected $amazonPayReferenceid;
/**
* @var string
*/
protected $amazonPayChargeid;
/**
* @var int
*/
protected $couponCampaignId;
/**
* @var int
*/
protected $ryoushuushou;
/**
* @var string
*/
protected $Atena;
/**
* @var string
*/
protected $ryoushuushouTadashi;
/**
* @var string
*/
protected $ryoushuushouComment;
/**
* @var int|null
*/
protected $customerShippingAddressId;
/**
* @var string
*/
protected $comment;
/**
* @var \DateTime
*/
protected $CDate;
/**
* @var \DateTime
*/
protected $udate;
/**
* @var int
*/
protected $yoyaku = OrderHeader::YOYAKU_NO;
/**
* @var int
*/
protected $yoyakuEx = OrderHeader::YOYAKU_EX_UNAVAILABLE;
/**
* @var string
*/
protected $catalogId;
/**
* @var CartList[]
*/
protected $cartListList = [];
/**
* @var Customer
*/
protected $customer;
/**
* @var CustomerShippingAddress
*/
protected $customerShippingAddress;
/**
* @var PaymentType
*/
protected $paymentType;
/**
* @var Shipping
*/
protected $shipping;
/**
* @var int
*/
protected $largeDiscount;
/**
* @var int
*/
protected $sendcharge;
/**
* @var int
*/
protected $sendchargeService;
/**
* @var int
*/
protected $daibiki;
/**
* @var int
*/
protected $orderType;
/**
* @var int
*/
protected $payment;
/**
* @var int
*/
protected $couponDiscount;
/**
* @var \DateTime
*/
protected $orderDate;
/**
* @var int
*/
protected $daibikiService;
/**
* @var int
*/
protected $atobarai;
/**
* @var int
*/
protected $atobaraiService;
/**
* @param array $data
*/
public function __construct($data = [])
{
//
$this->allowEmpty();
//
parent::__construct($data);
}
/**
* @return string
*/
public function getOrderSamNouki()
{
return $this->orderSamNouki;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamNouki($value)
{
$this->orderSamNouki = $value;
return $this;
}
/**
* @return string
*/
public function getOrderSamNoukiComment()
{
return $this->orderSamNoukiComment;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamNoukiComment($value)
{
$this->orderSamNoukiComment = $value;
return $this;
}
/**
* @return string
*/
public function getOrderSamSuuryou()
{
return $this->orderSamSuuryou;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamSuuryou($value)
{
$this->orderSamSuuryou = $value;
return $this;
}
/**
* @return string
*/
public function getOrderSamSuuryouComment()
{
return $this->orderSamSuuryouComment;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamSuuryouComment($value)
{
$this->orderSamSuuryouComment = $value;
return $this;
}
/**
* @return string
*/
public function getOrderSamNaire()
{
return $this->orderSamNaire;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamNaire($value)
{
$this->orderSamNaire = $value;
return $this;
}
/**
* @return string
*/
public function getOrderSamNaireDetail()
{
return $this->orderSamNaireDetail;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamNaireDetail($value)
{
$this->orderSamNaireDetail = $value;
return $this;
}
/**
* @return string
*/
public function getOrderSamNaireComment()
{
return $this->orderSamNaireComment;
}
/**
* @param string $value
* @return $this
*/
public function setOrderSamNaireComment($value)
{
$this->orderSamNaireComment = $value;
return $this;
}
/**
* @return int
*/
public function getInputEigyou()
{
return $this->inputEigyou;
}
/**
* @param int $value
* @return $this
*/
public function setInputEigyou($value)
{
$this->inputEigyou = $value;
return $this;
}
public function getUserAgent()
{
return $this->userAgent;
}
/**
* @param string $value
* @return $this
*/
public function setUserAgent($value)
{
$this->userAgent = $value;
return $this;
}
/**
* @return int
*/
public function getEccubePaymentId()
{
return $this->eccubePaymentId;
}
/**
* @param int $value
* @return $this
*/
public function setEccubePaymentId($value)
{
$this->eccubePaymentId = $value;
return $this;
}
public function getTaxRate()
{
return $this->taxRate;
}
public function setTaxRate($value)
{
$this->taxRate = $value;
return $this;
}
/**
* @return int
*/
public function getSiteType()
{
return $this->siteType;
}
/**
* @param int $value
* @return $this
*/
public function setSiteType($value)
{
$this->siteType = $value;
return $this;
}
/**
* @return int
*/
public function getJhouhou()
{
return $this->jhouhou;
}
/**
* @param int $jhouhou
* @return $this
*/
public function setJhouhou($jhouhou)
{
$this->jhouhou = $jhouhou;
return $this;
}
/**
* @return int
*/
public function getFaId()
{
return $this->faId;
}
/**
* @param int $faId
* @return $this
*/
public function setFaId($faId)
{
$this->faId = $faId;
return $this;
}
/**
* @return int
*/
public function getLandingPageId()
{
return $this->landingPageId;
}
/**
* @param int $landingPageId
* @return $this
*/
public function setLandingPageId($landingPageId)
{
$this->landingPageId = $landingPageId;
return $this;
}
/**
* @return int
*/
public function getMmagId()
{
return $this->mmagId;
}
/**
* @param int $mmagId
* @return $this
*/
public function setMmagId($mmagId)
{
$this->mmagId = $mmagId;
return $this;
}
/**
* @return PaymentType
* @throws \Exception
*/
public function getPaymentType()
{
//
return self::compute($this->payment, function () {
//
return PaymentType::getInstance($this->getPayment());
});
}
/**
* @return int|null
*/
public function getShubetsu()
{
return $this->shubetsu;
}
/**
* @param int|null $shubetsu
* @return $this
*/
public function setShubetsu($shubetsu)
{
$this->shubetsu = $shubetsu;
return $this;
}
/**
* @return int
*/
public function getCustomerId()
{
return $this->customerId;
}
/**
* @param int $customerId
* @return $this
*/
public function setCustomerId($customerId)
{
$this->customerId = $customerId;
return $this;
}
/**
* @return int
*/
public function getZeusTransferType()
{
return $this->zeusTransferType;
}
/**
* @param int $zeusTransferType
* @return $this
*/
public function setZeusTransferType($zeusTransferType)
{
$this->zeusTransferType = $zeusTransferType;
return $this;
}
/**
* @return int
*/
public function getZeusLinkpointFlg()
{
return $this->zeusLinkpointFlg;
}
/**
* @param int $zeusLinkpointFlg
* @return $this
*/
public function setZeusLinkpointFlg($zeusLinkpointFlg)
{
$this->zeusLinkpointFlg = $zeusLinkpointFlg;
return $this;
}
/**
* @return string
*/
public function getZeusOrdd()
{
return $this->zeusOrdd;
}
/**
* @param string $zeusOrdd
* @return $this
*/
public function setZeusOrdd($zeusOrdd)
{
$this->zeusOrdd = $zeusOrdd;
return $this;
}
/**
* @return string
*/
public function getAmazonPayId()
{
return $this->amazonPayId;
}
/**
* @param string $amazonPayId
* @return $this
*/
public function setAmazonPayId($amazonPayId)
{
$this->amazonPayId = $amazonPayId;
return $this;
}
/**
* @return string
*/
public function getAmazonPayReferenceid()
{
return $this->amazonPayReferenceid;
}
/**
* @param string $amazonPayReferenceid
* @return $this
*/
public function setAmazonPayReferenceid($amazonPayReferenceid)
{
$this->amazonPayReferenceid = $amazonPayReferenceid;
return $this;
}
/**
* @return string
*/
public function getAmazonPayChargeid()
{
return $this->amazonPayChargeid;
}
/**
* @param string $amazonPayChargeid
* @return $this
*/
public function setAmazonPayChargeid($amazonPayChargeid)
{
$this->amazonPayChargeid = $amazonPayChargeid;
return $this;
}
/**
* @return int
*/
public function getCouponCampaignId()
{
return $this->couponCampaignId;
}
/**
* @param int $couponCampaignId
* @return $this
*/
public function setCouponCampaignId($couponCampaignId)
{
$this->couponCampaignId = $couponCampaignId;
return $this;
}
/**
* @return int
*/
public function getRyoushuushou()
{
return $this->ryoushuushou;
}
/**
* @param int $ryoushuushou
* @return $this
*/
public function setRyoushuushou($ryoushuushou)
{
$this->ryoushuushou = $ryoushuushou;
return $this;
}
/**
* @return string
*/
public function getAtena()
{
return $this->Atena;
}
/**
* @param string $Atena
* @return $this
*/
public function setAtena($Atena)
{
$this->Atena = $Atena;
return $this;
}
/**
* @return string
*/
public function getRyoushuushouTadashi()
{
return $this->ryoushuushouTadashi;
}
/**
* @param string $ryoushuushouTadashi
* @return $this
*/
public function setRyoushuushouTadashi($ryoushuushouTadashi)
{
$this->ryoushuushouTadashi = $ryoushuushouTadashi;
return $this;
}
/**
* @return string
*/
public function getRyoushuushouComment()
{
return $this->ryoushuushouComment;
}
/**
* @param string $ryoushuushouComment
* @return $this
*/
public function setRyoushuushouComment($ryoushuushouComment)
{
$this->ryoushuushouComment = $ryoushuushouComment;
return $this;
}
/**
* @return int|null
*/
public function getCustomerShippingAddressId()
{
return $this->customerShippingAddressId;
}
/**
* @return string
*/
public function getSendCompany()
{
return $this->sendCompany;
}
/**
* @param string $sendCompany
* @return $this
*/
public function setSendCompany($sendCompany)
{
//
$this->sendCompany = $sendCompany;
//
return $this;
}
/**
* @return string
*/
public function getSendName()
{
return $this->sendName;
}
/**
* @param string $sendName
* @return $this
*/
public function setSendName($sendName)
{
//
$this->sendName = $sendName;
//
return $this;
}
/**
* @return string
*/
public function getSendTel()
{
return $this->sendTel;
}
/**
* @param string $sendTel
* @return $this
*/
public function setSendTel($sendTel)
{
//
$this->sendTel = $sendTel;
//
return $this;
}
/**
* @return string
*/
public function getSendPostcode()
{
return $this->sendPostcode;
}
/**
* @param string $sendPostcode
* @return $this
*/
public function setSendPostcode($sendPostcode)
{
//
$this->sendPostcode = $sendPostcode;
//
return $this;
}
/**
* @return int
*/
public function getSendPrefecture()
{
return $this->sendPrefecture;
}
/**
* @param string $sendPrefecture
* @return $this
*/
public function setSendPrefecture($sendPrefecture)
{
//
$this->sendPrefecture = $sendPrefecture;
//
return $this;
}
/**
* @return string
*/
public function getSendAddress1()
{
return $this->sendAddress1;
}
/**
* @param string $sendAddress1
* @return $this
*/
public function setSendAddress1($sendAddress1)
{
//
$this->sendAddress1 = $sendAddress1;
//
return $this;
}
/**
* @return string
*/
public function getSendAddress2()
{
return $this->sendAddress2;
}
/**
* @param string $sendAddress2
* @return $this
*/
public function setSendAddress2($sendAddress2)
{
//
$this->sendAddress2 = $sendAddress2;
//
return $this;
}
/**
* @return string
*/
public function getSendAddress3()
{
return $this->sendAddress3;
}
/**
* @param string $sendAddress3
* @return $this
*/
public function setSendAddress3($sendAddress3)
{
//
$this->sendAddress3 = $sendAddress3;
//
return $this;
}
/**
* @param int|null $customerShippingAddressId
* @return $this
*/
public function setCustomerShippingAddressId($customerShippingAddressId)
{
//
$this->customerShippingAddressId = $customerShippingAddressId;
//
return $this;
}
/**
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* @param string $comment
* @return $this
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* @return \DateTime
*/
public function getCDate()
{
return $this->CDate;
}
/**
* @param \DateTime $CDate
* @return $this
*/
public function setCDate($CDate)
{
$this->CDate = $CDate;
return $this;
}
/**
* @return \DateTime
*/
public function getUdate()
{
return $this->udate;
}
/**
* @param \DateTime $udate
* @return $this
*/
public function setUdate($udate)
{
$this->udate = $udate;
return $this;
}
/**
* @return int
*/
public function getYoyaku()
{
return $this->yoyaku;
}
/**
* @param int $yoyaku
* @return $this
*/
public function setYoyaku($yoyaku)
{
$this->yoyaku = $yoyaku;
return $this;
}
/**
* @return int
*/
public function getYoyakuEx()
{
return $this->yoyakuEx;
}
/**
* @param int $yoyakuEx
* @return $this
*/
public function setYoyakuEx($yoyakuEx)
{
$this->yoyakuEx = $yoyakuEx;
return $this;
}
/**
* @return string
*/
public function getCatalogId()
{
return $this->catalogId;
}
/**
* @param string $catalogId
* @return $this
*/
public function setCatalogId($catalogId)
{
$this->catalogId = $catalogId;
return $this;
}
/**
* @return CartList[]
*/
public function getCartListList()
{
return $this->cartListList;
}
/**
* @param CartList[] $cartListList
* @return $this
*/
public function setCartListList($cartListList)
{
$this->cartListList = $cartListList;
return $this;
}
/**
* @return int
*/
public function getDevice()
{
return $this->device;
}
/**
* @param int $device
* @return $this
*/
public function setDevice($device)
{
$this->device = $device;
return $this;
}
/**
* @return Customer
* @throws \Exception
*/
public function getCustomer()
{
//
if (empty($this->customer)) {
//
if ($customer = $this->findCustomer()) {
//
$this->customer = new Customer($customer);
}
}
return $this->customer;
}
/**
* @return CustomerShippingAddress
* @throws \Exception
*/
public function getCustomerShippingAddress()
{
//
if (empty($this->customerShippingAddress)) {
//
if ($this->customerShippingAddress = $this->findCustomerShippingAddress()) {
//
$this->customerShippingAddress = new CustomerShippingAddress($this->customerShippingAddress);
}
}
return $this->customerShippingAddress;
}
/**
* @param CustomerShippingAddress $customerShippingAddress
* @return $this
*/
public function setCustomerShippingAddress(CustomerShippingAddress $customerShippingAddress)
{
//
$this->customerShippingAddress = $customerShippingAddress;
//
return $this;
}
/**
* @return int
*/
public function getCartType()
{
$cartType = CartHeader::CART_TYPE_NORMAL;
switch (self::getOrderType()) {
case OrderHeader::TYPE_PURCHASE:
if (self::getShubetsu() === 'c') {
$cartType = CartHeader::CART_TYPE_NORMAL;
} elseif (self::getShubetsu() === 'm') {
$cartType = CartHeader::CART_TYPE_ESTIMATE;
}
break;
case OrderHeader::TYPE_SAMPLE:
$cartType = CartHeader::CART_TYPE_SAMPLE;
break;
case OrderHeader::TYPE_CATALOG:
$cartType = CartHeader::CART_TYPE_CATALOG;
break;
}
return $cartType;
}
/**
* @return array|null
*/
public function findCustomer()
{
//
$customerId = $this->getCustomerId();
//
$result = (new SqlService())
->Table(Customer::TABLE_NAME)
->Set('customer_id', $customerId)
->Find();
//
return $result;
}
/**
* @return array|null
*/
public function findCustomerShippingAddress()
{
//
$customerShippingAddressId = $this->getCustomerShippingAddressId();
//
$result = (new SqlService())
->Table(CustomerShippingAddress::TABLE_NAME)
->Set('csa_id', $customerShippingAddressId)
->Find();
//
return $result;
}
/**
* @inheritDoc
*/
public function getSubtotal()
{
//
$subtotal = 0;
//
foreach ($this->getCartListList() as $cartList) {
//
foreach ($cartList->getCartGoodsListList() as $cartGoodsList) {
//
$subtotal += ($cartGoodsList->getTanka() * $cartGoodsList->getAmount());
$subtotal += $cartGoodsList->getSusoagePrice();
}
//
foreach ($cartList->getCartPrintListList() as $cartPrintList) {
//
foreach ($cartPrintList->getCartPrintDetailList() as $cartPrintDetail) {
//
$subtotal += ($cartPrintDetail->getTanka() * $cartPrintDetail->getAmount());
}
}
//
$subtotal += $cartList->getOlKoguchi();
}
//
return $subtotal;
}
/**
* @return int
*/
public function getLargeDiscount()
{
//
return $this->largeDiscount;
}
/**
* @return int
*/
public function getSendcharge()
{
//
return $this->sendcharge;
}
/**
* @return int
*/
public function getSendchargeService()
{
//
return $this->sendchargeService;
}
/**
* @return int
*/
public function getDaibiki()
{
//
return $this->daibiki;
}
/**
* @return int
*/
public function getDaibikiService()
{
//
return $this->daibikiService;
}
/**
* @return int
*/
public function getAtobarai()
{
//
return $this->atobarai;
}
/**
* @return int
*/
public function getAtobaraiService()
{
//
return $this->atobaraiService;
}
/**
* @inheritDoc
*/
public function getOrderType()
{
return $this->orderType;
}
/**
* @inheritDoc
*/
public function getPayment()
{
return $this->payment;
}
/**
* @inheritDoc
*/
public function getCouponDiscount()
{
return $this->couponDiscount;
}
/**
* @inheritDoc
*/
public function getOrderDate()
{
return $this->orderDate;
}
/**
* @inheritDoc
*/
public function setLargeDiscount($largeDiscount)
{
//
$this->largeDiscount = $largeDiscount;
//
return $this;
}
/**
* @inheritDoc
*/
public function setSendcharge($sendcharge)
{
//
$this->sendcharge = $sendcharge;
//
return $this;
}
/**
* @inheritDoc
*/
public function setSendchargeService($sendchargeService)
{
//
$this->sendchargeService = $sendchargeService;
//
return $this;
}
/**
* @inheritDoc
*/
public function setDaibiki($daibiki)
{
//
$this->daibiki = $daibiki;
//
return $this;
}
/**
* @inheritDoc
*/
public function setOrderType($orderType)
{
//
$this->orderType = $orderType;
//
return $this;
}
/**
* @inheritDoc
*/
public function setPayment($payment)
{
//
$this->payment = $payment;
//
return $this;
}
/**
* @inheritDoc
*/
public function setCouponDiscount($couponDiscount)
{
//
$this->couponDiscount = $couponDiscount;
//
return $this;
}
/**
* @inheritDoc
*/
public function setOrderDate($orderDate)
{
//
$this->orderDate = $orderDate;
//
return $this;
}
/**
* @inheritDoc
*/
public function getShipping()
{
return self::compute($this->shipping, function () {
//
if ($csa = $this->getCustomerShippingAddress()) {
return Shipping::getInstance($csa->getCsaCompany(), $csa->getCsaUserName(), $csa->getCsaPostcode(), $csa->getCsaPrefecture(), $csa->getCsaAddress1(), $csa->getCsaAddress2(), $csa->getCsaAddress3(), $csa->getCsaTel(), null);
} else {
return null;
}
});
}
/**
* @inheritDoc
*/
public function setDaibikiService($daibikiService)
{
//
$this->daibikiService = $daibikiService;
//
return $this;
}
/**
* @inheritDoc
*/
public function setAtobarai($atobarai)
{
//
$this->atobarai = $atobarai;
//
return $this;
}
/**
* @inheritDoc
*/
public function setAtobaraiService($atobaraiService)
{
//
$this->atobaraiService = $atobaraiService;
//
return $this;
}
}