mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
adding install cart verification
This commit is contained in:
parent
c0a4d1d375
commit
94906b8260
@ -5,6 +5,7 @@ package net.lab1024.smartadmin.module.system.royalcanin.good;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.smartadmin.common.anno.OperateLog;
|
||||
import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
|
||||
import net.lab1024.smartadmin.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.common.heartbeat.StringUtil;
|
||||
import net.lab1024.smartadmin.constant.SwaggerTagConst;
|
||||
@ -165,21 +166,26 @@ public class GoodController {
|
||||
|
||||
@ApiOperation(value = "插入购物车信息", notes = "插入购物车信息")
|
||||
@PostMapping("royalcanin/insertCartProductInfo")
|
||||
public ResponseDTO<String> insertCartProductInfo(@RequestBody CartEntity cartEntity){
|
||||
|
||||
CartEntity cartEntityFromDB = cartService.getInfoByProductCodeAndMemberId(cartEntity.getMemberId(),cartEntity.getProductCode());
|
||||
if (null == cartEntityFromDB){
|
||||
if (1 == cartService.insertProductCart(cartEntity))
|
||||
return ResponseDTO.succ();
|
||||
else
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL);
|
||||
}else{
|
||||
int buyCountTotal = cartEntity.getBuyCount()+ cartEntityFromDB.getBuyCount();
|
||||
cartEntityFromDB.setBuyCount(buyCountTotal);
|
||||
if (1 == cartService.updateInfo(cartEntityFromDB))
|
||||
return ResponseDTO.succ();
|
||||
else
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL);
|
||||
public ResponseDTO<String> insertCartProductInfo(@RequestBody CartEntity cartEntity,HttpServletRequest request){
|
||||
String memberId = SmartJWTUtil.decodeToken(request.getHeader(TOKEN_NAME));
|
||||
cartEntity.setMemberId(memberId);
|
||||
if(cartEntity.getProductCode() != null&&cartEntity.getProductCode() != ""&&cartEntity.getProductName() != null&&cartEntity.getProductName() != ""&&cartEntity.getMemberId() != null&&cartEntity.getMemberId() != "") {
|
||||
CartEntity cartEntityFromDB = cartService.getInfoByProductCodeAndMemberId(cartEntity.getMemberId(), cartEntity.getProductCode());
|
||||
if (null == cartEntityFromDB) {
|
||||
if (1 == cartService.insertProductCart(cartEntity))
|
||||
return ResponseDTO.succ();
|
||||
else
|
||||
return ResponseDTO.wrap(OrderResponseCodeConst.GENERATE_FAIL);
|
||||
} else {
|
||||
int buyCountTotal = cartEntity.getBuyCount() + cartEntityFromDB.getBuyCount();
|
||||
cartEntityFromDB.setBuyCount(buyCountTotal);
|
||||
if (1 == cartService.updateInfo(cartEntityFromDB))
|
||||
return ResponseDTO.succ();
|
||||
else
|
||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM);
|
||||
}
|
||||
}else {
|
||||
return ResponseDTO.wrap(ResponseCodeConst.ERROR_PARAM);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user