|
|
|
|
@ -662,4 +662,106 @@ class OrdersController extends CommonController
|
|
|
|
|
])->select("id", "customer_id", "money", "balance", "belongs_type", "belongs_id", "remark", "order_id", "created_at")->orderBy("id", "desc")->paginate(10);
|
|
|
|
|
return response()->json($balances->toArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/customer/score-order/{id}",
|
|
|
|
|
* tags={"用户端订单处理"},
|
|
|
|
|
* summary="评价订单",
|
|
|
|
|
* description="评价订单",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="订单id"),
|
|
|
|
|
* @OA\Parameter(name="score", in="query", @OA\Schema(type="number"), required=true, description="分数,5分制,0.5分为一个阶梯"),
|
|
|
|
|
* @OA\Parameter(name="comment", in="query", @OA\Schema(type="string"), required=false, description="评语,不超过255字节"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="评价订单"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function scoreOrder($id)
|
|
|
|
|
{
|
|
|
|
|
$order = (new Orders())->where("customer_id", $this->customer->id)->find($id);
|
|
|
|
|
if (!$order) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => 40004,
|
|
|
|
|
"errormsg" => "没找到订单"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($order->status !== Orders::STATUS_FINISHED) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => 50001,
|
|
|
|
|
"errormsg" => "订单状态不适配"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$order->update([
|
|
|
|
|
"score" => request()->score,
|
|
|
|
|
"comment" => request()->comment,
|
|
|
|
|
"scored_at" => date("Y-m-d H:i:s"),
|
|
|
|
|
]);
|
|
|
|
|
DB::commit();
|
|
|
|
|
return response()->json($order);
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => $exception->getCode(),
|
|
|
|
|
"errormsg" => $exception->getMessage()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\POST(
|
|
|
|
|
* path="/customer/delete-score-order/{id}",
|
|
|
|
|
* tags={"用户端订单处理"},
|
|
|
|
|
* summary="删除订单评价",
|
|
|
|
|
* description="删除订单评价",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Parameter(name="id", in="path", @OA\Schema(type="integer"), required=true, description="订单id"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
* description="删除订单评价"
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function deleteScoreOrder($id)
|
|
|
|
|
{
|
|
|
|
|
$order = (new Orders())->where("customer_id", $this->customer->id)->find($id);
|
|
|
|
|
if (!$order) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => 40004,
|
|
|
|
|
"errormsg" => "没找到订单"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($order->status !== Orders::STATUS_FINISHED) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => 50001,
|
|
|
|
|
"errormsg" => "订单状态不适配"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$order->update([
|
|
|
|
|
"score" => null,
|
|
|
|
|
"comment" => null,
|
|
|
|
|
"scored_at" =>null
|
|
|
|
|
]);
|
|
|
|
|
DB::commit();
|
|
|
|
|
return response()->json($order);
|
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return response()->json([
|
|
|
|
|
"errorcode" => $exception->getCode(),
|
|
|
|
|
"errormsg" => $exception->getMessage()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|