diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/controller/ShopTradeCartController.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/controller/ShopTradeCartController.java index 8ea5f54d..c8d3cc4f 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/controller/ShopTradeCartController.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/controller/ShopTradeCartController.java @@ -43,13 +43,25 @@ public class ShopTradeCartController { shopTradeCartService.queryList(inputObject, outputObject); } + /** + * 新增购物车信息 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ @ApiOperation(id = "insertShopTradeCart", value = "新增购物车信息", method = "POST", allUse = "2") @ApiImplicitParams(classBean = ShopTradeCart.class) - @RequestMapping("/post/ShopTradeCartController/writeShopTradeCart") + @RequestMapping("/post/ShopTradeCartController/insertShopTradeCart") public void insertShopTradeCart(InputObject inputObject, OutputObject outputObject) { shopTradeCartService.createEntity(inputObject, outputObject); } + /** + * 批量删除购物车信息 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ @ApiOperation(id = "deleteShopTradCartByIds", value = "批量删除购物车信息", method = "DELETE", allUse = "2") @ApiImplicitParams({ @ApiImplicitParam(id = "ids", name = "ids", value = "主键id列表,多个id用逗号隔开", required = "required")}) @@ -58,6 +70,12 @@ public class ShopTradeCartController { shopTradeCartService.deleteById(inputObject, outputObject); } + /** + * 更新购物车商品数量 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ @ApiOperation(id = "changeCount", value = "更新购物车商品数量", method = "POST", allUse = "2") @ApiImplicitParams({ @ApiImplicitParam(id = "id", name = "id", value = "主键id", required = "required"), @@ -67,6 +85,12 @@ public class ShopTradeCartController { shopTradeCartService.changeCount(inputObject, outputObject); } + /** + * 更新购物车商品选中 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ @ApiOperation(id = "changeSelected", value = "更新购物车商品选中", method = "POST", allUse = "2") @ApiImplicitParams({ @ApiImplicitParam(id = "id", name = "id", value = "主键id", required = "required")}) @@ -75,16 +99,27 @@ public class ShopTradeCartController { shopTradeCartService.changeSelected(inputObject, outputObject); } + /** + * 重置购物车信息 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ @ApiOperation(id = "resetShopTradeCart", value = "重置购物车信息", method = "POST", allUse = "2") @RequestMapping("/post/ShopTradeCartController/resetShopTradeCart") public void resetShopTradeCart(InputObject inputObject, OutputObject outputObject) { shopTradeCartService.resetShopTradeCart(inputObject, outputObject); } + /** + * 计算购物车总价 + * + * @param inputObject 入参以及用户信息等获取对象 + * @param outputObject 出参以及提示信息的返回值对象 + */ @ApiOperation(id = "calculateTotalPrices", value = "计算购物车总价", method = "POST", allUse = "2") @RequestMapping("/post/ShopTradeCartController/calculateTotalPrices") public void calculateTotalPrices(InputObject inputObject, OutputObject outputObject) { shopTradeCartService.calculateTotalPrices(inputObject, outputObject); } - } \ No newline at end of file diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java index 157ae18a..13f91263 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/entity/ShopTradeCart.java @@ -38,7 +38,7 @@ public class ShopTradeCart extends OperatorUserInfo { @TableField(exist = false) @ApiModelProperty(value = "商品信息") - private Map materialMaton; + private Map materialMation; @TableField("norms_id") @ApiModelProperty(value = "规格id", required = "required") @@ -46,7 +46,7 @@ public class ShopTradeCart extends OperatorUserInfo { @TableField(exist = false) @ApiModelProperty(value = "規格信息") - private Map normsMaton; + private Map normsMation; @TableField("count") @ApiModelProperty(value = "数量", required = "required") diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/service/impl/ShopTradeCartServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/service/impl/ShopTradeCartServiceImpl.java index 11fae8ad..84c6d785 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/store/service/impl/ShopTradeCartServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/store/service/impl/ShopTradeCartServiceImpl.java @@ -5,6 +5,7 @@ package com.skyeye.store.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -18,6 +19,7 @@ import com.skyeye.common.enumeration.WhetherEnum; import com.skyeye.common.object.InputObject; import com.skyeye.common.object.OutputObject; import com.skyeye.common.util.CalculationUtil; +import com.skyeye.common.util.StringUtil; import com.skyeye.common.util.mybatisplus.MybatisPlusUtil; import com.skyeye.erp.service.IMaterialNormsService; import com.skyeye.erp.service.IMaterialService; @@ -26,6 +28,7 @@ import com.skyeye.rest.shopmaterialnorms.sevice.IShopMaterialNormsService; import com.skyeye.store.dao.ShopTradeCartDao; import com.skyeye.store.entity.ShopTradeCart; import com.skyeye.store.service.ShopTradeCartService; +import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -55,6 +58,7 @@ public class ShopTradeCartServiceImpl extends SkyeyeBusinessServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq(MybatisPlusUtil.toColumns(ShopTradeCart::getCreateId), userId); List beans = list(wrapper); - iMaterialNormsService.setDataMation(beans, ShopTradeCart::getMaterialId); + iMaterialNormsService.setDataMation(beans, ShopTradeCart::getNormsId); iMaterialService.setDataMation(beans, ShopTradeCart::getMaterialId); return JSONUtil.toList(JSONUtil.toJsonStr(beans), null); } + @Override + public String createEntity(ShopTradeCart shopTradeCart, String userId){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(MybatisPlusUtil.toColumns(ShopTradeCart::getMaterialId), shopTradeCart.getMaterialId()); + queryWrapper.eq(MybatisPlusUtil.toColumns(ShopTradeCart::getNormsId), shopTradeCart.getNormsId()); + ShopTradeCart one = getOne(queryWrapper); + if (ObjectUtil.isNotEmpty(one)) { + shopTradeCart.setId(one.getId()); + shopTradeCart.setCount(one.getCount() + shopTradeCart.getCount()); + return super.updateEntity(shopTradeCart, userId); + } + return super.createEntity(shopTradeCart, userId); + } + @Override public void deleteById(InputObject inputObject, OutputObject outputObject) { String ids = inputObject.getParams().get("ids").toString(); - List idList = Arrays.asList(ids.split(",")); + List idList = Arrays.asList(ids.split(CommonCharConstants.COMMA_MARK)); super.deleteById(idList); } @@ -88,14 +106,10 @@ public class ShopTradeCartServiceImpl extends SkyeyeBusinessServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq(MybatisPlusUtil.toColumns(ShopTradeCart::getCreateId), userId); - List list = list(queryWrapper); remove(queryWrapper); - List idCollect = list.stream() - .map(ShopTradeCart::getId).collect(Collectors.toList()); - outputObject.setBeans(idCollect); - outputObject.settotal(idCollect.size()); } @Override @@ -160,9 +167,8 @@ public class ShopTradeCartServiceImpl extends SkyeyeBusinessServiceImpl