后台下单,还没写完
This commit is contained in:
parent
139702efa7
commit
f0600e4b81
|
|
@ -141,8 +141,41 @@ public class OrderController extends BaseController {
|
|||
@PostMapping("/sys/order")
|
||||
@ResponseBody
|
||||
public AjaxResult sysOrder(@RequestBody SysOrderAssignRequest request) {
|
||||
String goodsBrand = request.getGoodsBrand();
|
||||
Long deptId = getSysUser().getDeptId();
|
||||
|
||||
ArrayList<Goods> goodList = new ArrayList<>();
|
||||
// 新增商品 -- 商品不关联师傅,状态为不展示在商城页面
|
||||
for (OrderTemplateGoods good : request.getGoods()) {
|
||||
List<Long> dgcIds = good.getDeptGoodsCategoryIds();
|
||||
List<String> dgcNames = good.getDeptGoodsCategoryNames();
|
||||
// 商品的4级类要完整
|
||||
Assert.isTrue(dgcIds != null && dgcIds.size() == 4, "商品类型不正确");
|
||||
Goods goods = new Goods();
|
||||
goods.setDeptId(deptId);
|
||||
goods.setGoodsName(goodsBrand + ' ' + good.getGoodsName());
|
||||
goods.setGoodsImgUrl(request.getImageUrl());
|
||||
goods.setGoodsVideoUrl(request.getVideoUrl());
|
||||
goods.setDeptGoodsCategoryId(dgcIds.get(2));
|
||||
goods.setDeptGoodsCategoryName(dgcNames.get(2));
|
||||
goods.setStatus(1);
|
||||
goodList.add(goods);
|
||||
|
||||
GoodsStandard standard = new GoodsStandard();
|
||||
standard.setGoodsStandardName(good.getGoodsName());
|
||||
standard.setDeptGoodsCategoryId(dgcIds.get(3));
|
||||
standard.setGoodsCategoryName(dgcNames.get(3));
|
||||
|
||||
goodsService.insertGoods(goods);
|
||||
}
|
||||
|
||||
List<AppGoodsRequest> appGoodsList = goodList.stream().map(x -> {
|
||||
AppGoodsRequest agr = new AppGoodsRequest();
|
||||
|
||||
return agr;
|
||||
}).collect(Collectors.toList());
|
||||
BigDecimal totalPay = goodsService.calculate(appGoodsList);
|
||||
try {
|
||||
// 新增商品 -- 商品不关联师傅,状态为不展示在商城页面
|
||||
|
||||
// 选择消费者(消费者类型为渠道商、不需要) --
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ghy.order.domain;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OrderTemplateGoods {
|
||||
|
||||
|
|
@ -11,8 +13,14 @@ public class OrderTemplateGoods {
|
|||
private Long goodsId;
|
||||
// 商品名称
|
||||
private String goodsName;
|
||||
// 商品类型ID(第三层)
|
||||
// 商品类型ID(第四层)
|
||||
private Long deptGoodsCategoryId;
|
||||
// 商品类型(第四层)
|
||||
private String deptGoodsCategoryName;
|
||||
// 四层商品类型ID
|
||||
private List<Long> deptGoodsCategoryIds;
|
||||
// 四层商品类型
|
||||
private List<String> deptGoodsCategoryNames;
|
||||
// 商品数量
|
||||
private Long number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,24 @@
|
|||
package com.ghy.order.request;
|
||||
|
||||
import com.ghy.order.domain.OrderTemplateGoods;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysOrderAssignRequest {
|
||||
|
||||
// 商品
|
||||
private List<OrderTemplateGoods> goods;
|
||||
|
||||
// 商品品牌
|
||||
private String goodsBrand;
|
||||
|
||||
// 视频
|
||||
private String videoUrl;
|
||||
// 图片
|
||||
private String imageUrl;
|
||||
|
||||
// 商品相关信息
|
||||
private Long goodsDeptCategoryId;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue