Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
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
曲欣亮
shop
Commits
5cafdfaf
Commit
5cafdfaf
authored
Oct 11, 2018
by
zhangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a65c2b03
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1033 additions
and
2 deletions
+1033
-2
CartController.java
src/main/java/com/egolm/shop/controller/CartController.java
+23
-0
CartRedisService.java
src/main/java/com/egolm/shop/service/CartRedisService.java
+12
-0
CartService.java
src/main/java/com/egolm/shop/service/CartService.java
+4
-0
CartRedisServiceImpl.java
...ava/com/egolm/shop/service/impl/CartRedisServiceImpl.java
+969
-0
CartServiceImpl.java
...ain/java/com/egolm/shop/service/impl/CartServiceImpl.java
+25
-2
No files found.
src/main/java/com/egolm/shop/controller/CartController.java
View file @
5cafdfaf
package
com
.
egolm
.
shop
.
controller
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -25,6 +28,26 @@ public class CartController {
@Autowired
private
CartService
cartService
;
@ApiOperation
(
"购物车信息"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"shopNO"
,
dataType
=
"String"
,
required
=
true
,
value
=
"店铺编号"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"terminal"
,
dataType
=
"String"
,
required
=
false
,
value
=
"终端标识"
,
defaultValue
=
"wechat"
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"langID"
,
dataType
=
"String"
,
required
=
false
,
value
=
"语言"
,
defaultValue
=
"936"
),
})
@RequestMapping
(
value
=
"/cartQuery"
,
method
=
RequestMethod
.
GET
)
public
String
cartQuery
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"shopNO"
,
request
.
getParameter
(
"shopNO"
));
params
.
put
(
"terminal"
,
request
.
getParameter
(
"terminal"
));
params
.
put
(
"langID"
,
request
.
getParameter
(
"langID"
));
return
cartService
.
query
(
params
);
}
@ApiOperation
(
"加入购物车(JSON格式)"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
false
,
value
=
"JSON格式"
,
defaultValue
=
"{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\" }]}"
),
...
...
src/main/java/com/egolm/shop/service/CartRedisService.java
0 → 100644
View file @
5cafdfaf
package
com
.
egolm
.
shop
.
service
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSONObject
;
public
interface
CartRedisService
{
public
void
reCache
(
String
shopNo
,
String
terminal
);
public
void
changeQty
(
String
shopNo
,
String
terminal
,
Integer
nIdx
,
Double
nSaleQty
);
public
Map
<
String
,
Object
>
querySync
(
String
shopNo
,
String
terminal
)
;
}
src/main/java/com/egolm/shop/service/CartService.java
View file @
5cafdfaf
package
com
.
egolm
.
shop
.
service
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSONObject
;
public
interface
CartService
{
...
...
@@ -9,4 +11,6 @@ public interface CartService {
public
String
remove
(
JSONObject
obj
);
public
String
updateQty
(
JSONObject
obj
);
public
String
query
(
Map
<
String
,
Object
>
params
);
}
src/main/java/com/egolm/shop/service/impl/CartRedisServiceImpl.java
0 → 100644
View file @
5cafdfaf
This diff is collapsed.
Click to expand it.
src/main/java/com/egolm/shop/service/impl/CartServiceImpl.java
View file @
5cafdfaf
...
...
@@ -15,6 +15,7 @@ import com.egolm.common.StringUtil;
import
com.egolm.common.Util
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.shop.service.CartRedisService
;
import
com.egolm.shop.service.CartService
;
@Service
...
...
@@ -23,6 +24,8 @@ public class CartServiceImpl implements CartService {
private
static
final
Log
logger
=
LogFactory
.
getLog
(
CartServiceImpl
.
class
);
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Autowired
private
CartRedisService
cartRedisService
;
/**
* {
...
...
@@ -96,7 +99,7 @@ public class CartServiceImpl implements CartService {
}
}
}
cartRedisService
.
reCache
(
shopNO
,
terminal
);
return
Rjx
.
jsonOk
().
set
(
"count"
,
count
(
shopNO
)).
toJson
();
}
...
...
@@ -143,6 +146,8 @@ public class CartServiceImpl implements CartService {
sql
=
"delete from tCart where sShopNO = '"
+
shopNO
+
"' and nTag = 1 and sPromoPaperNO in ("
+
sql
+
")"
;
jdbcTemplate
.
executeUpdate
(
sql
);
jdbcTemplate
.
executeUpdate
(
"delete from tCart where sShopNO = '"
+
shopNO
+
"'"
+
StringUtil
.
join
(
", "
,
" and nIdx in ("
,
")"
,
nIdx
));
cartRedisService
.
reCache
(
shopNO
,
terminal
);
return
Rjx
.
jsonOk
().
set
(
"count"
,
count
(
shopNO
)).
toJson
();
}
...
...
@@ -158,7 +163,7 @@ public class CartServiceImpl implements CartService {
*/
public
String
updateQty
(
JSONObject
obj
)
{
String
shopNO
=
obj
.
getString
(
"shopNO"
);
String
idx
=
obj
.
getString
(
"idx"
);
Integer
idx
=
obj
.
getInteger
(
"idx"
);
Double
saleQty
=
obj
.
getDouble
(
"saleQty"
);
String
terminal
=
obj
.
getString
(
"terminal"
);
String
langID
=
obj
.
getString
(
"langID"
);
...
...
@@ -177,7 +182,25 @@ public class CartServiceImpl implements CartService {
}
else
{
jdbcTemplate
.
executeUpdate
(
"update tCart set nSaleQty = "
+
saleQty
+
" where sShopNO = '"
+
shopNO
+
"' and nIdx = "
+
idx
);
}
cartRedisService
.
changeQty
(
shopNO
,
terminal
,
idx
,
saleQty
);
return
Rjx
.
jsonOk
().
set
(
"count"
,
count
(
shopNO
)).
toJson
();
}
/**
* 查询购物车
* <p>Title: query</p>
* <p>Description: </p>
* @param params
* @return
* @see com.egolm.shop.service.CartService#query(java.util.Map)
*/
@Override
public
String
query
(
Map
<
String
,
Object
>
params
)
{
String
shopNO
=
params
.
get
(
"shopNO"
)+
""
;
String
terminal
=
params
.
get
(
"terminal"
)+
""
;
Map
<
String
,
Object
>
queryMap
=
cartRedisService
.
querySync
(
shopNO
,
terminal
);
return
Rjx
.
jsonOk
().
setData
(
queryMap
).
toJson
();
}
}
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