Commit 16dc8515 by 孙龙

订单

parent ecfb1977
......@@ -190,6 +190,7 @@ class OrderApiController extends BaseController
public function editOrderSettlement(Request $request){
$reqParams = $request->all();
OrderService::editOrderSettlement($reqParams);
return $this->setSuccess();
}
......
......@@ -257,13 +257,31 @@ class OrderService extends BaseService
}
//修改订单结算信息
public static function editOrderSettlement($reqParams){
$orderId = arrayGet($reqParams,"order_id",0,"intval");
$freightCharge = arrayGet($reqParams,"freight_charge",0,"floatval");//运费
$payCommission = arrayGet($reqParams,"pay_commission",0,"floatval");//支付手续费
$orderUserPayType = arrayGet($reqParams,"order_user_pay_type",0,"intval");//支付方式
(new self)->startTransaction();
try{
$orderInfo = Order::getOne($orderId);
if(empty($orderInfo)){
throw new InvalidRequestException(admin_trans("order.return_msg.50005"));
}
OrderPrice::editOrderSettlement($orderId,$orderInfo["order_sn"],$freightCharge,$payCommission);
Order::updateOrder(["order_id"=>$orderId],[
"order_user_pay_type"=>$orderUserPayType,
"update_time"=>time(),
]);
}catch (\Throwable $e){
(new self)->rollBackTransaction();
throw new InvalidRequestException(sprintf("%s:%s",admin_trans("order.return_msg.50004"),$e->getMessage()));
}
(new self)->commitTransaction();
}
}
......@@ -127,4 +127,6 @@ class Order extends Model
}
}
......@@ -35,4 +35,33 @@ class OrderPrice extends Model
"支付手续费"=>5,
];
//新增或者修改订单的 运费 支付手续费
public static function editOrderSettlement($orderId,$orderSn,$freightCharge,$payCommission){
if($freightCharge){
self::updateOrCreate([
"order_id"=>$orderId,
"price_type"=>self::$PRICE_TYPE_LIST["运费"],
],[
"order_sn"=>$orderSn,
"price"=>decimal_number_format($freightCharge),
"currency"=>2,
"create_time"=>time(),
]);
}
if($payCommission){
self::updateOrCreate([
"order_id"=>$orderId,
"price_type"=>self::$PRICE_TYPE_LIST["支付手续费"],
],[
"order_sn"=>$orderSn,
"price"=>decimal_number_format($payCommission),
"currency"=>2,
"create_time"=>time(),
]);
}
}
}
......@@ -28,6 +28,8 @@ return [
"50001"=>"只能修改不是待审核的订单状态",
"50002"=>"取消订单失败",
"50003"=>"修改订单失败",
"50004"=>"修改结算信息失败",
"50005"=>"没找到订单相关数据",
],
"validator"=>[
'order_id_required' => '订单id必填',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment