1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kaylyu\Alipay\F2fpay\Base\Model\Builder; |
4
|
|
|
|
5
|
|
|
class AlipayTradePayContentBuilder extends ContentBuilder |
6
|
|
|
{ |
7
|
|
|
//支付场景码,此处为条码支付bar_code |
8
|
|
|
private $scene; |
9
|
|
|
|
10
|
|
|
//支付授权码,用户支付宝钱包app点击"付款",在条码下对应的一串数字 |
11
|
|
|
private $authCode; |
12
|
|
|
|
13
|
|
|
// 商户网站订单系统中唯一订单号,64个字符以内,只能包含字母、数字、下划线, |
14
|
|
|
// 需保证商户系统端不能重复,建议通过数据库sequence生成, |
15
|
|
|
private $outTradeNo; |
16
|
|
|
|
17
|
|
|
// 卖家支付宝账号ID,用于支持一个签约账号下支持打款到不同的收款账号,(打款到sellerId对应的支付宝账号) |
18
|
|
|
// 如果该字段为空,则默认为与支付宝签约的商户的PID,也就是appid对应的PID |
19
|
|
|
private $sellerId; |
20
|
|
|
|
21
|
|
|
// 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元 |
22
|
|
|
// 如果同时传入了【打折金额】,【不可打折金额】,【订单总金额】三者,则必须满足如下条件:【订单总金额】=【打折金额】+【不可打折金额】 |
23
|
|
|
private $totalAmount; |
24
|
|
|
|
25
|
|
|
// 订单可打折金额,此处单位为元,精确到小数点后2位 |
26
|
|
|
// 可以配合商家平台配置折扣活动,如果订单部分商品参与打折,可以将部分商品总价填写至此字段,默认全部商品可打折 |
27
|
|
|
// 如果该值未传入,但传入了【订单总金额】,【不可打折金额】 则该值默认为【订单总金额】- 【不可打折金额】 |
28
|
|
|
private $discountableAmount; |
29
|
|
|
|
30
|
|
|
// 订单不可打折金额,此处单位为元,精确到小数点后2位,可以配合商家平台配置折扣活动,如果酒水不参与打折,则将对应金额填写至此字段 |
31
|
|
|
// 如果该值未传入,但传入了【订单总金额】,【打折金额】,则该值默认为【订单总金额】-【打折金额】 |
32
|
|
|
private $undiscountableAmount; |
33
|
|
|
|
34
|
|
|
// 订单标题,粗略描述用户的支付目的。如“XX品牌XXX门店消费” |
35
|
|
|
private $subject; |
36
|
|
|
|
37
|
|
|
// 订单描述,可以对交易或商品进行一个详细地描述,比如填写"购买商品2件共15.00元" |
38
|
|
|
private $body; |
39
|
|
|
|
40
|
|
|
// 商品明细列表,需填写购买商品详细信息, |
41
|
|
|
private $goodsDetailList = array(); |
42
|
|
|
|
43
|
|
|
// 商户操作员编号,添加此参数可以为商户操作员做销售统 |
44
|
|
|
private $operatorId; |
45
|
|
|
|
46
|
|
|
// 商户门店编号,通过门店号和商家后台可以配置精准到门店的折扣信息,详询支付宝技术支持 |
47
|
|
|
private $storeId; |
48
|
|
|
|
49
|
|
|
// 支付宝商家平台中配置的商户门店号,详询支付宝技术支持 |
50
|
|
|
private $alipayStoreId; |
51
|
|
|
|
52
|
|
|
// 商户机具终端编号,当以机具方式接入支付宝时必传,详询支付宝技术支持 |
53
|
|
|
private $terminalId; |
54
|
|
|
|
55
|
|
|
// 业务扩展参数,目前可添加由支付宝分配的系统商编号(通过setSysServiceProviderId方法),详情请咨询支付宝技术支持 |
56
|
|
|
private $extendParams = array(); |
57
|
|
|
|
58
|
|
|
// (推荐使用,相对时间) 支付超时时间,5m 5分钟 |
59
|
|
|
private $timeExpress; |
60
|
|
|
|
61
|
|
|
// ISV (独立软件开发商) |
62
|
|
|
private $sysServiceProviderId; |
63
|
|
|
|
64
|
|
|
private $bizContent = NULL; |
65
|
|
|
|
66
|
|
|
private $bizParas = array(); |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
public function __construct() |
70
|
|
|
{ |
71
|
|
|
$this->bizParas['scene'] = "bar_code"; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function AlipayTradePayContentBuilder() |
75
|
|
|
{ |
76
|
|
|
$this->__construct(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
View Code Duplication |
public function getBizContent() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
/*$this->bizContent = "{"; |
82
|
|
|
foreach ($this->bizParas as $k=>$v){ |
83
|
|
|
$this->bizContent.= "\"".$k."\":\"".$v."\","; |
84
|
|
|
} |
85
|
|
|
$this->bizContent = substr($this->bizContent,0,-1); |
86
|
|
|
$this->bizContent.= "}";*/ |
87
|
|
|
if(!empty($this->bizParas)){ |
88
|
|
|
$this->bizContent = json_encode($this->bizParas,JSON_UNESCAPED_UNICODE); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $this->bizContent; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function getAuthCode() |
95
|
|
|
{ |
96
|
|
|
return $this->authCode; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setAuthCode($authCode) |
100
|
|
|
{ |
101
|
|
|
$this->authCode = $authCode; |
102
|
|
|
$this->bizParas['auth_code'] = $authCode; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function setOutTradeNo($outTradeNo) |
106
|
|
|
{ |
107
|
|
|
$this->outTradeNo = $outTradeNo; |
108
|
|
|
$this->bizParas['out_trade_no'] = $outTradeNo; |
109
|
|
|
} |
110
|
|
|
public function getOutTradeNo() |
111
|
|
|
{ |
112
|
|
|
return $this->outTradeNo; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function setSellerId($sellerId) |
116
|
|
|
{ |
117
|
|
|
$this->sellerId = $sellerId; |
118
|
|
|
$this->bizParas['seller_id'] = $sellerId; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function getSellerId() |
122
|
|
|
{ |
123
|
|
|
return $this->sellerId; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function setTotalAmount($totalAmount) |
127
|
|
|
{ |
128
|
|
|
$this->totalAmount = $totalAmount; |
129
|
|
|
$this->bizParas['total_amount'] = $totalAmount; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getTotalAmount() |
133
|
|
|
{ |
134
|
|
|
return $this->totalAmount; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function setDiscountableAmount($discountableAmount) |
138
|
|
|
{ |
139
|
|
|
$this->discountableAmount = $discountableAmount; |
140
|
|
|
$this->bizParas['discountable_amount'] = $discountableAmount; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getDiscountableAmount() |
144
|
|
|
{ |
145
|
|
|
return $this->discountableAmount; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function setUndiscountableAmount($undiscountableAmount) |
149
|
|
|
{ |
150
|
|
|
$this->undiscountableAmount = $undiscountableAmount; |
151
|
|
|
$this->bizParas['undiscountable_amount'] = $undiscountableAmount; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
public function getUndiscountableAmount() |
155
|
|
|
{ |
156
|
|
|
return $this->undiscountableAmount; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function setSubject($subject) |
160
|
|
|
{ |
161
|
|
|
$this->subject = $subject; |
162
|
|
|
$this->bizParas['subject'] = $subject; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function getSubject() |
166
|
|
|
{ |
167
|
|
|
return $this->subject; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function setBody($body) |
171
|
|
|
{ |
172
|
|
|
$this->body = $body; |
173
|
|
|
$this->bizParas['body'] = $body; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function getBody() |
177
|
|
|
{ |
178
|
|
|
return $this->body; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function setOperatorId($operatorId) |
182
|
|
|
{ |
183
|
|
|
$this->operatorId = $operatorId; |
184
|
|
|
$this->bizParas['operator_id'] = $operatorId; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function getOperatorId() |
188
|
|
|
{ |
189
|
|
|
return $this->operatorId; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function setStoreId($storeId) |
193
|
|
|
{ |
194
|
|
|
$this->storeId = $storeId; |
195
|
|
|
$this->bizParas['store_id'] = $storeId; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
public function getStoreId() |
199
|
|
|
{ |
200
|
|
|
return $this->storeId; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
public function setTerminalId($terminalId) |
204
|
|
|
{ |
205
|
|
|
$this->terminalId = $terminalId; |
206
|
|
|
$this->bizParas['terminal_id'] = $terminalId; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
public function getTerminalId() |
210
|
|
|
{ |
211
|
|
|
return $this->terminalId; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
public function setTimeExpress($timeExpress) |
215
|
|
|
{ |
216
|
|
|
$this->timeExpress = $timeExpress; |
217
|
|
|
$this->bizParas['timeout_express'] = $timeExpress; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function getTimeExpress() |
221
|
|
|
{ |
222
|
|
|
return $this->timeExpress; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
public function getAlipayStoreId() |
226
|
|
|
{ |
227
|
|
|
return $this->alipayStoreId; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
|
231
|
|
|
public function setAlipayStoreId($alipayStoreId) |
232
|
|
|
{ |
233
|
|
|
$this->alipayStoreId = $alipayStoreId; |
234
|
|
|
$this->bizParas['alipay_store_id'] = $alipayStoreId; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function getSysServiceProviderId() |
238
|
|
|
{ |
239
|
|
|
return $this->sysServiceProviderId; |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
|
243
|
|
|
public function setSysServiceProviderId($sysServiceProviderId) |
244
|
|
|
{ |
245
|
|
|
$this->sysServiceProviderId = $sysServiceProviderId; |
246
|
|
|
$this->bizParas['sysServiceProviderId'] = $sysServiceProviderId; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
public function getExtendParams() |
250
|
|
|
{ |
251
|
|
|
return $this->extendParams; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
public function setExtendParams($extendParams) |
255
|
|
|
{ |
256
|
|
|
$this->extendParams = $extendParams; |
257
|
|
|
$this->bizParas['extend_params'] = $extendParams; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
public function getGoodsDetailList() |
261
|
|
|
{ |
262
|
|
|
return $this->goodsDetailList; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
public function setGoodsDetailList($goodsDetailList) |
266
|
|
|
{ |
267
|
|
|
$this->goodsDetailList = $goodsDetailList; |
268
|
|
|
$this->bizParas['goods_detail'] = $goodsDetailList; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.