Commit ca26f33f by lizhilin

更新

parent 54d948a1
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
use App\Admin\Forms\VerifierCodeForm; use App\Admin\Forms\VerifierCodeForm;
class OrderInfoController extends AdminController class OrderInfoController extends AdminController
{ {
/** /**
...@@ -133,17 +134,26 @@ protected function form() ...@@ -133,17 +134,26 @@ protected function form()
return Form::make(new OrderInfo(), function (Form $form) { return Form::make(new OrderInfo(), function (Form $form) {
//$form->display('id'); //$form->display('id');
$form->display('order_sn', '订单号'); $form->display('order_sn', '订单号');
$infoObj = $form->model(); // 获取当前数据
//$form->text('remark', '备注(后台用)'); //$form->text('remark', '备注(后台用)');
//订单状态 -1:全部 0:待付款 1:待到货 2:待领取 3: 待评价 4:已完成 7:已取消 8:已退款 //订单状态 -1:全部 0:待付款 1:待到货 2:待领取 3: 待评价 4:已完成 7:已取消 8:已退款
$options = [ if ($form->model()->order_status == 2) {
1 => '待到货', $options = [
2 => '待领取', 3 => '待评价'
3 => '待评价', ];
4 => '已完成',
7 => '已取消', $form->select('order_status', '订单状态')->options($options);
]; }
// $options = [
// 1 => '选项1',
// 2 => '选项2',
// 'value2' => ['text' => '选项二', 'disabled' => true], // 这个选项是只读的
// ];
// 禁用选项2
//$options[2] = ['text' => '选项2', 'disable' => true];
$form->select('order_status', '订单状态')->options($options);
// $form->switch('pay_status')->default(0); // $form->switch('pay_status')->default(0);
// $form->switch('shipping_status', '发货状态')->default(0); // $form->switch('shipping_status', '发货状态')->default(0);
// $form->text('order_amount', '订单应付款'); // $form->text('order_amount', '订单应付款');
......
...@@ -30,7 +30,6 @@ public function handle(array $input) ...@@ -30,7 +30,6 @@ public function handle(array $input)
$order = OrderInfo::find($this->payload['id']); $order = OrderInfo::find($this->payload['id']);
$order->order_status = 2; //待领取状态 $order->order_status = 2; //待领取状态
$order->verification_code = $code; $order->verification_code = $code;
$order->verification_at = date("Y-m-d H:i:s");
$order->save(); $order->save();
return $this->response()->success('确认成功')->refresh(); return $this->response()->success('确认成功')->refresh();
} }
......
...@@ -74,7 +74,7 @@ public function handle(Request $request) ...@@ -74,7 +74,7 @@ public function handle(Request $request)
for ($i = 7; $i >= 0; $i--) { for ($i = 7; $i >= 0; $i--) {
$day = date("Y-m-d", strtotime("-" . $i . " day")); $day = date("Y-m-d", strtotime("-" . $i . " day"));
array_push($dayArr, $day); array_push($dayArr, $day);
$orderAmount = mt_rand(100, 200); //OrderInfo::getDayAmount($day); $orderAmount = OrderInfo::getDayAmount($day);
array_push($amounts, $orderAmount); array_push($amounts, $orderAmount);
} }
......
...@@ -21,7 +21,9 @@ public function grid(): Grid ...@@ -21,7 +21,9 @@ public function grid(): Grid
$grid->addTableClass(['table-text-center']); $grid->addTableClass(['table-text-center']);
$grid->model()->where('order_id', $order_id); $grid->model()->where('order_id', $order_id);
//$grid->column('goods_img', '图片')->image(env("IMAGE_URL"), 50); //$grid->column('goods_img', '图片')->image(env("IMAGE_URL"), 50);
$grid->column('goods_name', '标题')->limit(15)->width(300); $grid->column('goods_name', '标题')->display(function ($val) {
return $val . "(" . $this->id . ")";
})->width(300);
$grid->column('goods_attr', '规格')->limit(10); $grid->column('goods_attr', '规格')->limit(10);
$grid->column('goods_number', '数量')->limit(10); $grid->column('goods_number', '数量')->limit(10);
$grid->column('goods_price', '价格')->limit(10); $grid->column('goods_price', '价格')->limit(10);
......
...@@ -263,7 +263,7 @@ public function getDetail(Request $request) ...@@ -263,7 +263,7 @@ public function getDetail(Request $request)
'id' => $goods->id, 'id' => $goods->id,
'goods_img' => $cover, 'goods_img' => $cover,
'goods_price' => $mer_id ? $dg_price : $market_price, 'goods_price' => $mer_id ? $dg_price : $market_price,
'market_price' => $market_price, 'market_price' => $userObj ? $market_price : '',
'stock' => $stock, 'stock' => $stock,
'goods_name' => $goods->goods_name, 'goods_name' => $goods->goods_name,
'sale' => $goods->sale ?? 0, 'sale' => $goods->sale ?? 0,
......
...@@ -127,9 +127,10 @@ private function codeToSession($code) ...@@ -127,9 +127,10 @@ private function codeToSession($code)
return $wx_data; return $wx_data;
} }
public function testLogin() public function testLogin(Request $request)
{ {
$user = User::find(1); $uid = $request->uid ?? 31;
$user = User::find($uid);
$accessToken = 'Bearer ' . $user->createToken('Access-token')->plainTextToken; $accessToken = 'Bearer ' . $user->createToken('Access-token')->plainTextToken;
return $this->JsonResponse(['Authorization' => $accessToken,]); return $this->JsonResponse(['Authorization' => $accessToken,]);
} }
......
...@@ -434,18 +434,57 @@ public function delOrder(Request $request) ...@@ -434,18 +434,57 @@ public function delOrder(Request $request)
//扫码核销 //扫码核销
public function scanCodeVerifi(Request $request) public function scanCodeVerifi(Request $request)
{ {
$verObj = $request->user();
$code = $request->code ?? ''; $code = $request->code ?? '';
$orderObj = OrderInfoModel::where('verification_code', $code)->first(); $orderObj = OrderInfoModel::where('verification_code', $code)->first();
if (!$orderObj) { if (!$orderObj) {
return $this->JsonResponse('', '参数错误', 201); return $this->JsonResponse('', '参数错误', 201);
} }
Log::add('核销操作5', [$orderObj->verification_at]);
if (!$orderObj->verification_at) { if (!$orderObj->verification_at) {
$orderObj->order_status = 3; $orderObj->order_status = 3;
$orderObj->verifier_id = $verObj->id;
$orderObj->verifier = $verObj->name;
$orderObj->verification_at = date("Y-m-d H:i:s"); $orderObj->verification_at = date("Y-m-d H:i:s");
$orderObj->save(); if ($orderObj->save()) {
//更新商品销量、库存
$goodsList = OrderGoods::where("order_id", $orderObj->id)->get();
foreach ($goodsList as $item) {
$gid = $item->goods_id;
$attr_id = $item->attr_id;
$mer_id = $item->merchant_id;
$goods_number = $item->goods_number;
$goodsObj = GoodModel::find($gid);
//更新商品规格库存
$attrObj = GoodSku::find($attr_id);
$attr_stock = ($attrObj->stock - $goods_number) > 0 ? $attrObj->stock - $goods_number : 0;
$attrObj->stock = $attr_stock;
$attrObj->save();
//更新商品sku
$skuArr = json_decode($goodsObj->sku, true);
if ($skuArr['sku']) {
foreach ($skuArr['sku'] as $kk => $vv) {
if (isset($vv['attr_sn']) && $vv['attr_sn'] == $attrObj->attr_sn) {
$skuArr['sku'][$kk]['stock'] = $attr_stock;
}
}
$goodsObj->sku = json_encode($skuArr, JSON_UNESCAPED_UNICODE);
$goodsObj->save();
}
//商户规格库存
$mgsObj = MerchantGoodSku::where(['goods_id' => $gid, 'attr_id' => $attr_id, 'merchant_id' => $mer_id])->first();
if ($mer_id && $mgsObj) {
$changeStock = ($mgsObj->stock >= $goods_number) ? $mgsObj->stock - $goods_number : 0;
$mgsObj->stock = $changeStock;
$mgsObj->save();
}
}
}
} else { } else {
return $this->JsonResponse('', '该码已核销,无需多次重复扫码', 500); return $this->JsonResponse('', '该码已核销,无需多次重复扫码', 500);
} }
Log::add('核销操作6', $orderObj->toArray());
return $this->JsonResponse(''); return $this->JsonResponse('');
} }
......
...@@ -176,11 +176,11 @@ public function info(Request $request) ...@@ -176,11 +176,11 @@ public function info(Request $request)
'phone' => $user->phone, 'phone' => $user->phone,
'phone_sec' => $user->phone ? substr($user->phone, 0, 3) . "****" . substr($user->phone, 7) : '', 'phone_sec' => $user->phone ? substr($user->phone, 0, 3) . "****" . substr($user->phone, 7) : '',
//'status' => $user->status, //'status' => $user->status,
'merchant_id' => $user->merchant_id, 'merchant_id' => $user->merchant_id ?? 0,
'buycode' => $user->buycode, 'buycode' => $user->buycode ?? '',
'balance' => $balance, 'balance' => $balance ?? 0,
'total_revenue' => $total_revenue, 'total_revenue' => $total_revenue ?? 0,
'cashout' => $cashout, 'cashout' => $cashout ?? 0,
]); ]);
} }
......
...@@ -73,18 +73,17 @@ public static function getNumDayData($dayNum, $status = []) ...@@ -73,18 +73,17 @@ public static function getNumDayData($dayNum, $status = [])
'total' => 0, 'total' => 0,
'list' => [] 'list' => []
]; ];
$where = []; //DB::enableQueryLog();
$sqlObj = new self(); $sqlObj = new self();
if ($status) {
$sqlObj = $sqlObj->whereIn('order_status', $status);
}
foreach ($days as $day) { foreach ($days as $day) {
$startTime = $day . ' 00:00:00'; $startTime = $day . ' 00:00:00';
$endTime = $day . ' 23:59:59'; $endTime = $day . ' 23:59:59';
$count = $sqlObj->whereBetween('created_at', [$startTime, $endTime])->where($where)->count(); $count = $sqlObj->whereIn('order_status', $status)->whereBetween('created_at', [$startTime, $endTime])->count();
//$queries = DB::getQueryLog();
$data['list'][$day] = $count; $data['list'][$day] = $count;
$data['total'] += $count; $data['total'] += $count;
} }
return $data; return $data;
} }
...@@ -94,7 +93,9 @@ public static function getDayAmount($dayDate) ...@@ -94,7 +93,9 @@ public static function getDayAmount($dayDate)
$startTime = $dayDate . ' 00:00:00'; $startTime = $dayDate . ' 00:00:00';
$endTime = $dayDate . ' 23:59:59'; $endTime = $dayDate . ' 23:59:59';
$sqlObj = new self(); $sqlObj = new self();
$amount = $sqlObj->whereBetween('created_at', [$startTime, $endTime])->whereNull('deleted_at')->sum('order_amount'); $amount = $sqlObj->whereBetween('created_at', [$startTime, $endTime])
->where('pay_status', 1)
->whereNull('deleted_at')->sum('order_amount');
return $amount; return $amount;
} }
...@@ -110,7 +111,9 @@ public static function getMonthAmount($monthDate) ...@@ -110,7 +111,9 @@ public static function getMonthAmount($monthDate)
$startTime = $firstDayOfMonth . ' 00:00:00'; $startTime = $firstDayOfMonth . ' 00:00:00';
$endTime = $lastDayOfMonth . ' 23:59:59'; $endTime = $lastDayOfMonth . ' 23:59:59';
$sqlObj = new self(); $sqlObj = new self();
$amount = $sqlObj->whereBetween('created_at', [$startTime, $endTime])->whereNull('deleted_at')->sum('order_amount'); $amount = $sqlObj->whereBetween('created_at', [$startTime, $endTime])
->where('pay_status', 1)
->whereNull('deleted_at')->sum('order_amount');
return $amount; return $amount;
} }
......
...@@ -75,39 +75,6 @@ public static function payNotify($fields = []) ...@@ -75,39 +75,6 @@ public static function payNotify($fields = [])
$orderObj->order_status = 1; $orderObj->order_status = 1;
$orderObj->pay_status = 1; $orderObj->pay_status = 1;
$orderObj->save(); $orderObj->save();
//更新商品销量、库存
$goodsList = OrderGoods::where("order_id", $orderObj->id)->get();
foreach ($goodsList as $item) {
$gid = $item->goods_id;
$attr_id = $item->attr_id;
$mer_id = $item->merchant_id;
$goods_number = $item->goods_number;
$goodsObj = Good::find($gid);
//更新商品规格库存
$attrObj = GoodSku::find($attr_id);
$attr_stock = ($attrObj->stock - $goods_number) > 0 ? $attrObj->stock - $goods_number : 0;
$attrObj->stock = $attr_stock;
$attrObj->save();
//更新商品sku
$skuArr = json_decode($goodsObj->sku, true);
if ($skuArr['sku']) {
foreach ($skuArr['sku'] as $kk => $vv) {
if (isset($vv['attr_sn']) && $vv['attr_sn'] == $attrObj->attr_sn) {
$skuArr['sku'][$kk]['stock'] = $attr_stock;
}
}
$goodsObj->sku = json_encode($skuArr, JSON_UNESCAPED_UNICODE);
$goodsObj->save();
}
//商户规格库存
$mgsObj = MerchantGoodSku::where(['goods_id' => $gid, 'attr_id' => $attr_id, 'merchant_id' => $mer_id])->first();
if ($mer_id && $mgsObj) {
$changeStock = ($mgsObj->stock >= $goods_number) ? $mgsObj->stock - $goods_number : 0;
$mgsObj->stock = $changeStock;
$mgsObj->save();
}
}
} }
//支付记录 //支付记录
$pay_cord = new PaymentRecord(); $pay_cord = new PaymentRecord();
......
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 to comment