活动管理 赠送商品
This commit is contained in:
@@ -1,13 +1,19 @@
|
|||||||
package cn.ysk.cashier.mybatis.entity;
|
package cn.ysk.cashier.mybatis.entity;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.utils.ListUtil;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@@ -23,6 +29,25 @@ public class Activate extends Model<Activate> {
|
|||||||
private String handselType;
|
private String handselType;
|
||||||
private String isDel;
|
private String isDel;
|
||||||
private String isUser;
|
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(","))+"]";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package cn.ysk.cashier.mybatis.mapper;
|
package cn.ysk.cashier.mybatis.mapper;
|
||||||
|
|
||||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbUserStorage;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
public interface ActivateMapper extends BaseMapper<Activate> {
|
public interface ActivateMapper extends BaseMapper<Activate> {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.ysk.cashier.mybatis.mapper;
|
package cn.ysk.cashier.mybatis.mapper;
|
||||||
|
|
||||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
|
||||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||||
import cn.ysk.cashier.vo.CarVO;
|
import cn.ysk.cashier.vo.CarVO;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package cn.ysk.cashier.mybatis.rest;
|
|||||||
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
|
||||||
import cn.ysk.cashier.domain.QiniuContent;
|
import cn.ysk.cashier.domain.QiniuContent;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||||
@@ -14,6 +13,7 @@ import cn.ysk.cashier.utils.SecurityUtils;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -23,9 +23,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@@ -50,11 +48,19 @@ public class StorageController {
|
|||||||
}
|
}
|
||||||
@PostMapping("/modityActivate")
|
@PostMapping("/modityActivate")
|
||||||
public ResponseEntity<Object> modityActivate(@RequestBody Activate activate){
|
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();
|
String userName = SecurityUtils.getCurrentUsername();
|
||||||
shopService.modityActivate(activate);
|
shopService.modityActivate(activate);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
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
|
* @param params
|
||||||
* shopId 必填
|
* shopId 必填
|
||||||
|
|||||||
@@ -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;
|
package cn.ysk.cashier.mybatis.service;
|
||||||
|
|
||||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||||
import cn.ysk.cashier.mybatis.entity.StorageVo;
|
import cn.ysk.cashier.mybatis.entity.StorageVo;
|
||||||
|
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
* @description 服务接口
|
* @description 服务接口
|
||||||
@@ -36,4 +24,6 @@ public interface ShopService {
|
|||||||
Object findActivate(String shopId);
|
Object findActivate(String shopId);
|
||||||
|
|
||||||
void modityActivate(Activate activate);
|
void modityActivate(Activate activate);
|
||||||
|
|
||||||
|
List<TbProduct> findActivatePros(Integer activate);
|
||||||
}
|
}
|
||||||
@@ -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;
|
package cn.ysk.cashier.mybatis.service.impl;
|
||||||
|
|
||||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||||
import cn.ysk.cashier.mybatis.mapper.*;
|
import cn.ysk.cashier.mybatis.mapper.*;
|
||||||
|
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -50,6 +38,8 @@ public class ShopServiceImpl implements ShopService {
|
|||||||
private TbProducSkutMapper producSkutMapper;
|
private TbProducSkutMapper producSkutMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActivateMapper activateMapper;
|
private ActivateMapper activateMapper;
|
||||||
|
@Autowired
|
||||||
|
private TbProductRepository tbProductRepository;
|
||||||
@Override
|
@Override
|
||||||
public Object findStorage(Integer shopId, String account, Pageable pageable) {
|
public Object findStorage(Integer shopId, String account, Pageable pageable) {
|
||||||
QueryWrapper<TbUserStorage> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TbUserStorage> queryWrapper = new QueryWrapper<>();
|
||||||
@@ -139,4 +129,13 @@ public class ShopServiceImpl implements ShopService {
|
|||||||
activateMapper.insert(activate);
|
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<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user