|
|
@@ -7,13 +7,18 @@ import com.uas.platform.b2b.model.Role;
|
|
|
import com.uas.platform.b2b.model.User;
|
|
|
import com.uas.platform.b2b.model.Vendor;
|
|
|
import com.uas.platform.b2b.model.VendorContact;
|
|
|
+import com.uas.platform.b2b.result.ResultCode;
|
|
|
+import com.uas.platform.b2b.result.ResultMap;
|
|
|
import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.OrderRedDotService;
|
|
|
import com.uas.platform.b2b.service.VendorService;
|
|
|
import com.uas.platform.b2b.support.JxlsExcelView;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
+import com.uas.platform.b2b.support.UsageBufferedLogger;
|
|
|
+import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
import com.uas.search.b2b.model.SPage;
|
|
|
import com.uas.search.b2b.model.Sort;
|
|
|
import com.uas.search.b2b.model.Sort.Type;
|
|
|
@@ -25,7 +30,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
@@ -55,26 +59,20 @@ public class VendorController {
|
|
|
@Autowired
|
|
|
private OrderRedDotService redDotService;
|
|
|
|
|
|
+ private final static UsageBufferedLogger LOGGER = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
+
|
|
|
/**
|
|
|
* 获取供应商
|
|
|
*/
|
|
|
@RequestMapping(value= "/info/search", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public SPage<Vendor> getVendors(PageParams params, String keyword) {
|
|
|
- com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, null);
|
|
|
- pageParams.getFilters().put("ve_myenuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- pageParams.getFilters().put("ve_vendswitch", Constant.YES);
|
|
|
- List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("ve_id", false, Type.INT, new Long(1)));
|
|
|
- pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
- return searchService.searchVendorCheckIds(keyword, pageParams);
|
|
|
+ return vendorService.searchVendorCheckIds(keyword, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取服务商
|
|
|
*/
|
|
|
@RequestMapping(value= "/servicer", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public SPage<Vendor> getServicers(PageParams params, String keyword) {
|
|
|
com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, null);
|
|
|
pageParams.getFilters().put("ve_myenuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
@@ -92,7 +90,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/{id}/info", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public Vendor getVendorDetail(@PathVariable Long id) {
|
|
|
return vendorService.findById(id);
|
|
|
}
|
|
|
@@ -101,7 +98,6 @@ public class VendorController {
|
|
|
* 获取客户
|
|
|
*/
|
|
|
@RequestMapping(value = "/customer/info/search", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public SPage<Vendor> getCustomers(PageParams params, String keyword) {
|
|
|
return vendorService.getCustomerInfo(params, keyword);
|
|
|
}
|
|
|
@@ -110,7 +106,6 @@ public class VendorController {
|
|
|
* 获取客户在供应商对应的用户
|
|
|
*/
|
|
|
@RequestMapping(value = "/userInfo/{uu}", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public List<Distribute> getUserInfo(@PathVariable("uu") Long custUu){
|
|
|
return vendorService.findUserInfo(custUu);
|
|
|
}
|
|
|
@@ -119,7 +114,6 @@ public class VendorController {
|
|
|
* 获取当前用户
|
|
|
*/
|
|
|
@RequestMapping(value = "/user", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public User getUser(){
|
|
|
return SystemSession.getUser();
|
|
|
}
|
|
|
@@ -131,7 +125,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/customer/{id}/info", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public Vendor getCustomerDetail(@PathVariable Long id) {
|
|
|
return vendorService.findById(id);
|
|
|
}
|
|
|
@@ -145,6 +138,7 @@ public class VendorController {
|
|
|
public ModelMap exportVendorsPermission() {
|
|
|
return new ModelMap("success", true);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 导出
|
|
|
*
|
|
|
@@ -155,22 +149,17 @@ public class VendorController {
|
|
|
public ModelAndView exportVendors(PageParams params, String keyword) {
|
|
|
params.setCount(SearchConstants.TOP_NUM);
|
|
|
params.setPage(1);
|
|
|
- Map<String, Object> map = new HashMap<String, Object>();
|
|
|
-// PageInfo pageInfo = new PageInfo(1, JxlsExcelView.MAX_SIZE, 0);
|
|
|
-// pageInfo.sorting("myEnUU", Direction.ASC);
|
|
|
-// pageInfo.filter("vendEnUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
map.put("data", getCustomers(params, keyword).getContent());
|
|
|
return new ModelAndView(new JxlsExcelView("classpath:jxls-tpl/Customer", "客户列表"), map);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 供应商个数和客户个数
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/count", method = RequestMethod.GET, headers = "Accept=application/json")
|
|
|
- @ResponseBody
|
|
|
@ResponseStatus(value = HttpStatus.OK)
|
|
|
public ModelMap getTodo() {
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
@@ -186,7 +175,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/savecontact", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
private VendorContact savecontact(@RequestBody String contact) {
|
|
|
VendorContact vendor = JSON.parseObject(contact, VendorContact.class);
|
|
|
return vendorService.saveContact(vendor);
|
|
|
@@ -198,7 +186,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/contacts/{venduu}", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
private List<VendorContact> getContacts(@PathVariable Long venduu) {
|
|
|
return vendorService.getContacts(venduu);
|
|
|
}
|
|
|
@@ -209,7 +196,6 @@ public class VendorController {
|
|
|
* @param id
|
|
|
*/
|
|
|
@RequestMapping(value = "/deleteContact/{id}", method = RequestMethod.DELETE)
|
|
|
- @ResponseBody
|
|
|
private void deleteContact(@PathVariable Long id) {
|
|
|
vendorService.deleteContact(id);
|
|
|
}
|
|
|
@@ -221,7 +207,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/saveCustomerContact", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
private VendorContact saveCustomerContact(@RequestBody String contact) {
|
|
|
VendorContact vendor = JSON.parseObject(contact, VendorContact.class);
|
|
|
return vendorService.saveCustContact(vendor);
|
|
|
@@ -233,7 +218,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/custContacts/{enuu}", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
private List<VendorContact> getCustContacts(@PathVariable Long enuu) {
|
|
|
return vendorService.getCustContacts(enuu);
|
|
|
}
|
|
|
@@ -245,7 +229,6 @@ public class VendorController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/vendorInfo", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public Vendor findByBusinessCode(String businessCode) {
|
|
|
return vendorService.findByBusinessCode(businessCode);
|
|
|
}
|
|
|
@@ -255,7 +238,6 @@ public class VendorController {
|
|
|
* @author wangmh
|
|
|
*/
|
|
|
@RequestMapping(value = "/customer/setRead", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
public void setReadByIds() {
|
|
|
redDotService.setReadByState(OrderType.vendors.name(), Role.SELLER);
|
|
|
}
|
|
|
@@ -265,7 +247,6 @@ public class VendorController {
|
|
|
* @author wangmh
|
|
|
*/
|
|
|
@RequestMapping(value = "/vendor/setRead", method = RequestMethod.POST)
|
|
|
- @ResponseBody
|
|
|
public void setVendorReadByIds() {
|
|
|
redDotService.setReadByState(OrderType.vendors.name(), Role.BUYER);
|
|
|
}
|
|
|
@@ -274,11 +255,42 @@ public class VendorController {
|
|
|
* 将供应商关系同步到管理平台的合作伙伴关系表
|
|
|
*/
|
|
|
@RequestMapping(value = "/synchronize/partnerShipRecord", method = RequestMethod.GET)
|
|
|
- @ResponseBody
|
|
|
public void synchronizeToPartnerShipRecord() {
|
|
|
// 后台同步功能,使用get直接URL访问,暂时设置成手机号码过滤防止被误访问
|
|
|
if (SystemSession.getUser().getUserTel().equals("15671616315") || SystemSession.getUser().getUserTel().equals("18328587849")) {
|
|
|
vendorService.synchronizeToPartnerShipRecord();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 为用户分配客户权限,保存绑定(管理员才能操作)
|
|
|
+ *
|
|
|
+ * @param userUU 用户关系
|
|
|
+ * @param json 前端数据
|
|
|
+ * @return 绑定结果
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/bindVendor/{uu}", method = RequestMethod.POST)
|
|
|
+ public ResultMap bindVendor(@PathVariable("uu") Long userUU, @RequestBody String json) {
|
|
|
+ List<Vendor> ids = FlexJsonUtils.fromJsonArray(json, Vendor.class);
|
|
|
+ boolean result = vendorService.bindVendorToUser(userUU, ids);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("供应商权限", "分配供应商", "userUU: " + userUU + "结果: 分配" + resultInfo);
|
|
|
+ return new ResultMap(result ? ResultCode.OK.code() : ResultCode.ERROR.code());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商权限转移
|
|
|
+ *
|
|
|
+ * @param vendorUU 供应商UU
|
|
|
+ * @param json 前端json数据
|
|
|
+ * @return 绑定结果
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/bindUserToVendor/{uu}", method = RequestMethod.POST)
|
|
|
+ public ResultMap bindUserToVendor(@PathVariable("uu") Long vendorUU, @RequestBody String json) {
|
|
|
+ List<User> users = FlexJsonUtils.fromJsonArray(json, User.class);
|
|
|
+ boolean result = vendorService.transferVendorToUser(vendorUU, users);
|
|
|
+ String resultInfo = result ? "成功" : "失败";
|
|
|
+ LOGGER.log("供应商权限", "转移权限", "供应商UU: " + vendorUU + "结果: 绑定" + resultInfo);
|
|
|
+ return new ResultMap(result ? ResultCode.OK.code() : ResultCode.ERROR.code());
|
|
|
+ }
|
|
|
}
|