Merge branch 'refs/heads/test' into dev

# Conflicts:
#	eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java
This commit is contained in:
GYJ 2024-08-18 20:14:25 +08:00
commit e6b8414366
18 changed files with 146 additions and 69 deletions

View File

@ -75,6 +75,11 @@ public class ViewConInfoFlow implements Serializable {
private BigDecimal balance;
@Column(name = "`status`")
@ApiModelProperty(value = "status")
private String status;
@Column(name = "`product_id`")
@ApiModelProperty(value = "商品id")

View File

@ -50,7 +50,7 @@ public class ViewConInfoFlowDto implements Serializable {
private String productId;
private String productName;
private String status;
private String conCode;

View File

@ -96,9 +96,10 @@ public class TbPlaceController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer size,
@RequestParam Integer shopId,
@RequestParam(required = false) Integer vipUserId
@RequestParam(required = false) Integer vipUserId,
@RequestParam String masterId
) {
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId));
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId, masterId));
}
@AnonymousAccess

View File

@ -54,15 +54,4 @@ public class TbProductGroupDto implements Serializable {
private String saleStartTime;
private String saleEndTime;
public void upSaleEndTime() {
if (useTime != null && useTime == 1) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
LocalTime startTime = LocalTime.parse(saleStartTime, formatter);
LocalTime endTime = LocalTime.parse(saleEndTime, formatter);
if (endTime.isBefore(startTime)) {
saleEndTime = "次日 " + saleEndTime;
}
}
}
}

View File

@ -8,13 +8,12 @@ import javax.validation.constraints.NotNull;
@Data
public class PendingDTO {
@NotEmpty
private String masterId;
@NotNull
private Integer shopId;
@NotNull
private Long tableId;
private Integer vipUserId;
@NotNull
private Boolean isPending;
private Integer orderId;
}

View File

@ -1,13 +1,19 @@
package cn.ysk.cashier.mybatis.entity;
import cn.ysk.cashier.utils.ListUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
@Data
@EqualsAndHashCode(callSuper = true)
@ -23,6 +29,25 @@ public class Activate extends Model<Activate> {
private String handselType;
private String isDel;
private String isUser;
//是否赠送商品 0否 1是
private Integer isGiftPro;
private String productIds;
@TableField(exist = false)
private List<Integer> prodIds;
public void setProductIds(String productIds) {
this.productIds = productIds;
if(StringUtils.isNotBlank(productIds)){
prodIds=ListUtil.stringChangeIntegerList(productIds);
}
}
public void setProdIds(List<Integer> prodIds) {
this.prodIds = prodIds;
if(!CollectionUtils.isEmpty(prodIds)){
productIds="["+prodIds.stream()
.map(String::valueOf)
.collect(Collectors.joining(","))+"]";
}
}
}

View File

@ -1,7 +1,6 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.mybatis.entity.TbUserStorage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface ActivateMapper extends BaseMapper<Activate> {

View File

@ -27,9 +27,10 @@ public interface ShopUserMapper extends BaseMapper<TbShopUser> {
" or u.telephone like concat('%', #{param.name}, '%') or su.telephone like concat('%', #{param.name}, '%'))" +
"</if>" +
"<if test='isVip != null'>" +
"AND su.is_vip=#{isVip}" +
"AND su.is_vip=#{isVip} " +
"</if>" +
"</where>" +
"order by su.created_at" +
"</script>")
IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Integer isVip, Page pageInfo);

View File

@ -1,8 +1,9 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.vo.CarVO;
import cn.ysk.cashier.vo.PendingCountVO;
import cn.ysk.cashier.vo.TbCashierCartVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@ -18,4 +19,11 @@ public interface TbCashierCartMapper extends BaseMapper<TbCashierCart> {
" ifnull(sum(total_amount),0) as totalAmount\n" +
" from tb_cashier_cart where table_id is not null and shop_id = #{shopId} and status = 'refund' group by shop_Id, master_id order by trade_day desc")
List<CarVO> selectCar(@Param("shopId") Integer shopId);
@Select(" SELECT order_id orderId, pending_at, sum(total_amount) totalAmount, count(id) totalCount, count(total_number) totalNumber from tb_cashier_cart where status = 'refund' and shop_id=#{shopId} " +
" GROUP BY order_id ORDER BY trade_day")
List<PendingCountVO> countPending(@Param("shopId") Integer shopId);
@Select("select a.*, b.spec_snap from tb_cashier_cart as a left join tb_product_sku as b on a.sku_id=b.id where a.shop_id=#{shopId} and a.status='refund';")
List<TbCashierCartVO> selectPending(Integer shopId);
}

View File

@ -2,7 +2,6 @@ package cn.ysk.cashier.mybatis.rest;
import cn.hutool.core.io.IoUtil;
import cn.hutool.http.HttpUtil;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.domain.QiniuContent;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.Activate;
@ -14,6 +13,7 @@ import cn.ysk.cashier.utils.SecurityUtils;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,9 +23,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j
@RestController
@ -50,11 +48,19 @@ public class StorageController {
}
@PostMapping("/modityActivate")
public ResponseEntity<Object> modityActivate(@RequestBody Activate activate){
if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1 && CollectionUtils.isEmpty(activate.getProdIds()))
throw new BadRequestException("赠送商品不可为空");
String userName = SecurityUtils.getCurrentUsername();
shopService.modityActivate(activate);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/activate/{activateId}")
@ApiOperation("查询活动赠送商品")
public ResponseEntity<Object> queryActivatePros(@PathVariable("activateId") Integer activateId){
return new ResponseEntity<>(shopService.findActivatePros(activateId),HttpStatus.OK);
}
/**
* @param params
* shopId 必填

View File

@ -1,24 +1,12 @@
/*
* 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.mybatis.service;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.mybatis.entity.StorageVo;
import cn.ysk.cashier.pojo.product.TbProduct;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* @website https://eladmin.vip
* @description 服务接口
@ -36,4 +24,6 @@ public interface ShopService {
Object findActivate(String shopId);
void modityActivate(Activate activate);
List<TbProduct> findActivatePros(Integer activate);
}

View File

@ -1,23 +1,10 @@
/*
* 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.mybatis.service.impl;
import cn.ysk.cashier.mybatis.entity.Activate;
import cn.ysk.cashier.mybatis.mapper.*;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
import cn.ysk.cashier.repository.product.TbProductRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -30,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
@ -50,6 +38,8 @@ public class ShopServiceImpl implements ShopService {
private TbProducSkutMapper producSkutMapper;
@Autowired
private ActivateMapper activateMapper;
@Autowired
private TbProductRepository tbProductRepository;
@Override
public Object findStorage(Integer shopId, String account, Pageable pageable) {
QueryWrapper<TbUserStorage> queryWrapper = new QueryWrapper<>();
@ -139,4 +129,13 @@ public class ShopServiceImpl implements ShopService {
activateMapper.insert(activate);
}
}
@Override
public List<TbProduct> findActivatePros(Integer activateId) {
Activate activate = activateMapper.selectById(activateId);
if (!CollectionUtils.isEmpty(activate.getProdIds())){
return tbProductRepository.findByIds(activate.getProdIds());
}
return new ArrayList<>();
}
}

View File

@ -365,7 +365,8 @@ public class StockServiceImpl implements StockService {
break;
case "pauseSale":
sqlQuery.append(" set is_pause_sale = ").append(updateValueVO.getUpdateValue());
TbProduct product1 = tbProductRepository.selectById(Integer.valueOf(updateValueVO.getTargetId()));
TbProduct product1 = tbProductRepository.getById(Integer.valueOf(updateValueVO.getTargetId()));
// 推送微信操作消息
if (product1 != null) {
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName(), Integer.valueOf(updateValueVO.getShopId()));

View File

@ -58,11 +58,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
PageRequest sort = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
Page<TbProductGroup> page = tbProductGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
QueryHelp.getPredicate(root,criteria,criteriaBuilder),sort);
Page<TbProductGroupDto> map = page.map(tbProductGroupMapper::toDto);
map.getContent().forEach(s->{
s.upSaleEndTime();
});
return PageUtil.toPage(map);
return PageUtil.toPage(page.map(tbProductGroupMapper::toDto));
}
@Override

View File

@ -41,6 +41,7 @@ import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.PendingCountVO;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -395,7 +396,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
@Override
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId) {
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page,
Integer size, Integer shopId, Integer vipUserId, String masterId) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getStatus, "create")
@ -404,6 +406,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (vipUserId != null) {
queryWrapper.eq(TbCashierCart::getUserId, vipUserId);
}else {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getUserId);
}
@ -643,7 +646,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
} else {
orderCode = String.valueOf(Integer.parseInt(code.replace("#", "")) + 1);
}
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "#" + Integer.parseInt(code.replace("#", "")) + 2);
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, String.valueOf(Integer.parseInt(orderCode) + 1));
boolean flag = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode));
if (flag) {
return generateOrderCode(day, clientType, shopId);
@ -819,14 +822,23 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public Object pending(PendingDTO pendingDTO) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, pendingDTO.getShopId())
.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
.eq(TbCashierCart::getStatus, "create");
if (pendingDTO.getVipUserId() != null) {
queryWrapper.eq(TbCashierCart::getUserId, pendingDTO.getVipUserId());
.eq(TbCashierCart::getShopId, pendingDTO.getShopId());
if (!pendingDTO.getIsPending()) {
if (pendingDTO.getOrderId() == null) {
throw new BadRequestException("取消挂起订单id不为空");
}
queryWrapper.eq(TbCashierCart::getOrderId, pendingDTO.getOrderId());
}else {
queryWrapper.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId())
.isNull(TbCashierCart::getUserId);
queryWrapper.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
.eq(TbCashierCart::getStatus, "create");
if (pendingDTO.getVipUserId() != null) {
queryWrapper.eq(TbCashierCart::getUserId, pendingDTO.getVipUserId());
}else {
queryWrapper.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId())
.isNull(TbCashierCart::getUserId);
}
}
List<TbCashierCart> cashierCarts = cashierCartMapper
.selectList(queryWrapper);
@ -872,7 +884,27 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public Object getCar(Integer shopId) {
return cashierCartMapper.selectCar(shopId);
ArrayList<Map<String, Object>> data = new ArrayList<>();
List<PendingCountVO> pendingCountVOS = cashierCartMapper.countPending(shopId);
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getStatus, "refund"));
cashierCartMapper.selectPending(shopId);
HashMap<String, List<TbCashierCart>> cashierMap = new HashMap<>();
for (TbCashierCart tbCashierCart : tbCashierCarts) {
List<TbCashierCart> list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>());
list.add(tbCashierCart);
}
pendingCountVOS.forEach(item -> {
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
map.put("carList", cashierMap.get(item.getOrderId().toString()));
data.add(map);
});
return data;
}
@Override

View File

@ -102,7 +102,7 @@ public interface TbShopTableService {
void clearCart(ClearCartDTO clearCartDTO);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId, String masterId);
TbCashierCart updateCart(UpdateCartDTO updateCartDTO);

View File

@ -0,0 +1,15 @@
package cn.ysk.cashier.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.sql.Timestamp;
@Data
public class PendingCountVO {
private Long pendingAt;
private BigDecimal totalAmount;
private Integer totalCount;
private Integer totalNumber;
private Integer orderId;
}

View File

@ -0,0 +1,11 @@
package cn.ysk.cashier.vo;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class TbCashierCartVO extends TbCashierCart {
private String specSnap;
}