消费者下单,商品发布,商品详情接口
This commit is contained in:
parent
43496cdd94
commit
7b289e435c
|
|
@ -5,12 +5,11 @@ import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
import com.ghy.common.core.page.TableDataInfo;
|
import com.ghy.common.core.page.TableDataInfo;
|
||||||
import com.ghy.common.enums.BusinessType;
|
import com.ghy.common.enums.BusinessType;
|
||||||
|
import com.ghy.common.utils.ExceptionUtil;
|
||||||
import com.ghy.common.utils.ShiroUtils;
|
import com.ghy.common.utils.ShiroUtils;
|
||||||
import com.ghy.common.utils.poi.ExcelUtil;
|
import com.ghy.common.utils.poi.ExcelUtil;
|
||||||
import com.ghy.goods.domain.DeptGoodsCategory;
|
import com.ghy.goods.domain.*;
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.service.*;
|
||||||
import com.ghy.goods.service.DeptGoodsCategoryService;
|
|
||||||
import com.ghy.goods.service.GoodsService;
|
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
|
|
@ -18,7 +17,11 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/goods/goods")
|
@RequestMapping("/goods/goods")
|
||||||
|
|
@ -30,6 +33,12 @@ public class GoodsController extends BaseController {
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
@Resource
|
@Resource
|
||||||
private DeptGoodsCategoryService deptGoodsCategoryService;
|
private DeptGoodsCategoryService deptGoodsCategoryService;
|
||||||
|
@Resource
|
||||||
|
private GoodsImgsService goodsImgsService;
|
||||||
|
@Resource
|
||||||
|
private GoodsAreaService goodsAreaService;
|
||||||
|
@Resource
|
||||||
|
private GoodsStandardService goodsStandardService;
|
||||||
|
|
||||||
@RequiresPermissions("goods:goods:view")
|
@RequiresPermissions("goods:goods:view")
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
|
|
@ -43,9 +52,57 @@ public class GoodsController extends BaseController {
|
||||||
public TableDataInfo list(Goods goods) {
|
public TableDataInfo list(Goods goods) {
|
||||||
startPage();
|
startPage();
|
||||||
List<Goods> list = goodsService.selectGoodsList(goods);
|
List<Goods> list = goodsService.selectGoodsList(goods);
|
||||||
|
list.forEach(one->{
|
||||||
|
// 补全商品
|
||||||
|
List<GoodsArea> goodsAreas = goodsAreaService.selectByGoodsId(one.getGoodsId());
|
||||||
|
one.setGoodsAreaList(goodsAreas);
|
||||||
|
});
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/addGoods")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult addGoods(@RequestBody Goods goods){
|
||||||
|
try {
|
||||||
|
goodsService.addGoods(goods);
|
||||||
|
return AjaxResult.success("新增成功");
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getDetail")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult getDetail(@RequestBody Goods goods){
|
||||||
|
try {
|
||||||
|
Goods result = goodsService.selectById(goods.getGoodsId());
|
||||||
|
|
||||||
|
// 补全商品图片信息
|
||||||
|
List<GoodsImgs> goodsImgs = goodsImgsService.selectByGoodsId(result.getGoodsId());
|
||||||
|
Map<Integer, List<GoodsImgs>> listMap = new HashMap<>();
|
||||||
|
for (GoodsImgs goodsImg : goodsImgs) {
|
||||||
|
listMap.computeIfAbsent(goodsImg.getImgType(), k -> new ArrayList<>()).add(goodsImg);
|
||||||
|
}
|
||||||
|
result.setGoodsImgsMap(listMap);
|
||||||
|
|
||||||
|
// 补全商品区域
|
||||||
|
List<GoodsArea> goodsAreas = goodsAreaService.selectByGoodsId(result.getGoodsId());
|
||||||
|
result.setGoodsAreaList(goodsAreas);
|
||||||
|
|
||||||
|
// 补全商品类别
|
||||||
|
List<GoodsStandard> goodsStandards = goodsStandardService.selectByGoodsId(result.getGoodsId());
|
||||||
|
result.setGoodsStandardList(goodsStandards);
|
||||||
|
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Log(title = "商品管理", businessType = BusinessType.EXPORT)
|
@Log(title = "商品管理", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("goods:goods:export")
|
@RequiresPermissions("goods:goods:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import com.ghy.common.utils.StringUtils;
|
||||||
import com.ghy.customer.domain.Customer;
|
import com.ghy.customer.domain.Customer;
|
||||||
import com.ghy.customer.service.CustomerService;
|
import com.ghy.customer.service.CustomerService;
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
|
import com.ghy.goods.domain.GoodsStandard;
|
||||||
import com.ghy.goods.request.AppGoodsRequest;
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
import com.ghy.goods.service.GoodsService;
|
import com.ghy.goods.service.GoodsService;
|
||||||
|
import com.ghy.goods.service.GoodsStandardService;
|
||||||
import com.ghy.order.domain.OrderDetail;
|
import com.ghy.order.domain.OrderDetail;
|
||||||
import com.ghy.order.domain.OrderGoods;
|
import com.ghy.order.domain.OrderGoods;
|
||||||
import com.ghy.order.domain.OrderMaster;
|
import com.ghy.order.domain.OrderMaster;
|
||||||
|
|
@ -71,6 +73,9 @@ public class OrderController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private FinancialDetailService financialDetailService;
|
private FinancialDetailService financialDetailService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsStandardService goodsStandardService;
|
||||||
|
|
||||||
@PostMapping("/assign")
|
@PostMapping("/assign")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
|
@ -161,11 +166,11 @@ public class OrderController extends BaseController {
|
||||||
// 计算商品费用
|
// 计算商品费用
|
||||||
BigDecimal totalPay = goodsService.calculate(appGoodsList);
|
BigDecimal totalPay = goodsService.calculate(appGoodsList);
|
||||||
// 所有商品的ID
|
// 所有商品的ID
|
||||||
Set<Long> goodsIds = appGoodsList.stream().map(AppGoodsRequest::getGoodsId).collect(Collectors.toSet());
|
Set<Long> goodsStandardIds = appGoodsList.stream().map(AppGoodsRequest::getGoodsStandardId).collect(Collectors.toSet());
|
||||||
// 所有商品
|
// 所有商品
|
||||||
List<Goods> goodsList = goodsService.selectByIds(goodsIds);
|
List<GoodsStandard> goodsList = goodsStandardService.selectByIds(goodsStandardIds);
|
||||||
// 商户ID
|
// 商户ID
|
||||||
Long deptId = goodsList.get(0).getDeptId();
|
Long deptId = appOrderRequest.getDeptId();
|
||||||
Assert.notNull(deptId, "deptId is null!");
|
Assert.notNull(deptId, "deptId is null!");
|
||||||
|
|
||||||
// 生成主单
|
// 生成主单
|
||||||
|
|
@ -197,12 +202,12 @@ public class OrderController extends BaseController {
|
||||||
createFinancialDetail(deptId, customer, payMoney, financialMaster);
|
createFinancialDetail(deptId, customer, payMoney, financialMaster);
|
||||||
|
|
||||||
// 生成商品订单
|
// 生成商品订单
|
||||||
Map<Long, Goods> goodsMap = goodsList.stream().filter(Objects::nonNull)
|
Map<Long, GoodsStandard> goodsMap = goodsList.stream().filter(Objects::nonNull)
|
||||||
.collect(Collectors.toMap(Goods::getGoodsId, x -> x));
|
.collect(Collectors.toMap(GoodsStandard::getGoodsStandardId, x -> x));
|
||||||
for (AppGoodsRequest appGoods : appGoodsList) {
|
for (AppGoodsRequest appGoods : appGoodsList) {
|
||||||
Goods goods = goodsMap.get(appGoods.getGoodsId());
|
GoodsStandard goodsStandard = goodsMap.get(appGoods.getGoodsStandardId());
|
||||||
OrderGoods orderGoods = new OrderGoods(orderMaster.getId(), goods.getGoodsId(),
|
OrderGoods orderGoods = new OrderGoods(orderMaster.getId(), goodsStandard.getGoodsStandardId(),
|
||||||
goods.getGoodsName(), appGoods.getNum(), 0);
|
goodsStandard.getGoodsStandardName(), appGoods.getNum(), 0);
|
||||||
orderGoodsService.insertOrderGoods(orderGoods);
|
orderGoodsService.insertOrderGoods(orderGoods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import com.ghy.common.core.domain.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品
|
* 商品
|
||||||
|
|
@ -28,22 +30,10 @@ public class Goods extends BaseEntity {
|
||||||
@Excel(name = "名称")
|
@Excel(name = "名称")
|
||||||
private String goodsName;
|
private String goodsName;
|
||||||
|
|
||||||
@Excel(name = "价格")
|
|
||||||
private BigDecimal goodsPrice;
|
|
||||||
|
|
||||||
@Excel(name = "优惠价")
|
|
||||||
private BigDecimal discountsPrice;
|
|
||||||
|
|
||||||
@Excel(name = "团购价")
|
|
||||||
private BigDecimal groupPrice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位排序
|
|
||||||
*/
|
|
||||||
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Integer goodsSort;
|
private Integer goodsSort;
|
||||||
|
|
||||||
@Excel(name = "类别id")
|
@Excel(name = "类别id,必须是关联到系统的第三级目录")
|
||||||
private Long deptGoodsCategoryId;
|
private Long deptGoodsCategoryId;
|
||||||
|
|
||||||
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
@Excel(name = "商品图片", cellType = Excel.ColumnType.IMAGE)
|
||||||
|
|
@ -52,12 +42,14 @@ public class Goods extends BaseEntity {
|
||||||
@Excel(name = "商品视频", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "商品视频", cellType = Excel.ColumnType.STRING)
|
||||||
private String goodsVideoUrl;
|
private String goodsVideoUrl;
|
||||||
|
|
||||||
@Excel(name = "商品库存,-1则表示无限制", cellType = Excel.ColumnType.NUMERIC)
|
|
||||||
private Integer goodsNumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态(0上架 1下架 2删除)
|
|
||||||
*/
|
|
||||||
@Excel(name = "状态", readConverterExp = "0=上架,1=下架,2删除")
|
@Excel(name = "状态", readConverterExp = "0=上架,1=下架,2删除")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
private List<GoodsArea> goodsAreaList;
|
||||||
|
|
||||||
|
private Map<Integer, List<GoodsImgs>> goodsImgsMap;
|
||||||
|
|
||||||
|
private List<GoodsImgs> goodsImgsList;
|
||||||
|
|
||||||
|
private List<GoodsStandard> goodsStandardList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.ghy.goods.domain;
|
||||||
|
|
||||||
|
import com.ghy.common.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品服务区域
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GoodsArea {
|
||||||
|
|
||||||
|
@Excel(name = "商品区域id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long goodsAreaId;
|
||||||
|
|
||||||
|
@Excel(name = "商品id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long goodsId;
|
||||||
|
|
||||||
|
@Excel(name = "区域id,必须是第三级区", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Long countryAreaId;
|
||||||
|
|
||||||
|
private String areaName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -22,4 +22,7 @@ public class GoodsImgs extends BaseEntity {
|
||||||
@Excel(name = "图片url", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "图片url", cellType = Excel.ColumnType.STRING)
|
||||||
private String imgUrl;
|
private String imgUrl;
|
||||||
|
|
||||||
|
@Excel(name = "图片类型 0.轮播图 1.详情图", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Integer imgType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.ghy.goods.domain;
|
||||||
|
|
||||||
|
import com.ghy.common.annotation.Excel;
|
||||||
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品规格表
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GoodsStandard extends BaseEntity {
|
||||||
|
|
||||||
|
private Long goodsStandardId;
|
||||||
|
|
||||||
|
private String goodsStandardName;
|
||||||
|
|
||||||
|
private Long goodsId;
|
||||||
|
|
||||||
|
private Long deptGoodsCategoryId;
|
||||||
|
|
||||||
|
private BigDecimal goodsPrice;
|
||||||
|
|
||||||
|
@Excel(name = "优惠价")
|
||||||
|
private BigDecimal discountPrice;
|
||||||
|
|
||||||
|
@Excel(name = "团购价")
|
||||||
|
private BigDecimal groupPrice;
|
||||||
|
|
||||||
|
@Excel(name = "库存")
|
||||||
|
private Integer goodsNum;
|
||||||
|
|
||||||
|
private Integer saleNum;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.ghy.goods.mapper;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.GoodsArea;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GoodsAreaMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsId 商品id
|
||||||
|
* @return 商品服务区域集合
|
||||||
|
*/
|
||||||
|
List<GoodsArea> selectByGoodsId(Long goodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param areas 区域集合id
|
||||||
|
* @return 批量insert成功条数
|
||||||
|
*/
|
||||||
|
int batchInsert(List<GoodsArea> areas);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.ghy.goods.mapper;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.GoodsStandard;
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品规格
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
public interface GoodsStandardMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsStandardId 规格id
|
||||||
|
* @return 规格实体
|
||||||
|
*/
|
||||||
|
GoodsStandard selectById(Long goodsStandardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsStandardIds 规格id集合
|
||||||
|
* @return 规格集合
|
||||||
|
*/
|
||||||
|
List<GoodsStandard> selectByIds(Collection<Long> goodsStandardIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsId 商品id
|
||||||
|
* @return 所有规格集合
|
||||||
|
*/
|
||||||
|
List<GoodsStandard> selectByGoodsId(Long goodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsStandardList 批量添加商品规格
|
||||||
|
* @return 添加成功条数
|
||||||
|
*/
|
||||||
|
int batchInsert(List<GoodsStandard> goodsStandardList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param request 校验的商品数量
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
List<GoodsStandard> checkStore(AppGoodsRequest request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -10,8 +10,8 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class AppGoodsRequest {
|
public class AppGoodsRequest {
|
||||||
|
|
||||||
// 商品id
|
// 商品规格id
|
||||||
private Long goodsId;
|
private Long goodsStandardId;
|
||||||
|
|
||||||
// 数量
|
// 数量
|
||||||
private Integer num;
|
private Integer num;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.ghy.goods.service;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.GoodsArea;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品服务区域service
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
public interface GoodsAreaService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsId 商品id
|
||||||
|
* @return 商品服务区域集合
|
||||||
|
*/
|
||||||
|
List<GoodsArea> selectByGoodsId(@NotNull Long goodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param areas 区域集合id
|
||||||
|
* @return 批量insert成功条数
|
||||||
|
*/
|
||||||
|
int batchInsert(List<GoodsArea> areas);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,12 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface GoodsService {
|
public interface GoodsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goods 师傅端新增商品
|
||||||
|
* @return 新增成功条数
|
||||||
|
*/
|
||||||
|
int addGoods(Goods goods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param goodsList 需要校验库存的商品list
|
* @param goodsList 需要校验库存的商品list
|
||||||
* @return 校验结果
|
* @return 校验结果
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.ghy.goods.service;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.GoodsStandard;
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品规格service层
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
public interface GoodsStandardService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsStandardId 规格id
|
||||||
|
* @return 规格实体
|
||||||
|
*/
|
||||||
|
GoodsStandard selectById(Long goodsStandardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsStandardIds 规格id集合
|
||||||
|
* @return 规格集合
|
||||||
|
*/
|
||||||
|
List<GoodsStandard> selectByIds(Collection<Long> goodsStandardIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsId 商品id
|
||||||
|
* @return 所有规格集合
|
||||||
|
*/
|
||||||
|
List<GoodsStandard> selectByGoodsId(Long goodsId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param goodsStandardList 批量添加商品规格
|
||||||
|
* @return 添加成功条数
|
||||||
|
*/
|
||||||
|
int batchInsert(List<GoodsStandard> goodsStandardList);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param request 校验的商品数量
|
||||||
|
* @return 返回结果
|
||||||
|
*/
|
||||||
|
List<GoodsStandard> checkStore(AppGoodsRequest request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.ghy.goods.service.impl;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.GoodsArea;
|
||||||
|
import com.ghy.goods.mapper.GoodsAreaMapper;
|
||||||
|
import com.ghy.goods.service.GoodsAreaService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品服务区域impl
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class GoodsAreaServiceImpl implements GoodsAreaService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoodsAreaMapper goodsAreaMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodsArea> selectByGoodsId(@NotNull Long goodsId) {
|
||||||
|
return goodsAreaMapper.selectByGoodsId(goodsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchInsert(List<GoodsArea> areas) {
|
||||||
|
return goodsAreaMapper.batchInsert(areas);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,9 +5,14 @@ import com.ghy.common.core.text.Convert;
|
||||||
import com.ghy.common.exception.ServiceException;
|
import com.ghy.common.exception.ServiceException;
|
||||||
import com.ghy.common.utils.StringUtils;
|
import com.ghy.common.utils.StringUtils;
|
||||||
import com.ghy.goods.domain.Goods;
|
import com.ghy.goods.domain.Goods;
|
||||||
|
import com.ghy.goods.domain.GoodsArea;
|
||||||
|
import com.ghy.goods.domain.GoodsStandard;
|
||||||
import com.ghy.goods.mapper.GoodsMapper;
|
import com.ghy.goods.mapper.GoodsMapper;
|
||||||
import com.ghy.goods.request.AppGoodsRequest;
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
import com.ghy.goods.service.GoodsAreaService;
|
||||||
|
import com.ghy.goods.service.GoodsImgsService;
|
||||||
import com.ghy.goods.service.GoodsService;
|
import com.ghy.goods.service.GoodsService;
|
||||||
|
import com.ghy.goods.service.GoodsStandardService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
@ -28,10 +33,36 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
@Resource
|
@Resource
|
||||||
private GoodsMapper goodsMapper;
|
private GoodsMapper goodsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoodsAreaService goodsAreaService;
|
||||||
|
@Resource
|
||||||
|
private GoodsImgsService goodsImgsService;
|
||||||
|
@Resource
|
||||||
|
private GoodsStandardService goodsStandardService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkStore(List<AppGoodsRequest> goodsList) {
|
@Transactional
|
||||||
for (AppGoodsRequest goods : goodsList) {
|
public int addGoods(Goods goods) {
|
||||||
List<Goods> list = goodsMapper.checkAGoodsStore(goods);
|
// 添加商品主体
|
||||||
|
int result = goodsMapper.insertGoods(goods);
|
||||||
|
|
||||||
|
// 给各组件插入商品主体id
|
||||||
|
goods.getGoodsAreaList().forEach(goodsArea -> {goodsArea.setGoodsId(goods.getGoodsId());});
|
||||||
|
goods.getGoodsImgsList().forEach(goodsImg -> {goodsImg.setGoodsId(goods.getGoodsId());});
|
||||||
|
goods.getGoodsStandardList().forEach(goodsStandard -> {goodsStandard.setGoodsId(goods.getGoodsId());});
|
||||||
|
|
||||||
|
// 批量插入各组件
|
||||||
|
goodsAreaService.batchInsert(goods.getGoodsAreaList());
|
||||||
|
goodsImgsService.batchInsert(goods.getGoodsImgsList());
|
||||||
|
goodsStandardService.batchInsert(goods.getGoodsStandardList());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkStore(List<AppGoodsRequest> requests) {
|
||||||
|
for (AppGoodsRequest request : requests) {
|
||||||
|
List<GoodsStandard> list = goodsStandardService.checkStore(request);
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -43,8 +74,8 @@ public class GoodsServiceImpl implements GoodsService {
|
||||||
public BigDecimal calculate(List<AppGoodsRequest> goodsList) {
|
public BigDecimal calculate(List<AppGoodsRequest> goodsList) {
|
||||||
BigDecimal totalPay = BigDecimal.ZERO;
|
BigDecimal totalPay = BigDecimal.ZERO;
|
||||||
for (AppGoodsRequest appGoodsRequest : goodsList) {
|
for (AppGoodsRequest appGoodsRequest : goodsList) {
|
||||||
Goods goods = goodsMapper.selectById(appGoodsRequest.getGoodsId());
|
GoodsStandard goodsStandard = goodsStandardService.selectById(appGoodsRequest.getGoodsStandardId());
|
||||||
totalPay = totalPay.add(goods.getGoodsPrice().multiply(BigDecimal.valueOf(appGoodsRequest.getNum())));
|
totalPay = totalPay.add(goodsStandard.getGoodsPrice().multiply(BigDecimal.valueOf(appGoodsRequest.getNum())));
|
||||||
}
|
}
|
||||||
return totalPay;
|
return totalPay;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.ghy.goods.service.impl;
|
||||||
|
|
||||||
|
import com.ghy.goods.domain.GoodsStandard;
|
||||||
|
import com.ghy.goods.mapper.GoodsStandardMapper;
|
||||||
|
import com.ghy.goods.request.AppGoodsRequest;
|
||||||
|
import com.ghy.goods.service.GoodsStandardService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品规格impl层
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class GoodsStandardServiceImpl implements GoodsStandardService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoodsStandardMapper goodsStandardMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoodsStandard selectById(Long goodsStandardId) {
|
||||||
|
return goodsStandardMapper.selectById(goodsStandardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodsStandard> selectByIds(Collection<Long> goodsStandardIds) {
|
||||||
|
return goodsStandardMapper.selectByIds(goodsStandardIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodsStandard> selectByGoodsId(Long goodsId) {
|
||||||
|
return goodsStandardMapper.selectByGoodsId(goodsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchInsert(List<GoodsStandard> goodsStandardList) {
|
||||||
|
return goodsStandardMapper.batchInsert(goodsStandardList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GoodsStandard> checkStore(AppGoodsRequest request) {
|
||||||
|
return goodsStandardMapper.checkStore(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ghy.goods.mapper.GoodsAreaMapper">
|
||||||
|
|
||||||
|
<resultMap id="GoodsAreaResult" type="com.ghy.goods.domain.GoodsArea">
|
||||||
|
<result property="goodsAreaId" column="goods_area_id" />
|
||||||
|
<result property="goodsId" column="goods_id" />
|
||||||
|
<result property="countryAreaId" column="country_area_id"/>
|
||||||
|
<result property="areaName" column="area_name"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectGoodsArea">
|
||||||
|
SELECT ga.goods_area_id, ga.goods_id, ga.country_area_id, sa.area_name
|
||||||
|
FROM goods_area ga
|
||||||
|
LEFT JOIN sys_area sa on ga.country_area_id = sa.area_id
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectByGoodsId" resultMap="GoodsAreaResult">
|
||||||
|
<include refid="selectGoodsArea"/>
|
||||||
|
<where>
|
||||||
|
<if test="goodsId != null and goodsId != 0">
|
||||||
|
AND goods_id = #{goodsId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsArea" useGeneratedKeys="true" keyProperty="goodsAreaId">
|
||||||
|
<foreach collection="array" item="areas">
|
||||||
|
INSERT INTO goods_imgs(
|
||||||
|
<if test="goodsImgsId != null and goodsImgsId != 0">goods_imgs_id,</if>
|
||||||
|
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
||||||
|
<if test="imgUrl != null and imgUrl != ''">img_url</if>
|
||||||
|
)
|
||||||
|
VALUES(
|
||||||
|
<if test="goodsImgsId != null and goodsImgsId != 0">#{goodsImgsId},</if>
|
||||||
|
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
||||||
|
<if test="imgUrl != null and imgUrl != ''">#{imgUrl}</if>
|
||||||
|
);
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -6,15 +6,11 @@
|
||||||
<result property="goodsImgsId" column="goods_imgs_id" />
|
<result property="goodsImgsId" column="goods_imgs_id" />
|
||||||
<result property="goodsId" column="goods_id" />
|
<result property="goodsId" column="goods_id" />
|
||||||
<result property="imgUrl" column="img_url" />
|
<result property="imgUrl" column="img_url" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="imgType" column="img_type" />
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
<result property="remark" column="remark" />
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGoodsImgs">
|
<sql id="selectGoodsImgs">
|
||||||
SELECT goods_imgs_id, goods_id, img_url, create_by, create_time, remark
|
SELECT goods_imgs_id, goods_id, img_url, img_type
|
||||||
FROM goods_imgs
|
FROM goods_imgs
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
@ -29,7 +25,7 @@
|
||||||
DELETE FROM goods_imgs WHERE goods_id = #{goodsId}
|
DELETE FROM goods_imgs WHERE goods_id = #{goodsId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="selectByGoodsId" resultType="com.ghy.goods.domain.GoodsImgs">
|
<select id="selectByGoodsId" resultMap="GoodsImgsResult">
|
||||||
<include refid="selectGoodsImgs"/>
|
<include refid="selectGoodsImgs"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="goodsId != null and goodsId != 0">
|
<if test="goodsId != null and goodsId != 0">
|
||||||
|
|
@ -63,6 +59,7 @@
|
||||||
<set>
|
<set>
|
||||||
<if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if>
|
<if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if>
|
||||||
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
|
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
|
||||||
|
<if test="imgType != null and imgType != ''">img_type = #{imgType},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
WHERE goods_imgs_id = #{goodsImgsId};
|
WHERE goods_imgs_id = #{goodsImgsId};
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,10 @@
|
||||||
<result property="goodsCode" column="goods_code" />
|
<result property="goodsCode" column="goods_code" />
|
||||||
<result property="deptId" column="dept_id" />
|
<result property="deptId" column="dept_id" />
|
||||||
<result property="goodsName" column="goods_name" />
|
<result property="goodsName" column="goods_name" />
|
||||||
<result property="goodsPrice" column="goods_price" />
|
|
||||||
<result property="discountsPrice" column="discounts_price" />
|
|
||||||
<result property="groupPrice" column="group_price" />
|
|
||||||
<result property="goodsSort" column="goods_sort"/>
|
<result property="goodsSort" column="goods_sort"/>
|
||||||
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
||||||
<result property="goodsImgUrl" column="goods_img_url"/>
|
<result property="goodsImgUrl" column="goods_img_url"/>
|
||||||
<result property="goodsVideoUrl" column="goods_video_url"/>
|
<result property="goodsVideoUrl" column="goods_video_url"/>
|
||||||
<result property="goodsNumber" column="goods_number"/>
|
|
||||||
<result property="status" column="status"/>
|
<result property="status" column="status"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
|
|
@ -25,29 +21,19 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGoods">
|
<sql id="selectGoods">
|
||||||
SELECT goods_id, goods_code, dept_id, goods_name, goods_price, discounts_price, group_price, goods_sort,
|
SELECT goods_id, goods_code, dept_id, goods_name, goods_sort,
|
||||||
dept_goods_category_id, goods_img_url, goods_video_url, goods_number, status, create_by, create_time, remark
|
dept_goods_category_id, goods_img_url, goods_video_url, status, create_by, create_time, remark
|
||||||
FROM goods
|
FROM goods
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="checkAGoodsStore" parameterType="com.ghy.goods.request.AppGoodsRequest" resultMap="GoodsResult">
|
|
||||||
<include refid="selectGoods" />
|
|
||||||
where goods_id = #{goodsId} and goods_number >= #{num}
|
|
||||||
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
<update id="updateGoods" parameterType="com.ghy.goods.domain.Goods">
|
||||||
UPDATE goods
|
UPDATE goods
|
||||||
<set>
|
<set>
|
||||||
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
|
||||||
<if test="goodsPrice != null and goodsPrice != ''">goods_price = #{goodsPrice},</if>
|
|
||||||
<if test="discountsPrice != null and discountsPrice != ''">discounts_price = #{discountsPrice},</if>
|
|
||||||
<if test="groupPrice != null and groupPrice != ''">group_price = #{groupPrice},</if>
|
|
||||||
<if test="goodsSort != null and goodsSort != ''">goods_sort = #{goodsSort},</if>
|
<if test="goodsSort != null and goodsSort != ''">goods_sort = #{goodsSort},</if>
|
||||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id = #{deptGoodsCategoryId},</if>
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id = #{deptGoodsCategoryId},</if>
|
||||||
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url = #{goodsImgUrl},</if>
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url = #{goodsImgUrl},</if>
|
||||||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url = #{goodsVideoUrl},</if>
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url = #{goodsVideoUrl},</if>
|
||||||
<if test="goodsNumber != null and goodsNumber != ''">goods_number = #{goodsNumber},</if>
|
|
||||||
<if test="status != null and status != ''">`status` = #{status},</if>
|
<if test="status != null and status != ''">`status` = #{status},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
|
|
@ -67,14 +53,10 @@
|
||||||
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
<if test="goodsCode != null and goodsCode != ''">goods_code,</if>
|
||||||
<if test="deptId != null and deptId != ''">dept_id,</if>
|
<if test="deptId != null and deptId != ''">dept_id,</if>
|
||||||
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
||||||
<if test="goodsPrice != null and goodsPrice != ''">goods_price,</if>
|
|
||||||
<if test="discountsPrice != null and discountsPrice != ''">discounts_price,</if>
|
|
||||||
<if test="groupPrice != null and groupPrice != ''">group_price,</if>
|
|
||||||
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
||||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">dept_goods_category_id,</if>
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">dept_goods_category_id,</if>
|
||||||
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url,</if>
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url,</if>
|
||||||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url,</if>
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url,</if>
|
||||||
<if test="goodsNumber != null and goodsNumber != ''">goods_number,</if>
|
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
|
@ -83,14 +65,10 @@
|
||||||
<if test="goodsCode != null and goodsCode != ''">#{goodsCode},</if>
|
<if test="goodsCode != null and goodsCode != ''">#{goodsCode},</if>
|
||||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||||
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
||||||
<if test="goodsPrice != null and goodsPrice != ''">#{goodsPrice},</if>
|
|
||||||
<if test="discountsPrice != null and discountsPrice != ''">#{discountsPrice},</if>
|
|
||||||
<if test="groupPrice != null and groupPrice != ''">#{groupPrice},</if>
|
|
||||||
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
||||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">#{deptGoodsCategoryId},</if>
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">#{deptGoodsCategoryId},</if>
|
||||||
<if test="goodsImgUrl != null and goodsImgUrl != ''">#{goodsImgUrl},</if>
|
<if test="goodsImgUrl != null and goodsImgUrl != ''">#{goodsImgUrl},</if>
|
||||||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">#{goodsVideoUrl},</if>
|
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">#{goodsVideoUrl},</if>
|
||||||
<if test="goodsNumber != null and goodsNumber != ''">#{goodsNumber},</if>
|
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ghy.goods.mapper.GoodsStandardMapper">
|
||||||
|
|
||||||
|
<resultMap id="GoodsStandardResult" type="com.ghy.goods.domain.GoodsStandard">
|
||||||
|
<result property="goodsStandardId" column="goods_standard_id" />
|
||||||
|
<result property="goodsStandardName" column="goods_standard_name"/>
|
||||||
|
<result property="goodsId" column="goods_id" />
|
||||||
|
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
||||||
|
<result property="goodsPrice" column="goods_price"/>
|
||||||
|
<result property="discountPrice" column="discount_price"/>
|
||||||
|
<result property="groupPrice" column="group_price"/>
|
||||||
|
<result property="goodsNum" column="goods_num"/>
|
||||||
|
<result property="saleNum" column="sale_num"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectGoodsStandard">
|
||||||
|
SELECT goods_standard_id, goods_standard_name, goods_id, dept_goods_category_id, goods_price,
|
||||||
|
discount_price, group_price, goods_num, create_by, create_time, sale_num, status, update_by, update_time,
|
||||||
|
remark
|
||||||
|
FROM goods_standard
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectById" resultMap="GoodsStandardResult">
|
||||||
|
<include refid="selectGoodsStandard"/>
|
||||||
|
<where>
|
||||||
|
<if test="goodsStandardId != null and goodsStandardId != 0">
|
||||||
|
AND goods_standard_id = #{goodsStandardId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByIds" resultMap="GoodsStandardResult">
|
||||||
|
<include refid="selectGoodsStandard"/>
|
||||||
|
where goods_standard_id in
|
||||||
|
<foreach collection="collection" item="goodsStandardIds" open="(" separator="," close=")">
|
||||||
|
#{goodsStandardIds}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByGoodsId" resultMap="GoodsStandardResult">
|
||||||
|
<include refid="selectGoodsStandard"/>
|
||||||
|
<where>
|
||||||
|
<if test="goodsId != null and goodsId != 0">
|
||||||
|
AND goods_id = #{goodsId}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsStandard" useGeneratedKeys="true" keyProperty="goodsStandardId">
|
||||||
|
<foreach collection="array" item="goodsStandardList">
|
||||||
|
INSERT INTO goods_standard(
|
||||||
|
<if test="goodsStandardName != null and goodsStandardName != 0">goods_standard_name,</if>
|
||||||
|
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
||||||
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id</if>
|
||||||
|
<if test="goodsPrice != null and goodsPrice != 0">goods_price,</if>
|
||||||
|
<if test="discountPrice != null and discountPrice != 0">discount_price,</if>
|
||||||
|
<if test="groupPrice != null and groupPrice != 0">group_price,</if>
|
||||||
|
<if test="goodsNum != null and goodsNum != 0">goods_num,</if>
|
||||||
|
<if test="saleNum != null and saleNum != 0">sale_num,</if>
|
||||||
|
<if test="status != null and status != 0">status,</if>
|
||||||
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
|
create_time
|
||||||
|
)
|
||||||
|
VALUES(
|
||||||
|
<if test="goodsStandardName != null and goodsStandardName != 0">#{goodsStandardName},</if>
|
||||||
|
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
||||||
|
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">#{deptGoodsCategoryId}</if>
|
||||||
|
<if test="goodsPrice != null and goodsPrice != 0">#{goodsPrice},</if>
|
||||||
|
<if test="discountPrice != null and discountPrice != 0">#{discountPrice},</if>
|
||||||
|
<if test="groupPrice != null and groupPrice != 0">#{groupPrice},</if>
|
||||||
|
<if test="goodsNum != null and goodsNum != 0">#{goodsNum},</if>
|
||||||
|
<if test="saleNum != null and saleNum != 0">#{saleNum},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
sysdate()
|
||||||
|
);
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="checkStore" resultMap="GoodsStandardResult">
|
||||||
|
<include refid="selectGoodsStandard"/>
|
||||||
|
where goods_standard_id = #{goodsStandardId}
|
||||||
|
and goods_num >= #{num}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -22,7 +22,7 @@ public class OrderGoods extends BaseEntity {
|
||||||
@Excel(name = "订单id, 可以为主单或者细单", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "订单id, 可以为主单或者细单", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
|
|
||||||
@Excel(name = "商品id", cellType = Excel.ColumnType.NUMERIC)
|
@Excel(name = "商品规格id", cellType = Excel.ColumnType.NUMERIC)
|
||||||
private Long goodsId;
|
private Long goodsId;
|
||||||
|
|
||||||
@Excel(name = "商品名称", cellType = Excel.ColumnType.STRING)
|
@Excel(name = "商品名称", cellType = Excel.ColumnType.STRING)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ import java.util.List;
|
||||||
@Data
|
@Data
|
||||||
public class AppOrderRequest {
|
public class AppOrderRequest {
|
||||||
|
|
||||||
|
// 分公司id
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
// 消费者id
|
// 消费者id
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue