Forráskód Böngészése

Merge remote-tracking branch 'origin/feature/asyncOrder' into feature/asyncOrder

Mechrevo 1 éve
szülő
commit
b32fac751b

+ 4 - 8
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersApiController.java

@@ -104,14 +104,10 @@ public class TbOrdersApiController {
 
 	/** 查 根据订单Id查订单详情 */
 	@RequestMapping("getDetailById")
-	public AjaxJson getDetailById(Long id) {
-		TbOrders t = tbOrdersService.getById(id);
-
-		List<TbOrders> OrderList = new ArrayList<>();
-		OrderList.add(t);
-		List<TbOrdersDto> tbOrdersDto = methodOrdersService.getTbOrdersDto(OrderList);
-		if(tbOrdersDto.size() > 0) return AjaxJson.getSuccessData(tbOrdersDto.get((0)));
-		return AjaxJson.getError();
+	public AjaxJson getDetailById() {
+		SoMap so = SoMap.getRequestSoMap();
+		List<TbOrders> list = tbOrdersService.getDetailById(so);
+		return AjaxJson.getSuccessData(list);
 	}
 
 

+ 29 - 3
sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

@@ -1,15 +1,18 @@
 package com.pj.tb_orders;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
 import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.client.level_one_server.LevelOneServerInterface;
 import com.pj.api.dto.GoodsDto;
 import com.pj.api.dto.MessageDto;
+import com.pj.common.core.text.Convert;
 import com.pj.common.core.utils.StringUtils;
 import com.pj.current.config.SystemObject;
 import com.pj.current.dto.APPLoginUserInfo;
@@ -23,6 +26,8 @@ import com.pj.tb_goods_demand.TbGoodsDemand;
 import com.pj.tb_goods_demand.TbGoodsDemandMapper;
 import com.pj.tb_goods_demand.TbGoodsDemandService;
 import com.pj.tb_goods_demand.vo.GoodsDemandVo;
+import com.pj.tb_orders_cart.TbOrdersCart;
+import com.pj.tb_orders_cart.TbOrdersCartMapper;
 import com.pj.tb_purchaser.TbPurchaser;
 import com.pj.tb_purchaser.TbPurchaserMapper;
 import com.pj.utils.so.SoMap;
@@ -54,6 +59,8 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 	private TbDemandQuotationService demandQuotationService;
 	@Autowired
 	private MethodOrdersService methodOrdersService;
+	@Autowired
+	TbOrdersCartMapper tbOrdersCartMapper;
 
 	/**
 	 * 远程调用
@@ -88,18 +95,37 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
 		String idStr = so.getString("ids");
 		if(StringUtils.isEmpty(idStr)) throw new RuntimeException("当前购买操作异常,请重新登录或联系管理员!");
 
-		String[] idArr = idStr.split(",");
+		Long[] idArr = Convert.toLongArray(idStr);
 		TbOrders orders = new TbOrders();
 		orders.setPurchaserId(purchaser.getId());
 		orders.setPurchaserName(purchaser.getName());
-		for (String id : idArr) {
-			orders.setId(Long.valueOf(id));
+		for (Long id : idArr) {
+			orders.setId(id);
 			boolean b = updateById(orders);
 			if(!b)  throw new RuntimeException("购买异常,请重新登录或联系管理员!");
 		}
+
+		// 清空购物车
+		LambdaQueryWrapper<TbOrdersCart> wrapper = new LambdaQueryWrapper<>();
+		wrapper.in(TbOrdersCart::getOrderId, Arrays.asList(idArr));
+		int del = tbOrdersCartMapper.delete(wrapper);
+
 		return true;
     }
 
+	List<TbOrders> getDetailById(SoMap so){
+		String idStr = so.getString("ids");
+		if(StringUtils.isEmpty(idStr)) throw new RuntimeException("当前订单操作异常,请重新登录或联系管理员!");
+
+		List<TbOrders> list = new ArrayList<>();
+
+		String[] idArr = idStr.split(",");
+		for (String id : idArr) {
+			TbOrders orders = getById(id);
+			list.add(orders);
+		}
+		return list;
+	}
 	/** 查 */
 	TbOrders getById(Long id){
 		return super.getById(id);