Commit 12d36c99 by huluobin

全局的货币单位mybatis处理器

parent f501c64d
...@@ -34,38 +34,38 @@ public class OrderAddress extends BaseModel { ...@@ -34,38 +34,38 @@ public class OrderAddress extends BaseModel {
@ApiModelProperty(value = "ana-order id") @ApiModelProperty(value = "ana-order id")
private String orderId; private String orderId;
// @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "国家不能为空") @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "国家不能为空")
@ApiModelProperty(value = "国家") @ApiModelProperty(value = "国家")
private String countryCode; private String countryCode;
@ApiModelProperty(value = "地区") @ApiModelProperty(value = "地区")
private String area; private String area;
// @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "国家不能为空") @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "城市不能为空")
@ApiModelProperty(value = "城市") @ApiModelProperty(value = "城市")
private String city; private String city;
@ApiModelProperty(value = "州") @ApiModelProperty(value = "州")
private String stateOrRegion; private String stateOrRegion;
// @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "地址不能为空") @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "地址不能为空")
@ApiModelProperty(value = "地址1") @ApiModelProperty(value = "地址1")
private String address; private String address;
@ApiModelProperty(value = "地址2") @ApiModelProperty(value = "地址2")
private String address2; private String address2;
// @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "收货人姓名不能为空") @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "收货人姓名不能为空")
@ApiModelProperty(value = "收货人姓名") @ApiModelProperty(value = "收货人姓名")
private String receiver; private String receiver;
// @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "电话不能为空") @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "电话不能为空")
@ApiModelProperty(value = "电话") @ApiModelProperty(value = "电话")
private String phone; private String phone;
private String phone2; private String phone2;
// @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "邮编不能为空") @NotNull(groups = OrderValidGroup.PublishOrder.class, message = "邮编不能为空")
@ApiModelProperty(value = "邮编") @ApiModelProperty(value = "邮编")
private String postalCode; private String postalCode;
......
...@@ -35,7 +35,7 @@ import java.util.List; ...@@ -35,7 +35,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value = "Order对象", description = "ana-order订单") @ApiModel(value = "Order对象", description = "ana-order订单")
@TableName(value = "`order`") @TableName(autoResultMap = true, value = "`order`")
public class Order extends BaseModel { public class Order extends BaseModel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -6,6 +6,7 @@ import com.bailuntec.ana.vo.order.Currency; ...@@ -6,6 +6,7 @@ import com.bailuntec.ana.vo.order.Currency;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -31,6 +32,7 @@ import java.util.List; ...@@ -31,6 +32,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value = "OrdeDetail", description = "") @ApiModel(value = "OrdeDetail", description = "")
@TableName(autoResultMap = true)
public class OrderDetail extends BaseModel { public class OrderDetail extends BaseModel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -103,7 +103,9 @@ public class DictTransferAspect { ...@@ -103,7 +103,9 @@ public class DictTransferAspect {
//设置翻译后的字典值 //设置翻译后的字典值
valueField.set(object, value); valueField.set(object, value);
} }
if (field.getType().isAnnotationPresent(ApiModel.class) || field.getType().isAnnotationPresent(TableName.class)) { if ((field.getType().isAnnotationPresent(ApiModel.class) || field.getType().isAnnotationPresent(TableName.class)) &&
!field.getDeclaringClass().getName().equals(object.getClass().getName())) {
field.setAccessible(true); field.setAccessible(true);
Object subObject = field.get(object); Object subObject = field.get(object);
if (subObject != null) { if (subObject != null) {
......
package com.bailuntec.ana.infrastructure.common.config.config;
import com.bailuntec.ana.vo.order.Currency;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.type.TypeHandlerRegistry;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* <p>
* mybatis 全局currency转换器
* </p>
*
* @author robbendev
* @since 2020/8/5 9:36 上午
*/
@Component
public class CurrencyTypeHandler implements ApplicationContextAware {
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//从spring容器获取sqlSessionFactory
SqlSessionFactory sqlSessionFactory = applicationContext.getBean(SqlSessionFactory.class);
//获取typeHandler注册器
TypeHandlerRegistry typeHandlerRegistry = sqlSessionFactory.getConfiguration().getTypeHandlerRegistry();
//注册Currency的typeHandler
typeHandlerRegistry.register(Currency.class, JacksonTypeHandler.class);
}
}
package com.bailuntec.ana.infrastructure.feign; package com.bailuntec.ana.infrastructure.feign;
import com.bailuntec.ana.infrastructure.common.util.seq.IdWorker; import com.bailuntec.ana.infrastructure.common.util.seq.IdWorker;
import com.bailuntec.ana.vo.order.Currency;
import com.bailuntec.ana.vo.product.resp.PdsSkuInfo; import com.bailuntec.ana.vo.product.resp.PdsSkuInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -40,6 +41,8 @@ public interface PdsApi { ...@@ -40,6 +41,8 @@ public interface PdsApi {
pdsSkuInfo.setPurchaseAsin(IdWorker.getId()); pdsSkuInfo.setPurchaseAsin(IdWorker.getId());
pdsSkuInfo.setPurchasePlat("ebay"); pdsSkuInfo.setPurchasePlat("ebay");
pdsSkuInfo.setPurchaseSkuNo(IdWorker.getId()); pdsSkuInfo.setPurchaseSkuNo(IdWorker.getId());
pdsSkuInfo.setCostPrice(Currency.TEST);
pdsSkuInfo.setTolerance(Currency.TEST);
return pdsSkuInfo; return pdsSkuInfo;
} }
} }
......
...@@ -26,7 +26,7 @@ public class Schedule { ...@@ -26,7 +26,7 @@ public class Schedule {
* 从pams同步订单里面的刊登帐号信息 * 从pams同步订单里面的刊登帐号信息
* </p> * </p>
*/ */
@Scheduled(cron = "0 0/1 * * * *") @Scheduled(cron = "*/5 * * * * ?")
public void syncOrderPdsAccount() { public void syncOrderPdsAccount() {
List<Order> orderList = orderService.queryUnSyncPdsAccountOrder(); List<Order> orderList = orderService.queryUnSyncPdsAccountOrder();
...@@ -47,7 +47,7 @@ public class Schedule { ...@@ -47,7 +47,7 @@ public class Schedule {
* 从刊登系统同步订单详情销售sku对应的采购item,采购sku,成本 * 从刊登系统同步订单详情销售sku对应的采购item,采购sku,成本
* </p> * </p>
*/ */
@Scheduled(cron = "0 0/1 * * * *") @Scheduled(cron = "*/5 * * * * ?")
public void syncOrderDetails() { public void syncOrderDetails() {
List<Order> orderList = orderService.queryUnSyncDetailsOrder(); List<Order> orderList = orderService.queryUnSyncDetailsOrder();
if (ListUtil.isNotEmpty(orderList)) { if (ListUtil.isNotEmpty(orderList)) {
......
...@@ -38,5 +38,6 @@ public class Currency { ...@@ -38,5 +38,6 @@ public class Currency {
@ApiModelProperty(value = "货币单位") @ApiModelProperty(value = "货币单位")
private String currencyCode; private String currencyCode;
public static final Currency TEST = new Currency(BigDecimal.ONE, BigDecimal.ONE, "CNY");
} }
...@@ -42,4 +42,5 @@ public class PdsSkuInfo { ...@@ -42,4 +42,5 @@ public class PdsSkuInfo {
@ApiModelProperty(value = "容忍超过成本范围 超出不进行采购") @ApiModelProperty(value = "容忍超过成本范围 超出不进行采购")
private Currency tolerance; private Currency tolerance;
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<mapper namespace="com.bailuntec.ana.infrastructure.mapper.order.OrderMapper"> <mapper namespace="com.bailuntec.ana.infrastructure.mapper.order.OrderMapper">
<select id="selectByOrderNoAndPdsAccountId" resultType="com.bailuntec.ana.domain.order.Order"> <select id="selectByOrderNoAndPdsAccountId" resultType="com.bailuntec.ana.domain.order.Order">
select * select *
from `order` from `order`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment