9 changed files with 160 additions and 7 deletions
-
12app/JsonRpc/OrderService.php
-
8app/Model/CouponUserRec.php
-
6app/Model/CouponUserUse.php
-
20app/Service/CouponService.php
-
2app/Service/CouponServiceInterface.php
-
62app/Service/OrderService.php
-
47app/Service/PayRefundService.php
-
8app/Service/PayRefundServiceInterface.php
@ -0,0 +1,47 @@ |
|||
<?php |
|||
|
|||
namespace App\Service; |
|||
|
|||
use App\Model\OrderMain; |
|||
use EasyWeChat\Factory; |
|||
use Hyperf\DbConnection\Db; |
|||
use App\Constants\ErrorCode; |
|||
|
|||
class PayRefundService implements PayRefundServiceInterface |
|||
{ |
|||
/** |
|||
* 微信支付退款 |
|||
*/ |
|||
public function wxPayRefund($global_order_id) |
|||
{ |
|||
$config = config('wxpay'); |
|||
$app = Factory::payment($config); |
|||
$app['guzzle_handler'] = CoroutineHandler::class; |
|||
|
|||
$result = [ |
|||
'status' => 0, |
|||
'msg' => '退款成功' |
|||
]; |
|||
|
|||
// 查询订单
|
|||
$orderMain = OrderMain::query() |
|||
->select('id','code','order_num','money','state') |
|||
->where('global_order_id',$global_order_id) |
|||
->where('pay_type',OrderMain::ORDER_PAY_WX) |
|||
->where(Db::raw('refund_time is null')) |
|||
->first(); |
|||
if(empty($orderMain)){ |
|||
return ['status'=>1, 'msg'=>'订单不存在或已退款']; |
|||
} |
|||
$optional = []; |
|||
$result = $app->refund->byOutTradeNumber( |
|||
$orderMain->code, |
|||
$orderMain->code, |
|||
$orderMain->money * 100, |
|||
$orderMain->money * 100, |
|||
$optional |
|||
); |
|||
return $result; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
<?php |
|||
|
|||
namespace App\Service; |
|||
|
|||
interface PayRefundServiceInterface |
|||
{ |
|||
public function wxPayRefund($global_order_id); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue