| Conditions | 3 |
| Paths | 3 |
| Total Lines | 29 |
| Lines | 29 |
| Ratio | 100 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | View Code Duplication | public function refund(AlipayTradeRefundContentBuilder $builder) |
|
|
|
|||
| 31 | { |
||
| 32 | $request = new AlipayTradeRefundRequest(); |
||
| 33 | $request->setBizContent($builder->getBizContent()); |
||
| 34 | |||
| 35 | //请求 |
||
| 36 | $response = $this->httpPost($request, $builder->getAppAuthToken()); |
||
| 37 | |||
| 38 | //获取 |
||
| 39 | $data = $response->alipay_trade_refund_response; |
||
| 40 | $sign = $response->sign; |
||
| 41 | |||
| 42 | //组装返回数据 |
||
| 43 | $result = new AlipayF2FPayResult($data, $sign); |
||
| 44 | |||
| 45 | //处理 |
||
| 46 | if (tradeSuccess($data)) { |
||
| 47 | // 查询返回该订单交易支付成功 |
||
| 48 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_SUCCESS); |
||
| 49 | } elseif (tradeError($data)) { |
||
| 50 | //查询发生异常或无返回,交易状态未知 |
||
| 51 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_UNKNOWN); |
||
| 52 | } else { |
||
| 53 | //其他情况均表明该订单号交易失败 |
||
| 54 | $result->setTradeStatus(AlipayF2FPayResult::ALIPAY_F2FPAY_RESULT_FAILED); |
||
| 55 | } |
||
| 56 | |||
| 57 | return $this->formatResponseToType($result); |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
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.