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
eb09e88e
Commit
eb09e88e
authored
Oct 09, 2024
by
lizhilin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
060c5f0f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
75 deletions
+28
-75
app/Http/Controllers/Api/IncomeController.php
+2
-1
app/Http/Controllers/Api/LoginController.php
+4
-1
app/Http/Controllers/Api/MerchantController.php
+1
-1
app/Http/Controllers/Api/OrderController.php
+3
-1
app/Http/Controllers/Api/StoreController.php
+4
-4
app/Models/OrderInfo.php
+4
-63
app/Models/Pay.php
+5
-0
app/Store/Metrics/Examples/LastStockTotal.php
+4
-3
app/Store/Metrics/Examples/LastWaitPickTotal.php
+1
-1
No files found.
app/Http/Controllers/Api/IncomeController.php
View file @
eb09e88e
...
...
@@ -21,7 +21,8 @@ public function getList(Request $request)
if
(
!
in_array
(
$type
,
[
1
,
2
,]))
{
return
$this
->
JsonResponse
(
''
,
'参数错误'
,
201
);
}
$sql
=
Income
::
where
([
'um_id'
=>
$request
->
user
()
->
id
,
'user_type'
=>
$type
,
'deleted_at'
=>
null
]);
$um_id
=
(
$type
==
2
)
?
$request
->
user
()
->
merchant_id
:
$request
->
user
()
->
id
;
$sql
=
Income
::
where
([
'um_id'
=>
$um_id
,
'user_type'
=>
$type
,
'deleted_at'
=>
null
]);
$total
=
$sql
->
count
();
$data
=
[
...
...
app/Http/Controllers/Api/LoginController.php
View file @
eb09e88e
...
...
@@ -79,6 +79,9 @@ public function login(Request $request)
$encryptedData
=
$request
->
encryptedData
??
''
;
$result
=
$this
->
codeToSession
(
$code
);
if
(
isset
(
$result
[
'errcode'
]))
{
return
$this
->
JsonResponse
(
''
,
$result
[
'errmsg'
],
201
);
}
$openId
=
$result
[
'openid'
];
$session_key
=
$result
[
'session_key'
];
...
...
@@ -160,7 +163,7 @@ private function codeToSession($code)
$wx_data
=
json_decode
(
file_get_contents
(
$url
),
true
);
if
(
isset
(
$wx_data
[
'errcode'
]))
{
Log
::
add
(
'请求微信接口异常'
,
$wx_data
);
return
$this
->
JsonResponse
(
''
,
'请求微信接口异常'
,
201
);
//
return $this->JsonResponse('', '请求微信接口异常', 201);
}
return
$wx_data
;
}
...
...
app/Http/Controllers/Api/MerchantController.php
View file @
eb09e88e
...
...
@@ -45,7 +45,7 @@ public function getUserList(Request $request)
'uid'
=>
$uid
,
'name'
=>
$item
->
name
,
'divide_price'
=>
(
float
)
$divide_price
,
'avatar'
=>
(
isset
(
$item
->
avatar
)
?
env
(
'IMAGE_URL'
)
.
$item
->
avatar
:
env
(
'NO_AVATAR_IMAGE_URL'
)
),
'avatar'
=>
$item
->
avatar
?
env
(
'IMAGE_URL'
)
.
$item
->
avatar
:
env
(
'NO_AVATAR_IMAGE_URL'
),
'created_at'
=>
date
(
'Y-m-d H:i:s'
,
strtotime
(
$item
->
created_at
)),
];
}
...
...
app/Http/Controllers/Api/OrderController.php
View file @
eb09e88e
...
...
@@ -497,6 +497,7 @@ public function scanCodeDetail(Request $request)
$code
=
$request
->
code
??
''
;
$orderObj
=
OrderInfoModel
::
where
(
'verification_code'
,
$code
)
->
first
();
if
(
!
$orderObj
)
{
Log
::
add
(
'核销码'
,
$code
);
return
$this
->
JsonResponse
(
''
,
'参数错误'
,
201
);
}
$order_id
=
$orderObj
->
id
;
...
...
@@ -672,7 +673,8 @@ public function orderCollect(Request $request)
$lastMonth
[
'pickedCount'
]
=
OrderInfoModel
::
where
(
$where
)
->
where
(
'pay_status'
,
1
)
->
whereIn
(
'order_status'
,
[
3
,
4
])
->
whereBetween
(
'created_at'
,
[
$firstDayOfLastMonth
,
$ninthDayOfLastMonth
])
->
count
();
$lastMonth
[
'waitCount'
]
=
OrderInfoModel
::
where
(
$where
)
->
where
(
'pay_status'
,
1
)
->
where
(
"order_status"
,
2
)
->
whereBetween
(
'created_at'
,
[
$firstDayOfLastMonth
,
$ninthDayOfLastMonth
])
->
count
();
//本月订单商品销量
$goods_number
=
OrderGoods
::
where
(
'merchant_id'
,
$merchant_id
)
->
whereBetween
(
'created_at'
,
[
$firstDayOfMonth
,
$lastDayOfMonth
])
->
sum
(
'goods_number'
);
$goods_number
=
OrderGoods
::
where
([
'merchant_id'
=>
$merchant_id
,
'is_pay'
=>
1
])
->
whereBetween
(
'created_at'
,
[
$firstDayOfMonth
,
$lastDayOfMonth
])
->
sum
(
'goods_number'
);
$lastMonth
[
'stockCount'
]
=
$goods_number
+
$currentStock
;
return
$this
->
JsonResponse
([
'current'
=>
$currentMonth
?
$currentMonth
:
new
\stdClass
(),
'last'
=>
$lastMonth
?
$lastMonth
:
new
\stdClass
()]);
...
...
app/Http/Controllers/Api/StoreController.php
View file @
eb09e88e
...
...
@@ -71,10 +71,10 @@ function haversineDistance($lat1, $lng1, $lat2, $lng2)
$radius
=
6371
;
// 将角度转为弧度
$lat1
=
deg2rad
(
$lat1
);
$lng1
=
deg2rad
(
$lng1
);
$lat2
=
deg2rad
(
$lat2
);
$lng2
=
deg2rad
(
$lng2
);
$lat1
=
deg2rad
(
(
float
)
$lat1
);
$lng1
=
deg2rad
(
(
float
)
$lng1
);
$lat2
=
deg2rad
(
(
float
)
$lat2
);
$lng2
=
deg2rad
(
(
float
)
$lng2
);
// 计算经纬度差值
$latDiff
=
$lat2
-
$lat1
;
...
...
app/Models/OrderInfo.php
View file @
eb09e88e
...
...
@@ -2,6 +2,7 @@
namespace
App\Models
;
use
App\Command\Log
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Database\Eloquent\Model
;
...
...
@@ -44,6 +45,7 @@ public function merchant()
*/
public
static
function
getNumData
(
$started
=
''
,
$ended
=
''
,
$status
=
[],
$merchant_id
=
0
)
{
DB
::
enableQueryLog
();
$where
=
[
'pay_status'
=>
1
];
$sqlObj
=
new
self
();
if
(
$merchant_id
)
{
...
...
@@ -58,7 +60,8 @@ public static function getNumData($started = '', $ended = '', $status = [], $mer
$sqlObj
=
$sqlObj
->
whereBetween
(
'created_at'
,
[
$startTime
,
$endTime
]);
}
$count
=
$sqlObj
->
where
(
$where
)
->
count
();
//$queries = DB::getQueryLog();
//Log::add("待收货统计日志", $queries);
return
$count
;
}
//指定天数
...
...
@@ -141,66 +144,4 @@ public static function getYearData()
}
return
$data
;
}
public
static
function
CreateImportData
(
$item
)
:
array
{
// [0] => 北海道香格里拉
// [1] => 江户川区
// [2] => 新左近川亲水公园
// [3] => 3室2厅2卫
// [4] => 21-100
// [5] => 121.23917
// [6] => 31.19145
// [7] => 精装修|有车位
// [8] => 8000-20000
// [9] => Array
// (
// [0] => /housing/20240305/d3f238df7cfe166d878b141e9562e1d0.png
// )
// [10] => 交通配套周边直
$result
=
$item
;
// echo "<pre>";
// print_r($result);
// die;
$tags
=
$result
[
7
];
if
(
$tags
)
{
$tagsArr
=
explode
(
"|"
,
$tags
);
$tmp
=
[];
foreach
(
$tagsArr
as
$key
=>
$val
)
{
//去除无标签
$exist
=
DB
::
table
(
'tag'
)
->
where
(
"title"
,
$val
)
->
first
();
if
(
$exist
)
{
array_push
(
$tmp
,
$val
);
}
}
$tags
=
json_encode
(
$tmp
,
JSON_UNESCAPED_UNICODE
);
}
$imgs
=
''
;
if
(
$item
[
9
])
{
$imgs
=
json_encode
(
$item
[
9
],
JSON_UNESCAPED_UNICODE
);
}
$name
=
$result
[
0
];
if
(
$result
[
0
])
{
$exist
=
self
::
where
(
"name"
,
$result
[
0
])
->
first
();
$name
=
!
$exist
?
$name
:
''
;
}
$data
=
[
'name'
=>
$name
,
//'area_id' => AreaModel::getIdByName($result[1]),
'position'
=>
$result
[
2
],
'layout_house'
=>
$result
[
3
],
'extent'
=>
$result
[
4
],
'lng'
=>
$result
[
5
],
'lat'
=>
$result
[
6
],
'tags'
=>
$tags
,
'rent'
=>
$result
[
8
],
'imgs'
=>
$imgs
,
'describe'
=>
$result
[
10
],
'created_at'
=>
date
(
'Y-m-d H:i:s'
),
'updated_at'
=>
date
(
'Y-m-d H:i:s'
),
];
return
$data
;
}
}
app/Models/Pay.php
View file @
eb09e88e
...
...
@@ -80,10 +80,14 @@ public static function payNotify($fields = [])
//更新商品销量、库存
$goodsList
=
OrderGoods
::
where
(
"order_id"
,
$orderObj
->
id
)
->
get
();
foreach
(
$goodsList
as
$item
)
{
//Log::add('--订单商品对象--', $item);
$gid
=
$item
->
goods_id
;
$attr_id
=
$item
->
attr_id
;
$mer_id
=
$item
->
merchant_id
;
$goods_number
=
$item
->
goods_number
;
//更新此商品支付状态
$item
->
is_pay
=
1
;
$item
->
save
();
$goodsObj
=
GoodModel
::
find
(
$gid
);
//更新商品规格库存
...
...
@@ -128,6 +132,7 @@ public static function payNotify($fields = [])
//return true;
}
catch
(
\Exception
$e
)
{
Log
::
add
(
'付款回调失败'
,
$e
);
DB
::
rollBack
();
return
false
;
}
}
...
...
app/Store/Metrics/Examples/LastStockTotal.php
View file @
eb09e88e
...
...
@@ -44,11 +44,12 @@ public function handle(Request $request)
case
'7'
:
default
:
$mer_id
=
Admin
::
user
()
->
merchant_id
;
$firstDayOfMonth
=
date
(
'Y-m-01 00:00:00'
,
strtotime
(
'-1 month'
,
time
()));
$lastDayOfMonth
=
date
(
'Y-m-t 23:59:59'
,
strtotime
(
'-1 month'
,
time
()
));
$firstDayOfMonth
=
date
(
'Y-m-01 00:00:00'
);
// 00:00:00
$lastDayOfMonth
=
date
(
"Y-m-t 23:59:59"
,
time
(
));
$currentStock
=
MerchantGoodSku
::
where
(
"merchant_id"
,
$mer_id
)
->
sum
(
'stock'
);
//本月订单商品销量
$goods_number
=
OrderGoods
::
where
(
'merchant_id'
,
$mer_id
)
->
whereBetween
(
'created_at'
,
[
$firstDayOfMonth
,
$lastDayOfMonth
])
->
sum
(
'goods_number'
);
$goods_number
=
OrderGoods
::
where
([
'merchant_id'
=>
$mer_id
,
'is_pay'
=>
1
])
->
whereBetween
(
'created_at'
,
[
$firstDayOfMonth
,
$lastDayOfMonth
])
->
sum
(
'goods_number'
);
$total
=
$goods_number
+
$currentStock
;
// 卡片内容
$this
->
withContent
(
$total
);
...
...
app/Store/Metrics/Examples/LastWaitPickTotal.php
View file @
eb09e88e
...
...
@@ -44,7 +44,7 @@ public function handle(Request $request)
$started
=
date
(
'Y-m-01'
,
strtotime
(
'last month'
));
$ended
=
date
(
'Y-m-t'
,
strtotime
(
'last month'
));
$order_status
=
[
2
];
$count
=
OrderInfoModel
::
getNumData
(
$started
,
$ended
,
$order_status
,
Admin
::
user
()
->
id
);
$count
=
OrderInfoModel
::
getNumData
(
$started
,
$ended
,
$order_status
,
Admin
::
user
()
->
merchant_
id
);
// 卡片内容
$this
->
withContent
(
$count
);
...
...
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