From 9745739b71a6f1f4b8baa5a6f703747d2814c332 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Mon, 28 Jun 2021 17:19:33 +0800 Subject: [PATCH] Merge branch 'score-shop' of http://120.27.238.55:7000/r/xzx into score-shop --- gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderItemsMapper.java | 7 ++ gc-core/src/main/java/com/xzx/gc/entity/JhyOrder.java | 3 + gc-core/src/main/java/com/xzx/gc/common/utils/IdUtils.java | 2 gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java | 9 +++ gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml | 5 + gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java | 32 ++++++++++ gc-order/src/main/resources/mapper/order/JhyOrderItemsMapper.xml | 5 + gc-core/src/main/java/com/xzx/gc/entity/JhyOrderItems.java | 2 gc-order/src/main/java/com/xzx/gc/order/dto/AddJhyOrderDto.java | 33 +++++++++++ gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java | 77 +++++++++++++++++++++++++ 10 files changed, 174 insertions(+), 1 deletions(-) diff --git a/gc-core/src/main/java/com/xzx/gc/common/utils/IdUtils.java b/gc-core/src/main/java/com/xzx/gc/common/utils/IdUtils.java index 0033ed8..476dd03 100644 --- a/gc-core/src/main/java/com/xzx/gc/common/utils/IdUtils.java +++ b/gc-core/src/main/java/com/xzx/gc/common/utils/IdUtils.java @@ -15,7 +15,7 @@ /** * 生成分布式唯一全局ID * @param prefix ID前缀 如支付:ZF - * @param datacenterId 数据中心ID(0~31) 0:支付 1 订单 2入库 3 用户 4账户 5特殊用户 6废品站 7结算 8请假 9积分商城 + * @param datacenterId 数据中心ID(0~31) 0:支付 1 订单 2入库 3 用户 4账户 5特殊用户 6废品站 7结算 8请假 9积分商城 10集物员 * @return */ public String generate(String prefix,long datacenterId){ diff --git a/gc-core/src/main/java/com/xzx/gc/entity/JhyOrder.java b/gc-core/src/main/java/com/xzx/gc/entity/JhyOrder.java index c0fc58f..9443cd9 100644 --- a/gc-core/src/main/java/com/xzx/gc/entity/JhyOrder.java +++ b/gc-core/src/main/java/com/xzx/gc/entity/JhyOrder.java @@ -15,6 +15,8 @@ private String orderNo; + private String username; + private String phone; private String area; @@ -37,6 +39,7 @@ * 订单状态 状态 1-待接单2-服务中3-已收款4-待入库5-已完成6-已取消 */ private Integer status; + public static final Integer ORDER_STATUS_WAITING = 1; /** * 评论 diff --git a/gc-core/src/main/java/com/xzx/gc/entity/JhyOrderItems.java b/gc-core/src/main/java/com/xzx/gc/entity/JhyOrderItems.java index f7a0a6f..7c69c47 100644 --- a/gc-core/src/main/java/com/xzx/gc/entity/JhyOrderItems.java +++ b/gc-core/src/main/java/com/xzx/gc/entity/JhyOrderItems.java @@ -23,4 +23,6 @@ private BigDecimal weight; private String score; + + private Long itemType; } diff --git a/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java b/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java new file mode 100644 index 0000000..fc7fde0 --- /dev/null +++ b/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java @@ -0,0 +1,32 @@ +package com.xzx.gc.order.controller; + +import com.xzx.gc.common.Result; +import com.xzx.gc.common.request.BaseController; +import com.xzx.gc.order.dto.AddJhyOrderDto; +import com.xzx.gc.order.service.JhyOrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +@Slf4j +@RestController +@Api(tags = {"集物员-api集物员订单"}) +public class ApiJhyOrderController extends BaseController { + + @Autowired + private JhyOrderService jhyOrderService; + + @ApiOperation("下单") + @PostMapping(value = "/jhy/order/add") + public Result<String> addJhyOrder(@RequestBody AddJhyOrderDto addJhyOrderDto, HttpServletRequest request) { + addJhyOrderDto.setUserId(getUserId(request)); + jhyOrderService.addJhyOrder(addJhyOrderDto); + return Result.success(); + } +} diff --git a/gc-order/src/main/java/com/xzx/gc/order/dto/AddJhyOrderDto.java b/gc-order/src/main/java/com/xzx/gc/order/dto/AddJhyOrderDto.java new file mode 100644 index 0000000..5bff938 --- /dev/null +++ b/gc-order/src/main/java/com/xzx/gc/order/dto/AddJhyOrderDto.java @@ -0,0 +1,33 @@ +package com.xzx.gc.order.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +@ApiModel(value = "AddJhyOrderDto", description = "小程序下单参数接收类") +public class AddJhyOrderDto { + + @ApiModelProperty(value = "地址ID") + private Long addressId; + + @ApiModelProperty(value = "预约日期") + private Date reserveDate; + + @ApiModelProperty(value = "时间") + private String reserveTime; + + @ApiModelProperty(value = "重量") + private String weight; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "类型Ids") + private String typeIds; + + @ApiModelProperty(hidden = true) + private String userId; +} diff --git a/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderItemsMapper.java b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderItemsMapper.java new file mode 100644 index 0000000..765f687 --- /dev/null +++ b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderItemsMapper.java @@ -0,0 +1,7 @@ +package com.xzx.gc.order.mapper; + +import com.xzx.gc.entity.JhyOrderItems; +import com.xzx.gc.util.GcMapper; + +public interface JhyOrderItemsMapper extends GcMapper<JhyOrderItems> { +} diff --git a/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java new file mode 100644 index 0000000..6ac4580 --- /dev/null +++ b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java @@ -0,0 +1,9 @@ +package com.xzx.gc.order.mapper; + +import com.xzx.gc.entity.JhyOrder; +import com.xzx.gc.util.GcMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface JhyOrderMapper extends GcMapper<JhyOrder> { +} diff --git a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java new file mode 100644 index 0000000..f686b31 --- /dev/null +++ b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java @@ -0,0 +1,77 @@ +package com.xzx.gc.order.service; + +import cn.hutool.core.util.StrUtil; +import com.xzx.gc.common.utils.IdUtils; +import com.xzx.gc.entity.AddressInfo; +import com.xzx.gc.entity.JhyOrder; +import com.xzx.gc.entity.JhyOrderItems; +import com.xzx.gc.entity.SysEnvironmentalInfo; +import com.xzx.gc.order.dto.AddJhyOrderDto; +import com.xzx.gc.order.mapper.AddressMapper; +import com.xzx.gc.order.mapper.JhyOrderItemsMapper; +import com.xzx.gc.order.mapper.JhyOrderMapper; +import com.xzx.gc.order.mapper.SysEnvironmentalInfoMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Slf4j +@Service +@Transactional +public class JhyOrderService { + + @Autowired + private JhyOrderMapper jhyOrderMapper; + + @Autowired + private AddressMapper addressMapper; + + @Autowired + private SysEnvironmentalInfoMapper environmentalInfoMapper; + + @Autowired + private JhyOrderItemsMapper jhyOrderItemsMapper; + + @Autowired + private IdUtils idUtils; + + public void addJhyOrder(AddJhyOrderDto orderDto) { + String orderNo = idUtils.generate("JW", 10); + + JhyOrder jhyOrder = new JhyOrder(); + AddressInfo addressInfo = addressMapper.selectByPrimaryKey(orderDto.getAddressId()); + + jhyOrder.setOrderNo(orderNo); + jhyOrder.setArea(addressInfo.getAddressArea()); + jhyOrder.setAddress(addressInfo.getAddress()); + jhyOrder.setUsername(addressInfo.getRelaName()); + jhyOrder.setPhone(addressInfo.getMobilePhone()); + jhyOrder.setLongitude(addressInfo.getLongitude()); + jhyOrder.setLatitude(addressInfo.getLatitude()); + jhyOrder.setReserveDate(orderDto.getReserveDate()); + jhyOrder.setReserveTime(orderDto.getReserveTime()); + jhyOrder.setWeight(orderDto.getWeight()); + jhyOrder.setStatus(JhyOrder.ORDER_STATUS_WAITING); + jhyOrder.setCreatedTime(new Date()); + jhyOrderMapper.insert(jhyOrder); + + long[] typeIds = StrUtil.splitToLong(orderDto.getTypeIds(), ","); + for (long typeId : typeIds) { + SysEnvironmentalInfo environmentalInfo = environmentalInfoMapper.selectByPrimaryKey(typeId); + + JhyOrderItems item = new JhyOrderItems(); + item.setOrderId(jhyOrder.getId()); + item.setPicture(environmentalInfo.getPicture()); + item.setItemType(typeId); + item.setTitle(environmentalInfo.getTitle()); + item.setPrice(new BigDecimal(environmentalInfo.getPrice())); + jhyOrderItemsMapper.insert(item); + } + } +} diff --git a/gc-order/src/main/resources/mapper/order/JhyOrderItemsMapper.xml b/gc-order/src/main/resources/mapper/order/JhyOrderItemsMapper.xml new file mode 100644 index 0000000..6406d64 --- /dev/null +++ b/gc-order/src/main/resources/mapper/order/JhyOrderItemsMapper.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.xzx.gc.order.mapper.JhyOrderItemsMapper"> + +</mapper> \ No newline at end of file diff --git a/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml b/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml new file mode 100644 index 0000000..423755c --- /dev/null +++ b/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.xzx.gc.order.mapper.JhyOrderMapper"> + +</mapper> \ No newline at end of file -- Gitblit v1.9.1