Parcourir la source

拍卖app订单列表查询

lilinhui il y a 3 semaines
Parent
commit
e29cb12d34

+ 27 - 0
poyee-order/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.tzy</groupId>
+        <artifactId>tzy</artifactId>
+        <version>4.5.0</version>
+    </parent>
+
+    <artifactId>poyee-order</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.tzy</groupId>
+            <artifactId>poyi-service</artifactId>
+            <version>4.5.0</version>
+        </dependency>
+    </dependencies>
+</project>

+ 53 - 0
poyee-order/src/main/java/com/tzy/controller/LotOrderController.java

@@ -0,0 +1,53 @@
+package com.tzy.controller;
+
+import com.tzy.common.dto.OutDTO;
+import com.tzy.entity.LotOrder;
+import com.tzy.service.LotOrderService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/lot/order")
+public class LotOrderController {
+    @Autowired
+    private LotOrderService lotOrderService;
+
+    @PostMapping("create")
+    @ResponseBody
+    public OutDTO createLotOrder(@RequestBody LotOrder lotOrder) {
+        int inserted = lotOrderService.createLotOrder(lotOrder);
+        if (inserted > 0) {
+            // 订单创建成功
+            return OutDTO.ok();
+        }
+
+        return OutDTO.error500("创建订单失败");
+    }
+    //app拍品订单列表查询
+    @PostMapping("/list")
+    @ResponseBody
+    public OutDTO queryLotList(@RequestBody LotOrder lotOrder) {
+        List<LotOrder> lotOrders = lotOrderService.getLotOrders(lotOrder);
+        return OutDTO.ok().put("lotOrders", lotOrders);
+    }
+
+    //app订单详情查询
+    @PostMapping("/query")
+    @ResponseBody
+    public OutDTO queryLotOrderById(@RequestBody LotOrder lotOrder) {
+        lotOrder = lotOrderService.getLotOrderById(lotOrder.getId());
+        return OutDTO.ok().put("lotOrder", lotOrder);
+    }
+
+    //修改订单收货地址
+    @PostMapping("/editOrderAddress")
+    public OutDTO editOrderShippingAddress(@RequestBody LotOrder lotOrder) {
+        int i = lotOrderService.updateLotOrderAddress(lotOrder);
+        if (i > 0) {
+            return OutDTO.ok();
+        }
+        return OutDTO.error500("修改收货地址失败");
+    }
+}

+ 47 - 0
poyee-order/src/main/java/com/tzy/entity/LotOrder.java

@@ -0,0 +1,47 @@
+package com.tzy.entity;
+
+import lombok.Data;
+import org.apache.ibatis.type.Alias;
+
+import java.util.Date;
+
+/**
+ * 拍品订单
+ */
+@Data
+@Alias("lotOrder")
+public class LotOrder {
+
+    private Long id;
+    private String orderNo;
+    private Long auctionId;
+    //拍卖会名称
+    private String auctionName;
+    //拍品名称
+    private String lotName;
+    //拍品id
+    private Long lotId;
+    private Long spuId;
+    //用户id
+    private Long userId;
+    //订单状态
+    private Integer status;
+    //订单金额(单位:分)
+    private Long paymentAmount;
+
+    private Long shippingAddressId;
+    private String shippingAddressLinkname;
+    private String shippingAddressPhone;
+    private String shippingAddress;
+
+    private Long expressId;
+    private Long merchantId;
+    private Date createTime;
+    //支付时间
+    private Date payTime;
+    //订单过期时间
+    private Date expireTime;
+    //支付类型
+    private String payType;
+
+}

+ 34 - 0
poyee-order/src/main/java/com/tzy/entity/Spu.java

@@ -0,0 +1,34 @@
+package com.tzy.entity;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@ApiModel("商品信息")
+public class Spu {
+    private Long id;
+    @ApiModelProperty("商品分类")
+    private String category;
+    @ApiModelProperty("商品子分类")
+    private String subCategory;
+    @ApiModelProperty("商品名称")
+    private String spuName;
+    @ApiModelProperty("商品数量")
+    private Long num;
+    @ApiModelProperty("主图")
+    private String mainImage;
+    @ApiModelProperty("轮播图")
+    private String carouselImage;
+    @ApiModelProperty("商品状态:0未审核,1已上架,2已下架")
+    private Integer status;
+    @ApiModelProperty("商品属性:json格式保存")
+    private JsonNode properties;
+    private Date createTime;
+    private Date updateTime;
+    private String createBy;
+    private String updateBy;
+}

+ 14 - 0
poyee-order/src/main/java/com/tzy/mapper/LotOrderMapper.java

@@ -0,0 +1,14 @@
+package com.tzy.mapper;
+
+import com.tzy.entity.LotOrder;
+
+import java.util.List;
+
+public interface LotOrderMapper {
+
+    int insertLotOrder(LotOrder lotOrder);
+    int updateLotOrderAddress(LotOrder lotOrder);
+    int countLotOrderByLotId(LotOrder lotOrder);
+    LotOrder selectLotOrderById(Long id);
+    List<LotOrder> selectLotOrder(LotOrder lotOrder);
+}

+ 8 - 0
poyee-order/src/main/java/com/tzy/mapper/SpuMapper.java

@@ -0,0 +1,8 @@
+package com.tzy.mapper;
+
+import com.tzy.entity.Spu;
+
+public interface SpuMapper {
+
+    Spu getSpuById(Long id);
+}

+ 63 - 0
poyee-order/src/main/java/com/tzy/mapper/handler/JsonNodeTypeHandler.java

@@ -0,0 +1,63 @@
+package com.tzy.mapper.handler;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@MappedTypes(JsonNode.class)
+public class JsonNodeTypeHandler extends BaseTypeHandler<JsonNode> {
+
+    private static final ObjectMapper objectMapper = new ObjectMapper();
+
+    @Override
+    public void setNonNullParameter(PreparedStatement ps, int i, JsonNode parameter, JdbcType jdbcType)
+            throws SQLException {
+        ps.setString(i, parameter.toString());
+    }
+
+    @Override
+    public JsonNode getNullableResult(ResultSet rs, String columnName) throws SQLException {
+        String json = rs.getString(columnName);
+        if (json != null) {
+            try {
+                return objectMapper.readTree(json);
+            } catch (Exception e) {
+                throw new SQLException("Error parsing JSON", e);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public JsonNode getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+        String json = rs.getString(columnIndex);
+        if (json != null) {
+            try {
+                return objectMapper.readTree(json);
+            } catch (Exception e) {
+                throw new SQLException("Error parsing JSON", e);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public JsonNode getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+        String json = cs.getString(columnIndex);
+        if (json != null) {
+            try {
+                return objectMapper.readTree(json);
+            } catch (Exception e) {
+                throw new SQLException("Error parsing JSON", e);
+            }
+        }
+        return null;
+    }
+}

+ 13 - 0
poyee-order/src/main/java/com/tzy/service/LotOrderService.java

@@ -0,0 +1,13 @@
+package com.tzy.service;
+
+import com.tzy.entity.LotOrder;
+
+import java.util.List;
+
+public interface LotOrderService {
+
+    int createLotOrder(LotOrder lotOrder);
+    List<LotOrder> getLotOrders(LotOrder lotOrder);
+    LotOrder getLotOrderById(Long id);
+    int updateLotOrderAddress(LotOrder lotOrder);
+}

+ 7 - 0
poyee-order/src/main/java/com/tzy/service/SpuService.java

@@ -0,0 +1,7 @@
+package com.tzy.service;
+
+import com.tzy.entity.Spu;
+
+public interface SpuService {
+    Spu getSpuById(Long id);
+}

+ 71 - 0
poyee-order/src/main/java/com/tzy/service/impl/LotOrderServiceImpl.java

@@ -0,0 +1,71 @@
+package com.tzy.service.impl;
+
+import com.tzy.common.exception.ServiceException;
+import com.tzy.common.utils.DateUtils;
+import com.tzy.entity.LotOrder;
+import com.tzy.entity.Spu;
+import com.tzy.mapper.LotOrderMapper;
+import com.tzy.service.LotOrderService;
+import com.tzy.service.SpuService;
+import com.tzy.sportcard.api.domain.ShippingAddressDto;
+import com.tzy.sportcard.api.service.MineApiService;
+import com.tzy.system.domain.TzyShippingAddress;
+import com.tzy.system.service.ITzyShippingAddressService;
+import com.tzy.util.RandomUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class LotOrderServiceImpl implements LotOrderService {
+    @Resource
+    private LotOrderMapper lotOrderMapper;
+    @Resource
+    MineApiService mineApiService;
+    @Resource
+    private SpuService spuService;
+    @Resource
+    ITzyShippingAddressService shippingAddressService;
+    @Override
+    public List<LotOrder> getLotOrders(LotOrder lotOrder) {
+        return lotOrderMapper.selectLotOrder(lotOrder);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int createLotOrder(LotOrder lotOrder) {
+        //判断该拍品订单是否已存在
+        int countedLotOrderByLotId = lotOrderMapper.countLotOrderByLotId(lotOrder);
+        if (countedLotOrderByLotId > 0) {
+            throw new ServiceException(500, "auctionId:"+ lotOrder.getLotId() + "订单已存在");
+        }
+        //检查商品是否存在,
+        Spu spu = spuService.getSpuById(lotOrder.getSpuId());
+        if (spu == null) {
+            throw new ServiceException(500, "商品不存在,请联系管理员!");
+        }
+
+        lotOrder.setCreateTime(DateUtils.getNowDate());
+        lotOrder.setStatus(100);//待支付
+        lotOrder.setOrderNo(RandomUtil.getRandom(RandomUtil.MALL_USER_ORDER));
+        return lotOrderMapper.insertLotOrder(lotOrder);
+    }
+
+    @Override
+    public LotOrder getLotOrderById(Long id) {
+        return lotOrderMapper.selectLotOrderById(id);
+    }
+
+    @Override
+    public int updateLotOrderAddress(LotOrder lotOrder) {
+        TzyShippingAddress tzyShippingAddress = shippingAddressService.selectUserAddress(Math.toIntExact(lotOrder.getUserId()), Math.toIntExact(lotOrder.getShippingAddressId()));
+        lotOrder.setShippingAddressId(tzyShippingAddress.getId());
+        lotOrder.setShippingAddressLinkname(tzyShippingAddress.getLinkname());
+        lotOrder.setShippingAddressPhone(tzyShippingAddress.getPhone());
+        lotOrder.setShippingAddress(tzyShippingAddress.getAddress() + tzyShippingAddress.getAddressMore());
+
+        return lotOrderMapper.updateLotOrderAddress(lotOrder);
+    }
+}

+ 21 - 0
poyee-order/src/main/java/com/tzy/service/impl/SpuServiceImpl.java

@@ -0,0 +1,21 @@
+package com.tzy.service.impl;
+
+import com.tzy.entity.Spu;
+import com.tzy.mapper.SpuMapper;
+import com.tzy.service.SpuService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SpuServiceImpl implements SpuService {
+    private SpuMapper spuMapper;
+    @Autowired
+    public SpuServiceImpl(SpuMapper spuMapper) {
+        this.spuMapper = spuMapper;
+    }
+
+    @Override
+    public Spu getSpuById(Long id) {
+        return spuMapper.getSpuById(id);
+    }
+}

+ 53 - 0
poyee-order/src/main/resources/mapper/LotOrderMapper.xml

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzy.mapper.LotOrderMapper">
+    <resultMap id="lotOrderResultMap" type="lotOrder">
+        <id column="id" property="id"/>
+        <result column="order_no" property="orderNo"/>
+        <result column="auction_name" property="auctionName"/>
+        <result column="lot_name" property="lotName"/>
+        <result column="user_id" property="lotId"/>
+        <result column="status" property="status"/>
+        <result column="payment_amount" property="paymentAmount"/>
+        <result  column="merchant_id" property="merchantId"/>
+        <result column="shipping_address_id" property="shippingAddressId"/>
+        <result column="express_id" property="expressId"/>
+        <result column="lot_id" property="lotId"/>
+        <result column="auction_id" property="auctionId"/>
+        <result column="create_time" property="createTime"/>
+        <result column="pay_time" property="payTime"/>
+    </resultMap>
+    <select id="selectLotOrder" resultMap="lotOrderResultMap" parameterType="lotOrder">
+        select id,order_no,auction_name,lot_name,user_id,status,payment_amount,merchant_id,shipping_address_id,express_id,lot_id,auction_id,create_time,pay_time from lot_order_info
+        <where>
+
+            <if test="orderNo!=null and orderNo!=''">
+                and order_no=#{orderNo}
+            </if>
+            <if test="status!=null">
+                and status=#{status}
+            </if>
+            <if test="userId!=null">
+                and user_id=#{userId}
+            </if>
+        </where>
+        order by create_time desc
+    </select>
+    <select id="selectLotOrderById" resultType="lotOrder">
+        select id,order_no,auction_name,lot_name,user_id,status,payment_amount,merchant_id,shipping_address_id,express_id,lot_id,auction_id,create_time,pay_time from lot_order_info
+        where id=#{id}
+    </select>
+    <select id="countLotOrderByLotId" parameterType="lotOrder" resultType="int">
+        select count(*) from lot_order_info where lot_id=#{lotId}
+    </select>
+    <insert id="insertLotOrder">
+        insert into lot_order_info (order_no,auction_name,lot_name,user_id,status,payment_amount,merchant_id,shipping_address_id,express_id,lot_id,auction_id,create_time,pay_time)
+        values (#{orderNo},#{auctionName},#{lotName},#{userId},#{status},#{paymentAmount},#{merchantId},#{shippingAddressId},#{expressId},#{lotId},#{auctionId},#{createTime},#{payTime})
+    </insert>
+    <update id="updateLotOrderAddress" parameterType="lotOrder">
+        update lot_order_info set shipping_address_id=#{shippingAddressId},shipping_address=#{shippingAddress},shipping_address_likename=#{shippingAddressLinkname},shipping_address_phone=#{shippingAddressPhone}
+        where id=#{id}
+    </update>
+</mapper>

+ 24 - 0
poyee-order/src/main/resources/mapper/SpuMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzy.mapper.SpuMapper">
+    <resultMap id="spuMap" type="com.tzy.entity.Spu">
+        <id column="id" property="id"/>
+        <result column="category" property="category"/>
+        <result column="sub_category" property="subCategory"/>
+        <result column="spu_name" property="spuName"/>
+        <result column="num" property="num"/>
+        <result column="main_image" property="mainImage" />
+        <result column="carousel_image" property="carouselImage"/>
+        <result column="status" property="status" />
+        <result column="create_time" property="createTime"/>
+        <result column="create_by" property="createBy"/>
+        <result column="properties" property="properties" jdbcType="OTHER" typeHandler="com.tzy.mapper.handler.JsonNodeTypeHandler"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="update_by" property="updateBy"/>
+    </resultMap>
+    <select id="getSpuById" resultMap="spuMap">
+        select id,category,sub_category,spu_name,num,main_image,carousel_image,status,properties,create_time,create_by,update_time,update_by from spu where id=#{id}
+    </select>
+</mapper>

+ 44 - 0
poyee-order/target/classes/mapper/LotOrderMapper.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzy.mapper.LotOrderMapper">
+    <resultMap id="lotOrderResultMap" type="lotOrder">
+        <id column="id" property="id"/>
+        <result column="order_no" property="orderNo"/>
+        <result column="auction_name" property="auctionName"/>
+        <result column="lot_name" property="lotName"/>
+        <result column="user_id" property="lotId"/>
+        <result column="status" property="status"/>
+        <result column="payment_amount" property="paymentAmount"/>
+        <result  column="merchant_id" property="merchantId"/>
+        <result column="shipping_address_id" property="shippingAddressId"/>
+        <result column="express_id" property="expressId"/>
+        <result column="lot_id" property="lotId"/>
+        <result column="auction_id" property="auctionId"/>
+        <result column="create_time" property="createTime"/>
+        <result column="pay_time" property="payTime"/>
+    </resultMap>
+    <select id="selectLotOrder" resultMap="lotOrderResultMap" parameterType="lotOrder">
+        select id,order_no,auction_name,lot_name,user_id,status,payment_amount,merchant_id,shipping_address_id,express_id,lot_id,auction_id,create_time,pay_time from lot_order_info
+        <where>
+            <if test="id!=null">
+                and id=#{id}
+            </if>
+            <if test="orderNo!=null and orderNo!=''">
+                and order_no=#{orderNo}
+            </if>
+            <if test="status!=null">
+                and status=#{status}
+            </if>
+            <if test="userId!=null">
+                and user_id=#{userId}
+            </if>
+        </where>
+        order by create_time desc
+    </select>
+    <insert id="insertLotOrder">
+        insert into lot_order_info (order_no,auction_name,lot_name,user_id,status,payment_amount,merchant_id,shipping_address_id,express_id,lot_id,auction_id,create_time,pay_time)
+        values (#{orderNo},#{auctionName},#{lotName},#{userId},#{status},#{paymentAmount},#{merchantId},#{shippingAddressId},#{expressId},#{lotId},#{auctionId},#{createTime},#{payTime})
+    </insert>
+</mapper>

+ 78 - 0
tzy-sportcard/src/main/java/com/tzy/elasticsearch/dto/CardGroupInfoGoodsDTO.java

@@ -0,0 +1,78 @@
+package com.tzy.elasticsearch.dto;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@Accessors(chain = true)
+public class CardGroupInfoGoodsDTO {
+
+    /**
+     * 新增同步
+     */
+    public static final String SYNC_TYPE_ADD="add";
+    /**
+     * 编辑同步
+     */
+    public static final String SYNC_TYPE_EDIT="edit";
+    /**先删再添加*/
+    public static final String SYNC_TYPE_DEL_ADD="del_add";
+
+    /**
+     * 同步类型
+     * add 新增
+     * edit 编辑
+     * del_add 先删再添加
+     */
+    private String syncType;
+
+    private Long groupInfoId; // 组队ID
+
+    private String groupInfoName; // 组队名称
+
+    private String status; // 组队状态(多个逗号分隔)
+
+    private Long id; // es表ID
+
+    private String searchName; // 球员球队卡种搜索框
+
+    private String sport; // 运动类型(多个逗号分隔)
+
+    private String specs; // 规格
+
+    private Integer progress; // 进度
+
+    private String showApplet; // 是否在小程序显示
+
+    private String type; // 玩法:随机卡种、随机球员
+
+    private String soldTimeStart; // 开售开始时间
+
+    private String soldTimeEnd; // 开售结束时间
+
+    private String hotType; // 查询活动type
+
+    private String sets; // 系列(多个逗号分隔)
+
+    private Long sortValue;
+
+    private String sortBy; // 排序字段
+
+    private String direction; // 正序or倒序
+
+    private List<Long> merchantId;
+
+    private String keyword;
+
+    //分页
+    private Integer page;
+
+    private Integer rows;
+
+    private Integer userLevel;
+
+}

+ 41 - 0
tzy-sportcard/src/main/java/com/tzy/elasticsearch/dto/EsCardGroupInfoDTO.java

@@ -0,0 +1,41 @@
+package com.tzy.elasticsearch.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class EsCardGroupInfoDTO {
+
+    private Long groupInfoId;
+    private Integer merchantId;
+    private String merchantName;
+    private String groupInfoName;
+    private String groupInfoCode;
+    private BigDecimal totalPrice;
+    private BigDecimal unitPrice;
+    private Long status;
+    private String specs;
+    private String type;
+    private String title;
+    private String randomType;
+    private Long copies;
+    private String showApplet;
+    private Date startTime;
+    private Boolean lock;
+    private int sortValue;
+    private String year;
+    private String sport;
+    private String manufacturer;
+    private String sets;
+    private String hotType;
+    private int goodsType;
+    private int realSoldNum;
+    private Date groupFullTime;
+    private String coverPicture;
+    private int UserQuotaMax;
+    /**搜索别名 多个空格隔开 对应prop2字段*/
+    private String infoAlias;
+    private Integer userLevel;
+}

+ 17 - 0
tzy-sportcard/src/main/java/com/tzy/elasticsearch/dto/EsCardGroupInfoGoodsDTO.java

@@ -0,0 +1,17 @@
+package com.tzy.elasticsearch.dto;
+
+import lombok.Data;
+
+@Data
+public class EsCardGroupInfoGoodsDTO {
+
+    private String  playerName;
+    private String team;
+    private String  setName;
+    private String  znPlayerName;
+    private String  znTeam;
+    private String seq;
+    private String picture;
+    private String num;
+    private String no;
+}