-
Notifications
You must be signed in to change notification settings - Fork 0
/
composite.php
81 lines (72 loc) · 1.72 KB
/
composite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
abstract class Notify{
private $targetId;
private $msgHandle;
private $msg;
public function __consctruct($targetId,$msg){
$this->targetId=$targetId;
$this->msg=$msg;
}
public function setMsghandle($handle){
$this->msgHandle=$handle;
}
abstract public function send();
abstract public function getPassportId();
}
class AffNotify extends Notify{
public function send(){
$this->sendToAff();
$this->sendToAm();
}
private function sendToAff(){
$this->msgHandle->send($this->targetId,$this->msg);
}
private function sendToAm(){
$amId=$this->getAmIdByAffId($this->targetId);
$this->msgHandle->send($amId,$this->msg);
}
}
class OfferNotify extends Notify{
public function send(){
$this->sendToBd();
}
private function sendToBd(){
$bdId=$this->getBdIdByOfferId($this->targetId);
$this->msgHandle->send($bdId,$this->msg);
}
}
abstract class MessageHandle{
public function __construct(){
}
abstract public function send($passport_id,$msg);
}
class EmailHandle extends MessageHandle{
public function send($passport_id,$msg){
$email=$this->getEmailById($passport_id);
$this->send($email,$msg);
}
}
class InternalMsgHandle extends MessageHandle{
public function send($passport_id,$msg){
$this->insert($passport_id,$msg);
}
}
class EmailAndMsgHandle extends MessageHandle{
public function send($passport_id,$msg){
$emailHandle=new EmailHandle();
$emailHandle->send($passport_id,$msg);
$msghandle=new InternalMsgHandle();
$msgHandle->send($passport_id,$msg);
}
}
if($is_offer_notify){
$notify=new OfferNotify($offerId,$msg);
if($is_send_email){
$msgHandle=new EmailHandle()
}
if($is_send_msg){
$msgHandle=new InternalMsgHandle();
}
$notify->setMsghandle($msgHandle);
$notify->send();
}