|
@@ -1,5 +1,6 @@
|
|
|
package com.pj.tb_orders;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -7,14 +8,15 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
|
import com.pj.api.dto.GoodsDto;
|
|
|
-import com.pj.common.core.exception.ServiceException;
|
|
|
-import com.pj.common.core.utils.StringUtils;
|
|
|
import com.pj.current.config.SystemObject;
|
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
import com.pj.enummj.DeleteStatus;
|
|
|
import com.pj.enummj.OrderStatus;
|
|
|
+import com.pj.tb_demand_quotation.TbDemandQuotation;
|
|
|
+import com.pj.tb_demand_quotation.TbDemandQuotationService;
|
|
|
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_purchaser.TbPurchaser;
|
|
@@ -44,6 +46,8 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
private LevelOneServerInterface levelOneServerInterface;
|
|
|
@Autowired
|
|
|
private TbGoodsDemandService goodsDemandService;
|
|
|
+ @Autowired
|
|
|
+ private TbDemandQuotationService demandQuotationService;
|
|
|
|
|
|
/** 增 */
|
|
|
void add(TbOrders t){
|
|
@@ -76,24 +80,73 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
return tbOrdersMapper.getList();
|
|
|
}
|
|
|
|
|
|
- /** 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
|
+ /**
|
|
|
+ * 二级市场订单 组长角色入口
|
|
|
* 管理购买的商品订单(包括已支付、运输中、售后)
|
|
|
* */
|
|
|
- List<TbOrders> getList(SoMap so) {
|
|
|
- //首先判断该用户是否为收购商
|
|
|
- APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
|
|
|
- if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
|
|
|
- throw new ServiceException("当前登陆用户信息已失效!");
|
|
|
- //执行查询
|
|
|
- if(appLoginInfo.getUserType()==5){
|
|
|
- so.put("purchaserId",appLoginInfo.getFk()); // 收购商编号
|
|
|
- }
|
|
|
- if(appLoginInfo.getUserType()==2){
|
|
|
- so.put("leaderId",appLoginInfo.getFk()); // 边民组长id
|
|
|
- }
|
|
|
+ List<TbOrdersDto> getLeaderOrderList(SoMap so) {
|
|
|
+ // 边民组长id
|
|
|
+ so.put("leaderId",StpAPPUserUtil.getAPPLoginInfo().getFk());
|
|
|
so.put("sortType",22);
|
|
|
so.put("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
- return tbOrdersMapper.getList(so);
|
|
|
+ List<TbOrders> orderList = tbOrdersMapper.getList(so);
|
|
|
+
|
|
|
+ List<TbOrdersDto> ordersDtoList = new ArrayList<>();
|
|
|
+ BeanUtils.copyProperties(orderList,ordersDtoList);
|
|
|
+
|
|
|
+ ordersDtoList.forEach(ordersDto -> {
|
|
|
+ // 需求表主键Id
|
|
|
+ Long goodsDemandId = ordersDto.getFkGoodsDemandId();
|
|
|
+ // 获取订单关联的需求表信息
|
|
|
+ TbGoodsDemand goodsDemand = goodsDemandService.getById(goodsDemandId);
|
|
|
+
|
|
|
+ ordersDto.setGoodsImg(goodsDemand.getGoodsImg());
|
|
|
+ ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
|
|
|
+ ordersDto.setRemark(goodsDemand.getRemark());
|
|
|
+ ordersDto.setGoodsUnit(goodsDemand.getGoodsUnit());
|
|
|
+ ordersDto.setGoodsNo(goodsDemand.getGoodsNo());
|
|
|
+ ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
|
|
|
+ ordersDto.setAcquirerName(goodsDemand.getCreateName());
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return ordersDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 二级市场订单 收购商角色入口
|
|
|
+ * 管理购买的商品订单(包括已支付、运输中、售后)
|
|
|
+ * */
|
|
|
+ List<TbOrdersDto> getPurchaserOrderList(SoMap so) {
|
|
|
+ // 收购商id
|
|
|
+ so.put("purchaserId",StpAPPUserUtil.getAPPLoginInfo().getFk());
|
|
|
+ so.put("sortType",22);
|
|
|
+ so.put("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
+ List<TbOrders> orderList = tbOrdersMapper.getList(so);
|
|
|
+
|
|
|
+ List<TbOrdersDto> ordersDtoList = new ArrayList<>();
|
|
|
+
|
|
|
+ orderList.forEach(order -> {
|
|
|
+ // 需求表主键Id
|
|
|
+ Long goodsDemandId = order.getFkGoodsDemandId();
|
|
|
+ // 获取订单关联的需求表信息
|
|
|
+ TbGoodsDemand goodsDemand = goodsDemandService.getById(goodsDemandId);
|
|
|
+
|
|
|
+ TbOrdersDto ordersDto = new TbOrdersDto();
|
|
|
+ BeanUtils.copyProperties(order,ordersDto);
|
|
|
+
|
|
|
+ ordersDto.setGoodsImg(goodsDemand.getGoodsImg());
|
|
|
+ ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
|
|
|
+ ordersDto.setRemark(goodsDemand.getRemark());
|
|
|
+ ordersDto.setGoodsUnit(goodsDemand.getGoodsUnit());
|
|
|
+ ordersDto.setGoodsNo(goodsDemand.getGoodsNo());
|
|
|
+ ordersDto.setGoodsQuantity(goodsDemand.getGoodsQuantity());
|
|
|
+ ordersDto.setAcquirerName(goodsDemand.getCreateName());
|
|
|
+
|
|
|
+ ordersDtoList.add(ordersDto);
|
|
|
+ });
|
|
|
+
|
|
|
+ return ordersDtoList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -147,8 +200,12 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
orders.setConsigneePhone(goodsDemandVo.getPhone());
|
|
|
orders.setUnloadingAddress(goodsDemandVo.getAddressName());
|
|
|
orders.setLeaderId(goodsDemandVo.getLeaderId());
|
|
|
+ // 需求表主键Id
|
|
|
+ orders.setFkGoodsDemandId(goodsDemandVo.getGoodsDemandId());
|
|
|
//订单完成状态 (0=未完成,1=已完成)
|
|
|
orders.setOrderFinish(OrderStatus.ORDER_STATUS_ZERO.getCode());
|
|
|
+ //收货状态 (0=未收货,1=已收货)
|
|
|
+ orders.setOrderFinish(OrderStatus.ORDER_STATUS_ZERO.getCode());
|
|
|
//删除状态(0=禁用,1=启用)
|
|
|
orders.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
//创建人
|
|
@@ -156,18 +213,25 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
|
orders.setCreateName(StpAPPUserUtil.getAPPLoginInfo().getLoginName());
|
|
|
orders.setCreateTime(new Date());
|
|
|
|
|
|
- orders.setTradeAreaId(StpAPPUserUtil.getAPPLoginInfo().getTradeAreaId());
|
|
|
-
|
|
|
+ orders.setPurchaserId(StpAPPUserUtil.getAPPLoginInfo().getFk());
|
|
|
+ orders.setTradeAreaId(goodsDemandVo.getTradeAreaId());
|
|
|
+ orders.setTradeAreaName(goodsDemandVo.getTradeAreaName());
|
|
|
|
|
|
this.add(orders);
|
|
|
|
|
|
// 回写到收购商发布需求表,把收购商确认状态改为已确认
|
|
|
- LambdaUpdateWrapper<TbGoodsDemand> wrapper = new LambdaUpdateWrapper();
|
|
|
+ LambdaUpdateWrapper<TbGoodsDemand> wrapper1 = new LambdaUpdateWrapper();
|
|
|
//收购商是否确认:0=未确认,1=已确认
|
|
|
- wrapper.set(TbGoodsDemand::getIsConfirm, 1);
|
|
|
+ wrapper1.set(TbGoodsDemand::getIsConfirm, 1);
|
|
|
+ wrapper1.eq(TbGoodsDemand::getId, goodsDemandVo.getGoodsDemandId());
|
|
|
+ boolean update1 = goodsDemandService.update(wrapper1);
|
|
|
|
|
|
- wrapper.eq(TbGoodsDemand::getId, goodsDemandVo.getGoodsDemandId());
|
|
|
- goodsDemandService.update(wrapper);
|
|
|
+ // 回写到组长报价表,把报价结果状态改为已确认
|
|
|
+ LambdaUpdateWrapper<TbDemandQuotation> wrapper2 = new LambdaUpdateWrapper();
|
|
|
+ //收购商是否确认:0=未确认,1=已确认
|
|
|
+ wrapper2.set(TbDemandQuotation::getQuotationResult, 1);
|
|
|
+ wrapper2.eq(TbDemandQuotation::getDemandId, goodsDemandVo.getGoodsDemandId());
|
|
|
+ boolean update2 = demandQuotationService.update(wrapper2);
|
|
|
|
|
|
|
|
|
return true;
|