Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
758e556975
|
|
@ -2,10 +2,57 @@ package cn.ysk.cashier.cons;
|
|||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public interface TableConstant {
|
||||
|
||||
String CART_SEAT_ID = "-999";
|
||||
|
||||
class ShopTable {
|
||||
@Getter
|
||||
public enum State {
|
||||
IDLE("idle"), CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using"), CLEANING("cleaning");
|
||||
private final String value;
|
||||
|
||||
State(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CashierCart {
|
||||
public static final String ID = "-999";
|
||||
|
||||
@Getter
|
||||
public enum Status {
|
||||
REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"),
|
||||
UNPAID("unpaid"), PAYING("paying"), RETURN("return"), CANCEL("cancel");
|
||||
private final String value;
|
||||
Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum UseType {
|
||||
TAKEOUT("takeout"),
|
||||
DINE_IN_AFTER("dine-in-after"),
|
||||
DINE_IN_BEFORE("dine-in-before");
|
||||
private final String value;
|
||||
|
||||
UseType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OrderInfo {
|
||||
@Getter
|
||||
public enum Status {
|
||||
|
|
@ -21,7 +68,36 @@ public interface TableConstant {
|
|||
@Getter
|
||||
public enum UseType {
|
||||
TAKEOUT("takeout"),
|
||||
NONE_TABLE("dine-in"),
|
||||
DINE_IN_AFTER("dine-in-after"),
|
||||
DINE_IN_BEFORE("dine-in-before"), NONE_TABLE("dine-in");
|
||||
private final String value;
|
||||
|
||||
UseType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FreeDineRecord {
|
||||
@Getter
|
||||
public enum State {
|
||||
WAIT_PAY(0),
|
||||
SUCCESS_PAY(1),
|
||||
FAIL_PAY(2);
|
||||
private final Integer value;
|
||||
|
||||
State(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum UseType {
|
||||
TAKEOUT("takeout"),
|
||||
DINE_IN_AFTER("dine-in-after"),
|
||||
DINE_IN_BEFORE("dine-in-before");
|
||||
private final String value;
|
||||
|
|
@ -35,4 +111,73 @@ public interface TableConstant {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ShopInfo {
|
||||
@Getter
|
||||
public enum EatModel {
|
||||
TAKEOUT("takeout"),
|
||||
DINE_IN("dine-in");
|
||||
private final String value;
|
||||
|
||||
EatModel(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MemberIn {
|
||||
@Getter
|
||||
public enum Type {
|
||||
NORMAL(0),
|
||||
FREE_DINE(1);
|
||||
private final Integer value;
|
||||
|
||||
Type(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(Integer value) {
|
||||
return Objects.equals(this.value, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ActivateOutRecord {
|
||||
@Getter
|
||||
public enum Type {
|
||||
// 满减
|
||||
FULL_REDUCTION(1),
|
||||
// 商品
|
||||
PRODUCT(2);
|
||||
private final Integer value;
|
||||
|
||||
Type(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(Integer value) {
|
||||
return Objects.equals(this.value, value);
|
||||
}
|
||||
}
|
||||
@Getter
|
||||
public enum Status {
|
||||
CREATE("create"),
|
||||
CANCEL("cancel"),
|
||||
// 商品
|
||||
CLOSED("closed");
|
||||
private final String value;
|
||||
|
||||
Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVals(String value) {
|
||||
return this.value.equals(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public class SuppFlow implements Serializable {
|
|||
public static class ConInfos{
|
||||
private Integer conInfoId;
|
||||
|
||||
private String unit;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
private BigDecimal stockNumber;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,13 @@ public class TbConsInfo implements Serializable {
|
|||
@ApiModelProperty(value = "单位值")
|
||||
private String conUnit;
|
||||
|
||||
@Column(name = "`con_unit_two`")
|
||||
@ApiModelProperty(value = "单位值")
|
||||
private String conUnitTwo;
|
||||
|
||||
@Column(name = "`con_unit_two_convert`")
|
||||
@ApiModelProperty(value = "单位换算")
|
||||
private BigDecimal conUnitTwoConvert;
|
||||
|
||||
@Column(name = "`laster_in_stock`")
|
||||
@ApiModelProperty(value = "最近一次入库量")
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class TbConsInfoV2 implements Serializable {
|
|||
@ApiModelProperty(value = "库存值")
|
||||
private BigDecimal stockNumber;
|
||||
|
||||
// @Column(name = "`balance`")
|
||||
// @Column(name = "`balance`")
|
||||
@ApiModelProperty(value = "实际库存值")
|
||||
private BigDecimal balance;
|
||||
|
||||
|
|
@ -55,6 +55,14 @@ public class TbConsInfoV2 implements Serializable {
|
|||
@ApiModelProperty(value = "单位值")
|
||||
private String conUnit;
|
||||
|
||||
@Column(name = "`con_unit_two`")
|
||||
@ApiModelProperty(value = "单位值")
|
||||
private String conUnitTwo;
|
||||
|
||||
@Column(name = "`con_unit_two_convert`")
|
||||
@ApiModelProperty(value = "单位换算")
|
||||
private BigDecimal conUnitTwoConvert;
|
||||
|
||||
|
||||
@Column(name = "`laster_in_stock`")
|
||||
@ApiModelProperty(value = "最近一次入库量")
|
||||
|
|
|
|||
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* 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.cons.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="view_cons_supp_flow")
|
||||
public class ViewConsSuppFlow implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`con_info_id`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "conInfoId")
|
||||
private Integer conInfoId;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "店铺id")
|
||||
private Integer shopId;
|
||||
|
||||
@Column(name = "`sku_id`")
|
||||
@ApiModelProperty(value = "skuId")
|
||||
private Integer skuId;
|
||||
|
||||
@Column(name = "`product_id`")
|
||||
@ApiModelProperty(value = "productId")
|
||||
private Integer productId;
|
||||
|
||||
@Column(name = "`supplier_id`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "supplierId")
|
||||
private Integer supplierId;
|
||||
|
||||
@Column(name = "`type`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "出入库类型: in 入库 out 出库")
|
||||
private String type;
|
||||
|
||||
@Column(name = "`stock_number`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal stockNumber;
|
||||
|
||||
@Column(name = "`price`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "进价")
|
||||
private BigDecimal price;
|
||||
|
||||
@Column(name = "`amount`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "小计")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "`balance`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "剩余库存")
|
||||
private BigDecimal balance;
|
||||
|
||||
@Column(name = "`accounts_payable`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "应付款")
|
||||
private BigDecimal accountsPayable;
|
||||
|
||||
@Column(name = "`actual_payment`",nullable = false)
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "实付款")
|
||||
private BigDecimal actualPayment;
|
||||
|
||||
@Column(name = "`payment_time`")
|
||||
@ApiModelProperty(value = "paymentTime")
|
||||
private Timestamp paymentTime;
|
||||
|
||||
@Column(name = "`create_time`")
|
||||
@ApiModelProperty(value = "createTime")
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "`update_time`")
|
||||
@ApiModelProperty(value = "updateTime")
|
||||
private Timestamp updateTime;
|
||||
|
||||
@Column(name = "`con_name`")
|
||||
@ApiModelProperty(value = "耗材名称")
|
||||
private String conName;
|
||||
|
||||
@Column(name = "`con_code`")
|
||||
@ApiModelProperty(value = "耗材代码")
|
||||
private String conCode;
|
||||
|
||||
@Column(name = "`con_type_name`")
|
||||
@ApiModelProperty(value = "耗材类型名称")
|
||||
private String conTypeName;
|
||||
|
||||
@Column(name = "`purveyor_name`")
|
||||
@ApiModelProperty(value = "联系人名字")
|
||||
private String purveyorName;
|
||||
|
||||
@Column(name = "`address`")
|
||||
@ApiModelProperty(value = "供应商地址")
|
||||
private String address;
|
||||
|
||||
@Column(name = "`purveyor_telephone`")
|
||||
@ApiModelProperty(value = "联系人电话")
|
||||
private String purveyorTelephone;
|
||||
|
||||
public void copy(ViewConsSuppFlow source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package cn.ysk.cashier.cons.repository;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.TbConUnit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
public interface TbConUnitRepository extends JpaRepository<TbConUnit, Integer>, JpaSpecificationExecutor<TbConUnit> {
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package cn.ysk.cashier.cons.repository;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
public interface ViewConsSuppFlowRepository extends JpaRepository<ViewConsSuppFlow, Integer>, JpaSpecificationExecutor<ViewConsSuppFlow> {
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
package cn.ysk.cashier.cons.rest;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.cons.domain.TbConUnit;
|
||||
import cn.ysk.cashier.cons.service.TbConUnitService;
|
||||
import cn.ysk.cashier.cons.service.dto.TbConUnitQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "耗材单位添加管理")
|
||||
@RequestMapping("/api/tbConUnit")
|
||||
public class TbConUnitController {
|
||||
|
||||
private final TbConUnitService tbConUnitService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportTbConUnit(HttpServletResponse response, TbConUnitQueryCriteria criteria) throws IOException {
|
||||
tbConUnitService.download(tbConUnitService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询耗材单位添加")
|
||||
public ResponseEntity<Object> queryTbConUnit(TbConUnitQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbConUnitService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增耗材单位添加")
|
||||
@ApiOperation("新增耗材单位添加")
|
||||
public ResponseEntity<Object> createTbConUnit(@Validated @RequestBody TbConUnit resources){
|
||||
|
||||
if(ObjectUtil.isEmpty(resources.getParentId())|| Objects.isNull(resources.getParentId())){
|
||||
resources.setParentId(0);
|
||||
}
|
||||
resources.setStatus("0");
|
||||
resources.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||
return new ResponseEntity<>(tbConUnitService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改耗材单位添加")
|
||||
@ApiOperation("修改耗材单位添加")
|
||||
public ResponseEntity<Object> updateTbConUnit(@Validated @RequestBody TbConUnit resources){
|
||||
|
||||
resources.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
tbConUnitService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除耗材单位添加")
|
||||
@ApiOperation("删除耗材单位添加")
|
||||
public ResponseEntity<Object> deleteTbConUnit(@RequestBody Integer[] ids) {
|
||||
tbConUnitService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping("queryTbConUnitInfo")
|
||||
public ResponseEntity<Object> queryTbConUnitInfo(TbConUnitQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbConUnitService.queryAllInfo(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
package cn.ysk.cashier.cons.rest;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
|
||||
import cn.ysk.cashier.cons.service.ViewConsSuppFlowService;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "出入库记录管理")
|
||||
@RequestMapping("/api/viewConsSuppFlow")
|
||||
public class ViewConsSuppFlowController {
|
||||
|
||||
private final ViewConsSuppFlowService viewConsSuppFlowService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportViewConsSuppFlow(HttpServletResponse response, ViewConsSuppFlowQueryCriteria criteria) throws IOException {
|
||||
viewConsSuppFlowService.download(viewConsSuppFlowService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询出入库记录")
|
||||
public ResponseEntity<Object> queryViewConsSuppFlow(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(viewConsSuppFlowService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增出入库记录")
|
||||
@ApiOperation("新增出入库记录")
|
||||
public ResponseEntity<Object> createViewConsSuppFlow(@Validated @RequestBody ViewConsSuppFlow resources){
|
||||
return new ResponseEntity<>(viewConsSuppFlowService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改出入库记录")
|
||||
@ApiOperation("修改出入库记录")
|
||||
public ResponseEntity<Object> updateViewConsSuppFlow(@Validated @RequestBody ViewConsSuppFlow resources){
|
||||
viewConsSuppFlowService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除出入库记录")
|
||||
@ApiOperation("删除出入库记录")
|
||||
public ResponseEntity<Object> deleteViewConsSuppFlow(@RequestBody Integer[] ids) {
|
||||
viewConsSuppFlowService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.TbConUnit;
|
||||
import cn.ysk.cashier.cons.service.dto.TbConUnitDto;
|
||||
import cn.ysk.cashier.cons.service.dto.TbConUnitQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
public interface TbConUnitService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbConUnitQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbConUnitDto>
|
||||
*/
|
||||
List<TbConUnitDto> queryAll(TbConUnitQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbConUnitDto
|
||||
*/
|
||||
TbConUnitDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbConUnitDto
|
||||
*/
|
||||
TbConUnitDto create(TbConUnit resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbConUnit resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbConUnitDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
|
||||
|
||||
Map<String,Object> queryAllInfo(TbConUnitQueryCriteria criteria, Pageable pageable);
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowDto;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
public interface ViewConsSuppFlowService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<ViewConsSuppFlowDto>
|
||||
*/
|
||||
List<ViewConsSuppFlowDto> queryAll(ViewConsSuppFlowQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return ViewConsSuppFlowDto
|
||||
*/
|
||||
ViewConsSuppFlowDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return ViewConsSuppFlowDto
|
||||
*/
|
||||
ViewConsSuppFlowDto create(ViewConsSuppFlow resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(ViewConsSuppFlow resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<ViewConsSuppFlowDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* 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.cons.service.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.sql.Timestamp;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
@Data
|
||||
public class TbConUnitDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/** 主单位名称 */
|
||||
private String name;
|
||||
|
||||
/** 主单位值 */
|
||||
private BigDecimal value;
|
||||
|
||||
private Integer parentId;
|
||||
|
||||
private String isConsume;
|
||||
|
||||
/** 状态 1 启用 0 禁用 */
|
||||
private String status;
|
||||
|
||||
private Timestamp createTime;
|
||||
|
||||
private Timestamp updateTime;
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
@Data
|
||||
public class TbConUnitQueryCriteria{
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String name;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer parentId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String status;
|
||||
}
|
||||
|
|
@ -1,24 +1,7 @@
|
|||
/*
|
||||
* 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.cons.service.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.sql.Timestamp;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
|
@ -53,6 +36,10 @@ public class TbConsInfoDto implements Serializable {
|
|||
/** 单位值 */
|
||||
private String conUnit;
|
||||
|
||||
private String conUnitTwo;
|
||||
|
||||
private BigDecimal conUnitTwoConvert;
|
||||
|
||||
/** 最近一次入库量 */
|
||||
private BigDecimal lasterInStock;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* 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.cons.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
@Data
|
||||
public class ViewConsSuppFlowDto implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer conInfoId;
|
||||
|
||||
/** 店铺id */
|
||||
private Integer shopId;
|
||||
|
||||
private Integer skuId;
|
||||
|
||||
private Integer productId;
|
||||
|
||||
private Integer supplierId;
|
||||
|
||||
/** 出入库类型: in 入库 out 出库 */
|
||||
private String type;
|
||||
|
||||
/** 数量 */
|
||||
private BigDecimal stockNumber;
|
||||
|
||||
/** 进价 */
|
||||
private BigDecimal price;
|
||||
|
||||
/** 小计 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 剩余库存 */
|
||||
private BigDecimal balance;
|
||||
|
||||
/** 应付款 */
|
||||
private BigDecimal accountsPayable;
|
||||
|
||||
/** 实付款 */
|
||||
private BigDecimal actualPayment;
|
||||
|
||||
private Timestamp paymentTime;
|
||||
|
||||
private Timestamp createTime;
|
||||
|
||||
private Timestamp updateTime;
|
||||
|
||||
/** 耗材名称 */
|
||||
private String conName;
|
||||
|
||||
/** 耗材代码 */
|
||||
private String conCode;
|
||||
|
||||
/** 耗材类型名称 */
|
||||
private String conTypeName;
|
||||
|
||||
/** 联系人名字 */
|
||||
private String purveyorName;
|
||||
|
||||
/** 供应商地址 */
|
||||
private String address;
|
||||
|
||||
/** 联系人电话 */
|
||||
private String purveyorTelephone;
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service.dto;
|
||||
|
||||
import cn.ysk.cashier.utils.JSONUtil;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
@Data
|
||||
public class ViewConsSuppFlowQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer conInfoId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String type;
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String conName;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String conCode;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String conTypeName;
|
||||
|
||||
/** 模糊 */
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String purveyorName;
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
System.out.println(JSONUtil.toJSONString(new ViewConsSuppFlowQueryCriteria()));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.cons.domain.TbConUnit;
|
||||
import cn.ysk.cashier.cons.service.dto.ConUnitPO;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.cons.repository.TbConUnitRepository;
|
||||
import cn.ysk.cashier.cons.service.TbConUnitService;
|
||||
import cn.ysk.cashier.cons.service.dto.TbConUnitDto;
|
||||
import cn.ysk.cashier.cons.service.dto.TbConUnitQueryCriteria;
|
||||
import cn.ysk.cashier.cons.service.mapstruct.TbConUnitMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbConUnitServiceImpl implements TbConUnitService {
|
||||
|
||||
private final TbConUnitRepository tbConUnitRepository;
|
||||
private final TbConUnitMapper tbConUnitMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbConUnitQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbConUnit> page = tbConUnitRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbConUnitMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbConUnitDto> queryAll(TbConUnitQueryCriteria criteria){
|
||||
return tbConUnitMapper.toDto(tbConUnitRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbConUnitDto findById(Integer id) {
|
||||
TbConUnit tbConUnit = tbConUnitRepository.findById(id).orElseGet(TbConUnit::new);
|
||||
ValidationUtil.isNull(tbConUnit.getId(),"TbConUnit","id",id);
|
||||
return tbConUnitMapper.toDto(tbConUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbConUnitDto create(TbConUnit resources) {
|
||||
return tbConUnitMapper.toDto(tbConUnitRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbConUnit resources) {
|
||||
TbConUnit tbConUnit = tbConUnitRepository.findById(resources.getId()).orElseGet(TbConUnit::new);
|
||||
ValidationUtil.isNull( tbConUnit.getId(),"TbConUnit","id",resources.getId());
|
||||
tbConUnit.copy(resources);
|
||||
tbConUnitRepository.save(tbConUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbConUnitRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbConUnitDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbConUnitDto tbConUnit : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("主单位名称", tbConUnit.getName());
|
||||
map.put("主单位值", tbConUnit.getValue());
|
||||
map.put("状态 1 启用 0 禁用", tbConUnit.getStatus());
|
||||
map.put(" createTime", tbConUnit.getCreateTime());
|
||||
map.put(" updateTime", tbConUnit.getUpdateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAllInfo(TbConUnitQueryCriteria criteria, Pageable pageable) {
|
||||
List<ConUnitPO> list=new ArrayList<>();
|
||||
if(ObjectUtil.isEmpty(criteria.getParentId())){
|
||||
criteria.setParentId(0);
|
||||
}
|
||||
Page<TbConUnit> page = tbConUnitRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
if(Objects.nonNull(page)&&Objects.nonNull(page.getContent())){
|
||||
page.getContent().parallelStream().forEach(it->{
|
||||
ConUnitPO po=new ConUnitPO();
|
||||
po.setId(it.getId());
|
||||
po.setName(it.getName());
|
||||
po.setValue(it.getValue());
|
||||
po.setIsConsume(it.getIsConsume());
|
||||
po.setCreateTime(it.getCreateTime());
|
||||
po.setUpdateTime(it.getUpdateTime());
|
||||
|
||||
criteria.setParentId(it.getId());
|
||||
criteria.setName(null);
|
||||
criteria.setStatus(null);
|
||||
Page<TbConUnit> childPage = tbConUnitRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
if(Objects.nonNull(childPage)&&Objects.nonNull(childPage.getContent())){
|
||||
List<ConUnitPO> list1=new ArrayList<>();
|
||||
for (TbConUnit tbConUnit : childPage.getContent()) {
|
||||
ConUnitPO child=new ConUnitPO();
|
||||
child.setId(tbConUnit.getId());
|
||||
child.setName(tbConUnit.getName());
|
||||
child.setValue(tbConUnit.getValue());
|
||||
child.setIsConsume(tbConUnit.getIsConsume());
|
||||
child.setCreateTime(tbConUnit.getCreateTime());
|
||||
child.setUpdateTime(tbConUnit.getUpdateTime());
|
||||
list1.add(child);
|
||||
}
|
||||
po.setChildConUnit(list1);
|
||||
}
|
||||
list.add(po);
|
||||
});
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",list);
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
return map;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -114,6 +114,8 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
|
|||
criteria.setBizCode(Arrays.asList("stockIn","cancelCart","init","stockIn","checkStockIn","stockOtherIn","cancelCart","createCart","stockout","checkStockOut","frmLoss"));
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
criteria.setBizCode(Arrays.asList("stockIn","cancelCart","init","stockIn","checkStockIn","stockOtherIn","cancelCart","createCart","stockout","checkStockOut","frmLoss"));
|
||||
}
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
|
|
|
|||
|
|
@ -229,6 +229,11 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
log.info("耗材信息不存在");
|
||||
continue;
|
||||
}
|
||||
BigDecimal changeStock = conInfos.getStockNumber();
|
||||
//副单位的实际修改值
|
||||
if (StringUtils.isNotBlank(conInfos.getUnit()) && conInfos.getUnit().equals(info.getConUnitTwo())) {
|
||||
changeStock = conInfos.getStockNumber().multiply(info.getConUnitTwoConvert()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
TbConsSuppFlow suppFlow = new TbConsSuppFlow();
|
||||
|
||||
|
|
@ -246,17 +251,17 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
suppFlow.setShopId(resources.getShopId());
|
||||
suppFlow.setSupplierId(Objects.isNull(resources.getSupplierId()) ? 0 : resources.getSupplierId());
|
||||
suppFlow.setType(resources.getType());
|
||||
suppFlow.setStockNumber(conInfos.getStockNumber());
|
||||
|
||||
suppFlow.setStockNumber(changeStock);
|
||||
//实际库存
|
||||
BigDecimal amount = info.getStockNumber().subtract(info.getStockConsume());
|
||||
|
||||
|
||||
if ("in".equals(resources.getType())) {
|
||||
stockOperate.setSubType(1);
|
||||
info.setStockNumber(info.getStockNumber().add(conInfos.getStockNumber()));
|
||||
info.setLasterInStock(conInfos.getStockNumber());
|
||||
info.setStockNumber(info.getStockNumber().add(changeStock));
|
||||
info.setLasterInStock(changeStock);
|
||||
|
||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).add(conInfos.getStockNumber()));
|
||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).add(changeStock));
|
||||
|
||||
|
||||
flow.setBizCode("stockIn");
|
||||
|
|
@ -268,19 +273,19 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())));
|
||||
purveyorTransact.setType("cons_in");
|
||||
|
||||
object.put("number", conInfos.getStockNumber());
|
||||
object.put("number", changeStock);
|
||||
}
|
||||
else if ("out".equals(resources.getType())) {
|
||||
stockOperate.setSubType(-1);
|
||||
|
||||
if (conInfos.getStockNumber().compareTo(info.getStockNumber().subtract(info.getStockConsume())) > 0) {
|
||||
if (changeStock.compareTo(amount) > 0) {
|
||||
throw new BadRequestException("出库数量大于现有的库存数量");
|
||||
}
|
||||
|
||||
info.setStockNumber(info.getStockNumber().subtract(conInfos.getStockNumber()));
|
||||
info.setStockNumber(info.getStockNumber().subtract(changeStock));
|
||||
|
||||
|
||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(conInfos.getStockNumber()));
|
||||
suppFlow.setBalance(info.getStockNumber().subtract(info.getStockConsume()).subtract(changeStock));
|
||||
|
||||
|
||||
flow.setBizCode("stockout");
|
||||
|
|
@ -292,7 +297,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
|
||||
purveyorTransact.setWaitAmount((resources.getAccountsPayable().subtract(resources.getActualPayment())).negate());
|
||||
purveyorTransact.setType("cons_out");
|
||||
object.put("number", conInfos.getStockNumber());
|
||||
object.put("number", changeStock);
|
||||
}
|
||||
else {
|
||||
throw new BadRequestException("错误操作类型");
|
||||
|
|
@ -302,7 +307,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
object.put("stockNumber", amount);
|
||||
|
||||
object.put("name", info.getConName());
|
||||
object.put("unitName", info.getConUnit());
|
||||
object.put("unitName", StringUtils.isBlank(conInfos.getUnit()) ? info.getConUnit() : conInfos.getUnit());
|
||||
array.add(object);
|
||||
|
||||
suppFlow.setPrice(conInfos.getPrice());
|
||||
|
|
@ -319,7 +324,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
}
|
||||
|
||||
purveyorTransact.setPaidAt(System.currentTimeMillis());
|
||||
|
||||
//供应商
|
||||
purveyorTransactRepository.save(purveyorTransact);
|
||||
if (resources.getSupplierId() != null) {
|
||||
tbShopPurveyorRepository.upLastTransactAt(resources.getSupplierId().toString());
|
||||
|
|
@ -333,7 +338,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
|||
flow.setConsId(info.getId());
|
||||
flow.setShopId(info.getShopId());
|
||||
flow.setConName(info.getConName());
|
||||
flow.setAmount(conInfos.getStockNumber());
|
||||
flow.setAmount(changeStock);
|
||||
flow.setRemark(resources.getRemark());
|
||||
flow.setBalance(info.getStockNumber().subtract(info.getStockConsume()));
|
||||
flow.setOperator(SecurityUtils.getCurrentUserNickName());
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service.impl;
|
||||
|
||||
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.utils.QueryHelp;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.cons.repository.ViewConsSuppFlowRepository;
|
||||
import cn.ysk.cashier.cons.service.ViewConsSuppFlowService;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowDto;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowQueryCriteria;
|
||||
import cn.ysk.cashier.cons.service.mapstruct.ViewConsSuppFlowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ViewConsSuppFlowServiceImpl implements ViewConsSuppFlowService {
|
||||
|
||||
private final ViewConsSuppFlowRepository viewConsSuppFlowRepository;
|
||||
private final ViewConsSuppFlowMapper viewConsSuppFlowMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(ViewConsSuppFlowQueryCriteria criteria, Pageable pageable){
|
||||
Page<ViewConsSuppFlow> page = viewConsSuppFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(viewConsSuppFlowMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ViewConsSuppFlowDto> queryAll(ViewConsSuppFlowQueryCriteria criteria){
|
||||
return viewConsSuppFlowMapper.toDto(viewConsSuppFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ViewConsSuppFlowDto findById(Integer id) {
|
||||
ViewConsSuppFlow viewConsSuppFlow = viewConsSuppFlowRepository.findById(id).orElseGet(ViewConsSuppFlow::new);
|
||||
ValidationUtil.isNull(viewConsSuppFlow.getId(),"ViewConsSuppFlow","id",id);
|
||||
return viewConsSuppFlowMapper.toDto(viewConsSuppFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ViewConsSuppFlowDto create(ViewConsSuppFlow resources) {
|
||||
return viewConsSuppFlowMapper.toDto(viewConsSuppFlowRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(ViewConsSuppFlow resources) {
|
||||
ViewConsSuppFlow viewConsSuppFlow = viewConsSuppFlowRepository.findById(resources.getId()).orElseGet(ViewConsSuppFlow::new);
|
||||
ValidationUtil.isNull( viewConsSuppFlow.getId(),"ViewConsSuppFlow","id",resources.getId());
|
||||
viewConsSuppFlow.copy(resources);
|
||||
viewConsSuppFlowRepository.save(viewConsSuppFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
viewConsSuppFlowRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<ViewConsSuppFlowDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (ViewConsSuppFlowDto viewConsSuppFlow : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put(" conInfoId", viewConsSuppFlow.getConInfoId());
|
||||
map.put("店铺id", viewConsSuppFlow.getShopId());
|
||||
map.put(" skuId", viewConsSuppFlow.getSkuId());
|
||||
map.put(" productId", viewConsSuppFlow.getProductId());
|
||||
map.put(" supplierId", viewConsSuppFlow.getSupplierId());
|
||||
map.put("出入库类型: in 入库 out 出库", viewConsSuppFlow.getType());
|
||||
map.put("数量", viewConsSuppFlow.getStockNumber());
|
||||
map.put("进价", viewConsSuppFlow.getPrice());
|
||||
map.put("小计", viewConsSuppFlow.getAmount());
|
||||
map.put("剩余库存", viewConsSuppFlow.getBalance());
|
||||
map.put("应付款", viewConsSuppFlow.getAccountsPayable());
|
||||
map.put("实付款", viewConsSuppFlow.getActualPayment());
|
||||
map.put(" paymentTime", viewConsSuppFlow.getPaymentTime());
|
||||
map.put(" createTime", viewConsSuppFlow.getCreateTime());
|
||||
map.put(" updateTime", viewConsSuppFlow.getUpdateTime());
|
||||
map.put("耗材名称", viewConsSuppFlow.getConName());
|
||||
map.put("耗材代码", viewConsSuppFlow.getConCode());
|
||||
map.put("耗材类型名称", viewConsSuppFlow.getConTypeName());
|
||||
map.put("联系人名字", viewConsSuppFlow.getPurveyorName());
|
||||
map.put("供应商地址", viewConsSuppFlow.getAddress());
|
||||
map.put("联系人电话", viewConsSuppFlow.getPurveyorTelephone());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service.mapstruct;
|
||||
|
||||
import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.cons.domain.TbConUnit;
|
||||
import cn.ysk.cashier.cons.service.dto.TbConUnitDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-12
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbConUnitMapper extends BaseMapper<TbConUnitDto, TbConUnit> {
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package cn.ysk.cashier.cons.service.mapstruct;
|
||||
|
||||
import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.cons.domain.ViewConsSuppFlow;
|
||||
import cn.ysk.cashier.cons.service.dto.ViewConsSuppFlowDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @date 2024-07-03
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface ViewConsSuppFlowMapper extends BaseMapper<ViewConsSuppFlowDto, ViewConsSuppFlow> {
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
|
|
@ -33,6 +34,7 @@ public class SummaryByDayController {
|
|||
|
||||
|
||||
@GetMapping
|
||||
@AnonymousGetMapping
|
||||
public Page<T> shopSummary(ShopSummaryDto summaryDto,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ public class ReturnCartDTO {
|
|||
private Integer cartId;
|
||||
@NotNull
|
||||
private Integer shopId;
|
||||
@NotNull
|
||||
private Long tableId;
|
||||
@NotNull
|
||||
@Min(value = 1, message = "最小数量为1")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.cons.TableConstant;
|
||||
import cn.ysk.cashier.enums.OrderStatusEnums;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
|
@ -48,5 +49,11 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
|||
*/
|
||||
boolean clearCartByTableIdAndUseType(String tableId, String useType, Integer shopId);
|
||||
|
||||
/**
|
||||
* 根据订单id更改购物车状态
|
||||
* @param status 状态
|
||||
* @param orderId 订单id
|
||||
*/
|
||||
boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import cn.ysk.cashier.mybatis.service.MpCashierCartService;
|
|||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -85,5 +86,12 @@ public class MpCashierCartServiceImpl extends ServiceImpl<TbCashierCartMapper, T
|
|||
.eq(TbCashierCart::getTableId, tableId)
|
||||
.eq(TbCashierCart::getUseType, useType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStateByOrderId(TableConstant.OrderInfo.Status status, Integer orderId) {
|
||||
return update(new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, orderId)
|
||||
.set(TbCashierCart::getStatus, status.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||
List<TbOrderDetail> searchDetailByOrderIds(@Param("ids")List<Integer> ids);
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayV2Vo(" +
|
||||
"info.productName,pro.id, cate.name,'', " +
|
||||
"info.productName,pro.id, cate.name,pro.typeEnum, " +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as salesNum, " +
|
||||
"SUM(CASE WHEN orders.orderType='return' THEN info.num ELSE 0 END), " +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.priceAmount ELSE 0 END), " +
|
||||
|
|
@ -82,15 +82,16 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
|
|||
"SUM(CASE WHEN orders.orderType='return' THEN info.priceAmount ELSE 0 END)) " +
|
||||
"FROM TbOrderInfo orders " +
|
||||
"LEFT JOIN TbOrderDetail info on orders.id=info.orderId " +
|
||||
"INNER JOIN TbProduct pro ON info.productId = pro.id AND pro.id= :proId " +
|
||||
"INNER JOIN TbProduct pro ON info.productId = pro.id " +
|
||||
" AND pro.typeEnum= 'sku' " +
|
||||
"LEFT JOIN TbShopCategory cate ON cate.id = pro.categoryId " +
|
||||
"WHERE info.shopId = :shopId " +
|
||||
"AND info.createTime > :startTime AND info.createTime < :endTime " +
|
||||
"AND (info.status = 'closed' OR info.status = 'refund') " +
|
||||
"GROUP BY info.productId, info.productSkuId " +
|
||||
"ORDER BY salesNum DESC")
|
||||
List<TbOrderSalesCountByDayV2Vo> queryTbOrderSalesCountBySku(@Param("shopId") Integer shopId,@Param("proId")Integer proId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
List<TbOrderSalesCountByDayV2Vo> queryTbOrderSalesCountBySku(@Param("shopId") Integer shopId
|
||||
, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
@Query("SELECT new cn.ysk.cashier.vo.TbOrderSalesCountByDayVo(" +
|
||||
"info.productName, info.productSkuName, cate.name, unit.name,info.price," +
|
||||
"SUM(CASE WHEN orders.orderType!='return' THEN info.num ELSE 0 END) as salesNum, " +
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package cn.ysk.cashier.service;
|
|||
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
|
@ -12,7 +13,7 @@ import java.math.BigDecimal;
|
|||
public interface TbPayService {
|
||||
TbOrderInfo scanPay(Integer shopId, String code, Integer merchantId, Integer memberId, BigDecimal payMount, TbOrderInfo orderInfo);
|
||||
|
||||
void vipPay(BigDecimal payMount, Integer vipUserId);
|
||||
TbShopUser vipPay(BigDecimal payMount, Integer vipUserId);
|
||||
|
||||
TbOrderInfo cashPay(PayDTO payDTO);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -35,6 +36,7 @@ import java.time.Instant;
|
|||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -333,12 +335,45 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
summaryDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
summaryDto.setEndTime(new Date());
|
||||
}
|
||||
Page<TbOrderSalesCountByDayV2Vo> products = detailRepository.queryTbOrderSalesCountByProduct(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||
for (TbOrderSalesCountByDayV2Vo product : products) {
|
||||
List<TbOrderSalesCountByDayV2Vo> skus = detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), product.getProductId(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
product.setSkus(skus);
|
||||
|
||||
// 使用 CompletableFuture 并行执行两个数据库查询
|
||||
CompletableFuture<Page<TbOrderSalesCountByDayV2Vo>> productsFuture = CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return detailRepository.queryTbOrderSalesCountByProduct(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime(), pageable);
|
||||
} catch (Exception e) {
|
||||
log.error("查询 products 时发生错误", e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
CompletableFuture<List<TbOrderSalesCountByDayV2Vo>> skusFuture = CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
} catch (Exception e) {
|
||||
log.error("查询 skus 时发生错误", e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
try {
|
||||
// 等待两个查询都完成后执行后续逻辑
|
||||
return CompletableFuture.allOf(productsFuture, skusFuture).thenApply(v -> {
|
||||
Page<TbOrderSalesCountByDayV2Vo> products = productsFuture.join();
|
||||
List<TbOrderSalesCountByDayV2Vo> skus = skusFuture.join();
|
||||
if (products!= null && skus!= null) {
|
||||
Map<Integer, List<TbOrderSalesCountByDayV2Vo>> collect = skus.stream().collect(Collectors.groupingBy(TbOrderSalesCountByDayV2Vo::getProductId));
|
||||
for (TbOrderSalesCountByDayV2Vo product : products) {
|
||||
if ("sku".equals(product.getTypeEnum())) {
|
||||
product.setSkus(collect.get(product.getProductId()));
|
||||
}
|
||||
}
|
||||
return (Page<T>) products;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}).join();
|
||||
} catch (Exception e) {
|
||||
log.error("处理查询结果时发生错误", e);
|
||||
return null;
|
||||
}
|
||||
return (Page<T>)products;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -353,10 +388,12 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
}
|
||||
|
||||
List<TbOrderSalesCountByDayV2Vo> products = detailRepository.queryTbOrderSalesCountByProduct(Integer.valueOf(summaryDto.getShopId()), summaryDto.getCateId(), summaryDto.getProName(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
List<TbOrderSalesCountByDayV2Vo> proSkus = detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()),
|
||||
summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
Map<Integer, List<TbOrderSalesCountByDayV2Vo>> collect = proSkus.stream().collect(Collectors.groupingBy(TbOrderSalesCountByDayV2Vo::getProductId));
|
||||
for (TbOrderSalesCountByDayV2Vo product : products) {
|
||||
if("sku".equals(product.getTypeEnum())){
|
||||
List<TbOrderSalesCountByDayV2Vo> skus = detailRepository.queryTbOrderSalesCountBySku(Integer.valueOf(summaryDto.getShopId()), product.getProductId(), summaryDto.getStartTime(), summaryDto.getEndTime());
|
||||
product.setSkus(skus);
|
||||
product.setSkus(collect.get(product.getProductId()));
|
||||
}
|
||||
}
|
||||
for (TbOrderSalesCountByDayV2Vo product : products) {
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void vipPay(BigDecimal payMount, Integer vipUserId) {
|
||||
public TbShopUser vipPay(BigDecimal payMount, Integer vipUserId) {
|
||||
|
||||
// 扣减会员余额
|
||||
TbShopUser shopUser = shopUserMapper.selectOne(new LambdaUpdateWrapper<TbShopUser>()
|
||||
|
|
@ -317,7 +317,7 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
throw new BadRequestException("用户不存在或已被禁用");
|
||||
}
|
||||
|
||||
long flag = shopUserMapper.decrBalance(vipUserId, payMount);
|
||||
long flag = shopUserMapper.decrBalance(shopUser.getId(), payMount);
|
||||
if (flag < 1) {
|
||||
throw new BadRequestException("余额不足或扣除余额失败");
|
||||
}
|
||||
|
|
@ -332,6 +332,8 @@ public class TbPayServiceImpl implements TbPayService {
|
|||
userFlow.setType("-");
|
||||
shopUserFlowMapper.insert(userFlow);
|
||||
|
||||
return shopUser;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,14 +14,8 @@ import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
|||
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.*;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbOrderDetailMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpOrderDetailService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.*;
|
||||
import cn.ysk.cashier.mybatis.service.impl.MpOrderDetailServiceImpl;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
|
|
@ -30,6 +24,7 @@ import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
|||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||
|
|
@ -110,6 +105,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
private final PayService payService;
|
||||
private final MpOrderDetailService mpOrderDetailService;
|
||||
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||
private final MpCashierCartService mpCashierCartService;
|
||||
private final MpShopInfoMapper mpShopInfoMapper;
|
||||
|
||||
@Value("${thirdPay.url}")
|
||||
private String url;
|
||||
|
|
@ -168,6 +165,13 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
return predicate;
|
||||
}, pageable);
|
||||
|
||||
List<String> shopIds = page.getContent().stream().map(TbOrderInfo::getShopId).distinct().collect(Collectors.toList());
|
||||
HashMap<String, TbShopInfo> shopInfoMap = new HashMap<>();
|
||||
if (!shopIds.isEmpty()) {
|
||||
mpShopInfoMapper.selectBatchIds(shopIds).forEach(item -> {
|
||||
shopInfoMap.put(item.getId().toString(), item);
|
||||
});
|
||||
}
|
||||
List<TbOrderInfoVo> orderInfoVoList = new ArrayList<>();
|
||||
for (TbOrderInfo tbOrderInfo : page.getContent()) {
|
||||
TbOrderInfoVo orderInfoVo = new TbOrderInfoVo();
|
||||
|
|
@ -210,6 +214,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
orderInfoVo.setSeatInfo(seatInfo);
|
||||
BeanUtils.copyProperties(tbOrderInfo, orderInfoVo);
|
||||
orderInfoVo.setRefundAmount(refundAmount);
|
||||
TbShopInfo shopInfo = shopInfoMap.get(tbOrderInfo.getShopId());
|
||||
if (shopInfo != null) {
|
||||
orderInfoVo.setRegisterType(shopInfo.getRegisterType());
|
||||
}
|
||||
orderInfoVoList.add(orderInfoVo);
|
||||
}
|
||||
return PageUtil.toPage(orderInfoVoList, page.getTotalElements());
|
||||
|
|
@ -317,15 +325,14 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
// dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
// }
|
||||
dto.setDetailList(details);
|
||||
List<TbCashierCart> tbCashierCarts = tbCashierCartMapper.selectList(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, id)
|
||||
.eq(TbCashierCart::getUseType, tbOrderInfo.getUseType())
|
||||
.eq(TbCashierCart::getProductId, TableConstant.CART_SEAT_ID)
|
||||
.orderByDesc(TbCashierCart::getId));
|
||||
TbCashierCart cashierCart = tbCashierCarts.isEmpty() ? null : tbCashierCarts.get(0);
|
||||
List<TbOrderDetail> tbCashierCarts = tbOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, id)
|
||||
.eq(TbOrderDetail::getProductId, TableConstant.CART_SEAT_ID)
|
||||
.orderByDesc(TbOrderDetail::getId));
|
||||
TbOrderDetail cashierCart = tbCashierCarts.isEmpty() ? null : tbCashierCarts.get(0);
|
||||
Map<String, Object> map = BeanUtil.beanToMap(cashierCart, false, false);
|
||||
if (cashierCart != null) {
|
||||
map.put("cartId", cashierCart.getId());
|
||||
map.put("cartId", cashierCart.getCartId());
|
||||
TbOrderDetail orderDetail = details.stream().filter(item -> item.getCartId().equals(cashierCart.getId())).findFirst().orElse(null);
|
||||
map.put("id", orderDetail != null ? orderDetail.getId() : null);
|
||||
}
|
||||
|
|
@ -422,13 +429,35 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upOrderStatus(TbOrderInfo tbOrderInfo) {
|
||||
tbOrderInfo.setStatus("cancelled");
|
||||
//订单取消 赠送商品数量返回
|
||||
QueryWrapper<TbActivateOutRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", tbOrderInfo.getId());
|
||||
queryWrapper.eq("status", "create");
|
||||
List<TbActivateOutRecord> outRecords = outRecordService.list(queryWrapper);
|
||||
for (TbActivateOutRecord outRecord : outRecords) {
|
||||
TbActivateInRecord inRecord = inRecordService.getById(outRecord.getGiveId());
|
||||
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getUseNum());
|
||||
inRecordService.updateById(inRecord);
|
||||
}
|
||||
LambdaUpdateWrapper<TbActivateOutRecord> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(TbActivateOutRecord::getOrderId, tbOrderInfo.getId())
|
||||
.eq(TbActivateOutRecord::getStatus, "create")
|
||||
.set(TbActivateOutRecord::getStatus, "cancel");
|
||||
outRecordService.update(lambdaUpdateWrapper);
|
||||
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (TbOrderDetail detail : details) {
|
||||
detail.setStatus("cancelled");
|
||||
// 返还库存
|
||||
productService.returnStockByPro(detail.getProductId(), detail.getProductSkuId(), detail.getNum());
|
||||
tbOrderDetailRepository.save(detail);
|
||||
keys.add(CacheKey.PRODUCT_SKU + detail.getShopId() + ":" + detail.getId());
|
||||
}
|
||||
|
||||
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, tbOrderInfo.getId());
|
||||
String[] keysArray = keys.toArray(new String[keys.size()]);
|
||||
redisUtils.del(keysArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -576,7 +605,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||
if (user == null) {
|
||||
throw new BadRequestException("用户信息不存在");
|
||||
}
|
||||
tbMShopUserMapper.incrBalance(userId, shopId, returnAmount, cn.hutool.core.date.DateUtil.current());
|
||||
tbMShopUserMapper.incrBalance(user.getId(), shopId, returnAmount, cn.hutool.core.date.DateUtil.current());
|
||||
|
||||
TbShopUserFlow flow = new TbShopUserFlow();
|
||||
flow.setShopUserId(user.getId());
|
||||
|
|
|
|||
|
|
@ -117,10 +117,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
private final PayService payService;
|
||||
private final TbOrderInfoService orderInfoService;
|
||||
private final MpOrderInfoService mpOrderInfoService;
|
||||
private final TbShopUserMapper tbShopUserMapper;
|
||||
|
||||
private TbOrderInfo getCurrentOrder(ShopEatTypeInfoDTO eatTypeInfoDTO) {
|
||||
// 获取当前台桌最新订单,先付款模式不获取
|
||||
if (eatTypeInfoDTO.isDineInBefore()) {
|
||||
if (!eatTypeInfoDTO.isDineInAfter()) {
|
||||
return null;
|
||||
}
|
||||
List<TbOrderInfo> orderInfoList = orderInfoMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(1, 1), new LambdaQueryWrapper<TbOrderInfo>()
|
||||
|
|
@ -419,9 +420,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (updateCartDTO.getIsPack() != null) {
|
||||
if (!updateCartDTO.getIsPack()) {
|
||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||
tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(BigDecimal.valueOf(updateCartDTO.getNum())));
|
||||
} else {
|
||||
tbCashierCart.setPackFee(new BigDecimal(updateCartDTO.getNum()).multiply(product.getPackFee()));
|
||||
tbCashierCart.setTotalAmount(tbCashierCart.getTotalAmount().add(tbCashierCart.getPackFee()));
|
||||
tbCashierCart.setTotalAmount(tbCashierCart.getSalePrice().multiply(BigDecimal.valueOf(updateCartDTO.getNum()))
|
||||
.add(tbCashierCart.getPackFee()));
|
||||
}
|
||||
tbCashierCart.setIsPack(updateCartDTO.getIsPack() ? "true" : "false");
|
||||
}
|
||||
|
|
@ -645,11 +648,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
@Override
|
||||
public void returnCart(ReturnCartDTO removeCartDTO) {
|
||||
boolean isSeatCart = TableConstant.CashierCart.ID.equals(removeCartDTO.getCartId().toString());
|
||||
// 会员点单
|
||||
TbCashierCart cashierCart = cashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, removeCartDTO.getShopId())
|
||||
.in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue())
|
||||
.isNotNull(TbCashierCart::getOrderId)
|
||||
// .in(TbCashierCart::getStatus, OrderStatusEnums.CREATE.getValue())
|
||||
.ne(TbCashierCart::getStatus, TableConstant.OrderInfo.Status.RETURN.getValue())
|
||||
// .isNotNull(TbCashierCart::getOrderId)
|
||||
.eq(TbCashierCart::getId, removeCartDTO.getCartId()));
|
||||
|
||||
if (cashierCart == null) {
|
||||
|
|
@ -660,16 +665,16 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
throw new BadRequestException("最大退菜数量为: {}", cashierCart.getNumber());
|
||||
}
|
||||
|
||||
|
||||
if (cashierCart.getOrderId() == null) {
|
||||
throw new BadRequestException("此商品还未下单,无需退单");
|
||||
}
|
||||
|
||||
|
||||
// 餐位费直接删除
|
||||
TbOrderDetail orderDetail = orderDetailMapper.selectOne(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getCartId, cashierCart.getId()));
|
||||
|
||||
if (cashierCart.getProductId().equals("-999")) {
|
||||
if (false && cashierCart.getProductId().equals("-999")) {
|
||||
cashierCartMapper.deleteById(cashierCart.getId());
|
||||
cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getId, cashierCart.getId())
|
||||
|
|
@ -698,7 +703,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.eq(TbOrderDetail::getId, tbOrderDetail.getId())
|
||||
.set(TbOrderDetail::getUpdateTime, DateUtil.date())
|
||||
.set(TbOrderDetail::getStatus, "return"));
|
||||
rabbitMsgUtils.printDishesTicket(tbOrderDetail.getOrderId(), true, tbOrderDetail);
|
||||
if (TableConstant.OrderInfo.UseType.DINE_IN_AFTER.equalsVals(tbOrderDetail.getUseType()) && !isSeatCart) {
|
||||
rabbitMsgUtils.printDishesTicket(tbOrderDetail.getOrderId(), true, tbOrderDetail);
|
||||
}
|
||||
} else {
|
||||
//生成退菜的购物车记录
|
||||
TbCashierCart returnCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class);
|
||||
|
|
@ -723,7 +730,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
cashierCartMapper.updateNumAmountStatus(cashierCart.getId(), cashierCart.getStatus(), -returnCart.getNumber());
|
||||
orderDetailMapper.updateNumAmountStatus(orderDetail.getId(), orderDetail.getStatus(), -returnCart.getNumber());
|
||||
rabbitMsgUtils.printDishesTicket(returnOrderDetail.getOrderId(), true, returnOrderDetail);
|
||||
if (TableConstant.OrderInfo.UseType.DINE_IN_AFTER.equalsVals(tbOrderDetail.getUseType()) && !isSeatCart) {
|
||||
rabbitMsgUtils.printDishesTicket(returnOrderDetail.getOrderId(), true, returnOrderDetail);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -781,7 +790,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
if (!shopEatTypeInfoDTO.isTakeout()) {
|
||||
if (StrUtil.isBlank(tableId)) {
|
||||
queryWrapper.isNull(TbCashierCart::getTableId);
|
||||
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
|
||||
} else {
|
||||
queryWrapper.eq(TbCashierCart::getTableId, tableId);
|
||||
}
|
||||
|
|
@ -1127,7 +1136,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
}
|
||||
queryWrapper.eq(TbCashierCart::getTableId, createOrderDTO.getTableId());
|
||||
} else {
|
||||
queryWrapper.isNull(TbCashierCart::getTableId);
|
||||
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1246,6 +1255,15 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (orderId != null) {
|
||||
orderInfo = orderInfoMapper.selectById(orderId);
|
||||
}
|
||||
|
||||
TbShopUser shopUser = null;
|
||||
if (StrUtil.isNotBlank(createOrderDTO.getVipUserId())) {
|
||||
shopUser = tbShopUserMapper.selectById(createOrderDTO.getVipUserId());
|
||||
if (shopUser == null) {
|
||||
throw new BadRequestException("用户不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 是否是第一次创建订单
|
||||
boolean isFirst = false;
|
||||
// 修改订单信息
|
||||
|
|
@ -1269,7 +1287,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
orderInfo.setSeatCount(seatCart.getNumber());
|
||||
}
|
||||
if (StrUtil.isNotBlank(createOrderDTO.getVipUserId())) {
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId());
|
||||
orderInfo.setMemberId(createOrderDTO.getVipUserId());
|
||||
orderInfo.setUserId(shopUser.getUserId());
|
||||
}
|
||||
orderInfo.setSendType(shopEatTypeInfoDTO.getSendType());
|
||||
// 存在新添加的商品,增加下单次数
|
||||
|
|
@ -1305,6 +1324,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
orderInfo.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||
if (StrUtil.isNotBlank(createOrderDTO.getVipUserId())) {
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId());
|
||||
orderInfo.setUserId(shopUser.getUserId());
|
||||
}
|
||||
if (seatCart != null) {
|
||||
orderInfo.setSeatAmount(seatCart.getTotalAmount());
|
||||
|
|
@ -1379,9 +1399,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
addGlobalCode(cn.ysk.cashier.utils.DateUtils.getDay(), "pc", String.valueOf(createOrderDTO.getShopId()));
|
||||
}
|
||||
|
||||
if (shopEatTypeInfoDTO.isIncrMaterId() && "pending".equals(orderInfo.getStatus())) {
|
||||
if (shopEatTypeInfoDTO.isIncrMaterId() || "pending".equals(orderInfo.getStatus())) {
|
||||
String key = RedisConstant.getMasterIdKey(createOrderDTO.getShopId(), cn.ysk.cashier.utils.DateUtils.getDay(), orderInfo.getTableId());
|
||||
;
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
|
@ -1606,7 +1625,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (payDTO.getVipUserId() != null) {
|
||||
orderInfo.setUserId(String.valueOf(payDTO.getVipUserId()));
|
||||
}
|
||||
tbPayServiceImpl.vipPay(finalAmount, Integer.valueOf(orderInfo.getUserId()));
|
||||
TbShopUser shopUser = tbPayServiceImpl.vipPay(finalAmount, payDTO.getVipUserId());
|
||||
orderInfo.setMemberId(String.valueOf(shopUser.getId()));
|
||||
orderInfo.setUserId(shopUser.getUserId());
|
||||
orderInfo.setPayOrderNo("vipPay".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfo.setPayType("deposit");
|
||||
break;
|
||||
|
|
@ -1748,16 +1769,23 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
||||
}
|
||||
|
||||
TbShopUser shopUser = tbShopUserMapper.selectById(updateVipDTO.getVipUserId());
|
||||
if (shopUser == null) {
|
||||
throw new BadRequestException("用户信息不存在");
|
||||
}
|
||||
|
||||
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(queryWrapper.isNotNull(TbCashierCart::getOrderId));
|
||||
if (!tbCashierCarts.isEmpty()) {
|
||||
Integer orderId = tbCashierCarts.get(0).getOrderId();
|
||||
if (updateVipDTO.getType() == 0) {
|
||||
return orderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, orderId)
|
||||
.set(TbOrderInfo::getUserId, updateVipDTO.getVipUserId()));
|
||||
.set(TbOrderInfo::getUserId, shopUser.getUserId())
|
||||
.set(TbOrderInfo::getMemberId, updateVipDTO.getVipUserId()));
|
||||
} else {
|
||||
return orderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, orderId)
|
||||
.set(TbOrderInfo::getUserId, null)
|
||||
.set(TbOrderInfo::getUserId, null));
|
||||
}
|
||||
}
|
||||
|
|
@ -1997,11 +2025,14 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
cashierCarts.forEach(item -> {
|
||||
TbProduct product = productMap.get(item.getProductId());
|
||||
// 设置打包费
|
||||
item.setPackFee(product.getPackFee() != null ?
|
||||
product.getPackFee().multiply(BigDecimal.valueOf(item.getNumber())) : BigDecimal.ZERO);
|
||||
item.setTableId("");
|
||||
item.setUseType(OrderUseTypeEnum.TAKEOUT.getValue());
|
||||
item.setIsPack("true");
|
||||
mpCashierCartService.update(new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getId, item.getId())
|
||||
.set(TbCashierCart::getPackFee, product.getPackFee() != null ?
|
||||
product.getPackFee().multiply(BigDecimal.valueOf(item.getNumber())) : BigDecimal.ZERO)
|
||||
.set(TbCashierCart::getTableId, null)
|
||||
.set(TbCashierCart::getUseType, OrderUseTypeEnum.TAKEOUT.getValue())
|
||||
.set(TbCashierCart::getIsPack, "true"));
|
||||
|
||||
});
|
||||
|
||||
List<TbOrderDetail> detailList = orderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
|
|
@ -2018,19 +2049,18 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
if (!detailList.isEmpty()) {
|
||||
mpOrderDetailService.updateBatchById(detailList);
|
||||
}
|
||||
|
||||
return mpCashierCartService.updateBatchById(cashierCarts);
|
||||
return true;
|
||||
} else {
|
||||
cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.in(TbCashierCart::getId, choseModelDTO.getCartIds())
|
||||
.eq(TbCashierCart::getShopId, choseModelDTO.getShopId())
|
||||
.set(TbCashierCart::getTableId, choseModelDTO.getTableId())
|
||||
.set(TbCashierCart::getUseType, choseModelDTO.getUseType())
|
||||
.set(TbCashierCart::getUseType, StrUtil.isNotBlank(choseModelDTO.getTableId()) ? choseModelDTO.getUseType() : TableConstant.OrderInfo.UseType.NONE_TABLE.getValue())
|
||||
.set(TbCashierCart::getIsPack, "false")
|
||||
.set(TbCashierCart::getPackFee, BigDecimal.ZERO));
|
||||
return orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.in(TbOrderDetail::getCartId, choseModelDTO.getCartIds())
|
||||
.set(TbOrderDetail::getUseType, choseModelDTO.getUseType())
|
||||
.set(TbOrderDetail::getUseType, StrUtil.isNotBlank(choseModelDTO.getTableId()) ? choseModelDTO.getUseType() : TableConstant.OrderInfo.UseType.NONE_TABLE.getValue())
|
||||
.set(TbOrderDetail::getPackAmount, BigDecimal.ZERO));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,4 +117,5 @@ public class TbOrderInfoVo {
|
|||
private List<? extends TbOrderDetail> detailList;
|
||||
|
||||
private TbOrderDetail seatInfo;
|
||||
private String registerType;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue