Commit e308c691 by huangZW

111

parent e1e57c2e
...@@ -23,7 +23,11 @@ public enum AppPageType { ...@@ -23,7 +23,11 @@ public enum AppPageType {
//任务列表 //任务列表
TASK_LIST(9, "hbapp_task_list"), TASK_LIST(9, "hbapp_task_list"),
//商品详情 //商品详情
GOOD_DETAIL(10, "hbapp_commodity_detail"); GOOD_DETAIL(10, "hbapp_commodity_detail"),
//我的关联记录
MY_RELATED_RECORD(11, "store_relate_my_record_list"),
//门店关联记录
STORE_RELATED_RECORD(12, "store_relate_store_record_list");
AppPageType(int type, String desc){ AppPageType(int type, String desc){
this.code = type; this.code = type;
......
...@@ -34,6 +34,8 @@ public interface StaffDepartmentRelatedApiService { ...@@ -34,6 +34,8 @@ public interface StaffDepartmentRelatedApiService {
//发送消息,单人发送 //发送消息,单人发送
boolean sendSingleMessage(String clerkId,String title,String content,String pageUrl); boolean sendSingleMessage(String clerkId,String title,String content,String pageUrl);
//发送消息,带审核理由
public boolean sendAuditMessage(String clerkId, String title,String content, String pageUrl,int auditStatus, String auditReason);
List<StaffDepartmentRelatedDTO> listByStaffIds(List<String> staffIds); List<StaffDepartmentRelatedDTO> listByStaffIds(List<String> staffIds);
......
...@@ -19,6 +19,8 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -19,6 +19,8 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
...@@ -88,7 +90,8 @@ public class AuditApiServiceImpl implements AuditApiService{ ...@@ -88,7 +90,8 @@ public class AuditApiServiceImpl implements AuditApiService{
private SyncHaobanToGicServiceApi syncHaobanToGicServiceApi; private SyncHaobanToGicServiceApi syncHaobanToGicServiceApi;
@Autowired @Autowired
private StaffClerkRelationApiService staffClerkRelationApiService; private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private ClerkService clerkService;
@Override @Override
public Page<AuditDTO> page(Integer auditType, String search,String wxEnterpriseId, public Page<AuditDTO> page(Integer auditType, String search,String wxEnterpriseId,
...@@ -181,6 +184,16 @@ public class AuditApiServiceImpl implements AuditApiService{ ...@@ -181,6 +184,16 @@ public class AuditApiServiceImpl implements AuditApiService{
if(org.apache.commons.lang.StringUtils.isNotBlank(batchId)){ if(org.apache.commons.lang.StringUtils.isNotBlank(batchId)){
insertBatchLog( batchId,AuditRsultType.success.getCode(), tab); insertBatchLog( batchId,AuditRsultType.success.getCode(), tab);
} }
//TODO huang 发送申请人,我的记录页
ClerkDTO clerk = clerkService.getclerkById(obj.getClerkId());
String messageTitle = "门店账号申请";
String messageContent = clerk.getClerkName()+"申请关联导购code("+obj.getClerkCode()+")";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", clerk.getStoreId());
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MY_RELATED_RECORD.getCode(), data);
staffDepartmentRelatedApiService.sendAuditMessage(obj.getClerkId(), messageTitle, messageContent, pageUrl, 1, "");
}else if(auditType == AuditType.CLERK_ADD.getCode()){ }else if(auditType == AuditType.CLERK_ADD.getCode()){
//门店导购新增 //门店导购新增
String oldValue = tab.getOldValue(); String oldValue = tab.getOldValue();
......
...@@ -196,7 +196,54 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -196,7 +196,54 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
logger.info("发送===============》{}",b); logger.info("发送===============》{}",b);
return b; return b;
} }
@Override
public boolean sendAuditMessage(String clerkId, String title,
String content, String pageUrl,int auditStatus, String auditReason) {
Map<String,String> map = getWxUserIdByClerkId(clerkId);
String wxUserId = map.get("wxUserId");
String corpId = map.get("corpId");
String name = map.get("clerkName");
if(jodd.util.StringUtil.isEmpty(wxUserId)){
logger.info("wxUserId不存在============clerkId={}",clerkId);
return false;
}
if(content.length()>30){
content = content.substring(0, 26);
content = content+"...";
}
//先发送下,试试
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
List<ItemDTO> items = new ArrayList();;
ItemDTO dto1 = new ItemDTO();
ItemDTO dto2 = new ItemDTO();
ItemDTO dto3 = new ItemDTO();
ItemDTO dto4 = new ItemDTO();
dto1.setKey("接收人");
dto1.setValue(name);
dto2.setKey("接收事件");
dto2.setValue(content);
dto3.setKey("结果");
dto3.setValue(auditStatus == 1?"已同意":"已拒绝");
dto4.setKey("理由");
dto4.setValue(auditReason);
items.add(dto1);
items.add(dto2);
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
messageDTO.setTitle(title);
messageDTO.setItems(items);
logger.info("发送参数为corpId============:{},suitId============:{},messageDTO============:{},",corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO));
boolean b = qywxSuiteApiService.sendMessage(corpId,config.getWxSuiteid(), messageDTO);
logger.info("发送===============》{}",b);
return b;
}
@Override @Override
public String getPageUrl(int type, String data) { public String getPageUrl(int type, String data) {
String baseUrl = "/pages/route/index"; String baseUrl = "/pages/route/index";
......
...@@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.PageResult2; import com.gic.haoban.base.api.common.PageResult2;
...@@ -23,10 +25,12 @@ import com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi; ...@@ -23,10 +25,12 @@ import com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi;
import com.gic.haoban.manage.api.dto.AuditDTO; import com.gic.haoban.manage.api.dto.AuditDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.enums.AuditType; import com.gic.haoban.manage.api.enums.AuditType;
import com.gic.haoban.manage.api.service.AuditApiService; import com.gic.haoban.manage.api.service.AuditApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService; import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.AuditVO; import com.gic.haoban.manage.web.vo.AuditVO;
...@@ -47,6 +51,13 @@ public class AuditController extends WebBaseController{ ...@@ -47,6 +51,13 @@ public class AuditController extends WebBaseController{
@Autowired @Autowired
private SyncHaobanToGicServiceApi syncHaobanToGicServiceApi; private SyncHaobanToGicServiceApi syncHaobanToGicServiceApi;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private ClerkService clerkService;
//关联记录列表 //关联记录列表
@RequestMapping("clerk-apply-list") @RequestMapping("clerk-apply-list")
public HaobanResponse staffStoreList(String staffId,Integer auditType,Integer auditStatus,String wxEnterpriseId,BasePageInfo pageInfo){ public HaobanResponse staffStoreList(String staffId,Integer auditType,Integer auditStatus,String wxEnterpriseId,BasePageInfo pageInfo){
...@@ -123,6 +134,48 @@ public class AuditController extends WebBaseController{ ...@@ -123,6 +134,48 @@ public class AuditController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_1,pageResult2); return resultResponse(HaoBanErrCode.ERR_1,pageResult2);
} }
//导购绑定,,审核记录,,消息发送
public void sendClerkBind(String clerkId,String clerkCode,int auditStatus,String auditReason){
//TODO huang 发送申请人,我的记录页
ClerkDTO clerk = clerkService.getclerkById(clerkId);
String messageTitle = "门店账号申请";
String messageContent = clerk.getClerkName()+"申请关联导购code("+clerkCode+")";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", clerk.getStoreId());
String data = jsonObject.toJSONString();
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.MY_RELATED_RECORD.getCode(), data);
staffDepartmentRelatedApiService.sendAuditMessage(clerkId, messageTitle, messageContent, pageUrl, auditStatus, auditReason);
}
//导购新增,,审核记录,,消息发送
public void sendClerkAdd (String clerkId,String clerkCode,int auditStatus,String auditReason){
//TODO huang 发送店长,门店关联记录列表
ClerkDTO clerk = clerkService.getclerkById(clerkId);
String messageTitle = "门店导购变更";
String messageContent ="新增导购:"+ clerk.getClerkName()+"("+clerkCode+")";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", clerk.getStoreId());
String data = jsonObject.toJSONString();
ClerkDTO gicClerk = clerkService.getClerkLeaderByStoreId(clerk.getStoreId());
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.STORE_RELATED_RECORD.getCode(), data);
staffDepartmentRelatedApiService.sendAuditMessage(gicClerk.getClerkId(), messageTitle, messageContent, pageUrl,auditStatus,"");
}
//导购删除,,审核记录,,消息发送
public void sendClerkDel (String clerkId,String clerkCode,int auditStatus,String auditReason){
//TODO huang 发送店长,门店关联记录列表
ClerkDTO clerk = clerkService.getclerkById(clerkId);
String messageTitle = "门店导购变更";
String messageContent ="删除导购:"+ clerk.getClerkName()+"("+clerkCode+")";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", clerk.getStoreId());
String data = jsonObject.toJSONString();
ClerkDTO gicClerk = clerkService.getClerkLeaderByStoreId(clerk.getStoreId());
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.STORE_RELATED_RECORD.getCode(), data);
staffDepartmentRelatedApiService.sendAuditMessage(gicClerk.getClerkId(), messageTitle, messageContent, pageUrl,auditStatus,"");
}
//审核,1同意,2拒绝,3取消审核 //审核,1同意,2拒绝,3取消审核
@RequestMapping("clerk-audit") @RequestMapping("clerk-audit")
public HaobanResponse clerkAudit(String auditId,String auditReason,Integer auditStatus,String wxEnterpriseId,String staffId){ public HaobanResponse clerkAudit(String auditId,String auditReason,Integer auditStatus,String wxEnterpriseId,String staffId){
...@@ -142,25 +195,19 @@ public class AuditController extends WebBaseController{ ...@@ -142,25 +195,19 @@ public class AuditController extends WebBaseController{
if(staff != null){ if(staff != null){
audit.setAuditName(staff.getStaffName()); audit.setAuditName(staff.getStaffName());
} }
String oldValue = audit.getOldValue();
JSONObject json = JSON.parseObject(oldValue);
String clerkCode = json.get("clerkCode")==null?"":json.get("clerkCode").toString();
String enterpriseId = json.getString("enterpriseId")==null?"":json.get("enterpriseId").toString();
String clerkId = json.getString("clerkId")==null?"":json.get("clerkId").toString();
String wxUserId = json.getString("wxUserId")==null?"":json.get("wxUserId").toString();
Integer sex = json.getInteger("sex")==null?0:json.getInteger("sex");
String phoneNumber = json.getString("phoneNumber")==null?"":json.get("phoneNumber").toString();
String nationCode = json.getString("nationCode")==null?"":json.get("nationCode").toString();
String storeId = audit.getCommitStoreId();
if(auditStatus == 1){ if(auditStatus == 1){
//审核同意 //审核同意
String oldValue = audit.getOldValue();
String clerkCode = "";
String enterpriseId = "";
String clerkId = "";
String wxUserId = "";
String phoneNumber = "";
String nationCode = "";
Integer sex = null;
JSONObject json = JSON.parseObject(oldValue);
clerkCode = json.getString("clerkCode");
enterpriseId = json.getString("enterpriseId");
clerkId = json.getString("clerkId");
wxUserId = json.getString("wxUserId");
sex = json.getInteger("sex");
phoneNumber = json.getString("phoneNumber");
nationCode = json.getString("nationCode");
String storeId = audit.getCommitStoreId();
if(audit.getAuditType() == AuditType.CLERK_BIND.getCode()){ if(audit.getAuditType() == AuditType.CLERK_BIND.getCode()){
//导购绑定 //导购绑定
StaffClerkRelationDTO staffClerkRelation = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode,enterpriseId); StaffClerkRelationDTO staffClerkRelation = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode,enterpriseId);
...@@ -177,6 +224,8 @@ public class AuditController extends WebBaseController{ ...@@ -177,6 +224,8 @@ public class AuditController extends WebBaseController{
staffClerkRelationApiService.insert(staffClerkRelation); staffClerkRelationApiService.insert(staffClerkRelation);
audit.setAuditStatus(1); audit.setAuditStatus(1);
} }
//发送消息
this.sendClerkBind(clerkId, clerkCode, auditStatus, auditReason);
} }
if(audit.getAuditType() == AuditType.CLERK_ADD.getCode()){ if(audit.getAuditType() == AuditType.CLERK_ADD.getCode()){
//导购新增 //导购新增
...@@ -185,16 +234,28 @@ public class AuditController extends WebBaseController{ ...@@ -185,16 +234,28 @@ public class AuditController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_10010); return resultResponse(HaoBanErrCode.ERR_10010);
} }
audit.setAuditStatus(1); audit.setAuditStatus(1);
this.sendClerkAdd(clerkId, clerkCode, auditStatus, auditReason);
} }
if(audit.getAuditType() == AuditType.CLERK_DEL.getCode()){ if(audit.getAuditType() == AuditType.CLERK_DEL.getCode()){
//导购删除 //导购删除
syncHaobanToGicServiceApi.delGicClerk(clerkId); syncHaobanToGicServiceApi.delGicClerk(clerkId);
audit.setAuditStatus(1); audit.setAuditStatus(1);
this.sendClerkDel(clerkId, clerkCode, auditStatus, auditReason);
} }
}else if(auditStatus == 2){ }else if(auditStatus == 2){
//审核拒绝 //审核拒绝
audit.setAuditReason(auditReason); audit.setAuditReason(auditReason);
audit.setAuditStatus(2); audit.setAuditStatus(2);
if(audit.getAuditType() == AuditType.CLERK_BIND.getCode()){
//发送消息
this.sendClerkBind(clerkId, clerkCode, auditStatus, auditReason);
}else if (audit.getAuditType() == AuditType.CLERK_ADD.getCode()){
this.sendClerkAdd(clerkId, clerkCode, auditStatus, auditReason);
}else if (audit.getAuditType() == AuditType.CLERK_DEL.getCode()){
this.sendClerkDel(clerkId, clerkCode, auditStatus, auditReason);
}
}else if(auditStatus == 3){ }else if(auditStatus == 3){
//取消审核 //取消审核
audit.setAuditStatus(3); audit.setAuditStatus(3);
......
...@@ -45,6 +45,7 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; ...@@ -45,6 +45,7 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO; import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.service.AuditApiService; import com.gic.haoban.manage.api.service.AuditApiService;
import com.gic.haoban.manage.api.service.AuditSettingApiService; import com.gic.haoban.manage.api.service.AuditSettingApiService;
import com.gic.haoban.manage.api.service.BindApiService; import com.gic.haoban.manage.api.service.BindApiService;
...@@ -608,6 +609,17 @@ public class ClerkController extends WebBaseController{ ...@@ -608,6 +609,17 @@ public class ClerkController extends WebBaseController{
audit.setCommitTime(new Date()); audit.setCommitTime(new Date());
audit.setAuditType(2); audit.setAuditType(2);
auditApiService.insert(audit); auditApiService.insert(audit);
//TODO huang 发送店长,门店关联记录列表
String messageTitle = "门店账号申请";
String messageContent = clerk.getClerkName()+"申请关联导购code("+clerkCode+")";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", clerk.getStoreId());
String data = jsonObject.toJSONString();
ClerkDTO gicClerk = clerkService.getClerkLeaderByStoreId(clerk.getStoreId());
String pageUrl = staffDepartmentRelatedApiService.getPageUrl(AppPageType.STORE_RELATED_RECORD.getCode(), data);
staffDepartmentRelatedApiService.sendSingleMessage(gicClerk.getClerkId(), messageTitle, messageContent, pageUrl);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
} }
...@@ -680,9 +692,12 @@ public class ClerkController extends WebBaseController{ ...@@ -680,9 +692,12 @@ public class ClerkController extends WebBaseController{
for (ClerkListDTO clerkListDTO : list) { for (ClerkListDTO clerkListDTO : list) {
BindClerkVO vo = EntityUtil.changeEntityByJSON(BindClerkVO.class, clerkListDTO); BindClerkVO vo = EntityUtil.changeEntityByJSON(BindClerkVO.class, clerkListDTO);
if(bindCodeMap.keySet().contains(clerkListDTO.getClerkCode())){ if(bindCodeMap.keySet().contains(clerkListDTO.getClerkCode())){
vo.setStaffId(bindCodeMap.get(clerkListDTO.getClerkCode()).getStaffId()); String staffId = bindCodeMap.get(clerkListDTO.getClerkCode()).getStaffId();
StaffDTO staffDTO = staffApiService.selectById(staffId);
vo.setStaffId(staffId);
vo.setNationCode(clerkListDTO.getNationcode()); vo.setNationCode(clerkListDTO.getNationcode());
vo.setPhoneNumber(clerkListDTO.getPhoneNumber()); vo.setPhoneNumber(clerkListDTO.getPhoneNumber());
vo.setStaffName(staffDTO == null?"":staffDTO.getStaffName());
bindList.add(vo); bindList.add(vo);
}else{ }else{
unBindList.add(vo); unBindList.add(vo);
......
...@@ -10,6 +10,8 @@ public class BindClerkVO implements Serializable{ ...@@ -10,6 +10,8 @@ public class BindClerkVO implements Serializable{
private String clerkName; private String clerkName;
private String staffName;
private String staffId; private String staffId;
private String clerkCode; private String clerkCode;
...@@ -18,6 +20,14 @@ public class BindClerkVO implements Serializable{ ...@@ -18,6 +20,14 @@ public class BindClerkVO implements Serializable{
private String phoneNumber; private String phoneNumber;
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getNationCode() { public String getNationCode() {
return nationCode; return nationCode;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment