|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
|
import com.pj.api.dto.GoodsDto;
|
|
|
import com.pj.api.dto.PeopleDto;
|
|
|
+import com.pj.current.dto.APPLoginUserInfo;
|
|
|
import com.pj.enummj.DeleteStatus;
|
|
|
import com.pj.retry.SmsRetryService;
|
|
|
import com.pj.tb_demand_quotation.TbDemandQuotation;
|
|
@@ -11,11 +12,14 @@ import com.pj.tb_demand_quotation.TbDemandQuotationMapper;
|
|
|
import com.pj.tb_demand_quotation.TbDemandQuotationService;
|
|
|
import com.pj.tb_goods_demand.vo.GoodsDemandVo;
|
|
|
import com.pj.tb_orders.TbOrders;
|
|
|
+import com.pj.tb_orders.TbOrdersMapper;
|
|
|
+import com.pj.utils.so.SoMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -33,7 +37,7 @@ public class MethodGoodsDemandService {
|
|
|
@Autowired
|
|
|
private TbGoodsDemandMapper tbGoodsDemandMapper;
|
|
|
@Autowired
|
|
|
- private SmsRetryService smsRetryService;
|
|
|
+ private TbOrdersMapper tbOrdersMapper;
|
|
|
|
|
|
/**
|
|
|
* 数据封装
|
|
@@ -41,7 +45,7 @@ public class MethodGoodsDemandService {
|
|
|
* @param list
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<GoodsDemandVo> setGoodsDemandVo(List<TbGoodsDemand> list){
|
|
|
+ public List<GoodsDemandVo> setGoodsDemandVo(List<TbGoodsDemand> list, SoMap so){
|
|
|
//创建返回值集合
|
|
|
List<GoodsDemandVo> resultList = new ArrayList<>();
|
|
|
|
|
@@ -51,10 +55,9 @@ public class MethodGoodsDemandService {
|
|
|
//获取需求表ID
|
|
|
Long id = item.getId();
|
|
|
//查询报价表
|
|
|
- LambdaQueryWrapper<TbDemandQuotation> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(TbDemandQuotation::getDemandId,id);
|
|
|
- queryWrapper.eq(TbDemandQuotation::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
- List<TbDemandQuotation> tbDemandQuotations = tbDemandQuotationMapper.selectList(queryWrapper);
|
|
|
+ so.put("demandId",id);
|
|
|
+ so.put("deleteStatus",DeleteStatus.DELETE_STATUS_ON.getCode());
|
|
|
+ List<TbDemandQuotation> tbDemandQuotations = tbDemandQuotationMapper.getList(so);
|
|
|
if(tbDemandQuotations.size() == 0)return;
|
|
|
//查询商品基本信息
|
|
|
TbDemandQuotation tbDemandQuotation = tbDemandQuotations.get(0);
|
|
@@ -80,19 +83,23 @@ public class MethodGoodsDemandService {
|
|
|
|
|
|
/**
|
|
|
* 执行同意处理
|
|
|
- * @param goodsDemandId 需求表ID
|
|
|
- * @param demandQuotationId 报价表ID
|
|
|
- * @param disposeStatus 处理状态 1=确认,2=拒绝
|
|
|
+ * @param appLoginUserInfo 当前登录账号信息
|
|
|
+ * @param goodsDemandId 需求表ID
|
|
|
+ * @param demandQuotationId 报价表ID
|
|
|
+ * @param purchaserRemark 二级收购商备注
|
|
|
*/
|
|
|
- public void agreeQuotation(Integer disposeStatus,Long goodsDemandId,Long demandQuotationId){
|
|
|
+ public boolean agreeQuotation(APPLoginUserInfo appLoginUserInfo,Long goodsDemandId,Long demandQuotationId,String purchaserRemark){
|
|
|
// 校验参数
|
|
|
TbDemandQuotation tbDemandQuotation = tbDemandQuotationMapper.selectById(demandQuotationId); // 报价
|
|
|
- if(tbDemandQuotation == null)return;
|
|
|
+ if(tbDemandQuotation == null)return false;
|
|
|
TbGoodsDemand tbGoodsDemand = tbGoodsDemandMapper.selectById(goodsDemandId); //需求
|
|
|
- if(tbGoodsDemand == null)return;
|
|
|
+ if(tbGoodsDemand == null)return false;
|
|
|
//执行过程
|
|
|
- tbDemandQuotation.setQuotationResult(disposeStatus);
|
|
|
+ tbDemandQuotation.setQuotationResult(1); // 设置二级收购商处理结果 1表示同意
|
|
|
+ tbDemandQuotation.setResultTime(new Date()); // 设置二级收购商处理时间
|
|
|
+ tbDemandQuotation.setRemark("\n" + appLoginUserInfo.getLoginName() + ": " + purchaserRemark); // 商家备注
|
|
|
int updateById = tbDemandQuotationMapper.updateById(tbDemandQuotation);
|
|
|
+ //处理商家同意后的逻辑
|
|
|
if(updateById == 1){
|
|
|
//开始创建订单
|
|
|
TbOrders tbOrders = new TbOrders();
|
|
@@ -102,27 +109,48 @@ public class MethodGoodsDemandService {
|
|
|
// tbOrders.setGoodsFrom(); //产地
|
|
|
tbOrders.setShipperPhone(tbDemandQuotation.getLinkPhone()); //联系电话
|
|
|
tbOrders.setShipperName(tbDemandQuotation.getCreateName()); //卖家名称
|
|
|
-
|
|
|
-
|
|
|
+ tbOrders.setTradeAreaId(tbDemandQuotation.getTradeAreaId()); //交易地区ID
|
|
|
+ tbOrders.setTradeAreaName(tbDemandQuotation.getTradeAreaName()); //交易地区名称
|
|
|
+ tbOrders.setCreateBy(tbDemandQuotation.getLeaderId()); // 订单创建人 -- 边民表主键
|
|
|
+ tbOrders.setPurchaserId(tbGoodsDemand.getPurchaserId()); //买家ID 商户表
|
|
|
+ tbOrders.setPurchaserName(tbGoodsDemand.getPurchaserName()); // 买家名称 商户表
|
|
|
+ tbOrders.setCreateName(tbDemandQuotation.getCreateName());
|
|
|
+ tbOrders.setCreateTime(new Date()); // 创建时间
|
|
|
+ tbOrders.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 删除状态 默认可用
|
|
|
+ int insert = tbOrdersMapper.insert(tbOrders);
|
|
|
+ return insert == 1;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+ return false;
|
|
|
}
|
|
|
- // todo: ----------------
|
|
|
+
|
|
|
/**
|
|
|
* 执行拒绝处理
|
|
|
- * @param goodsDemandId
|
|
|
- * @param demandQuotationId
|
|
|
+ * @param appLoginUserInfo 当前登录账号信息
|
|
|
+ * @param goodsDemandId 需求表ID
|
|
|
+ * @param demandQuotationId 报价表ID
|
|
|
+ * @param purchaserRemark 二级收购商备注
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public void refuseQuotation(Long goodsDemandId,Long demandQuotationId) throws Exception {
|
|
|
+ public boolean refuseQuotation(APPLoginUserInfo appLoginUserInfo,Long goodsDemandId, Long demandQuotationId, String purchaserRemark){
|
|
|
// 校验参数
|
|
|
TbDemandQuotation tbDemandQuotation = tbDemandQuotationMapper.selectById(demandQuotationId);
|
|
|
- if(tbDemandQuotation == null)return;
|
|
|
+ if(tbDemandQuotation == null)return false;
|
|
|
TbGoodsDemand tbGoodsDemand = tbGoodsDemandMapper.selectById(goodsDemandId);
|
|
|
- if(tbGoodsDemand == null)return;
|
|
|
- //执行过程
|
|
|
-
|
|
|
+ if(tbGoodsDemand == null)return false;
|
|
|
+ // 修改需求状态
|
|
|
+ tbGoodsDemand.setIsOrders(0); // 将需求设置为未发布
|
|
|
+ int updateById = tbGoodsDemandMapper.updateById(tbGoodsDemand); // 设置二级市场收购商的响应时间
|
|
|
+ //修改报价状态
|
|
|
+ if(updateById == 1){
|
|
|
+ tbDemandQuotation.setQuotationResult(2); // 2 表示拒绝
|
|
|
+ tbDemandQuotation.setRemark("\n" + appLoginUserInfo.getLoginName() + ": " + purchaserRemark);
|
|
|
+ tbDemandQuotation.setResultTime(new Date());
|
|
|
+ int updateById1 = tbDemandQuotationMapper.updateById(tbDemandQuotation);
|
|
|
+ return updateById1 == 1;
|
|
|
+ }
|
|
|
|
|
|
+ return false;
|
|
|
|
|
|
}
|
|
|
}
|