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
7af39ae3
authored
Dec 05, 2022
by
SUDPTDUBLXEROFX\Administrator
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新深茂
parent
5af5a298
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
112 deletions
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/CartApiController.php
View file @
7af39ae3
...
...
@@ -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
);
}
//批量添加购物车, 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
){
$result
=
CartService
::
cartLists
(
$request
->
user
->
id
,
$request
->
user
->
gid
,
$request
->
input
(
"cart_ids"
,
0
));
...
...
app/Http/Controllers/HomeController.php
View file @
7af39ae3
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Controllers
;
use
App\Http\Services\AutoAssignCustomerService
;
use
App\Http\Services\ThirdService
;
use
App\Http\Services\UserService
;
use
Illuminate\Http\Request
;
...
...
app/Http/Services/CartService.php
View file @
7af39ae3
...
...
@@ -26,7 +26,7 @@ class CartService
$con
->
beginTransaction
();
$redis
=
Redis
::
connection
();
$goodsInfoArr
=
ThirdService
::
get
GoodsInfo
([
$goods_id
]
);
$goodsInfoArr
=
ThirdService
::
get
SemourData
(
"goods_info"
,
$goods_id
);
$temp
=
[
'goods_id'
=>
$goods_id
,
...
...
@@ -41,7 +41,7 @@ class CartService
}
$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
){
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
...
...
@@ -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
$con
->
beginTransaction
();
$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
=
[];
...
...
@@ -251,7 +169,7 @@ class CartService
}
$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
){
$digikeyArr
=
json_decode
(
$digikeyInfo
,
true
);
$temp
[
"raw_goods_sn"
]
=
$digikeyArr
[
"raw_goods_id"
];
...
...
@@ -350,7 +268,7 @@ class CartService
//猎芯联营采购员 ,添加供应商采购员渠道不得为空
$info
[
'purchase_name'
]
=
''
;
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
;
}
//货区去掉工作日
...
...
@@ -362,7 +280,7 @@ class CartService
#查询英文品牌缩写
$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
){
$standardBrandInfoArr
=
json_decode
(
$standardBrandInfo
,
true
);
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
...
...
app/Http/Services/OrderService.php
View file @
7af39ae3
...
...
@@ -125,7 +125,8 @@ class OrderService
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
=
[];
//订单商品明细
$orderAmount
=
0
;
foreach
(
$items
as
$v
)
{
...
...
@@ -142,7 +143,7 @@ class OrderService
#查询英文品牌缩写
$brandName
=
$skuInfo
[
"brand_name"
];
$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
){
$standardBrandInfoArr
=
json_decode
(
$standardBrandInfo
,
true
);
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
...
...
@@ -397,7 +398,7 @@ class OrderService
->
get
()
->
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
=
[];
$merchandise_total
=
0
;
//商品总额
foreach
(
$items
as
$k
=>
$v
){
...
...
app/Http/Services/ThirdService.php
View file @
7af39ae3
...
...
@@ -2,6 +2,7 @@
namespace
App\Http\Services
;
use
App\Exceptions\InvalidRequestException
;
use
App\Http\ApiHelper\ApiCode
;
use
App\Http\Models\Order\OrderModel
;
use
Illuminate\Support\Facades\Http
;
use
Illuminate\Support\Facades\Log
;
...
...
@@ -34,4 +35,20 @@ class ThirdService
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