Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
SongZhang 2024-09-27 16:08:38 +08:00
commit 7bd4d05381
16 changed files with 479 additions and 7 deletions

View File

@ -69,7 +69,7 @@ public class TbProskuConController {
throw new Exception(be.getMessage());
}catch (Exception e){
e.printStackTrace();
throw new Exception("参数错误");
throw new Exception(e.getMessage());
}
}

View File

@ -196,15 +196,31 @@ public class TbProskuConServiceImpl implements TbProskuConService {
if (ObjectUtil.isNull(tbConsInfo) || ObjectUtil.isNull(tbConsInfo.getId())) {
throw new BadRequestException("对应的耗材信息不存在");
}
TbProductSku sku = null;
if (resource.getProductSkuId() != 0) {
TbProductSku sku = tbProductSkuRepository.findById(resource.getProductSkuId()).orElseGet(TbProductSku::new);
sku = tbProductSkuRepository.findById(resource.getProductSkuId()).orElseGet(TbProductSku::new);
if (ObjectUtil.isNull(sku) || ObjectUtil.isNull(sku.getId())) {
throw new BadRequestException("规格信息不存在");
}
}
TbProskuCon tbConsInfo1 = new TbProskuCon();
BeanUtil.copyProperties(resource,tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
if (resource.getId() == null) {
int count = tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resource.getConInfoId(), resource.getProductSkuId(), resource.getShopId(), resource.getProductId());
if (count <= 0) {
BeanUtil.copyProperties(resource, tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
} else {
StringBuilder strResult = new StringBuilder(product.getName());
if (sku != null) {
strResult.append(" 规格" + sku.getSpecSnap());
}
strResult.append("与耗材 " + tbConsInfo.getConName() + " 的对应关系已存在");
throw new BadRequestException(product.getName().concat("对应的").concat(Objects.nonNull(sku.getSpecSnap())?sku.getSpecSnap():"").concat("规格已存在"));
}
}else {
BeanUtil.copyProperties(resource,tbConsInfo1, CopyOptions.create().setIgnoreNullValue(true));
newCons.add(tbConsInfo1);
}
}
if (!CollectionUtils.isEmpty(newCons)) {
tbProskuConRepository.saveAll(newCons);

View File

@ -0,0 +1,67 @@
package cn.ysk.cashier.controller.shop;
import cn.hutool.core.map.MapProxy;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.system.enums.ParamsEnum;
import cn.ysk.cashier.system.service.ParamsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.nio.charset.Charset;
import java.util.Map;
/**
* 店铺支付相关接口
*
* @author tankaikai
* @since 2024-09-24 16:56
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "店铺支付相关接口")
@RequestMapping(value = {"/api/shop-pay-api", "/api/shopPayApi"})
public class ShopPayApiController {
private final ParamsService paramsService;
@GetMapping("getOrderPayUrl")
@ApiOperation("获取店铺订单支付URL")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", required = true, dataType = "String"),
@ApiImplicitParam(name = "shopId", value = "店铺id", paramType = "query", required = true, dataType = "String"),
})
public ResponseEntity url(@RequestParam Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
String shopId = mapProxy.getStr("shopId");
String orderId = mapProxy.getStr("orderId");
try {
if (StrUtil.isBlank(shopId)) {
throw new BadRequestException("店铺id不能为空");
}
if (StrUtil.isBlank(orderId)) {
throw new BadRequestException("订单id不能为空");
}
String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name());
String buildUrl = URLUtil.buildQuery(params, Charset.defaultCharset());
String fullUrl = baseUrl.concat("?").concat(buildUrl);
return ResponseEntity.ok().body(fullUrl);
} catch (BadRequestException e) {
return ResponseEntity.badRequest().body(e.getMessage());
} catch (Exception e) {
log.error("获取店铺订单支付URL异常", e);
return ResponseEntity.ok().body("获取店铺订单支付URL异常");
}
}
}

View File

@ -52,6 +52,12 @@ public class TbProductQueryV2Criteria {
@Query
private Integer isDel = 0;
@Query
private Integer isPauseSale;
@Query
private Integer isGrounding;
@Query
private String type;

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.system.domain.Params;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 参数管理
*
* @author tankaikai
* @since 2024-09-27 11:34
*/
@Mapper
public interface SysParamsMapper extends BaseMapper<Params> {
}

View File

@ -207,6 +207,6 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
void updateGrounding(Integer skuId,int isGrounding);
@Modifying
@Query("update TbProductSku set salePrice = :salePrice where productId=:productId")
void upSalePrice(@Param("productId") Integer productId, @Param("lowPrice") BigDecimal salePrice);
@Query("update TbProductSku set salePrice = :salePrice where productId= :productId")
void upSalePrice(@Param("productId") String productId, @Param("lowPrice") BigDecimal salePrice);
}

View File

@ -414,13 +414,14 @@ public class StockServiceImpl implements StockService {
detail.setType("盘点入库");
}
detail.setCreatedAt(System.currentTimeMillis());
detail.setUpdatedAt(System.currentTimeMillis());
tbProductStockDetailRepository.save(detail);
break;
case "salePrice"://价格
description.append("修改价格为" + updateValueVO.getValue());
sqlQuery.append(" set low_price = ").append(updateValueVO.getValue());
tbProductRepository.upLowPrice(product.getId(),new BigDecimal(updateValueVO.getValue()));
tbProductSkuRepository.upSalePrice(product.getId(),new BigDecimal(updateValueVO.getValue()));
tbProductSkuRepository.upSalePrice(product.getId().toString(),new BigDecimal(updateValueVO.getValue()));
break;
case "refundStock"://商品 暂停销售
if (!"0".equals(updateValueVO.getValue()) && !"1".equals(updateValueVO.getValue())) {

View File

@ -34,7 +34,9 @@ import cn.ysk.cashier.system.domain.Dept;
import cn.ysk.cashier.system.domain.Job;
import cn.ysk.cashier.system.domain.Role;
import cn.ysk.cashier.system.domain.User;
import cn.ysk.cashier.system.enums.ParamsEnum;
import cn.ysk.cashier.system.repository.UserRepository;
import cn.ysk.cashier.system.service.ParamsService;
import cn.ysk.cashier.system.service.UserService;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
@ -75,6 +77,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
private final UserCacheManager userCacheManager;
private final TokenProvider tokenProvider;
private final ParamsService paramsService;
private final TbMerchantRegisterRepository merchantRegisterRepository;
@ -109,6 +112,8 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
tbShopInfo.setSmallQrcode(smallQrcode);
tbShopInfoRepository.save(tbShopInfo);
}
String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name());
tbShopInfo.setPaymentQrcode(baseUrl+"?shopId="+id);
ValidationUtil.isNull(tbShopInfo.getId(),"TbShopInfo","id",id);
return tbShopInfoMapper.toDto(tbShopInfo);
}

View File

@ -0,0 +1,63 @@
package cn.ysk.cashier.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 参数管理
*
* @author tankaikai
* @since 2024-09-27 11:34
*/
@Data
@TableName("sys_params")
public class Params implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
@TableField("param_id")
private Long paramId;
/**
* 参数编码
*/
private String paramCode;
/**
* 参数值
*/
private String paramValue;
/**
* 类型 0系统参数 1非系统参数
*/
private Integer paramType;
/**
* 备注
*/
private String remark;
/**
* 创建者
*/
private Long createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新者
*/
private Long updateBy;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -0,0 +1,15 @@
package cn.ysk.cashier.system.enums;
/**
* 参数枚举类
* @author tankaikai
* @since 2024-09-27 14:21
*/
public enum ParamsEnum {
/**
* 店铺订单支付BASE_URL
*/
SHOP_ORDER_PAY_BASE_URL
;
}

View File

@ -0,0 +1,93 @@
package cn.ysk.cashier.system.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.system.domain.Params;
import cn.ysk.cashier.system.service.ParamsService;
import cn.ysk.cashier.system.service.dto.ParamsDTO;
import cn.ysk.cashier.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Date;
import java.util.Map;
/**
* 参数管理
*
* @author tankaikai
* @since 2024-09-27 11:34
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/sys/params")
@Api(tags="参数管理")
public class ParamsController {
private final ParamsService paramsService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = "size", value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = "paramCode", value = "参数编码", paramType = "query", dataType="String")
})
public ResponseEntity page(@ApiIgnore @RequestParam Map<String, Object> params){
Map<String, Object> page = paramsService.page(params);
return ResponseEntity.ok().body(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
public ResponseEntity get(@PathVariable("id") Long id){
Params entity = paramsService.getById(id);
ParamsDTO data = BeanUtil.toBean(entity, ParamsDTO.class);
return ResponseEntity.ok().body(data);
}
@PostMapping
@ApiOperation("保存")
@Log("保存")
public ResponseEntity save(@RequestBody ParamsDTO dto){
Params entity = BeanUtil.toBean(dto, Params.class);
Long currentUserId = SecurityUtils.getCurrentUserId();
entity.setCreateBy(currentUserId);
entity.setCreateTime(new Date());
entity.setUpdateBy(currentUserId);
entity.setUpdateTime(entity.getCreateTime());
paramsService.save(entity);
return new ResponseEntity<>(HttpStatus.OK);
}
@PutMapping
@ApiOperation("修改")
@Log("修改")
public ResponseEntity update(@RequestBody ParamsDTO dto){
Long paramId = dto.getParamId();
Params entity = paramsService.getById(paramId);
BeanUtil.copyProperties(dto, entity,"createBy","createTime");
Long currentUserId = SecurityUtils.getCurrentUserId();
entity.setUpdateBy(currentUserId);
entity.setUpdateTime(entity.getCreateTime());
paramsService.updateById(entity);
return new ResponseEntity<>(HttpStatus.OK);
}
@DeleteMapping("{id}")
@ApiOperation("删除")
@Log("删除")
public ResponseEntity delete(@PathVariable("paramId") Long paramId){
paramsService.removeById(paramId);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -0,0 +1,43 @@
package cn.ysk.cashier.system.service;
import cn.ysk.cashier.system.domain.Params;
import cn.ysk.cashier.system.service.dto.ParamsDTO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* 参数管理
*
* @author tankaikai
* @since 2024-09-27 11:34
*/
public interface ParamsService extends IService<Params> {
Map<String,Object> page(Map<String, Object> params);
List<ParamsDTO> list(Map<String, Object> params);
/**
* 根据参数编码获取参数的value值
*
* @param paramCode 参数编码
*/
String getValue(String paramCode);
/**
* 根据参数编码获取value的Object对象
* @param paramCode 参数编码
* @param clazz Object对象
*/
<T> T getValueObject(String paramCode, Class<T> clazz);
/**
* 根据参数编码更新value
* @param paramCode 参数编码
* @param paramValue 参数值
*/
int updateValueByCode(String paramCode, String paramValue);
}

View File

@ -0,0 +1,45 @@
package cn.ysk.cashier.system.service.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 参数管理
*
* @author tankaikai
* @since 2024-09-27 11:34
*/
@Data
@ApiModel(value = "参数管理")
public class ParamsDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long paramId;
@ApiModelProperty(value = "参数编码")
private String paramCode;
@ApiModelProperty(value = "参数值")
private String paramValue;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "创建时间")
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "更新时间")
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
}

View File

@ -0,0 +1,94 @@
package cn.ysk.cashier.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapProxy;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.SysParamsMapper;
import cn.ysk.cashier.system.domain.Params;
import cn.ysk.cashier.system.service.ParamsService;
import cn.ysk.cashier.system.service.dto.ParamsDTO;
import cn.ysk.cashier.utils.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 参数管理
*
* @author tankaikai
* @since 2024-09-27 11:34
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ParamsServiceImpl extends ServiceImpl<SysParamsMapper, Params> implements ParamsService {
private QueryWrapper<Params> getWrapper(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
QueryWrapper<Params> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(Params::getParamType, 1);
String paramCode = mapProxy.getStr("paramCode");
wrapper.lambda().like(StrUtil.isNotEmpty(paramCode), Params::getParamCode, paramCode);
wrapper.lambda().orderByDesc(Params::getParamId);
return wrapper;
}
@Override
public Map<String, Object> page(Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params);
int pageNum = mapProxy.getInt("page", 1);
int pageSize = mapProxy.getInt("size", 10);
Page<Params> page = super.page(new Page<>(pageNum, pageSize), getWrapper(params));
List<ParamsDTO> list = BeanUtil.copyToList(page.getRecords(), ParamsDTO.class);
return PageUtil.toPlusPage(list, Convert.toInt(page.getTotal()));
}
@Override
public List<ParamsDTO> list(Map<String, Object> params) {
List<Params> list = super.list(getWrapper(params));
return BeanUtil.copyToList(list, ParamsDTO.class);
}
@Override
public String getValue(String paramCode) {
Params params = baseMapper.selectOne(Wrappers.<Params>lambdaQuery().select(Params::getParamValue).eq(Params::getParamCode, paramCode));
return Optional.ofNullable(params).map(Params::getParamValue).orElseThrow(() -> new BadRequestException("找不到对应的系统参数值"));
}
@Override
public <T> T getValueObject(String paramCode, Class<T> clazz) {
String paramValue = getValue(paramCode);
if (StringUtils.isNotBlank(paramValue)) {
return JSONUtil.toBean(paramValue, clazz);
}
try {
return clazz.newInstance();
} catch (Exception e) {
throw new BadRequestException("获取参数失败");
}
}
@Override
public int updateValueByCode(String paramCode, String paramValue) {
return baseMapper.update(null, Wrappers.<Params>lambdaUpdate().eq(Params::getParamCode, paramCode).set(Params::getParamValue, paramValue));
}
}

View File

@ -45,10 +45,12 @@ public class FileUtils {
cell.setCellValue(value);
if (j == 10 && !"0".equals(value)) {
cell.setCellValue("-" + value);
setCellBackground(cell, IndexedColors.YELLOW, workbook);
}
if (j == 11 && !"0.00".equals(value)) {
cell.setCellValue("-" + value);
setCellBackground(cell, IndexedColors.YELLOW, workbook);
}
}

View File

@ -0,0 +1,6 @@
<?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.SysParamsMapper">
</mapper>