深茂订单详情

parent c3180025
......@@ -63,5 +63,10 @@ class OrderApiController extends Controller
return $this->setSuccessData($result);
}
//单个订单售后列表
public function orderServiceDetail(Request $request){
$result = OrderService::orderServiceDetail($request->user->id,$request->input("order_id"));
return $this->setSuccessData($result);
}
}
......@@ -8,6 +8,7 @@ use App\Models\OrderAddressModel;
use App\Models\OrderItemsModel;
use App\Models\OrderModel;
use App\Models\OrderPriceModel;
use App\Models\OrderReturnItemsModel;
use App\Models\UserAddressModel;
use App\Models\UserModel;
use Illuminate\Support\Facades\DB;
......@@ -373,7 +374,7 @@ class OrderService
$goods_id = $v["goods_id"];
$oneInfo = \Arr::get($goodsInfoArr,$goods_id,[]);
$ext_price = round($v["goods_number"]*$v["goods_price"],2);
$itemsTemp = [
$itemsTemp[] = [
"id"=>$k+1,
"goods_id"=>$v["goods_id"],
"goods_name"=>$v["goods_name"],
......@@ -397,7 +398,12 @@ class OrderService
"order_id"=>$order_id,
"order_sn"=>$orderInfo["order_sn"],
"order_amount"=>$orderInfo["order_amount"],
"sub_total "=>$orderInfo["order_amount"], //小计
"sub_total"=>$orderInfo["order_amount"], //小计
"created_time"=>timeToDate($orderInfo["create_time"]), //创建时间
"reviewed_time"=>timeToDate($orderInfo["confirm_time"]), //审核时间
"paid_time"=>timeToDate($orderInfo["pay_time"]), //支付时间
"delivered_time"=>timeToDate($orderInfo["shipping_time"]), //发货时间
"received_time"=>"", //收货时间
"shipping"=>\Arr::get($priceArr,3,0), //运费
"payment_surcharge"=>\Arr::get($priceArr,5,0), //支付手续费
"merchandise_total"=>$merchandise_total, //商品总额
......@@ -411,6 +417,37 @@ class OrderService
return $temp;
}
//订单售后详情
public static function orderServiceDetail($user_id,$order_id){
$returnItems = OrderReturnItemsModel::where("order_id",$order_id)->get()->toArray();
if (!$returnItems){
return false;
}
$orderItemsArr = OrderItemsModel::where(["order_id"=>$order_id])
->wherein("rec_id",array_column($returnItems,"rec_id"))
->get()
->keyby("rec_id")
->toArray();
$temp = [];
foreach ($returnItems as $k=>$v){
$orderGoodsInfo = \Arr::get($orderItemsArr,$v["rec_id"]);
$temp[] = [
"no"=>$k+1,
"part_no"=>$orderGoodsInfo["goods_name"], // 型号名称
"manufacturer"=>$orderGoodsInfo["brand_name"], // 品牌名称
"price_per_unit"=>$orderGoodsInfo["goods_price"], // 单价
"quantity"=>$orderGoodsInfo["goods_number"], // 购买数量
"subtotal"=>round($orderGoodsInfo["goods_price"]*$orderGoodsInfo["goods_number"],2), // 金额
"type"=>OrderReturnItemsModel::$types[$v["type"]], // 售后类型
"after_sale_quantity"=>$v["return_num"], // 售后数量
"after_sale_price"=>$v["return_price"], // 售后单价
"return_amount"=>$v["return_amount"], // 售后金额
];
}
return $temp;
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class OrderReturnItemsModel extends Model
{
protected $table = 'order_return_items';
protected $primaryKey = 'return_items_id';
public $timestamps = false;
//`type` '1退货退款 2仅退款',
const types_return_refund = 1;
const types_refund = 2;
static $types = [
self::types_refund => "Refund",
self::types_return_refund => "Return And Refund"
];
}
......@@ -109,3 +109,10 @@ function getRate($k = "美元")
$redis = Redis::connection();
return $redis->hget('erp_rate', $k);
}
/*
* 时间传换
*/
function timeToDate($timestr){
return $timestr >0 ? date("Y-m-d H:i:s",$timestr) : "";
}
......@@ -55,6 +55,7 @@ Route::middleware(['api', 'api.check'])->namespace('Api')->group(function () {
Route::POST('order/updateOrder', 'OrderApiController@updateOrder'); //更新订单状态
Route::POST('order/cancelOrder', 'OrderApiController@cancelOrder'); //取消订单
Route::POST('order/orderDetail', 'OrderApiController@orderDetail'); //订单详情
Route::POST('order/orderServiceDetail', 'OrderApiController@orderServiceDetail'); //订单售后详情
});
......
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