initorder
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package com.peanut.modules.common.controller;
|
||||||
|
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.common.service.BuyOrderService;
|
||||||
|
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController("commonBuyOrder")
|
||||||
|
@RequestMapping("common/buyOrder")
|
||||||
|
public class BuyOrderController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderService buyOrderService;
|
||||||
|
|
||||||
|
@RequestMapping("/initPrepareOrder")
|
||||||
|
public R initPrepareOrder(@RequestBody PrepareOrderDto prepareOrderDto){
|
||||||
|
Map<String, Object> stringObjectMap = buyOrderService.initPrepareOrder(prepareOrderDto);
|
||||||
|
return R.ok().put("data",stringObjectMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.peanut.modules.common.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.peanut.modules.common.entity.BuyOrder;
|
||||||
|
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface BuyOrderService extends IService<BuyOrder> {
|
||||||
|
|
||||||
|
Map<String,Object> initPrepareOrder(PrepareOrderDto prepareOrderDto);
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.peanut.modules.common.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.peanut.modules.common.dao.BuyOrderDao;
|
||||||
|
import com.peanut.modules.common.dao.MyUserDao;
|
||||||
|
import com.peanut.modules.common.dao.ShopProductDao;
|
||||||
|
import com.peanut.modules.common.entity.BuyOrder;
|
||||||
|
import com.peanut.modules.common.entity.MyUserEntity;
|
||||||
|
import com.peanut.modules.common.entity.ShopProduct;
|
||||||
|
import com.peanut.modules.common.service.BuyOrderService;
|
||||||
|
import com.peanut.modules.common.to.PrepareOrderDto;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service("commonBuyOrderService")
|
||||||
|
public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> implements BuyOrderService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MyUserDao userDao;
|
||||||
|
@Autowired
|
||||||
|
private BuyOrderDao buyOrderDao;
|
||||||
|
@Autowired
|
||||||
|
private ShopProductDao shopProductDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> initPrepareOrder(PrepareOrderDto prepareOrderDto) {
|
||||||
|
Map<String, Object> flag = new HashMap<>();
|
||||||
|
MyUserEntity userEntity = userDao.selectById(prepareOrderDto.getUid());
|
||||||
|
flag.put("user",userEntity);
|
||||||
|
|
||||||
|
boolean allFive = true;
|
||||||
|
for (Map<String,Integer> m:prepareOrderDto.getProductList()){
|
||||||
|
ShopProduct shopProduct = shopProductDao.selectById(m.get("productId"));
|
||||||
|
if(!shopProduct.getGoodsType().equals("05")){
|
||||||
|
allFive = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flag.put("is_course",allFive);
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.peanut.modules.common.to;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PrepareOrderDto {
|
||||||
|
|
||||||
|
private Integer uid;
|
||||||
|
|
||||||
|
private List<Map<String,Integer>> productList;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user