Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
aimeiyue
service
Commits
ca26f33f
Commit
ca26f33f
authored
Sep 30, 2024
by
lizhilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
54d948a1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
81 additions
and
60 deletions
+81
-60
app/Admin/Controllers/OrderInfoController.php
+18
-8
app/Admin/Forms/VerifierCodeForm.php
+0
-1
app/Admin/Metrics/Examples/OrderAjaxBar.php
+1
-1
app/Admin/Renderable/OrderGoodsList.php
+3
-1
app/Http/Controllers/Api/GoodController.php
+1
-1
app/Http/Controllers/Api/LoginController.php
+3
-2
app/Http/Controllers/Api/OrderController.php
+40
-1
app/Http/Controllers/Api/UserController.php
+5
-5
app/Models/OrderInfo.php
+10
-7
app/Models/Pay.php
+0
-33
No files found.
app/Admin/Controllers/OrderInfoController.php
View file @
ca26f33f
...
...
@@ -15,6 +15,7 @@
use
Dcat\Admin\Http\Controllers\AdminController
;
use
App\Admin\Forms\VerifierCodeForm
;
class
OrderInfoController
extends
AdminController
{
/**
...
...
@@ -133,17 +134,26 @@ protected function form()
return
Form
::
make
(
new
OrderInfo
(),
function
(
Form
$form
)
{
//$form->display('id');
$form
->
display
(
'order_sn'
,
'订单号'
);
$infoObj
=
$form
->
model
();
// 获取当前数据
//$form->text('remark', '备注(后台用)');
//订单状态 -1:全部 0:待付款 1:待到货 2:待领取 3: 待评价 4:已完成 7:已取消 8:已退款
$options
=
[
1
=>
'待到货'
,
2
=>
'待领取'
,
3
=>
'待评价'
,
4
=>
'已完成'
,
7
=>
'已取消'
,
];
if
(
$form
->
model
()
->
order_status
==
2
)
{
$options
=
[
3
=>
'待评价'
];
$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('shipping_status', '发货状态')->default(0);
// $form->text('order_amount', '订单应付款');
...
...
app/Admin/Forms/VerifierCodeForm.php
View file @
ca26f33f
...
...
@@ -30,7 +30,6 @@ public function handle(array $input)
$order
=
OrderInfo
::
find
(
$this
->
payload
[
'id'
]);
$order
->
order_status
=
2
;
//待领取状态
$order
->
verification_code
=
$code
;
$order
->
verification_at
=
date
(
"Y-m-d H:i:s"
);
$order
->
save
();
return
$this
->
response
()
->
success
(
'确认成功'
)
->
refresh
();
}
...
...
app/Admin/Metrics/Examples/OrderAjaxBar.php
View file @
ca26f33f
...
...
@@ -74,7 +74,7 @@ public function handle(Request $request)
for
(
$i
=
7
;
$i
>=
0
;
$i
--
)
{
$day
=
date
(
"Y-m-d"
,
strtotime
(
"-"
.
$i
.
" day"
));
array_push
(
$dayArr
,
$day
);
$orderAmount
=
mt_rand
(
100
,
200
);
//
OrderInfo::getDayAmount($day);
$orderAmount
=
OrderInfo
::
getDayAmount
(
$day
);
array_push
(
$amounts
,
$orderAmount
);
}
...
...
app/Admin/Renderable/OrderGoodsList.php
View file @
ca26f33f
...
...
@@ -21,7 +21,9 @@ public function grid(): Grid
$grid
->
addTableClass
([
'table-text-center'
]);
$grid
->
model
()
->
where
(
'order_id'
,
$order_id
);
//$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_number'
,
'数量'
)
->
limit
(
10
);
$grid
->
column
(
'goods_price'
,
'价格'
)
->
limit
(
10
);
...
...
app/Http/Controllers/Api/GoodController.php
View file @
ca26f33f
...
...
@@ -263,7 +263,7 @@ public function getDetail(Request $request)
'id'
=>
$goods
->
id
,
'goods_img'
=>
$cover
,
'goods_price'
=>
$mer_id
?
$dg_price
:
$market_price
,
'market_price'
=>
$
market_price
,
'market_price'
=>
$
userObj
?
$market_price
:
''
,
'stock'
=>
$stock
,
'goods_name'
=>
$goods
->
goods_name
,
'sale'
=>
$goods
->
sale
??
0
,
...
...
app/Http/Controllers/Api/LoginController.php
View file @
ca26f33f
...
...
@@ -127,9 +127,10 @@ private function codeToSession($code)
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
;
return
$this
->
JsonResponse
([
'Authorization'
=>
$accessToken
,]);
}
...
...
app/Http/Controllers/Api/OrderController.php
View file @
ca26f33f
...
...
@@ -434,18 +434,57 @@ public function delOrder(Request $request)
//扫码核销
public
function
scanCodeVerifi
(
Request
$request
)
{
$verObj
=
$request
->
user
();
$code
=
$request
->
code
??
''
;
$orderObj
=
OrderInfoModel
::
where
(
'verification_code'
,
$code
)
->
first
();
if
(
!
$orderObj
)
{
return
$this
->
JsonResponse
(
''
,
'参数错误'
,
201
);
}
Log
::
add
(
'核销操作5'
,
[
$orderObj
->
verification_at
]);
if
(
!
$orderObj
->
verification_at
)
{
$orderObj
->
order_status
=
3
;
$orderObj
->
verifier_id
=
$verObj
->
id
;
$orderObj
->
verifier
=
$verObj
->
name
;
$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
{
return
$this
->
JsonResponse
(
''
,
'该码已核销,无需多次重复扫码'
,
500
);
}
Log
::
add
(
'核销操作6'
,
$orderObj
->
toArray
());
return
$this
->
JsonResponse
(
''
);
}
...
...
app/Http/Controllers/Api/UserController.php
View file @
ca26f33f
...
...
@@ -176,11 +176,11 @@ public function info(Request $request)
'phone'
=>
$user
->
phone
,
'phone_sec'
=>
$user
->
phone
?
substr
(
$user
->
phone
,
0
,
3
)
.
"****"
.
substr
(
$user
->
phone
,
7
)
:
''
,
//'status' => $user->status,
'merchant_id'
=>
$user
->
merchant_id
,
'buycode'
=>
$user
->
buycode
,
'balance'
=>
$balance
,
'total_revenue'
=>
$total_revenue
,
'cashout'
=>
$cashout
,
'merchant_id'
=>
$user
->
merchant_id
??
0
,
'buycode'
=>
$user
->
buycode
??
''
,
'balance'
=>
$balance
??
0
,
'total_revenue'
=>
$total_revenue
??
0
,
'cashout'
=>
$cashout
??
0
,
]);
}
...
...
app/Models/OrderInfo.php
View file @
ca26f33f
...
...
@@ -73,18 +73,17 @@ public static function getNumDayData($dayNum, $status = [])
'total'
=>
0
,
'list'
=>
[]
];
$where
=
[]
;
//DB::enableQueryLog()
;
$sqlObj
=
new
self
();
if
(
$status
)
{
$sqlObj
=
$sqlObj
->
whereIn
(
'order_status'
,
$status
);
}
foreach
(
$days
as
$day
)
{
$startTime
=
$day
.
' 00:00:00'
;
$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
[
'total'
]
+=
$count
;
}
return
$data
;
}
...
...
@@ -94,7 +93,9 @@ public static function getDayAmount($dayDate)
$startTime
=
$dayDate
.
' 00:00:00'
;
$endTime
=
$dayDate
.
' 23:59:59'
;
$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
;
}
...
...
@@ -110,7 +111,9 @@ public static function getMonthAmount($monthDate)
$startTime
=
$firstDayOfMonth
.
' 00:00:00'
;
$endTime
=
$lastDayOfMonth
.
' 23:59:59'
;
$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
;
}
...
...
app/Models/Pay.php
View file @
ca26f33f
...
...
@@ -75,39 +75,6 @@ public static function payNotify($fields = [])
$orderObj
->
order_status
=
1
;
$orderObj
->
pay_status
=
1
;
$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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment