Agreement.php
3.88 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Created by PhpStorm.
* User: Ziy
* Date: 14/8/31
* Time: 下午6:16
*/
class YHMIm_Agreement {
/**
* @param array $messageData
* @return YHMIm_Agreement_Abstract
*/
static function factory(array $messageData) {
switch ($messageData['type']) {
case 'yhm-text':
$agreement = new YHMIm_Agreement_Base_Text();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-image':
$agreement = new YHMIm_Agreement_Base_Images();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-product':
$agreement = new YHMIm_Agreement_Product_Product();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-product-change-price':
$agreement = new YHMIm_Agreement_Product_Change();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-order-info':
$agreement = new YHMIm_Agreement_Order_Info();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-order-close':
$agreement = new YHMIm_Agreement_Order_Close();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-product-reduce-price':
$agreement = new YHMIm_Agreement_Product_ReducePrice();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-message-read':
$agreement = new YHMIm_Agreement_Message_Reader();
$agreement->setReaderData($messageData)->make();
break;
case 'yhm-order-status':
$agreement = new YHMIm_Agreement_Order_Status();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-order-complain':
$agreement = new YHMIm_Agreement_Order_Complain();
$agreement->setQueueData($messageData)->make();
break;
case 'yhm-product-txt':
$agreement = new YHMIm_Agreement_Product_Txt();
$agreement->setQueueData($messageData)->make();
break;
default:
$agreement = new YHMIm_Agreement_Default();
$agreement->setQueueData($messageData)->make();
break;
}
return $agreement;
}
/**
* 格式化输出
* @param array $messageData
* @return YHMIm_Agreement_Abstract
*/
static function format(array $messageData, $uid) {
switch ($messageData['type']) {
case 'yhm-text':
$agreement = new YHMIm_Agreement_Base_Text();
break;
case 'yhm-image':
$agreement = new YHMIm_Agreement_Base_Images();
break;
case 'yhm-product':
$agreement = new YHMIm_Agreement_Product_Info();
break;
case 'yhm-product-change-price':
$agreement = new YHMIm_Agreement_Product_Change();
break;
case 'yhm-order-info':
$agreement = new YHMIm_Agreement_Order_Info();
break;
case 'yhm-order-close':
$agreement = new YHMIm_Agreement_Order_Close();
break;
case 'yhm-product-reduce-price':
$agreement = new YHMIm_Agreement_Product_ReducePrice();
break;
case 'yhm-message-read':
$agreement = new YHMIm_Agreement_Message_Reader();
break;
default:
$agreement = new YHMIm_Agreement_Default();
break;
}
return $agreement->setMongoData($messageData, $uid);
}
}