Completed
Push — master ( 215a50...b22f79 )
by lyu
01:58
created

AlipayTradePrecreateContentBuilder   A

Complexity

Total Complexity 34

Size/Duplication

Total Lines 254
Duplicated Lines 5.51 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 14
loc 254
ccs 0
cts 151
cp 0
rs 9.68
c 0
b 0
f 0
wmc 34
lcom 1
cbo 1

33 Methods

Rating   Name   Duplication   Size   Complexity  
A setOutTradeNo() 0 5 1
A getOutTradeNo() 0 4 1
A setSellerId() 0 5 1
A getSellerId() 0 4 1
A setTotalAmount() 0 5 1
A getTotalAmount() 0 4 1
A setDiscountableAmount() 0 5 1
A getDiscountableAmount() 0 4 1
A setUndiscountableAmount() 0 5 1
A getUndiscountableAmount() 0 4 1
A setBuyerLogonId() 0 5 1
A getBuyerLogonId() 0 4 1
A setSubject() 0 5 1
A getSubject() 0 4 1
A setBody() 0 5 1
A getBody() 0 4 1
A setOperatorId() 0 5 1
A getOperatorId() 0 4 1
A setStoreId() 0 5 1
A getStoreId() 0 4 1
A getSysServiceProviderId() 0 4 1
A setSysServiceProviderId() 0 5 1
A setTerminalId() 0 5 1
A getTerminalId() 0 4 1
A setTimeExpress() 0 5 1
A getTimeExpress() 0 4 1
A getAlipayStoreId() 0 4 1
A setAlipayStoreId() 0 5 1
A getExtendParams() 0 4 1
A setExtendParams() 0 5 1
A getGoodsDetailList() 0 4 1
A setGoodsDetailList() 0 5 1
A getBizContent() 14 14 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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

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.

Loading history...
245
    {
246
        /*$this->bizContent = "{";
247
        foreach ($this->bizParas as $k=>$v){
248
            $this->bizContent.= "\"".$k."\":\"".$v."\",";
249
        }
250
        $this->bizContent = substr($this->bizContent,0,-1);
251
        $this->bizContent.= "}";*/
252
        if (!empty($this->bizParas)) {
253
            $this->bizContent = json_encode($this->bizParas, JSON_UNESCAPED_UNICODE);
254
        }
255
256
        return $this->bizContent;
257
    }
258
}