소스 검색

二级市场组长接单

李书文 2 년 전
부모
커밋
da3fd232ef

+ 75 - 74
sp-service/level-two-server/src/main/java/com/pj/tb_demand_quotation/AppTbDemandQuotationController.java

@@ -6,98 +6,99 @@ import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
 
 /**
  * app: tb_demand_quotation -- 一级市场组长需求抢购表
- * @author yzs 
+ *
+ * @author yzs
  */
 @RestController
 @RequestMapping("/app/TbDemandQuotation/")
 public class AppTbDemandQuotationController {
 
-	/** 底层 Service 对象 */
-	@Autowired
-	TbDemandQuotationService tbDemandQuotationService;
+    /**
+     * 底层 Service 对象
+     */
+    @Autowired
+    TbDemandQuotationService tbDemandQuotationService;
 
-	/** 增 */  
-	@RequestMapping("add")
+    /**
+     * 增
+     */
+    @RequestMapping("add")
 //	@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE_ADD)
-	public AjaxJson add(TbDemandQuotation t){
-		tbDemandQuotationService.add(t);
-		t = tbDemandQuotationService.getById(SP.publicMapper.getPrimarykey());
-		return AjaxJson.getSuccessData(t);
-	}
-
-	/** 删 */  
-	@RequestMapping("delete")
+    public AjaxJson add(TbDemandQuotation t) {
+        tbDemandQuotationService.add(t);
+        t = tbDemandQuotationService.getById(SP.publicMapper.getPrimarykey());
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 删
+     */
+    @RequestMapping("delete")
 //	@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		 tbDemandQuotationService.delete(id);
-		return AjaxJson.getSuccess();
-	}
-	
-	/** 删 - 根据id列表 */  
-	@RequestMapping("deleteByIds")
+    public AjaxJson delete(Long id) {
+        tbDemandQuotationService.delete(id);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 删 - 根据id列表
+     */
+    @RequestMapping("deleteByIds")
 //	@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
-		int line = SP.publicMapper.deleteByIds(TbDemandQuotation.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-	
-	/** 改 */  
-	@RequestMapping("update")
+    public AjaxJson deleteByIds() {
+        List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+        int line = SP.publicMapper.deleteByIds(TbDemandQuotation.TABLE_NAME, ids);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改
+     */
+    @RequestMapping("update")
 //	@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE_EDIT)
-	public AjaxJson update(TbDemandQuotation t){
-		tbDemandQuotationService.update(t);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 查 - 根据id */  
-	@RequestMapping("getById")
+    public AjaxJson update(TbDemandQuotation t) {
+        tbDemandQuotationService.update(t);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("getById")
 //		@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE)
-	public AjaxJson getById(Long id){
-		TbDemandQuotation t = tbDemandQuotationService.getById(id);
-		return AjaxJson.getSuccessData(t);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	@RequestMapping("getList")
+    public AjaxJson getById(Long id) {
+        TbDemandQuotation t = tbDemandQuotationService.getById(id);
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getList")
 //		@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE)
-	public AjaxJson getList() { 
-		SoMap so = SoMap.getRequestSoMap();
-		List<TbDemandQuotation> list = tbDemandQuotationService.getList(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
-
-
-	/**
-	 * 一级市场组长接单
-	 * @param demandQuotationParam
-	 * @return
-	 * @throws Exception
-	 */
-	@RequestMapping("quotation")
-//		@SaCheckPermission(TbDemandQuotation.PERMISSION_CODE)
-	public AjaxJson quotation(@Validated @RequestBody DemandQuotationParam demandQuotationParam) throws Exception {
-		boolean quotation = tbDemandQuotationService.quotation(demandQuotationParam);
-		if(!quotation)return AjaxJson.getError("抢单失败!");
-		return AjaxJson.getSuccess();
-	}
-
-
-
-
-
-
-
+    public AjaxJson getList() {
+        SoMap so = SoMap.getRequestSoMap();
+        List<TbDemandQuotation> list = tbDemandQuotationService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
+
+
+    /**
+     * 二级市场组长接单
+     */
+    @PostMapping("quotation")
+    public AjaxJson quotation(@Validated DemandQuotationParam demandQuotationParam) throws Exception {
+        boolean quotation = tbDemandQuotationService.quotation(demandQuotationParam);
+        if (!quotation) return AjaxJson.getError("抢单失败!");
+        return AjaxJson.getSuccess();
+    }
 
 
 }

+ 106 - 85
sp-service/level-two-server/src/main/java/com/pj/tb_demand_quotation/TbDemandQuotationService.java

@@ -24,103 +24,124 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Service: tb_demand_quotation -- 一级市场组长需求抢购表
- * @author yzs 
+ *
+ * @author yzs
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbDemandQuotationService extends ServiceImpl<TbDemandQuotationMapper, TbDemandQuotation> implements IService<TbDemandQuotation>{
+public class TbDemandQuotationService extends ServiceImpl<TbDemandQuotationMapper, TbDemandQuotation> implements IService<TbDemandQuotation> {
 
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbDemandQuotationMapper tbDemandQuotationMapper;
-	/** 远程调用 */
-	@Autowired
-	private LevelOneServerInterface levelOneServerInterface;
-	/** 失败重试机制 */
-	@Autowired
-	private SmsRetryService smsRetryService;
-	/** 二级收购商需求 */
-	@Autowired
-	private TbGoodsDemandMapper tbGoodsDemandMapper;
-	/** 二级市场收购商 */
-	@Autowired
-	private TbPurchaserMapper tbPurchaserMapper;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbDemandQuotationMapper tbDemandQuotationMapper;
+    /**
+     * 远程调用
+     */
+    @Autowired
+    private LevelOneServerInterface levelOneServerInterface;
+    /**
+     * 失败重试机制
+     */
+    @Autowired
+    private SmsRetryService smsRetryService;
+    /**
+     * 二级收购商需求
+     */
+    @Autowired
+    private TbGoodsDemandMapper tbGoodsDemandMapper;
+    /**
+     * 二级市场收购商
+     */
+    @Autowired
+    private TbPurchaserMapper tbPurchaserMapper;
 
-	/** 增 */
-	void add(TbDemandQuotation t){
-		save(t);
-	}
+    /**
+     * 增
+     */
+    void add(TbDemandQuotation t) {
+        save(t);
+    }
 
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/** 改 */
-	void update(TbDemandQuotation t){
-		updateById(t);
+    /**
+     * 改
+     */
+    void update(TbDemandQuotation t) {
+        updateById(t);
 
-	}
+    }
 
-	/** 查 */
-	TbDemandQuotation getById(Long id){
-		return super.getById(id);
-	}
+    /**
+     * 查
+     */
+    TbDemandQuotation getById(Long id) {
+        return super.getById(id);
+    }
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbDemandQuotation> getList(SoMap so) { 
-		return tbDemandQuotationMapper.getList(so);	
-	}
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbDemandQuotation> getList(SoMap so) {
+        return tbDemandQuotationMapper.getList(so);
+    }
 
 
-	/**
-	 * 互市组组长接单
-	 * @param demandQuotationParam
-	 */
-	public boolean quotation(DemandQuotationParam demandQuotationParam) throws Exception {
-		//获取并判断当前登陆人
-		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		if(appLoginInfo == null || appLoginInfo.getLoginId() == null)
-			throw new ServiceException("当前登录账号信息已失效!");
-		//判定接单状态
-		if(demandQuotationParam.getIsOrders() != 1)throw new ServiceException("非法操作!");
-		//获取边民组信息
-		PeopleDto rpcById = levelOneServerInterface.getRpcById(appLoginInfo.getFk());
-		if(rpcById == null)throw new ServiceException("边民组信息有误!");
-		//判断组长身份
-		if(rpcById.getRole() != 2)throw new ServiceException("您当前身份不是组长,无法抢单报价!");
-		//执行接单报价
-		TbDemandQuotation tbDemandQuotation = new TbDemandQuotation();
-		tbDemandQuotation.setQuotationResult(0); //默认待商家确认
-		tbDemandQuotation.setPurchaserId(demandQuotationParam.getPurchaserId()); // 商家ID
-		tbDemandQuotation.setDemandId(demandQuotationParam.getGoodsDemandId()); //需求表ID
-		tbDemandQuotation.setQuotation(demandQuotationParam.getPrice()); // 报价
-		tbDemandQuotation.setCreateBy(appLoginInfo.getLoginId()); //创建人登陆表主键
-		tbDemandQuotation.setRemark(appLoginInfo.getLoginName() + ": " +  demandQuotationParam.getRemark()); //报价备注
-		tbDemandQuotation.setLeaderId(appLoginInfo.getFk());  //边民表主键
-		tbDemandQuotation.setGroupName(rpcById.getGroupName()); // 互市组组名
-		tbDemandQuotation.setCreateTime(new Date()); //创建时间
-		tbDemandQuotation.setGroupId(rpcById.getGroupId());
-		tbDemandQuotation.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 删除状态默认可用
-		int insert = tbDemandQuotationMapper.insert(tbDemandQuotation);
-		if(insert == 1){
-			//修改二级市场收购商的需求状态
-			TbGoodsDemand tbGoodsDemand = tbGoodsDemandMapper.selectById(demandQuotationParam.getGoodsDemandId());
-			if(tbGoodsDemand == null || tbGoodsDemand.getIsOrders() == 1 || tbGoodsDemand.getDeleteStatus() == 0)
-				throw new RuntimeException("二级市场收购商需求订单状态异常!");
-			//执行修改二级市场收购商需求状态
-			tbGoodsDemand.setIsOrders(demandQuotationParam.getIsOrders());
-			int updateById = tbGoodsDemandMapper.updateById(tbGoodsDemand);
-			if(updateById != 1)throw new RuntimeException("无法进行报价!");
-			//短信提示二级市场收购商,需求已报价,进入app进行确认接单
-			TbPurchaser tbPurchaser = tbPurchaserMapper.selectById(tbGoodsDemand.getPurchaserId());
-			if(tbPurchaser == null)throw new RuntimeException("服务器繁忙~");
-			//todo:发送短信
+    /**
+     * 互市组组长接单
+     *
+     * @param demandQuotationParam
+     */
+    public boolean quotation(DemandQuotationParam demandQuotationParam) throws Exception {
+        //获取并判断当前登陆人
+        APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
+        if (appLoginInfo == null || appLoginInfo.getLoginId() == null)
+            throw new ServiceException("当前登录账号信息已失效!");
+        demandQuotationParam.setIsOrders(1);
+        //获取边民组信息
+        PeopleDto rpcById = levelOneServerInterface.getRpcById(appLoginInfo.getFk());
+        if (rpcById == null) throw new ServiceException("边民组信息有误!");
+        //判断组长身份
+        if (rpcById.getRole() != 2) throw new ServiceException("您当前身份不是组长,无法抢单报价!");
+        //执行接单报价
+        TbDemandQuotation tbDemandQuotation = new TbDemandQuotation();
+        tbDemandQuotation.setQuotationResult(0); //默认待商家确认
+        tbDemandQuotation.setPurchaserId(demandQuotationParam.getPurchaserId()); // 商家ID
+        tbDemandQuotation.setDemandId(demandQuotationParam.getGoodsDemandId()); //需求表ID
+        tbDemandQuotation.setQuotation(demandQuotationParam.getPrice()); // 报价
+        tbDemandQuotation.setCreateBy(appLoginInfo.getLoginId()); //创建人登陆表主键
+        tbDemandQuotation.setRemark(appLoginInfo.getLoginName() + ": " + demandQuotationParam.getRemark()); //报价备注
+        tbDemandQuotation.setLeaderId(appLoginInfo.getFk());  //边民表主键
+        tbDemandQuotation.setGroupName(rpcById.getGroupName()); // 互市组组名
+        tbDemandQuotation.setCreateTime(new Date()); //创建时间
+        tbDemandQuotation.setGroupId(rpcById.getGroupId());
+        tbDemandQuotation.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 删除状态默认可用
+        int insert = tbDemandQuotationMapper.insert(tbDemandQuotation);
+        if (insert == 1) {
+            //修改二级市场收购商的需求状态
+            TbGoodsDemand tbGoodsDemand = tbGoodsDemandMapper.selectById(demandQuotationParam.getGoodsDemandId());
+            if (tbGoodsDemand == null || tbGoodsDemand.getIsOrders() == 1 || tbGoodsDemand.getDeleteStatus() == 0)
+                throw new RuntimeException("二级市场收购商需求订单状态异常!");
+            //执行修改二级市场收购商需求状态
+            tbGoodsDemand.setIsOrders(demandQuotationParam.getIsOrders());
+            int updateById = tbGoodsDemandMapper.updateById(tbGoodsDemand);
+            if (updateById != 1) throw new RuntimeException("无法进行报价!");
+            //短信提示二级市场收购商,需求已报价,进入app进行确认接单
+            TbPurchaser tbPurchaser = tbPurchaserMapper.selectById(tbGoodsDemand.getPurchaserId());
+            if (tbPurchaser == null) throw new RuntimeException("服务器繁忙~");
+            //todo:发送短信
 //			smsRetryService.sendSmsMsg(tbPurchaser.getContact());
-			return true;
-		}
-			throw new RuntimeException("抢单报价失败!");
-	}
-	
+            return true;
+        }
+        throw new RuntimeException("抢单报价失败!");
+    }
+
 
 }

+ 8 - 5
sp-service/level-two-server/src/main/java/com/pj/tb_demand_quotation/param/DemandQuotationParam.java

@@ -4,6 +4,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 
 /**
  * @Author Mechrevo
@@ -14,17 +15,19 @@ import javax.validation.constraints.NotBlank;
 public class DemandQuotationParam {
 
     /** 二级市场收购商需求表ID */
-    @NotBlank(message = "goodsDemandId")
+    @NotNull(message = "goodsDemandId")
     private Long goodsDemandId;
-    /** 接单状态,默认传个 1 */
-    @NotBlank(message = "isOrders")
+
     private Integer isOrders;
+
     /** 报价 */
-    @NotBlank(message = "price")
+    @NotNull(message = "price")
     private Double price;
+
     /** 二级市场收购商主键ID */
-    @NotBlank(message = "purchaserId")
+    @NotNull(message = "purchaserId")
     private Long purchaserId;
+
     private String remark;
 
 }