Authored by mali

货号生成表

  1 +package com.yoho.order.dal;
  2 +
  3 +import com.yoho.order.model.DepositCode;
  4 +import org.apache.ibatis.annotations.Param;
  5 +
  6 +/**
  7 + * Created by li.ma on 2019/7/16.
  8 + */
  9 +public interface DepositCodeMapper {
  10 + int insert(DepositCode depositCode);
  11 +}
  1 +package com.yoho.order.model;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +import lombok.NoArgsConstructor;
  6 +import lombok.ToString;
  7 +
  8 +/**
  9 + * Created by li.ma on 2019/7/16.
  10 + */
  11 +@NoArgsConstructor
  12 +@AllArgsConstructor
  13 +@Data
  14 +@ToString
  15 +public class DepositCode {
  16 + private Integer id;
  17 +
  18 + private Integer createTime;
  19 +}
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.yoho.order.dal.DepositCodeMapper">
  4 + <resultMap id="BaseResultMap" type="com.yoho.order.model.DepositCode">
  5 + <id column="id" jdbcType="INTEGER" property="id" />
  6 + <result column="create_time" jdbcType="INTEGER" property="createTime" />
  7 + </resultMap>
  8 +
  9 + <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.yoho.order.model.DepositCode">
  10 + insert into deposit_code (create_time)
  11 + values (#{createTime,jdbcType=INTEGER})
  12 + </insert>
  13 +</mapper>
@@ -579,4 +579,10 @@ public class BuyerOrderController { @@ -579,4 +579,10 @@ public class BuyerOrderController {
579 ExpressCompany result = buyerOrderService.orderQueryExpressCompanyId(req.getOrderCode()); 579 ExpressCompany result = buyerOrderService.orderQueryExpressCompanyId(req.getOrderCode());
580 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); 580 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
581 } 581 }
  582 +
  583 + @RequestMapping(value = "/generateDepositCode")
  584 + public ApiResponse generateDepositCode() {
  585 + String result = buyerOrderService.generateDepositCode();
  586 + return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
  587 + }
582 } 588 }
@@ -131,4 +131,6 @@ public interface IBuyerOrderService { @@ -131,4 +131,6 @@ public interface IBuyerOrderService {
131 List<IdentifyCenterResp> queryIdentifyCenter(); 131 List<IdentifyCenterResp> queryIdentifyCenter();
132 132
133 JSONObject settleFail(BuyerOrderReq req); 133 JSONObject settleFail(BuyerOrderReq req);
  134 +
  135 + String generateDepositCode();
134 } 136 }
@@ -248,6 +248,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -248,6 +248,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
248 @Autowired 248 @Autowired
249 private DepositOrderMapper depositOrderMapper; 249 private DepositOrderMapper depositOrderMapper;
250 250
  251 + @Autowired
  252 + private DepositCodeService depositCodeService;
  253 +
251 private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address"; 254 private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address";
252 255
253 private static final String BUYER_ORDER_META_KEY_RECALL_ADDRESS = "recall_address"; 256 private static final String BUYER_ORDER_META_KEY_RECALL_ADDRESS = "recall_address";
@@ -1371,11 +1374,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -1371,11 +1374,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
1371 return jsonObject; 1374 return jsonObject;
1372 } 1375 }
1373 1376
1374 - private static String generateDepositCode() {  
1375 - //生成寄存码:当前时间戳后9位 1377 + public String generateDepositCode() {
  1378 + /*//生成寄存码:当前时间戳后9位
1376 String currentSeconds = String.valueOf(DateUtil.getCurrentTimeSeconds()); 1379 String currentSeconds = String.valueOf(DateUtil.getCurrentTimeSeconds());
1377 Random random = new Random(); 1380 Random random = new Random();
1378 - return currentSeconds.substring(1, currentSeconds.length()-1) + "" + random.nextInt(9); 1381 + return currentSeconds.substring(1, currentSeconds.length()-1) + "" + random.nextInt(9);*/
  1382 + return String.valueOf(depositCodeService.selectDepositCode());
1379 } 1383 }
1380 1384
1381 //鉴定不通过 : 平台收货后,直接鉴定不通过 1385 //鉴定不通过 : 平台收货后,直接鉴定不通过
  1 +package com.yoho.ufo.order.service.impl;
  2 +
  3 +import com.yoho.order.dal.DepositCodeMapper;
  4 +import com.yoho.order.model.DepositCode;
  5 +import com.yoho.ufo.util.DateUtil;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 + * Created by li.ma on 2019/7/16.
  11 + */
  12 +@Service
  13 +public class DepositCodeService {
  14 + @Autowired
  15 + private DepositCodeMapper depositCodeMapper;
  16 +
  17 + public int selectDepositCode() {
  18 + DepositCode depositCode = new DepositCode(null, DateUtil.getCurrentTimeSeconds());
  19 +
  20 + depositCodeMapper.insert(depositCode);
  21 +
  22 + return depositCode.getId();
  23 + }
  24 +}
@@ -58,6 +58,7 @@ datasources: @@ -58,6 +58,7 @@ datasources:
58 - com.yoho.order.dal.AbnormalPackageMapper 58 - com.yoho.order.dal.AbnormalPackageMapper
59 - com.yoho.order.dal.StorageDepositMapper 59 - com.yoho.order.dal.StorageDepositMapper
60 - com.yoho.order.dal.DepositOrderMapper 60 - com.yoho.order.dal.DepositOrderMapper
  61 + - com.yoho.order.dal.DepositCodeMapper
61 62
62 ufo_resource: 63 ufo_resource:
63 servers: 64 servers:
@@ -59,6 +59,7 @@ datasources: @@ -59,6 +59,7 @@ datasources:
59 - com.yoho.order.dal.AbnormalPackageMapper 59 - com.yoho.order.dal.AbnormalPackageMapper
60 - com.yoho.order.dal.StorageDepositMapper 60 - com.yoho.order.dal.StorageDepositMapper
61 - com.yoho.order.dal.DepositOrderMapper 61 - com.yoho.order.dal.DepositOrderMapper
  62 + - com.yoho.order.dal.DepositCodeMapper
62 63
63 ufo_resource: 64 ufo_resource:
64 servers: 65 servers: