Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
4b5a4544d1
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry){
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new UserInterceptor());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ public class AuthorizationController {
|
|||
put("user", jwtUserDto);
|
||||
if (byAccount != null) {
|
||||
put("shopId", byAccount.getId());
|
||||
put("mainId", byAccount.getId());
|
||||
put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType())?authUser.getLoginType():"merchant");
|
||||
put("shopName", byAccount.getShopName());
|
||||
put("logo", byAccount.getLogo());
|
||||
|
|
|
|||
|
|
@ -73,6 +73,16 @@ public class TokenProvider implements InitializingBean {
|
|||
.compact();
|
||||
}
|
||||
|
||||
public String createToken(String name,String shopId) {
|
||||
return jwtBuilder
|
||||
// 加入ID确保生成的 Token 都不一致
|
||||
.setId(IdUtil.simpleUUID())
|
||||
.claim(AUTHORITIES_KEY, name)
|
||||
.claim("shopId",shopId)
|
||||
.setSubject(name)
|
||||
.compact();
|
||||
}
|
||||
|
||||
/**
|
||||
* 依据Token 获取鉴权信息
|
||||
*
|
||||
|
|
|
|||
|
|
@ -50,6 +50,19 @@ public class OnlineUserService {
|
|||
redisUtils.set(properties.getOnlineKey() + token, onlineUserDto, properties.getTokenValidityInSeconds()/1000);
|
||||
}
|
||||
|
||||
public void save(String username, String nickName, String token, HttpServletRequest request,Integer shopId){
|
||||
String ip = StringUtils.getIp(request);
|
||||
String browser = StringUtils.getBrowser(request);
|
||||
String address = StringUtils.getCityInfo(ip);
|
||||
OnlineUserDto onlineUserDto = null;
|
||||
try {
|
||||
onlineUserDto = new OnlineUserDto(shopId,username, nickName, null, browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
redisUtils.set(properties.getOnlineKey() + token, onlineUserDto, properties.getTokenValidityInSeconds()/1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
* @param filter /
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.config.security.config.bean.SecurityProperties;
|
||||
import cn.ysk.cashier.config.security.security.TokenProvider;
|
||||
import cn.ysk.cashier.config.security.service.OnlineUserService;
|
||||
import cn.ysk.cashier.dto.BindingDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopInfoDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.service.shop.TbShopInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -20,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -43,13 +47,39 @@ public class TbShopInfoController {
|
|||
public ResponseEntity<Object> binding(@RequestBody BindingDto bindingDto){
|
||||
return new ResponseEntity<>(tbShopInfoService.binding(bindingDto), HttpStatus.OK);
|
||||
}
|
||||
// @Log("导出数据")
|
||||
// @ApiOperation("导出数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// @PreAuthorize("@el.check('tbShopInfo:list')")
|
||||
// public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException {
|
||||
// tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response);
|
||||
// }
|
||||
|
||||
private final SecurityProperties properties;
|
||||
|
||||
@PostMapping("changChildShop")
|
||||
@ApiOperation("切换子店铺")
|
||||
public ResponseEntity<Object> changChildShop(@RequestBody TbShopInfoQueryCriteria criteria, HttpServletRequest request) {
|
||||
TbShopInfoDto shopInfo = tbShopInfoService.findById(criteria.getId());
|
||||
if (shopInfo != null) {
|
||||
//生成token
|
||||
String token = tokenProvider.createToken(shopInfo.getAccount(), criteria.getId().toString());
|
||||
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
||||
put("token", properties.getTokenStartWith() + token);
|
||||
if (shopInfo != null) {
|
||||
put("shopId", shopInfo.getId());
|
||||
put("mainId", shopInfo.getMainId());
|
||||
put("loginType", "merchant");
|
||||
put("shopName", shopInfo.getShopName());
|
||||
put("logo", shopInfo.getLogo());
|
||||
}
|
||||
}};
|
||||
// 保存在线信息
|
||||
onlineUserService.save(shopInfo.getAccount(), shopInfo.getShopName(), token, request, shopInfo.getId());
|
||||
return ResponseEntity.ok(authInfo);
|
||||
} else {
|
||||
throw new BadRequestException("店铺信息不存在");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("queryChildShop")
|
||||
@ApiOperation("查询子店铺")
|
||||
public ResponseEntity<Object> queryChildShop(TbShopInfoQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbShopInfoService.queryChildShop(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询/shop/list")
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class TbShopInfoDto implements Serializable {
|
|||
|
||||
/** 自增id */
|
||||
private Integer id;
|
||||
private String mainId;
|
||||
|
||||
/** 店铺帐号 */
|
||||
@NotBlank(message = "店铺账号不能为空")
|
||||
|
|
@ -101,6 +102,8 @@ public class TbShopInfoDto implements Serializable {
|
|||
/** 未用 */
|
||||
private String mchId;
|
||||
|
||||
private Integer tubeType;
|
||||
|
||||
private String registerType;
|
||||
|
||||
/** 是否独立的微信小程序 */
|
||||
|
|
@ -112,7 +115,7 @@ public class TbShopInfoDto implements Serializable {
|
|||
/** 类似于这种规则51.51.570 */
|
||||
private String city;
|
||||
|
||||
/** 店铺类型 超市--MARKET---其它店SHOP */
|
||||
/** 店铺类型 单店--only 连锁店--chain--加盟店join*/
|
||||
private String type;
|
||||
|
||||
/** 行业 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ public class TbShopInfo implements Serializable {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`main_id`")
|
||||
@ApiModelProperty(value = "总店铺帐号")
|
||||
private String mainId;
|
||||
|
||||
@Column(name = "`account`")
|
||||
@ApiModelProperty(value = "店铺帐号")
|
||||
private String account;
|
||||
|
|
@ -138,9 +142,13 @@ public class TbShopInfo implements Serializable {
|
|||
private String city;
|
||||
|
||||
@Column(name = "`type`")
|
||||
@ApiModelProperty(value = "店铺类型 超市--MARKET---其它店SHOP")
|
||||
@ApiModelProperty(value = "店铺类型 单店--only 连锁店--chain--加盟店join")
|
||||
private String type;
|
||||
|
||||
@Column(name = "`tube_type`")
|
||||
@ApiModelProperty(value = "管理 0否 1是")
|
||||
private Integer tubeType;
|
||||
|
||||
@Column(name = "`industry`")
|
||||
@ApiModelProperty(value = "行业")
|
||||
private String industry;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.ysk.cashier.config.security.security.TokenProvider;
|
||||
import cn.ysk.cashier.config.security.service.UserCacheManager;
|
||||
|
|
@ -12,13 +9,15 @@ import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
|
|||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.exception.EntityNotFoundException;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopInfoMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.MpShopInfoMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantRegister;
|
||||
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||
import cn.ysk.cashier.repository.shop.*;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantRegisterRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.WxService;
|
||||
import cn.ysk.cashier.service.shop.TbShopInfoService;
|
||||
import cn.ysk.cashier.system.domain.Dept;
|
||||
|
|
@ -31,11 +30,8 @@ import cn.ysk.cashier.system.service.ParamsService;
|
|||
import cn.ysk.cashier.system.service.UserService;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
@ -45,12 +41,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -74,8 +67,6 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
|
||||
private final UserService userService;
|
||||
|
||||
private final UserCacheManager userCacheManager;
|
||||
private final TokenProvider tokenProvider;
|
||||
private final ParamsService paramsService;
|
||||
|
||||
private final TbMerchantRegisterRepository merchantRegisterRepository;
|
||||
|
|
@ -129,6 +120,28 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
return PageUtil.toPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopInfo> queryChildShop(TbShopInfoQueryCriteria criteria){
|
||||
List<TbShopInfo> list = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> {
|
||||
Predicate query1 = criteriaBuilder.equal(root.get("id"), criteria.getId());
|
||||
Predicate query2 = criteriaBuilder.and(
|
||||
criteriaBuilder.equal(root.get("mainId"), criteria.getId()),
|
||||
criteriaBuilder.notEqual(root.get("type"), "only"),
|
||||
criteriaBuilder.equal(root.get("tubeType"), 1)
|
||||
);
|
||||
|
||||
|
||||
// 再将两个子条件进行或运算组合成最终条件
|
||||
Predicate predicate = criteriaBuilder.or(
|
||||
query1,
|
||||
query2
|
||||
);
|
||||
|
||||
return predicate;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria){
|
||||
// return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
|
|
@ -155,11 +168,6 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
return tbShopInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbShopInfoDto finByAccount(String account) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopInfoDto create(TbShopInfoDto resources) {
|
||||
|
|
@ -198,6 +206,15 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
//向redis中存入key
|
||||
redisUtils.set(CacheKey.ACT_CODE+resources.getAccount(),"1",tbShopInfo.getExpireAt()-Instant.now().toEpochMilli());
|
||||
}
|
||||
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){
|
||||
if(resources.getMainId() == null){
|
||||
throw new BadRequestException("连锁店或者扩展店 主店铺不能为空");
|
||||
}
|
||||
}else {
|
||||
tbShopInfo.setMainId(null);
|
||||
}
|
||||
|
||||
//增加商户详情
|
||||
TbShopInfo save = tbShopInfoRepository.save(tbShopInfo);
|
||||
if (resources.getRegisterCode() != null) {
|
||||
|
|
@ -286,6 +303,13 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopInfo resources) {
|
||||
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(resources.getType()) && !"only".equals(resources.getType())){
|
||||
if(resources.getMainId() == null){
|
||||
throw new BadRequestException("连锁店或者扩展店 主店铺不能为空");
|
||||
}
|
||||
}else {
|
||||
tbShopInfo.setMainId(null);
|
||||
}
|
||||
if (StringUtils.isNotBlank(resources.getShopName()) && !resources.getShopName().equals(tbShopInfo.getShopName())) {
|
||||
shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString());
|
||||
userRepository.updateNickName(resources.getAccount(),resources.getShopName());
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ public interface TbShopInfoService {
|
|||
*/
|
||||
Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria);
|
||||
|
||||
List<TbShopInfo> queryChildShop(TbShopInfoQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
|
|
@ -63,7 +65,6 @@ public interface TbShopInfoService {
|
|||
TbShopInfoDto findById(Integer id);
|
||||
TbShopInfo findByIdInfo(Integer id);
|
||||
|
||||
TbShopInfoDto finByAccount(String account);
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
|
|
|
|||
Loading…
Reference in New Issue