diff --git a/eladmin-logging/src/main/java/cn/ysk/cashier/aspect/LogAspect.java b/eladmin-logging/src/main/java/cn/ysk/cashier/aspect/LogAspect.java index 5d0446e7..75813f21 100644 --- a/eladmin-logging/src/main/java/cn/ysk/cashier/aspect/LogAspect.java +++ b/eladmin-logging/src/main/java/cn/ysk/cashier/aspect/LogAspect.java @@ -78,12 +78,14 @@ public class LogAspect { Object o = redisUtils.get("online-token-"+getToken(request)); JSONObject jsonObject = null; Integer shopId = null; - if (o!= null){ + String nickName = ""; + if (o != null) { String jsonString = JSON.toJSONString(o); jsonObject = JSONObject.parseObject(jsonString); - shopId = (Integer)jsonObject.get("shopId"); + shopId = (Integer) jsonObject.get("shopId"); + nickName = jsonObject.get("nickName") == null ? "" : jsonObject.get("nickName").toString(); } - logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log, shopId); + logService.save(nickName+":"+getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log, shopId); return result; } @@ -110,6 +112,7 @@ public class LogAspect { logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log, shopId); } + public String getUsername() { try { return SecurityUtils.getCurrentUsername(); @@ -117,6 +120,7 @@ public class LogAspect { return ""; } } + public String getToken(HttpServletRequest request) { final String requestHeader = request.getHeader("Authorization"); if (requestHeader != null && requestHeader.startsWith("Bearer")) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/config/SpringSecurityConfig.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/config/SpringSecurityConfig.java index 513949f0..7d9da724 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/config/SpringSecurityConfig.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/config/SpringSecurityConfig.java @@ -137,6 +137,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { // 所有类型的接口都放行 .antMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll() .antMatchers("/auth/appletsLogin").permitAll() + .antMatchers("/api/tbHandover").permitAll() // 所有请求都需要认证 .anyRequest().authenticated() .and().apply(securityConfigurerAdapter()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java index 3080fe98..f5ab968d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java @@ -16,9 +16,12 @@ package cn.ysk.cashier.config.security.rest; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.config.security.config.bean.LoginCodeEnum; import cn.ysk.cashier.config.security.security.TokenProvider; +import cn.ysk.cashier.pojo.shop.TbMerchantAccount; import cn.ysk.cashier.pojo.shop.TbPlussShopStaff; +import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository; import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository; import cn.ysk.cashier.utils.*; import com.wf.captcha.base.Captcha; @@ -75,6 +78,8 @@ public class AuthorizationController { private final AuthenticationManagerBuilder authenticationManagerBuilder; private final TbShopInfoRepository tbShopInfoRepository; private final TbPlussShopStaffRepository staffRepository; + private final TbMerchantAccountRepository tbMerchantAccountRepository; + @Resource private LoginProperties loginProperties; @@ -93,9 +98,23 @@ public class AuthorizationController { if (authUser.isChecked() && StringUtils.isBlank(authUser.getCode()) || authUser.isChecked() && !authUser.getCode().equalsIgnoreCase(code)) { throw new BadRequestException("验证码错误"); } + String loginpre=""; + // 判断是否是员工登录 + if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) { + if (StrUtil.isBlank(authUser.getMerchantName())) { + throw new BadRequestException("商户名称不能为空"); + } + + TbMerchantAccount merchant = tbMerchantAccountRepository.findByAccount(authUser.getMerchantName()); + if (merchant == null) { + throw new BadRequestException("商户不存在"); + } + loginpre=merchant.getShopId() + "@"; + } + //生成token UsernamePasswordAuthenticationToken authenticationToken = - new UsernamePasswordAuthenticationToken(authUser.getUsername(), password); + new UsernamePasswordAuthenticationToken(loginpre+authUser.getUsername(), password); Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); SecurityContextHolder.getContext().setAuthentication(authentication); // 生成令牌与第三方系统获取令牌方式 @@ -104,7 +123,7 @@ public class AuthorizationController { // SecurityContextHolder.getContext().setAuthentication(authentication); final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal(); // TbShopInfo byAccount = tbShopInfoRepository.findByAccount(jwtUserDto.getUsername()); - TbPlussShopStaff tbPlussShopStaff = staffRepository.queryByAccount(jwtUserDto.getUsername()); + TbPlussShopStaff tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername()); if (tbPlussShopStaff != null && tbPlussShopStaff.getType().equals("staff")) { Integer isManage = tbPlussShopStaff.getIsManage(); if (isManage != null && isManage != 1) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/dto/AuthUserDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/dto/AuthUserDto.java index 147abc97..305d7e60 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/dto/AuthUserDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/service/dto/AuthUserDto.java @@ -33,6 +33,10 @@ public class AuthUserDto { @NotBlank private String password; + private String merchantName; + + private String loginType = "merchant"; + private String code; private String uuid = ""; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java index e7f333fb..30993bbf 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/SuppFlow.java @@ -25,6 +25,8 @@ public class SuppFlow implements Serializable { private List list; + private String remark; + @Data diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConCheckController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConCheckController.java index 106bc4a4..3c48f2db 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConCheckController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConCheckController.java @@ -34,7 +34,6 @@ public class TbConCheckController { } @GetMapping - @Log("查询盘点耗材") @ApiOperation("查询盘点耗材") public ResponseEntity queryTbConCheck(TbConCheckQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbConCheckService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConUnitController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConUnitController.java index 4fef292f..1b572f8c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConUnitController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConUnitController.java @@ -37,7 +37,6 @@ public class TbConUnitController { } @GetMapping - @Log("查询耗材单位添加") @ApiOperation("查询耗材单位添加") public ResponseEntity queryTbConUnit(TbConUnitQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbConUnitService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoController.java index 4c7a5062..7c50ba9a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoController.java @@ -41,7 +41,6 @@ public class TbConsInfoController { } @GetMapping - @Log("查询耗材信息") @ApiOperation("查询耗材信息") public ResponseEntity queryTbConsInfo(TbConsInfoQueryCriteria criteria, Pageable pageable){ pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("createTime").descending()); @@ -75,6 +74,7 @@ public class TbConsInfoController { @Log("耗材出入库") @ApiOperation("耗材出入库") public ResponseEntity stockInOut(@Validated @RequestBody SuppFlow resources) throws Exception { + tbConsInfoService.stockInOut(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoFlowController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoFlowController.java index 7be90f0f..64acbc06 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoFlowController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsInfoFlowController.java @@ -34,7 +34,6 @@ public class TbConsInfoFlowController { } @GetMapping - @Log("查询耗材流水") @ApiOperation("查询耗材流水") public ResponseEntity queryTbConsInfoFlow(TbConsInfoFlowQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbConsInfoFlowService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsSuppFlowController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsSuppFlowController.java index c644ce8b..0403ad4b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsSuppFlowController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsSuppFlowController.java @@ -34,7 +34,6 @@ public class TbConsSuppFlowController { } @GetMapping - @Log("查询入库记录") @ApiOperation("查询入库记录") public ResponseEntity queryTbConsSuppFlow(TbConsSuppFlowQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbConsSuppFlowService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsTypeController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsTypeController.java index 425593e5..5b28b4b1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsTypeController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbConsTypeController.java @@ -35,7 +35,6 @@ public class TbConsTypeController { } @GetMapping - @Log("查询耗材类型") @ApiOperation("查询耗材类型") public ResponseEntity queryTbConsType(TbConsTypeQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbConsTypeService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbHandoverController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbHandoverController.java index baafaa7c..453d4789 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbHandoverController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbHandoverController.java @@ -34,19 +34,11 @@ public class TbHandoverController { } @GetMapping - @Log("查询查询交班记录") @ApiOperation("查询查询交班记录") public ResponseEntity queryTbHandover(TbHandoverQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbHandoverService.queryAll(criteria,pageable),HttpStatus.OK); } - @PostMapping - @Log("新增查询交班记录") - @ApiOperation("新增查询交班记录") - public ResponseEntity createTbHandover(@Validated @RequestBody TbHandover resources){ - return new ResponseEntity<>(tbHandoverService.create(resources),HttpStatus.CREATED); - } - @PutMapping @Log("修改查询交班记录") @ApiOperation("修改查询交班记录") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbProskuConController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbProskuConController.java index 7311119b..c4a46071 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbProskuConController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/TbProskuConController.java @@ -37,7 +37,6 @@ public class TbProskuConController { } @GetMapping - @Log("查询商品规格耗材信息") @ApiOperation("查询商品规格耗材信息") public ResponseEntity queryTbProskuCon(TbProskuConQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbProskuConService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConInfoFlowController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConInfoFlowController.java index e5558da6..8de657ce 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConInfoFlowController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConInfoFlowController.java @@ -34,7 +34,6 @@ public class ViewConInfoFlowController { } @GetMapping - @Log("查询获取耗材流水信息") @ApiOperation("查询获取耗材流水信息") public ResponseEntity queryViewConInfoFlow(ViewConInfoFlowQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(viewConInfoFlowService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConSkuController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConSkuController.java index 276aa1cd..473a08de 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConSkuController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConSkuController.java @@ -34,7 +34,6 @@ public class ViewConSkuController { } @GetMapping - @Log("查询查询耗材规格信息") @ApiOperation("查询查询耗材规格信息") public ResponseEntity queryViewConSku(ViewConSkuQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(viewConSkuService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConsSuppFlowController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConsSuppFlowController.java index b1c72be8..2c51372b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConsSuppFlowController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewConsSuppFlowController.java @@ -34,7 +34,6 @@ public class ViewConsSuppFlowController { } @GetMapping - @Log("查询出入库记录") @ApiOperation("查询出入库记录") public ResponseEntity queryViewConsSuppFlow(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(viewConsSuppFlowService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewProductSkuShopController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewProductSkuShopController.java index a3ed039c..862f8f6b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewProductSkuShopController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewProductSkuShopController.java @@ -34,7 +34,6 @@ public class ViewProductSkuShopController { } @GetMapping - @Log("查询商品规格信息查询") @ApiOperation("查询商品规格信息查询") public ResponseEntity queryViewProductSkuShop(ViewProductSkuShopQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(viewProductSkuShopService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbHandoverQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbHandoverQueryCriteria.java index aae144bb..d177bc98 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbHandoverQueryCriteria.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/TbHandoverQueryCriteria.java @@ -12,8 +12,8 @@ import cn.ysk.cashier.annotation.Query; public class TbHandoverQueryCriteria{ /** 精确 */ - @Query - private String tradeDay; + @Query(type = Query.Type.BETWEEN) + private List tradeDay; /** 精确 */ @Query diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index 8bd53ce1..acdb3836 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -175,6 +175,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { @Override @Transactional(rollbackFor = Exception.class) public void stockInOut(SuppFlow resources) throws Exception { + log.info("resources:{}",JSON.toJSONString(resources)); if (Objects.isNull(resources)) { throw new Exception("参数错误"); } @@ -198,7 +199,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { operatorSnapMap.put("account", tbShopInfo.getAccount()); stockOperate.setOperatorSnap(JSON.toJSONString(operatorSnapMap)); - stockOperate.setRemark(""); + stockOperate.setRemark(resources.getRemark()); stockOperate.setStockTime(System.currentTimeMillis()); stockOperate.setCreatedAt(System.currentTimeMillis()); stockOperate.setUpdatedAt(System.currentTimeMillis()); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java index dbf8901f..bebca5c4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java @@ -113,7 +113,8 @@ public class StockController { return new ResponseEntity<>(dataMap, HttpStatus.OK); } - @AnonymousAccess + + @Log("商品库存:上下架商品") @PutMapping("/grounding") @ApiOperation("上下架商品") public ResponseEntity grounding( @@ -140,6 +141,7 @@ public class StockController { return new ResponseEntity<>(HttpStatus.OK); } + @Log("商品库存:修改商品状态") @PutMapping("productStatus") public ResponseEntity updateProductStatus(@RequestBody StockUpdateValueVO updateValueVO) { stockService.updateProductStatus(updateValueVO); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbCouponCategoryController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbCouponCategoryController.java index a6fc4257..8a33c94a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbCouponCategoryController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbCouponCategoryController.java @@ -26,7 +26,6 @@ public class TbCouponCategoryController { private final TbCouponCategoryService tbCouponCategoryService; @GetMapping - @Log("查询团购卷类别") @ApiOperation("查询团购卷类别") public ResponseEntity queryTbCouponCategory(TbCouponCategoryQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(tbCouponCategoryService.queryAll(criteria,pageable),HttpStatus.OK); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/StockCountDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/StockCountDTO.java index 159f8ea6..bb38e71c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/StockCountDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/StockCountDTO.java @@ -17,4 +17,5 @@ public class StockCountDTO { private String specSnap; private Integer stockCount; private Integer stockNumber; + private String specSnap; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java index b19fe427..4c66cfcf 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProductSku.java @@ -129,7 +129,7 @@ public class TbProductSku implements Serializable { @Column(name = "`is_grounding`") @ApiModelProperty(value = "是否上架") - private Integer isGrounding = 0; + private Integer isGrounding; public void setIsDel(Integer isDel) { if(isDel!=null){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java index aa50c29b..01e2ae64 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/product/TbProductRepository.java @@ -58,4 +58,8 @@ public interface TbProductRepository extends JpaRepository, @Query("select product from TbProduct product where product.id=:id and product.shopId=:shopId") TbProduct selectByShopIdAndId(Integer id, String shopId); + + @Query("select product from TbProduct product where product.shopId=:shopId") + List selectByShopId(String shopId); + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java index 95aebda8..1fbab89b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/order/TbOrderInfoServiceImpl.java @@ -409,7 +409,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { case "offline": tbOrderInfo.setOrderType("线下"); break; - case "return ": + case "return": tbOrderInfo.setOrderType("退单"); break; default: @@ -466,7 +466,6 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { map.put("支付类型", tbOrderInfo.getPayType()); map.put("订单金额", tbOrderInfo.getOrderAmount()); - map.put("退单金额", tbOrderInfo.getRefundAmount()); map.put("支付金额", tbOrderInfo.getPayAmount()); switch (tbOrderInfo.getStatus()) { case "unpaid": @@ -485,6 +484,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService { tbOrderInfo.setStatus("申请退单中"); break; case "refund": + map.put("支付金额", "-"+tbOrderInfo.getPayAmount()); tbOrderInfo.setStatus("退单完成"); break; case "cancelled": diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index 489982b2..7d6993f6 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -373,6 +373,9 @@ public class TbProductServiceImpl implements TbProductService { } } } + + // 默认开启共享库存和库存 +// product.setIsDistribute(1); TbProduct save = tbProductRepository.save(product); if (save.getId() == null) { throw new BadRequestException("添加商品失败"); @@ -381,12 +384,24 @@ public class TbProductServiceImpl implements TbProductService { tbProductRepository.save(save); //sku if (resources.getSkuList() != null) { + Integer warnLine = 0; + List productList = tbProductRepository.selectByShopId(resources.getShopId()); + if (!productList.isEmpty()) { + TbProduct p = productList.get(0); + List productSkus = tbProductSkuRepository.searchSku(p.getId().toString()); + if (!productSkus.isEmpty()) { + warnLine = productSkus.get(0).getWarnLine(); + } + } + List skuList = new ArrayList<>(); for (TbProductSku sku : resources.getSkuList()) { sku.setProductId(String.valueOf(save.getId())); sku.setShopId(save.getShopId()); sku.setCreatedAt(Instant.now().toEpochMilli()); sku.setUpdatedAt(Instant.now().toEpochMilli()); + sku.setIsGrounding(1); + sku.setWarnLine(warnLine); skuList.add(sku); } List tbProductSkus = tbProductSkuRepository.saveAll(skuList); @@ -476,13 +491,28 @@ public class TbProductServiceImpl implements TbProductService { // } // } if ("sku".equals(save.getTypeEnum())) { - List collect = resources.getSkuList().stream().map(TbProductSku::getId).collect(Collectors.toList()); +// List collect = resources.getSkuList().stream().map(TbProductSku::getId).collect(Collectors.toList()); List tbProductSkus = tbProductSkuRepository.searchSku(resources.getId().toString()); + List collect = tbProductSkus.stream().map(TbProductSku::getId).collect(Collectors.toList()); + HashMap skuInfo = new HashMap<>(); for (TbProductSku productSkus : tbProductSkus) { - if (!collect.contains(productSkus.getId())) { - tbProductSkuRepository.deleteBySkuId(productSkus.getId()); + skuInfo.put(productSkus.getId().toString(), productSkus); + } + for (TbProductSku tbProductSku : resources.getSkuList()) { + if (!collect.contains(tbProductSku.getId())) { + tbProductSkuRepository.deleteBySkuId(tbProductSku.getId()); + }else { + TbProductSku productSku = skuInfo.get(tbProductSku.getId().toString()); + if (productSku != null) { + tbProductSku.setIsGrounding(productSku.getIsGrounding()); + } } } +// for (TbProductSku productSkus : tbProductSkus) { +// if (!collect.contains(productSkus.getId())) { +// tbProductSkuRepository.deleteBySkuId(productSkus.getId()); +// } +// } } tbProductSkuRepository.saveAll(resources.getSkuList()); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java index 1691e564..187f2411 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java @@ -84,7 +84,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).orElseGet(TbPlussShopStaff::new); ValidationUtil.isNull(tbPlussShopStaff.getId(),"TbPlussShopStaff","id",id); TbPlussShopStaffDto dto = tbPlussShopStaffMapper.toDto(tbPlussShopStaff); - UserDto userDto = userService.findByName(tbPlussShopStaff.getAccount()); + UserDto userDto = userService.findByName(tbPlussShopStaff.getShopId()+"@"+tbPlussShopStaff.getAccount()); // dto.setUser(userDto); if(!CollectionUtils.isEmpty(userDto.getRoles())){ dto.setRoleId(userDto.getRoles().stream().findFirst().get().getId()); @@ -115,7 +115,6 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) { throw new BadRequestException("最大优惠金额过大"); } - resources.setCreatedAt(Instant.now().toEpochMilli()); //添加收银系统后台账号 @@ -127,7 +126,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { user.setPassword(passwordEncoder.encode(resources.getPassword())); resources.setPassword(MD5Utils.md5(resources.getPassword())); } - user.setUsername(resources.getAccount()); + user.setUsername(resources.getShopId() + "@" +resources.getAccount()); user.setNickName(resources.getName()); user.setPhone(resources.getPhone()); user.setEnabled(true); @@ -162,9 +161,9 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { throw new BadRequestException("员工编号不能包含中文"); } TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new); - User sysUser = userRepository.findByUsername(tbPlussShopStaff.getAccount()); + User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount()); if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){ - if (userRepository.findByUsername(resources.getAccount()) != null) { + if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) { throw new BadRequestException("员工账号不可重复"); } } @@ -180,7 +179,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { Role role = new Role(); role.setId(resources.getRoleId()); roles.add(role); - sysUser.setUsername(resources.getAccount()); + sysUser.setUsername(resources.getShopId()+"@"+resources.getAccount()); sysUser.setRoles(roles); sysUser.setNickName(resources.getName()); if (StringUtils.isNotBlank(resources.getPassword())) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java index 59f2e184..0fad205e 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopInfoServiceImpl.java @@ -178,6 +178,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { User user = new User(); user.setPassword(passwordEncoder.encode(resources.getPassword())); user.setUsername(resources.getAccount()); + user.setNickName(resources.getShopName()); user.setPhone(resources.getPhone()); user.setCreateBy("admin"); user.setEnabled(true); @@ -240,6 +241,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { TbShopInfo tbShopInfo = tbShopInfoRepository.findById(resources.getId()).orElseGet(TbShopInfo::new); if (!resources.getShopName().equals(tbShopInfo.getShopName())) { shopStaffRepository.updateNameById(resources.getShopName(),resources.getId().toString()); + userRepository.updateNickName(resources.getAccount(),resources.getShopName()); } ValidationUtil.isNull( tbShopInfo.getId(),"TbShopInfo","id",resources.getId()); tbShopInfo.copy(resources); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/system/repository/UserRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/system/repository/UserRepository.java index 5d5afe4b..779fa5af 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/system/repository/UserRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/system/repository/UserRepository.java @@ -65,6 +65,10 @@ public interface UserRepository extends JpaRepository, JpaSpecificat @Query(value = "update sys_user set enabled = 0 where username = ?1",nativeQuery = true) void upEnableByusername(String username); + @Modifying + @Query(value = "update sys_user set nick_name = ?2 where username = ?1",nativeQuery = true) + void updateNickName(String username, String nickName); + /** * 修改邮箱 * @param username 用户名 diff --git a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl index 8b863d9f..ada29d7f 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl @@ -34,7 +34,6 @@ public class ${className}Controller { } @GetMapping - @Log("查询${apiAlias}") @ApiOperation("查询${apiAlias}") public ResponseEntity query${className}(${className}QueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);