Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
05c86cf1
Commit
05c86cf1
authored
Sep 16, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车已存在规格修改问题
parent
89f77007
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
CartService.php
application/models/Business/Cart/CartService.php
+29
-1
Cart.php
application/models/DAO/Cart/Cart.php
+3
-0
CodeConfig.php
application/models/Error/CodeConfig.php
+2
-0
No files found.
application/models/Business/Cart/CartService.php
View file @
05c86cf1
...
...
@@ -56,8 +56,11 @@ class CartServiceModel extends \Business\AbstractModel{
*/
public
function
editCart
(
$data
,
$cart
,
$memberId
,
$pBundlind
=
null
){
$validReturnData
=
$this
->
validEditCart
(
$data
,
$cart
,
$memberId
,
$pBundlind
);
$cartDao
=
\DAO\Cart\CartModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
if
(
isset
(
$validReturnData
[
'existCartFlag'
])
&&
$validReturnData
[
'existCartFlag'
]
==
\Our\ApiConst
::
one
){
return
$this
->
editDelCart
(
$cart
,
$memberId
);
}
$cartArray
=
$this
->
getFormattedCartDataForEdit
(
$data
,
$cart
,
$memberId
,
$pBundlind
,
$validReturnData
);
$cartDao
=
\DAO\Cart\CartModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$result
=
$cartDao
->
update
(
$cartArray
[
'newCarts'
][
0
],
array
(
'cart_id'
=>
$data
[
'cartId'
]));
if
(
!
$result
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
editCartFailed
);
...
...
@@ -73,6 +76,26 @@ class CartServiceModel extends \Business\AbstractModel{
return
$result
;
}
/**
* 编辑规格时出现当前规格已经在购物车时,删除当前购物车
* @param $cart
* @param $memberId
* @return mixed
* @throws \Error\OurExceptionModel
* @throws \Exception
*/
public
function
editDelCart
(
$cart
,
$memberId
){
$cartRedis
=
\Redis\Db7\CartRedisModel
::
getInstance
();
$cartDao
=
\DAO\Cart\CartModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$result
=
$cartDao
->
del
(
array
(
'cart_id'
=>
$cart
[
'cart_id'
]));
if
(
!
$result
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
editDelCartFailed
);
}
$memberStoreCartsKey
=
\Our\NameConst
::
memberStoreCartsPrefix
.
$memberId
.
\Our\NameConst
::
underline
.
$cart
[
'store_id'
];
$cartRedis
->
tableDel
(
$memberStoreCartsKey
);
return
$result
;
}
/**
* 批量删除购物车
* @param $data
...
...
@@ -358,6 +381,11 @@ class CartServiceModel extends \Business\AbstractModel{
if
(
!
(
isset
(
$data
[
'goodsNum'
])
&&
intval
(
$data
[
'goodsNum'
])
>
\Our\ApiConst
::
zero
)){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
emptyCartGoodsNum
);
}
$cartDao
=
\DAO\Cart\CartModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$existCart
=
$cartDao
->
find
(
array
(
'goods_id'
=>
$data
[
'goodsId'
],
'buyer_id'
=>
$memberId
,
array
(
'cart_id'
=>
array
(
'neq '
,
$data
[
'cartId'
]))));
if
(
$existCart
){
return
array
(
'existCartFlag'
=>
\Our\ApiConst
::
one
);
}
$goodsDao
=
\DAO\GoodsModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$goodsValidStatus
=
$goodsDao
->
validEditCartGoods
(
$data
,
$cart
);
if
(
!
$goodsValidStatus
){
...
...
application/models/DAO/Cart/Cart.php
100755 → 100644
View file @
05c86cf1
...
...
@@ -40,6 +40,9 @@ class CartModel extends \DAO\AbstractModel{
*/
public
function
find
(
$where
,
$field
=
\Our\NameConst
::
allField
){
$this
->
setDb
(
$this
->
dbName
);
if
(
is_array
(
$where
)){
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
$data
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
select
(
$field
)
->
where
(
$where
)
->
fetchOne
();
return
$data
;
}
...
...
application/models/Error/CodeConfig.php
View file @
05c86cf1
...
...
@@ -163,6 +163,7 @@ class CodeConfigModel {
const
emptyPBundlingdForOrder
=
50038
;
const
pBundlingOfflineForOrder
=
50039
;
const
pBundlingNoStorageForOrder
=
50040
;
const
editDelCartFailed
=
50041
;
//订单相关错误码
...
...
@@ -553,6 +554,7 @@ class CodeConfigModel {
self
::
emptyPBundlingdForOrder
=>
'组合销售商品不存在'
,
self
::
pBundlingOfflineForOrder
=>
'组合销售商品已经下架'
,
self
::
pBundlingNoStorageForOrder
=>
'组合销售商品库存不足'
,
self
::
editDelCartFailed
=>
'编辑购物车时删除数据失败'
,
self
::
addressNotExist
=>
'地址不存在'
,
self
::
emptyAddressId
=>
'地址主键参数不能为空'
,
...
...
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