Commit afd24318 by 孙龙

订单详情

parent 093dbba3
...@@ -9,6 +9,7 @@ use App\Admin\Actions\OrderReverseAuditAction; ...@@ -9,6 +9,7 @@ use App\Admin\Actions\OrderReverseAuditAction;
use App\Admin\Pages\OrderDetailPage; use App\Admin\Pages\OrderDetailPage;
use App\Models\Cms\CmsUser; use App\Models\Cms\CmsUser;
use App\Models\Order; use App\Models\Order;
use App\Models\OrderPrice;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Show; use Dcat\Admin\Show;
...@@ -16,6 +17,7 @@ use Dcat\Admin\Http\Controllers\AdminController; ...@@ -16,6 +17,7 @@ use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content; use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Box; use Dcat\Admin\Widgets\Box;
use Dcat\Admin\Widgets\Dropdown; use Dcat\Admin\Widgets\Dropdown;
use Illuminate\Support\Arr;
class OrderController extends AdminController class OrderController extends AdminController
...@@ -58,7 +60,7 @@ class OrderController extends AdminController ...@@ -58,7 +60,7 @@ class OrderController extends AdminController
}); });
$grid->column('order_id',"ID"); $grid->column('order_id',"ID");
$grid->column('order_sn')->width('120px')->display(function () { $grid->column('order_sn')->width('120px')->display(function () {
return '<a target="_blank" iframe-extends=true iframe-tab=true href="/admin/order/page?order_id="'.$this->user_id.' >'.$this->order_sn.'</a>'; return '<a target="_blank" iframe-extends=true iframe-tab=true href="/admin/order/page?order_id='.$this->order_id.'" >'.$this->order_sn.'</a>';
}); });
$grid->column('status')->using(admin_trans('order.options.status'))->sortable(); $grid->column('status')->using(admin_trans('order.options.status'))->sortable();
$grid->column('company_name')->display(function ($company_name) { $grid->column('company_name')->display(function ($company_name) {
...@@ -239,7 +241,77 @@ JS ...@@ -239,7 +241,77 @@ JS
} }
public function page(Content $content){ public function page(Content $content){
return view('admin.pages.order-page'); $params = request()->all();
$order_id = arrayGet($params,"order_id",0,"intval");
$orderInfo = Order::getOneAndRelationList($order_id);
$orderItems = $orderInfo["orderItems"]??[];
dump($orderInfo);
$info=[];
// $info["orderInfo"] = $orderInfo;
//基本信息
$info["baseInfo"]["order_sn"] = $orderInfo["order_sn"];
$info["baseInfo"]["status"] = $orderInfo["status"];
$info["baseInfo"]["status_cn"] = Arr::get(array_flip(Order::$STATUS_FORAMT),$orderInfo["status"],"");
$info["baseInfo"]["company_name"] = $orderInfo["company_name"];
$info["baseInfo"]["user_sn"] = $orderInfo["scm_user"]["user_sn"]??"";
$info["baseInfo"]["name"] = $orderInfo["scm_user"]["name"]??"";
$info["receiveInfo"] = [];//收货信息
$info["billingInfo"] = [];//账单信息
$addressList = $orderInfo["order_address"]??[];
foreach($addressList as $addressItem){
if($addressItem["order_address_type"] == "1"){
$info["receiveInfo"] = $addressItem;
}elseif($addressItem["order_address_type"] == "2"){
$info["billingInfo"] = $addressItem;
}
}
$orderInfo["orderItemList"] = $orderItems;
foreach($orderInfo["orderItemList"] as $k=>$item){
$orderInfo["orderItemList"][$k]["goods_price_format"] = decimal_number_format_usd($item["goods_price"]);
$orderInfo["orderItemList"][$k]["total_amount"] = decimal_number_format($item["goods_price"]*$item["goods_number"]);
$orderInfo["orderItemList"][$k]["total_amount_format"] = decimal_number_format_usd($item["goods_price"]*$item["goods_number"]);
}
//结算信息
$info["settlementInfo"]=[];
$orderPrice = $orderInfo["order_price"]??[];
$info["settlementInfo"]["order_amount"] = $orderInfo["order_amount"];
$info["settlementInfo"]["order_amount_format"] = decimal_number_format_usd($orderInfo["order_amount"]);
$info["settlementInfo"]["order_freight_amount"] = 0;//运费
$info["settlementInfo"]["order_freight_amount_format"] = "";
$info["settlementInfo"]["order_pay_commission_amount"] = 0;//手续费
$info["settlementInfo"]["order_pay_commission_amount_format"] = "";
$orderItemsId = Arr::pluck($orderItems,"rec_id");
foreach($orderPrice as $orderPriceItem){
switch ($orderPriceItem["price_type"]){
case OrderPrice::$PRICE_TYPE_LIST["运费"]:
$info["settlementInfo"]["order_freight_amount"] = $orderPriceItem["price"];
$info["settlementInfo"]["order_freight_amount_format"] = decimal_number_format_usd($orderPriceItem["price"]);
case OrderPrice::$PRICE_TYPE_LIST["支付手续费"]:
$info["settlementInfo"]["order_pay_commission_amount"] = $orderPriceItem["price"];
$info["settlementInfo"]["order_pay_commission_amount_format"] = decimal_number_format_usd($orderPriceItem["price"]);
}
}
$info["settlementInfo"]["order_total_amount"] = $info["settlementInfo"]["order_amount"] + $info["settlementInfo"]["order_freight_amount"]+$info["settlementInfo"]["order_pay_commission_amount"];
$info["settlementInfo"]["order_total_amount_format"] = decimal_number_format_usd($info["settlementInfo"]["order_total_amount"]);
dump($info);
return view('admin.pages.order-page',["info"=>$info]);
// return $content->body(new OrderDetailPage()); // return $content->body(new OrderDetailPage());
} }
......
...@@ -51,6 +51,10 @@ class Order extends Model ...@@ -51,6 +51,10 @@ class Order extends Model
return $this->hasMany(OrderPrice::class, 'order_id', 'order_id'); return $this->hasMany(OrderPrice::class, 'order_id', 'order_id');
} }
public function order_address()
{
return $this->hasMany(OrderAddress::class, 'order_id', 'order_id');
}
//审核订单 //审核订单
...@@ -80,6 +84,11 @@ class Order extends Model ...@@ -80,6 +84,11 @@ class Order extends Model
return $orderInfo ? $orderInfo->toArray() : []; return $orderInfo ? $orderInfo->toArray() : [];
} }
public static function getOneAndRelationList($orderId=0){
$orderInfo = self::where("order_id",$orderId)->with("scmUser")->with("order_price")->with("order_items")->with("order_address")->first();
return $orderInfo ? $orderInfo->toArray() : [];
}
//取消 //取消
public static function canelOrder($orderId=0){ public static function canelOrder($orderId=0){
return self::where("order_id",$orderId)->update([ return self::where("order_id",$orderId)->update([
...@@ -87,4 +96,10 @@ class Order extends Model ...@@ -87,4 +96,10 @@ class Order extends Model
]); ]);
} }
//修改订单
public static function updateOrder($where,$update){
$update["update_time"] = time();
return self::where($where)->update($update);
}
} }
...@@ -5,6 +5,7 @@ use Illuminate\Support\Arr; ...@@ -5,6 +5,7 @@ use Illuminate\Support\Arr;
define("DIGITS_TWO", 2); define("DIGITS_TWO", 2);
define("DIGITS_FOUR", 4); define("DIGITS_FOUR", 4);
define("DIGITS_SIX", 6); define("DIGITS_SIX", 6);
define("CURRENCY_USD", 2);
if (!function_exists('user_admin_config')) { if (!function_exists('user_admin_config')) {
function user_admin_config($key = null, $value = null) function user_admin_config($key = null, $value = null)
...@@ -110,6 +111,14 @@ if (!function_exists('decimal_number_format')) { ...@@ -110,6 +111,14 @@ if (!function_exists('decimal_number_format')) {
} }
} }
if (!function_exists('decimal_number_format_usd')) {
function decimal_number_format_usd($amount){
return decimal_number_format($amount,DIGITS_TWO,CURRENCY_USD);
}
}
if (!function_exists('printJson')) { if (!function_exists('printJson')) {
function printJson($data) function printJson($data)
{ {
......
...@@ -4,6 +4,7 @@ return [ ...@@ -4,6 +4,7 @@ return [
'Order' => 'Order', 'Order' => 'Order',
'order' => 'Order', 'order' => 'Order',
'edit_status_handle' => '修改状态', 'edit_status_handle' => '修改状态',
'将该订单状态置为' => '将该订单状态置为',
], ],
'fields' => [ 'fields' => [
'order_sn' => '订单编号号', 'order_sn' => '订单编号号',
...@@ -22,6 +23,10 @@ return [ ...@@ -22,6 +23,10 @@ return [
'sale_id' => '业务员id', 'sale_id' => '业务员id',
'sale_name' => '业务员', 'sale_name' => '业务员',
], ],
"return_msg"=>[
"50000"=>"操作成功",
"50001"=>"只能修改不是待审核的订单状态"
],
'options' => [ 'options' => [
"status"=>[ "status"=>[
"-1"=>"已取消", "-1"=>"已取消",
......
...@@ -23,6 +23,10 @@ return [ ...@@ -23,6 +23,10 @@ return [
'sale_id' => '业务员id', 'sale_id' => '业务员id',
'sale_name' => '业务员', 'sale_name' => '业务员',
], ],
"return_msg"=>[
"50000"=>"操作成功",
"50001"=>"只能修改不是待审核的订单状态"
],
'options' => [ 'options' => [
"status"=>[ "status"=>[
"-1"=>"已取消", "-1"=>"已取消",
......
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