fix:库存
This commit is contained in:
1 parent
5f3bd682b9
commit
e43533e6b5
5 files changed
+80
-54
No files matched your search
+56
-50
@@ -41,12 +41,12 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/supermarketSpu" )
|
||||
@Tag(description = "supermarketSpu" , name = "商品spu管理" )
|
||||
@RequestMapping("/supermarketSpu")
|
||||
@Tag(description = "supermarketSpu", name = "商品spu管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SupermarketSpuController {
|
||||
|
||||
private final SupermarketSpuService supermarketSpuService;
|
||||
private final SupermarketSpuService supermarketSpuService;
|
||||
|
||||
private final SupermarketUnitService supermarketUnitService;
|
||||
|
||||
@@ -54,31 +54,33 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param supermarketSpu 商品spu
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
public R getSupermarketSpuPage(@ParameterObject Page page, @ParameterObject SupermarketSpuEntity supermarketSpu) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductCode()),SupermarketSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getBarcode()),SupermarketSpuEntity::getBarcode,supermarketSpu.getBarcode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductName()),SupermarketSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductCode()), SupermarketSpuEntity::getProductCode, supermarketSpu.getProductCode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getBarcode()), SupermarketSpuEntity::getBarcode, supermarketSpu.getBarcode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductName()), SupermarketSpuEntity::getProductName, supermarketSpu.getProductName());
|
||||
return R.ok(supermarketSpuService.pageScope(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询商品spu
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
||||
@GetMapping("/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getById(@PathVariable("id" ) Long id) {
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
SupermarketSpuEntity supermarketSpuEntity = supermarketSpuService.getById(id);
|
||||
List<SupermarketUnitEntity> list = supermarketUnitService.list(new LambdaQueryWrapper<SupermarketUnitEntity>().eq(SupermarketUnitEntity::getSpuId, id));
|
||||
supermarketSpuEntity.setSupermarketUnitEntityList(list);
|
||||
@@ -91,13 +93,14 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 新增商品spu
|
||||
*
|
||||
* @param supermarketSpu 商品spu
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增商品spu" , description = "新增商品spu" )
|
||||
@SysLog("新增商品spu" )
|
||||
@Operation(summary = "新增商品spu", description = "新增商品spu")
|
||||
@SysLog("新增商品spu")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_add')" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_add')")
|
||||
public R save(@RequestBody SupermarketSpuEntity supermarketSpu) {
|
||||
supermarketSpu.setDeptId(SecurityUtils.getUser().getDeptId());
|
||||
return supermarketSpuService.saveSpu(supermarketSpu);
|
||||
@@ -105,26 +108,28 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 修改商品spu
|
||||
*
|
||||
* @param supermarketSpu 商品spu
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改商品spu" , description = "修改商品spu" )
|
||||
@SysLog("修改商品spu" )
|
||||
@Operation(summary = "修改商品spu", description = "修改商品spu")
|
||||
@SysLog("修改商品spu")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_edit')" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_edit')")
|
||||
public R updateById(@RequestBody SupermarketSpuEntity supermarketSpu) {
|
||||
return supermarketSpuService.updateSpuById(supermarketSpu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除商品spu
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除商品spu" , description = "通过id删除商品spu" )
|
||||
@SysLog("通过id删除商品spu" )
|
||||
@Operation(summary = "通过id删除商品spu", description = "通过id删除商品spu")
|
||||
@SysLog("通过id删除商品spu")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_del')" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(supermarketSpuService.removeSpuBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
@@ -132,30 +137,31 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param supermarketSpu 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_export')" )
|
||||
public List<SupermarketSpuEntity> export(SupermarketSpuEntity supermarketSpu,Long[] ids) {
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_export')")
|
||||
public List<SupermarketSpuEntity> export(SupermarketSpuEntity supermarketSpu, Long[] ids) {
|
||||
return supermarketSpuService.list(Wrappers.lambdaQuery(supermarketSpu).in(ArrayUtil.isNotEmpty(ids), SupermarketSpuEntity::getId, ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------APP-----------------
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询spu单表 列表信息
|
||||
*
|
||||
* @param supermarketSpuQueryDTO 商品spu
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "安卓机条件查询所有" , description = "安卓机条件查询所有" )
|
||||
@PostMapping("/ad/selectListAll" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
@Operation(summary = "安卓机条件查询所有", description = "安卓机条件查询所有")
|
||||
@PostMapping("/ad/selectListAll")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
public R getSupermarketSpuByScope(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO) {
|
||||
return R.ok(supermarketSpuService.selectListAllScope(supermarketSpuQueryDTO));
|
||||
}
|
||||
@@ -163,37 +169,36 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "条件查询所有" , description = "条件查询所有" )
|
||||
@GetMapping("/ad/SpuDetails" )
|
||||
public R getSupermarketSpuDetailById(@RequestParam("id")Long id) {
|
||||
@Operation(summary = "条件查询所有", description = "条件查询所有")
|
||||
@GetMapping("/ad/SpuDetails")
|
||||
public R getSupermarketSpuDetailById(@RequestParam("id") Long id) {
|
||||
return R.ok(supermarketSpuService.getSupermarketSpuDetailById(id));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/ad/updateSpuStock")
|
||||
@Operation(summary = "更新库存" , description = "app和安卓公用" )
|
||||
@Operation(summary = "更新库存", description = "app和安卓公用")
|
||||
@SysLog("更新商品库存")
|
||||
public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO){
|
||||
public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO) {
|
||||
return supermarketSpuService.updateSpuStock(updateStockReqDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询spu单表 列表信息
|
||||
*
|
||||
* @param supermarketSpuQueryDTO 商品spu
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "APP根据条件查询分页SPU" , description = "APP条件分页查询" )
|
||||
@PostMapping("/app/selectListAll" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getSupermarketSpu(@RequestBody SupermarketSpuAppQueryDTO supermarketSpuQueryDTO,@ParameterObject Page page) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
@Operation(summary = "APP根据条件查询分页SPU", description = "APP条件分页查询")
|
||||
@PostMapping("/app/selectListAll")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
public R getSupermarketSpu(@RequestBody SupermarketSpuAppQueryDTO supermarketSpuQueryDTO, @ParameterObject Page page) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(supermarketSpuQueryDTO.getMerchantId() != null, SupermarketSpuEntity::getMerchantId, supermarketSpuQueryDTO.getMerchantId());
|
||||
wrapper.eq(supermarketSpuQueryDTO.getCategoryId() != null, SupermarketSpuEntity::getCategoryId, supermarketSpuQueryDTO.getCategoryId());
|
||||
// wrapper.eq(StrUtil.isNotBlank(supermarketSpuQueryDTO.getProductCode()), SupermarketSpuEntity::getProductCode, supermarketSpuQueryDTO.getProductCode());
|
||||
@@ -208,24 +213,25 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "app获取spu详情" , description = "根据spu的id" )
|
||||
@GetMapping("/app/SpuDetails" )
|
||||
public R getSupermarketSpuAppDetailById(@RequestParam("id")Long id) {
|
||||
@Operation(summary = "app获取spu详情", description = "根据spu的id")
|
||||
@GetMapping("/app/SpuDetails")
|
||||
public R getSupermarketSpuAppDetailById(@RequestParam("id") Long id) {
|
||||
return R.ok(supermarketSpuService.getSupermarketSpuAppDetailById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/app/checkSpuStock")
|
||||
@SysLog("购物车效验库存")
|
||||
@Transactional
|
||||
public R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount) {
|
||||
SupermarketSpuEntity spu= supermarketSpuService.getById(spuId);
|
||||
public R checkSpuStock(@RequestParam(value = "spuId") Long spuId, @RequestParam("incrCount") Integer incrCount) {
|
||||
SupermarketSpuEntity spu = supermarketSpuService.getById(spuId);
|
||||
if (spu == null) {
|
||||
R.failed("商品不存在");
|
||||
return R.failed("商品不存在");
|
||||
}
|
||||
if (spu.getStock()<Math.abs(incrCount)){
|
||||
if (spu.getStock() < Math.abs(incrCount)) {
|
||||
return R.failed("库存不足");
|
||||
}
|
||||
return R.ok();
|
||||
|
||||
+2
-2
@@ -105,8 +105,8 @@ public class WalletRechargeApplyController {
|
||||
@SysLog("修改充值/扣款申请")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeApply_edit')")
|
||||
public R updateById(@RequestBody WalletRechargeApplyEntity walletRechargeApply) {
|
||||
return R.ok(walletRechargeApplyService.updateById(walletRechargeApply));
|
||||
public R updateById(@RequestBody WalletRechargeApplyDto dto) {
|
||||
return R.ok(walletRechargeApplyService.edit(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id删除充值/扣款申请", description = "通过id删除充值/扣款申请")
|
||||
|
||||
+2
@@ -16,6 +16,8 @@ public interface WalletRechargeApplyService extends IService<WalletRechargeApply
|
||||
|
||||
void create(WalletRechargeApplyEntity dto);
|
||||
|
||||
Boolean edit(WalletRechargeApplyDto dto);
|
||||
|
||||
Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto);
|
||||
|
||||
Page<WalletRechargeApplyVo> scopePageList(Page page, WalletRechargeApplyDto dto);
|
||||
|
||||
-1
@@ -53,7 +53,6 @@ public class WalletRechargeApplyComposeServiceImpl implements WalletRechargeAppl
|
||||
|
||||
if (ObjectUtil.isEmpty(topUpApplyDetail)) return result;
|
||||
if (ObjectUtil.isEmpty(topUpApplyDetail.getImportTime())) return result;
|
||||
rechargeApplyService.updateBeforePrice(topUpApplyDetail);
|
||||
|
||||
Page<WalletRechargeApplyCompareVo> resultVo = new Page<>();
|
||||
List<WalletRechargeApplyCompareVo> resultList = new ArrayList<>();
|
||||
|
||||
+20
-1
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -16,6 +17,7 @@ import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.common.core.exception.CheckedException;
|
||||
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.MsgUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -35,7 +37,6 @@ import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
@@ -44,6 +45,7 @@ import com.bsd.pjcloud.wallet.service.WalletManageService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletTypeService;
|
||||
import com.bsd.pjcloud.wallet.service.impl.WalletManageServiceImpl;
|
||||
import com.bsd.pjcloud.wallet.utils.flow.FlowUtil;
|
||||
import com.bsd.pjcloud.wallet.utils.flow.dto.WalletRechargeApplyFlowDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -91,6 +93,17 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
baseMapper.insert(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean edit(WalletRechargeApplyDto dto) {
|
||||
WalletRechargeApplyEntity detail = baseMapper.selectById(dto.getId());
|
||||
if (ObjectUtil.isEmpty(detail)) throw new RuntimeException("申请不存在");
|
||||
WalletRechargeApplyEntity updateObj = BeanUtils.toBean(dto, WalletRechargeApplyEntity.class);
|
||||
baseMapper.updateById(updateObj);
|
||||
getSelf().updateBeforePrice(detail);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<WalletRechargeApplyVo> pageJoin(Page page, WalletRechargeApplyDto dto) {
|
||||
Page<WalletRechargeApplyVo> list = baseMapper.pageJoin(page, dto);
|
||||
@@ -272,6 +285,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
.eq(WalletRechargeImportEntity::getApplyId, detail.getId())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(importList)) return;
|
||||
getSelf().updateBeforePrice(detail);
|
||||
if (ObjectUtil.equals(detail.getBizType(), WalletBizRechargeEnum.REDUCTION.getCode())) {
|
||||
importList.forEach(v -> v.setPrice(-1 * Math.abs(v.getPrice())));
|
||||
}
|
||||
@@ -290,6 +304,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateBeforePrice(WalletRechargeApplyEntity detail) {
|
||||
if (!ObjectUtil.equals(detail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
|
||||
return;
|
||||
@@ -321,4 +336,8 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
);
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
private WalletRechargeApplyServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user