Bladeren bron

二级市场收购商购买功能修改

linbl 1 jaar geleden
bovenliggende
commit
36e1e83da3
1 gewijzigde bestanden met toevoegingen van 16 en 3 verwijderingen
  1. 16 3
      sp-service/level-two-server/src/main/java/com/pj/tb_orders/TbOrdersService.java

+ 16 - 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,15 +95,21 @@ 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;
     }