Merge remote-tracking branch 'origin/dev'
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@
|
|||||||
/.gradle/
|
/.gradle/
|
||||||
/application.pid
|
/application.pid
|
||||||
*.log
|
*.log
|
||||||
|
logs/*
|
||||||
@@ -22,6 +22,8 @@ package cn.ysk.cashier.utils;
|
|||||||
*/
|
*/
|
||||||
public interface CacheKey {
|
public interface CacheKey {
|
||||||
|
|
||||||
|
String ONLINE_ADMIN = "ONLINE_ADMIN:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 激活码
|
* 激活码
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,14 +17,19 @@ package cn.ysk.cashier.utils;
|
|||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.poi.excel.BigExcelWriter;
|
import cn.hutool.poi.excel.BigExcelWriter;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
|
import cn.hutool.poi.excel.ExcelWriter;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -32,6 +37,7 @@ import java.io.*;
|
|||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -231,6 +237,79 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
IoUtil.close(out);
|
IoUtil.close(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 输入标题到excel
|
||||||
|
*
|
||||||
|
* @param writer excel对象
|
||||||
|
* @param column 当前列位置
|
||||||
|
* @param cellValue 标题内容
|
||||||
|
* @param requiredFlag 是否标红
|
||||||
|
*/
|
||||||
|
private static void writeCell(ExcelWriter writer, int column, int row, String cellValue, boolean requiredFlag) {
|
||||||
|
// 根据x,y轴设置单元格内容
|
||||||
|
if (StrUtil.isNotBlank(cellValue)) {
|
||||||
|
writer.writeCellValue(column, row, cellValue);
|
||||||
|
}
|
||||||
|
Font font = writer.createFont();
|
||||||
|
font.setColor(Font.COLOR_RED);
|
||||||
|
if (requiredFlag) {
|
||||||
|
// 根据x,y轴获取当前单元格样式
|
||||||
|
CellStyle cellStyle = writer.createCellStyle(column, row);
|
||||||
|
// 内容水平居中
|
||||||
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
// 内容垂直居中
|
||||||
|
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
// 设置边框
|
||||||
|
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
// 字体颜色标红
|
||||||
|
// cellStyle.setFont(font);
|
||||||
|
cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
|
||||||
|
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void downloadExcelAndMerge(List<Map<String, Object>> list, int colSize, HttpServletResponse response, ArrayList<Integer> mergeRowIndex) throws IOException {
|
||||||
|
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
|
||||||
|
File file = new File(tempPath);
|
||||||
|
ExcelWriter writer = ExcelUtil.getWriter(file);
|
||||||
|
for (int i = 0; i < mergeRowIndex.size(); i++) {
|
||||||
|
|
||||||
|
int start = i == 0 ? 1 : mergeRowIndex.get(i - 1) + 1;
|
||||||
|
for (int i1 = 0; i1 < colSize; i1++) {
|
||||||
|
|
||||||
|
if (start != mergeRowIndex.get(i)) {
|
||||||
|
writer.merge(i == 0 ? 1 : mergeRowIndex.get(i - 1) + 1, mergeRowIndex.get(i), i1, i1, "", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 一次性写出内容,使用默认样式,强制输出标题
|
||||||
|
writer.write(list, true);
|
||||||
|
|
||||||
|
XSSFSheet sheet = (XSSFSheet) writer.getSheet();
|
||||||
|
// 设置列宽
|
||||||
|
for (int i = 0; i < colSize + 2; i++) {
|
||||||
|
sheet.setColumnWidth(i, 4000); // 200个字符宽度
|
||||||
|
}
|
||||||
|
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
|
||||||
|
// sheet.trackAllColumnsForAutoSizing();
|
||||||
|
//列宽自适应
|
||||||
|
// writer.autoSizeColumnAll();
|
||||||
|
//response为HttpServletResponse对象
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||||
|
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
|
||||||
|
// 将写入的Excel作为文件流写出到response
|
||||||
|
ServletOutputStream out = response.getOutputStream();
|
||||||
|
// 终止后删除临时文件
|
||||||
|
file.deleteOnExit();
|
||||||
|
writer.flush(out, true);
|
||||||
|
//此处记得关闭输出Servlet流
|
||||||
|
IoUtil.close(out);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getFileType(String type) {
|
public static String getFileType(String type) {
|
||||||
String documents = "txt doc pdf ppt pps xlsx xls docx";
|
String documents = "txt doc pdf ppt pps xlsx xls docx";
|
||||||
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
||||||
@@ -353,4 +432,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
public static String getMd5(File file) {
|
public static String getMd5(File file) {
|
||||||
return getMd5(getByte(file));
|
return getMd5(getByte(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,26 @@ public class LogServiceImpl implements LogService {
|
|||||||
String value = SpelUtil.generateKeyBySpEL(split[1], joinPoint);
|
String value = SpelUtil.generateKeyBySpEL(split[1], joinPoint);
|
||||||
// 描述
|
// 描述
|
||||||
log.setDescription(split[0] + ":" + value);
|
log.setDescription(split[0] + ":" + value);
|
||||||
|
}
|
||||||
|
if (split.length == 3) {
|
||||||
|
// String v1 = SpelUtil.generateKeyBySpEL(split[1], joinPoint);
|
||||||
|
String v2 = SpelUtil.generateKeyBySpEL(split[2], joinPoint);
|
||||||
|
if (methodName.contains("createOutAndONOperate")) {
|
||||||
|
//subType 1入库 -1出库
|
||||||
|
if ("purchase".equals(v2) || "purveyor".equals(v2)) {
|
||||||
|
v2 = "入库";
|
||||||
|
} else {
|
||||||
|
v2 = "出库";
|
||||||
|
}
|
||||||
|
}else if(methodName.contains("stockInOut")){
|
||||||
|
if (("in".equals(v2) || "purveyor".equals(v2))) {
|
||||||
|
v2 = "入库";
|
||||||
|
} else {
|
||||||
|
v2 = "出库";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 描述
|
||||||
|
log.setDescription(split[0] + ":" + v2 );
|
||||||
}else {
|
}else {
|
||||||
log.setDescription(split[0]);
|
log.setDescription(split[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- 代码生成模块 -->
|
<!-- 代码生成模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.ysk.cashier</groupId>
|
<groupId>cn.ysk.cashier</groupId>
|
||||||
@@ -39,6 +40,11 @@
|
|||||||
<version>2.6</version>
|
<version>2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>5.2.1</version>
|
||||||
|
</dependency>
|
||||||
<!-- Spring boot websocket -->
|
<!-- Spring boot websocket -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ public class AuthorizationController {
|
|||||||
put("user", jwtUserDto);
|
put("user", jwtUserDto);
|
||||||
if (byAccount != null) {
|
if (byAccount != null) {
|
||||||
put("shopId", byAccount.getId());
|
put("shopId", byAccount.getId());
|
||||||
|
put("loginType", org.apache.commons.lang3.StringUtils.isNotBlank(authUser.getLoginType())?authUser.getLoginType():"merchant");
|
||||||
put("shopName", byAccount.getShopName());
|
put("shopName", byAccount.getShopName());
|
||||||
put("logo", byAccount.getLogo());
|
put("logo", byAccount.getLogo());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ public class TbConsSuppFlow implements Serializable {
|
|||||||
@ApiModelProperty(value = "productId")
|
@ApiModelProperty(value = "productId")
|
||||||
private Integer productId;
|
private Integer productId;
|
||||||
|
|
||||||
@Column(name = "`supplier_id`",nullable = false)
|
@Column(name = "`supplier_id`")
|
||||||
@NotNull
|
|
||||||
@ApiModelProperty(value = "supplierId")
|
@ApiModelProperty(value = "supplierId")
|
||||||
private Integer supplierId;
|
private Integer supplierId;
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class TbConsInfoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "stockInOut")
|
@PostMapping(value = "stockInOut")
|
||||||
@Log("耗材出入库")
|
@Log("耗材::#resources.type")
|
||||||
@ApiOperation("耗材出入库")
|
@ApiOperation("耗材出入库")
|
||||||
public ResponseEntity<Object> stockInOut(@Validated @RequestBody SuppFlow resources) throws Exception {
|
public ResponseEntity<Object> stockInOut(@Validated @RequestBody SuppFlow resources) throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package cn.ysk.cashier.cons.service.impl;
|
|||||||
|
|
||||||
import cn.ysk.cashier.cons.domain.TbConCheck;
|
import cn.ysk.cashier.cons.domain.TbConCheck;
|
||||||
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
import cn.ysk.cashier.cons.domain.TbConsInfo;
|
||||||
|
import cn.ysk.cashier.cons.domain.TbConsInfoFlow;
|
||||||
|
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository;
|
||||||
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
|
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
|
||||||
import cn.ysk.cashier.utils.FileUtil;
|
import cn.ysk.cashier.utils.FileUtil;
|
||||||
import cn.ysk.cashier.utils.PageUtil;
|
import cn.ysk.cashier.utils.PageUtil;
|
||||||
@@ -39,6 +41,8 @@ public class TbConCheckServiceImpl implements TbConCheckService {
|
|||||||
|
|
||||||
private final TbConsInfoRepository tbConsInfoRepository;
|
private final TbConsInfoRepository tbConsInfoRepository;
|
||||||
|
|
||||||
|
public final TbConsInfoFlowRepository tbConsInfoFlowRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> queryAll(TbConCheckQueryCriteria criteria, Pageable pageable){
|
public Map<String,Object> queryAll(TbConCheckQueryCriteria criteria, Pageable pageable){
|
||||||
Page<TbConCheck> page = tbConCheckRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
Page<TbConCheck> page = tbConCheckRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||||
@@ -65,20 +69,46 @@ public class TbConCheckServiceImpl implements TbConCheckService {
|
|||||||
if(Objects.isNull(consInfo)){
|
if(Objects.isNull(consInfo)){
|
||||||
throw new Exception("耗材信息不存在");
|
throw new Exception("耗材信息不存在");
|
||||||
}
|
}
|
||||||
|
TbConsInfoFlow flow=new TbConsInfoFlow();
|
||||||
|
|
||||||
BigDecimal stonum=consInfo.getStockNumber().subtract(consInfo.getStockConsume());
|
if(consInfo.getStockNumber().compareTo(resources.getStockNumber())>=0){
|
||||||
|
flow.setBizCode("checkStockOut");
|
||||||
|
flow.setBizName("盘点出库");
|
||||||
|
flow.setBizType("-");
|
||||||
|
}else {
|
||||||
|
flow.setBizCode("checkStockIn");
|
||||||
|
flow.setBizName("盘点入库");
|
||||||
|
flow.setBizType("+");
|
||||||
|
}
|
||||||
|
|
||||||
consInfo.setStockConsume(consInfo.getStockConsume().add(resources.getLpNum().negate()));
|
|
||||||
|
consInfo.setStockConsume(BigDecimal.ZERO);
|
||||||
|
consInfo.setStockNumber(resources.getStockNumber());
|
||||||
consInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
consInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
tbConsInfoRepository.save(consInfo);
|
tbConsInfoRepository.save(consInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
flow.setConsId(consInfo.getId());
|
||||||
|
flow.setShopId(consInfo.getShopId());
|
||||||
|
flow.setConName(consInfo.getConName());
|
||||||
|
flow.setAmount(consInfo.getStockNumber());
|
||||||
|
flow.setBalance(consInfo.getStockNumber());
|
||||||
|
|
||||||
|
flow.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
tbConsInfoFlowRepository.save(flow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TbConCheck conCheck=new TbConCheck();
|
TbConCheck conCheck=new TbConCheck();
|
||||||
|
|
||||||
conCheck.setConInfoId(consInfo.getId());
|
conCheck.setConInfoId(consInfo.getId());
|
||||||
conCheck.setConName(consInfo.getConName());
|
conCheck.setConName(consInfo.getConName());
|
||||||
conCheck.setPrice(consInfo.getPrice());
|
conCheck.setPrice(consInfo.getPrice());
|
||||||
conCheck.setAcStockNumber(consInfo.getStockNumber().subtract(consInfo.getStockConsume()));
|
conCheck.setAcStockNumber(resources.getStockNumber());
|
||||||
conCheck.setStockNumber(stonum);
|
conCheck.setStockNumber(resources.getStockNumber());
|
||||||
conCheck.setLpNum(resources.getLpNum());
|
conCheck.setLpNum(resources.getLpNum());
|
||||||
conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum()));
|
conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum()));
|
||||||
conCheck.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
conCheck.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
|||||||
@@ -184,13 +184,17 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
if (Objects.isNull(tbShopInfo)) {
|
if (Objects.isNull(tbShopInfo)) {
|
||||||
throw new Exception("店铺信息不存在");
|
throw new Exception("店铺信息不存在");
|
||||||
}
|
}
|
||||||
TbShopPurveyor purveyor = tbShopPurveyorRepository.getById(resources.getSupplierId());
|
|
||||||
if (Objects.isNull(purveyor)) {
|
TbShopPurveyor purveyor=null;
|
||||||
throw new Exception("不存在的供应商");
|
TbProductStockOperate stockOperate = new TbProductStockOperate();
|
||||||
|
if(Objects.nonNull(resources.getSupplierId())){
|
||||||
|
purveyor = tbShopPurveyorRepository.getById(resources.getSupplierId());
|
||||||
|
if (Objects.nonNull(purveyor)) {
|
||||||
|
stockOperate.setPurveyorId(resources.getSupplierId().toString());
|
||||||
|
stockOperate.setPurveyorName(purveyor.getPurveyorName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TbProductStockOperate stockOperate = new TbProductStockOperate();
|
|
||||||
stockOperate.setShopId(tbShopInfo.getId().toString());
|
stockOperate.setShopId(tbShopInfo.getId().toString());
|
||||||
stockOperate.setStockSnap("");
|
stockOperate.setStockSnap("");
|
||||||
stockOperate.setType(resources.getType().equals("in")?"cons_in":"cons_out");
|
stockOperate.setType(resources.getType().equals("in")?"cons_in":"cons_out");
|
||||||
@@ -204,8 +208,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
stockOperate.setCreatedAt(System.currentTimeMillis());
|
stockOperate.setCreatedAt(System.currentTimeMillis());
|
||||||
stockOperate.setUpdatedAt(System.currentTimeMillis());
|
stockOperate.setUpdatedAt(System.currentTimeMillis());
|
||||||
stockOperate.setStatus("normal");
|
stockOperate.setStatus("normal");
|
||||||
stockOperate.setPurveyorId(resources.getSupplierId().toString());
|
|
||||||
stockOperate.setPurveyorName(purveyor.getPurveyorName());
|
|
||||||
JSONArray array=new JSONArray();
|
JSONArray array=new JSONArray();
|
||||||
|
|
||||||
|
|
||||||
@@ -224,15 +227,15 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||||||
|
|
||||||
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
|
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
|
||||||
purveyorTransact.setShopId(tbShopInfo.getId().toString());
|
purveyorTransact.setShopId(tbShopInfo.getId().toString());
|
||||||
purveyorTransact.setPurveyorName(purveyor.getPurveyorName());
|
purveyorTransact.setPurveyorName(Objects.isNull(purveyor)?"":purveyor.getPurveyorName());
|
||||||
purveyorTransact.setPurveyorId(purveyor.getId().toString());
|
purveyorTransact.setPurveyorId(Objects.isNull(purveyor)?"":purveyor.getId().toString());
|
||||||
purveyorTransact.setRemark("");
|
purveyorTransact.setRemark(resources.getRemark());
|
||||||
purveyorTransact.setCreatedAt(System.currentTimeMillis());
|
purveyorTransact.setCreatedAt(System.currentTimeMillis());
|
||||||
purveyorTransact.setUpdatedAt(System.currentTimeMillis());
|
purveyorTransact.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
|
||||||
suppFlow.setConInfoId(info.getConTypeId());
|
suppFlow.setConInfoId(info.getConTypeId());
|
||||||
suppFlow.setShopId(resources.getShopId());
|
suppFlow.setShopId(resources.getShopId());
|
||||||
suppFlow.setSupplierId(resources.getSupplierId());
|
suppFlow.setSupplierId(Objects.isNull(resources.getSupplierId())?0: resources.getSupplierId());
|
||||||
suppFlow.setType(resources.getType());
|
suppFlow.setType(resources.getType());
|
||||||
suppFlow.setStockNumber(conInfos.getStockNumber());
|
suppFlow.setStockNumber(conInfos.getStockNumber());
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
package cn.ysk.cashier.controller.product;
|
package cn.ysk.cashier.controller.product;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.ysk.cashier.annotation.AnonymousAccess;
|
|
||||||
import cn.ysk.cashier.annotation.Log;
|
import cn.ysk.cashier.annotation.Log;
|
||||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
|
||||||
import cn.ysk.cashier.dto.product.StockQueryDto;
|
import cn.ysk.cashier.dto.product.StockQueryDto;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.service.product.StockService;
|
import cn.ysk.cashier.service.product.StockService;
|
||||||
import cn.ysk.cashier.utils.BeanUtil;
|
import cn.ysk.cashier.utils.BeanUtil;
|
||||||
import cn.ysk.cashier.utils.SecurityUtils;
|
|
||||||
import cn.ysk.cashier.vo.StockPageImpl;
|
|
||||||
import cn.ysk.cashier.vo.StockUpdateValueVO;
|
import cn.ysk.cashier.vo.StockUpdateValueVO;
|
||||||
import cn.ysk.cashier.vo.StockUpdateWarnLineVO;
|
import cn.ysk.cashier.vo.StockUpdateWarnLineVO;
|
||||||
import cn.ysk.cashier.vo.StockV2Vo;
|
import cn.ysk.cashier.vo.StockV2Vo;
|
||||||
@@ -18,15 +14,12 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ public class TbProductController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/isHot")
|
@GetMapping("/isHot")
|
||||||
public ResponseEntity<Object> updateIsHot(@RequestParam String shopId, @RequestParam Integer id){
|
public ResponseEntity<Object> updateIsHot(@RequestParam Integer isHot, @RequestParam Integer id){
|
||||||
tbProductService.updateIsHot(id,shopId);
|
tbProductService.updateIsHot(id,isHot);
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class TbProductStockOperateController {
|
|||||||
|
|
||||||
@PostMapping("/outAndOn")
|
@PostMapping("/outAndOn")
|
||||||
@ApiOperation("新增/product/StockOperate")
|
@ApiOperation("新增/product/StockOperate")
|
||||||
@Log("出入库")
|
@Log("商品::#outAndOnDto.type")
|
||||||
// @PreAuthorize("@el.check('tbProductStockOperate:add')")
|
// @PreAuthorize("@el.check('tbProductStockOperate:add')")
|
||||||
public ResponseEntity<Object> createOutAndONOperate(@RequestBody OutAndOnDto outAndOnDto){
|
public ResponseEntity<Object> createOutAndONOperate(@RequestBody OutAndOnDto outAndOnDto){
|
||||||
return new ResponseEntity<>(tbProductStockOperateService.createOutAndONOperate(outAndOnDto),HttpStatus.CREATED);
|
return new ResponseEntity<>(tbProductStockOperateService.createOutAndONOperate(outAndOnDto),HttpStatus.CREATED);
|
||||||
|
|||||||
@@ -1,25 +1,9 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.ysk.cashier.controller.shop;
|
package cn.ysk.cashier.controller.shop;
|
||||||
|
|
||||||
import cn.ysk.cashier.annotation.Log;
|
import cn.ysk.cashier.annotation.Log;
|
||||||
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||||
import cn.ysk.cashier.service.shop.TbPlussShopStaffService;
|
import cn.ysk.cashier.service.shop.TbPlussShopStaffService;
|
||||||
import cn.ysk.cashier.dto.shop.TbPlussShopStaffQueryCriteria;
|
import cn.ysk.cashier.dto.shop.TbPlussShopStaffQueryCriteria;
|
||||||
import io.swagger.models.auth.In;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -91,4 +75,15 @@ public class TbPlussShopStaffController {
|
|||||||
tbPlussShopStaffService.deleteAll(ids);
|
tbPlussShopStaffService.deleteAll(ids);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ApiOperation("修改个人密码")
|
||||||
|
// @PostMapping(value = "/upPass")
|
||||||
|
// @AnonymousPostMapping
|
||||||
|
// public ResponseEntity<Object> upshopStaffPass(HttpServletRequest request, @RequestBody Map<String, String> map){
|
||||||
|
// tbShopInfoService.upShopPass(map.get("username"),map.get("password"));
|
||||||
|
// //根据token踢出用户
|
||||||
|
// onlineUserService.logout(tokenProvider.getToken(request));
|
||||||
|
// log.info("修改商户密码成功。");
|
||||||
|
// return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ public class TbShopInfoController {
|
|||||||
public ResponseEntity<Object> upShopPass(HttpServletRequest request, @RequestBody Map<String, String> map) throws Exception {
|
public ResponseEntity<Object> upShopPass(HttpServletRequest request, @RequestBody Map<String, String> map) throws Exception {
|
||||||
tbShopInfoService.upShopPass(map.get("username"),map.get("password"));
|
tbShopInfoService.upShopPass(map.get("username"),map.get("password"));
|
||||||
//根据token踢出用户
|
//根据token踢出用户
|
||||||
// onlineUserService.logout(tokenProvider.getToken(request));
|
onlineUserService.logout(tokenProvider.getToken(request));
|
||||||
log.info("修改商户密码成功。");
|
log.info("修改商户密码成功。");
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package cn.ysk.cashier.mybatis.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商家openid信息表
|
||||||
|
* @TableName tb_shop_open_id
|
||||||
|
*/
|
||||||
|
@Table(name="tb_shop_open_id")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class TbShopOpenId implements Serializable {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已经订阅消息的商家微信号
|
||||||
|
*/
|
||||||
|
private String openId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型 -1 任意消息 0库存预警
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.ysk.cashier.mybatis.mapper;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Mapper
|
||||||
|
* @createDate 2024-08-02 10:00:27
|
||||||
|
* @Entity cn.ysk.cashier.mybatis.entity.TbShopOpenId
|
||||||
|
*/
|
||||||
|
public interface TbShopOpenIdMapper extends BaseMapper<TbShopOpenId> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Service
|
||||||
|
* @createDate 2024-08-02 10:00:27
|
||||||
|
*/
|
||||||
|
public interface TbShopOpenIdService extends IService<TbShopOpenId> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package cn.ysk.cashier.mybatis.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||||
|
import cn.ysk.cashier.mybatis.service.TbShopOpenIdService;
|
||||||
|
import cn.ysk.cashier.mybatis.mapper.TbShopOpenIdMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_shop_open_id(商家openid信息表)】的数据库操作Service实现
|
||||||
|
* @createDate 2024-08-02 10:00:27
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbShopOpenIdServiceImpl extends ServiceImpl<TbShopOpenIdMapper, TbShopOpenId>
|
||||||
|
implements TbShopOpenIdService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -3,6 +3,7 @@ package cn.ysk.cashier.repository.order;
|
|||||||
import cn.ysk.cashier.dto.product.StockCountDTO;
|
import cn.ysk.cashier.dto.product.StockCountDTO;
|
||||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||||
|
import cn.ysk.cashier.vo.TbOrderSaleVO;
|
||||||
import cn.ysk.cashier.vo.TbOrderSalesCountByDayVo;
|
import cn.ysk.cashier.vo.TbOrderSalesCountByDayVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -14,6 +15,8 @@ import org.springframework.data.jpa.repository.Query;
|
|||||||
|
|
||||||
|
|
||||||
import javax.persistence.Tuple;
|
import javax.persistence.Tuple;
|
||||||
|
import java.sql.Time;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -82,7 +85,9 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||||||
"SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END), " +
|
"SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END), " +
|
||||||
"SUM(info.num), " +
|
"SUM(info.num), " +
|
||||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.priceAmount ELSE 0 END), " +
|
"SUM(CASE WHEN orders.orderType!='return' THEN info.priceAmount ELSE 0 END), " +
|
||||||
"SUM(CASE WHEN orders.orderType='return' THEN info.priceAmount ELSE 0 END)) " +
|
"SUM(CASE WHEN orders.orderType='return' THEN info.priceAmount ELSE 0 END), " +
|
||||||
|
"info.productId, " +
|
||||||
|
"info.productSkuId ) " +
|
||||||
"FROM TbOrderInfo orders " +
|
"FROM TbOrderInfo orders " +
|
||||||
"LEFT JOIN TbOrderDetail info on orders.id=info.orderId " +
|
"LEFT JOIN TbOrderDetail info on orders.id=info.orderId " +
|
||||||
"LEFT JOIN TbProduct pro ON info.productId = pro.id " +
|
"LEFT JOIN TbProduct pro ON info.productId = pro.id " +
|
||||||
@@ -97,6 +102,20 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||||||
"ORDER BY salesNum DESC")
|
"ORDER BY salesNum DESC")
|
||||||
List<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId,@Param("cateId")String cateId,@Param("proName")String proName, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
List<TbOrderSalesCountByDayVo> queryTbOrderSalesCountByDay(@Param("shopId") Integer shopId,@Param("cateId")String cateId,@Param("proName")String proName, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||||
|
|
||||||
|
@Query(value = "SELECT " +
|
||||||
|
"new cn.ysk.cashier.vo.TbOrderSaleVO(oi.orderNo, od.num, od.price, od.status)\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
"TbOrderInfo oi\n" +
|
||||||
|
"LEFT JOIN TbOrderDetail od ON oi.id = od.orderId \n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
"od.shopId = :shopId \n" +
|
||||||
|
"AND ( od.status = 'closed' OR od.status = 'refund' ) \n" +
|
||||||
|
"AND od.createTime > :startTime \n" +
|
||||||
|
"AND od.createTime < :endTime \n" +
|
||||||
|
"AND (:productId is null or od.productId = :productId)\n" +
|
||||||
|
"AND (:productId is null or od.productSkuId = :productSkuId)")
|
||||||
|
List<TbOrderSaleVO> querySaleOrderInfo(@Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime, @Param("productId") Integer productId, @Param("productSkuId") Integer productSkuId, @Param("shopId") Integer shopId);
|
||||||
|
|
||||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||||
"COALESCE(CAST(SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as long),0), " +
|
"COALESCE(CAST(SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as long),0), " +
|
||||||
"COALESCE(CAST(SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END) as long),0))" +
|
"COALESCE(CAST(SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END) as long),0))" +
|
||||||
@@ -145,4 +164,5 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||||||
List<Integer> findOrderIdsByProductNameLike(@Param("productName") String productName, @Param("shop_id") String shopId,
|
List<Integer> findOrderIdsByProductNameLike(@Param("productName") String productName, @Param("shop_id") String shopId,
|
||||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
|
|||||||
@Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true)
|
@Query(value = "update tb_product set status = -1 where id in :productIds",nativeQuery = true)
|
||||||
@Modifying
|
@Modifying
|
||||||
void updateByStatus(List<Integer> productIds);
|
void updateByStatus(List<Integer> productIds);
|
||||||
@Query(value = "update tb_product set is_hot=1 where id = :id",nativeQuery = true)
|
@Query(value = "update tb_product set is_hot=:isHot where id = :id",nativeQuery = true)
|
||||||
@Modifying
|
@Modifying
|
||||||
void updateIsHot(@Param("id") Integer id);
|
void updateIsHot(@Param("id") Integer id,@Param("isHot")Integer isHot);
|
||||||
|
|
||||||
@Query(value = "update tb_product set is_stock=:isStock where id = :proId and shop_id=:shopId",nativeQuery = true)
|
@Query(value = "update tb_product set is_stock=:isStock where id = :proId and shop_id=:shopId",nativeQuery = true)
|
||||||
@Modifying
|
@Modifying
|
||||||
@@ -62,4 +62,6 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
|
|||||||
@Query("select product from TbProduct product where product.shopId=:shopId")
|
@Query("select product from TbProduct product where product.shopId=:shopId")
|
||||||
List<TbProduct> selectByShopId(String shopId);
|
List<TbProduct> selectByShopId(String shopId);
|
||||||
|
|
||||||
|
@Query(value = "select b.* from tb_product_sku as a left join tb_product as b on a.product_id=b.id where a.id=:skuId", nativeQuery = true)
|
||||||
|
TbProduct selectBySkuId(@Param("skuId") Integer skuId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
|||||||
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
|
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
|
||||||
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
|
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
|
||||||
"CASE WHEN pro.isDistribute = 1 THEN IFNULL(pro.stockNumber, 0) ELSE SUM(sku.stockNumber) END as number" +
|
"CASE WHEN pro.isDistribute = 1 THEN IFNULL(pro.stockNumber, 0) ELSE SUM(sku.stockNumber) END as number" +
|
||||||
", pro.isDistribute, pro.isPauseSale, true, sku.warnLine, pro.lowPrice, CASE WHEN sku.isGrounding=1 THEN true ELSE false END as isGrounding) " +
|
", pro.isDistribute, pro.isPauseSale, true, sku.warnLine, pro.lowPrice, CASE WHEN sum(sku.isGrounding) > 0 THEN true ELSE false END as isGrounding) " +
|
||||||
"from " +
|
"from " +
|
||||||
"TbProduct pro " +
|
"TbProduct pro " +
|
||||||
"LEFT JOIN TbProductSku sku on pro.id = sku.productId " +
|
"LEFT JOIN TbProductSku sku on pro.id = sku.productId " +
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.ysk.cashier.repository.shop;
|
package cn.ysk.cashier.repository.shop;
|
||||||
|
|
||||||
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||||
@@ -21,8 +6,6 @@ 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,6 +25,10 @@ public interface TbPlussShopStaffRepository extends JpaRepository<TbPlussShopSta
|
|||||||
@Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account")
|
@Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account")
|
||||||
void updatePass(String account, String password, Long lastPasswordResetTime);
|
void updatePass(String account, String password, Long lastPasswordResetTime);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("update TbPlussShopStaff set password = :password , updatedAt = :lastPasswordResetTime where account = :account and shopId=:shopId")
|
||||||
|
void updatePassAndShopId(String account, String shopId, String password, Long lastPasswordResetTime);
|
||||||
|
|
||||||
@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);
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,12 @@ import java.io.IOException;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -404,9 +406,12 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
@Override
|
@Override
|
||||||
public void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException {
|
public void download(ShopSummaryDto summaryDto, HttpServletResponse response) throws IOException {
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
// ConcurrentLinkedQueue<Map<String, Object>> list = new ConcurrentLinkedQueue();
|
||||||
if(StringUtils.isBlank(summaryDto.getCateId())){
|
if(StringUtils.isBlank(summaryDto.getCateId())){
|
||||||
summaryDto.setCateId(null);
|
summaryDto.setCateId(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<Integer> mergeRowIndex = new ArrayList<>();
|
||||||
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
if (summaryDto.getType() != null && summaryDto.getType() == 1) {//金额
|
||||||
Long start = 1704038400000L;
|
Long start = 1704038400000L;
|
||||||
Long end = Instant.now().toEpochMilli();
|
Long end = Instant.now().toEpochMilli();
|
||||||
@@ -430,8 +435,12 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||||
summaryDto.setEndTime(new Date());
|
summaryDto.setEndTime(new Date());
|
||||||
}
|
}
|
||||||
List<TbOrderSalesCountByDayVo> tbOrderSalesCountByDayVos = detailRepository.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()),summaryDto.getCateId(),summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
List<TbOrderSalesCountByDayVo> tbOrderSalesCountByDayVos = detailRepository
|
||||||
for (TbOrderSalesCountByDayVo all : tbOrderSalesCountByDayVos) {
|
.queryTbOrderSalesCountByDay(Integer.valueOf(summaryDto.getShopId()),summaryDto.getCateId(),summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||||
|
tbOrderSalesCountByDayVos.forEach(all -> {
|
||||||
|
List<TbOrderSaleVO> tbOrderSaleVOS = detailRepository.querySaleOrderInfo(new Timestamp(summaryDto.getStartTime().getTime()),
|
||||||
|
new Timestamp(summaryDto.getEndTime().getTime()), all.getProductId(), all.getProductSkuId(), Integer.valueOf(summaryDto.getShopId()));
|
||||||
|
for (TbOrderSaleVO tbOrderSaleVO : tbOrderSaleVOS) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
map.put("商品分类", all.getCateName());
|
map.put("商品分类", all.getCateName());
|
||||||
map.put("商品名称", all.getProductName());
|
map.put("商品名称", all.getProductName());
|
||||||
@@ -443,10 +452,22 @@ public class SummaryServiceImpl implements SummaryService {
|
|||||||
map.put("退 单 量", all.getRefNum());
|
map.put("退 单 量", all.getRefNum());
|
||||||
map.put("退 单 额", all.getRefAmount().compareTo(BigDecimal.ZERO)==0?all.getRefAmount():"-"+all.getRefAmount());
|
map.put("退 单 额", all.getRefAmount().compareTo(BigDecimal.ZERO)==0?all.getRefAmount():"-"+all.getRefAmount());
|
||||||
map.put("总 量", all.getNum()-all.getRefNum());
|
map.put("总 量", all.getNum()-all.getRefNum());
|
||||||
|
map.put("订单编号", tbOrderSaleVO.getOrderNo());
|
||||||
|
map.put("售出数量", tbOrderSaleVO.getNum());
|
||||||
list.add(map);
|
list.add(map);
|
||||||
}
|
}
|
||||||
|
if (!tbOrderSaleVOS.isEmpty()) {
|
||||||
|
if (mergeRowIndex.isEmpty()) {
|
||||||
|
mergeRowIndex.add(tbOrderSaleVOS.size());
|
||||||
|
}else {
|
||||||
|
mergeRowIndex.add(mergeRowIndex.get(mergeRowIndex.size() - 1) + tbOrderSaleVOS.size());
|
||||||
}
|
}
|
||||||
FileUtil.downloadExcel(list, response);
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
FileUtil.downloadExcelAndMerge(list, 10, response, mergeRowIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
|
|||||||
import cn.ysk.cashier.service.TbProductStockOperateService;
|
import cn.ysk.cashier.service.TbProductStockOperateService;
|
||||||
import cn.ysk.cashier.service.product.StockService;
|
import cn.ysk.cashier.service.product.StockService;
|
||||||
import cn.ysk.cashier.service.product.TbProductService;
|
import cn.ysk.cashier.service.product.TbProductService;
|
||||||
import cn.ysk.cashier.utils.CacheKey;
|
import cn.ysk.cashier.utils.*;
|
||||||
import cn.ysk.cashier.utils.FileUtil;
|
|
||||||
import cn.ysk.cashier.utils.RedisUtils;
|
|
||||||
import cn.ysk.cashier.utils.StringUtils;
|
|
||||||
import cn.ysk.cashier.vo.StockUpdateValueVO;
|
import cn.ysk.cashier.vo.StockUpdateValueVO;
|
||||||
import cn.ysk.cashier.vo.StockUpdateWarnLineVO;
|
import cn.ysk.cashier.vo.StockUpdateWarnLineVO;
|
||||||
import cn.ysk.cashier.vo.StockV2Vo;
|
import cn.ysk.cashier.vo.StockV2Vo;
|
||||||
@@ -62,6 +59,7 @@ public class StockServiceImpl implements StockService {
|
|||||||
private final TbShopUnitRepository shopUnitRepository;
|
private final TbShopUnitRepository shopUnitRepository;
|
||||||
private final TbProductStockDetailRepository tbProductStockDetailRepository;
|
private final TbProductStockDetailRepository tbProductStockDetailRepository;
|
||||||
private final TbProductRepository tbProductRepository;
|
private final TbProductRepository tbProductRepository;
|
||||||
|
private final WxMsgUtils wxMsgUtils;
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
@@ -349,6 +347,15 @@ public class StockServiceImpl implements StockService {
|
|||||||
|
|
||||||
Query nativeQuery = em.createNativeQuery(String.valueOf(sqlQuery));
|
Query nativeQuery = em.createNativeQuery(String.valueOf(sqlQuery));
|
||||||
nativeQuery.executeUpdate();
|
nativeQuery.executeUpdate();
|
||||||
|
|
||||||
|
TbProduct product = tbProductRepository.selectBySkuId(Integer.valueOf(updateValueVO.getTargetId()));
|
||||||
|
TbProductSku tbProductSku = tbProductSkuRepository.findById(Integer.valueOf(updateValueVO.getTargetId())).orElse(null);
|
||||||
|
// 推送微信操作消息
|
||||||
|
if (product != null && tbProductSku != null) {
|
||||||
|
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭sku售罄: " : "开启sku售罄: ") + product.getName() + "/"+ tbProductSku.getSpecSnap());
|
||||||
|
}else {
|
||||||
|
log.warn("推送微信操作消息失败,未查询到商品信息,skuId: {}", updateValueVO.getTargetId());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case "stock":
|
case "stock":
|
||||||
sqlQuery.append(" set is_stock = ").append(updateValueVO.getUpdateValue());
|
sqlQuery.append(" set is_stock = ").append(updateValueVO.getUpdateValue());
|
||||||
@@ -358,6 +365,13 @@ public class StockServiceImpl implements StockService {
|
|||||||
break;
|
break;
|
||||||
case "pauseSale":
|
case "pauseSale":
|
||||||
sqlQuery.append(" set is_pause_sale = ").append(updateValueVO.getUpdateValue());
|
sqlQuery.append(" set is_pause_sale = ").append(updateValueVO.getUpdateValue());
|
||||||
|
TbProduct product1 = tbProductRepository.selectBySkuId(Integer.valueOf(updateValueVO.getTargetId()));
|
||||||
|
// 推送微信操作消息
|
||||||
|
if (product1 != null) {
|
||||||
|
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName());
|
||||||
|
}else {
|
||||||
|
log.warn("推送微信操作消息失败,未查询到商品信息,skuId: {}", updateValueVO.getTargetId());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException("无效更新类型");
|
throw new BadRequestException("无效更新类型");
|
||||||
@@ -393,7 +407,10 @@ public class StockServiceImpl implements StockService {
|
|||||||
if (tbProductSku == null) {
|
if (tbProductSku == null) {
|
||||||
throw new BadRequestException("商品不存在,skuId: " + skuId);
|
throw new BadRequestException("商品不存在,skuId: " + skuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
TbProduct product = tbProductRepository.selectByShopIdAndId(Integer.parseInt(tbProductSku.getProductId()), String.valueOf(shopId));
|
TbProduct product = tbProductRepository.selectByShopIdAndId(Integer.parseInt(tbProductSku.getProductId()), String.valueOf(shopId));
|
||||||
|
// 推送微信操作消息
|
||||||
|
wxMsgUtils.aboardOperationMsg((isGrounding ? "上架商品: " : "下架商品: ") + product.getName());
|
||||||
// 共享库存下架所有sku
|
// 共享库存下架所有sku
|
||||||
if (product.getIsDistribute().equals(1)) {
|
if (product.getIsDistribute().equals(1)) {
|
||||||
tbProductSkuRepository.updateGroundingByProId(product.getId().toString(), isGrounding ? 1 : 0);
|
tbProductSkuRepository.updateGroundingByProId(product.getId().toString(), isGrounding ? 1 : 0);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||||||
private final TbProductGroupRepository tbProductGroupRepository;
|
private final TbProductGroupRepository tbProductGroupRepository;
|
||||||
private final TbProductGroupMapper tbProductGroupMapper;
|
private final TbProductGroupMapper tbProductGroupMapper;
|
||||||
private final TbProductRepository tbProductRepository;
|
private final TbProductRepository tbProductRepository;
|
||||||
|
private final WxMsgUtils wxMsgUtils;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OnlineUserService onlineUserService;
|
private OnlineUserService onlineUserService;
|
||||||
@@ -104,6 +105,9 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
|||||||
ValidationUtil.isNull( tbProductGroup.getId(),"TbProductGroup","id",resources.getId());
|
ValidationUtil.isNull( tbProductGroup.getId(),"TbProductGroup","id",resources.getId());
|
||||||
tbProductGroup.copy(resources);
|
tbProductGroup.copy(resources);
|
||||||
tbProductGroupRepository.save(tbProductGroup);
|
tbProductGroupRepository.save(tbProductGroup);
|
||||||
|
|
||||||
|
// 推送微信操作消息
|
||||||
|
wxMsgUtils.aboardOperationMsg((resources.getIsShow() == 0 ? "关闭分组: " : "开启分组: ") + tbProductGroup.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|||||||
@@ -521,9 +521,8 @@ public class TbProductServiceImpl implements TbProductService {
|
|||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void updateIsHot(Integer id, String shopId) {
|
public void updateIsHot(Integer id,Integer isHot) {
|
||||||
tbProductRepository.updateNullHot(shopId);
|
tbProductRepository.updateIsHot(id,isHot);
|
||||||
tbProductRepository.updateIsHot(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
|||||||
|
|
||||||
|
|
||||||
round = (int) Math.floor( productSku.getStockNumber());
|
round = (int) Math.floor( productSku.getStockNumber());
|
||||||
|
productStockDetail.setSpecSnap(productSku.getSpecSnap());
|
||||||
|
|
||||||
productStockDetail.setSubType(productStocktakinDTO.getStocktakinNum() > productSku.getStockNumber() ? 1 : -1);
|
productStockDetail.setSubType(productStocktakinDTO.getStocktakinNum() > productSku.getStockNumber() ? 1 : -1);
|
||||||
stockOperate.setType(productStocktakinDTO.getStocktakinNum() > productSku.getStockNumber() ? "盘点入库" : "盘点出库");
|
stockOperate.setType(productStocktakinDTO.getStocktakinNum() > productSku.getStockNumber() ? "盘点入库" : "盘点出库");
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
Set<Long> sysUserIds=new HashSet<>();
|
Set<Long> sysUserIds=new HashSet<>();
|
||||||
for (Integer id : ids) {
|
for (Integer id : ids) {
|
||||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).get();
|
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(id).get();
|
||||||
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getAccount());
|
User sysUser = userRepository.findByUsername(tbPlussShopStaff.getShopId()+"@"+tbPlussShopStaff.getAccount());
|
||||||
tbPlussShopStaffRepository.deleteById(id);
|
tbPlussShopStaffRepository.deleteById(id);
|
||||||
sysUserIds.add(sysUser.getId());
|
sysUserIds.add(sysUser.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public interface TbProductService {
|
|||||||
*/
|
*/
|
||||||
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
|
void download(List<TbProductDto> all, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
void updateIsHot(Integer id, String shopId);
|
void updateIsHot(Integer id,Integer isStock);
|
||||||
|
|
||||||
void updateIsStock(Integer proId, String shopId, Integer isStock);
|
void updateIsStock(Integer proId, String shopId, Integer isStock);
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.ysk.cashier.system.domain.vo;
|
package cn.ysk.cashier.system.domain.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -25,6 +10,9 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class UserPassVo {
|
public class UserPassVo {
|
||||||
|
|
||||||
|
//staff
|
||||||
|
private String loginType;
|
||||||
|
|
||||||
private String oldPass;
|
private String oldPass;
|
||||||
|
|
||||||
private String newPass;
|
private String newPass;
|
||||||
|
|||||||
@@ -1,26 +1,15 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package cn.ysk.cashier.system.rest;
|
package cn.ysk.cashier.system.rest;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.ysk.cashier.config.security.security.TokenProvider;
|
||||||
|
import cn.ysk.cashier.config.security.service.OnlineUserService;
|
||||||
|
import cn.ysk.cashier.repository.shop.TbPlussShopStaffRepository;
|
||||||
import cn.ysk.cashier.system.domain.Dept;
|
import cn.ysk.cashier.system.domain.Dept;
|
||||||
import cn.ysk.cashier.system.domain.User;
|
import cn.ysk.cashier.system.domain.User;
|
||||||
import cn.ysk.cashier.system.domain.vo.UserPassVo;
|
import cn.ysk.cashier.system.domain.vo.UserPassVo;
|
||||||
import cn.ysk.cashier.system.service.dto.UserDto;
|
import cn.ysk.cashier.system.service.dto.UserDto;
|
||||||
import cn.ysk.cashier.system.service.dto.UserQueryCriteria;
|
import cn.ysk.cashier.system.service.dto.UserQueryCriteria;
|
||||||
|
import cn.ysk.cashier.utils.MD5Utils;
|
||||||
import cn.ysk.cashier.utils.PageUtil;
|
import cn.ysk.cashier.utils.PageUtil;
|
||||||
import cn.ysk.cashier.utils.RsaUtils;
|
import cn.ysk.cashier.utils.RsaUtils;
|
||||||
import cn.ysk.cashier.utils.SecurityUtils;
|
import cn.ysk.cashier.utils.SecurityUtils;
|
||||||
@@ -37,16 +26,20 @@ import cn.ysk.cashier.system.service.dto.RoleSmallDto;
|
|||||||
import cn.ysk.cashier.system.service.VerifyService;
|
import cn.ysk.cashier.system.service.VerifyService;
|
||||||
import cn.ysk.cashier.system.service.UserService;
|
import cn.ysk.cashier.system.service.UserService;
|
||||||
import cn.ysk.cashier.utils.enums.CodeEnum;
|
import cn.ysk.cashier.utils.enums.CodeEnum;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -68,6 +61,9 @@ public class UserController {
|
|||||||
private final DeptService deptService;
|
private final DeptService deptService;
|
||||||
private final RoleService roleService;
|
private final RoleService roleService;
|
||||||
private final VerifyService verificationCodeService;
|
private final VerifyService verificationCodeService;
|
||||||
|
private final OnlineUserService onlineUserService;
|
||||||
|
private final TbPlussShopStaffRepository shopStaffRepository;
|
||||||
|
private final TokenProvider tokenProvider;
|
||||||
|
|
||||||
@ApiOperation("导出用户数据")
|
@ApiOperation("导出用户数据")
|
||||||
@GetMapping(value = "/download")
|
@GetMapping(value = "/download")
|
||||||
@@ -155,17 +151,27 @@ public class UserController {
|
|||||||
|
|
||||||
@ApiOperation("修改密码")
|
@ApiOperation("修改密码")
|
||||||
@PostMapping(value = "/updatePass")
|
@PostMapping(value = "/updatePass")
|
||||||
public ResponseEntity<Object> updateUserPass(@RequestBody UserPassVo passVo) throws Exception {
|
@Transactional
|
||||||
|
public ResponseEntity<Object> updateUserPass(HttpServletRequest request, @RequestBody UserPassVo passVo) throws Exception {
|
||||||
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
|
UserDto user = userService.findByName(currentUsername);
|
||||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass());
|
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass());
|
||||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());
|
|
||||||
UserDto user = userService.findByName(SecurityUtils.getCurrentUsername());
|
|
||||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||||
throw new BadRequestException("修改失败,旧密码错误");
|
throw new BadRequestException("修改失败,旧密码错误");
|
||||||
}
|
}
|
||||||
if(passwordEncoder.matches(newPass, user.getPassword())){
|
System.out.println(oldPass);
|
||||||
|
if (passwordEncoder.matches(passVo.getNewPass(), user.getPassword())) {
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));
|
String encPass = MD5Utils.encrypt( passVo.getNewPass());
|
||||||
|
if (StringUtils.isNotBlank(passVo.getLoginType()) && passVo.getLoginType().equals("staff")) {
|
||||||
|
String[] split = currentUsername.split("@");
|
||||||
|
shopStaffRepository.updatePassAndShopId(split[1],split[0],encPass,System.currentTimeMillis());
|
||||||
|
}else {
|
||||||
|
shopStaffRepository.updatePass(currentUsername,encPass,System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
userService.updatePass(user.getUsername(),passwordEncoder.encode(passVo.getNewPass()));
|
||||||
|
onlineUserService.logout(tokenProvider.getToken(request));
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package cn.ysk.cashier.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class WxAccountUtil {
|
||||||
|
@Value("${wx.ysk.appId}")
|
||||||
|
private String appId = "wx212769170d2c6b2a";
|
||||||
|
@Value("${wx.ysk.secrete}")
|
||||||
|
private String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
|
||||||
|
@Value("${wx.ysk.operationMsgTmpId}")
|
||||||
|
private String operationMsgTmpId ;
|
||||||
|
|
||||||
|
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
|
||||||
|
linkedHashMap.put("40003","不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
|
||||||
|
linkedHashMap.put("40014","不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
|
||||||
|
linkedHashMap.put("40037","不合法的 template_id");
|
||||||
|
linkedHashMap.put("43101","用户未订阅消息");
|
||||||
|
linkedHashMap.put("43107","订阅消息能力封禁");
|
||||||
|
linkedHashMap.put("43108","并发下发消息给同一个粉丝");
|
||||||
|
linkedHashMap.put("45168","命中敏感词");
|
||||||
|
linkedHashMap.put("47003","参数错误");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// sendStockWarnMsg("13213", "31123", "234", "ojC-S6n2DDlpj52iVMoiLL0Ry4HI");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRadarQrCode(Integer shopId) {
|
||||||
|
HashMap<String, Object> req = new HashMap<>();
|
||||||
|
req.put("expire_seconds", 300);
|
||||||
|
req.put("action_name", "QR_STR_SCENE");
|
||||||
|
HashMap<Object, Object> actionInfo = new HashMap<>();
|
||||||
|
HashMap<String, Object> scene = new HashMap<>();
|
||||||
|
scene.put("scene_str", "msg" + shopId);
|
||||||
|
actionInfo.put("scene", scene);
|
||||||
|
req.put("action_info", actionInfo);
|
||||||
|
log.info("开始获取公众号二维码, 请求数据: {}", req);
|
||||||
|
String resp = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + getAccessToken(), JSONObject.toJSONString(req));
|
||||||
|
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||||
|
log.warn("获取微信公众号二维码结束,响应: {}", resp);
|
||||||
|
if (!respInfo.containsKey("url")) {
|
||||||
|
log.warn("获取微信公众号二维码失败,响应: {}", resp);
|
||||||
|
throw new RuntimeException(resp);
|
||||||
|
}
|
||||||
|
return respInfo.getString("url");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
|
||||||
|
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||||
|
if (!respInfo.containsKey("access_token")) {
|
||||||
|
log.warn("公众号获取token失败, 响应内容: {}", resp);
|
||||||
|
throw new RuntimeException(resp);
|
||||||
|
}
|
||||||
|
return respInfo.getString("access_token");
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
|
||||||
|
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||||
|
String accessToken = getAccessToken();
|
||||||
|
|
||||||
|
JSONObject object1=new JSONObject();
|
||||||
|
|
||||||
|
object1.put("template_id", templateId);
|
||||||
|
object1.put("touser", toUserOpenId);
|
||||||
|
object1.put("data",data);
|
||||||
|
|
||||||
|
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||||
|
log.info("微信模板消息发送成功,响应内容:{}",response);
|
||||||
|
JSONObject resObj=JSONObject.parseObject(response);
|
||||||
|
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
|
||||||
|
return resObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void sendOperationMsg(List<TbShopOpenId> openIds, String userName, String operationDesc) {
|
||||||
|
openIds.forEach(item -> {
|
||||||
|
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||||
|
put("thing19", new HashMap<String, Object>(){{
|
||||||
|
put("value", userName);
|
||||||
|
}});
|
||||||
|
put("thing8", new HashMap<String, Object>(){{
|
||||||
|
put("value", operationDesc);
|
||||||
|
}});
|
||||||
|
put("time21", new HashMap<String, Object>(){{
|
||||||
|
put("value", DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
}});
|
||||||
|
}};
|
||||||
|
log.info("开始发送敏感操作消息, 接收用户openId: {}, 操作用户: {}, 操作描述: {}", item.getOpenId(), userName, operationDesc);
|
||||||
|
try {
|
||||||
|
sendTemplateMsg(operationMsgTmpId, item.getOpenId(), data);
|
||||||
|
}catch (Exception e) {
|
||||||
|
log.error("发送失败, openId: {}, 响应: {}", item.getOpenId(), e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package cn.ysk.cashier.utils;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||||
|
import cn.ysk.cashier.mybatis.service.TbShopOpenIdService;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class WxMsgUtils {
|
||||||
|
|
||||||
|
private final TbShopOpenIdService tbShopOpenIdService;
|
||||||
|
|
||||||
|
private final RedisUtils redisUtils;
|
||||||
|
|
||||||
|
private final WxAccountUtil wxAccountUtil;
|
||||||
|
|
||||||
|
public WxMsgUtils(TbShopOpenIdService tbShopOpenIdService, RedisUtils redisUtils, WxAccountUtil wxAccountUtil) {
|
||||||
|
this.tbShopOpenIdService = tbShopOpenIdService;
|
||||||
|
this.redisUtils = redisUtils;
|
||||||
|
this.wxAccountUtil = wxAccountUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void aboardOperationMsg(String operationDesc) {
|
||||||
|
HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||||
|
|
||||||
|
Object o = redisUtils.get("online-token-"+getToken(request));
|
||||||
|
JSONObject jsonObject;
|
||||||
|
Integer shopId;
|
||||||
|
String nickName;
|
||||||
|
if (o != null) {
|
||||||
|
String jsonString = JSON.toJSONString(o);
|
||||||
|
jsonObject = JSONObject.parseObject(jsonString);
|
||||||
|
shopId = (Integer) jsonObject.get("shopId");
|
||||||
|
nickName = jsonObject.get("nickName") == null ? "" : jsonObject.get("nickName").toString();
|
||||||
|
List<TbShopOpenId> openIds = tbShopOpenIdService.lambdaQuery().eq(TbShopOpenId::getShopId, shopId).list();
|
||||||
|
log.info("即将开始推送敏感操作消息, 接收推送openId列表: {}", openIds);
|
||||||
|
String finalNickName = nickName;
|
||||||
|
wxAccountUtil.sendOperationMsg(openIds, finalNickName, operationDesc);
|
||||||
|
}else {
|
||||||
|
log.warn("发送敏感操作预警失败,未获取到登录信息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken(HttpServletRequest request) {
|
||||||
|
final String requestHeader = request.getHeader("Authorization");
|
||||||
|
if (requestHeader != null && requestHeader.startsWith("Bearer")) {
|
||||||
|
return requestHeader.substring(7);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package cn.ysk.cashier.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class TbOrderSaleVO {
|
||||||
|
private String orderNo;
|
||||||
|
private Integer num;
|
||||||
|
private BigDecimal price;
|
||||||
|
private String status;
|
||||||
|
}
|
||||||
@@ -14,6 +14,24 @@ public class TbOrderSalesCountByDayVo {
|
|||||||
private BigDecimal salesAmount;
|
private BigDecimal salesAmount;
|
||||||
private BigDecimal refAmount;
|
private BigDecimal refAmount;
|
||||||
private Long num;
|
private Long num;
|
||||||
|
private Integer productId;
|
||||||
|
private Integer productSkuId;
|
||||||
|
|
||||||
|
public Integer getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Integer productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getProductSkuId() {
|
||||||
|
return productSkuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductSkuId(Integer productSkuId) {
|
||||||
|
this.productSkuId = productSkuId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getProductName() {
|
public String getProductName() {
|
||||||
return productName;
|
return productName;
|
||||||
@@ -116,6 +134,25 @@ public class TbOrderSalesCountByDayVo {
|
|||||||
count();
|
count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TbOrderSalesCountByDayVo(String productName, String productSkuName, String cateName,String unitName,BigDecimal price,
|
||||||
|
Long salesNum, Long refNum, Long num, BigDecimal salesAmount, BigDecimal refAmount, Integer productId, Integer productSkuId) {
|
||||||
|
this.productName = productName;
|
||||||
|
this.productSkuName = productSkuName;
|
||||||
|
this.cateName = cateName;
|
||||||
|
this.unitName = unitName;
|
||||||
|
this.price = price;
|
||||||
|
this.salesNum = salesNum;
|
||||||
|
this.refNum = refNum;
|
||||||
|
this.salesAmount = salesAmount;
|
||||||
|
this.refAmount = refAmount;
|
||||||
|
this.num = num;
|
||||||
|
this.productId = productId;
|
||||||
|
this.productSkuId = productSkuId;
|
||||||
|
count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void count(){
|
public void count(){
|
||||||
salesNum=salesNum-refNum;
|
salesNum=salesNum-refNum;
|
||||||
salesAmount=salesAmount.subtract(refAmount);
|
salesAmount=salesAmount.subtract(refAmount);
|
||||||
|
|||||||
@@ -78,3 +78,9 @@ aliyun:
|
|||||||
oss:
|
oss:
|
||||||
bucketname: cashier-oss
|
bucketname: cashier-oss
|
||||||
endpoint: oss-cn-beijing.aliyuncs.com
|
endpoint: oss-cn-beijing.aliyuncs.com
|
||||||
|
|
||||||
|
wx:
|
||||||
|
ysk:
|
||||||
|
appId: wx212769170d2c6b2a
|
||||||
|
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
|
||||||
|
operationMsgTmpId: wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbShopOpenIdMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbShopOpenId">
|
||||||
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="shop_id" column="shop_id" jdbcType="INTEGER"/>
|
||||||
|
<result property="open_id" column="open_id" jdbcType="VARCHAR"/>
|
||||||
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||||
|
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="update_time" column="update_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="type" column="type" jdbcType="TINYINT"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,shop_id,open_id,
|
||||||
|
status,create_time,update_time,
|
||||||
|
type
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user