|
|
@@ -1,21 +1,27 @@
|
|
|
package com.uas.platform.b2b.controller;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.account.entity.PartnershipRecord;
|
|
|
+import com.uas.account.util.AccountUtils;
|
|
|
import com.uas.platform.b2b.model.AddPartner;
|
|
|
-import com.uas.platform.b2b.model.Vendor;
|
|
|
import com.uas.platform.b2b.service.AddPartnerService;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
-import com.uas.platform.core.model.PageInfo;
|
|
|
+import com.uas.platform.b2b.temporary.model.BasePartnersInfo;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.platform.core.model.Status;
|
|
|
import com.uas.platform.core.web.bind.RequestState;
|
|
|
+import com.uas.search.b2b.model.SPage;
|
|
|
|
|
|
/**
|
|
|
* 添加合作伙伴
|
|
|
@@ -30,73 +36,6 @@ public class AddPartnerController {
|
|
|
@Autowired
|
|
|
private AddPartnerService addPartnerService;
|
|
|
|
|
|
- /**
|
|
|
- * 接收到的请求<br>
|
|
|
- * 企业的名义查看新的消息<br>
|
|
|
- * 全部
|
|
|
- *
|
|
|
- * @param params
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/message", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Page<AddPartner> getAllMessage(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("supplieruu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- return addPartnerService.findBysupplieruu(info, null);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 接收到的请求<br>
|
|
|
- * 企业的名义查看新的消息<br>
|
|
|
- * 待回复
|
|
|
- *
|
|
|
- * @param params
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/message", params = RequestState.TODO, method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Page<AddPartner> getTodoMessage(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("supplieruu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- info.filter("applyStatuscode", Status.NOT_REPLY.value());
|
|
|
- return addPartnerService.findBysupplieruu(info, null);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 接收到的请求<br>
|
|
|
- * 企业的名义查看新的消息<br>
|
|
|
- * 已通过
|
|
|
- *
|
|
|
- * @param params
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/message", params = RequestState.DONE, method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Page<AddPartner> getDoneMessage(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("supplieruu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- info.filter("applyStatuscode", Status.AGREED.value());
|
|
|
- return addPartnerService.findBysupplieruu(info, null);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 接收到的请求<br>
|
|
|
- * 企业的名义查看新的消息<br>
|
|
|
- * 未通过
|
|
|
- *
|
|
|
- * @param params
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/message", params = RequestState.END, method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
- public Page<AddPartner> getMessage(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("supplieruu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- info.filter("applyStatuscode", Status.NOTAGREED.value());
|
|
|
- return addPartnerService.findBysupplieruu(info, null);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 已发出的请求<br>
|
|
|
* 请求者的名义查看个人的发出的请求<br>
|
|
|
@@ -107,11 +46,8 @@ public class AddPartnerController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/request", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public Page<AddPartner> getAllRequest(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("applicantuu", SystemSession.getUser().getUserUU());
|
|
|
- info.filter("clientuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- return addPartnerService.findByApplicantuu(info, null);
|
|
|
+ public SPage<BasePartnersInfo> getAllRequest(PageParams params, String keyword) throws Exception {
|
|
|
+ return addPartnerService.findByBusCodeAndKeyWord(keyword, null, params.getCount(), params.getPage());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -121,15 +57,13 @@ public class AddPartnerController {
|
|
|
*
|
|
|
* @param params
|
|
|
* @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
@RequestMapping(value = "/request", params = RequestState.TODO, method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public Page<AddPartner> getTodoRequest(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("applicantuu", SystemSession.getUser().getUserUU());
|
|
|
- info.filter("clientuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- info.filter("applyStatuscode", Status.NOT_REPLY.value());
|
|
|
- return addPartnerService.findByApplicantuu(info, null);
|
|
|
+ public SPage<BasePartnersInfo> getTodoRequest(PageParams params, String keyword) throws Exception {
|
|
|
+ return addPartnerService.findByBusCodeAndKeyWord(keyword, Status.UNAUDIT.value(), params.getCount(),
|
|
|
+ params.getPage());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -142,12 +76,9 @@ public class AddPartnerController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/request", params = RequestState.DONE, method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public Page<AddPartner> getDoneRequest(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("applicantuu", SystemSession.getUser().getUserUU());
|
|
|
- info.filter("clientuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- info.filter("applyStatuscode", Status.AGREED.value());
|
|
|
- return addPartnerService.findByApplicantuu(info, null);
|
|
|
+ public SPage<BasePartnersInfo> getDoneRequest(PageParams params, String keyword) throws Exception {
|
|
|
+ return addPartnerService.findByBusCodeAndKeyWord(keyword, Status.ENABLED.value(), params.getCount(),
|
|
|
+ params.getPage());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -160,12 +91,9 @@ public class AddPartnerController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/request", params = RequestState.END, method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public Page<AddPartner> getEndRequest(PageParams params) {
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- info.filter("applicantuu", SystemSession.getUser().getUserUU());
|
|
|
- info.filter("clientuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- info.filter("applyStatuscode", Status.NOTAGREED.value());
|
|
|
- return addPartnerService.findByApplicantuu(info, null);
|
|
|
+ public SPage<BasePartnersInfo> getEndRequest(PageParams params, String keyword) throws Exception {
|
|
|
+ return addPartnerService.findByBusCodeAndKeyWord(keyword, Status.UNAPPLY.value(), params.getCount(),
|
|
|
+ params.getPage());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -173,11 +101,32 @@ public class AddPartnerController {
|
|
|
*
|
|
|
* @param uu
|
|
|
* @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- @RequestMapping(value = "/request/{uu}", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/request/nameAndBusCode", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public AddPartner addNewPartner(@PathVariable("uu") Long uu) {
|
|
|
- return addPartnerService.addNewPartner(uu);
|
|
|
+ public ResponseEntity<ModelMap> addNewPartner(String name, String businessCode)
|
|
|
+ throws Exception {
|
|
|
+ PartnershipRecord newrecord = new PartnershipRecord();
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ if (businessCode.equals(SystemSession.getUser().getEnterprise().getEnBussinessCode())) {
|
|
|
+ map.put("error", "不能添加自己为合作伙伴");
|
|
|
+ } else {
|
|
|
+ newrecord.setVendName(name);
|
|
|
+ newrecord.setVendUID(businessCode);
|
|
|
+ newrecord.setAppId("b2b");
|
|
|
+ newrecord.setCustName(SystemSession.getUser().getEnterprise().getEnName());
|
|
|
+ newrecord.setCustUID(SystemSession.getUser().getEnterprise().getEnBussinessCode());
|
|
|
+ newrecord.setCustUserCode(String.valueOf(SystemSession.getUser().getUserUU()));
|
|
|
+ newrecord.setCustUserEmail(SystemSession.getUser().getUserEmail());
|
|
|
+ newrecord.setCustUserName(SystemSession.getUser().getUserName());
|
|
|
+ newrecord.setCustUserTel(SystemSession.getUser().getUserTel());
|
|
|
+ String result = AccountUtils.addNewRecord(newrecord);
|
|
|
+ JSONObject object = JSON.parseObject(result);
|
|
|
+ map.put("error", object.getString("error"));
|
|
|
+ map.put("success", object.getString("success"));
|
|
|
+ }
|
|
|
+ return new ResponseEntity<ModelMap>(map, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -194,11 +143,16 @@ public class AddPartnerController {
|
|
|
|
|
|
/**
|
|
|
* 企业同意申请
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
@RequestMapping(value = "/agree/{id}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public AddPartner agreeRequest(@PathVariable("id") Long id) {
|
|
|
- return addPartnerService.agreeRequest(id);
|
|
|
+ public ModelMap agreeRequest(@PathVariable("id") Long id) throws Exception {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ String result = AccountUtils.acceptRequest(id, SystemSession.getUser().getUserTel(), "b2b");
|
|
|
+ map.put("result", result);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -207,11 +161,15 @@ public class AddPartnerController {
|
|
|
* @param id
|
|
|
* @param reason
|
|
|
* @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
@RequestMapping(value = "/refuse/{id}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public AddPartner refuseRequest(@PathVariable("id") Long id, String reason) {
|
|
|
- return addPartnerService.refuseRequest(id, reason);
|
|
|
+ public ModelMap refuseRequest(@PathVariable("id") Long id, String reason) throws Exception {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ String result = AccountUtils.rejectRequest(id, reason, SystemSession.getUser().getUserTel(), "b2b");
|
|
|
+ map.put("result", result);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -220,10 +178,10 @@ public class AddPartnerController {
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/addSupplier/{id}", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/addSupplier/{businessCode}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public Vendor addSupplier(@PathVariable("id") Long id) {
|
|
|
- return addPartnerService.addSupplier(id);
|
|
|
+ public ModelMap addSupplier(@PathVariable("businessCode") String businessCode) {
|
|
|
+ return addPartnerService.addSupplier(businessCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -232,9 +190,9 @@ public class AddPartnerController {
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = "/addCust/{id}", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/addCust/{businessCode}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public Vendor addCust(@PathVariable("id") Long id) {
|
|
|
- return addPartnerService.addCust(id);
|
|
|
+ public ModelMap addCust(@PathVariable("businessCode") String businessCode) {
|
|
|
+ return addPartnerService.addCust(businessCode);
|
|
|
}
|
|
|
}
|