Authored by mali

货号生成表

package com.yoho.order.dal;
import com.yoho.order.model.DepositCode;
import org.apache.ibatis.annotations.Param;
/**
* Created by li.ma on 2019/7/16.
*/
public interface DepositCodeMapper {
int insert(DepositCode depositCode);
}
... ...
package com.yoho.order.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* Created by li.ma on 2019/7/16.
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
@ToString
public class DepositCode {
private Integer id;
private Integer createTime;
}
... ...
<?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.yoho.order.dal.DepositCodeMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.DepositCode">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
</resultMap>
<insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.yoho.order.model.DepositCode">
insert into deposit_code (create_time)
values (#{createTime,jdbcType=INTEGER})
</insert>
</mapper>
\ No newline at end of file
... ...
... ... @@ -579,4 +579,10 @@ public class BuyerOrderController {
ExpressCompany result = buyerOrderService.orderQueryExpressCompanyId(req.getOrderCode());
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
@RequestMapping(value = "/generateDepositCode")
public ApiResponse generateDepositCode() {
String result = buyerOrderService.generateDepositCode();
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
... ... @@ -131,4 +131,6 @@ public interface IBuyerOrderService {
List<IdentifyCenterResp> queryIdentifyCenter();
JSONObject settleFail(BuyerOrderReq req);
String generateDepositCode();
}
... ...
... ... @@ -248,6 +248,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
@Autowired
private DepositOrderMapper depositOrderMapper;
@Autowired
private DepositCodeService depositCodeService;
private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address";
private static final String BUYER_ORDER_META_KEY_RECALL_ADDRESS = "recall_address";
... ... @@ -1371,11 +1374,12 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
return jsonObject;
}
private static String generateDepositCode() {
//生成寄存码:当前时间戳后9位
public String generateDepositCode() {
/*//生成寄存码:当前时间戳后9位
String currentSeconds = String.valueOf(DateUtil.getCurrentTimeSeconds());
Random random = new Random();
return currentSeconds.substring(1, currentSeconds.length()-1) + "" + random.nextInt(9);
return currentSeconds.substring(1, currentSeconds.length()-1) + "" + random.nextInt(9);*/
return String.valueOf(depositCodeService.selectDepositCode());
}
//鉴定不通过 : 平台收货后,直接鉴定不通过
... ...
package com.yoho.ufo.order.service.impl;
import com.yoho.order.dal.DepositCodeMapper;
import com.yoho.order.model.DepositCode;
import com.yoho.ufo.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Created by li.ma on 2019/7/16.
*/
@Service
public class DepositCodeService {
@Autowired
private DepositCodeMapper depositCodeMapper;
public int selectDepositCode() {
DepositCode depositCode = new DepositCode(null, DateUtil.getCurrentTimeSeconds());
depositCodeMapper.insert(depositCode);
return depositCode.getId();
}
}
... ...
... ... @@ -58,6 +58,7 @@ datasources:
- com.yoho.order.dal.AbnormalPackageMapper
- com.yoho.order.dal.StorageDepositMapper
- com.yoho.order.dal.DepositOrderMapper
- com.yoho.order.dal.DepositCodeMapper
ufo_resource:
servers:
... ...
... ... @@ -59,6 +59,7 @@ datasources:
- com.yoho.order.dal.AbnormalPackageMapper
- com.yoho.order.dal.StorageDepositMapper
- com.yoho.order.dal.DepositOrderMapper
- com.yoho.order.dal.DepositCodeMapper
ufo_resource:
servers:
... ...