Commit a43c015d by 宁成龙

Merge remote-tracking branch 'origin/master'

parents 9c3f5fab 7da49779
<?php
namespace App\Admin\Actions;
use App\Models\Order as OrderModel;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Grid\Tools\AbstractTool;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class OrderEditSatusAction extends BatchAction
{
/**
* 按钮样式定义,默认 btn btn-white waves-effect
*
* @var string
*/
protected $title = "";
protected $style = 'btn btn-primary feather icon-check-square';
public function render()
{
$this->title = admin_trans("order.labels.edit_status_handle");
$form = \App\Admin\Forms\HandOrderListEStatus::make();
$buttonName = trans('order.labels.edit_status_handle');
return Modal::make()->lg()->title($this->title)->body($form->payload([
]))->onLoad($this->getModalScript())
->button('<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">' . $buttonName . '</span>
</button>');
}
protected function getModalScript()
{
// 弹窗显示后往隐藏的id表单中写入批量选中的行ID
$warning = trans('global.labels.operate_must_single');
$warning2 = trans('global.labels.operate_must_select_data');
return <<<JS
// 获取选中的ID数组
var key = {$this->getSelectedKeysScript()}
if (key.length > 1){
Dcat.swal.error('$warning');
Dcat.reload();
return false;
}
if (!key.length){
Dcat.swal.error('$warning2');
Dcat.reload();
}
$('#order_id').val(key);
JS;
}
}
\ No newline at end of file
......@@ -59,7 +59,7 @@ class OrderReverseAuditAction extends BatchAction
{
// 你的代码逻辑
$orderIdArr = $this->getKey();
// OrderModel::auditOrder($orderIdArr);
OrderModel::reverseAuditOrder($orderIdArr);
return $this->response()->success('反审核成功')->refresh();
}
......
......@@ -4,10 +4,12 @@ namespace App\Admin\Controllers;
use App\Admin\Actions\OrderAuditAction;
use App\Admin\Actions\OrderCancelAction;
use App\Admin\Actions\OrderEditSatusAction;
use App\Admin\Actions\OrderReverseAuditAction;
use App\Admin\Pages\OrderDetailPage;
use App\Models\Cms\CmsUser;
use App\Models\Order;
use App\Models\OrderPrice;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
......@@ -15,6 +17,7 @@ use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Box;
use Dcat\Admin\Widgets\Dropdown;
use Illuminate\Support\Arr;
class OrderController extends AdminController
......@@ -57,7 +60,7 @@ class OrderController extends AdminController
});
$grid->column('order_id',"ID");
$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('company_name')->display(function ($company_name) {
......@@ -113,6 +116,7 @@ class OrderController extends AdminController
$grid->tools([
new OrderAuditAction(),
new OrderReverseAuditAction(),
new OrderEditSatusAction(),
]);
......@@ -237,7 +241,77 @@ JS
}
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());
}
......
<?php
namespace App\Admin\Forms;
use App\Models\Inquiry;
use App\Models\Order;
use Dcat\Admin\Models\Administrator;
use Dcat\Admin\Widgets\Alert;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Contracts\LazyRenderable;
class HandOrderListEStatus extends Form implements LazyRenderable
{
use LazyWidget;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
$order_id = arrayGet($input,"order_id",0,"intval");
$status = arrayGet($input,"status",0,"intval");
$orderInfo = Order::getOne($order_id);
if($orderInfo["status"] <= Order::$STATUS_FORAMT["待审核"] ){
return $this->response()->error(admin_trans("order.return_msg.50001"))->refresh();
}
Order::updateOrder(["order_id"=>$order_id],["status"=>$status]);
return $this->response()->success('order.return_msg.50000')->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$this->hidden('order_id')->attribute('id', 'order_id');
$this->select("status",admin_trans("order.labels.将该订单状态置为"))->width(8, 3)->options(admin_trans("order.options.edit_status"));
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return [
];
}
}
......@@ -51,6 +51,10 @@ class Order extends Model
return $this->hasMany(OrderPrice::class, 'order_id', 'order_id');
}
public function order_address()
{
return $this->hasMany(OrderAddress::class, 'order_id', 'order_id');
}
//审核订单
......@@ -58,6 +62,11 @@ class Order extends Model
return self::whereIn("order_id",$orderIds)->where("status",self::$STATUS_WAIT_AUDIT)->update(["status"=>self::$STATUS_WAIT_PAY]);
}
//反审核订单
public static function reverseAuditOrder($orderIds=[]){
return self::whereIn("order_id",$orderIds)->where("status",self::$STATUS_FORAMT["待付款"])->update(["status"=>self::$STATUS_FORAMT["待审核"]]);
}
//获取订单数据
public static function getOrderList($orderId=0){
......@@ -75,6 +84,11 @@ class Order extends Model
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){
return self::where("order_id",$orderId)->update([
......@@ -82,4 +96,10 @@ class Order extends Model
]);
}
//修改订单
public static function updateOrder($where,$update){
$update["update_time"] = time();
return self::where($where)->update($update);
}
}
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class OrderReturnItems extends Model
{
use HasDateTimeFormatter;
protected $table = 'order_return_items';
protected $primaryKey = 'return_items_id';
public $timestamps = false;
public static function getOrderReturnItemList($rec_ids=[]){
self::whereIn("rec_id")
}
}
......@@ -5,6 +5,7 @@ use Illuminate\Support\Arr;
define("DIGITS_TWO", 2);
define("DIGITS_FOUR", 4);
define("DIGITS_SIX", 6);
define("CURRENCY_USD", 2);
if (!function_exists('user_admin_config')) {
function user_admin_config($key = null, $value = null)
......@@ -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')) {
function printJson($data)
{
......
......@@ -3,6 +3,8 @@ return [
'labels' => [
'Order' => 'Order',
'order' => 'Order',
'edit_status_handle' => '修改状态',
'将该订单状态置为' => '将该订单状态置为',
],
'fields' => [
'order_sn' => '订单编号号',
......@@ -21,6 +23,10 @@ return [
'sale_id' => '业务员id',
'sale_name' => '业务员',
],
"return_msg"=>[
"50000"=>"操作成功",
"50001"=>"只能修改不是待审核的订单状态"
],
'options' => [
"status"=>[
"-1"=>"已取消",
......@@ -40,5 +46,11 @@ return [
"4"=>"预收自定义",
"5"=>"预收50%",
],
"edit_status"=>[
"4"=>"待发货",
"8"=>"待收货",
"10"=>" 交易成功",
"-1"=>"已取消",
],
],
];
......@@ -3,6 +3,8 @@ return [
'labels' => [
'Order' => 'Order',
'order' => 'Order',
'edit_status_handle' => '修改状态',
'将该订单状态置为' => '将该订单状态置为',
],
'fields' => [
'order_sn' => '订单编号号',
......@@ -21,6 +23,10 @@ return [
'sale_id' => '业务员id',
'sale_name' => '业务员',
],
"return_msg"=>[
"50000"=>"操作成功",
"50001"=>"只能修改不是待审核的订单状态"
],
'options' => [
"status"=>[
"-1"=>"已取消",
......@@ -40,5 +46,11 @@ return [
"4"=>"预收自定义",
"5"=>"预收50%",
],
"edit_status"=>[
"4"=>"待发货",
"8"=>"待收货",
"10"=>" 交易成功",
"-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