|
|
@@ -1,11 +1,17 @@
|
|
|
package com.uas.platform.b2b.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.uas.platform.b2b.model.Enterprise;
|
|
|
+import com.uas.platform.b2b.core.util.ContextUtils;
|
|
|
+import com.uas.platform.b2b.model.EnterpriseBaseInfo;
|
|
|
import com.uas.platform.b2b.model.InvitationRecord;
|
|
|
import com.uas.platform.b2b.search.SearchService;
|
|
|
import com.uas.platform.b2b.service.InvitationRecordService;
|
|
|
+import com.uas.platform.b2b.support.SysConf;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
+import com.uas.platform.b2b.support.UsageBufferedLogger;
|
|
|
+import com.uas.platform.b2b.v2.service.InviteRecordService;
|
|
|
+import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
+import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
import com.uas.search.b2b.model.SPage;
|
|
|
@@ -19,7 +25,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@@ -32,6 +40,11 @@ public class InvitationRecordController {
|
|
|
@Autowired
|
|
|
private SearchService searchService;
|
|
|
|
|
|
+ private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InviteRecordService inviteRecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 邀请开通平台
|
|
|
*
|
|
|
@@ -41,6 +54,7 @@ public class InvitationRecordController {
|
|
|
@RequestMapping(value = "/invite", method = RequestMethod.POST)
|
|
|
private ModelMap invite(String formStore) {
|
|
|
InvitationRecord record = JSONObject.parseObject(formStore, InvitationRecord.class);
|
|
|
+ logger.log("邀请注册", "增加邀请注册信息", record.getVendname());
|
|
|
return invitationRecordService.invite(record);
|
|
|
}
|
|
|
|
|
|
@@ -52,6 +66,7 @@ public class InvitationRecordController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/reInvite/{id}", method = RequestMethod.POST)
|
|
|
private ModelMap reInvite(@PathVariable Long id) {
|
|
|
+ logger.log("邀请注册", "再次邀请", "关联id:" + id);
|
|
|
return invitationRecordService.reInvite(id);
|
|
|
}
|
|
|
|
|
|
@@ -63,6 +78,7 @@ public class InvitationRecordController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/record/{id}", method = RequestMethod.GET)
|
|
|
private InvitationRecord getRecordById(@PathVariable Long id) {
|
|
|
+ logger.log("邀请注册", "查询邀请记录", "关联id:" + id);
|
|
|
return invitationRecordService.getRecordById(id);
|
|
|
}
|
|
|
|
|
|
@@ -74,11 +90,12 @@ public class InvitationRecordController {
|
|
|
@RequestMapping(value = "/records", method = RequestMethod.GET)
|
|
|
private SPage<InvitationRecord> getRecords(PageParams params, String keyword) {
|
|
|
com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, null);
|
|
|
- pageParams.getFilters().put("in_enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+// pageParams.getFilters().put("in_enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
pageParams.getFilters().put("in_useruu", SystemSession.getUser().getUserUU());
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
sortList.add(new Sort("in_date", false, Type.LONG, new Long(1)));
|
|
|
pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ logger.log("邀请注册", "查询邀请记录(个人)");
|
|
|
return invitationRecordService.getRecords(pageParams, keyword);
|
|
|
}
|
|
|
|
|
|
@@ -94,6 +111,7 @@ public class InvitationRecordController {
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
sortList.add(new Sort("in_date", false, Type.LONG, new Long(1)));
|
|
|
pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ logger.log("邀请注册", "查询邀请记录(企业)");
|
|
|
return invitationRecordService.getRecords(pageParams, keyword);
|
|
|
}
|
|
|
|
|
|
@@ -114,6 +132,7 @@ public class InvitationRecordController {
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
sortList.add(new Sort("in_date", false, Type.LONG, new Long(1)));
|
|
|
pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ logger.log("邀请注册", "查询邀请记录(企业)--已激活");
|
|
|
return invitationRecordService.getRecords(pageParams, keyword);
|
|
|
}
|
|
|
|
|
|
@@ -124,13 +143,43 @@ public class InvitationRecordController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/enterpriseList/{name}", method = RequestMethod.GET)
|
|
|
- private List<Enterprise> getEnterpriseListByName(@PathVariable String name) {
|
|
|
+ private List<EnterpriseBaseInfo> getEnterpriseListByName(@PathVariable String name) {
|
|
|
return invitationRecordService.findByName(name);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/setenterprise/{uu}", method = RequestMethod.POST)
|
|
|
- private ModelMap setenterprise(@PathVariable Long uu) {
|
|
|
- return null;
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 获取邀请链接接口
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/inviteUrl", method = RequestMethod.GET)
|
|
|
+ private ModelMap setenterprise() {
|
|
|
+ String url = ContextUtils.getBean(SysConf.class).getRegisterUrl();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ url = url + "?inviteUserCode=" + SystemSession.getUser().getUserUU() + "&inviteuid="
|
|
|
+ + SystemSession.getUser().getEnterprise().getEnBussinessCode() + "&invitationTime=" + sdf.format(new Date()) + "&source=B2B";
|
|
|
+ logger.log("邀请注册", "获取邀请链接", url);
|
|
|
+ return new ModelMap("url", url);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 邀请注册如果已注册增加添加合作伙伴接口
|
|
|
+ *
|
|
|
+ * @param inviteEnUU 被邀请的企业UU
|
|
|
+ * @param inviteUserName 被邀请的用户姓名
|
|
|
+ * @param inviteUserTel 被邀请的用户联系方式
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/addPart", method = RequestMethod.POST)
|
|
|
+ private ModelMap addPartner(Long inviteEnUU, String inviteUserName, String inviteUserTel) throws Exception {
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ Long userUU = SystemSession.getUser().getUserUU();
|
|
|
+ String app = "B2B";
|
|
|
+ if (enUU.equals(inviteEnUU)) {
|
|
|
+ throw new IllegalOperatorException("不能添加自己企业为合作伙伴");
|
|
|
+ }
|
|
|
+ logger.log("邀请注册", "添加合作伙伴", "添加企业UU:" + inviteEnUU + ",用户:" + inviteUserName);
|
|
|
+ return inviteRecordService.addPartner(userUU, enUU, inviteEnUU, inviteUserName, inviteUserTel, app);
|
|
|
+ }
|
|
|
}
|