diff --git a/common/src/main/java/com/huoran/common/entity/UserAccount.java b/common/src/main/java/com/huoran/common/entity/UserAccount.java index 43c1141..0827fb0 100644 --- a/common/src/main/java/com/huoran/common/entity/UserAccount.java +++ b/common/src/main/java/com/huoran/common/entity/UserAccount.java @@ -63,7 +63,7 @@ public class UserAccount implements Serializable { private Date platformBindTime; @ApiModelProperty(value = "手机绑定时间") - private Date phoneBindingTime; + private String phoneBindingTime; @ApiModelProperty(value = "平台端区分:0->教师端 1->学生端 2->无端") private Integer type; diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/MyOrderController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/MyOrderController.java new file mode 100644 index 0000000..90e21c2 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/MyOrderController.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.controller; + +import cn.hutool.core.bean.BeanUtil; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.huoran.common.exception.YamiShopBindException; +import com.huoran.common.response.ServerResponseEntity; +import com.huoran.common.utils.SecurityUtils; +import com.huoran.nakadai.entity.app.dto.MyOrderDto; +import com.huoran.nakadai.entity.app.dto.OrderCountData; +import com.huoran.nakadai.entity.app.dto.OrderItemDto; +import com.huoran.nakadai.entity.app.dto.OrderShopDto; +import com.huoran.nakadai.entity.enums.OrderStatus; +import com.huoran.nakadai.entity.model.Order; +import com.huoran.nakadai.entity.model.OrderItem; +import com.huoran.nakadai.entity.model.ShopDetail; +import com.huoran.nakadai.entity.model.UserAddrOrder; +import com.huoran.nakadai.service.*; +import com.huoran.nakadai.utils.Arith; +import com.huoran.nakadai.utils.PageParam; +import io.swagger.annotations.Api; + +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Collections; + +import java.util.List; +import java.util.Objects; + +/** + * @author lanhai + */ +@RestController +@RequestMapping("/myOrder") +@Api(tags = "小程序我的订单接口(用户采购信息)") +@AllArgsConstructor +public class MyOrderController { + + private final OrderService orderService; + + private final ProductService productService; + + private final SkuService skuService; + + private final MyOrderService myOrderService; + + private final ShopDetailService shopDetailService; + + private final OrderItemService orderItemService; + + + /** + * 订单详情信息接口 + */ + @GetMapping("/orderDetail") + @ApiOperation(value = "根据订单号获取订单详情信息") + public ServerResponseEntity orderDetail(@RequestParam(value = "orderNumber") String orderNumber) { + + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + OrderShopDto orderShopDto = new OrderShopDto(); + + Order order = orderService.getOrderByOrderNumber(orderNumber); + + if (order == null) { + throw new RuntimeException("该订单不存在"); + } + if (!Objects.equals(order.getUserId(), userId)) { + throw new RuntimeException("你没有权限获取该订单信息"); + } + + ShopDetail shopDetail = shopDetailService.getShopDetailByShopId(order.getShopId()); +// UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId()); +// UserAddrDto userAddrDto = BeanUtil.copyProperties(userAddrOrder, UserAddrDto.class); + List orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber); + List orderItemList = BeanUtil.copyToList(orderItems, OrderItemDto.class); + + orderShopDto.setShopId(shopDetail.getShopId()); + orderShopDto.setShopName(shopDetail.getShopName()); + orderShopDto.setActualTotal(order.getActualTotal()); +// orderShopDto.setUserAddrDto(userAddrDto); + orderShopDto.setOrderItemDtos(orderItemList); + orderShopDto.setTransfee(order.getFreightAmount()); + orderShopDto.setReduceAmount(order.getReduceAmount()); + orderShopDto.setCreateTime(order.getCreateTime()); + orderShopDto.setRemarks(order.getRemarks()); + orderShopDto.setStatus(order.getStatus()); + + double total = 0.0; + Integer totalNum = 0; + for (OrderItemDto orderItem : orderShopDto.getOrderItemDtos()) { + total = Arith.add(total, orderItem.getProductTotalAmount()); + totalNum += orderItem.getProdCount(); + } + orderShopDto.setTotal(total); + orderShopDto.setTotalNum(totalNum); + + return ServerResponseEntity.success(orderShopDto); + } + + + /** + * 订单列表接口 + */ + @GetMapping("/myOrder") + @ApiOperation(value = "根据订单状态获取订单列表信息,状态为0时获取所有订单 1:待付款 2:待发货 3:待收货 4:待评价 5:成功 6:失败") + public ServerResponseEntity> myOrder(@RequestParam(value = "status") Integer status, PageParam page) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + IPage myOrderDtoIpage = myOrderService.pageMyOrderByUserIdAndStatus(page, userId, status); + return ServerResponseEntity.success(myOrderDtoIpage); + } + + /** + * 取消订单 + */ + @PostMapping("/cancel") + @ApiOperation(value = "根据订单号取消订单") + public ServerResponseEntity cancel(@RequestParam("orderNumber") String orderNumber) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + Order order = orderService.getOrderByOrderNumber(orderNumber); + if (!Objects.equals(order.getUserId(), userId)) { + throw new YamiShopBindException("你没有权限获取该订单信息"); + } + if (!Objects.equals(order.getStatus(), OrderStatus.UNPAY.value())) { + throw new YamiShopBindException("订单已支付,无法取消订单"); + } + List orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber); + order.setOrderItems(orderItems); + // 取消订单 + orderService.cancelOrders(Collections.singletonList(order)); + + // 清除缓存 + for (OrderItem orderItem : orderItems) { + productService.removeProductCacheByProdId(orderItem.getProdId()); + skuService.removeSkuCacheBySkuId(orderItem.getSkuId(), orderItem.getProdId()); + } + return ServerResponseEntity.success(); + } + + + /** + * 确认收货 + */ + @PostMapping("/receipt") + @ApiOperation(value = "根据订单号确认收货") + public ServerResponseEntity receipt(@RequestParam("orderNumber") String orderNumber) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + Order order = orderService.getOrderByOrderNumber(orderNumber); + if (!Objects.equals(order.getUserId(), userId)) { + throw new YamiShopBindException("你没有权限获取该订单信息"); + } + if (!Objects.equals(order.getStatus(), OrderStatus.CONSIGNMENT.value())) { + throw new YamiShopBindException("订单未发货,无法确认收货"); + } + List orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber); + order.setOrderItems(orderItems); + // 确认收货 + orderService.confirmOrder(Collections.singletonList(order)); + + for (OrderItem orderItem : orderItems) { + productService.removeProductCacheByProdId(orderItem.getProdId()); + skuService.removeSkuCacheBySkuId(orderItem.getSkuId(), orderItem.getProdId()); + } + return ServerResponseEntity.success(); + } + + /** + * 删除订单 + */ + @PostMapping("/deleteOrder") + @ApiOperation(value = "根据订单号删除订单") + public ServerResponseEntity delete(@RequestParam("orderNumber") String orderNumber) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + + Order order = orderService.getOrderByOrderNumber(orderNumber); + if (order == null) { + throw new YamiShopBindException("该订单不存在"); + } + if (!Objects.equals(order.getUserId(), userId)) { + throw new YamiShopBindException("你没有权限获取该订单信息"); + } + if (!Objects.equals(order.getStatus(), OrderStatus.SUCCESS.value()) && !Objects.equals(order.getStatus(), OrderStatus.CLOSE.value())) { + throw new YamiShopBindException("订单未完成或未关闭,无法删除订单"); + } + + // 删除订单 + orderService.deleteOrders(Collections.singletonList(order)); + + return ServerResponseEntity.success("删除成功"); + } + + /** + * 获取我的订单订单数量 + */ + @GetMapping("/orderCount") + @ApiOperation(value = "获取我的订单订单数量") + public ServerResponseEntity getOrderCount() { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + OrderCountData orderCountMap = orderService.getOrderCount(userId); + return ServerResponseEntity.success(orderCountMap); + } + + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java index 6ba3064..7b294bb 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/OrderController.java @@ -16,6 +16,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.IORuntimeException; import cn.hutool.core.io.IoUtil; +import cn.hutool.core.lang.Snowflake; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -64,7 +65,7 @@ import static com.huoran.nakadai.utils.SpringContextUtils.applicationContext; * @author lgh on 2018/09/15. */ @Slf4j -@Api(tags = "订单管理") +@Api(tags = "小程序订单接口(用户采购下单结算)") @RestController @RequestMapping("/order/order") public class OrderController { @@ -83,17 +84,19 @@ public class OrderController { @Autowired private BasketService basketService; @Autowired + private Snowflake snowflake; + @Autowired private ApplicationContext applicationContext; - @PostMapping("/sendInquiryForm") - @ApiOperation(value = "根据店铺发送询价单给商家或留言",response = ShopCartOrderMergerDto.class) + @PostMapping("/confirm") + @ApiOperation(value = "传入下单所需要的参数进行下单结算,生成订单信息",response = ShopCartOrderMergerDto.class) public ServerResponseEntity confirm( @Valid @RequestBody OrderParam orderParam) { String userId = SecurityUtils.getCurrentInfo().getAccountId(); // 组装获取用户提交的购物车商品项 - List shopCartItems = basketService.getShopCartItemsByOrderItems(null,orderParam.getOrderItem(),userId); + List shopCartItems = basketService.getShopCartItemsByOrderItems(orderParam.getBasketIds(),orderParam.getOrderItem(),userId); if (CollectionUtil.isEmpty(shopCartItems)) { throw new YamiShopBindException("请选择您需要的商品加入购物车"); @@ -148,16 +151,92 @@ public class OrderController { shopCartOrderMergerDto.setShopCartOrders(shopCartOrders); shopCartOrderMergerDto.setOrderReduce(orderReduce); + shopCartOrderMergerDto = orderService.putConfirmOrderCache(userId, shopCartOrderMergerDto); + return ServerResponseEntity.success(shopCartOrderMergerDto); } + + /** + * 购物车/立即购买 提交订单,根据店铺拆单 + */ + @PostMapping("/submit") + @ApiOperation(value = "根据店铺提交询价单给商家或留言,返回支付流水号,根据传入的参数判断是否为购物车提交订单,同时对购物车进行删除,用户开始进行支付") + public ServerResponseEntity submitOrders(@Valid @RequestBody SubmitOrderParam submitOrderParam) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + if (submitOrderParam.isLeaveAMessage()){ + Order order = new Order(); + order.setUserId(userId); + order.setTotal(0.0); + order.setOrderType(submitOrderParam.getOrderType()); + order.setProdName("采购留言"); + order.setShopId(SecurityUtils.getCurrentInfo().getShopId()); + String orderNumbers = String.valueOf(snowflake.nextId()); + order.setOrderNumber(orderNumbers); + order.setCreateTime(new Date()); + orderService.save(order); + return ServerResponseEntity.success(new OrderNumbersDto(orderNumbers)); + } + ShopCartOrderMergerDto mergerOrder = orderService.getConfirmOrderCache(userId); + if (mergerOrder == null) { + throw new YamiShopBindException("订单已过期,请重新下单"); + } + + List orderShopParams = submitOrderParam.getOrderShopParam(); + + List shopCartOrders = mergerOrder.getShopCartOrders(); + // 设置备注 + if (CollectionUtil.isNotEmpty(orderShopParams)) { + for (ShopCartOrderDto shopCartOrder : shopCartOrders) { + for (OrderShopParam orderShopParam : orderShopParams) { + if (shopCartOrder.getShopId().toString().equals(orderShopParam.getShopId().toString())) { + shopCartOrder.setRemarks(orderShopParam.getRemarks()); + shopCartOrder.setOrderType(submitOrderParam.getOrderType()); + } + } + } + } + + List orders = orderService.submit(userId,mergerOrder); + + + + StringBuilder orderNumbers = new StringBuilder(); + for (Order order : orders) { + orderNumbers.append(order.getOrderNumber()).append(","); + } + orderNumbers.deleteCharAt(orderNumbers.length() - 1); + + boolean isShopCartOrder = false; + // 移除缓存 + for (ShopCartOrderDto shopCartOrder : shopCartOrders) { + for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartOrder.getShopCartItemDiscounts()) { + for (ShopCartItemDto shopCartItem : shopCartItemDiscount.getShopCartItems()) { + Integer basketId = shopCartItem.getBasketId(); + if (basketId != null && basketId != 0) { + isShopCartOrder = true; + } + skuService.removeSkuCacheBySkuId(shopCartItem.getSkuId(),shopCartItem.getProdId()); + productService.removeProductCacheByProdId(shopCartItem.getProdId()); + } + } + } + // 购物车提交订单时(即有购物车ID时) + if (isShopCartOrder) { + basketService.removeShopCartItemsCacheByUserId(userId); + } + orderService.removeConfirmOrderCache(userId); + return ServerResponseEntity.success(new OrderNumbersDto(orderNumbers.toString())); + } + /** * 分页获取 */ // @GetMapping("/page") +// @ApiOperation(value = "商机线索列表") // public ServerResponseEntity> page(OrderParam orderParam, PageParam page, HttpServletRequest request) { // Integer shopId = TokenUtils.getShopIdByJwtToken(request); -// orderParam.setShopId(shopId); +// orderParam.setShopId(SecurityUtils.getCurrentInfo().getShopId()); // IPage orderPage = orderService.pageOrdersDetailByOrderParam(page, orderParam); // return ServerResponseEntity.success(orderPage); // } diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformOrderController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformOrderController.java new file mode 100644 index 0000000..d47593c --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformOrderController.java @@ -0,0 +1,287 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.controller; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.IORuntimeException; +import cn.hutool.core.io.IoUtil; +import cn.hutool.poi.excel.ExcelUtil; +import cn.hutool.poi.excel.ExcelWriter; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.google.common.base.Objects; +import com.huoran.common.exception.YamiShopBindException; +import com.huoran.common.response.ServerResponseEntity; +import com.huoran.common.utils.SecurityUtils; +import com.huoran.common.utils.TokenUtils; +import com.huoran.nakadai.entity.enums.OrderStatus; +import com.huoran.nakadai.entity.model.Order; +import com.huoran.nakadai.entity.model.OrderItem; +import com.huoran.nakadai.entity.model.UserAddrOrder; +import com.huoran.nakadai.entity.param.DeliveryOrderParam; +import com.huoran.nakadai.entity.param.OrderParam; +import com.huoran.nakadai.service.*; +import com.huoran.nakadai.utils.PageParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Sheet; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +/** + * @author lanhai + */ +@Slf4j +@RestController +@RequestMapping("/platformOrder") +@Api(tags = "供应商平台后台订单管理") +@AllArgsConstructor +public class PlatformOrderController { + + @Autowired + private OrderService orderService; + + @Autowired + private OrderItemService orderItemService; + + @Autowired + private ProductService productService; + + @Autowired + private SkuService skuService; + + + /** + * 分页获取 + */ + @GetMapping("/page") + @ApiOperation(value = "商机线索列表") + public ServerResponseEntity> page(OrderParam orderParam, PageParam page, HttpServletRequest request) { + orderParam.setShopId(SecurityUtils.getCurrentInfo().getShopId()); + IPage orderPage = orderService.pageOrdersDetailByOrderParam(page, orderParam); + return ServerResponseEntity.success(orderPage); + } + + /** + * 获取信息 + */ + @GetMapping("/orderInfo/{orderNumber}") + public ServerResponseEntity info(@PathVariable("orderNumber") String orderNumber, HttpServletRequest request) { + Integer shopId = TokenUtils.getShopIdByJwtToken(request); + Order order = orderService.getOrderByOrderNumber(orderNumber); + if (!com.google.common.base.Objects.equal(shopId, order.getShopId())) { + throw new YamiShopBindException("您没有权限获取该订单信息"); + } + List orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber); + order.setOrderItems(orderItems); +// UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId()); +// order.setUserAddrOrder(userAddrOrder); + return ServerResponseEntity.success(order); + } + + /** + * 发货 + */ + @PutMapping("/delivery") + public ServerResponseEntity delivery(@RequestBody DeliveryOrderParam deliveryOrderParam, HttpServletRequest request) { + Integer shopId = TokenUtils.getShopIdByJwtToken(request); + Order order = orderService.getOrderByOrderNumber(deliveryOrderParam.getOrderNumber()); + if (!Objects.equal(shopId, order.getShopId())) { + throw new YamiShopBindException("您没有权限修改该订单信息"); + } + + Order orderParam = new Order(); + orderParam.setOrderId(order.getOrderId()); + orderParam.setDvyId(deliveryOrderParam.getDvyId()); + orderParam.setDvyFlowId(deliveryOrderParam.getDvyFlowId()); + orderParam.setDvyTime(new Date()); + orderParam.setStatus(OrderStatus.CONSIGNMENT.value()); + orderParam.setUserId(order.getUserId()); + + orderService.delivery(orderParam); + + List orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber()); + for (OrderItem orderItem : orderItems) { + productService.removeProductCacheByProdId(orderItem.getProdId()); + skuService.removeSkuCacheBySkuId(orderItem.getSkuId(),orderItem.getProdId()); + } + return ServerResponseEntity.success(); + } + + /** + * 打印待发货的订单表 + * + * @param order + * @param consignmentName 发件人姓名 + * @param consignmentMobile 发货人手机号 + * @param consignmentAddr 发货地址 + */ + @GetMapping("/waitingConsignmentExcel") + public void waitingConsignmentExcel(Order order, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime, + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime, String consignmentName, String consignmentMobile, + String consignmentAddr, HttpServletResponse response, HttpServletRequest request) { + Integer shopId = TokenUtils.getShopIdByJwtToken(request); + order.setShopId(shopId); + order.setStatus(OrderStatus.PADYED.value()); + List orders = orderService.listOrdersDetailByOrder(order, startTime, endTime); + + //通过工具类创建writer + ExcelWriter writer = ExcelUtil.getBigWriter(); + Sheet sheet = writer.getSheet(); + sheet.setColumnWidth(0, 20 * 256); + sheet.setColumnWidth(1, 20 * 256); + sheet.setColumnWidth(2, 20 * 256); + sheet.setColumnWidth(3, 60 * 256); + sheet.setColumnWidth(4, 60 * 256); + sheet.setColumnWidth(7, 60 * 256); + sheet.setColumnWidth(8, 60 * 256); + sheet.setColumnWidth(9, 60 * 256); + // 待发货 + String[] hearder = {"订单编号", "收件人", "手机", "收货地址", "商品名称", "数量", "发件人姓名", "发件人手机号", "发货地址", "备注"}; + writer.merge(hearder.length - 1, "发货信息整理"); + writer.writeRow(Arrays.asList(hearder)); + + int row = 1; + for (Order dbOrder : orders) { + UserAddrOrder addr = dbOrder.getUserAddrOrder(); + String addrInfo = addr.getProvince() + addr.getCity() + addr.getArea() + addr.getAddr(); + List orderItems = dbOrder.getOrderItems(); + row++; + for (OrderItem orderItem : orderItems) { + // 第0列开始 + int col = 0; + writer.writeCellValue(col++, row, dbOrder.getOrderNumber()); + writer.writeCellValue(col++, row, addr.getReceiver()); + writer.writeCellValue(col++, row, addr.getMobile()); + writer.writeCellValue(col++, row, addrInfo); + writer.writeCellValue(col++, row, orderItem.getProdName()); + writer.writeCellValue(col++, row, orderItem.getProdCount()); + writer.writeCellValue(col++, row, consignmentName); + writer.writeCellValue(col++, row, consignmentMobile); + writer.writeCellValue(col++, row, consignmentAddr); + writer.writeCellValue(col++, row, dbOrder.getRemarks()); + } + } + writeExcel(response, writer); + } + + /** + * 已销售订单 + * + * @param order + */ + @GetMapping("/soldExcel") + public void soldExcel(Order order, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime, + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime, HttpServletResponse response,HttpServletRequest request) { + Integer shopId = TokenUtils.getShopIdByJwtToken(request); + order.setShopId(shopId); + order.setIsPayed(1); + List orders = orderService.listOrdersDetailByOrder(order, startTime, endTime); + + //通过工具类创建writer + ExcelWriter writer = ExcelUtil.getBigWriter(); + // 待发货 + String[] hearder = {"订单编号", "下单时间", "收件人", "手机", "收货地址", "商品名称", "数量", "订单应付", "订单运费", "订单实付"}; + Sheet sheet = writer.getSheet(); + sheet.setColumnWidth(0, 20 * 256); + sheet.setColumnWidth(1, 20 * 256); + sheet.setColumnWidth(3, 20 * 256); + sheet.setColumnWidth(4, 60 * 256); + sheet.setColumnWidth(5, 60 * 256); + + writer.merge(hearder.length - 1, "销售信息整理"); + writer.writeRow(Arrays.asList(hearder)); + + int row = 1; + for (Order dbOrder : orders) { + UserAddrOrder addr = dbOrder.getUserAddrOrder(); + String addrInfo = addr.getProvince() + addr.getCity() + addr.getArea() + addr.getAddr(); + List orderItems = dbOrder.getOrderItems(); + int firstRow = row + 1; + int lastRow = row + orderItems.size(); + int col = -1; + // 订单编号 + mergeIfNeed(writer, firstRow, lastRow, ++col, col, dbOrder.getOrderNumber()); + // 下单时间 + mergeIfNeed(writer, firstRow, lastRow, ++col, col, dbOrder.getCreateTime()); + // 收件人 + mergeIfNeed(writer, firstRow, lastRow, ++col, col, addr.getReceiver()); + // "手机" + mergeIfNeed(writer, firstRow, lastRow, ++col, col, addr.getMobile()); + // "收货地址" + mergeIfNeed(writer, firstRow, lastRow, ++col, col, addrInfo); + int prodNameCol = ++col; + int prodCountCol = ++col; + for (OrderItem orderItem : orderItems) { + row++; + // 商品名称 + writer.writeCellValue(prodNameCol, row, orderItem.getProdName()); + // 数量 + writer.writeCellValue(prodCountCol, row, orderItem.getProdCount()); + } + // 订单应付 + mergeIfNeed(writer, firstRow, lastRow, ++col, col, dbOrder.getTotal()); + // 订单运费 + mergeIfNeed(writer, firstRow, lastRow, ++col, col, dbOrder.getFreightAmount()); + // 订单实付 + mergeIfNeed(writer, firstRow, lastRow, ++col, col, dbOrder.getActualTotal()); + + } + writeExcel(response, writer); + } + + /** + * 如果需要合并的话,就合并 + */ + private void mergeIfNeed(ExcelWriter writer, int firstRow, int lastRow, int firstColumn, int lastColumn, Object content) { + if (content instanceof Date) { + content = DateUtil.format((Date) content, DatePattern.NORM_DATETIME_PATTERN); + } + if (lastRow - firstRow > 0 || lastColumn - firstColumn > 0) { + writer.merge(firstRow, lastRow, firstColumn, lastColumn, content, false); + } else { + writer.writeCellValue(firstColumn, firstRow, content); + } + + } + + private void writeExcel(HttpServletResponse response, ExcelWriter writer) { + //response为HttpServletResponse对象 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 + response.setHeader("Content-Disposition", "attachment;filename=1.xls"); + + ServletOutputStream servletOutputStream = null; + try { + servletOutputStream = response.getOutputStream(); + writer.flush(servletOutputStream); + servletOutputStream.flush(); + } catch (IORuntimeException | IOException e) { + log.error("写出Excel错误:", e); + } finally { + IoUtil.close(writer); + } + } + + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java index 73a4489..ae9b2d6 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/PlatformTeamAccountController.java @@ -188,16 +188,12 @@ public class PlatformTeamAccountController { @PostMapping("/updateAccountStatus") public R updateAccountStatus( @RequestParam("openId") @ApiParam(value = "openId") String openId, - @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->禁用,0->启用)") Integer isEnable) { + @RequestParam("isEnable") @ApiParam(value = "是否禁用(1->启用,0->禁用)") Integer isEnable) { //根据openId查询账号详情List List userAccountList = platformTeamClassificationService.selectAccountList(openId); for (UserAccount userAccount : userAccountList) { - int status = 1; - if (isEnable==1){ - status=0; - } //更新账号信息 - platformTeamClassificationService.updateByAccountId(userAccount.getId(), status); + platformTeamClassificationService.updateByAccountId(userAccount.getId(), isEnable); if (Integer.parseInt(userAccount.getPlatformId())!=7){ //查询账号绑定的组织信息 List platformTeamAccounts = platformTeamAccountService.list(new QueryWrapper().eq("account_id", userAccount.getId())); @@ -206,7 +202,11 @@ public class PlatformTeamAccountController { PlatformTeam platformTeam = platformTeamService.getOne(new QueryWrapper().eq("manage_id", platformTeamAccount.getManageId())); PlatformTeamClassification platformTeamClassification = new PlatformTeamClassification(); platformTeamClassification.setId(platformTeam.getClassificationId()); - platformTeamClassification.setIsEnable(isEnable); + int status = 1; + if (isEnable==1){ + status=0; + } + platformTeamClassification.setIsEnable(status); //更新账号绑定的组织信息 platformTeamClassificationService.updateById(platformTeamClassification); } diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/ShopCartController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/ShopCartController.java new file mode 100644 index 0000000..41e2d14 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/ShopCartController.java @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.controller; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.map.MapUtil; +import com.google.common.collect.Lists; +import com.huoran.common.response.ServerResponseEntity; +import com.huoran.common.utils.SecurityUtils; +import com.huoran.nakadai.entity.app.dto.*; +import com.huoran.nakadai.entity.app.param.ChangeShopCartParam; +import com.huoran.nakadai.entity.app.param.ShopCartParam; +import com.huoran.nakadai.entity.model.Basket; +import com.huoran.nakadai.entity.model.Product; +import com.huoran.nakadai.entity.model.Sku; +import com.huoran.nakadai.event.ShopCartEvent; +import com.huoran.nakadai.service.BasketService; +import com.huoran.nakadai.service.ProductService; +import com.huoran.nakadai.service.SkuService; +import com.huoran.nakadai.utils.Arith; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.context.ApplicationContext; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author lanhai + */ +@RestController +@RequestMapping("/shopCart") +@Api(tags = "购物车管理") +@AllArgsConstructor +public class ShopCartController { + + private final BasketService basketService; + + private final ProductService productService; + + private final SkuService skuService; + + private final ApplicationContext applicationContext; + + /** + * 获取用户购物车信息 + * + * @param basketIdShopCartParamMap 购物车参数对象列表 + * @return + */ + @PostMapping("/info") + @ApiOperation(value = "获取用户购物车信息,参数为用户选中的活动项数组,以购物车id为key") + public ServerResponseEntity> info(@RequestBody Map basketIdShopCartParamMap) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + + // 更新购物车信息, + if (MapUtil.isNotEmpty(basketIdShopCartParamMap)) { + basketService.updateBasketByShopCartParam(userId, basketIdShopCartParamMap); + } + + // 拿到购物车的所有item + List shopCartItems = basketService.getShopCartItems(userId); + return ServerResponseEntity.success(basketService.getShopCarts(shopCartItems)); + + } + + @PostMapping("/deleteItem") + @ApiOperation("通过购物车id删除用户购物车物品") + public ServerResponseEntity deleteItem(@RequestBody List basketIds) { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + basketService.deleteShopCartItemsByBasketIds(userId, basketIds); + return ServerResponseEntity.success(); + } + + @PostMapping("/deleteAll") + @ApiOperation("清空用户购物车所有物品") + public ServerResponseEntity deleteAll() { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + basketService.deleteAllShopCartItems(userId); + return ServerResponseEntity.success("删除成功"); + } + + @PostMapping("/changeItem") + @ApiOperation(value = "添加、修改用户购物车物品,通过商品id(prodId)、skuId、店铺Id(shopId),添加/修改用户购物车商品,并传入改变的商品个数(count)," + + "当count为正值时,增加商品数量,当count为负值时,将减去商品的数量,当最终count值小于0时,会将商品从购物车里面删除") + public ServerResponseEntity addItem(@Valid @RequestBody ChangeShopCartParam param) { + + if (param.getCount() == 0) { + return ServerResponseEntity.showFailMsg("输入更改数量"); + } + + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + List shopCartItems = basketService.getShopCartItems(userId); + Product prodParam = productService.getProductByProdId(param.getProdId()); + Sku skuParam = skuService.getSkuBySkuId(param.getSkuId()); + + // 当商品状态不正常时,不能添加到购物车 + if (prodParam.getStatus() != 1 || skuParam.getStatus() != 1) { + return ServerResponseEntity.showFailMsg("当前商品已下架"); + } + for (ShopCartItemDto shopCartItemDto : shopCartItems) { + if (Objects.equals(param.getSkuId(), shopCartItemDto.getSkuId())) { + Basket basket = new Basket(); + basket.setUserId(userId); + basket.setBasketCount(param.getCount() + shopCartItemDto.getProdCount()); + basket.setBasketId(shopCartItemDto.getBasketId()); + + // 防止购物车变成负数 + if (basket.getBasketCount() <= 0) { + basketService.deleteShopCartItemsByBasketIds(userId, Collections.singletonList(basket.getBasketId())); + return ServerResponseEntity.success(); + } + + // 当sku实际库存不足时,不能添加到购物车 + if (skuParam.getStocks() < basket.getBasketCount() && shopCartItemDto.getProdCount() > 0) { + return ServerResponseEntity.showFailMsg("库存不足"); + } + basketService.updateShopCartItem(basket); + return ServerResponseEntity.success(); + } + } + + // 防止购物车已被删除的情况下,添加了负数的商品 + if (param.getCount() < 0) { + return ServerResponseEntity.showFailMsg("商品已从购物车移除"); + } + // 当sku实际库存不足时,不能添加到购物车 + if (skuParam.getStocks() < param.getCount()) { + return ServerResponseEntity.showFailMsg("库存不足"); + } + // 所有都正常时 + basketService.addShopCartItem(param,userId); + return ServerResponseEntity.success("添加成功"); + } + + @GetMapping("/prodCount") + @ApiOperation(value = "获取所有购物车商品数量") + public ServerResponseEntity prodCount() { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + List shopCartItems = basketService.getShopCartItems(userId); + if (CollectionUtil.isEmpty(shopCartItems)) { + return ServerResponseEntity.success(0); + } + Integer totalCount = shopCartItems.stream().map(ShopCartItemDto::getProdCount).reduce(0, Integer::sum); + return ServerResponseEntity.success(totalCount); + } + + @GetMapping("/expiryProdList") + @ApiOperation(value = "获取购物车失效商品列表") + public ServerResponseEntity> expiryProdList() { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + List shopCartItems = basketService.getShopCartExpiryItems(userId); + //根据店铺ID划分item + Map> shopCartItemDtoMap = shopCartItems.stream().collect(Collectors.groupingBy(ShopCartItemDto::getShopId)); + + // 返回一个店铺对应的所有信息 + List shopcartExpiryitems = Lists.newArrayList(); + + for (Integer key : shopCartItemDtoMap.keySet()) { + ShopCartExpiryItemDto shopCartExpiryItemDto = new ShopCartExpiryItemDto(); + shopCartExpiryItemDto.setShopId(key); + List shopCartItemDtos = Lists.newArrayList(); + for (ShopCartItemDto tempShopCartItemDto : shopCartItemDtoMap.get(key)) { + shopCartExpiryItemDto.setShopName(tempShopCartItemDto.getShopName()); + shopCartItemDtos.add(tempShopCartItemDto); + } + shopCartExpiryItemDto.setShopCartItemDtoList(shopCartItemDtos); + shopcartExpiryitems.add(shopCartExpiryItemDto); + } + + return ServerResponseEntity.success(shopcartExpiryitems); + } + + @PostMapping("/cleanExpiryProdList") + @ApiOperation(value = "清空用户失效商品") + public ServerResponseEntity cleanExpiryProdList() { + String userId = SecurityUtils.getCurrentInfo().getAccountId(); + basketService.cleanExpiryProdList(userId); + return ServerResponseEntity.success(); + } + + @PostMapping("/totalPay") + @ApiOperation(value = "获取选中购物项总计、选中的商品数量,参数为购物车id数组") + public ServerResponseEntity getTotalPay(@RequestBody List basketIds) { + + // 拿到购物车的所有item + List dbShopCartItems = basketService.getShopCartItems(SecurityUtils.getCurrentInfo().getAccountId()); + + List chooseShopCartItems = dbShopCartItems + .stream() + .filter(shopCartItemDto -> { + for (Long basketId : basketIds) { + if (Objects.equals(basketId,shopCartItemDto.getBasketId())) { + return true; + } + } + return false; + }) + .collect(Collectors.toList()); + + // 根据店铺ID划分item + Map> shopCartMap = chooseShopCartItems.stream().collect(Collectors.groupingBy(ShopCartItemDto::getShopId)); + + double total = 0.0; + int count = 0; + double reduce = 0.0; + for (Integer shopId : shopCartMap.keySet()) { + //获取店铺的所有商品项 + List shopCartItemDtoList = shopCartMap.get(shopId); + // 构建每个店铺的购物车信息 + ShopCartDto shopCart = new ShopCartDto(); + shopCart.setShopId(shopId); + + applicationContext.publishEvent(new ShopCartEvent(shopCart, shopCartItemDtoList)); + + List shopCartItemDiscounts = shopCart.getShopCartItemDiscounts(); + + for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) { + List shopCartItems = shopCartItemDiscount.getShopCartItems(); + + for (ShopCartItemDto shopCartItem : shopCartItems) { + count = shopCartItem.getProdCount() + count; + total = Arith.add(shopCartItem.getProductTotalAmount(), total); + } + } + } + ShopCartAmountDto shopCartAmountDto = new ShopCartAmountDto(); + shopCartAmountDto.setCount(count); + shopCartAmountDto.setTotalMoney(total); + shopCartAmountDto.setSubtractMoney(reduce); + shopCartAmountDto.setFinalMoney(Arith.sub(shopCartAmountDto.getTotalMoney(), shopCartAmountDto.getSubtractMoney())); + + return ServerResponseEntity.success(shopCartAmountDto); + } + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/SkuController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/SkuController.java new file mode 100644 index 0000000..bc76425 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/SkuController.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved. + * + * https://www.mall4j.com/ + * + * 未经允许,不可做商业用途! + * + * 版权所有,侵权必究! + */ + +package com.huoran.nakadai.controller; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.huoran.common.response.ServerResponseEntity; +import com.huoran.nakadai.entity.app.dto.SkuDto; +import com.huoran.nakadai.entity.model.Sku; +import com.huoran.nakadai.service.SkuService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author lanhai + */ +@RestController +@RequestMapping("/sku") +@Api(tags = "sku规格管理") +@AllArgsConstructor +public class SkuController { + + private final SkuService skuService; + + + @GetMapping("/getSkuList") + @ApiOperation(value = "通过prodId获取商品全部规格列表") + public ServerResponseEntity> getSkuListByProdId(Integer prodId) { + List skus = skuService.list(new LambdaQueryWrapper() + .eq(Sku::getStatus, 1) + .eq(Sku::getIsDelete, 0) + .eq(Sku::getProdId, prodId) + ); + List skuDtoList = BeanUtil.copyToList(skus, SkuDto.class); + return ServerResponseEntity.success(skuDtoList); + } +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/MyOrderDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/MyOrderDto.java index 5f9e919..eccdc69 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/MyOrderDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/MyOrderDto.java @@ -22,16 +22,16 @@ import java.util.List; @Data public class MyOrderDto { - @ApiModelProperty(value = "订单项" ,required=true) + @ApiModelProperty(value = "订单项" ) private List orderItemDtos; - @ApiModelProperty(value = "订单号" ,required=true) + @ApiModelProperty(value = "订单号" ) private String orderNumber; - @ApiModelProperty(value = "总价" ,required=true) + @ApiModelProperty(value = "总价" ) private Double actualTotal; - @ApiModelProperty(value = "订单状态" ,required=true) + @ApiModelProperty(value = "订单状态" ) private Integer status; } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/OrderShopDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/OrderShopDto.java index df2d950..8a350f1 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/OrderShopDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/OrderShopDto.java @@ -31,7 +31,7 @@ public class OrderShopDto implements Serializable { * 店铺ID **/ @ApiModelProperty(value = "店铺id" , required = true) - private Long shopId; + private Integer shopId; /** * 店铺名称 diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartExpiryItemDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartExpiryItemDto.java index c9f6ede..dd6e966 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartExpiryItemDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartExpiryItemDto.java @@ -22,7 +22,7 @@ import java.util.List; @Data public class ShopCartExpiryItemDto { @ApiModelProperty(value = "店铺ID" , required = true) - private Long shopId; + private Integer shopId; @ApiModelProperty(value = "店铺名称" , required = true) private String shopName; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderDto.java index 12aafd8..190c0bc 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderDto.java @@ -32,6 +32,9 @@ public class ShopCartOrderDto implements Serializable{ @ApiModelProperty(value = "实际总值" , required = true) private Double actualTotal; + @ApiModelProperty(value = "订单类型:1为个人、2为组织") + private Integer orderType; + @ApiModelProperty(value = "商品总值" , required = true) private Double total; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java index e6776bb..e7f049d 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/dto/ShopCartOrderMergerDto.java @@ -36,6 +36,9 @@ public class ShopCartOrderMergerDto implements Serializable{ @ApiModelProperty(value = "订单优惠金额(所有店铺优惠金额相加)" , required = true) private Double orderReduce; + @ApiModelProperty(value = "订单类型:1为个人、2为组织") + private Integer orderType; + // @ApiModelProperty(value = "地址Dto" , required = true) // private UserAddrDto userAddr; // diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/ChangeShopCartParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/ChangeShopCartParam.java index 73a44b8..23be106 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/ChangeShopCartParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/ChangeShopCartParam.java @@ -34,7 +34,7 @@ public class ChangeShopCartParam { @NotNull(message = "店铺ID不能为空") @ApiModelProperty(value = "店铺ID" , required = true) - private Long shopId; + private Integer shopId; @NotNull(message = "商品个数不能为空") @ApiModelProperty(value = "商品个数" , required = true) diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java index 3e62228..4de7170 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderParam.java @@ -24,8 +24,8 @@ import java.util.List; public class OrderParam { -// @ApiModelProperty(value = "购物车id 数组" ) -// private List basketIds; + @ApiModelProperty(value = "购物车id 数组" ) + private List basketIds; @ApiModelProperty(value = "立即购买时提交的商品项" ) private OrderItemParam orderItem; diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderShopParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderShopParam.java index 0af30c8..a89bcde 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderShopParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/OrderShopParam.java @@ -12,36 +12,22 @@ package com.huoran.nakadai.entity.app.param; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; /** * @author lanhai */ +@Data public class OrderShopParam { /** 店铺ID **/ @ApiModelProperty(value = "店铺id" ,required=true) - private Long shopId; + private Integer shopId; /** * 订单备注信息 */ @ApiModelProperty(value = "订单备注信息" ,required=true) private String remarks; - - public Long getShopId() { - return shopId; - } - - public void setShopId(Long shopId) { - this.shopId = shopId; - } - - public String getRemarks() { - return remarks; - } - - public void setRemarks(String remarks) { - this.remarks = remarks; - } } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/SubmitOrderParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/SubmitOrderParam.java index 66329d8..a9b41d5 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/SubmitOrderParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/app/param/SubmitOrderParam.java @@ -23,4 +23,12 @@ import java.util.List; public class SubmitOrderParam { @ApiModelProperty(value = "每个店铺提交的订单信息" ,required=true) private List orderShopParam; + + @ApiModelProperty(value = "订单类型:1为个人、2为组织" ,required=true) + private Integer orderType; + + @ApiModelProperty(value = "是否为留言订单" ,required=true) + private boolean leaveAMessage; + + } diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/model/Basket.java b/nakadai/src/main/java/com/huoran/nakadai/entity/model/Basket.java index b0d2323..1e48299 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/model/Basket.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/model/Basket.java @@ -27,14 +27,13 @@ public class Basket implements Serializable { * 主键 */ @TableId - - private Long basketId; + private Integer basketId; /** * 店铺ID */ - private Long shopId; + private Integer shopId; /** * 产品ID diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/model/Order.java b/nakadai/src/main/java/com/huoran/nakadai/entity/model/Order.java index 59ba124..cbd262f 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/model/Order.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/model/Order.java @@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -64,6 +65,10 @@ public class Order implements Serializable { */ private Double actualTotal; + + @ApiModelProperty(value = "订单类型:1为个人、2为组织") + private Integer orderType; + /** * 支付方式 1 微信支付 2 支付宝 */ diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/param/ProductParam.java b/nakadai/src/main/java/com/huoran/nakadai/entity/param/ProductParam.java index c2812f9..c895395 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/param/ProductParam.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/param/ProductParam.java @@ -51,21 +51,21 @@ public class ProductParam { /** * 商品价格 */ - @NotNull(message = "请输入商品价格") +// @NotNull(message = "请输入商品价格") @ApiModelProperty(value = "商品价格") private Double price; /** * 商品价格 */ - @NotNull(message = "请输入商品原价") +// @NotNull(message = "请输入商品原价") @ApiModelProperty(value = "商品原价") private Double oriPrice; /** * 库存量 */ - @NotNull(message = "请输入商品库存") +// @NotNull(message = "请输入商品库存") @ApiModelProperty(value = "商品库存") private Integer totalStocks; @@ -84,7 +84,7 @@ public class ProductParam { * 商品图片 */ // @NotBlank(message = "请选择图片上传") - @ApiModelProperty(value = "商品图片",hidden = true) + @ApiModelProperty(value = "商品图片") private String imgs; /** diff --git a/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java b/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java index 6cb65c3..34ce080 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java +++ b/nakadai/src/main/java/com/huoran/nakadai/listener/SubmitOrderListener.java @@ -202,6 +202,7 @@ public class SubmitOrderListener { order.setActualTotal(shopCartOrderDto.getActualTotal()); order.setStatus(OrderStatus.UNPAY.value()); order.setUpdateTime(now); + order.setOrderType(shopCartOrderDto.getOrderType()); order.setCreateTime(now); order.setIsPayed(0); order.setDeleteStatus(0); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/OrderItemMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/OrderItemMapper.java index f5460b2..67ddb9a 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/OrderItemMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/OrderItemMapper.java @@ -12,6 +12,7 @@ package com.huoran.nakadai.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.huoran.nakadai.entity.model.OrderItem; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -19,6 +20,7 @@ import java.util.List; /** * @author lanhai */ +@Mapper public interface OrderItemMapper extends BaseMapper { /** @@ -30,8 +32,8 @@ public interface OrderItemMapper extends BaseMapper { /** * 插入订单项 - * @param orderItems + * @param orderItem */ - void insertBatch(List orderItems); + void insertBatch(List orderItem); } \ No newline at end of file diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml index 756939e..0dfa987 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/PlatformTeamAccountMapper.xml @@ -173,7 +173,7 @@ INNER JOIN k_platform_team_classification tc on t.classification_id = tc.id WHERE a.app_open_id = #{openId} - AND a.platform_id = #{platformId} and tc.is_team = 1 and ta.is_del = 0 + AND a.platform_id = #{platformId} and tc.is_team = 1 and ta.is_del = 0 and a.is_del = 0