Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1c4f132a
authored
Dec 05, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev/ver/1.0.0'
parents
9ef1de8d
7af39ae3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
113 deletions
app/Http/Controllers/Api/AuthApiController.php
app/Http/Controllers/Api/CartApiController.php
app/Http/Controllers/HomeController.php
app/Http/Services/CartService.php
app/Http/Services/OrderService.php
app/Http/Services/ThirdService.php
app/Http/Controllers/Api/AuthApiController.php
View file @
1c4f132a
...
@@ -71,7 +71,7 @@ class AuthApiController extends Controller
...
@@ -71,7 +71,7 @@ class AuthApiController extends Controller
}
}
return
$this
->
setError
(
'
Login failure
'
);
return
$this
->
setError
(
'
The account or password is incorrect
'
);
}
}
public
function
logout
(
Request
$request
)
public
function
logout
(
Request
$request
)
...
...
app/Http/Controllers/Api/CartApiController.php
View file @
1c4f132a
...
@@ -37,27 +37,6 @@ class CartApiController extends Controller
...
@@ -37,27 +37,6 @@ class CartApiController extends Controller
return
!
$result
?
$this
->
setError
(
'Add cart failed , please contact administrator'
)
:
$this
->
setSuccess
(
'success'
,
ApiCode
::
API_CODE_SUCCESS
,
$result
);
return
!
$result
?
$this
->
setError
(
'Add cart failed , please contact administrator'
)
:
$this
->
setSuccess
(
'success'
,
ApiCode
::
API_CODE_SUCCESS
,
$result
);
}
}
//批量添加购物车, items: {"goods_id":1166788996788323407,"goods_number":2}
public
function
saveCartBatch
(
Request
$request
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'items'
=>
'required|string'
,
],
[
'items.min'
=>
'items must be at least 1 characters long.'
]);
if
(
$validator
->
fails
())
{
return
$this
->
setError
(
$validator
->
errors
()
->
first
());
}
$data
=
$request
->
only
([
'items'
,
'data'
,
]);
$result
=
CartService
::
saveCart
(
$data
,
$request
->
user
->
id
,
$request
->
user
->
gid
);
return
!
$result
?
$this
->
setError
(
'Add cart failed , please contact administrator'
)
:
$this
->
setSuccess
(
'Add inquiry success'
);
}
//购物车列表
//购物车列表
public
function
cartLists
(
Request
$request
){
public
function
cartLists
(
Request
$request
){
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
,
$request
->
user
->
gid
,
$request
->
input
(
"cart_ids"
,
0
));
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
,
$request
->
user
->
gid
,
$request
->
input
(
"cart_ids"
,
0
));
...
...
app/Http/Controllers/HomeController.php
View file @
1c4f132a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Http\Services\AutoAssignCustomerService
;
use
App\Http\Services\AutoAssignCustomerService
;
use
App\Http\Services\ThirdService
;
use
App\Http\Services\UserService
;
use
App\Http\Services\UserService
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
...
...
app/Http/Services/CartService.php
View file @
1c4f132a
...
@@ -26,7 +26,7 @@ class CartService
...
@@ -26,7 +26,7 @@ class CartService
$con
->
beginTransaction
();
$con
->
beginTransaction
();
$redis
=
Redis
::
connection
();
$redis
=
Redis
::
connection
();
$goodsInfoArr
=
ThirdService
::
get
GoodsInfo
([
$goods_id
]
);
$goodsInfoArr
=
ThirdService
::
get
SemourData
(
"goods_info"
,
$goods_id
);
$temp
=
[
$temp
=
[
'goods_id'
=>
$goods_id
,
'goods_id'
=>
$goods_id
,
...
@@ -41,7 +41,7 @@ class CartService
...
@@ -41,7 +41,7 @@ class CartService
}
}
$skuInfo
=
$goodsInfoArr
[
$goods_id
];
//sku库存
$skuInfo
=
$goodsInfoArr
[
$goods_id
];
//sku库存
$digikeyInfo
=
$redis
->
hget
(
"sku_raw_map"
,
$goods_id
);
//digikey 编码
$digikeyInfo
=
ThirdService
::
getSemourData
(
"sku_raw_map"
,
$goods_id
);
//digikey 编码
if
(
$digikeyInfo
){
if
(
$digikeyInfo
){
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
...
@@ -117,88 +117,6 @@ class CartService
...
@@ -117,88 +117,6 @@ class CartService
}
}
}
}
//添加或者更新购物车(批量)
public
static
function
saveCartBatch
(
$data
,
$user_id
=
""
,
$gid
=
""
)
{
try
{
$con
=
DB
::
connection
();
$con
->
beginTransaction
();
$vs
=
json_decode
(
\Arr
::
get
(
$data
,
'items'
,
[]),
true
);
$redis
=
Redis
::
connection
();
$goodsInfoArr
=
ThirdService
::
getGoodsInfo
(
array_column
(
$vs
,
"goods_id"
));
foreach
(
$vs
as
$v
)
{
$goods_id
=
$v
[
'goods_id'
];
$temp
=
[
'goods_id'
=>
$v
[
'goods_id'
],
'update_time'
=>
time
(),
];
if
(
$user_id
){
$temp
[
"user_id"
]
=
$user_id
;
}
else
{
$temp
[
"gid"
]
=
$gid
;
}
$skuInfo
=
$goodsInfoArr
[
$goods_id
];
//sku库存
$digikeyInfo
=
$redis
->
hget
(
"sku_raw_map"
,
$goods_id
);
//digikey 编码
if
(
$digikeyInfo
){
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
$temp
[
"raw_goods_packing"
]
=
$digikeyArr
[
"pack"
];
$temp
[
"raw_brand_name"
]
=
$digikeyArr
[
"raw_brand_name"
];
}
//购买时价格
$buy_price
=
0
;
$ladder_price
=
data_get
(
$skuInfo
,
"ladder_price"
);
if
(
$ladder_price
){
//购买价格
foreach
(
$ladder_price
as
$a
=>
$b
){
if
(
$v
[
"buy_number"
]
>=
$b
[
"purchases"
]){
$buy_price
=
$b
[
"price_us"
];
}
else
{
break
;
}
}
}
$temp
[
"buy_price"
]
=
$buy_price
;
$checkHas
=
CartModel
::
where
([
"user_id"
=>
$user_id
,
"goods_id"
=>
$goods_id
,
"status"
=>
1
])
->
first
();
if
(
$checkHas
){
//存在累计库存
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
(
$v
[
'buy_number'
]
+
$checkHas
[
"buy_number"
])
?
$v
[
'buy_number'
]
+
$checkHas
[
"buy_number"
]
:
$skuInfo
[
"stock"
];
$temp
[
"update_time"
]
=
time
();
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$flag
=
CartModel
::
where
([
"cart_id"
=>
$checkHas
[
"cart_id"
]])
->
update
(
$temp
);
if
(
!
$flag
){
throw
new
Exception
(
"error update"
,
1003
);
}
}
else
{
//不存在插入购物车
$temp
[
"buy_number"
]
=
$skuInfo
[
"stock"
]
>
$v
[
'buy_number'
]
?
$v
[
'buy_number'
]
:
$skuInfo
[
"stock"
];
$temp
[
"status"
]
=
$v
[
"buy_number"
]
>
0
?
CartModel
::
status_yes
:
CartModel
::
status_no
;
$temp
[
"create_time"
]
=
time
();
$temp
[
"update_time"
]
=
time
();
$flag
=
CartModel
::
insertGetId
(
$temp
);
if
(
!
$flag
){
throw
new
Exception
(
"error add"
,
1003
);
}
}
}
$con
->
commit
();
return
true
;
}
catch
(
\Exception
$e
){
$con
->
rollback
();
#throw new InvalidRequestException($e->getMessage().$e->getLine());
return
false
;
}
}
/*
/*
* 刷新购物车并且返回列表
* 刷新购物车并且返回列表
...
@@ -232,7 +150,7 @@ class CartService
...
@@ -232,7 +150,7 @@ class CartService
$con
->
beginTransaction
();
$con
->
beginTransaction
();
$redis
=
Redis
::
connection
();
$redis
=
Redis
::
connection
();
$goodsInfoArr
=
ThirdService
::
get
GoodsInfo
(
array_column
(
$result
,
"goods_id"
));
$goodsInfoArr
=
ThirdService
::
get
SemourData
(
"goods_info"
,
implode
(
","
,
array_column
(
$result
,
"goods_id"
)
));
$cartList
=
[];
$cartList
=
[];
...
@@ -251,7 +169,7 @@ class CartService
...
@@ -251,7 +169,7 @@ class CartService
}
}
$skuInfo
=
$goodsInfoArr
[
$goods_id
];
//sku库存
$skuInfo
=
$goodsInfoArr
[
$goods_id
];
//sku库存
$digikeyInfo
=
$redis
->
hget
(
"sku_raw_map"
,
$goods_id
);
//digikey 编码
$digikeyInfo
=
ThirdService
::
getSemourData
(
"sku_raw_map"
,
$goods_id
);
//digikey 编码
if
(
$digikeyInfo
){
if
(
$digikeyInfo
){
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
...
@@ -350,7 +268,7 @@ class CartService
...
@@ -350,7 +268,7 @@ class CartService
//猎芯联营采购员 ,添加供应商采购员渠道不得为空
//猎芯联营采购员 ,添加供应商采购员渠道不得为空
$info
[
'purchase_name'
]
=
''
;
$info
[
'purchase_name'
]
=
''
;
if
(
$info
[
'canal'
]
!=
""
){
if
(
$info
[
'canal'
]
!=
""
){
$pur_name
=
$redis
->
hget
(
'search_supplier_canaltopurchase'
,
$info
[
'canal'
]);
$pur_name
=
ThirdService
::
getSemourData
(
'search_supplier_canaltopurchase'
,
$info
[
'canal'
]);
$info
[
'purchase_name'
]
=
$pur_name
;
$info
[
'purchase_name'
]
=
$pur_name
;
}
}
//货区去掉工作日
//货区去掉工作日
...
@@ -362,7 +280,7 @@ class CartService
...
@@ -362,7 +280,7 @@ class CartService
#查询英文品牌缩写
#查询英文品牌缩写
$standard_brand_id
=
\Arr
::
get
(
\Arr
::
get
(
$info
,
"standard_brand"
),
"standard_brand_id"
);
$standard_brand_id
=
\Arr
::
get
(
\Arr
::
get
(
$info
,
"standard_brand"
),
"standard_brand_id"
);
$standardBrandInfo
=
$redis
->
hget
(
"standard_brand"
,
$standard_brand_id
);
$standardBrandInfo
=
ThirdService
::
getSemourData
(
"standard_brand"
,
$standard_brand_id
);
if
(
$standardBrandInfo
){
if
(
$standardBrandInfo
){
$standardBrandInfoArr
=
json_decode
(
$standardBrandInfo
,
true
);
$standardBrandInfoArr
=
json_decode
(
$standardBrandInfo
,
true
);
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
...
...
app/Http/Services/OrderService.php
View file @
1c4f132a
...
@@ -125,7 +125,8 @@ class OrderService
...
@@ -125,7 +125,8 @@ class OrderService
throw
new
InvalidRequestException
(
"error:order address"
);
throw
new
InvalidRequestException
(
"error:order address"
);
}
}
#订单明细
#订单明细
$goodsInfoArr
=
ThirdService
::
getGoodsInfo
(
array_column
(
$items
,
"goods_id"
));
//商品详情
$goodsInfoArr
=
ThirdService
::
getSemourData
(
"goods_info"
,
implode
(
","
,
array_column
(
$items
,
"goods_id"
)));
$orderItems
=
[];
//订单商品明细
$orderItems
=
[];
//订单商品明细
$orderAmount
=
0
;
$orderAmount
=
0
;
foreach
(
$items
as
$v
)
{
foreach
(
$items
as
$v
)
{
...
@@ -142,7 +143,7 @@ class OrderService
...
@@ -142,7 +143,7 @@ class OrderService
#查询英文品牌缩写
#查询英文品牌缩写
$brandName
=
$skuInfo
[
"brand_name"
];
$brandName
=
$skuInfo
[
"brand_name"
];
$standard_brand_id
=
\Arr
::
get
(
$standard_brand
,
"standard_brand_id"
,
0
);
$standard_brand_id
=
\Arr
::
get
(
$standard_brand
,
"standard_brand_id"
,
0
);
$standardBrandInfo
=
$redis
->
hget
(
"standard_brand"
,
$standard_brand_id
);
$standardBrandInfo
=
ThirdService
::
getSemourData
(
"standard_brand"
,
$standard_brand_id
);
if
(
$standardBrandInfo
){
if
(
$standardBrandInfo
){
$standardBrandInfoArr
=
json_decode
(
$standardBrandInfo
,
true
);
$standardBrandInfoArr
=
json_decode
(
$standardBrandInfo
,
true
);
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
...
@@ -397,7 +398,7 @@ class OrderService
...
@@ -397,7 +398,7 @@ class OrderService
->
get
()
->
get
()
->
keyBy
(
"order_address_type"
)
->
toArray
();
//地址信息,1收货信息 2账单邮寄信息
->
keyBy
(
"order_address_type"
)
->
toArray
();
//地址信息,1收货信息 2账单邮寄信息
$goodsInfoArr
=
ThirdService
::
get
GoodsInfo
(
array_column
(
$items
,
"goods_id"
));
//商品详情
$goodsInfoArr
=
ThirdService
::
get
SemourData
(
"goods_info"
,
implode
(
","
,
array_column
(
$items
,
"goods_id"
)
));
//商品详情
$itemsTemp
=
[];
$itemsTemp
=
[];
$merchandise_total
=
0
;
//商品总额
$merchandise_total
=
0
;
//商品总额
foreach
(
$items
as
$k
=>
$v
){
foreach
(
$items
as
$k
=>
$v
){
...
...
app/Http/Services/ThirdService.php
View file @
1c4f132a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Services
;
namespace
App\Http\Services
;
use
App\Exceptions\InvalidRequestException
;
use
App\Exceptions\InvalidRequestException
;
use
App\Http\ApiHelper\ApiCode
;
use
App\Http\Models\Order\OrderModel
;
use
App\Http\Models\Order\OrderModel
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Log
;
...
@@ -34,4 +35,20 @@ class ThirdService
...
@@ -34,4 +35,20 @@ class ThirdService
return
$res
[
'data'
];
return
$res
[
'data'
];
}
}
/*
*
* getSemourData("sku_raw_map","1163833797285826826")
*
* 深茂获取相关数据
* hget("sku_raw_map",$goods_id); //digikey 编码
* hget("standard_brand",$standard_brand_id); //获取标准品牌
* synchronization //获取商品详情
*/
public
static
function
getSemourData
(
$types
,
$k
){
$response
=
Http
::
asForm
()
->
post
(
env
(
'FOOTSTONE_URL'
,
''
)
.
"/open/getSemourData"
,
[
"k"
=>
$k
,
"types"
=>
$types
]);
$data
=
json_decode
(
$response
->
body
(),
true
);
return
\Arr
::
get
(
$data
,
"data"
);
}
}
}
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