|
|
@@ -1,19 +1,27 @@
|
|
|
package com.uas.platform.b2b.v2.service.impl;
|
|
|
|
|
|
+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.dao.CommonDao;
|
|
|
import com.uas.platform.b2b.model.Enterprise;
|
|
|
import com.uas.platform.b2b.model.EnterpriseBaseInfo;
|
|
|
import com.uas.platform.b2b.model.InvitationRecord;
|
|
|
+import com.uas.platform.b2b.model.User;
|
|
|
import com.uas.platform.b2b.service.EnterpriseService;
|
|
|
import com.uas.platform.b2b.service.InvitationRecordService;
|
|
|
+import com.uas.platform.b2b.service.UserService;
|
|
|
import com.uas.platform.b2b.v2.model.Invitation;
|
|
|
import com.uas.platform.b2b.v2.service.InviteRecordService;
|
|
|
+import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.search.b2b.model.PageParams;
|
|
|
import com.uas.search.b2b.model.SPage;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -33,6 +41,9 @@ public class InviteRecordServiceImpl implements InviteRecordService {
|
|
|
@Autowired
|
|
|
private CommonDao commonDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
/**
|
|
|
* 通过填写的名称检验企业是否已注册
|
|
|
*
|
|
|
@@ -123,4 +134,55 @@ public class InviteRecordServiceImpl implements InviteRecordService {
|
|
|
}
|
|
|
return all;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加合作伙伴
|
|
|
+ *
|
|
|
+ * @param userUU 用户UU
|
|
|
+ * @param enUU 企业UU
|
|
|
+ * @param inviteEnUU 邀请企业的UU
|
|
|
+ * @param inviteUserName 邀请的用户的姓名
|
|
|
+ * @param inviteUserTel 邀请的用户的联系方式
|
|
|
+ * @param app 应用
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ModelMap addPartner(Long userUU, Long enUU, Long inviteEnUU, String inviteUserName, String inviteUserTel, String app) throws Exception {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ PartnershipRecord record = new PartnershipRecord();
|
|
|
+ Enterprise v = enterpriseService.findByEnUU(inviteEnUU);
|
|
|
+ if (null == v) {
|
|
|
+ throw new IllegalOperatorException("添加合作伙伴的企业未注册");
|
|
|
+ }
|
|
|
+ record.setVendName(v.getEnName());
|
|
|
+ record.setVendUID(v.getEnBussinessCode());
|
|
|
+ if (null != v.getAdmin()) {
|
|
|
+ record.setVendUserCode(String.valueOf(v.getAdmin().getUserUU()));
|
|
|
+ record.setVendUserEmail(v.getAdmin().getUserEmail());
|
|
|
+ record.setVendUserName(v.getAdmin().getUserName());
|
|
|
+ record.setVendUserTel(v.getAdmin().getUserTel());
|
|
|
+ }
|
|
|
+ Enterprise c = enterpriseService.findByEnUU(enUU);
|
|
|
+ record.setAppId(app);
|
|
|
+ record.setCustName(c.getEnName());
|
|
|
+ record.setCustUID(c.getEnBussinessCode());
|
|
|
+ record.setCustUserCode(String.valueOf(userUU));
|
|
|
+ User cu = userService.findUserByUserTel(inviteUserTel);
|
|
|
+ record.setCustUserEmail(cu.getUserEmail());
|
|
|
+ record.setCustUserName(cu.getUserName());
|
|
|
+ record.setCustUserTel(cu.getUserTel());
|
|
|
+ if (!StringUtils.isEmpty(inviteUserTel)) {
|
|
|
+ User vu = userService.findUserByUserTel(inviteUserTel);
|
|
|
+ record.setVendUserCode(String.valueOf(vu.getUserUU()));
|
|
|
+ record.setVendUserEmail(vu.getUserEmail());
|
|
|
+ String userName = StringUtils.isEmpty(inviteUserName) ? vu.getUserName() : inviteUserName;
|
|
|
+ record.setVendUserName(userName);
|
|
|
+ record.setVendUserTel(vu.getUserTel());
|
|
|
+ }
|
|
|
+ String result = AccountUtils.addNewRecord(record);
|
|
|
+ JSONObject object = JSON.parseObject(result);
|
|
|
+ map.put("error", object.getString("error"));
|
|
|
+ map.put("success", object.getString("success"));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|