Merge remote-tracking branch 'origin/dev' into zs
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class PhoneUtil {
|
public class PhoneUtil {
|
||||||
public static boolean validator(String phone) {
|
public static boolean validator(String phone) {
|
||||||
String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$";
|
String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[0-9]))\\d{8}$";
|
||||||
if (phone.length() != 11) {
|
if (phone.length() != 11) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -110,6 +110,11 @@ public class AuthorizationController {
|
|||||||
if (isManage != null && isManage != 1) {
|
if (isManage != null && isManage != 1) {
|
||||||
throw new BadRequestException("该账号无权限登录,请联系管理员");
|
throw new BadRequestException("该账号无权限登录,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer status = tbPlussShopStaff.getStatus();
|
||||||
|
if (status != null && status != 1) {
|
||||||
|
throw new BadRequestException("该账号已被禁用,请联系管理员");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TbShopInfo byAccount = tbShopInfoRepository.findById(Integer.valueOf(tbPlussShopStaff.getShopId())).get();
|
TbShopInfo byAccount = tbShopInfoRepository.findById(Integer.valueOf(tbPlussShopStaff.getShopId())).get();
|
||||||
//校验商户商户激活是否到期(未激活)
|
//校验商户商户激活是否到期(未激活)
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public class SuppFlow implements Serializable {
|
|||||||
|
|
||||||
private List<ConInfos> list;
|
private List<ConInfos> list;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class TbConsInfoController {
|
|||||||
@Log("耗材出入库")
|
@Log("耗材出入库")
|
||||||
@ApiOperation("耗材出入库")
|
@ApiOperation("耗材出入库")
|
||||||
public ResponseEntity<Object> stockInOut(@Validated @RequestBody SuppFlow resources) throws Exception {
|
public ResponseEntity<Object> stockInOut(@Validated @RequestBody SuppFlow resources) throws Exception {
|
||||||
|
|
||||||
tbConsInfoService.stockInOut(resources);
|
tbConsInfoService.stockInOut(resources);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,6 @@ public class TbHandoverQueryCriteria{
|
|||||||
/** 精确 */
|
/** 精确 */
|
||||||
@Query
|
@Query
|
||||||
private String merchantName;
|
private String merchantName;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import cn.ysk.cashier.cons.service.TbConsInfoService;
|
|||||||
import cn.ysk.cashier.cons.service.dto.TbConsInfoDto;
|
import cn.ysk.cashier.cons.service.dto.TbConsInfoDto;
|
||||||
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
|
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
|
||||||
import cn.ysk.cashier.cons.service.mapstruct.TbConsInfoMapper;
|
import cn.ysk.cashier.cons.service.mapstruct.TbConsInfoMapper;
|
||||||
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.pojo.product.TbProductStockOperate;
|
import cn.ysk.cashier.pojo.product.TbProductStockOperate;
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||||
import cn.ysk.cashier.pojo.shop.TbShopPurveyor;
|
import cn.ysk.cashier.pojo.shop.TbShopPurveyor;
|
||||||
@@ -174,6 +175,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void stockInOut(SuppFlow resources) throws Exception {
|
public void stockInOut(SuppFlow resources) throws Exception {
|
||||||
|
log.info("resources:{}",JSON.toJSONString(resources));
|
||||||
if (Objects.isNull(resources)) {
|
if (Objects.isNull(resources)) {
|
||||||
throw new Exception("参数错误");
|
throw new Exception("参数错误");
|
||||||
}
|
}
|
||||||
@@ -197,7 +199,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
operatorSnapMap.put("account", tbShopInfo.getAccount());
|
operatorSnapMap.put("account", tbShopInfo.getAccount());
|
||||||
|
|
||||||
stockOperate.setOperatorSnap(JSON.toJSONString(operatorSnapMap));
|
stockOperate.setOperatorSnap(JSON.toJSONString(operatorSnapMap));
|
||||||
stockOperate.setRemark("");
|
stockOperate.setRemark(resources.getRemark());
|
||||||
stockOperate.setStockTime(System.currentTimeMillis());
|
stockOperate.setStockTime(System.currentTimeMillis());
|
||||||
stockOperate.setCreatedAt(System.currentTimeMillis());
|
stockOperate.setCreatedAt(System.currentTimeMillis());
|
||||||
stockOperate.setUpdatedAt(System.currentTimeMillis());
|
stockOperate.setUpdatedAt(System.currentTimeMillis());
|
||||||
@@ -255,7 +257,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
purveyorTransact.setType("cons_in");
|
purveyorTransact.setType("cons_in");
|
||||||
|
|
||||||
object.put("number",conInfos.getStockNumber());
|
object.put("number",conInfos.getStockNumber());
|
||||||
} else {
|
} else if("out".equals(resources.getType())) {
|
||||||
stockOperate.setSubType(-1);
|
stockOperate.setSubType(-1);
|
||||||
info.setStockNumber(info.getStockNumber().subtract(conInfos.getStockNumber()));
|
info.setStockNumber(info.getStockNumber().subtract(conInfos.getStockNumber()));
|
||||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(conInfos.getStockNumber()));
|
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(conInfos.getStockNumber()));
|
||||||
@@ -271,6 +273,8 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
|
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
|
||||||
purveyorTransact.setType("cons_out");
|
purveyorTransact.setType("cons_out");
|
||||||
object.put("number",conInfos.getStockNumber());
|
object.put("number",conInfos.getStockNumber());
|
||||||
|
}else {
|
||||||
|
throw new BadRequestException("错误操作类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,4 +58,8 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
|
|||||||
|
|
||||||
@Query("select product from TbProduct product where product.id=:id and product.shopId=:shopId")
|
@Query("select product from TbProduct product where product.id=:id and product.shopId=:shopId")
|
||||||
TbProduct selectByShopIdAndId(Integer id, String shopId);
|
TbProduct selectByShopIdAndId(Integer id, String shopId);
|
||||||
|
|
||||||
|
@Query("select product from TbProduct product where product.shopId=:shopId")
|
||||||
|
List<TbProduct> selectByShopId(String shopId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
* @author lyf
|
* @author lyf
|
||||||
@@ -42,4 +44,8 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
|
|||||||
|
|
||||||
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
|
@Query("select staff from TbPlussShopStaff as staff where staff.account = :account")
|
||||||
TbPlussShopStaff queryByAccount(String account);
|
TbPlussShopStaff queryByAccount(String account);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("update TbPlussShopStaff set name=:name where shopId = :shopId and type='master'")
|
||||||
|
void updateNameById(String name, String shopId);
|
||||||
}
|
}
|
||||||
@@ -373,6 +373,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TbProduct save = tbProductRepository.save(product);
|
TbProduct save = tbProductRepository.save(product);
|
||||||
if (save.getId() == null) {
|
if (save.getId() == null) {
|
||||||
throw new BadRequestException("添加商品失败");
|
throw new BadRequestException("添加商品失败");
|
||||||
@@ -381,6 +382,16 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
tbProductRepository.save(save);
|
tbProductRepository.save(save);
|
||||||
//sku
|
//sku
|
||||||
if (resources.getSkuList() != null) {
|
if (resources.getSkuList() != null) {
|
||||||
|
Integer warnLine = 0;
|
||||||
|
List<TbProduct> productList = tbProductRepository.selectByShopId(resources.getShopId());
|
||||||
|
if (!productList.isEmpty()) {
|
||||||
|
TbProduct p = productList.get(0);
|
||||||
|
List<TbProductSku> productSkus = tbProductSkuRepository.searchSku(p.getId().toString());
|
||||||
|
if (!productSkus.isEmpty()) {
|
||||||
|
warnLine = productSkus.get(0).getWarnLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<TbProductSku> skuList = new ArrayList<>();
|
List<TbProductSku> skuList = new ArrayList<>();
|
||||||
for (TbProductSku sku : resources.getSkuList()) {
|
for (TbProductSku sku : resources.getSkuList()) {
|
||||||
sku.setProductId(String.valueOf(save.getId()));
|
sku.setProductId(String.valueOf(save.getId()));
|
||||||
@@ -388,6 +399,7 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
sku.setCreatedAt(Instant.now().toEpochMilli());
|
sku.setCreatedAt(Instant.now().toEpochMilli());
|
||||||
sku.setUpdatedAt(Instant.now().toEpochMilli());
|
sku.setUpdatedAt(Instant.now().toEpochMilli());
|
||||||
sku.setIsGrounding(1);
|
sku.setIsGrounding(1);
|
||||||
|
sku.setWarnLine(warnLine);
|
||||||
skuList.add(sku);
|
skuList.add(sku);
|
||||||
}
|
}
|
||||||
List<TbProductSku> tbProductSkus = tbProductSkuRepository.saveAll(skuList);
|
List<TbProductSku> tbProductSkus = tbProductSkuRepository.saveAll(skuList);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package cn.ysk.cashier.service.impl.shopimpl;
|
package cn.ysk.cashier.service.impl.shopimpl;
|
||||||
|
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
|
import cn.ysk.cashier.exception.EntityExistException;
|
||||||
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||||
import cn.ysk.cashier.system.domain.Dept;
|
import cn.ysk.cashier.system.domain.Dept;
|
||||||
import cn.ysk.cashier.system.domain.Job;
|
import cn.ysk.cashier.system.domain.Job;
|
||||||
@@ -39,9 +40,11 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,6 +64,9 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
private final PasswordEncoder passwordEncoder;
|
private final PasswordEncoder passwordEncoder;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
|
|
||||||
|
// 正则表达式:(\u4e00-\u9fa5) 表示匹配一个中文字符,.* 表示匹配零个或多个任意字符
|
||||||
|
private final Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> queryAll(TbPlussShopStaffQueryCriteria criteria, Pageable pageable){
|
public Map<String,Object> queryAll(TbPlussShopStaffQueryCriteria criteria, Pageable pageable){
|
||||||
Page<TbPlussShopStaff> page = tbPlussShopStaffRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<TbPlussShopStaff> page = tbPlussShopStaffRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
@@ -94,6 +100,22 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
if (!PhoneUtil.validator(resources.getPhone())){
|
if (!PhoneUtil.validator(resources.getPhone())){
|
||||||
throw new BadRequestException("手机号格式有误");
|
throw new BadRequestException("手机号格式有误");
|
||||||
}
|
}
|
||||||
|
if (userRepository.findByUsername(resources.getAccount()) != 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("最大优惠金额过大");
|
||||||
|
}
|
||||||
|
|
||||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||||
|
|
||||||
//添加收银系统后台账号
|
//添加收银系统后台账号
|
||||||
@@ -116,11 +138,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
|
|
||||||
Set<Role> roles = new HashSet<>();
|
Set<Role> roles = new HashSet<>();
|
||||||
Role role = new Role();
|
Role role = new Role();
|
||||||
if(resources.getRoleId()!=null){
|
|
||||||
role.setId(resources.getRoleId());
|
role.setId(resources.getRoleId());
|
||||||
}else {
|
|
||||||
role.setId(2l);
|
|
||||||
}
|
|
||||||
roles.add(role);
|
roles.add(role);
|
||||||
user.setRoles(roles);
|
user.setRoles(roles);
|
||||||
|
|
||||||
@@ -136,8 +154,21 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(TbPlussShopStaff resources) {
|
public void update(TbPlussShopStaff resources) {
|
||||||
|
if (StringUtils.isBlank(resources.getPassword())) {
|
||||||
|
resources.setPassword(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pattern.matcher(resources.getCode()).find()) {
|
||||||
|
throw new BadRequestException("员工编号不能包含中文");
|
||||||
|
}
|
||||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
|
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
|
||||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getAccount());
|
||||||
|
if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){
|
||||||
|
if (userRepository.findByUsername(resources.getAccount()) != null) {
|
||||||
|
throw new BadRequestException("员工账号不可重复");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resources.setUpdatedAt(System.currentTimeMillis());
|
||||||
ValidationUtil.isNull( tbPlussShopStaff.getId(),"TbPlussShopStaff","id",resources.getId());
|
ValidationUtil.isNull( tbPlussShopStaff.getId(),"TbPlussShopStaff","id",resources.getId());
|
||||||
tbPlussShopStaff.copy(resources);
|
tbPlussShopStaff.copy(resources);
|
||||||
if (StringUtils.isNotBlank(resources.getPassword())) {
|
if (StringUtils.isNotBlank(resources.getPassword())) {
|
||||||
@@ -145,11 +176,11 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
}
|
}
|
||||||
tbPlussShopStaffRepository.save(tbPlussShopStaff);
|
tbPlussShopStaffRepository.save(tbPlussShopStaff);
|
||||||
//修改 sysUser账号
|
//修改 sysUser账号
|
||||||
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getAccount());
|
|
||||||
Set<Role> roles = new HashSet<>();
|
Set<Role> roles = new HashSet<>();
|
||||||
Role role = new Role();
|
Role role = new Role();
|
||||||
role.setId(resources.getRoleId());
|
role.setId(resources.getRoleId());
|
||||||
roles.add(role);
|
roles.add(role);
|
||||||
|
sysUser.setUsername(resources.getAccount());
|
||||||
sysUser.setRoles(roles);
|
sysUser.setRoles(roles);
|
||||||
sysUser.setNickName(resources.getName());
|
sysUser.setNickName(resources.getName());
|
||||||
if (StringUtils.isNotBlank(resources.getPassword())) {
|
if (StringUtils.isNotBlank(resources.getPassword())) {
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||||||
TbPlussShopStaff tbPlussShopStaff = new TbPlussShopStaff();
|
TbPlussShopStaff tbPlussShopStaff = new TbPlussShopStaff();
|
||||||
tbPlussShopStaff.setShopId(String.valueOf(save.getId()));
|
tbPlussShopStaff.setShopId(String.valueOf(save.getId()));
|
||||||
tbPlussShopStaff.setType("master");
|
tbPlussShopStaff.setType("master");
|
||||||
|
tbPlussShopStaff.setName(resources.getShopName());
|
||||||
tbPlussShopStaff.setAccount(resources.getAccount());
|
tbPlussShopStaff.setAccount(resources.getAccount());
|
||||||
tbPlussShopStaff.setPassword(MD5Utils.encrypt(resources.getPassword()));
|
tbPlussShopStaff.setPassword(MD5Utils.encrypt(resources.getPassword()));
|
||||||
tbPlussShopStaff.setStatus(1);
|
tbPlussShopStaff.setStatus(1);
|
||||||
@@ -237,6 +238,9 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(TbShopInfo resources) {
|
public void update(TbShopInfo resources) {
|
||||||
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
|
TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new);
|
||||||
|
if (!resources.getShopName().equals(tbShopInfo.getShopName())) {
|
||||||
|
shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString());
|
||||||
|
}
|
||||||
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
|
ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId());
|
||||||
tbShopInfo.copy(resources);
|
tbShopInfo.copy(resources);
|
||||||
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
|
tbShopInfo.setUpdatedAt(Instant.now().toEpochMilli());
|
||||||
|
|||||||
Reference in New Issue
Block a user