feat(商品管理): 新增商品与柜机格口关联查询功能
在商品管理模块中,新增了查询商品及其关联的柜机格口信息的功能。该功能通过新增的 `SearchGoodsWithCabinetDO` 数据对象、`getGoodsWithCabinetList` 方法以及相应的 SQL 查询实现,支持在客户端按柜机格口显示商品列表。同时,调整了 `ShopController` 中的商品列表获取逻辑,以适配新的查询方式。
This commit is contained in:
parent
2ec5255615
commit
774dc07d1a
|
@ -4,10 +4,16 @@ import com.agileboot.api.response.ShopGoodsResponse;
|
|||
import com.agileboot.common.constant.WeixinConstants;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.domain.shop.category.CategoryApplicationService;
|
||||
import com.agileboot.domain.shop.category.db.ShopCategoryEntity;
|
||||
import com.agileboot.domain.shop.category.dto.ShopCategoryDTO;
|
||||
import com.agileboot.domain.shop.goods.GoodsApplicationService;
|
||||
import com.agileboot.domain.shop.goods.db.SearchGoodsWithCabinetDO;
|
||||
import com.agileboot.domain.shop.goods.db.ShopGoodsEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -28,7 +34,7 @@ public class ShopController {
|
|||
|
||||
@GetMapping("/goods")
|
||||
public ResponseDTO<ShopGoodsResponse> getShopGoodsInfo() {
|
||||
// 获取商品列表
|
||||
/*// 获取商品列表
|
||||
List<ShopGoodsEntity> goodsList = goodsApplicationService.getGoodsAll();
|
||||
goodsList.forEach(goods -> {
|
||||
// 最多只能购买一件
|
||||
|
@ -37,10 +43,22 @@ public class ShopController {
|
|||
}
|
||||
});
|
||||
// 获取分类列表
|
||||
List<ShopCategoryDTO> categoryList = categoryApplicationService.getCategoryAll();
|
||||
List<ShopCategoryDTO> categoryList = categoryApplicationService.getCategoryAll();*/
|
||||
|
||||
// 客户端显示商品列表按柜机格口
|
||||
List<SearchGoodsWithCabinetDO> goodsWithCabinetList = goodsApplicationService.getGoodsWithCabinetList();
|
||||
goodsWithCabinetList.forEach(goodsWithCabinet -> {
|
||||
goodsWithCabinet.setCategoryId(goodsWithCabinet.getCabinetId());
|
||||
});
|
||||
|
||||
return ResponseDTO.ok(new ShopGoodsResponse(goodsList, categoryList, "0"));
|
||||
List<ShopCategoryDTO> categoryList = goodsWithCabinetList.stream().map(g -> {
|
||||
ShopCategoryDTO categoryDTO = new ShopCategoryDTO(new ShopCategoryEntity());
|
||||
categoryDTO.setCategoryId(g.getCategoryId());
|
||||
categoryDTO.setCategoryName(g.getCabinetName());
|
||||
return categoryDTO;
|
||||
}).distinct().collect(Collectors.toList());
|
||||
|
||||
return ResponseDTO.ok(new ShopGoodsResponse(goodsWithCabinetList, categoryList, "0"));
|
||||
}
|
||||
|
||||
@GetMapping("/wechatAuth")
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.agileboot.api.response;
|
|||
|
||||
|
||||
import com.agileboot.domain.shop.category.dto.ShopCategoryDTO;
|
||||
import com.agileboot.domain.shop.goods.db.SearchGoodsWithCabinetDO;
|
||||
import com.agileboot.domain.shop.goods.db.ShopGoodsEntity;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
@ -10,7 +11,7 @@ import lombok.Data;
|
|||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ShopGoodsResponse {
|
||||
private List<ShopGoodsEntity> goodsList;
|
||||
private List<SearchGoodsWithCabinetDO> goodsList;
|
||||
private List<ShopCategoryDTO> categoryList;
|
||||
private String res;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public class SearchCabinetCellQuery<T> extends AbstractPageQuery<T> {
|
|||
.eq(cellType != null, "cell_type", cellType)
|
||||
.eq(usageStatus != null, "usage_status", usageStatus)
|
||||
.eq(availableStatus != null, "available_status", availableStatus)
|
||||
.eq("deleted", false)
|
||||
.between(startTime != null && endTime != null, "create_time", startTime, endTime);
|
||||
|
||||
this.timeRangeColumn = "create_time";
|
||||
|
|
|
@ -25,6 +25,7 @@ public class SearchSmartCabinetQuery<T> extends AbstractPageQuery<T> {
|
|||
.like(StrUtil.isNotEmpty(cabinetName), "cabinet_name", cabinetName)
|
||||
.eq(cabinetType != null, "cabinet_type", cabinetType)
|
||||
.eq(StrUtil.isNotEmpty(templateNo), "template_no", templateNo)
|
||||
.eq("deleted", false)
|
||||
.between(startTime != null && endTime != null, "create_time", startTime, endTime);
|
||||
|
||||
this.timeRangeColumn = "create_time";
|
||||
|
|
|
@ -13,10 +13,14 @@ import org.eclipse.paho.client.mqttv3.*;
|
|||
@RequiredArgsConstructor
|
||||
public class MqttService implements MqttCallback {
|
||||
private static final String SERVER_URL = "tcp://221.7.159.46:1883";
|
||||
private static final String USERNAME = "lock";
|
||||
private static final String PASSWORD = "lock@ys#6785$";
|
||||
private static final String TOPIC_FILTER = "lock/up/S4202414S";
|
||||
private static final String TOPIC = "lock/down/S4202414S";
|
||||
// private static final String USERNAME = "lock";
|
||||
// private static final String PASSWORD = "lock@ys#6785$";
|
||||
// private static final String TOPIC_FILTER = "lock/up/S4202414S";
|
||||
// private static final String TOPIC = "lock/down/S4202414S";
|
||||
private static final String USERNAME = "sell";
|
||||
private static final String PASSWORD = "sell@ys#6785$";
|
||||
private static final String TOPIC_FILTER = "lock/up/S5200184S";
|
||||
private static final String TOPIC = "lock/down/S5200184S";
|
||||
|
||||
private MqttClient client;
|
||||
// 设置自定义消息处理器
|
||||
|
|
|
@ -6,9 +6,11 @@ import com.agileboot.common.annotation.ExcelSheet;
|
|||
import com.agileboot.domain.shop.category.db.ShopCategoryEntity;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ExcelSheet(name = "商品分类列表")
|
||||
@Data
|
||||
@EqualsAndHashCode(of = {"categoryId", "categoryName"})
|
||||
public class ShopCategoryDTO {
|
||||
|
||||
public ShopCategoryDTO(ShopCategoryEntity entity) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.agileboot.domain.common.command.BulkOperationCommand;
|
|||
import com.agileboot.domain.shop.goods.command.AddGoodsCommand;
|
||||
import com.agileboot.domain.shop.goods.command.UpdateGoodsCommand;
|
||||
import com.agileboot.domain.shop.goods.db.SearchGoodsDO;
|
||||
import com.agileboot.domain.shop.goods.db.SearchGoodsWithCabinetDO;
|
||||
import com.agileboot.domain.shop.goods.db.ShopGoodsEntity;
|
||||
import com.agileboot.domain.shop.goods.db.ShopGoodsService;
|
||||
import com.agileboot.domain.shop.goods.dto.ShopGoodsDTO;
|
||||
|
@ -59,4 +60,9 @@ public class GoodsApplicationService {
|
|||
public List<ShopGoodsEntity> getGoodsAll(){
|
||||
return shopGoodsService.selectAll();
|
||||
}
|
||||
|
||||
|
||||
public List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList() {
|
||||
return shopGoodsService.getGoodsWithCabinetList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.agileboot.domain.shop.goods.db;
|
||||
|
||||
import com.agileboot.common.core.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("shop_goods")
|
||||
public class SearchGoodsWithCabinetDO extends BaseEntity<SearchGoodsWithCabinetDO> {
|
||||
|
||||
private Long goodsId;
|
||||
private String goodsName;
|
||||
private Long categoryId;
|
||||
private BigDecimal price;
|
||||
private Integer stock;
|
||||
private Integer status;
|
||||
private String coverImg;
|
||||
private String goodsDetail;
|
||||
private String remark;
|
||||
|
||||
@TableField("sc.cabinet_id")
|
||||
private Long cabinetId;
|
||||
|
||||
@TableField("sc.cabinet_name")
|
||||
private String cabinetName;
|
||||
|
||||
@TableField("cc.cell_id")
|
||||
private Long cellId;
|
||||
}
|
|
@ -45,4 +45,15 @@ public interface ShopGoodsMapper extends BaseMapper<ShopGoodsEntity> {
|
|||
"WHERE deleted = 0 " +
|
||||
"ORDER BY create_time DESC")
|
||||
List<ShopGoodsEntity> selectAll();
|
||||
|
||||
/**
|
||||
* 查询商品及其关联的柜机格口信息
|
||||
* @return 商品列表
|
||||
*/
|
||||
@Select("SELECT g.*, sc.cabinet_id, sc.cabinet_name, cc.cell_id " +
|
||||
"FROM shop_goods g " +
|
||||
"LEFT JOIN cabinet_cell cc ON g.goods_id = cc.goods_id " +
|
||||
"LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id " +
|
||||
"WHERE g.deleted = 0 AND sc.deleted = 0 AND cc.deleted = 0 AND cc.goods_id IS NOT NULL ")
|
||||
List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList();
|
||||
}
|
||||
|
|
|
@ -17,4 +17,6 @@ public interface ShopGoodsService extends IService<ShopGoodsEntity> {
|
|||
Page<SearchGoodsDO> getGoodsList(AbstractPageQuery<SearchGoodsDO> query);
|
||||
|
||||
List<ShopGoodsEntity> selectAll();
|
||||
|
||||
List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList();
|
||||
}
|
||||
|
|
|
@ -29,4 +29,9 @@ public class ShopGoodsServiceImpl extends ServiceImpl<ShopGoodsMapper, ShopGoods
|
|||
public List<ShopGoodsEntity> selectAll() {
|
||||
return baseMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchGoodsWithCabinetDO> getGoodsWithCabinetList() {
|
||||
return baseMapper.getGoodsWithCabinetList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,3 +66,6 @@ ADD COLUMN `is_internal` TINYINT(1) DEFAULT 0 COMMENT '是否内部用户(0否
|
|||
|
||||
ALTER TABLE `shop_order`
|
||||
ADD COLUMN `userid` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '企业微信用户ID或汇邦云用户ID' AFTER `mobile`;
|
||||
|
||||
ALTER TABLE `cabinet_cell`
|
||||
ADD COLUMN `stock` INT NOT NULL DEFAULT 0 COMMENT '库存数量' AFTER `pin_no`;
|
||||
|
|
Loading…
Reference in New Issue