app/Plugin/np42/Entity/OrderAtone.php line 20

Open in your IDE?
  1. <?php
  2. namespace Plugin\np42\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Eccube\Entity\Master\OrderStatus;
  5. use Eccube\Entity\Order;
  6. use Plugin\np42\Service\PaymentApi\Cancel;
  7. use Plugin\np42\Service\PaymentApi\Capture;
  8. use Plugin\np42\Service\PaymentApi\Change;
  9. use Plugin\np42\Service\PaymentApi\Register;
  10. use Plugin\np42\ValueObject\ServiceType;
  11. /**
  12.  * OrderAtone
  13.  *
  14.  * @ORM\Table(name="plg_np42_order_atone")
  15.  * @ORM\Entity(repositoryClass="Plugin\np42\Repository\OrderAtoneRepository")
  16.  */
  17. class OrderAtone
  18. {
  19.     /** atone決済状況 オーソリ @var int */
  20.     const ATONE_STATUS_AUTH 1;
  21.     /** atone決済状況 売上 @var int */
  22.     const ATONE_STATUS_CAPTURE 2;
  23.     /** atone決済状況 キャンセル @var int */
  24.     const ATONE_STATUS_CANCEL 3;
  25.     /** atone決済状況 仮登録 @var int */
  26.     const ATONE_STATUS_TEMPORARY_REGISTER 4;
  27.     /**
  28.      * atone決済状況
  29.      * @var array
  30.      */
  31.     const ATONE_STATUS_LIST = [
  32.         self::ATONE_STATUS_AUTH => 'オーソリ',
  33.         self::ATONE_STATUS_CAPTURE => '売上',
  34.         self::ATONE_STATUS_CANCEL => 'キャンセル',
  35. //        self::ATONE_STATUS_TEMPORARY_REGISTER => '仮登録',
  36.     ];
  37.     /**
  38.      * atone サービス種別
  39.      * @var array
  40.      */
  41.     const ATONE_SERVICE_TYPE_LIST = [
  42.         ServiceType::TYPE_ATONE => '翌月',
  43.         ServiceType::TYPE_TSU_DO_ATONE => 'つど',
  44.     ];
  45.     /**
  46.      * @var int
  47.      *
  48.      * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  49.      * @ORM\Id
  50.      * @ORM\GeneratedValue(strategy="IDENTITY")
  51.      */
  52.     private $id;
  53.     /**
  54.      * @var Order
  55.      * @ORM\ManyToOne(targetEntity="Eccube\Entity\Order", inversedBy="OrderAtone")
  56.      * @ORM\JoinColumns({
  57.      *   @ORM\JoinColumn(name="order_id", referencedColumnName="id")
  58.      * })
  59.      */
  60.     private $Order;
  61.     /**
  62.      * @var int $atone_status_id atone受注ステータスID
  63.      * @ORM\Column(name="atone_status_id", type="text", options={"default":"1", "comment":"atone受注ステータスID"})
  64.      */
  65.     private $atone_status_id;
  66.     /**
  67.      * @var string
  68.      * @ORM\Column(name="atone_service_type", type="text", nullable=true, options={"default":"", "comment": "atone サービス種別 01=atone翌月払い、04=atoneつど後払い"})
  69.      */
  70.     private $atone_service_type '';
  71.     /**
  72.      * @var string $company_code 加盟企業コード
  73.      * @ORM\Column(name="company_code", type="text", options={"default":"", "comment": "加盟企業コード"})
  74.      */
  75.     private $company_code '';
  76.     /**
  77.      * @var string
  78.      * @ORM\Column(name="shop_branch_code", type="text", options={"default":"", "comment": "店舗支店コード"})
  79.      */
  80.     private $shop_branch_code '';
  81.     /**
  82.      * @var string $atone_module_authentication_token
  83.      *
  84.      * @ORM\Column(name="atone_module_authentication_token", type="text", options={"default":"", "comment": "決済認証トークン"})
  85.      */
  86.     private $atone_module_authentication_token '';
  87.     /**
  88.      * @var string
  89.      * @ORM\Column(name="shop_transaction_no", type="text", options={"default":"", "comment": "加盟店取引ID 半角英数字"})
  90.      */
  91.     private $shop_transaction_no '';
  92.     /**
  93.      * @var string $transaction_id
  94.      * @ORM\Column(name="transaction_id", type="text", options={"default":"", "comment": "取引ID format:YYMMDDXXXXXX"})
  95.      */
  96.     private $transaction_id '';
  97.     /**
  98.      * @var string $authorization_result 与信結果
  99.      * @ORM\Column(name="authorization_result", type="text", options={"default":"", "comment": "与信結果"})
  100.      */
  101.     private $authorization_result '';
  102.     /**
  103.      * @var string $authorization_result_ng_reason 与信NG事由
  104.      * @ORM\Column(name="authorization_result_ng_reason", type="text", options={"default":"", "comment": "与信NG事由"})
  105.      */
  106.     private $authorization_result_ng_reason '';
  107.     /**
  108.      * @var string
  109.      * @ORM\Column(name="authori_hold", type="text", options={"default":"", "comment": "与信保留事由"})
  110.      */
  111.     private $authori_hold '';
  112.     /**
  113.      * @var string $amount atone顧客請求金額
  114.      * @ORM\Column(name="amount", type="integer", options={"default":0, "comment": "顧客請求金額"})
  115.      */
  116.     private $amount;
  117.     /**
  118.      * md5でハッシュ化された受注情報
  119.      *
  120.      * @var string $order_atone_detail_md5
  121.      *
  122.      * @ORM\Column(name="order_atone_detail_md5", type="text", length=65532, options={"default":"", "comment": "atone md5でハッシュ化された受注情報"})
  123.      */
  124.     private $order_atone_detail_md5 '';
  125.     /**
  126.      * @var string $order_diff
  127.      *
  128.      * @ORM\Column(name="order_diff", type="text", nullable=true, options={"default":"", "comment": "atone 差分情報"})
  129.      */
  130.     private $order_diff '';
  131.     /**
  132.      * @var \DateTime
  133.      *
  134.      * @ORM\Column(name="create_date", type="datetimetz", options={"comment": "作成日時"})
  135.      */
  136.     private $create_date;
  137.     /**
  138.      * @var \DateTime
  139.      *
  140.      * @ORM\Column(name="update_date", type="datetimetz", options={"comment": "更新日時"})
  141.      */
  142.     private $update_date;
  143.     public function getOrder()
  144.     {
  145.         return $this->Order;
  146.     }
  147.     public function setOrder(Order $Order)
  148.     {
  149.         $this->Order $Order;
  150.         return $this;
  151.     }
  152.     /**
  153.      * Get atone_status_id
  154.      *
  155.      * @return integer
  156.      */
  157.     public function getAtoneStatusId()
  158.     {
  159.         return $this->atone_status_id;
  160.     }
  161.     /**
  162.      * Set atone_status_id
  163.      *
  164.      * @param integer $atone_status_id
  165.      *
  166.      * @return OrderAtone
  167.      */
  168.     public function setAtoneStatusId(int $atone_status_id)
  169.     {
  170.         $this->atone_status_id $atone_status_id;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return string|null
  175.      */
  176.     public function getAtoneServiceType(): ?string
  177.     {
  178.         return $this->atone_service_type;
  179.     }
  180.     /**
  181.      * @param string|null $atone_service_type
  182.      */
  183.     public function setAtoneServiceType(?string $atone_service_type): self
  184.     {
  185.         $this->atone_service_type $atone_service_type;
  186.         return $this;
  187.     }
  188.     public function getId(): ?int
  189.     {
  190.         return $this->id;
  191.     }
  192.     public function getCompanyCode(): ?string
  193.     {
  194.         return $this->company_code;
  195.     }
  196.     public function setCompanyCode(string $company_code): self
  197.     {
  198.         $this->company_code $company_code;
  199.         return $this;
  200.     }
  201.     public function getShopBranchCode(): ?string
  202.     {
  203.         return $this->shop_branch_code;
  204.     }
  205.     public function setShopBranchCode(string $shop_branch_code): self
  206.     {
  207.         $this->shop_branch_code $shop_branch_code;
  208.         return $this;
  209.     }
  210.     public function getAtoneModuleAuthenticationToken(): ?string
  211.     {
  212.         return $this->atone_module_authentication_token;
  213.     }
  214.     public function setAtoneModuleAuthenticationToken(string $atone_module_authentication_token): self
  215.     {
  216.         $this->atone_module_authentication_token $atone_module_authentication_token;
  217.         return $this;
  218.     }
  219.     public function getShopTransactionNo(): ?string
  220.     {
  221.         return $this->shop_transaction_no;
  222.     }
  223.     public function setShopTransactionNo(string $shop_transaction_no): self
  224.     {
  225.         $this->shop_transaction_no $shop_transaction_no;
  226.         return $this;
  227.     }
  228.     public function getTransactionId(): ?string
  229.     {
  230.         return $this->transaction_id;
  231.     }
  232.     public function setTransactionId(string $transaction_id): self
  233.     {
  234.         $this->transaction_id $transaction_id;
  235.         return $this;
  236.     }
  237.     public function getAuthorizationResult(): ?string
  238.     {
  239.         return $this->authorization_result;
  240.     }
  241.     public function setAuthorizationResult(string $authorization_result): self
  242.     {
  243.         $this->authorization_result $authorization_result;
  244.         return $this;
  245.     }
  246.     public function getAuthorizationResultNgReason(): ?string
  247.     {
  248.         return $this->authorization_result_ng_reason;
  249.     }
  250.     public function setAuthorizationResultNgReason(string $authorization_result_ng_reason): self
  251.     {
  252.         $this->authorization_result_ng_reason $authorization_result_ng_reason;
  253.         return $this;
  254.     }
  255.     public function getAuthoriHold(): ?string
  256.     {
  257.         return $this->authori_hold;
  258.     }
  259.     public function setAuthoriHold(string $authori_hold): self
  260.     {
  261.         $this->authori_hold $authori_hold;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return string
  266.      */
  267.     public function getAmount(): string
  268.     {
  269.         return $this->amount;
  270.     }
  271.     /**
  272.      * @param string $amount
  273.      */
  274.     public function setAmount(string $amount): self
  275.     {
  276.         $this->amount $amount;
  277.         return $this;
  278.     }
  279.     /**
  280.      * Set createDate.
  281.      *
  282.      * @param \DateTime $createDate
  283.      *
  284.      * @return $this
  285.      */
  286.     public function setCreateDate($createDate): self
  287.     {
  288.         $this->create_date $createDate;
  289.         return $this;
  290.     }
  291.     /**
  292.      * Get createDate.
  293.      *
  294.      * @return \DateTime
  295.      */
  296.     public function getCreateDate()
  297.     {
  298.         return $this->create_date;
  299.     }
  300.     /**
  301.      * Set updateDate.
  302.      *
  303.      * @param \DateTime $updateDate
  304.      *
  305.      * @return $this
  306.      */
  307.     public function setUpdateDate($updateDate): self
  308.     {
  309.         $this->update_date $updateDate;
  310.         return $this;
  311.     }
  312.     /**
  313.      * Get updateDate.
  314.      *
  315.      * @return \DateTime
  316.      */
  317.     public function getUpdateDate()
  318.     {
  319.         return $this->update_date;
  320.     }
  321.     public function getOrderAtoneDetailMd5(): string
  322.     {
  323.         return $this->order_atone_detail_md5;
  324.     }
  325.     public function setOrderAtoneDetailMd5(string $order_atone_detail_md5): self
  326.     {
  327.         $this->order_atone_detail_md5 $order_atone_detail_md5;
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return string|null
  332.      */
  333.     public function getOrderDiff(): ?string
  334.     {
  335.         return $this->order_diff;
  336.     }
  337.     /**
  338.      * @param string|null $order_diff
  339.      */
  340.     public function setOrderDiff(?string $order_diff): self
  341.     {
  342.         $this->order_diff $order_diff;
  343.         return $this;
  344.     }
  345.     public function getCancelRequestAction(): string
  346.     {
  347.         // 取引キャンセル
  348.         if ($this->getAtoneStatusId() != self::ATONE_STATUS_CANCEL) {
  349.             return Cancel::__REQUEST_ACTION;
  350.         }
  351.         return '';
  352.     }
  353.     public function getSubmitRequestAction(): string
  354.     {
  355.         /** * @var \Eccube\Entity\Order $Order */
  356.         $Order $this->getOrder();
  357.         // 取引登録
  358.         // 売上確定
  359.         if ($this->getOrderAtoneDetailMd5() === $Order->getOrderAtoneDetailMd5()
  360.             && $Order->getOrderStatus()->getId() != OrderStatus::CANCEL
  361.             && $this->getAtoneStatusId() != self::ATONE_STATUS_CAPTURE
  362.             && $this->getAtoneStatusId() != self::ATONE_STATUS_CANCEL
  363.             // 与信NG事由がない
  364.             && empty($this->getAuthorizationResultNgReason())
  365.             // 与信保留事由がない
  366.             && empty($this->getAuthoriHold())
  367.         ) {
  368.             return Capture::__REQUEST_ACTION;
  369.         }
  370.         // 取引更新
  371.         if ($this->getOrderAtoneDetailMd5() != $Order->getOrderAtoneDetailMd5()
  372.             && $Order->getOrderStatus()->getId() != OrderStatus::CANCEL
  373.             && $this->getAtoneStatusId() != self::ATONE_STATUS_CAPTURE
  374.             && $this->getAtoneStatusId() != self::ATONE_STATUS_CANCEL
  375.         ) {
  376.             return Change::__REQUEST_ACTION;
  377.         }
  378.         return '';
  379.     }
  380. }