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

This commit is contained in:
SongZhang 2024-10-21 13:49:49 +08:00
commit 844156341c
8 changed files with 150 additions and 33 deletions

View File

@ -48,9 +48,6 @@ public class TbConsInfo implements Serializable {
@ApiModelProperty(value = "库存值") @ApiModelProperty(value = "库存值")
private BigDecimal stockNumber; private BigDecimal stockNumber;
@Column(name = "`balance`")
@ApiModelProperty(value = "实际库存值")
private BigDecimal balance;
@Column(name = "`con_unit`") @Column(name = "`con_unit`")
@ApiModelProperty(value = "单位值") @ApiModelProperty(value = "单位值")
@ -105,7 +102,4 @@ public class TbConsInfo implements Serializable {
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }
public static void main(String[] args){
System.out.println(JSONUtil.toJSONString(new TbConsInfo()));
}
} }

View File

@ -0,0 +1,106 @@
package cn.ysk.cashier.cons.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
/**
* @author admin
* @date 2024-06-22
**/
@Entity
@Data
@Table(name="tb_cons_info")
public class TbConsInfoV2 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`id`")
@ApiModelProperty(value = "id")
private Integer id;
@Column(name = "`con_type_id`")
@ApiModelProperty(value = "耗材类型id")
private Integer conTypeId;
@Column(name = "`con_type_name`")
@ApiModelProperty(value = "耗材类型名称")
private String conTypeName;
@Column(name = "`con_code`")
@ApiModelProperty(value = "耗材代码")
private String conCode;
@Column(name = "`con_name`")
@ApiModelProperty(value = "耗材名称")
private String conName;
@Column(name = "`stock_number`")
@ApiModelProperty(value = "库存值")
private BigDecimal stockNumber;
// @Column(name = "`balance`")
@ApiModelProperty(value = "实际库存值")
private BigDecimal balance;
@Column(name = "`con_unit`")
@ApiModelProperty(value = "单位值")
private String conUnit;
@Column(name = "`laster_in_stock`")
@ApiModelProperty(value = "最近一次入库量")
private BigDecimal lasterInStock;
@Column(name = "`con_warning`")
@ApiModelProperty(value = "耗材预警值")
private BigDecimal conWarning;
@Column(name = "`create_time`")
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
@Column(name = "`update_time`")
@ApiModelProperty(value = "更新时间")
private Timestamp updateTime;
@Column(name = "`shop_id`")
@ApiModelProperty(value = "店铺id")
private Integer shopId;
@Column(name = "`price`")
@ApiModelProperty(value = "单价")
private BigDecimal price;
@Column(name = "`status`")
@ApiModelProperty(value = "状态 1 启用 0 禁用")
private String status;
@Column(name = "`stock_consume`")
@ApiModelProperty(value = "消耗总量")
private BigDecimal stockConsume;
@Column(name = "`is_check`")
@ApiModelProperty(value = "是否检测库存")
private String isCheck;
@Transient
private List<Map<Integer, Object>> product;
public void copy(TbConsInfoV2 source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,9 @@
package cn.ysk.cashier.cons.repository;
import cn.ysk.cashier.cons.domain.TbConsInfoV2;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface TbConsInfoV2Repository extends JpaRepository<TbConsInfoV2, Integer>, JpaSpecificationExecutor<TbConsInfoV2> {
}

View File

@ -4,10 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.ysk.cashier.cons.domain.*; import cn.ysk.cashier.cons.domain.*;
import cn.ysk.cashier.cons.repository.TbConsInfoFlowRepository; import cn.ysk.cashier.cons.repository.*;
import cn.ysk.cashier.cons.repository.TbConsInfoRepository;
import cn.ysk.cashier.cons.repository.TbConsSuppFlowRepository;
import cn.ysk.cashier.cons.repository.TbConsTypeRepository;
import cn.ysk.cashier.cons.service.TbConsInfoService; import cn.ysk.cashier.cons.service.TbConsInfoService;
import cn.ysk.cashier.cons.service.dto.TbConsInfoDto; import cn.ysk.cashier.cons.service.dto.TbConsInfoDto;
import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria; import cn.ysk.cashier.cons.service.dto.TbConsInfoQueryCriteria;
@ -57,6 +54,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
public final TbConsInfoFlowRepository tbConsInfoFlowRepository; public final TbConsInfoFlowRepository tbConsInfoFlowRepository;
public final TbConsSuppFlowRepository tbConsSuppFlowRepository; public final TbConsSuppFlowRepository tbConsSuppFlowRepository;
private final TbConsInfoRepository tbConsInfoRepository; private final TbConsInfoRepository tbConsInfoRepository;
private final TbConsInfoV2Repository tbConsInfoV2Repository;
private final TbConsInfoMapper tbConsInfoMapper; private final TbConsInfoMapper tbConsInfoMapper;
private final TbShopPurveyorRepository tbShopPurveyorRepository; private final TbShopPurveyorRepository tbShopPurveyorRepository;
@ -86,13 +84,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
sort = Sort.by(sortDirection, sortField); sort = Sort.by(sortDirection, sortField);
} }
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
Page<TbConsInfo> page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); Page<TbConsInfoV2> page = tbConsInfoV2Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
Page<TbConsInfoDto> result = page.map(tbConsInfoMapper::toDto); page.getContent().forEach(it -> {
result.getContent().forEach(it -> {
List<Map<Integer, Object>> list = tbConsInfoRepository.queryAllAndPro(criteria.getShopId(), it.getId()); List<Map<Integer, Object>> list = tbConsInfoRepository.queryAllAndPro(criteria.getShopId(), it.getId());
it.setProduct(list); it.setProduct(list);
}); });
return PageUtil.toPage(result); return PageUtil.toPage(page);
} }
@ -155,7 +152,6 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
} }
BeanUtil.copyProperties(resource,tbConsInfo, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(resource,tbConsInfo, CopyOptions.create().setIgnoreNullValue(true));
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis())); tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoRepository.save(tbConsInfo); tbConsInfoRepository.save(tbConsInfo);
} }

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.controller.product;
import cn.ysk.cashier.annotation.AnonymousAccess; import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.dto.shoptable.*; import cn.ysk.cashier.dto.shoptable.*;
import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.product.TbProductService;
@ -13,6 +14,8 @@ import org.springframework.http.ResponseEntity;
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 javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
@RestController @RestController
@ -21,6 +24,8 @@ public class TbPlaceController {
private final TbShopTableService tbShopTableService; private final TbShopTableService tbShopTableService;
private final TbProductService tbProductService; private final TbProductService tbProductService;
private final RabbitMsgUtils rabbitMsgUtils; private final RabbitMsgUtils rabbitMsgUtils;
@Resource
private TokenProvider tokenProvider;
@GetMapping("/activate") @GetMapping("/activate")
@ApiOperation("查询/product") @ApiOperation("查询/product")
@ -138,7 +143,9 @@ public class TbPlaceController {
@PutMapping("/pay") @PutMapping("/pay")
@ApiOperation("代客下单 支付订单") @ApiOperation("代客下单 支付订单")
public ResponseEntity<Object> pay(@Validated @RequestBody PayDTO payDTO) { public ResponseEntity<Object> pay(HttpServletRequest request, @Validated @RequestBody PayDTO payDTO) {
String token = tokenProvider.getToken(request);
payDTO.setToken(token);
return ResponseEntity.ok(tbShopTableService.pay(payDTO)); return ResponseEntity.ok(tbShopTableService.pay(payDTO));
} }

View File

@ -20,4 +20,6 @@ public class PayDTO {
private Double discount; private Double discount;
private Integer vipUserId; private Integer vipUserId;
private String code; private String code;
private String token;
} }

View File

@ -9,10 +9,12 @@ import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.config.security.security.TokenProvider; import cn.ysk.cashier.config.security.security.TokenProvider;
import cn.ysk.cashier.cons.RedisConstant; import cn.ysk.cashier.cons.RedisConstant;
import cn.ysk.cashier.cons.rabbit.RabbitConstants; import cn.ysk.cashier.cons.rabbit.RabbitConstants;
import cn.ysk.cashier.dto.shop.TbShopTableDto;
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
import cn.ysk.cashier.dto.shoptable.*; import cn.ysk.cashier.dto.shoptable.*;
import cn.ysk.cashier.enums.*; import cn.ysk.cashier.enums.*;
import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow; import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
import cn.ysk.cashier.mybatis.mapper.*; import cn.ysk.cashier.mybatis.mapper.*;
import cn.ysk.cashier.mybatis.service.MpCashierCartService; import cn.ysk.cashier.mybatis.service.MpCashierCartService;
import cn.ysk.cashier.mybatis.service.MpOrderDetailService; import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
@ -29,9 +31,11 @@ import cn.ysk.cashier.repository.TbShopPayTypeRepository;
import cn.ysk.cashier.repository.order.TbCashierCartRepository; import cn.ysk.cashier.repository.order.TbCashierCartRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
import cn.ysk.cashier.service.PayService; import cn.ysk.cashier.service.PayService;
import cn.ysk.cashier.service.impl.TbPayServiceImpl; import cn.ysk.cashier.service.impl.TbPayServiceImpl;
import cn.ysk.cashier.service.order.TbOrderInfoService; import cn.ysk.cashier.service.order.TbOrderInfoService;
import cn.ysk.cashier.service.shop.TbShopTableService;
import cn.ysk.cashier.utils.*; import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.PendingCountVO; import cn.ysk.cashier.vo.PendingCountVO;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -39,32 +43,27 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dianguang.cloud.ossservice.model.DateUtils; import com.dianguang.cloud.ossservice.model.DateUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
import cn.ysk.cashier.service.shop.TbShopTableService;
import cn.ysk.cashier.dto.shop.TbShopTableDto;
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import java.io.IOException;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
/** /**
* @author lyf * @author lyf
@ -1603,10 +1602,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
.set(TbOrderDetail::getStatus, "closed")); .set(TbOrderDetail::getStatus, "closed"));
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("token", null); jsonObject.put("token", payDTO.getToken());
jsonObject.put("type", "create"); jsonObject.put("type", "create");
jsonObject.put("orderId", orderInfo.getId()); jsonObject.put("orderId", orderInfo.getId());
rabbitMsgUtils.sendOrderCollectMsg(jsonObject); rabbitMsgUtils.sendOrderCollectMsg(jsonObject,3);
// 打印消息 // 打印消息
if (!shopEatTypeInfoDTO.isDineInAfter()) { if (!shopEatTypeInfoDTO.isDineInAfter()) {

View File

@ -32,7 +32,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
} }
} }
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson, Integer waitTime) { private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson, Integer waitTime) {
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> {
if (waitTime != null) { if (waitTime != null) {
ThreadUtil.sleep(waitTime, TimeUnit.SECONDS); ThreadUtil.sleep(waitTime, TimeUnit.SECONDS);
@ -47,7 +47,11 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true, null); sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true, null);
} }
public void printTicket(String orderId){ public <T> void sendOrderCollectMsg(T data, int waitTime) {
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true, waitTime);
}
public void printTicket(String orderId) {
sendMsg(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, "打印票", false, null); sendMsg(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, "打印票", false, null);
} }
@ -91,7 +95,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
printDTO.setCurrentUserId(SecurityUtils.getCurrentUserId()); printDTO.setCurrentUserId(SecurityUtils.getCurrentUserId());
printDTO.setCurrentUserName(SecurityUtils.getCurrentUsername()); printDTO.setCurrentUserName(SecurityUtils.getCurrentUsername());
printDTO.setCurrentUserNickName(SecurityUtils.getCurrentUserNickName()); printDTO.setCurrentUserNickName(SecurityUtils.getCurrentUserNickName());
}catch (Exception e){ } catch (Exception e) {
log.error("获取当前用户信息失败", e); log.error("获取当前用户信息失败", e);
} }
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印", true, null); sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印", true, null);
@ -106,12 +110,12 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
} }
public void buildCurrentUserInfo(JSONObject jsonObject){ public void buildCurrentUserInfo(JSONObject jsonObject) {
try { try {
jsonObject.put("currentUserId", SecurityUtils.getCurrentUserId()); jsonObject.put("currentUserId", SecurityUtils.getCurrentUserId());
jsonObject.put("currentUserName", SecurityUtils.getCurrentUsername()); jsonObject.put("currentUserName", SecurityUtils.getCurrentUsername());
jsonObject.put("currentUserNickName", SecurityUtils.getCurrentUserNickName()); jsonObject.put("currentUserNickName", SecurityUtils.getCurrentUserNickName());
}catch (Exception e){ } catch (Exception e) {
log.error("获取当前用户信息失败", e); log.error("获取当前用户信息失败", e);
} }
} }