超市优化
This commit is contained in:
@ -41,4 +41,5 @@ public class StoreSaleGoodsPageVO extends PageParam {
|
||||
|
||||
private Integer number;
|
||||
|
||||
private String img;
|
||||
}
|
@ -21,11 +21,13 @@ import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.enums.StoreOrderStatusEnum;
|
||||
import cn.iocoder.yudao.module.member.service.async.MemberAsyncService;
|
||||
import cn.iocoder.yudao.module.member.service.storegoods.StoreGoodsService;
|
||||
import cn.iocoder.yudao.module.member.service.storegoodsinventory.StoreGoodsInventoryService;
|
||||
import cn.iocoder.yudao.module.member.service.storegoodstype.StoreGoodsTypeService;
|
||||
import cn.iocoder.yudao.module.member.service.storeorder.StoreOrderService;
|
||||
import cn.iocoder.yudao.module.member.service.storeorderdetail.StoreOrderDetailService;
|
||||
import cn.iocoder.yudao.module.member.service.storesalegoods.StoreSaleGoodsService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.system.api.cashregisterinfo.CashregisterinfoApi;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -40,6 +42,7 @@ import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Tag(name = "用户 APP - 超市")
|
||||
@RestController
|
||||
@ -62,6 +65,10 @@ public class AppStoreController {
|
||||
private StoreOrderDetailService orderDetailService;
|
||||
@Resource
|
||||
private MemberAsyncService memberAsyncService;
|
||||
@Resource
|
||||
private CashregisterinfoApi cashregisterinfoApi;
|
||||
@Resource
|
||||
private StoreGoodsInventoryService storeGoodsInventoryService;
|
||||
|
||||
@GetMapping("/mgcr/memberUser/getMenberTwoList")
|
||||
@Operation(summary = "获取用户关联信息")
|
||||
@ -113,14 +120,21 @@ public class AppStoreController {
|
||||
goodsResult.setSuccess(true);
|
||||
goodsResult.setMessage("操作成功");
|
||||
|
||||
|
||||
List<Integer> goodsIds = saleGoodsService.getGoodsIds(equipmentCode);
|
||||
Long storeId = cashregisterinfoApi.getStoreId(equipmentCode);
|
||||
List<Integer> goodsIds = saleGoodsService.getGoodsIds(storeId);
|
||||
if(CollectionUtil.isEmpty(goodsIds)){
|
||||
return JsonUtils.toJsonString(goodsResult);
|
||||
}
|
||||
List<StoreGoodsDO> goodsDOS = storeGoodsService.getAll(goodsIds);
|
||||
List<StoreGoodsTypeDO> goodsTypeDOS = goodsTypeService.getAll();
|
||||
List<StoreGoodsListVo> goodData = BeanUtils.toBean(goodsDOS, StoreGoodsListVo.class);
|
||||
|
||||
//库存处理
|
||||
Map<Integer, Integer> inventoryList = storeGoodsInventoryService.getInventoryList(goodsIds, storeId);
|
||||
for (StoreGoodsListVo listVo:goodData){
|
||||
listVo.setNumber(inventoryList.get(listVo.getGoodsId()));
|
||||
}
|
||||
|
||||
List<StoreGoodsTypeListVo> categoryData = BeanUtils.toBean(goodsTypeDOS, StoreGoodsTypeListVo.class);
|
||||
goodsResult.setCategoryData(categoryData);
|
||||
goodsResult.setGoodsData(goodData);
|
||||
|
@ -19,4 +19,9 @@ public class StoreGoodsListVo {
|
||||
*/
|
||||
private Double price;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private Integer number;
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.member.controller.admin.storegoodsinventory.vo.St
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storegoodsinventory.StoreGoodsInventoryDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品库存 Service 接口
|
||||
@ -64,4 +66,6 @@ public interface StoreGoodsInventoryService {
|
||||
|
||||
|
||||
Integer getInventory(Integer goodsId,Long carteenId);
|
||||
|
||||
Map<Integer,Integer> getInventoryList(List<Integer> goodsIds, Long carteenId);
|
||||
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.service.storegoodsinventory;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storegoodsinventory.vo.AddReqVO;
|
||||
@ -21,11 +22,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.STORE_GOODS_INVENTORY_NOT_ENOUGH;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.STORE_GOODS_INVENTORY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@ -70,10 +72,12 @@ public class StoreGoodsInventoryServiceImpl implements StoreGoodsInventoryServic
|
||||
}
|
||||
StoreGoodsInventoryDO storeGoodsInventoryDO = storeGoodsInventoryDOS.get(0);
|
||||
if (storeGoodsInventoryDO.getNumber() < vo.getNumber()) {
|
||||
throw exception(STORE_GOODS_INVENTORY_NOT_ENOUGH);
|
||||
StoreGoodsDO storeGoodsDO = storeGoodsMapper.selectById(storeGoodsInventoryDO.getGoodsId());
|
||||
throw exception(new ErrorCode(1_004_019_001, storeGoodsDO.getGoodsName()+"商品库存不足"));
|
||||
}
|
||||
if (storeGoodsInventoryDO.getWeight() < vo.getWeight()) {
|
||||
throw exception(STORE_GOODS_INVENTORY_NOT_ENOUGH);
|
||||
StoreGoodsDO storeGoodsDO = storeGoodsMapper.selectById(storeGoodsInventoryDO.getGoodsId());
|
||||
throw exception(new ErrorCode(1_004_019_001, storeGoodsDO.getGoodsName()+"商品库存不足"));
|
||||
}
|
||||
storeGoodsInventoryDO.setNumber(storeGoodsInventoryDO.getNumber() - vo.getNumber());
|
||||
storeGoodsInventoryDO.setWeight(storeGoodsInventoryDO.getWeight() - vo.getWeight());
|
||||
@ -159,4 +163,16 @@ public class StoreGoodsInventoryServiceImpl implements StoreGoodsInventoryServic
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Integer> getInventoryList(List<Integer> goodsIds, Long carteenId) {
|
||||
List<StoreGoodsInventoryDO> list = storeGoodsInventoryMapper.selectList(Wrappers.<StoreGoodsInventoryDO>lambdaQuery()
|
||||
.in(StoreGoodsInventoryDO::getGoodsId, goodsIds)
|
||||
.eq(StoreGoodsInventoryDO::getCarteenId, carteenId));
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
return list.stream().collect(Collectors.toMap(StoreGoodsInventoryDO::getGoodsId,StoreGoodsInventoryDO::getNumber));
|
||||
}
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
@ -57,5 +57,5 @@ public interface StoreSaleGoodsService {
|
||||
|
||||
Boolean bindGoods(StoreSaleGoodsDto dto);
|
||||
|
||||
List<Integer> getGoodsIds(String equipmentCode);
|
||||
List<Integer> getGoodsIds( Long storeId);
|
||||
}
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreGoodsDto;
|
||||
import cn.iocoder.yudao.module.member.controller.app.store.dto.StoreSaleGoodsDto;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storesalegoods.StoreSaleGoodsDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.storesalegoods.StoreSaleGoodsMapper;
|
||||
import cn.iocoder.yudao.module.member.service.storegoodsinventory.StoreGoodsInventoryService;
|
||||
import cn.iocoder.yudao.module.system.api.cashregisterinfo.CashregisterinfoApi;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@ -42,8 +41,7 @@ public class StoreSaleGoodsServiceImpl implements StoreSaleGoodsService {
|
||||
private StoreSaleGoodsMapper storeSaleGoodsMapper;
|
||||
@Resource
|
||||
private CashregisterinfoApi cashregisterinfoApi;
|
||||
@Resource
|
||||
private StoreGoodsInventoryService storeGoodsInventoryService;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -127,9 +125,7 @@ public class StoreSaleGoodsServiceImpl implements StoreSaleGoodsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getGoodsIds(String equipmentCode) {
|
||||
|
||||
Long storeId = cashregisterinfoApi.getStoreId(equipmentCode);
|
||||
public List<Integer> getGoodsIds(Long storeId) {
|
||||
|
||||
List<StoreSaleGoodsDO> storeSaleGoodsDOS = storeSaleGoodsMapper.selectList(new LambdaQueryWrapper<StoreSaleGoodsDO>().eq(StoreSaleGoodsDO::getCarteenId, storeId));
|
||||
if (CollectionUtil.isEmpty(storeSaleGoodsDOS)) {
|
||||
|
@ -18,8 +18,8 @@ import java.util.concurrent.TimeUnit;
|
||||
public class QRCodeWithJWTUtil {
|
||||
private static final String SECRET_KEY = "your_secret_key"; // 使用HS256算法生成秘钥
|
||||
public static final String BASE_PATH = "qrCodes/";
|
||||
public static final String QR_PREFIX_ZF = "ZF_";
|
||||
public static final String QR_PREFIX_HX = "HX_";
|
||||
public static final String QR_PREFIX_ZF = "";
|
||||
public static final String QR_PREFIX_HX = "HX";
|
||||
// public static void main(String[] args) throws WriterException, IOException {
|
||||
// // 用户ID
|
||||
// Long userId = 123L;
|
||||
|
@ -50,6 +50,6 @@ public class SmsUtil {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
sendMsg("15723110242","这是一条测试短信2");
|
||||
sendMsg("15723110242,15213164384","这是一条测试短信2");
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
-->
|
||||
|
||||
<select id="getSaleGoodsPage" resultType="cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.StoreSaleGoodsPageVO">
|
||||
select sg.id,sg.carteen_id,sg.create_time,ms.category_id,ms.goods_name,ms.img,ms.sales_model,ms.price,sg.goods_id,gi.number
|
||||
select sg.id,sg.carteen_id,sg.create_time,ms.category_id,ms.goods_name,ms.img,ms.sales_model,ms.price,sg.goods_id,gi.number,ms.img
|
||||
from member_store_sale_goods sg left join member_store_goods ms on sg.goods_id = ms.goods_id
|
||||
left join member_store_goods_inventory gi on gi.carteen_id = sg.carteen_id and gi.goods_id = sg.goods_id
|
||||
where sg.deleted = false
|
||||
|
Reference in New Issue
Block a user