Code Duplication    Length = 27-30 lines in 6 locations

src/F2fpay/Order/Client.php 4 locations

@@ 38-64 (lines=27) @@
35
     * @author kaylv <[email protected]>
36
     * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string
37
     */
38
    public function barPay(AlipayTradePayContentBuilder $builder)
39
    {
40
        //创建
41
        $request = new AlipayTradePayRequest();
42
        $request->setBizContent($builder->getBizContent());
43
44
        //请求
45
        $response = $this->httpPost($request, $builder->getAppAuthToken());
46
47
        //获取
48
        $data = $response->alipay_trade_pay_response;
49
        $sign = $response->sign;
50
51
        //组装返回数据
52
        $result = new AlipayF2FPayResult($data, $sign);
53
54
        //处理
55
        if (tradeSuccess($data)) {
56
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS);
57
        } elseif (tradeError($data)) {
58
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN);
59
        } else {
60
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED);
61
        }
62
63
        return $this->formatResponseToType($result);
64
    }
65
66
    /**
67
     * 统一收单线下交易预创建(扫码支付)
@@ 120-149 (lines=30) @@
117
     * @author kaylv <[email protected]>
118
     * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string
119
     */
120
    public function query(AlipayTradeQueryContentBuilder $builder)
121
    {
122
        //查询
123
        $request = new AlipayTradeQueryRequest();
124
        $request->setBizContent($builder->getBizContent());
125
126
        //请求
127
        $response = $this->httpPost($request, $builder->getAppAuthToken());
128
129
        //获取
130
        $data = $response->alipay_trade_query_response;
131
        $sign = $response->sign;
132
133
        //组装返回数据
134
        $result = new AlipayF2FPayResult($data, $sign);
135
136
        //处理
137
        if (querySuccess($data)) {
138
            // 查询返回该订单交易支付成功
139
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS);
140
        } elseif (tradeError($data)) {
141
            //查询发生异常或无返回,交易状态未知
142
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN);
143
        } else {
144
            //其他情况均表明该订单号交易失败
145
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED);
146
        }
147
148
        return $this->formatResponseToType($result);
149
    }
150
151
    /**
152
     * 统一收单交易撤销接口
@@ 162-190 (lines=29) @@
159
     * @author kaylv <[email protected]>
160
     * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string
161
     */
162
    public function cancel(AlipayTradeCancelContentBuilder $builder)
163
    {
164
        $request = new AlipayTradeCancelRequest();
165
        $request->setBizContent($builder->getBizContent());
166
167
        //请求
168
        $response = $this->httpPost($request, $builder->getAppAuthToken());
169
170
        //获取
171
        $data = $response->alipay_trade_cancel_response;
172
        $sign = $response->sign;
173
174
        //组装返回数据
175
        $result = new AlipayF2FPayResult($data, $sign);
176
177
        //处理
178
        if (tradeSuccess($data)) {
179
            // 查询返回该订单交易支付成功
180
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS);
181
        } elseif (tradeError($data)) {
182
            //查询发生异常或无返回,交易状态未知
183
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN);
184
        } else {
185
            //其他情况均表明该订单号交易失败
186
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED);
187
        }
188
189
        return $this->formatResponseToType($result);
190
    }
191
192
    /**
193
     * 统一收单交易关闭接口
@@ 201-229 (lines=29) @@
198
     * @author kaylv <[email protected]>
199
     * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string
200
     */
201
    public function close(AlipayTradeCloseContentBuilder $builder)
202
    {
203
        $request = new AlipayTradeCloseRequest();
204
        $request->setBizContent($builder->getBizContent());
205
206
        //请求
207
        $response = $this->httpPost($request, $builder->getAppAuthToken());
208
209
        //获取
210
        $data = $response->alipay_trade_close_response;
211
        $sign = $response->sign;
212
213
        //组装返回数据
214
        $result = new AlipayF2FPayResult($data, $sign);
215
216
        //处理
217
        if (tradeSuccess($data)) {
218
            // 查询返回该订单交易支付成功
219
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS);
220
        } elseif (tradeError($data)) {
221
            //查询发生异常或无返回,交易状态未知
222
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN);
223
        } else {
224
            //其他情况均表明该订单号交易失败
225
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED);
226
        }
227
228
        return $this->formatResponseToType($result);
229
    }
230
}
231

src/F2fpay/Refund/Client.php 2 locations

@@ 32-60 (lines=29) @@
29
     * @author kaylv <[email protected]>
30
     * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string
31
     */
32
    public function refund(AlipayTradeRefundContentBuilder $builder)
33
    {
34
        $request = new AlipayTradeRefundRequest();
35
        $request->setBizContent($builder->getBizContent());
36
37
        //请求
38
        $response = $this->httpPost($request, $builder->getAppAuthToken());
39
40
        //获取
41
        $data = $response->alipay_trade_refund_response;
42
        $sign = $response->sign;
43
44
        //组装返回数据
45
        $result = new AlipayF2FPayResult($data, $sign);
46
47
        //处理
48
        if (tradeSuccess($data)) {
49
            // 查询返回该订单交易支付成功
50
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS);
51
        } elseif (tradeError($data)) {
52
            //查询发生异常或无返回,交易状态未知
53
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN);
54
        } else {
55
            //其他情况均表明该订单号交易失败
56
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED);
57
        }
58
59
        return $this->formatResponseToType($result);
60
    }
61
62
    /**
63
     * 统一收单交易退款查询
@@ 74-102 (lines=29) @@
71
     * @author kaylv <[email protected]>
72
     * @return array|\Kaylyu\Alipay\Kernel\Support\Collection|string
73
     */
74
    public function query(AlipayTradeRefundQueryContentBuilder $builder)
75
    {
76
        $request = new AlipayTradeRefundQueryRequest();
77
        $request->setBizContent($builder->getBizContent());
78
79
        //请求
80
        $response = $this->httpPost($request, $builder->getAppAuthToken());
81
82
        //获取
83
        $data = $response->alipay_trade_fastpay_refund_query_response;
84
        $sign = $response->sign;
85
86
        //组装返回数据
87
        $result = new AlipayF2FPayResult($data, $sign);
88
89
        //处理
90
        if (tradeSuccess($data)) {
91
            // 查询返回该订单交易支付成功
92
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS);
93
        } elseif (tradeError($data)) {
94
            //查询发生异常或无返回,交易状态未知
95
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN);
96
        } else {
97
            //其他情况均表明该订单号交易失败
98
            $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED);
99
        }
100
101
        return $this->formatResponseToType($result);
102
    }
103
}
104