Compare commits
6 Commits
dev-门店切换-应
...
gyj
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33b0c2bb10 | ||
|
|
d7ba8509d5 | ||
|
|
7a305e8901 | ||
|
|
6c25d89eb2 | ||
|
|
afed250715 | ||
|
|
088d8037b8 |
@@ -14,6 +14,7 @@ import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -28,7 +29,9 @@ import java.util.List;
|
||||
@EnableWebMvc
|
||||
public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
|
||||
/** 文件配置 */
|
||||
/**
|
||||
* 文件配置
|
||||
*/
|
||||
private final FileProperties properties;
|
||||
|
||||
public ConfigurerAdapter(FileProperties properties) {
|
||||
@@ -50,8 +53,8 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
FileProperties.ElPath path = properties.getPath();
|
||||
String avatarUtl = "file:" + path.getAvatar().replace("\\","/");
|
||||
String pathUtl = "file:" + path.getPath().replace("\\","/");
|
||||
String avatarUtl = "file:" + path.getAvatar().replace("\\", "/");
|
||||
String pathUtl = "file:" + path.getPath().replace("\\", "/");
|
||||
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
|
||||
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
|
||||
@@ -65,7 +68,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||
supportMediaTypeList.add(MediaType.APPLICATION_JSON);
|
||||
FastJsonConfig config = new FastJsonConfig();
|
||||
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue);
|
||||
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat);
|
||||
converter.setFastJsonConfig(config);
|
||||
converter.setSupportedMediaTypes(supportMediaTypeList);
|
||||
converter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||
|
||||
@@ -1,44 +1,16 @@
|
||||
package cn.ysk.cashier.config.interceptor;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry){
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new UserInterceptor());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() {
|
||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
//忽略未知属性
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
//日期格式转换
|
||||
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
||||
mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
|
||||
//Long类型转String类型
|
||||
//SimpleModule simpleModule = new SimpleModule();
|
||||
//simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||
//simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
||||
//mapper.registerModule(simpleModule);
|
||||
converter.setObjectMapper(mapper);
|
||||
return converter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
@@ -106,21 +107,25 @@ public class TbPointsExchangeRecord {
|
||||
/**
|
||||
* 取消/退款时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date cancelOrRefundTime;
|
||||
/**
|
||||
* 实际支付时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date payTime;
|
||||
/**
|
||||
* 创建时间(下单时间)
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间(核销时间)
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
@@ -104,27 +104,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbPlussShopStaffDto create(TbPlussShopStaff resources) {
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(resources.getAccount())) {
|
||||
throw new BadRequestException("员工账号为空");
|
||||
}
|
||||
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
|
||||
throw new BadRequestException("员工账号已存在");
|
||||
}
|
||||
if (!PhoneUtil.validator(resources.getPhone())){
|
||||
throw new BadRequestException("手机号格式有误");
|
||||
}
|
||||
checkStaffParams(resources);
|
||||
|
||||
if (pattern.matcher(resources.getCode()).find()) {
|
||||
throw new BadRequestException("员工编号不能包含中文");
|
||||
}
|
||||
|
||||
if (resources.getRoleId()==null) {
|
||||
throw new BadRequestException("请选择角色");
|
||||
}
|
||||
|
||||
if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) {
|
||||
throw new BadRequestException("最大优惠金额过大");
|
||||
}
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
|
||||
//添加收银系统后台账号
|
||||
@@ -175,6 +156,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
||||
if (pattern.matcher(resources.getCode()).find()) {
|
||||
throw new BadRequestException("员工编号不能包含中文");
|
||||
}
|
||||
|
||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
|
||||
User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount());
|
||||
if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){
|
||||
@@ -207,6 +189,33 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
||||
Integer.valueOf(resources.getShopId()), resources.getId(), resources.getPermissions());
|
||||
}
|
||||
|
||||
private void checkStaffParams(TbPlussShopStaff resources) {
|
||||
if (StringUtils.isBlank(resources.getAccount())) {
|
||||
throw new BadRequestException("员工账号为空");
|
||||
}
|
||||
if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) {
|
||||
throw new BadRequestException("员工账号已存在");
|
||||
}
|
||||
if (!PhoneUtil.validator(resources.getPhone())){
|
||||
throw new BadRequestException("手机号格式有误");
|
||||
}
|
||||
if (tbPlussShopStaffRepository.queryByAccount(resources.getAccount(),resources.getShopId()) != null) {
|
||||
throw new BadRequestException("账号已存在");
|
||||
}
|
||||
|
||||
if (pattern.matcher(resources.getCode()).find()) {
|
||||
throw new BadRequestException("员工编号不能包含中文");
|
||||
}
|
||||
|
||||
if (resources.getRoleId()==null) {
|
||||
throw new BadRequestException("请选择角色");
|
||||
}
|
||||
|
||||
if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) {
|
||||
throw new BadRequestException("最大优惠金额过大");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStatus(TbPlussShopStaff resources) {
|
||||
|
||||
Reference in New Issue
Block a user