|
|
@ -6,6 +6,8 @@ use App\Commons\Log; |
|
|
use App\Constants\v3\ErrorCode; |
|
|
use App\Constants\v3\ErrorCode; |
|
|
use App\Constants\v3\LogLabel; |
|
|
use App\Constants\v3\LogLabel; |
|
|
use App\Exception\ErrorCodeException; |
|
|
use App\Exception\ErrorCodeException; |
|
|
|
|
|
use App\Model\v3\Order; |
|
|
|
|
|
use App\Model\v3\OrderMain; |
|
|
use App\Service\v3\Interfaces\OrderOnlineServiceInterface; |
|
|
use App\Service\v3\Interfaces\OrderOnlineServiceInterface; |
|
|
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface; |
|
|
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface; |
|
|
use Hyperf\DbConnection\Db; |
|
|
use Hyperf\DbConnection\Db; |
|
|
@ -98,16 +100,49 @@ class OrderService implements OrderServiceInterface |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 线上订单单笔退款 |
|
|
|
|
|
|
|
|
* 线上订单单笔退款,主要用于后台强行操作退单退款 |
|
|
* 支持单商品、单店、整单 |
|
|
* 支持单商品、单店、整单 |
|
|
|
|
|
* 按比例计算红包进行退款 |
|
|
|
|
|
* 比如:两个子订单和子订单商品,分别是2元,98元,使用了10元优惠券 |
|
|
|
|
|
* 退2元商品时,退款金额为 |
|
|
|
|
|
* 红包 :(2/(98+2))*10 = 0.2 |
|
|
|
|
|
* 退款:2-0.2=1.8元 |
|
|
* @param $user_id *用户ID |
|
|
* @param $user_id *用户ID |
|
|
* @param $global_order_id *全局总订单ID |
|
|
* @param $global_order_id *全局总订单ID |
|
|
* @param $child_order_id *主订单ID, |
|
|
* @param $child_order_id *主订单ID, |
|
|
* @param $order_goods_id *订单商品ID |
|
|
* @param $order_goods_id *订单商品ID |
|
|
* @param $note |
|
|
* @param $note |
|
|
*/ |
|
|
*/ |
|
|
public function onlineSingleRefund($user_id, $global_order_id, $child_order_id, $order_goods_id, $note) |
|
|
|
|
|
|
|
|
public function onlineSingleRefund($user_id, $note, $global_order_id, $child_order_id=null, $order_goods_id=null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (!$user_id || !$global_order_id || !$note) { |
|
|
|
|
|
$this->log->event(LogLabel::ORDER_REFUND_LOG, [ |
|
|
|
|
|
'jsonrpc_order_service_exception_onlineSingleRefund' => '参数不对', |
|
|
|
|
|
'params' => json([$global_order_id, $user_id, $note]) |
|
|
|
|
|
]); |
|
|
|
|
|
throw new ErrorCodeException(ErrorCode::ORDER_REFUND_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 主订单
|
|
|
|
|
|
$orderMain = OrderMain::query()->where(['global_order_id' => $global_order_id])->first(); |
|
|
|
|
|
|
|
|
|
|
|
// 子订单
|
|
|
|
|
|
if ($child_order_id) { |
|
|
|
|
|
$orderChild = Order::query()->where(['order_main_id' => $orderMain->global_order_id])->first(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 单商品退
|
|
|
|
|
|
if ($order_goods_id) { |
|
|
|
|
|
if (!$child_order_id) { |
|
|
|
|
|
$this->log->event(LogLabel::ORDER_REFUND_LOG, [ |
|
|
|
|
|
'jsonrpc_order_service_exception_onlineSingleRefund' => '参数不对[单品]', |
|
|
|
|
|
'params' => json([$global_order_id, $user_id, $note, $child_order_id]) |
|
|
|
|
|
]); |
|
|
|
|
|
throw new ErrorCodeException(ErrorCode::ORDER_REFUND_FAIL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |