Commit e28e43a0 by songyinghui

Merge remote-tracking branch 'origin/master' into feature-0524-home-change

parents 17137c74 f3f69e52
package com.gic.haoban.manage.api.dto.qdto;
import java.io.Serializable;
import java.util.Date;
/**
* Created By MBG-GUI-EXTENSION https://github.com/spawpaw/mybatis-generator-gui-extension
* Description:
* 好办消息通知
*
* @author fdh
*/
public class NoticeMessageQDTO implements Serializable {
/**
*
*/
private Long noticeMessageId;
/**
* 企业id
*/
private String enterpriseId;
/**
* 门店id
*/
private String storeId;
/**
* 导购id
*/
private String clerkId;
/**
* 类别 0客户相关、1任务相关、2活动相关、3其他
*/
private Integer categoryType;
/**
* 消息类型
*/
private Integer messageType;
private String templateCode;
/**
* 标题
*/
private String title;
/**
* 描述
*/
private String description;
/**
* 关联的具体业务消息id
*/
private String relationId;
/**
* 消息带的参数信息
*/
private String messageContent;
/**
* 0 未读 1已读
*/
private Integer readFlag;
/**
* 状态 0删除 1正常
*/
private Integer deleteFlag;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
*/
private static final long serialVersionUID = 1L;
public String getTemplateCode() {
return templateCode;
}
public void setTemplateCode(String templateCode) {
this.templateCode = templateCode;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.notice_message_id
*
* @return the value of tab_haoban_notice_message.notice_message_id
*/
public Long getNoticeMessageId() {
return noticeMessageId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.notice_message_id
*
* @param noticeMessageId the value for tab_haoban_notice_message.notice_message_id
*/
public void setNoticeMessageId(Long noticeMessageId) {
this.noticeMessageId = noticeMessageId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.enterprise_id
*
* @return the value of tab_haoban_notice_message.enterprise_id
*/
public String getEnterpriseId() {
return enterpriseId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.enterprise_id
*
* @param enterpriseId the value for tab_haoban_notice_message.enterprise_id
*/
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.store_id
*
* @return the value of tab_haoban_notice_message.store_id
*/
public String getStoreId() {
return storeId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.store_id
*
* @param storeId the value for tab_haoban_notice_message.store_id
*/
public void setStoreId(String storeId) {
this.storeId = storeId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.clerk_id
*
* @return the value of tab_haoban_notice_message.clerk_id
*/
public String getClerkId() {
return clerkId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.clerk_id
*
* @param clerkId the value for tab_haoban_notice_message.clerk_id
*/
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.category_type
*
* @return the value of tab_haoban_notice_message.category_type
*/
public Integer getCategoryType() {
return categoryType;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.category_type
*
* @param categoryType the value for tab_haoban_notice_message.category_type
*/
public void setCategoryType(Integer categoryType) {
this.categoryType = categoryType;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.message_type
*
* @return the value of tab_haoban_notice_message.message_type
*/
public Integer getMessageType() {
return messageType;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.message_type
*
* @param messageType the value for tab_haoban_notice_message.message_type
*/
public void setMessageType(Integer messageType) {
this.messageType = messageType;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.title
*
* @return the value of tab_haoban_notice_message.title
*/
public String getTitle() {
return title;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.title
*
* @param title the value for tab_haoban_notice_message.title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.description
*
* @return the value of tab_haoban_notice_message.description
*/
public String getDescription() {
return description;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.description
*
* @param description the value for tab_haoban_notice_message.description
*/
public void setDescription(String description) {
this.description = description;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.relation_id
*
* @return the value of tab_haoban_notice_message.relation_id
*/
public String getRelationId() {
return relationId;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.relation_id
*
* @param relationId the value for tab_haoban_notice_message.relation_id
*/
public void setRelationId(String relationId) {
this.relationId = relationId;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.message_content
*
* @return the value of tab_haoban_notice_message.message_content
*/
public String getMessageContent() {
return messageContent;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.message_content
*
* @param messageContent the value for tab_haoban_notice_message.message_content
*/
public void setMessageContent(String messageContent) {
this.messageContent = messageContent;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.read_flag
*
* @return the value of tab_haoban_notice_message.read_flag
*/
public Integer getReadFlag() {
return readFlag;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.read_flag
*
* @param readFlag the value for tab_haoban_notice_message.read_flag
*/
public void setReadFlag(Integer readFlag) {
this.readFlag = readFlag;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.delete_flag
*
* @return the value of tab_haoban_notice_message.delete_flag
*/
public Integer getDeleteFlag() {
return deleteFlag;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.delete_flag
*
* @param deleteFlag the value for tab_haoban_notice_message.delete_flag
*/
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.create_time
*
* @return the value of tab_haoban_notice_message.create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.create_time
*
* @param createTime the value for tab_haoban_notice_message.create_time
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* This method returns the value of the database column tab_haoban_notice_message.update_time
*
* @return the value of tab_haoban_notice_message.update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* This method sets the value of the database column tab_haoban_notice_message.update_time
*
* @param updateTime the value for tab_haoban_notice_message.update_time
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
......@@ -3,109 +3,127 @@ package com.gic.haoban.manage.api.enums;
/**
* Created by hua on 2021/12/17.
*/
@Deprecated
public enum NoticeMessageTypeEnum {
ACTIVITY_START(1001, "活动开始通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_start", "/pages/route/index?pageType=", "hbapp_activity_detail"),
ACTIVITY_NEW(1002, "活动上新通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_new", "/pages/route/index?pageType=", "hbapp_activity_detail"),
ACTIVITY_DEL(1003, "活动删除通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_del", "/pages/route/index", ""),
ACTIVITY_OFFLINE(1004, "活动下线通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_offline", "/pages/route/index?pageType=", "hbapp_activity_ranking"),
ACTIVITY_END(1005, "活动结束通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_end", "/pages/route/index?pageType=", "hbapp_activity_ranking"),
ACTIVITY_RANK(1006, "活动排名通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_rank", "/pages/route/index?pageType=", "hbapp_activity_ranking"),
ACTIVITY_AWARD(1007, "活动奖励通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_award", "/pages/route/index?pageType=", "hbapp_activity_ranking"),
ACTIVITY_START(1001, "活动开始通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_start", "/pages/route/index?pageType=", "hbapp_activity_detail", "activityStart", "haobanNotice"),
ACTIVITY_NEW(1002, "活动上新通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_new", "/pages/route/index?pageType=", "hbapp_activity_detail", "activityNew", "haobanNotice"),
ACTIVITY_DEL(1003, "活动删除通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_del", "/pages/route/index", "", "activityDelete", "haobanNotice"),
ACTIVITY_OFFLINE(1004, "活动下线通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_offline", "/pages/route/index?pageType=", "hbapp_activity_ranking", "activityDown", "haobanNotice"),
ACTIVITY_END(1005, "活动结束通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_end", "/pages/route/index?pageType=", "hbapp_activity_ranking", "activityEnd", "haobanNotice"),
ACTIVITY_RANK(1006, "活动排名通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_rank", "/pages/route/index?pageType=", "hbapp_activity_ranking", "activityRank", "haobanNotice"),
ACTIVITY_AWARD(1007, "活动奖励通知", NoticeMessageCategoryTypeEnum.ACTIVITY.getType(), "activity_award", "/pages/route/index?pageType=", "hbapp_activity_ranking", "activityReward", "haobanNotice"),
TEL_TASK_CREATE(2001, "话务任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_create", "/pages/route/index?pageType=", "hbapp_task_list_new"),
TEL_TASK_OVERDUE(2002, "话务任务逾期推送", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_overdue", "/pages/route/index?pageType=", "hbapp_marketing_task_list"),
TEL_TASK_CREATE(2001, "话务任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_create", "/pages/route/index?pageType=", "hbapp_task_list_new", "TelServiceTask", "haobanNotice"),
TEL_TASK_OVERDUE(2002, "话务任务逾期推送", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_overdue", "/pages/route/index?pageType=", "hbapp_marketing_task_list", "TelServiceTaskExceedTime", "haobanNotice"),
//没集成 还没有
TEL_TASK_INVALID(2003, "话务任务逾期失效通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_nvalid", "/pages/route/index?pageType=", "hbapp_marketing_task_list"),
GROUP_TASK_CREATE(2004, "群发任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "group_task_create", "/pages/route/index?pageType=", "hbapp_marketing_task_list"),
GROUP_TASK_OVERDUE(2005, "群发任务逾期通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "group_task_overdue", "/pages/route/index?pageType=", "hbapp_marketing_task_list"),
TEL_TASK_INVALID(2003, "话务任务逾期失效通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_nvalid", "/pages/route/index?pageType=", "hbapp_marketing_task_list", "TelServiceTaskExceedTimeLoseEfficacy", "haobanNotice"),
GROUP_TASK_CREATE(2004, "群发任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "group_task_create", "/pages/route/index?pageType=", "hbapp_marketing_task_list", "groupTask", "haobanNotice"),
GROUP_TASK_OVERDUE(2005, "群发任务逾期通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "group_task_overdue", "/pages/route/index?pageType=", "hbapp_marketing_task_list", "groupTaskExceedTime", "haobanNotice"),
//没集成 还没有
GROUP_TASK_INVALID(2006, "群发任务逾期失效通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "group_task_invalid", "/pages/route/index?pageType=", "hbapp_marketing_task_list"),
PERFORMANCE_TASK_CREATE(2007, "指标任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "performance_task_create", "/pages/route/index?pageType=", "hbapp_task_kpi_detail"),
EVALUATE_TASK_CREATE(2008, "不良评价通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "evaluate_task_create", "/pages/route/index?pageType=", "hbapp_task_detail"),
PERFORMANCE_TASK_CHANGE(2009, "指标任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "performance_task_change", "/pages/route/index?pageType=", "hbapp_task_kpi_detail"),
GROUP_TASK_INVALID(2006, "群发任务逾期失效通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "group_task_invalid", "/pages/route/index?pageType=", "hbapp_marketing_task_list", "groupTaskExceedTimeLoseEfficacy", "haobanNotice"),
PERFORMANCE_TASK_CREATE(2007, "指标任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "performance_task_create", "/pages/route/index?pageType=", "hbapp_task_kpi_detail", "targetTask", "haobanNotice"),
EVALUATE_TASK_CREATE(2008, "不良评价通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "evaluate_task_create", "/pages/route/index?pageType=", "hbapp_task_detail", "badEvaluate", "haobanNotice"),
PERFORMANCE_TASK_CHANGE(2009, "指标任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "performance_task_change", "/pages/route/index?pageType=", "hbapp_task_kpi_detail", "targetTaskByStoreManage", "haobanNotice"),
TASK_TRANS(2010, "话务任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_trans", "/pages/route/index?pageType=", "hbapp_task_list_new"),
TASK_TRANS(2010, "话务任务通知", NoticeMessageCategoryTypeEnum.TASK.getType(), "task_trans", "/pages/route/index?pageType=", "hbapp_task_list_new", "TelServiceTaskByStoreManage", "haobanNotice"),
STORE_ACCOUNT(3001, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account", "/pages/route/index?pageType=", "store_relate_store_record_list"),
MEMBER_FACE(3002, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "member_face", "/pages/route/index?pageType=", "hbapp_customer_edit_tag"),
STORE_ACCOUNT_REFUSE(3010, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list"),
STORE_ACCOUNT_AGREE(3011, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account_agree", "/pages/route/index?pageType=", "store_relate_store_record_list"),
STORE_ACCOUNT(3001, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account", "/pages/route/index?pageType=", "store_relate_store_record_list", "accountApplication", "haobanNotice"),
//
MEMBER_FACE(3002, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "member_face", "/pages/route/index?pageType=", "hbapp_customer_edit_tag", "", "haobanNotice"),
CLERK_ADD_REFUSE(3020, "导购新增通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_add_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list"),
CLERK_ADD_AGREE(3021, "导购新增通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_add_agree", "/pages/route/index?pageType=", "store_relate_store_record_list"),
CLERK_DEL_REFUSE(3022, "导购删除通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_del_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list"),
CLERK_DEL_AGREE(3023, "导购删除通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_del_agree", "/pages/route/index?pageType=", "store_relate_store_record_list"),
STORE_EDIT_REFUSE(3024, "门店信息修改通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_edit_refuse", "/pages/route/index?pageType=", "store_detail"),
STORE_EDIT_AGREE(3025, "门店信息修改通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_edit_agree", "/pages/route/index?pageType=", "store_detail"),
DAILY_REPORT(3031, "云日报通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "daily_report", "/pages/route/index?pageType=", "hbapp_task_daily_report_detail"),
DAILY_REPORT_TRANS(3033, "云日报通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "daily_report_trans", "/pages/route/index?pageType=", "hbapp_task_daily_report_detail"),
//下面两个使用staff发送
STORE_ACCOUNT_REFUSE(3010, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list", "refuseAccountApplication", "haobanNotice"),
STORE_ACCOUNT_AGREE(3011, "账号申请", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_account_agree", "/pages/route/index?pageType=", "store_relate_store_record_list", "agreeAccountApplication", "haobanNotice"),
CASH_OUT_REFUSE(3040, "提现通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "cash_out_refuse", "/pages/route/index?pageType=", "hbapp_withdraw_list"),
CLERK_ADD_REFUSE(3020, "导购新增通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_add_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list", "refuseAddClerk", "haobanNotice"),
CLERK_ADD_AGREE(3021, "导购新增通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_add_agree", "/pages/route/index?pageType=", "store_relate_store_record_list", "agreeAddClerk", "haobanNotice"),
//
CLERK_DEL_REFUSE(3022, "导购删除通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_del_refuse", "/pages/route/index?pageType=", "store_relate_store_record_list", "refuseDeleteClerk", "haobanNotice"),
CLERK_DEL_AGREE(3023, "导购删除通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "clerk_del_agree", "/pages/route/index?pageType=", "store_relate_store_record_list", "agreeDeleteClerk", "haobanNotice"),
STORE_EDIT_REFUSE(3024, "门店信息修改通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_edit_refuse", "/pages/route/index?pageType=", "store_detail", "refuseStoreInfoUpdate", "haobanNotice"),
STORE_EDIT_AGREE(3025, "门店信息修改通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "store_edit_agree", "/pages/route/index?pageType=", "store_detail", "agreeStoreInfoUpdate", "haobanNotice"),
DAILY_REPORT(3031, "云日报通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "daily_report", "/pages/route/index?pageType=", "hbapp_task_daily_report_detail", "cloudDailyForStoreManage", "haobanNotice"),
DAILY_REPORT_TRANS(3033, "云日报通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "daily_report_trans", "/pages/route/index?pageType=", "hbapp_task_daily_report_detail", "cloudDailyForClerk", "haobanNotice"),
CASH_OUT_REFUSE(3040, "提现通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "cash_out_refuse", "/pages/route/index?pageType=", "hbapp_withdraw_list", "CashWithdrawal", "haobanNotice"),
OFFLINE_PRE(3041, "预约提醒", NoticeMessageCategoryTypeEnum.OTHER.getType(), "task_overdue", "/pages/route/index?pageType=", "hbapp_appointment_list"),
OFFLINE_PRE(3041, "预约提醒", NoticeMessageCategoryTypeEnum.OTHER.getType(), "task_overdue", "/pages/route/index?pageType=", "hbapp_appointment_list", "offlinePre", "haobanNotice"),
CUSTOMER_MOVE(3052, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_move", "/pages/route/index?pageType=", "hbapp_customer_list"),
CUSTOMER_MOVED(3053, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_moved", "/pages/route/index?pageType=", "hbapp_customer_list"),
CUSTOMER_UNBIND(3054, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_unbind", "/pages/route/index?pageType=", "hbapp_customer_list"),
CUSTOMER_MOVE(3052, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_move", "/pages/route/index?pageType=", "hbapp_customer_list", "assignCustomers", "haobanNotice"),
CUSTOMER_MOVED(3053, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_moved", "/pages/route/index?pageType=", "hbapp_customer_list", "removeCustomer", "haobanNotice"),
CUSTOMER_UNBIND(3054, "客户变动通知", NoticeMessageCategoryTypeEnum.OTHER.getType(), "customer_unbind", "/pages/route/index?pageType=", "hbapp_customer_list", "", ""),
CUSTOMER_ORDER_CREATE(4001, "客户下单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_create", "/pages/route/index?pageType=", "hbapp_customer_order_detail"),
CUSTOMER_ORDER_REFUND(4002, "客户退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_refund", "/pages/route/index?pageType=", "hbapp_withdraw_list"),
CUSTOMER_ORDER_LOOK(4003, "客户浏览通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_look", "/pages/route/index?pageType=", "hbapp_customer_look_goods"),
CUSTOMER_GET_COUPON(4004, "客户领券通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_get_coupon", "/pages/route/index?pageType=", "hbapp_customer_detail"),
CUSTOMER_APPLY_ORDER_REFUND(4005, "客户申请退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_apply_order_refund", "/pages/route/index?pageType=", "hbapp_customer_order_detail"),
CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail"),
CUSTOMER_ORDER_CREATE(4001, "客户下单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_create", "/pages/route/index?pageType=", "hbapp_customer_order_detail", "customerBuyOrder", "haobanNotice"),
//
CUSTOMER_ORDER_REFUND(4002, "客户退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_refund", "/pages/route/index?pageType=", "hbapp_withdraw_list", "customerChargebackOrder", "haobanNotice"),
CUSTOMER_ORDER_LOOK(4003, "客户浏览通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_order_look", "/pages/route/index?pageType=", "hbapp_customer_look_goods", "customerBrowsing", "haobanNotice"),
CUSTOMER_GET_COUPON(4004, "客户领券通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_get_coupon", "/pages/route/index?pageType=", "hbapp_customer_detail", "customerGetCoupon", "haobanNotice"),
CUSTOMER_APPLY_ORDER_REFUND(4005, "客户申请退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_apply_order_refund", "/pages/route/index?pageType=", "hbapp_customer_order_detail", "customerApplyChargebackOrder", "haobanNotice"),
CUSTOMER_SUCCESS_ORDER_REFUND(4006, "客户成功退单通知", NoticeMessageCategoryTypeEnum.CUSTOMER.getType(), "customer_success_order_refund", "/pages/route/index?pageType=", "hbapp_user_bill_detail", "customerChargebackOrderSuccess", "haobanNotice"),
// 订单- 待发货订单提醒
ORDER_TAKE(5000, "待自提订单提醒", NoticeMessageCategoryTypeEnum.ORDER.getType(), "order_take", "/pages/route/index?pageType=", "hbapp_order_verfication"),
ORDER_PAY(5001, "待发货订单提醒", NoticeMessageCategoryTypeEnum.ORDER.getType(), "order_pay", "/pages/route/index?pageType=", "hbapp_order_center"),
REFUND_AUDIT(5010, "售后待审核提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_audit", "/pages/route/index?pageType=", "hbapp_order_center"),
REFUND_MEMBER_CANCEL(5011, "买家取消售后提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_member_cancel", "/pages/route/index?pageType=", "hbapp_order_center"),
REFUND_DELIVER(5013, "买家寄出退换货提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_deliver", "/pages/route/index?pageType=", "hbapp_order_center"),
ORDER_TAKE(5000, "待自提订单提醒", NoticeMessageCategoryTypeEnum.ORDER.getType(), "order_take", "/pages/route/index?pageType=", "hbapp_order_verfication", "toBePickUpOrderRemind", "haobanNotice"),
ORDER_PAY(5001, "待发货订单提醒", NoticeMessageCategoryTypeEnum.ORDER.getType(), "order_pay", "/pages/route/index?pageType=", "hbapp_order_center", "reminderForPendingOrders", "haobanNotice"),
REFUND_AUDIT(5010, "新增售后提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_audit", "/pages/route/index?pageType=", "hbapp_order_center", "afterSalesReviewReminder", "haobanNotice"),
REFUND_MEMBER_CANCEL(5011, "买家取消售后提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_member_cancel", "/pages/route/index?pageType=", "hbapp_order_center", "afterSalesCancelReminder", "haobanNotice"),
REFUND_DELIVER(5013, "买家寄出退换货提醒", NoticeMessageCategoryTypeEnum.REFUND.getType(), "refund_deliver", "/pages/route/index?pageType=", "hbapp_order_center", "buyerSendsBackRemind", "haobanNotice"),
MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center"),
MATERIAL_REPORT_NOTIFY(6002, "素材周报/月报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_mate_report"),
//
MATERIAL_NEW_NOTIFY(6001, "素材上新通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_new_notify", "/pages/route/index?pageType=", "hbapp_material_center", "materialsNotice", "clerkMaterialsNotice"),
MATERIAL_REPORT_NOTIFY_WEEK(6002, "素材周报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_week_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialWeek", "clerkMaterialsReport"),
MATERIAL_REPORT_NOTIFY_MONTH(6004, "素材月报通知", NoticeMessageCategoryTypeEnum.MATERIAL.getType(), "material_month_notify", "/pages/route/index?pageType=", "hbapp_mate_report", "materialMonth", "clerkMaterialsReport"),
POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center");
POTENTIAL_CUSTOMER_NOTIFY(6003, "销售线索通知", NoticeMessageCategoryTypeEnum.POTENTIAL_CUSTOMER.getType(), "potential_customer_notify", "/pages/route/index?pageType=", "hbapp_sales_clue_center", "salesLeadNotice", "haobanNotice");
/**
* 消息类型
*/
@Deprecated
private int type;
/**
* 消息名称
*/
@Deprecated
private String name;
/**
* 大类
*/
@Deprecated
private int category;
/**
* 模板类型
*/
@Deprecated
private String templateCode;
/**
* 活动页面
*/
@Deprecated
private String pageUrl;
/**
* 前端的页面类型
*/
@Deprecated
private String pageType;
NoticeMessageTypeEnum(int type, String name, int category, String templateCode, String pageUrl, String pageType) {
private String messageCode;
private String routerCode;
NoticeMessageTypeEnum(int type, String name, int category, String templateCode, String pageUrl, String pageType, String messageCode, String routerCode) {
this.type = type;
this.name = name;
this.category = category;
this.templateCode = templateCode;
this.pageUrl = pageUrl;
this.pageType = pageType;
this.messageCode = messageCode;
this.routerCode = routerCode;
}
......@@ -165,4 +183,20 @@ public enum NoticeMessageTypeEnum {
}
return null;
}
public String getMessageCode() {
return messageCode;
}
public void setMessageCode(String messageCode) {
this.messageCode = messageCode;
}
public String getRouterCode() {
return routerCode;
}
public void setRouterCode(String routerCode) {
this.routerCode = routerCode;
}
}
......@@ -5,6 +5,7 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.dto.qdto.NoticeMessageQDTO;
import java.util.List;
......@@ -82,4 +83,12 @@ public interface NoticeMessageApiService {
*/
public ServiceResponse<Boolean> updateWriteFlagByClerkId(String enterpriseId, String clerkId, int categoryType);
/**
* 新增好办内部通知
*
* @param qdto
* @return
*/
public ServiceResponse<Boolean> addOrCreateNoticeMessage(List<NoticeMessageQDTO> qdto);
}
\ No newline at end of file
......@@ -196,6 +196,12 @@
<artifactId>gic-order-api</artifactId>
<version>${gic-order-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-message-center-api</artifactId>
<version>${gic-message-center-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -2,8 +2,10 @@ package com.gic.haoban.manage.service.pojo.bo.content.context;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
......@@ -13,11 +15,11 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY;
/**
* @Author MUSI
......@@ -106,16 +108,22 @@ public class MaterialReportContext {
log.info("成员{}为区经角色, 不发送小程序消息通知 ", this.staffId);
return Collections.emptyList();
}
final NoticeMessageTypeEnum noticeMessageTypeEnum = MaterialReportType.WEEK.getCode().equals(this.getReportType()) ? NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK : NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
if (ObjectUtil.isNull(noticeMessageTypeEnum)){
return new ArrayList<>();
}
return this.staffClerkRelations
.stream()
.map(item -> {
NoticeMessageBO noticeMessageBO = new NoticeMessageBO();
noticeMessageBO.setCategoryType(MATERIAL_REPORT_NOTIFY.getCategory());
noticeMessageBO.setMessageType(MATERIAL_REPORT_NOTIFY.getType());
noticeMessageBO.setCategoryType(noticeMessageTypeEnum.getCategory());
noticeMessageBO.setMessageType(noticeMessageTypeEnum.getType());
noticeMessageBO.setClerkId(StringUtils.isNotBlank(item.getClerkId()) ? item.getClerkId() : "-1");
noticeMessageBO.setStoreId(StringUtils.isNotBlank(item.getStoreId()) ? item.getStoreId() : "-1");
noticeMessageBO.setTitle(this.getMessageTitle());
noticeMessageBO.setTemplateCode(MATERIAL_REPORT_NOTIFY.getTemplateCode());
noticeMessageBO.setTemplateCode(noticeMessageTypeEnum.getTemplateCode());
noticeMessageBO.setDescription(this.getMessageDesc());
noticeMessageBO.setEnterpriseId(this.enterpriseId);
noticeMessageBO.setRelationId(this.clerkId);
......
package com.gic.haoban.manage.service.service.content.adaptor;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
......@@ -22,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
......@@ -198,7 +200,9 @@ public class MaterialReportBuilder {
articleInfo.setTitle(context.getMessageTitle());
articleInfo.setDescription(context.getMessageDesc());
String extendParams = StringUtils.isNotBlank(context.getMainStoreId()) ? context.getMainStoreId() : context.getEnterpriseId();
articleInfo.setPagepath(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, context.extendParams(extendParams)));
final NoticeMessageTypeEnum noticeMessageTypeEnum = MaterialReportType.WEEK.getCode().equals(context.getReportType()) ? NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK : NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
articleInfo.setPagepath(NoticeMessageUtil.buildMiniAppUrl(noticeMessageTypeEnum, context.extendParams(extendParams)));
articleInfo.setPicurl(context.getMaterialReportUrl());
newsSendMessage.setArticleMessages(Collections.singletonList(articleInfo));
return newsSendMessage;
......
package com.gic.haoban.manage.service.service.content.adaptor;
import com.alibaba.fastjson.JSON;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
......@@ -15,7 +16,10 @@ import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNo
import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.ItemDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
......@@ -28,6 +32,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -60,6 +65,8 @@ public class PotentialCustomerNotifyBuilder {
private Config config;
@Autowired
private StaffApiService staffApiService;
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/**
* 获取企业下所有导购id
......@@ -189,10 +196,29 @@ public class PotentialCustomerNotifyBuilder {
log.info("企业信息不存在 {}", staffClerkRelation.getWxEnterpriseId());
continue;
}
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO,
if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/* 消息中心修改此处*/
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO,
customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId()));
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), wxEnterpriseQwDTO.getSelf3thSecret(), messageDTO,wxEnterpriseQwDTO.isSelf(),wxEnterpriseQwDTO.getUrlHost());
log.info("发送销售线索应用消息结果 {}", sendMessage);
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), wxEnterpriseQwDTO.getSelf3thSecret(), messageDTO,wxEnterpriseQwDTO.isSelf(),wxEnterpriseQwDTO.getUrlHost());
log.info("发送销售线索应用消息结果 {}", sendMessage);
} else {
Map<String, String> variableMap = new HashMap<>();
variableMap.put("memberNum", customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum().toString());
variableMap.put("page", NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId())));
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY.getMessageCode())
.mqRouterCode(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY.getRouterCode())
.businessId("-1")
.createTime(new Date())
.enterpriseId(context.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(Collections.singletonList(staffClerkRelation.getClerkId()))
.variableMap(variableMap).build());
}
}
}
......
package com.gic.haoban.manage.service.service.content.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
......@@ -12,7 +18,11 @@ import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.content.adaptor.MaterialReportBuilder;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.QywxNewsArticleMessageDTO;
import com.gic.wechat.api.dto.qywx.QywxNewsSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import lombok.extern.slf4j.Slf4j;
......@@ -21,7 +31,12 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author MUSI
......@@ -49,6 +64,9 @@ public class MaterialReportServiceImpl implements MaterialReportService {
@Autowired
private Config config;
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/**
* 素材周报/月报
......@@ -87,13 +105,24 @@ public class MaterialReportServiceImpl implements MaterialReportService {
materialReportBuilder.buildMaterialReportData(context);
// 保存小程序消息
List<NoticeMessageBO> noticeMessageBos = context.buildNotifyMessageBos();
if (CollectionUtils.isNotEmpty(noticeMessageBos)) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/*消息中心修改此处*/
if (CollectionUtils.isNotEmpty(noticeMessageBos)) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}
}
if (StringUtils.isBlank(context.getClerkId())) {
log.info("成员{}在企业{}中不存在主门店, 不推送企微应用消息", staffId, enterpriseId);
if (ApolloUtils.useMessageCenter()) {
noticeMessageService.addNoticeMessageBatch(noticeMessageBos);
}
return;
}
// 发送企微消息
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffInfo.getWxEnterpriseId());
QywxNewsSendMessageDTO newsSendMessageDTO = materialReportBuilder.buildQywxNewsMessage(context, qwDTO);
......@@ -102,7 +131,46 @@ public class MaterialReportServiceImpl implements MaterialReportService {
return;
}
log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO));
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/*消息中心修改此处*/
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
return;
} else {
Map<String, String> variableMap = new HashMap<>();
QywxNewsArticleMessageDTO qywxNewsArticleMessageDTO = newsSendMessageDTO.getArticleMessages().get(0);
variableMap.put("image", qywxNewsArticleMessageDTO.getPicurl());
variableMap.put("page", qywxNewsArticleMessageDTO.getPagepath());
variableMap.put("templateTitle", qywxNewsArticleMessageDTO.getTitle());
variableMap.put("templateDescription", qywxNewsArticleMessageDTO.getDescription());
variableMap.put("haobanNoticeMessageList", JSONObject.toJSONString(noticeMessageBos));
NoticeMessageTypeEnum noticeMessageTypeEnum = null;
if (MaterialReportType.WEEK.getCode().equals(context.getReportType())) {
noticeMessageTypeEnum = NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_WEEK;
} else if (MaterialReportType.MONTH.getCode().equals(context.getReportType())) {
noticeMessageTypeEnum = NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH;
}
if (ObjectUtil.isNull(noticeMessageTypeEnum)){
log.info("枚举不存在 context:{}", JSONObject.toJSONString(context));
return;
}
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode(noticeMessageTypeEnum.getMessageCode())
.mqRouterCode(noticeMessageTypeEnum.getRouterCode())
.businessId("-1")
.createTime(new Date())
.enterpriseId(context.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(context.getClerkId() == null ? new ArrayList<>() : Collections.singletonList(context.getClerkId()))
.variableMap(variableMap).build());
}
/*boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);*/
}
}
......@@ -21,6 +21,7 @@ import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder;
import com.gic.haoban.manage.service.service.content.adaptor.PotentialCustomerNotifyBuilder;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.member.api.dto.es.MemberDataDTO;
import com.gic.member.api.service.MemberOutApiService;
import com.gic.search.engine.api.constant.MemberDataEnum;
......@@ -263,7 +264,13 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
// 区经 忽略
potentialCustomerNotifyBuilder.filterAreaManage(context);
// 构建应用内消息
potentialCustomerNotifyBuilder.sendHaoBanNotifyMessage(context);
/*消息中心修改此处*/
if (!ApolloUtils.useMessageCenter()){
log.info("消息中心-走老版消息通知");
/*消息中心修改此处*/
potentialCustomerNotifyBuilder.sendHaoBanNotifyMessage(context);
}
// 如果该导购id是成员在主门店时的导购id 发送应用消息
// 如果本批数据中无成员主门店数据 则不发送
potentialCustomerNotifyBuilder.sendApplicationMessage(context);
......
......@@ -296,20 +296,16 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
this.clerkMainStoreRelatedService.reflushExternal(wxEnterpriseId, staffId);
}
//有活码权限的企业
boolean flag = rightService.hasRightForAdmin(enterpriseId, "hb_m0206");
if (flag) {
// 绑定自动创建活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmType(1);
hmQrcodeQDTO.setWxEnterpriseId(wxEnterpriseId);
hmQrcodeQDTO.setEnterpriseId(enterpriseId);
hmQrcodeQDTO.setName(tabHaobanStaff.getStaffName());
hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(dto.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId()));
hmQrcodeQDTO.setInvokingType(channelCode);
hmQrcodeApiService.add(hmQrcodeQDTO);
}
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmType(1);
hmQrcodeQDTO.setWxEnterpriseId(wxEnterpriseId);
hmQrcodeQDTO.setEnterpriseId(enterpriseId);
hmQrcodeQDTO.setName(tabHaobanStaff.getStaffName());
hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(dto.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(dto.getClerkId()));
hmQrcodeQDTO.setInvokingType(channelCode);
hmQrcodeApiService.add(hmQrcodeQDTO);
}
//推入日志
staffClerkBindLogService.pushToMq(staffId, optStaffId, BindTypeEnum.BIND.getVal(), channelCode, staffClerkRelationId);
......
package com.gic.haoban.manage.service.service.message;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.manage.service.service.notify.out.NoticeMessageApiServiceImpl;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.mq.sdk.GicMQClient;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import static org.slf4j.LoggerFactory.getLogger;
/**
* @description: 企业微信通知消息发送处理类
* @author: 巴弗
* @createDate: 2023/4/21 14:03
*/
@Service
public class NoticeMessageHandler {
private static final Logger logger = getLogger(NoticeMessageHandler.class);
/**
* 发送小程序消息
*/
public void sendMessage(NoticeMessageForm noticeMessageForm){
logger.info("消息中心发送消息实体:{}", JSONObject.toJSONString(noticeMessageForm));
if (ObjectUtil.isEmpty(noticeMessageForm.getMessageCode()) || ObjectUtil.isEmpty(noticeMessageForm.getMqRouterCode())) {
logger.info("消息中心发送消息实体 messageCode 或 mqRouterCode 不存在");
}
GicMQClient client = GICMQClientUtil.getClientInstance();
try {
client.sendMessage(noticeMessageForm.getMqRouterCode(), JSONObject.toJSONString(noticeMessageForm));
} catch (Exception e) {
logger.error("消息中心发送消息实体发送异常 ", e);
}
}
}
......@@ -9,18 +9,25 @@ import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gic.clerk.api.dto.ClerkListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.notify.dto.NotifyMessageMQDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NotifyMessageBatchQDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.WxEnterpriseRelatedService;
import com.gic.haoban.manage.service.service.message.NoticeMessageHandler;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.gic.message.center.api.subscribe.model.NoticeMessageForm;
import com.gic.wechat.api.dto.qywx.QywxTemplateCardSendMessageDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
......@@ -92,8 +99,12 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
@Autowired
private ClerkService clerkService;
@Override
public void noticeMessageMq(String json) {
@Autowired
private NoticeMessageHandler noticeMessageHandler;
/*消息中心修改此处
@Override*/
public void noticeMessageMq_old(String json) {
logger.info("通知消息:{}", json);
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
NoticeMessageTypeEnum messageTypeEnum = NoticeMessageTypeEnum.getByType(messageQDTO.getMessageType());
......@@ -147,6 +158,68 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
}
@Override
public void noticeMessageMq(String json) {
if (!ApolloUtils.useMessageCenter()){
logger.info("消息中心-走老版消息通知");
this.noticeMessageMq_old(json);
return;
}
NoticeMessageQDTO messageQDTO = JSONObject.parseObject(json, NoticeMessageQDTO.class);
logger.info("messageType:{},消息中心测试通知消息:{}", messageQDTO.getMessageType(), json);
String staffId = null;
StaffClerkRelationDTO clerkRelationDTO = null;
if (StringUtils.isNotBlank(messageQDTO.getStaffId())) {
TabHaobanStaff haobanStaff = staffService.selectById(messageQDTO.getStaffId());
staffId = haobanStaff != null ? haobanStaff.getStaffId() : null;
}
if (StringUtils.isNotEmpty(messageQDTO.getClerkId())) {
clerkRelationDTO = staffClerkRelationService.getByClerkId(messageQDTO.getClerkId());
}
if (staffId == null && clerkRelationDTO == null) {
logger.info("没有导购:{}", messageQDTO.getClerkId());
return;
}
try {
Map<String, String> variableMap = ObjectUtil.isNotNull(messageQDTO.getContentMap()) ? messageQDTO.getContentMap() : new HashMap<>();
if (ObjectUtil.isNotEmpty(messageQDTO.getExtendContent())) {
variableMap.put("pageParams", JSONObject.toJSONString(messageQDTO.getExtendContent()));
}
if (ObjectUtil.isNotEmpty(messageQDTO.getTitle())) {
variableMap.put("templateTitle", messageQDTO.getTitle());
}
NoticeMessageTypeEnum noticeMessageTypeEnum = NoticeMessageTypeEnum.getByType(messageQDTO.getMessageType());
if (ObjectUtil.isNull(noticeMessageTypeEnum)) {
return;
}
NoticeMessageForm build = NoticeMessageForm.builder()
.messageCode(noticeMessageTypeEnum.getMessageCode())
.mqRouterCode(noticeMessageTypeEnum.getRouterCode())
.businessId(messageQDTO.getOptTargetId())
.createTime(new Date())
.enterpriseId(messageQDTO.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.variableMap(variableMap).build();
if (clerkRelationDTO != null){
build.setUserIdList(Collections.singletonList(clerkRelationDTO.getClerkId()));
} else {
build.setStaffIdList(Collections.singletonList(staffId));
}
noticeMessageHandler.sendMessage(build);
} catch (Exception e) {
logger.error("发送消息通知失败",e);
}
}
@Override
public void run(String json) {
this.noticeMessageMq(json);
}
......@@ -154,11 +227,17 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
@Override
public void noticeMessageBatchMq(String json) {
NotifyMessageBatchQDTO notifyMessageBatchQDTO = JSONObject.parseObject(json, NotifyMessageBatchQDTO.class);
if (!ApolloUtils.useMessageCenter()){
logger.info("消息中心-走老版消息通知");
this.batchSendMessage_old(notifyMessageBatchQDTO);
return;
}
batchSendMessage(notifyMessageBatchQDTO);
}
@Override
public ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO) {
/*消息中心修改此处
@Override*/
public ServiceResponse<Void> batchSendMessage_old(NotifyMessageBatchQDTO notifyMessageBatchQDTO) {
String enterpriseId = notifyMessageBatchQDTO.getEnterpriseId();
List<String> storeIdList = notifyMessageBatchQDTO.getStoreIdList();
if (CollectionUtils.isEmpty(storeIdList)) {
......@@ -209,7 +288,76 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> batchSendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO) {
logger.info("消息中心测试通知消息:{}", JSONObject.toJSONString(notifyMessageBatchQDTO));
String enterpriseId = notifyMessageBatchQDTO.getEnterpriseId();
List<String> storeIdList = notifyMessageBatchQDTO.getStoreIdList();
if (CollectionUtils.isEmpty(storeIdList)) {
logger.info("门店列表为空");
return ServiceResponse.success();
}
int count = wxEnterpriseRelatedService.getRelationCount(enterpriseId);
if (count == 0) {
logger.info("商户未关联好办或都已停用enterpriseId={}", enterpriseId);
return ServiceResponse.success();
}
List<String> clerkIdList = clerkService.getclerkListByStoreIds(storeIdList);
if (CollectionUtils.isEmpty(clerkIdList)) {
logger.info("门店导购列表为空");
return ServiceResponse.success();
}
List<StaffClerkRelationDTO> relationList = staffClerkRelationService.listByClerkIds(clerkIdList);
if (CollectionUtils.isEmpty(relationList)) {
logger.info("成员关联列表为空");
return ServiceResponse.success();
}
try {
//TODO 这里有个回调未处理
Map<String, String> variableMap = notifyMessageBatchQDTO.getContentMap();
variableMap.put("pageParams", JSONObject.toJSONString(notifyMessageBatchQDTO.getExtendContent()));
variableMap.put("extendContent", JSONObject.toJSONString(notifyMessageBatchQDTO.getExtendContent()));
variableMap.put("templateTitle", notifyMessageBatchQDTO.getTitle());
NoticeMessageTypeEnum noticeMessageTypeEnum = NoticeMessageTypeEnum.getByType(notifyMessageBatchQDTO.getMessageType());
if (ObjectUtil.isNull(noticeMessageTypeEnum)) {
return ServiceResponse.failure("-1", "模版枚举不存在");
}
noticeMessageHandler.sendMessage(NoticeMessageForm.builder()
.messageCode(noticeMessageTypeEnum.getMessageCode())
.mqRouterCode(noticeMessageTypeEnum.getRouterCode())
.businessId(notifyMessageBatchQDTO.getOptTargetId())
.createTime(new Date())
.enterpriseId(notifyMessageBatchQDTO.getEnterpriseId())
.uniqueKey(UniqueIdUtils.uniqueLongHex())
.userIdList(relationList.stream().map(StaffClerkRelationDTO::getClerkId).distinct().collect(Collectors.toList()))
.variableMap(variableMap).build());
} catch (Exception e) {
logger.error("发送消息通知失败",e);
}
return ServiceResponse.success();
}
private String getUrlParams(Map<String, Object> extendContent) {
String data = extendContent != null ? JSONObject.toJSONString(extendContent) : null;
if (StringUtils.isNotBlank(data)) {
try {
data = URLEncoder.encode(data, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage());
}
}
return data;
}
private void sendMessage(NotifyMessageBatchQDTO notifyMessageBatchQDTO, List<StaffClerkRelationDTO> list,Set<String> userIdSet, WxEnterpriseQwDTO qwDTO) {
//企业微信模板
List<TemplateContentBO> contentList = getDescriotion(notifyMessageBatchQDTO);
//好办模板
......@@ -324,6 +472,13 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
return ServiceResponse.success(true);
}
@Override
public ServiceResponse<Boolean> addOrCreateNoticeMessage(List<com.gic.haoban.manage.api.dto.qdto.NoticeMessageQDTO> qdto) {
noticeMessageService.addNoticeMessageBatch(EntityUtil.changeEntityListByJSON(NoticeMessageBO.class, qdto));
return ServiceResponse.success();
}
/**
* 获取详情
*
......
......@@ -574,6 +574,7 @@ public class MessageApiServiceImpl implements MessageApiService {
}
@Override
@Deprecated
public com.gic.api.base.commons.ServiceResponse<Void> sendPreMessage(String enterpriseId, String storeId,
String message) {
log.info("线下预约通知,storeId={}", storeId);
......@@ -680,7 +681,11 @@ public class MessageApiServiceImpl implements MessageApiService {
Map<String, String> map = new HashMap<>();
if (CollectionUtils.isNotEmpty(valueList)) {
for (int i = 0; i < valueList.size(); i++) {
map.put("" + (i + 1), valueList.get(i));
String key = "" + (i + 1);
map.put(key, valueList.get(i));
if (key.equals("1")) {
map.put("goodsName", valueList.get(i));
}
}
}
MemberDataDTO member = this.findMember(enterpriseId,memberId);
......
......@@ -213,7 +213,7 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
, NoticeMessageTypeEnum.CLERK_DEL_AGREE.getType(), null, params, jsonObject);
} else {
NoticeMessageUtil.sendNoticeMessage(tab.getEnterpriseId(), tab.getClerkId()
, NoticeMessageTypeEnum.CLERK_DEL_AGREE.getType(), null, params, jsonObject);
, NoticeMessageTypeEnum.CLERK_DEL_REFUSE.getType(), null, params, jsonObject);
}
}
......
......@@ -25,7 +25,6 @@ import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.constants.Manage3Constants;
import com.gic.haoban.manage.api.dto.AlertMessageDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeAccountInterceptLogDTO;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDTO;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO;
......@@ -90,11 +89,19 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
@Override
public void run(String param) {
List<TabHaobanWxEnterprise> tabHaobanWxEnterprises = wxEnterpriseService.listAll();
for (TabHaobanWxEnterprise wxEnterprise : tabHaobanWxEnterprises) {
GicMQClient instance = GICMQClientUtil.getClientInstance();
GicMQClient instance = GICMQClientUtil.getClientInstance();
if("-1".equals(param)) {
List<TabHaobanWxEnterprise> tabHaobanWxEnterprises = wxEnterpriseService.listAll();
for (TabHaobanWxEnterprise wxEnterprise : tabHaobanWxEnterprises) {
try {
instance.sendMessage("qywxAddFeeMq", wxEnterprise.getWxEnterpriseId());
} catch (Exception e) {
logger.info("发送消息处理异常:{}", e.getMessage(), e);
}
}
}else {
try {
instance.sendMessage("qywxAddFeeMq", wxEnterprise.getWxEnterpriseId());
instance.sendMessage("qywxAddFeeMq", param);
} catch (Exception e) {
logger.info("发送消息处理异常:{}", e.getMessage(), e);
}
......@@ -162,8 +169,8 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
}
String serviceCorpid = config.getCorpid();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO.getWxSecurityType() <= 0) {
logger.info("WxSecurityType=0,wxEnterpriseId={}", wxEnterpriseId);
if (wxEnterpriseDTO.getWxSecurityType() <= 0 || wxEnterpriseDTO.getWxSecurityType() == 5) {
logger.info("WxSecurityType=0/5,wxEnterpriseId={}", wxEnterpriseId);
return;
}
String corpid = wxEnterpriseDTO.getOpenCorpid();
......@@ -227,11 +234,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
// 成员的激活码信息
this.staffService.activedAccountTimer(wxEnterpriseId);
// 更新企业的激活数量统计
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(!qwDTO.isSelf()) {
this.wxEnterpriseActiveDataService.saveOrUpdate(wxEnterpriseId);
}
this.wxEnterpriseActiveDataService.saveOrUpdate(wxEnterpriseId);
// 统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数
HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = haobanQywxFeeAccountStaffService.feeIntercept(wxEnterpriseId);
......@@ -254,8 +257,9 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFee.setInterceptFlag(0);
haobanQywxFeeService.insert(tabHaobanQywxFee);
// 判断今天是否是本月最后一天
if (DateUtil.isSameDay(DateUtil.endOfMonth(new Date()), new Date()) || "ca66a01b79474c40b3e7c7f93daf1a3b".equals(wxEnterpriseId)) {
int monthWillInterceptNum = haobanQywxFeeDetailDTO.getInterceptUserNum() ;
if (DateUtil.isSameDay(DateUtil.endOfMonth(new Date()), new Date())
|| "ca66a01b79474c40b3e7c7f93daf1a3b".equals(wxEnterpriseId)) {
int monthWillInterceptNum = haobanQywxFeeDetailDTO.getInterceptUserNum();
String content = "30天将有" + monthWillInterceptNum + "个接口许可证即将过期,您总共还剩余" + permissionUserNum
+ "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName(), content);
......@@ -300,13 +304,13 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
TabHaobanQywxFeeOrderAccount activeAccount = new TabHaobanQywxFeeOrderAccount();
// 查询激活码的详情
List<ActiveInfoCodeResponseDTO> respList = qywxUserApiService.getActiveInfoByCodeList(corpid, serviceCorpid,
codeList);
if (CollectionUtils.isNotEmpty(respList)) {
List<List<ActiveInfoCodeResponseDTO>> list = Lists.partition(respList, 800);
for (int i = 0; i < list.size(); i++) {
List<ActiveInfoCodeResponseDTO> subList = list.get(i);
for (ActiveInfoCodeResponseDTO activeDetail : subList) {
List<List<String>> list = Lists.partition(codeList, 1000);
for (int i = 0; i < list.size(); i++) {
List<String> subCodeList = list.get(i);
List<ActiveInfoCodeResponseDTO> respList = qywxUserApiService.getActiveInfoByCodeList(corpid, serviceCorpid,
subCodeList);
if (CollectionUtils.isNotEmpty(respList)) {
for (ActiveInfoCodeResponseDTO activeDetail : respList) {
String userid = activeDetail.getUserid();
String activeCode = activeDetail.getActiveCode();
activeAccount.setWxUserId(userid);
......
......@@ -787,11 +787,6 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String enterpriseId = wxEnterpriseDTO.getEnterpriseId();
//查询出所有正常的导购
String wxEnterpriseId = wxEnterpriseDTO.getWxEnterpriseId();
boolean flag = rightService.hasRightForAdmin(enterpriseId, "hb_m0206");
if (!flag) {
logger.info("该企业未与gic关联,无需开启:enterpriseId:{},wxEnterpriseId:{}", enterpriseId, wxEnterpriseId);
continue;
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("wxEnterpriseId", wxEnterpriseId);
jsonObject.put("enterpriseId", enterpriseId);
......
package com.gic.haoban.manage.service.util;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
public class ApolloUtils {
/**
* 旧的调用发送,是否采用新的消息中心开关1:是 0:否
* @return
*/
public static boolean useMessageCenter() {
Config config = ConfigService.getConfig("COMMON.gic-properties");
String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0");
return "1".equals(messageCenterSwitch);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper">
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
<id column="external_clerk_related_id" property="externalClerkRelatedId" jdbcType="VARCHAR"/>
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR"/>
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR"/>
<result column="store_id" property="storeId" jdbcType="VARCHAR"/>
<result column="member_id" property="memberId" jdbcType="VARCHAR"/>
<result column="unionid" property="unionid" jdbcType="VARCHAR"/>
<result column="external_name" property="externalName" jdbcType="VARCHAR"/>
<result column="head_url" property="headUrl" jdbcType="VARCHAR"/>
<result column="external_user_id" property="externalUserId" jdbcType="VARCHAR"/>
<result column="add_create_time" property="addCreateTime" jdbcType="VARCHAR"/>
<result column="member_unionid_related_id" property="memberUnionidRelatedId" jdbcType="VARCHAR"/>
<result column="clerk_id" property="clerkId" jdbcType="VARCHAR"/>
<result column="staff_id" property="staffId" jdbcType="VARCHAR"/>
<result column="relation_key" property="relationKey" jdbcType="VARCHAR"/>
<result column="status_flag" property="statusFlag" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
external_clerk_related_id, wx_enterprise_id, enterprise_id, store_id, member_id,
unionid, head_url,external_name, add_create_time, member_unionid_related_id, clerk_id, staff_id,
relation_key, status_flag, create_time, update_time,external_user_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where external_clerk_related_id = #{externalClerkRelatedId,jdbcType=VARCHAR}
</select>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
insert into tab_haoban_external_clerk_related
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="externalClerkRelatedId != null">
external_clerk_related_id,
</if>
<if test="wxEnterpriseId != null">
wx_enterprise_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="storeId != null">
store_id,
</if>
<if test="memberId != null">
member_id,
</if>
<if test="unionid != null">
unionid,
</if>
<if test="headUrl != null">
head_url,
</if>
<if test="externalName != null">
external_name,
</if>
<if test="externalUserId != null">
external_user_id,
</if>
<if test="addCreateTime != null">
add_create_time,
</if>
<if test="memberUnionidRelatedId != null">
member_unionid_related_id,
</if>
<if test="clerkId != null">
clerk_id,
</if>
<if test="staffId != null">
staff_id,
</if>
<if test="pushTimes != null">
push_times,
</if>
<if test="relationKey != null">
relation_key,
</if>
<if test="statusFlag != null">
status_flag,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="selfExternalUserid != null">
self_external_userid,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="externalClerkRelatedId != null">
#{externalClerkRelatedId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null">
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="storeId != null">
#{storeId,jdbcType=VARCHAR},
</if>
<if test="memberId != null">
#{memberId,jdbcType=VARCHAR},
</if>
<if test="unionid != null">
#{unionid,jdbcType=VARCHAR},
</if>
<if test="headUrl != null">
#{headUrl,jdbcType=VARCHAR},
</if>
<if test="externalName != null">
#{externalName,jdbcType=VARCHAR},
</if>
<if test="externalUserId != null">
#{externalUserId,jdbcType=VARCHAR},
</if>
<if test="addCreateTime != null">
#{addCreateTime,jdbcType=VARCHAR},
</if>
<if test="memberUnionidRelatedId != null">
#{memberUnionidRelatedId,jdbcType=VARCHAR},
</if>
<if test="clerkId != null">
#{clerkId,jdbcType=VARCHAR},
</if>
<if test="staffId != null">
#{staffId,jdbcType=VARCHAR},
</if>
<if test="pushTimes != null">
#{pushTimes},
</if>
<if test="relationKey != null">
#{relationKey,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null">
#{statusFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="selfExternalUserid != null">
#{selfExternalUserid},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
<set>
<if test="wxEnterpriseId != null">
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="storeId != null">
store_id = #{storeId,jdbcType=VARCHAR},
</if>
<if test="memberId != null">
member_id = #{memberId,jdbcType=VARCHAR},
</if>
<if test="unionid != null">
unionid = #{unionid,jdbcType=VARCHAR},
</if>
<if test="headUrl != null">
head_url = #{headUrl,jdbcType=VARCHAR},
</if>
<if test="externalName != null">
external_name = #{externalName,jdbcType=VARCHAR},
</if>
<if test="externalUserId != null">
external_user_id = #{externalUserId,jdbcType=VARCHAR},
</if>
<if test="addCreateTime != null">
add_create_time = #{addCreateTime,jdbcType=VARCHAR},
</if>
<if test="memberUnionidRelatedId != null">
member_unionid_related_id = #{memberUnionidRelatedId,jdbcType=VARCHAR},
</if>
<if test="clerkId != null">
clerk_id = #{clerkId,jdbcType=VARCHAR},
</if>
<if test="staffId != null">
staff_id = #{staffId,jdbcType=VARCHAR},
</if>
<if test="relationKey != null">
relation_key = #{relationKey,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null">
status_flag = #{statusFlag,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where external_clerk_related_id = #{externalClerkRelatedId,jdbcType=VARCHAR}
</update>
<select id="selectByClerkIdAndExternalUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where clerk_id = #{clerkId,jdbcType=VARCHAR}
and external_user_id = #{externalUserId}
and status_flag = 1
</select>
<update id="delByUserIdAndExternalUserId">
update tab_haoban_external_clerk_related
set status_flag = 2,
update_time = now()
where external_user_id = #{externalUserId}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</update>
<update id="delByUserIdAndExternalUserIdBatch"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set
status_flag = 2,
update_time = now()
where
wx_enterprise_id=#{wxEnterpriseId}
and staff_id = #{staffId}
and status_flag in(1,3,4)
and external_user_id in
<foreach collection="externalUserIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="delByClerkIdAndStaffId"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set status_flag = 2,
update_time = now()
where clerk_id = #{clerkId,jdbcType=VARCHAR}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</update>
<update id="delByStoreIdAndStaffId"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set status_flag = 2,
update_time = now()
where store_id = #{storeId,jdbcType=VARCHAR}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</update>
<update id="delByStoreIds"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set
status_flag = 2,
update_time = now()
where store_id IN
<foreach collection="storeIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and status_flag in(1,3,4)
</update>
<update id="cleanStaffRelated" parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set
status_flag = 2,
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and staff_id IN
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
and status_flag = 1
</update>
<select id="listByExTernalUseridAndWxUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and external_user_id = #{externalUserid}
and status_flag = #{statusFlag}
</select>
<select id="listByExternalUseridAndWxEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where external_user_id = #{externalUserid} and wx_enterprise_id = #{wxEnterpriseId}
<if test="statusFlags != null">
and status_flag IN
<foreach collection="statusFlags" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
</select>
<select id="listByExTernalUseridAndWxUserIdAllStatus" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and external_user_id = #{externalUserid}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag in(1,3,4)
</select>
<select id="listByEnterpriseIdAndDate" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where status_flag = 1
and enterprise_id = #{enterpriseId}
<if test="date != null">
and TO_DAYS(create_time) <![CDATA[ >= ]]> TO_DAYS(#{date,jdbcType=TIMESTAMP})
</if>
</select>
<select id="pageMemberUnionByParams" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and status_flag = 1
and member_id in
<foreach item="memberId" index="index" collection="sendMemberIds" open="(" separator="," close=")">
#{memberId, jdbcType=CHAR}
</foreach>
and staff_id in
<foreach item="staffId" index="index" collection="staffIdList" open="(" separator="," close=")">
#{staffId, jdbcType=CHAR}
</foreach>
and member_id is not null
group by external_user_id
</select>
<select id="listByWxEnterpriseIdAndWxUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<select id="listByWxEnterpriseIdAndWxUserIds" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id in
<foreach item="staffId" index="index" collection="staffIdList" open="(" separator="," close=")">
#{staffId, jdbcType=CHAR}
</foreach>
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<select id="getByMemberId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and member_id = #{memberId}
and status_flag = 1
and external_user_id is not null
order by update_time desc
limit 1
</select>
<select id="listExternalByUnionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and unionid = #{unionId}
and status_flag = 1
</select>
<select id="getByRelationKey" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where
relation_key = #{relationKey}
<if test="filterMember==1">
and member_id is null
</if>
and status_flag != 2
order by create_time desc limit 1
</select>
<select id="listByWxEnterpriseIdAndWxUserIdAndStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag in
<foreach collection="statusFlags" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<update id="pushExternalByRelationKey">
update tab_haoban_external_clerk_related
set status_flag = 4,
push_times =push_times + 1,
update_time = now()
where relation_key = #{relationKey,jdbcType=VARCHAR}
and status_flag in (3, 4)
</update>
<select id="getExternalClerkByWxUserIdAncExternalUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and external_user_id = #{externalUserId}
and status_flag in(1,3,4)
order by update_time desc limit 1
</select>
<select id="listByMemberIdAndWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and member_id = #{memberId}
and status_flag = 1
</select>
<select id="listByMemberIdList" resultType="com.gic.haoban.manage.api.dto.ExternalClerkRelatedDTO">
select
member_id memberId , external_user_id externalUserId
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
and wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and status_flag = 1 and external_status = 1 group by member_id
</select>
<select id="getLastByExTernalUseridAndWxUserIdNoStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and staff_id = #{staffId}
and external_user_id = #{externalUserid}
order by create_time desc limit 1
</select>
<select id="listByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and external_clerk_related_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<select id="listMemberIdByEnterpriseId" resultType="String">
select member_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and status_flag in (1, 3, 4)
order by create_time
</select>
<select id="listMemberIdsByMemberIds" resultType="String">
select
member_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and member_id in
<foreach collection="memberIds" open="(" separator="," close=")" item="item">
#{item}
</foreach>
and status_flag = 1
</select>
<select id="listByMemberId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where member_id = #{memberId}
and status_flag = 1
<if test="enterpriseId != null and enterpriseId != ''">
and enterprise_id = #{enterpriseId}
</if>
</select>
<select id="listStoreIdByMemberId" resultType="string">
select
store_id
from tab_haoban_external_clerk_related
where member_id = #{memberId}
and status_flag = 1
</select>
<select id="listByExternalUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
and external_user_id = #{externalUserId}
</select>
<update id="updateMemberIdByMemberId">
UPDATE
tab_haoban_external_clerk_related
SET member_id=#{memberId},
update_time = now()
where member_id = #{oldMemberId}
and enterprise_id = #{enterpriseId} and status_flag = 1
</update>
<update id="updateStatusByMemberId">
UPDATE
tab_haoban_external_clerk_related
SET status_flag = 2,
update_time = now()
where member_id = #{memberId}
and enterprise_id = #{enterpriseId}
</update>
<select id="getByMemberIdAndStaffId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where
member_id = #{memberId}
and enterprise_id = #{enterpriseId}
AND staff_id = #{staffId}
AND status_flag = 1 limit 1
</select>
<select id="getByUnionIdAndStaffId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where
member_id = #{memberId}
and enterprise_id = #{enterpriseId}
AND unionid = #{unionid}
AND status_flag = 1 limit 1
</select>
<select id="pageExternalByEnterpriseId" resultMap="BaseResultMap">
select wx_enterprise_id,
enterprise_id,
external_user_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
AND status_flag = 1
and external_user_id is not null
</select>
<update id="updateExternalUserIdByOldExternalUserId">
UPDATE
tab_haoban_external_clerk_related
SET external_user_id = #{newExternalUserId},
update_time = now()
where external_user_id = #{oldExternalUserId}
and wx_enterprise_id = #{wxEnterpriseId}
</update>
<select id="countByClerkId" resultType="Integer">
select count(*)
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and staff_id = #{staffId}
and clerk_id = #{clerkId}
AND status_flag = 1
</select>
<select id="getByEnterpriseIdAndExternalUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and external_user_id = #{externalUserId}
and status_flag in (3, 4)
order by update_time desc limit 1
</select>
<select id="getByWxUserIdAndWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId} and status_flag in(1,3,4)
</select>
<select id="getByWxEnterpriseIdAndUnionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and wx_enterprise_id = #{wxEnterpriseId}
and unionid = #{unionid}
and status_flag = 1
order by update_time desc limit 1
</select>
<select id="getByEnterpriseIdAndMemberId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and member_id = #{memberId}
<if test="statusFlag != null and statusFlag == 1">
and status_flag in (1,3,4)
</if>
<if test="statusFlag != null and statusFlag == 2">
and status_flag in (0,2)
</if>
order by create_time desc limit 1
</select>
<select id="countByMemberId" resultType="int">
select count(*)
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and member_id = #{memberId}
and status_flag = 1
</select>
<select id="getIdList" resultType="string">
select external_clerk_related_id from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId} and member_id = #{memberId} and status_flag = 1
</select>
<update id="updateMemberByIdList">
UPDATE
tab_haoban_external_clerk_related
SET member_id=#{memberId},
update_time = now()
where external_clerk_related_id in
<foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
and status_flag = 1
</update>
<select id="listPageByWxenterpriseId" resultMap="BaseResultMap">
select DISTINCT(external_user_id) external_user_id , create_time from tab_haoban_external_clerk_related where wx_enterprise_id = #{wxEnterpriseId} and
<if test="type==0">
status_flag in (1)
</if>
<if test="type==1">
status_flag in (3,4)
</if>
limit ${startItem},${pageSize}
</select>
<select id="getByStoreIdAndStaffId" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where store_id = #{storeId,jdbcType=VARCHAR}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</select>
<select id="listMemberAndClerk" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and clerk_id in
<foreach collection="clerkIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and enterprise_id = #{enterpriseId}
AND status_flag = 1
</select>
<select id="getCountExternalClerk" resultType="java.lang.Integer">
select count(*)
from tab_haoban_external_clerk_related
where
wx_enterprise_id = #{wxEnterpriseId}
and staff_id = #{staffId}
and status_flag in
<foreach collection="statusFlags" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<select id="getCountByMemberId" resultType="java.lang.Integer" parameterType="java.lang.String">
select
count(*)
from tab_haoban_external_clerk_related
where
member_id = #{memberId} and status_flag in (1,3,4)
</select>
<update id="updateClerkInfo">
UPDATE
tab_haoban_external_clerk_related
SET clerk_id = #{newClerkId},
store_id = #{storeId},
update_time = now()
where staff_id = #{staffId}
and clerk_id = #{oldClerkId}
and status_flag in (1,3,4)
</update>
<select id="listByClerkId" resultType="String">
select member_id from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and clerk_id = #{clerkId}
and status_flag = 1
</select>
<update id="updateExternalStatus">
update tab_haoban_external_clerk_related set external_status = #{status} where
external_user_id = #{externalUserid} and wx_enterprise_id = #{wxEnterpriseId}
</update>
<select id="getMemberForExternalId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related where wx_enterprise_id = #{wxEnterpriseId}
and external_user_id = #{externalUserId} and status_flag in (1,3,4) and member_id <![CDATA[ <> '' ]]>
limit 1
</select>
<select id="queryExternalUserIdWithStaffId" resultType="java.lang.String">
SELECT external_user_id from tab_haoban_external_clerk_related
WHERE staff_id = #{staffId}
and status_flag in (1, 3, 4);
</select>
<select id="queryClerkMemberRelations" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and status_flag in (1, 3, 4)
and member_id in
<foreach collection="memberIds" item="memberId" open="(" close=")" separator=",">
#{memberId}
</foreach>
</select>
<select id="listMemberAndStaff" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and staff_id = #{staffId}
and enterprise_id = #{enterpriseId}
AND status_flag = 1
</select>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper">
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
<id column="external_clerk_related_id" property="externalClerkRelatedId" jdbcType="VARCHAR"/>
<result column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR"/>
<result column="enterprise_id" property="enterpriseId" jdbcType="VARCHAR"/>
<result column="store_id" property="storeId" jdbcType="VARCHAR"/>
<result column="member_id" property="memberId" jdbcType="VARCHAR"/>
<result column="unionid" property="unionid" jdbcType="VARCHAR"/>
<result column="external_name" property="externalName" jdbcType="VARCHAR"/>
<result column="head_url" property="headUrl" jdbcType="VARCHAR"/>
<result column="external_user_id" property="externalUserId" jdbcType="VARCHAR"/>
<result column="add_create_time" property="addCreateTime" jdbcType="VARCHAR"/>
<result column="member_unionid_related_id" property="memberUnionidRelatedId" jdbcType="VARCHAR"/>
<result column="clerk_id" property="clerkId" jdbcType="VARCHAR"/>
<result column="staff_id" property="staffId" jdbcType="VARCHAR"/>
<result column="relation_key" property="relationKey" jdbcType="VARCHAR"/>
<result column="status_flag" property="statusFlag" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
external_clerk_related_id, wx_enterprise_id, enterprise_id, store_id, member_id,
unionid, head_url,external_name, add_create_time, member_unionid_related_id, clerk_id, staff_id,
relation_key, status_flag, create_time, update_time,external_user_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where external_clerk_related_id = #{externalClerkRelatedId,jdbcType=VARCHAR}
</select>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
insert into tab_haoban_external_clerk_related
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="externalClerkRelatedId != null">
external_clerk_related_id,
</if>
<if test="wxEnterpriseId != null">
wx_enterprise_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="storeId != null">
store_id,
</if>
<if test="memberId != null">
member_id,
</if>
<if test="unionid != null">
unionid,
</if>
<if test="headUrl != null">
head_url,
</if>
<if test="externalName != null">
external_name,
</if>
<if test="externalUserId != null">
external_user_id,
</if>
<if test="addCreateTime != null">
add_create_time,
</if>
<if test="memberUnionidRelatedId != null">
member_unionid_related_id,
</if>
<if test="clerkId != null">
clerk_id,
</if>
<if test="staffId != null">
staff_id,
</if>
<if test="pushTimes != null">
push_times,
</if>
<if test="relationKey != null">
relation_key,
</if>
<if test="statusFlag != null">
status_flag,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="selfExternalUserid != null">
self_external_userid,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="externalClerkRelatedId != null">
#{externalClerkRelatedId,jdbcType=VARCHAR},
</if>
<if test="wxEnterpriseId != null">
#{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="storeId != null">
#{storeId,jdbcType=VARCHAR},
</if>
<if test="memberId != null">
#{memberId,jdbcType=VARCHAR},
</if>
<if test="unionid != null">
#{unionid,jdbcType=VARCHAR},
</if>
<if test="headUrl != null">
#{headUrl,jdbcType=VARCHAR},
</if>
<if test="externalName != null">
#{externalName,jdbcType=VARCHAR},
</if>
<if test="externalUserId != null">
#{externalUserId,jdbcType=VARCHAR},
</if>
<if test="addCreateTime != null">
#{addCreateTime,jdbcType=VARCHAR},
</if>
<if test="memberUnionidRelatedId != null">
#{memberUnionidRelatedId,jdbcType=VARCHAR},
</if>
<if test="clerkId != null">
#{clerkId,jdbcType=VARCHAR},
</if>
<if test="staffId != null">
#{staffId,jdbcType=VARCHAR},
</if>
<if test="pushTimes != null">
#{pushTimes},
</if>
<if test="relationKey != null">
#{relationKey,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null">
#{statusFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="selfExternalUserid != null">
#{selfExternalUserid},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
<set>
<if test="wxEnterpriseId != null">
wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
</if>
<if test="storeId != null">
store_id = #{storeId,jdbcType=VARCHAR},
</if>
<if test="memberId != null">
member_id = #{memberId,jdbcType=VARCHAR},
</if>
<if test="unionid != null">
unionid = #{unionid,jdbcType=VARCHAR},
</if>
<if test="headUrl != null">
head_url = #{headUrl,jdbcType=VARCHAR},
</if>
<if test="externalName != null">
external_name = #{externalName,jdbcType=VARCHAR},
</if>
<if test="externalUserId != null">
external_user_id = #{externalUserId,jdbcType=VARCHAR},
</if>
<if test="addCreateTime != null">
add_create_time = #{addCreateTime,jdbcType=VARCHAR},
</if>
<if test="memberUnionidRelatedId != null">
member_unionid_related_id = #{memberUnionidRelatedId,jdbcType=VARCHAR},
</if>
<if test="clerkId != null">
clerk_id = #{clerkId,jdbcType=VARCHAR},
</if>
<if test="staffId != null">
staff_id = #{staffId,jdbcType=VARCHAR},
</if>
<if test="relationKey != null">
relation_key = #{relationKey,jdbcType=VARCHAR},
</if>
<if test="statusFlag != null">
status_flag = #{statusFlag,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where external_clerk_related_id = #{externalClerkRelatedId,jdbcType=VARCHAR}
</update>
<select id="selectByClerkIdAndExternalUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where clerk_id = #{clerkId,jdbcType=VARCHAR}
and external_user_id = #{externalUserId}
and status_flag = 1
</select>
<update id="delByUserIdAndExternalUserId">
update tab_haoban_external_clerk_related
set status_flag = 2,
update_time = now()
where external_user_id = #{externalUserId}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</update>
<update id="delByUserIdAndExternalUserIdBatch"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set
status_flag = 2,
update_time = now()
where
wx_enterprise_id=#{wxEnterpriseId}
and staff_id = #{staffId}
and status_flag in(1,3,4)
and external_user_id in
<foreach collection="externalUserIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="delByClerkIdAndStaffId"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set status_flag = 2,
update_time = now()
where clerk_id = #{clerkId,jdbcType=VARCHAR}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</update>
<update id="delByStoreIdAndStaffId"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set status_flag = 2,
update_time = now()
where store_id = #{storeId,jdbcType=VARCHAR}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</update>
<update id="delByStoreIds"
parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set
status_flag = 2,
update_time = now()
where store_id IN
<foreach collection="storeIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and status_flag in(1,3,4)
</update>
<update id="cleanStaffRelated" parameterType="com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated">
update tab_haoban_external_clerk_related
set
status_flag = 2,
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and staff_id IN
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
and status_flag = 1
</update>
<select id="listByExTernalUseridAndWxUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and external_user_id = #{externalUserid}
and status_flag = #{statusFlag}
</select>
<select id="listByExternalUseridAndWxEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where external_user_id = #{externalUserid} and wx_enterprise_id = #{wxEnterpriseId}
<if test="statusFlags != null">
and status_flag IN
<foreach collection="statusFlags" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
</select>
<select id="listByExTernalUseridAndWxUserIdAllStatus" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and external_user_id = #{externalUserid}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag in(1,3,4)
</select>
<select id="listByEnterpriseIdAndDate" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where status_flag = 1
and enterprise_id = #{enterpriseId}
<if test="date != null">
and TO_DAYS(create_time) <![CDATA[ >= ]]> TO_DAYS(#{date,jdbcType=TIMESTAMP})
</if>
</select>
<select id="pageMemberUnionByParams" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and status_flag = 1
and member_id in
<foreach item="memberId" index="index" collection="sendMemberIds" open="(" separator="," close=")">
#{memberId, jdbcType=CHAR}
</foreach>
and staff_id in
<foreach item="staffId" index="index" collection="staffIdList" open="(" separator="," close=")">
#{staffId, jdbcType=CHAR}
</foreach>
and member_id is not null
group by external_user_id
</select>
<select id="listByWxEnterpriseIdAndWxUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<select id="listByWxEnterpriseIdAndWxUserIds" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id in
<foreach item="staffId" index="index" collection="staffIdList" open="(" separator="," close=")">
#{staffId, jdbcType=CHAR}
</foreach>
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<select id="getByMemberId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and member_id = #{memberId}
and status_flag = 1
and external_user_id is not null
order by update_time desc
limit 1
</select>
<select id="listExternalByUnionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and unionid = #{unionId}
and status_flag = 1
</select>
<select id="getByRelationKey" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where
relation_key = #{relationKey}
<if test="filterMember==1">
and member_id is null
</if>
and status_flag != 2
order by create_time desc limit 1
</select>
<select id="listByWxEnterpriseIdAndWxUserIdAndStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag in
<foreach collection="statusFlags" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<update id="pushExternalByRelationKey">
update tab_haoban_external_clerk_related
set status_flag = 4,
push_times =push_times + 1,
update_time = now()
where relation_key = #{relationKey,jdbcType=VARCHAR}
and status_flag in (3, 4)
</update>
<select id="getExternalClerkByWxUserIdAncExternalUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and external_user_id = #{externalUserId}
and status_flag in(1,3,4)
order by update_time desc limit 1
</select>
<select id="listByMemberIdAndWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and member_id = #{memberId}
and status_flag = 1
</select>
<select id="listByMemberIdList" resultType="com.gic.haoban.manage.api.dto.ExternalClerkRelatedDTO">
select
member_id memberId , external_user_id externalUserId
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
and wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and status_flag = 1 and external_status = 1
and external_user_id is not null
group by member_id
</select>
<select id="getLastByExTernalUseridAndWxUserIdNoStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and staff_id = #{staffId}
and external_user_id = #{externalUserid}
order by create_time desc limit 1
</select>
<select id="listByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and external_clerk_related_id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<select id="listMemberIdByEnterpriseId" resultType="String">
select member_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and status_flag in (1, 3, 4)
order by create_time
</select>
<select id="listMemberIdsByMemberIds" resultType="String">
select
member_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and member_id in
<foreach collection="memberIds" open="(" separator="," close=")" item="item">
#{item}
</foreach>
and status_flag = 1
</select>
<select id="listByMemberId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where member_id = #{memberId}
and status_flag = 1
<if test="enterpriseId != null and enterpriseId != ''">
and enterprise_id = #{enterpriseId}
</if>
</select>
<select id="listStoreIdByMemberId" resultType="string">
select
store_id
from tab_haoban_external_clerk_related
where member_id = #{memberId}
and status_flag = 1
</select>
<select id="listByExternalUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
and external_user_id = #{externalUserId}
</select>
<update id="updateMemberIdByMemberId">
UPDATE
tab_haoban_external_clerk_related
SET member_id=#{memberId},
update_time = now()
where member_id = #{oldMemberId}
and enterprise_id = #{enterpriseId} and status_flag = 1
</update>
<update id="updateStatusByMemberId">
UPDATE
tab_haoban_external_clerk_related
SET status_flag = 2,
update_time = now()
where member_id = #{memberId}
and enterprise_id = #{enterpriseId}
</update>
<select id="getByMemberIdAndStaffId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where
member_id = #{memberId}
and enterprise_id = #{enterpriseId}
AND staff_id = #{staffId}
AND status_flag = 1 limit 1
</select>
<select id="getByUnionIdAndStaffId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where
member_id = #{memberId}
and enterprise_id = #{enterpriseId}
AND unionid = #{unionid}
AND status_flag = 1 limit 1
</select>
<select id="pageExternalByEnterpriseId" resultMap="BaseResultMap">
select wx_enterprise_id,
enterprise_id,
external_user_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
AND status_flag = 1
and external_user_id is not null
</select>
<update id="updateExternalUserIdByOldExternalUserId">
UPDATE
tab_haoban_external_clerk_related
SET external_user_id = #{newExternalUserId},
update_time = now()
where external_user_id = #{oldExternalUserId}
and wx_enterprise_id = #{wxEnterpriseId}
</update>
<select id="countByClerkId" resultType="Integer">
select count(*)
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and staff_id = #{staffId}
and clerk_id = #{clerkId}
AND status_flag = 1
</select>
<select id="getByEnterpriseIdAndExternalUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and external_user_id = #{externalUserId}
and status_flag in (3, 4)
order by update_time desc limit 1
</select>
<select id="getByWxUserIdAndWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId} and status_flag in(1,3,4)
</select>
<select id="getByWxEnterpriseIdAndUnionId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and wx_enterprise_id = #{wxEnterpriseId}
and unionid = #{unionid}
and status_flag = 1
order by update_time desc limit 1
</select>
<select id="getByEnterpriseIdAndMemberId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and member_id = #{memberId}
<if test="statusFlag != null and statusFlag == 1">
and status_flag in (1,3,4)
</if>
<if test="statusFlag != null and statusFlag == 2">
and status_flag in (0,2)
</if>
order by create_time desc limit 1
</select>
<select id="countByMemberId" resultType="int">
select count(*)
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId}
and member_id = #{memberId}
and status_flag = 1
</select>
<select id="getIdList" resultType="string">
select external_clerk_related_id from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId} and member_id = #{memberId} and status_flag = 1
</select>
<update id="updateMemberByIdList">
UPDATE
tab_haoban_external_clerk_related
SET member_id=#{memberId},
update_time = now()
where external_clerk_related_id in
<foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
and status_flag = 1
</update>
<select id="listPageByWxenterpriseId" resultMap="BaseResultMap">
select DISTINCT(external_user_id) external_user_id , create_time from tab_haoban_external_clerk_related where wx_enterprise_id = #{wxEnterpriseId} and
<if test="type==0">
status_flag in (1)
</if>
<if test="type==1">
status_flag in (3,4)
</if>
limit ${startItem},${pageSize}
</select>
<select id="getByStoreIdAndStaffId" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where store_id = #{storeId,jdbcType=VARCHAR}
and staff_id = #{staffId}
and status_flag in (1, 3, 4)
</select>
<select id="listMemberAndClerk" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and clerk_id in
<foreach collection="clerkIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and enterprise_id = #{enterpriseId}
AND status_flag = 1
</select>
<select id="getCountExternalClerk" resultType="java.lang.Integer">
select count(*)
from tab_haoban_external_clerk_related
where
wx_enterprise_id = #{wxEnterpriseId}
and staff_id = #{staffId}
and status_flag in
<foreach collection="statusFlags" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<select id="getCountByMemberId" resultType="java.lang.Integer" parameterType="java.lang.String">
select
count(*)
from tab_haoban_external_clerk_related
where
member_id = #{memberId} and status_flag in (1,3,4)
</select>
<update id="updateClerkInfo">
UPDATE
tab_haoban_external_clerk_related
SET clerk_id = #{newClerkId},
store_id = #{storeId},
update_time = now()
where staff_id = #{staffId}
and clerk_id = #{oldClerkId}
and status_flag in (1,3,4)
</update>
<select id="listByClerkId" resultType="String">
select member_id from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and clerk_id = #{clerkId}
and status_flag = 1
</select>
<update id="updateExternalStatus">
update tab_haoban_external_clerk_related set external_status = #{status} where
external_user_id = #{externalUserid} and wx_enterprise_id = #{wxEnterpriseId}
</update>
<select id="getMemberForExternalId" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related where wx_enterprise_id = #{wxEnterpriseId}
and external_user_id = #{externalUserId} and status_flag in (1,3,4) and member_id <![CDATA[ <> '' ]]>
limit 1
</select>
<select id="queryExternalUserIdWithStaffId" resultType="java.lang.String">
SELECT external_user_id from tab_haoban_external_clerk_related
WHERE staff_id = #{staffId}
and status_flag in (1, 3, 4);
</select>
<select id="queryClerkMemberRelations" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where staff_id = #{staffId}
and status_flag in (1, 3, 4)
and member_id in
<foreach collection="memberIds" item="memberId" open="(" close=")" separator=",">
#{memberId}
</foreach>
</select>
<select id="listMemberAndStaff" resultType="java.lang.String">
select member_id
from tab_haoban_external_clerk_related
where member_id in
<foreach collection="memberIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and staff_id = #{staffId}
and enterprise_id = #{enterpriseId}
AND status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -116,8 +116,8 @@ public class GroupMessageServiceTest {
qywxMomentInfoQDTO.setEndTime(1681906519L);
qywxMomentInfoQDTO.setCreatorId("wo59NLDQAAbjSBA575NouC1pUYQgCOtw");
qywxMomentInfoQDTO.setPageSize(20);
ServiceResponse<QywxMomentRespDTO> serviceResponse = qywxSuiteApiService.queryQywxMomentList(qywxMomentInfoQDTO);
System.out.println(JSON.toJSONString(serviceResponse));
//ServiceResponse<QywxMomentRespDTO> serviceResponse = qywxSuiteApiService.queryQywxMomentList(qywxMomentInfoQDTO);
//System.out.println(JSON.toJSONString(serviceResponse));
}
@Test
......
......@@ -103,7 +103,7 @@ public class MaterialReportServiceTest {
// params.put("t", 1);
// params.put("d", "04");
String s = params.toJSONString();
String s1 = NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, s);
String s1 = NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH, s);
System.out.println("/pages/route/index?pageType=hbapp_material_report&data=".length());
System.out.println(s1);
System.out.println(s1.length());
......
......@@ -124,8 +124,8 @@ public class NotityTest {
articleInfo.setPicurl("https://platform-1251519181.cos.ap-shanghai.myqcloud.com/image/newdmwltest/enterprise_common-e1e8b3d46fdb4486ad545aae6cba67a1.png");
messageDTO.setArticleMessages(Arrays.asList(articleInfo));
boolean b = qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
System.out.println(b);
/*boolean b = qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
System.out.println(b);*/
}
@Test
......@@ -138,7 +138,7 @@ public class NotityTest {
search.setSuiteid(config.getWxSuiteid());
search.setChatType("single");
Date date = DateUtils.addDays(new Date(), -1);
ServiceResponse<QywxGroupMsgResp> serviceResponse = qywxSuiteApiService.queryQywxGroupMessageList(search);
//ServiceResponse<QywxGroupMsgResp> serviceResponse = qywxSuiteApiService.queryQywxGroupMessageList(search);
}
......
......@@ -69,7 +69,7 @@ public class test {
// params.put("t", 1);
// params.put("d", "04");
String s = params.toJSONString();
String s1 = NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY, s);
String s1 = NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.MATERIAL_REPORT_NOTIFY_MONTH, s);
System.out.println("/pages/route/index?pageType=hbapp_material_report&data=".length());
System.out.println(s1);
System.out.println(s1.length());
......
package com.gic.haoban.manage.web.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.DateUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.*;
import com.gic.enterprise.api.service.AuthorizeService;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.anno.IgnoreLogin;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService;
import com.gic.haoban.manage.api.service.out.SecretSettingApiService;
import com.gic.haoban.manage.web.config.Config;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.MiniprogramSettingQo;
import com.gic.haoban.manage.web.vo.StoreVo;
import com.gic.haoban.manage.web.vo.*;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxCorpApiService;
import com.gic.wechat.token.api.dto.QywxCorpInfoDTO;
import com.gic.wechat.token.api.service.QywxTokenManageService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
@RestController
public class WxEnterpriseController extends WebBaseController {
private static final Logger logger = LoggerFactory.getLogger(WxEnterpriseController.class);
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private StoreService storeService;
@Autowired
private QywxTokenManageService qywxTokenManageService;
@Autowired
private Config config;
@Autowired
private QywxCorpApiService qywxCorpApiService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired
private MaterialApiService materialApiService;
@Autowired
private AuthorizeService authorizeService;
@Autowired
private HaobanUserApiService haobanUserApiService ;
@Autowired
private HaobanQywxFeeApiService haobanQywxFeeApiService;
@Autowired
private SecretSettingApiService secretSettingApiService ;
@Autowired
private ClerkService clerkService;
//授权企业列表
@RequestMapping("wxa-enterprise-list")
public HaobanResponse wxEnterpriseList() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String phoneNumber = login.getPhoneNumber() ;
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId,phoneNumber,true);
List<EnterpriseDetailVO> detailVOS = EntityUtil.changeEntityListByOrika(EnterpriseDetailVO.class, list);
if (CollectionUtil.isNotEmpty(detailVOS)) {
List<String> enterpriseIds = detailVOS.stream().map(s -> s.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDTO> enterpriseList = enterpriseService.listEnterpriseByIds(enterpriseIds);
Map<String, EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriseList, "enterpriseId");
for (EnterpriseDetailVO dto : detailVOS) {
List<EnterpriseWxaRelationDTO> relationDTOS = authorizeService.queryList(dto.getEnterpriseId());
EnterpriseDTO enterpriseDTO = map.get(dto.getEnterpriseId());
EnterpriseWxaRelationDTO wxaRelationDTO = relationDTOS.stream().filter(mid -> mid.getWxaAppkey().equals(enterpriseDTO.getMallMiniprogramAppid())).findFirst().orElse(null);
if (wxaRelationDTO != null) {
dto.setEnterpriseName(enterpriseDTO.getEnterpriseName());
dto.setImageUrl(wxaRelationDTO.getAuthImg());
dto.setAppId(wxaRelationDTO.getWxaAppkey());
dto.setMiniprogramName(wxaRelationDTO.getAuthName());
dto.setTitle(wxaRelationDTO.getAuthName());
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, detailVOS);
}
//授权企业列表 filteRight 是否过滤无登录权限的列表
@RequestMapping("wx-enterprise-list")
public HaobanResponse wxaEnterpriseList(@RequestParam(defaultValue="0") int filteRight) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String phoneNumber = login.getPhoneNumber() ;
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId,phoneNumber,filteRight==1);
String userId = login.getHanbaoUserId() ;
HaobanUserDTO dto = this.haobanUserApiService.selectById(userId) ;
if(null != dto) {
String eid = dto.getDefaultGicEid() ;
for(EnterpriseDetailDTO item : list) {
if(null != eid && eid.equals(item.getEnterpriseId())) {
item.setDefaultFlag(1);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, list);
}
//企业信息
@IgnoreLogin
@RequestMapping("wxEnterprise-detail")
public HaobanResponse enterpriseDetail(String wxEnterpriseId) {
if (StringUtils.isEmpty(wxEnterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
return resultResponse(HaoBanErrCode.ERR_100018);
}
wxEnterpriseDTO.setSmallVersion("免费版");
wxEnterpriseDTO.setStoreTotal(departmentApiService.totalStoreCountByEnterpriseId(wxEnterpriseId));
WxEnterpriseVO vo = com.gic.commons.util.EntityUtil.changeEntityNew( WxEnterpriseVO.class, wxEnterpriseDTO) ;
vo.setCorpid(getCorpid(wxEnterpriseDTO));
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
//企业信息
@IgnoreLogin
@RequestMapping("wxEnterprise-refresh")
public HaobanResponse enterpriseRefresh(String wxEnterpriseId) {
if (StringUtils.isEmpty(wxEnterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
return this.fail("自建应用不能刷新");
}
QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(qwDTO.getThirdCorpid(), config.getWxSuiteid());
if (dto == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
Long verifiedEndTime = dto.getVerifiedEndTime();
logger.info("【企业同步】dto={}", JSON.toJSONString(dto));
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, dto);
if (verifiedEndTime != null) {
wxDTO.setVerifiedEndTime(new Date(verifiedEndTime * 1000));
}
wxDTO.setWxEnterpriseId(wxEnterpriseId);
Integer contactFlag = wxEnterpriseDTO.getContactFlag();
if (contactFlag == 0) {
wxDTO.setContactFlag(1);
}
wxEnterpriseApiService.update(wxDTO);
WxEnterpriseVO vo = com.gic.commons.util.EntityUtil.changeEntityNew( WxEnterpriseVO.class, wxEnterpriseDTO) ;
vo.setCorpid(getCorpid(wxEnterpriseDTO));
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
private String getCorpid(WxEnterpriseDTO wxEnterpriseDTO) {
Integer wxType = wxEnterpriseDTO.getWxSecurityType() ;
String wxEnterpriseId = wxEnterpriseDTO.getWxEnterpriseId() ;
if(null == wxType || 0==wxType) {
this.wxEnterpriseApiService.updateWxSecurityType(wxEnterpriseId);
wxType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ;
}
String desc = " (企微加密方式待确认,请联系运营人员) " ;
if(wxType==1) {
desc = "(全明文)" ;
}
if(wxType==2) {
desc = "(全密文)" ;
}
if(wxType==3) {
desc = "(第三方密文,代开明文)" ;
}
if(wxType==4) {
desc = "(第三方明文,代开密文)" ;
}
if(wxType==5) {
desc = " ( "+wxEnterpriseDTO.getWxaAppid() +" / " + wxEnterpriseDTO.getUrlHost()+") " ;
}
int newType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ;
String diff = "";
if(null != wxType && wxType.intValue() != newType && wxType != 5) {
diff = "*";
}
return Arrays.asList(wxEnterpriseDTO.getWxCorpid(),wxEnterpriseDTO.getOpenCorpid()).stream().filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.joining(" / ")) + desc + diff;
}
//gic企业列表
@IgnoreLogin
@RequestMapping("enterprise-search")
public HaobanResponse gicEnterpriseDetail(String enterpriseId) {
if (org.apache.commons.lang.StringUtils.isEmpty(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
EnterpriseSearchVO vo = new EnterpriseSearchVO();
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId);
if (enterprise != null) {
vo.setEnterpriseId(enterpriseId);
vo.setEnterpriseName(enterprise.getEnterpriseName());
vo.setBrandName(enterprise.getBrandName());
ClerkDTO clerk = clerkService.getSuperAdminByEnterpriseId(enterpriseId);
if (clerk != null) {
vo.setClerkId(clerk.getClerkId());
vo.setClerkCode(clerk.getClerkCode());
vo.setClerkName(clerk.getClerkName());
vo.setPhoneNumber(clerk.getPhoneNumber());
vo.setNationCode(clerk.getNationcode());
}
}else {
//enterpriseId 参数可以是企业id,也可以是企业名称
//按名称去查
EnterpriseAndUserDTO dto = enterpriseService.getEnterpriseAndUserByName(enterpriseId);
vo = EntityUtil.changeEntityByJSON(EnterpriseSearchVO.class, dto);
if (vo != null) {
EnterpriseDTO enterprise1 = enterpriseService.getEnterpriseById(vo.getEnterpriseId());
if (enterprise1 != null) {
vo.setBrandName(enterprise1.getBrandName());
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
//溢出门店列表
@RequestMapping("store-full-list")
public HaobanResponse storeFullList(BasePageInfo basePageInfo, String keyWord) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
int maxVersionCount = 0;
List<EnterpriseDetailDTO> enterpriseList = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtil.isEmpty(enterpriseList)) {
return resultResponse(HaoBanErrCode.ERR_10010);
}
List<String> enterpriseIds = enterpriseList.stream().map(s -> s.getEnterpriseId()).collect(Collectors.toList());
//获取门店列表
Page page1 = new Page<>();
page1.setCurrentPage(1);
page1.setPageSize(Integer.MAX_VALUE);
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseIdList(enterpriseIds);
storeSearchDTO.setSearchName(keyWord);
Page storePage = storeService.storeListPage(page1, storeSearchDTO);
if (storePage == null || storePage.getResult() == null) {
return resultResponse(HaoBanErrCode.ERR_10009);
}
List<StoreDTO> t_list = storePage.getResult();
List<String> storeIds = t_list.stream().map(s -> s.getStoreId()).collect(Collectors.toList());
if (StringUtils.isEmpty(keyWord)) {
storeIds = null;
}
Page<DepartmentDTO> page = departmentApiService.pageFullStoreByWxEnterpriseId(wxEnterpriseId, keyWord, storeIds, maxVersionCount, basePageInfo);
List<DepartmentDTO> list = page.getResult();
List<StoreVo> resultList = EntityUtil.changeEntityListByJSON(StoreVo.class, list);
List<String> t_storeIds = list.stream().map(s -> s.getRelatedId()).collect(Collectors.toList());
String[] storeIdArr = t_storeIds.toArray(new String[t_storeIds.size()]);
List<StoreDTO> storeList = storeService.getStores(storeIdArr);
Map<String, StoreDTO> map = com.gic.commons.util.CollectionUtil.toMap(storeList, "storeId");
for (StoreVo vo : resultList) {
if (map.get(vo.getRelatedId()) != null) {
vo.setStoreCode(map.get(vo.getRelatedId()).getStoreCode());
vo.setStoreId(map.get(vo.getRelatedId()).getStoreId());
vo.setStoreName(map.get(vo.getRelatedId()).getStoreName());
}
}
Page resultPage = new Page<>();
resultPage.setCurrentPage(page.getCurrentPage());
resultPage.setPageSize(page.getPageSize());
resultPage.setTotalCount(page.getTotalCount());
resultPage.setResult(resultList);
return resultResponse(HaoBanErrCode.ERR_1, resultPage);
}
//微信企业是否设置key
@RequestMapping("is-wx-enterprise-secret-set")
public HaobanResponse isWxEnterpriseSecretSet() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<SecretSettingDTO> listSecret = wxEnterpriseApiService.listSecret(wxEnterpriseId);
if (CollectionUtils.isEmpty(listSecret)) {
return resultResponse(HaoBanErrCode.ERR_1, false);
}
Set<Integer> secretTypeList = listSecret.stream().filter(secretSettingDTO -> secretSettingDTO.getCheckFlag() == 1).map(secretSettingDTO -> secretSettingDTO.getSecretType()).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(secretTypeList)) {
return resultResponse(HaoBanErrCode.ERR_1, false);
}
// 如果是第三方校验待开发
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
if ((secretTypeList.contains(SecretTypeEnum.SELF_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}else {
if ((secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}
return resultResponse(HaoBanErrCode.ERR_1, false);
}
/**
* 微信企业绑定接口绑定通讯录key
*
* @param wxSecretKey
* @return
*/
@RequestMapping("wx-enterprise-wx-secret-set")
public HaobanResponse wxEnterpriseWxSecretSet(String wxSecretKey) {
if (StringUtils.isAnyBlank(wxSecretKey)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if (qwDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
wxSecretKey = wxSecretKey.trim();
String token = this.qywxCorpApiService.getToken(qwDTO.getDkCorpid(), wxSecretKey);
logger.info("查询token={}", token) ;
if(StringUtils.isEmpty(token) || token.length() < 10) {
return this.fail("请确认secret是否正确") ;
}
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.SELF_APP.getVal(), null);
if (null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
secretSetting.setSecretType(SecretTypeEnum.SELF_APP.getVal());
secretSetting.setSecretName(SecretTypeEnum.SELF_APP.getName());
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setEnterpriseId("-1");
secretSetting.setSecretVal(wxSecretKey);
secretSetting.setCheckFlag(1);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_1, true);
}
/**
* 微信企业会员小程序
*
* @param memberSecret
* @param enterpriseId
* @param secretName
* @return
*/
@RequestMapping("wx-enterprise-member-secret-set")
public HaobanResponse wxEnterpriseMemberSecretSet(String secretId,String memberSecret, String enterpriseId, String secretName) {
if (StringUtils.isAnyBlank(memberSecret,enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterprise == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
memberSecret = memberSecret.trim();
SecretSettingDTO secretSetting = null ;
if (StringUtils.isNotBlank(secretId)) {
secretSetting = wxEnterpriseApiService.getSecretSettingById(secretId);
}
if(null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
List<SecretSettingDTO> enList = this.secretSettingApiService.exsitGicEidMemberApp(wxEnterpriseId) ;
if(CollectionUtils.isNotEmpty(enList)) {
Map<String,SecretSettingDTO> map = enList.stream().collect(Collectors.toMap(SecretSettingDTO::getEnterpriseId, dto->dto,(k1,k2)->k1));
if(StringUtils.isEmpty(secretId)) {
if(null != map.get(enterpriseId)) {
return this.fail("此商户小程序已存在") ;
}
}else {
if(null != map.get(enterpriseId) && !secretId.equals(map.get(enterpriseId).getSecretId())) {
return this.fail("此商户小程序已存在") ;
}
}
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
String token = this.qywxCorpApiService.getToken(qwDTO.getMemberCorpid(), memberSecret);
logger.info("查询token", token) ;
if(StringUtils.isEmpty(token) || token.length() < 10) {
return this.fail("请确认secret是否正确") ;
}
secretSetting.setSecretType(SecretTypeEnum.MEMBER_WAPP.getVal());
secretSetting.setSecretName(secretName);
secretSetting.setEnterpriseId(enterpriseId);
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setSecretVal(memberSecret);
secretSetting.setCheckFlag(1);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_1, true);
}
/**
* 企微相关密钥列表
*
* @return
*/
@RequestMapping("secret-list")
public HaobanResponse secretList() {
String wxEnterpriseId = "";
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterprise == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
List<SecretSettingDTO> listSecret = wxEnterpriseApiService.listSecret(wxEnterpriseId);
List<SecretSettingVO> listRet = EntityUtil.changeEntityListByJSON(SecretSettingVO.class, listSecret);
if (CollectionUtils.isNotEmpty(listRet)) {
listRet.forEach(secretSettingVO -> {
if ((!StringUtils.isEmpty(secretSettingVO.getEnterpriseId())) && (!secretSettingVO.getEnterpriseId().equals("-1"))) {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(secretSettingVO.getEnterpriseId());
secretSettingVO.setEnterpriseName(enterpriseDTO == null ? "" : enterpriseDTO.getBrandName());
}
});
}
return resultResponse(HaoBanErrCode.ERR_1, listRet);
}
//微信企业会员小程序
@RequestMapping("member-secret-del")
public HaobanResponse delMemberSecret(String secretId) {
if (StringUtils.isAnyBlank(secretId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
boolean b = wxEnterpriseApiService.delSecretSetting(secretId);
return resultResponse(HaoBanErrCode.ERR_1, b);
}
/**
* 刷新企业微信好友
*
* @return
*/
@RequestMapping("/fresh-wx-friend")
public HaobanResponse freshWxFriend() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String dayKey = "haoban_fresh-wx-friend-day" + wxEnterpriseId + DateUtil.dateToStr(new Date(), "yyyy-MM-dd");
String monthKey = "haoban_fresh-wx-friend-month" + wxEnterpriseId + DateUtil.dateToStr(new Date(), "yyyy-MM");
String dateKey = "haoban_fresh-wx-friend-date" + wxEnterpriseId;
Integer dayCount = RedisUtil.getCache(dayKey) == null ? 0 : Integer.parseInt(RedisUtil.getCache(dayKey).toString());
Integer monthCount = RedisUtil.getCache(monthKey) == null ? 0 : Integer.parseInt(RedisUtil.getCache(monthKey).toString());
if (dayCount >= 1) {
return resultResponse(HaoBanErrCode.ERR_100019);
}
if (monthCount >= 3) {
return resultResponse(HaoBanErrCode.ERR_100020);
}
String taskId = dealSyncOperationApiService.createWxFriendTask(wxEnterpriseId, "刷新企微好友", login.getClerkId(), "刷新企微好友");
if (StringUtils.isEmpty(taskId)) {
return resultResponse(HaoBanErrCode.ERR_100021);
}
RedisUtil.setCache(dayKey, dayCount + 1);
RedisUtil.setCache(monthKey, monthCount + 1);
RedisUtil.setCache(dateKey, DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19));
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 获取企业微信好友刷新时间
*
* @return
*/
@RequestMapping("/get-fresh-detail")
public HaobanResponse getFreshDetail() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String dateKey = "haoban_fresh-wx-friend-date" + wxEnterpriseId;
RedisUtil.getCache(dateKey);
return resultResponse(HaoBanErrCode.ERR_1, RedisUtil.getCache(dateKey));
}
/**
* 微信企业绑定详情
*
* @param enterpriseId
* @return
*/
@RequestMapping("wx-enterprise-bind-detail")
public HaobanResponse wxEnterpriseBindDetail(String enterpriseId) {
if (StringUtils.isAnyBlank(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseRelationDetailDTO bindInfo = wxEnterpriseRelatedApiService.getEnterpriseBindInfo(wxEnterpriseId, enterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, bindInfo);
}
/**
* 绑定门店列表
*
* @param enterpriseId
* @return
*/
@RequestMapping("bind-store-list")
public HaobanResponse bindStoreList(String enterpriseId, String search, BasePageInfo basePageInfo) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
Page<BindStoreInfoDTO> retPage = wxEnterpriseRelatedApiService.pageBindStoreByEnterpriseId(wxEnterpriseId, enterpriseId, search, basePageInfo);
return resultResponse(HaoBanErrCode.ERR_1, retPage);
}
/**
* 绑定门店列表
*
* @param enterpriseId
* @return
*/
@RequestMapping("flush-bind-store-list")
public HaobanResponse flushBindStoreList(String enterpriseId) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
ServiceResponse response = wxEnterpriseRelatedApiService.flushBindStoreByEnterpriseId(enterpriseId, wxEnterpriseId, login.getClerkId(), ChannelCodeEnum.SYNC_UNBIND.getCode());
logger.info("返回信息:{}", JSONObject.toJSONString(response));
if (response.getCode() != 1) {
HaoBanErrCode.ERR_DEFINE.setMsg(response.getMessage());
return resultResponse(HaoBanErrCode.ERR_DEFINE);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 绑定小程序配置列表
*
* @return
*/
@RequestMapping("list-miniprogram-setting")
public HaobanResponse miniprogramList() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<MiniprogramSettingDTO> settingDTOS = wxEnterpriseApiService.listMiniprogramSetting(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, settingDTOS);
}
/**
* 保存小程序配置列表
*
* @return
*/
@RequestMapping("save-miniprogram-setting")
public HaobanResponse saveMiniprogram(MiniprogramSettingQo settingDTO) {
if (StringUtils.isAnyBlank(settingDTO.getAppId(),
settingDTO.getImageUrl(), settingDTO.getMiniprogramName(), settingDTO.getTitle())) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
settingDTO.setWxEnterpriseId(wxEnterpriseId);
settingDTO.setEnterpriseId(login.getEnterpriseId());
MiniprogramSettingDTO miniprogramSettingDTO = wxEnterpriseApiService.getMiniprogramSettingByAppId(wxEnterpriseId, settingDTO.getAppId());
if (null != miniprogramSettingDTO
&& (!miniprogramSettingDTO.getMiniprogramSettingId().equals(settingDTO.getMiniprogramSettingId()))) {
return resultResponse(HaoBanErrCode.ERR_100031);
}
wxEnterpriseApiService.saveMiniprogramSetting(EntityUtil.changeEntityByOrika(MiniprogramSettingDTO.class, settingDTO));
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 获取小程序配置
*
* @return
*/
@RequestMapping("get-miniprogram-setting")
public HaobanResponse getMiniprogram(String enterpriseId) {
if (StringUtils.isEmpty(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
MiniprogramSettingDTO settingDTO = wxEnterpriseApiService.getMiniprogramSettingByEid(wxEnterpriseId, enterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, settingDTO);
}
/**
* 删除小程序配置
*
* @return
*/
@RequestMapping("del-miniprogram-setting")
public HaobanResponse delMiniprogram(String id) {
if (StringUtils.isEmpty(id)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
wxEnterpriseApiService.delMiniprogramSettingByEid(id);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 分析素材
*
* @return
*/
@RequestMapping("/agent-wx-enterprise-list")
public HaobanResponse materialShare(String materialId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
List<EnterpriseDetailDTO> detailDTOS = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
List<String> enterpriseIds = detailDTOS.stream().filter(dto -> dto.getWxEnterpriseType() == 0).map(dto -> dto.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDetailDTO> retList = wxEnterpriseRelatedApiService.listEnterpriseByEnterpriseIds(enterpriseIds);
Map<String, EnterpriseDetailDTO> detailDTOMap = retList.stream().filter(dto -> dto.getWxEnterpriseType() == 1).collect(Collectors.toMap(dto -> dto.getWxEnterpriseId(), dto -> dto, (ne, ol) -> ol));
Collection<EnterpriseDetailDTO> values = detailDTOMap.values();
List<AgentEnterpriseDTO> enterpriseList = EntityUtil.changeEntityListByOrika(AgentEnterpriseDTO.class, values);
if (CollectionUtils.isNotEmpty(values)) {
List<MaterialDTO> materialDTOS = materialApiService.listByFromMaterialId(materialId);
List<String> wxEids = new ArrayList<>();
if (CollectionUtils.isNotEmpty(materialDTOS)) {
wxEids = materialDTOS.stream().map(dto -> dto.getWxEnterpriseId()).collect(Collectors.toList());
}
List<String> finalWxEids = wxEids;
for(AgentEnterpriseDTO dto : enterpriseList) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(dto.getWxEnterpriseId());
if(null == wxEnterpriseDTO) {
continue ;
}
logger.info("wxEnterpriseDTO={},dto={}", JSON.toJSONString(wxEnterpriseDTO),JSON.toJSONString(dto));
dto.setEnterpriseName(wxEnterpriseDTO.getCorpName());
if (finalWxEids.contains(dto.getWxEnterpriseId())) {
dto.setBindFlag(1);
} else {
dto.setBindFlag(0);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, enterpriseList);
}
/**
* 删除欢迎语
*
* @return
*/
@RequestMapping("del-welcome")
public HaobanResponse delWelcome() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
wxEnterpriseApiService.delWelcome(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 欢迎语开启关闭
*
* @return
*/
@RequestMapping("set-welcome")
public HaobanResponse setWelcome(int openFlag) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
wxEnterpriseApiService.setWelcome(wxEnterpriseId, openFlag);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 授权绑定-设置导购编辑权限
*
* @return
*/
@IgnoreLogin
@RequestMapping("set-clerk-edit")
public HaobanResponse setClerkEdit(String wxEnterprieseRelatedId, int clerkEditFlag) {
if (StringUtils.isBlank(wxEnterprieseRelatedId)) {
logger.info("缺少参数");
return resultResponse(HaoBanErrCode.ERR_2);
}
boolean b = wxEnterpriseRelatedApiService.setClerkEditFlag(wxEnterprieseRelatedId, clerkEditFlag);
if (b) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_100032);
}
}
/**
* 是否同意授权
*
* @param openFlag
* @return
*/
@RequestMapping("agree_external_userid_flag")
public HaobanResponse agreeExternalUseridFlag(Integer openFlag) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
wxEnterpriseApiService.agreeExternalUseridFlag(wxEnterpriseId, openFlag);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping(path = "/current/enterprise/info")
public RestResponse<?> queryCurrentInfo(){
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
com.gic.api.base.commons.ServiceResponse<EnterpriseDetailDTO> serviceResponse = wxEnterpriseRelatedApiService.queryEnterpriseDetail(loginUser.getWxEnterpriseId(), loginUser.getEnterpriseId());
if (serviceResponse.isSuccess()){
return RestResponse.successResult(serviceResponse.getResult());
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
/**
* 最新一条将要被拦截记录
* @return
*/
@RequestMapping(value = "qywx-fee-wxEnterprise-detail", method = RequestMethod.GET)
public RestResponse qywxFeeWxEnterpriseListDetail() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
HaobanQywxFeeDTO haobanQywxFeeDTO = haobanQywxFeeApiService.queryByWxEnterpriseId(wxEnterpriseId);
if (haobanQywxFeeDTO == null) {
return RestResponse.successResult();
}
List<EnterpriseDetailDTO> enterpriseDetailDTOS = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(enterpriseDetailDTOS)) {
StringBuffer stringBuffer = new StringBuffer();
for (EnterpriseDetailDTO enterpriseDetailDTO : enterpriseDetailDTOS) {
stringBuffer.append(enterpriseDetailDTO.getEnterpriseName()).append(" ");
}
haobanQywxFeeDTO.setEnterpriseNames(stringBuffer.toString());
}
return RestResponse.successResult(haobanQywxFeeDTO);
}
}
package com.gic.haoban.manage.web.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.DateUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.*;
import com.gic.enterprise.api.service.AuthorizeService;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.anno.IgnoreLogin;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService;
import com.gic.haoban.manage.api.service.out.SecretSettingApiService;
import com.gic.haoban.manage.web.config.Config;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.MiniprogramSettingQo;
import com.gic.haoban.manage.web.vo.StoreVo;
import com.gic.haoban.manage.web.vo.*;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxCorpApiService;
import com.gic.wechat.token.api.dto.QywxCorpInfoDTO;
import com.gic.wechat.token.api.service.QywxTokenManageService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.stream.Collectors;
@RestController
public class WxEnterpriseController extends WebBaseController {
private static final Logger logger = LoggerFactory.getLogger(WxEnterpriseController.class);
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private StoreService storeService;
@Autowired
private QywxTokenManageService qywxTokenManageService;
@Autowired
private Config config;
@Autowired
private QywxCorpApiService qywxCorpApiService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired
private MaterialApiService materialApiService;
@Autowired
private AuthorizeService authorizeService;
@Autowired
private HaobanUserApiService haobanUserApiService ;
@Autowired
private HaobanQywxFeeApiService haobanQywxFeeApiService;
@Autowired
private SecretSettingApiService secretSettingApiService ;
@Autowired
private ClerkService clerkService;
//授权企业列表
@RequestMapping("wxa-enterprise-list")
public HaobanResponse wxEnterpriseList() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String phoneNumber = login.getPhoneNumber() ;
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId,phoneNumber,true);
List<EnterpriseDetailVO> detailVOS = EntityUtil.changeEntityListByOrika(EnterpriseDetailVO.class, list);
if (CollectionUtil.isNotEmpty(detailVOS)) {
List<String> enterpriseIds = detailVOS.stream().map(s -> s.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDTO> enterpriseList = enterpriseService.listEnterpriseByIds(enterpriseIds);
Map<String, EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriseList, "enterpriseId");
for (EnterpriseDetailVO dto : detailVOS) {
List<EnterpriseWxaRelationDTO> relationDTOS = authorizeService.queryList(dto.getEnterpriseId());
EnterpriseDTO enterpriseDTO = map.get(dto.getEnterpriseId());
EnterpriseWxaRelationDTO wxaRelationDTO = relationDTOS.stream().filter(mid -> mid.getWxaAppkey().equals(enterpriseDTO.getMallMiniprogramAppid())).findFirst().orElse(null);
if (wxaRelationDTO != null) {
dto.setEnterpriseName(enterpriseDTO.getEnterpriseName());
dto.setImageUrl(wxaRelationDTO.getAuthImg());
dto.setAppId(wxaRelationDTO.getWxaAppkey());
dto.setMiniprogramName(wxaRelationDTO.getAuthName());
dto.setTitle(wxaRelationDTO.getAuthName());
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, detailVOS);
}
//授权企业列表 filteRight 是否过滤无登录权限的列表
@RequestMapping("wx-enterprise-list")
public HaobanResponse wxaEnterpriseList(@RequestParam(defaultValue="0") int filteRight) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String phoneNumber = login.getPhoneNumber() ;
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId,phoneNumber,filteRight==1);
String userId = login.getHanbaoUserId() ;
HaobanUserDTO dto = this.haobanUserApiService.selectById(userId) ;
if(null != dto) {
String eid = dto.getDefaultGicEid() ;
for(EnterpriseDetailDTO item : list) {
if(null != eid && eid.equals(item.getEnterpriseId())) {
item.setDefaultFlag(1);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, list);
}
//企业信息
@IgnoreLogin
@RequestMapping("wxEnterprise-detail")
public HaobanResponse enterpriseDetail(String wxEnterpriseId) {
if (StringUtils.isEmpty(wxEnterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
return resultResponse(HaoBanErrCode.ERR_100018);
}
wxEnterpriseDTO.setSmallVersion("免费版");
wxEnterpriseDTO.setStoreTotal(departmentApiService.totalStoreCountByEnterpriseId(wxEnterpriseId));
WxEnterpriseVO vo = com.gic.commons.util.EntityUtil.changeEntityNew( WxEnterpriseVO.class, wxEnterpriseDTO) ;
vo.setCorpid(getCorpid(wxEnterpriseDTO));
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
//企业信息
@IgnoreLogin
@RequestMapping("wxEnterprise-refresh")
public HaobanResponse enterpriseRefresh(String wxEnterpriseId) {
if (StringUtils.isEmpty(wxEnterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
return this.fail("已刷新");
}
QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(qwDTO.getThirdCorpid(), config.getWxSuiteid());
if (dto == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
Long verifiedEndTime = dto.getVerifiedEndTime();
logger.info("【企业同步】dto={}", JSON.toJSONString(dto));
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, dto);
if (verifiedEndTime != null) {
wxDTO.setVerifiedEndTime(new Date(verifiedEndTime * 1000));
}
wxDTO.setWxEnterpriseId(wxEnterpriseId);
Integer contactFlag = wxEnterpriseDTO.getContactFlag();
if (contactFlag == 0) {
wxDTO.setContactFlag(1);
}
wxEnterpriseApiService.update(wxDTO);
WxEnterpriseVO vo = com.gic.commons.util.EntityUtil.changeEntityNew( WxEnterpriseVO.class, wxEnterpriseDTO) ;
vo.setCorpid(getCorpid(wxEnterpriseDTO));
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
private String getCorpid(WxEnterpriseDTO wxEnterpriseDTO) {
Integer wxType = wxEnterpriseDTO.getWxSecurityType() ;
String wxEnterpriseId = wxEnterpriseDTO.getWxEnterpriseId() ;
if(null == wxType || 0==wxType) {
this.wxEnterpriseApiService.updateWxSecurityType(wxEnterpriseId);
wxType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ;
}
String desc = " (企微加密方式待确认,请联系运营人员) " ;
if(wxType==1) {
desc = "(全明文)" ;
}
if(wxType==2) {
desc = "(全密文)" ;
}
if(wxType==3) {
desc = "(第三方密文,代开明文)" ;
}
if(wxType==4) {
desc = "(第三方明文,代开密文)" ;
}
if(wxType==5) {
desc = " ( "+wxEnterpriseDTO.getWxaAppid() +" / " + wxEnterpriseDTO.getUrlHost()+") " ;
}
int newType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ;
String diff = "";
if(null != wxType && wxType.intValue() != newType && wxType != 5) {
diff = "*";
}
return Arrays.asList(wxEnterpriseDTO.getWxCorpid(),wxEnterpriseDTO.getOpenCorpid()).stream().filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.joining(" / ")) + desc + diff;
}
//gic企业列表
@IgnoreLogin
@RequestMapping("enterprise-search")
public HaobanResponse gicEnterpriseDetail(String enterpriseId) {
if (org.apache.commons.lang.StringUtils.isEmpty(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
EnterpriseSearchVO vo = new EnterpriseSearchVO();
EnterpriseDTO enterprise = enterpriseService.getEnterpriseById(enterpriseId);
if (enterprise != null) {
vo.setEnterpriseId(enterpriseId);
vo.setEnterpriseName(enterprise.getEnterpriseName());
vo.setBrandName(enterprise.getBrandName());
ClerkDTO clerk = clerkService.getSuperAdminByEnterpriseId(enterpriseId);
if (clerk != null) {
vo.setClerkId(clerk.getClerkId());
vo.setClerkCode(clerk.getClerkCode());
vo.setClerkName(clerk.getClerkName());
vo.setPhoneNumber(clerk.getPhoneNumber());
vo.setNationCode(clerk.getNationcode());
}
}else {
//enterpriseId 参数可以是企业id,也可以是企业名称
//按名称去查
EnterpriseAndUserDTO dto = enterpriseService.getEnterpriseAndUserByName(enterpriseId);
vo = EntityUtil.changeEntityByJSON(EnterpriseSearchVO.class, dto);
if (vo != null) {
EnterpriseDTO enterprise1 = enterpriseService.getEnterpriseById(vo.getEnterpriseId());
if (enterprise1 != null) {
vo.setBrandName(enterprise1.getBrandName());
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
//溢出门店列表
@RequestMapping("store-full-list")
public HaobanResponse storeFullList(BasePageInfo basePageInfo, String keyWord) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
int maxVersionCount = 0;
List<EnterpriseDetailDTO> enterpriseList = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtil.isEmpty(enterpriseList)) {
return resultResponse(HaoBanErrCode.ERR_10010);
}
List<String> enterpriseIds = enterpriseList.stream().map(s -> s.getEnterpriseId()).collect(Collectors.toList());
//获取门店列表
Page page1 = new Page<>();
page1.setCurrentPage(1);
page1.setPageSize(Integer.MAX_VALUE);
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseIdList(enterpriseIds);
storeSearchDTO.setSearchName(keyWord);
Page storePage = storeService.storeListPage(page1, storeSearchDTO);
if (storePage == null || storePage.getResult() == null) {
return resultResponse(HaoBanErrCode.ERR_10009);
}
List<StoreDTO> t_list = storePage.getResult();
List<String> storeIds = t_list.stream().map(s -> s.getStoreId()).collect(Collectors.toList());
if (StringUtils.isEmpty(keyWord)) {
storeIds = null;
}
Page<DepartmentDTO> page = departmentApiService.pageFullStoreByWxEnterpriseId(wxEnterpriseId, keyWord, storeIds, maxVersionCount, basePageInfo);
List<DepartmentDTO> list = page.getResult();
List<StoreVo> resultList = EntityUtil.changeEntityListByJSON(StoreVo.class, list);
List<String> t_storeIds = list.stream().map(s -> s.getRelatedId()).collect(Collectors.toList());
String[] storeIdArr = t_storeIds.toArray(new String[t_storeIds.size()]);
List<StoreDTO> storeList = storeService.getStores(storeIdArr);
Map<String, StoreDTO> map = com.gic.commons.util.CollectionUtil.toMap(storeList, "storeId");
for (StoreVo vo : resultList) {
if (map.get(vo.getRelatedId()) != null) {
vo.setStoreCode(map.get(vo.getRelatedId()).getStoreCode());
vo.setStoreId(map.get(vo.getRelatedId()).getStoreId());
vo.setStoreName(map.get(vo.getRelatedId()).getStoreName());
}
}
Page resultPage = new Page<>();
resultPage.setCurrentPage(page.getCurrentPage());
resultPage.setPageSize(page.getPageSize());
resultPage.setTotalCount(page.getTotalCount());
resultPage.setResult(resultList);
return resultResponse(HaoBanErrCode.ERR_1, resultPage);
}
//微信企业是否设置key
@RequestMapping("is-wx-enterprise-secret-set")
public HaobanResponse isWxEnterpriseSecretSet() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<SecretSettingDTO> listSecret = wxEnterpriseApiService.listSecret(wxEnterpriseId);
if (CollectionUtils.isEmpty(listSecret)) {
return resultResponse(HaoBanErrCode.ERR_1, false);
}
Set<Integer> secretTypeList = listSecret.stream().filter(secretSettingDTO -> secretSettingDTO.getCheckFlag() == 1).map(secretSettingDTO -> secretSettingDTO.getSecretType()).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(secretTypeList)) {
return resultResponse(HaoBanErrCode.ERR_1, false);
}
// 如果是第三方校验待开发
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
if ((secretTypeList.contains(SecretTypeEnum.SELF_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}else {
if ((secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}
return resultResponse(HaoBanErrCode.ERR_1, false);
}
/**
* 微信企业绑定接口绑定通讯录key
*
* @param wxSecretKey
* @return
*/
@RequestMapping("wx-enterprise-wx-secret-set")
public HaobanResponse wxEnterpriseWxSecretSet(String wxSecretKey) {
if (StringUtils.isAnyBlank(wxSecretKey)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if (qwDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
wxSecretKey = wxSecretKey.trim();
String token = this.qywxCorpApiService.getToken(qwDTO.getDkCorpid(), wxSecretKey);
logger.info("查询token={}", token) ;
if(StringUtils.isEmpty(token) || token.length() < 10) {
return this.fail("请确认secret是否正确") ;
}
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.SELF_APP.getVal(), null);
if (null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
secretSetting.setSecretType(SecretTypeEnum.SELF_APP.getVal());
secretSetting.setSecretName(SecretTypeEnum.SELF_APP.getName());
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setEnterpriseId("-1");
secretSetting.setSecretVal(wxSecretKey);
secretSetting.setCheckFlag(1);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_1, true);
}
/**
* 微信企业会员小程序
*
* @param memberSecret
* @param enterpriseId
* @param secretName
* @return
*/
@RequestMapping("wx-enterprise-member-secret-set")
public HaobanResponse wxEnterpriseMemberSecretSet(String secretId,String memberSecret, String enterpriseId, String secretName) {
if (StringUtils.isAnyBlank(memberSecret,enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterprise == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
memberSecret = memberSecret.trim();
SecretSettingDTO secretSetting = null ;
if (StringUtils.isNotBlank(secretId)) {
secretSetting = wxEnterpriseApiService.getSecretSettingById(secretId);
}
if(null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
List<SecretSettingDTO> enList = this.secretSettingApiService.exsitGicEidMemberApp(wxEnterpriseId) ;
if(CollectionUtils.isNotEmpty(enList)) {
Map<String,SecretSettingDTO> map = enList.stream().collect(Collectors.toMap(SecretSettingDTO::getEnterpriseId, dto->dto,(k1,k2)->k1));
if(StringUtils.isEmpty(secretId)) {
if(null != map.get(enterpriseId)) {
return this.fail("此商户小程序已存在") ;
}
}else {
if(null != map.get(enterpriseId) && !secretId.equals(map.get(enterpriseId).getSecretId())) {
return this.fail("此商户小程序已存在") ;
}
}
}
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
String token = this.qywxCorpApiService.getToken(qwDTO.getMemberCorpid(), memberSecret);
logger.info("查询token", token) ;
if(StringUtils.isEmpty(token) || token.length() < 10) {
return this.fail("请确认secret是否正确") ;
}
secretSetting.setSecretType(SecretTypeEnum.MEMBER_WAPP.getVal());
secretSetting.setSecretName(secretName);
secretSetting.setEnterpriseId(enterpriseId);
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setSecretVal(memberSecret);
secretSetting.setCheckFlag(1);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_1, true);
}
/**
* 企微相关密钥列表
*
* @return
*/
@RequestMapping("secret-list")
public HaobanResponse secretList() {
String wxEnterpriseId = "";
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterprise == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
List<SecretSettingDTO> listSecret = wxEnterpriseApiService.listSecret(wxEnterpriseId);
List<SecretSettingVO> listRet = EntityUtil.changeEntityListByJSON(SecretSettingVO.class, listSecret);
if (CollectionUtils.isNotEmpty(listRet)) {
listRet.forEach(secretSettingVO -> {
if ((!StringUtils.isEmpty(secretSettingVO.getEnterpriseId())) && (!secretSettingVO.getEnterpriseId().equals("-1"))) {
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(secretSettingVO.getEnterpriseId());
secretSettingVO.setEnterpriseName(enterpriseDTO == null ? "" : enterpriseDTO.getBrandName());
}
});
}
return resultResponse(HaoBanErrCode.ERR_1, listRet);
}
//微信企业会员小程序
@RequestMapping("member-secret-del")
public HaobanResponse delMemberSecret(String secretId) {
if (StringUtils.isAnyBlank(secretId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
boolean b = wxEnterpriseApiService.delSecretSetting(secretId);
return resultResponse(HaoBanErrCode.ERR_1, b);
}
/**
* 刷新企业微信好友
*
* @return
*/
@RequestMapping("/fresh-wx-friend")
public HaobanResponse freshWxFriend() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String dayKey = "haoban_fresh-wx-friend-day" + wxEnterpriseId + DateUtil.dateToStr(new Date(), "yyyy-MM-dd");
String monthKey = "haoban_fresh-wx-friend-month" + wxEnterpriseId + DateUtil.dateToStr(new Date(), "yyyy-MM");
String dateKey = "haoban_fresh-wx-friend-date" + wxEnterpriseId;
Integer dayCount = RedisUtil.getCache(dayKey) == null ? 0 : Integer.parseInt(RedisUtil.getCache(dayKey).toString());
Integer monthCount = RedisUtil.getCache(monthKey) == null ? 0 : Integer.parseInt(RedisUtil.getCache(monthKey).toString());
if (dayCount >= 1) {
return resultResponse(HaoBanErrCode.ERR_100019);
}
if (monthCount >= 3) {
return resultResponse(HaoBanErrCode.ERR_100020);
}
String taskId = dealSyncOperationApiService.createWxFriendTask(wxEnterpriseId, "刷新企微好友", login.getClerkId(), "刷新企微好友");
if (StringUtils.isEmpty(taskId)) {
return resultResponse(HaoBanErrCode.ERR_100021);
}
RedisUtil.setCache(dayKey, dayCount + 1);
RedisUtil.setCache(monthKey, monthCount + 1);
RedisUtil.setCache(dateKey, DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATETIME_19));
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 获取企业微信好友刷新时间
*
* @return
*/
@RequestMapping("/get-fresh-detail")
public HaobanResponse getFreshDetail() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String dateKey = "haoban_fresh-wx-friend-date" + wxEnterpriseId;
RedisUtil.getCache(dateKey);
return resultResponse(HaoBanErrCode.ERR_1, RedisUtil.getCache(dateKey));
}
/**
* 微信企业绑定详情
*
* @param enterpriseId
* @return
*/
@RequestMapping("wx-enterprise-bind-detail")
public HaobanResponse wxEnterpriseBindDetail(String enterpriseId) {
if (StringUtils.isAnyBlank(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseRelationDetailDTO bindInfo = wxEnterpriseRelatedApiService.getEnterpriseBindInfo(wxEnterpriseId, enterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, bindInfo);
}
/**
* 绑定门店列表
*
* @param enterpriseId
* @return
*/
@RequestMapping("bind-store-list")
public HaobanResponse bindStoreList(String enterpriseId, String search, BasePageInfo basePageInfo) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
Page<BindStoreInfoDTO> retPage = wxEnterpriseRelatedApiService.pageBindStoreByEnterpriseId(wxEnterpriseId, enterpriseId, search, basePageInfo);
return resultResponse(HaoBanErrCode.ERR_1, retPage);
}
/**
* 绑定门店列表
*
* @param enterpriseId
* @return
*/
@RequestMapping("flush-bind-store-list")
public HaobanResponse flushBindStoreList(String enterpriseId) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
ServiceResponse response = wxEnterpriseRelatedApiService.flushBindStoreByEnterpriseId(enterpriseId, wxEnterpriseId, login.getClerkId(), ChannelCodeEnum.SYNC_UNBIND.getCode());
logger.info("返回信息:{}", JSONObject.toJSONString(response));
if (response.getCode() != 1) {
HaoBanErrCode.ERR_DEFINE.setMsg(response.getMessage());
return resultResponse(HaoBanErrCode.ERR_DEFINE);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 绑定小程序配置列表
*
* @return
*/
@RequestMapping("list-miniprogram-setting")
public HaobanResponse miniprogramList() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<MiniprogramSettingDTO> settingDTOS = wxEnterpriseApiService.listMiniprogramSetting(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, settingDTOS);
}
/**
* 保存小程序配置列表
*
* @return
*/
@RequestMapping("save-miniprogram-setting")
public HaobanResponse saveMiniprogram(MiniprogramSettingQo settingDTO) {
if (StringUtils.isAnyBlank(settingDTO.getAppId(),
settingDTO.getImageUrl(), settingDTO.getMiniprogramName(), settingDTO.getTitle())) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
settingDTO.setWxEnterpriseId(wxEnterpriseId);
settingDTO.setEnterpriseId(login.getEnterpriseId());
MiniprogramSettingDTO miniprogramSettingDTO = wxEnterpriseApiService.getMiniprogramSettingByAppId(wxEnterpriseId, settingDTO.getAppId());
if (null != miniprogramSettingDTO
&& (!miniprogramSettingDTO.getMiniprogramSettingId().equals(settingDTO.getMiniprogramSettingId()))) {
return resultResponse(HaoBanErrCode.ERR_100031);
}
wxEnterpriseApiService.saveMiniprogramSetting(EntityUtil.changeEntityByOrika(MiniprogramSettingDTO.class, settingDTO));
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 获取小程序配置
*
* @return
*/
@RequestMapping("get-miniprogram-setting")
public HaobanResponse getMiniprogram(String enterpriseId) {
if (StringUtils.isEmpty(enterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
MiniprogramSettingDTO settingDTO = wxEnterpriseApiService.getMiniprogramSettingByEid(wxEnterpriseId, enterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, settingDTO);
}
/**
* 删除小程序配置
*
* @return
*/
@RequestMapping("del-miniprogram-setting")
public HaobanResponse delMiniprogram(String id) {
if (StringUtils.isEmpty(id)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
wxEnterpriseApiService.delMiniprogramSettingByEid(id);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 分析素材
*
* @return
*/
@RequestMapping("/agent-wx-enterprise-list")
public HaobanResponse materialShare(String materialId) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
List<EnterpriseDetailDTO> detailDTOS = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
List<String> enterpriseIds = detailDTOS.stream().filter(dto -> dto.getWxEnterpriseType() == 0).map(dto -> dto.getEnterpriseId()).collect(Collectors.toList());
List<EnterpriseDetailDTO> retList = wxEnterpriseRelatedApiService.listEnterpriseByEnterpriseIds(enterpriseIds);
Map<String, EnterpriseDetailDTO> detailDTOMap = retList.stream().filter(dto -> dto.getWxEnterpriseType() == 1).collect(Collectors.toMap(dto -> dto.getWxEnterpriseId(), dto -> dto, (ne, ol) -> ol));
Collection<EnterpriseDetailDTO> values = detailDTOMap.values();
List<AgentEnterpriseDTO> enterpriseList = EntityUtil.changeEntityListByOrika(AgentEnterpriseDTO.class, values);
if (CollectionUtils.isNotEmpty(values)) {
List<MaterialDTO> materialDTOS = materialApiService.listByFromMaterialId(materialId);
List<String> wxEids = new ArrayList<>();
if (CollectionUtils.isNotEmpty(materialDTOS)) {
wxEids = materialDTOS.stream().map(dto -> dto.getWxEnterpriseId()).collect(Collectors.toList());
}
List<String> finalWxEids = wxEids;
for(AgentEnterpriseDTO dto : enterpriseList) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(dto.getWxEnterpriseId());
if(null == wxEnterpriseDTO) {
continue ;
}
logger.info("wxEnterpriseDTO={},dto={}", JSON.toJSONString(wxEnterpriseDTO),JSON.toJSONString(dto));
dto.setEnterpriseName(wxEnterpriseDTO.getCorpName());
if (finalWxEids.contains(dto.getWxEnterpriseId())) {
dto.setBindFlag(1);
} else {
dto.setBindFlag(0);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, enterpriseList);
}
/**
* 删除欢迎语
*
* @return
*/
@RequestMapping("del-welcome")
public HaobanResponse delWelcome() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
wxEnterpriseApiService.delWelcome(wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 欢迎语开启关闭
*
* @return
*/
@RequestMapping("set-welcome")
public HaobanResponse setWelcome(int openFlag) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
wxEnterpriseApiService.setWelcome(wxEnterpriseId, openFlag);
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 授权绑定-设置导购编辑权限
*
* @return
*/
@IgnoreLogin
@RequestMapping("set-clerk-edit")
public HaobanResponse setClerkEdit(String wxEnterprieseRelatedId, int clerkEditFlag) {
if (StringUtils.isBlank(wxEnterprieseRelatedId)) {
logger.info("缺少参数");
return resultResponse(HaoBanErrCode.ERR_2);
}
boolean b = wxEnterpriseRelatedApiService.setClerkEditFlag(wxEnterprieseRelatedId, clerkEditFlag);
if (b) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_100032);
}
}
/**
* 是否同意授权
*
* @param openFlag
* @return
*/
@RequestMapping("agree_external_userid_flag")
public HaobanResponse agreeExternalUseridFlag(Integer openFlag) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
wxEnterpriseApiService.agreeExternalUseridFlag(wxEnterpriseId, openFlag);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping(path = "/current/enterprise/info")
public RestResponse<?> queryCurrentInfo(){
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
com.gic.api.base.commons.ServiceResponse<EnterpriseDetailDTO> serviceResponse = wxEnterpriseRelatedApiService.queryEnterpriseDetail(loginUser.getWxEnterpriseId(), loginUser.getEnterpriseId());
if (serviceResponse.isSuccess()){
return RestResponse.successResult(serviceResponse.getResult());
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
/**
* 最新一条将要被拦截记录
* @return
*/
@RequestMapping(value = "qywx-fee-wxEnterprise-detail", method = RequestMethod.GET)
public RestResponse qywxFeeWxEnterpriseListDetail() {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
HaobanQywxFeeDTO haobanQywxFeeDTO = haobanQywxFeeApiService.queryByWxEnterpriseId(wxEnterpriseId);
if (haobanQywxFeeDTO == null) {
return RestResponse.successResult();
}
List<EnterpriseDetailDTO> enterpriseDetailDTOS = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(enterpriseDetailDTOS)) {
StringBuffer stringBuffer = new StringBuffer();
for (EnterpriseDetailDTO enterpriseDetailDTO : enterpriseDetailDTOS) {
stringBuffer.append(enterpriseDetailDTO.getEnterpriseName()).append(" ");
}
haobanQywxFeeDTO.setEnterpriseNames(stringBuffer.toString());
}
return RestResponse.successResult(haobanQywxFeeDTO);
}
}
package com.gic.haoban.manage.web.controller.order;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.business.order.dto.member.MemberStoreInfoDTO;
import com.gic.business.order.dto.ordermanage.ListOrderDTO;
import com.gic.business.order.dto.ordermanage.ListOrderItemDTO;
import com.gic.business.order.dto.ordermanage.OrderDetailDTO;
import com.gic.business.order.dto.ordermanage.OrderInfoDTO;
import com.gic.business.order.dto.ordermanage.OrderNodeDTO;
import com.gic.business.order.dto.ordermanage.OrderStatusDTO;
import com.gic.business.order.dto.setting.MallOrderSettingDTO;
import com.gic.business.order.enums.OrderEnum;
import com.gic.business.order.enums.OrderEnum.DeliveryOptTypeEnum;
import com.gic.business.order.enums.OrderEnum.SearchOrderTypeEnum;
import com.gic.business.order.qdto.ordermanage.CountOrderStatusQDTO;
import com.gic.business.order.qdto.ordermanage.ListOrderManageQDTO;
import com.gic.business.order.qdto.ordermanage.OrderItemShipmentQDTO;
import com.gic.business.order.qdto.ordermanage.OrderShipmentQDTO;
import com.gic.business.order.qdto.ordermanage.QueryOrderDetailQDTO;
import com.gic.business.order.qdto.ordermanage.SelfPickOffQDTO;
import com.gic.business.order.qdto.ordermanage.UpdateOrderLogisticsQDTO;
import com.gic.business.order.service.activity.MemberReferClerkApiService;
import com.gic.business.order.service.ordermanage.WebOrderManageApiService;
import com.gic.business.order.service.setting.OrderSettingApiService;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.evaluate.manage.api.dto.EvaluateRuleScoreDTO;
import com.gic.evaluate.manage.api.dto.StoreEvaluateInfoDTO;
import com.gic.evaluate.manage.api.service.EvaluateDataApiService;
import com.gic.haoban.app.aggregation.api.dto.evaluation.CreateRecordRequest;
import com.gic.haoban.app.aggregation.api.dto.evaluation.OrderProductRequest;
import com.gic.haoban.app.aggregation.api.dto.evaluation.OrderVerificationRecordDTO;
import com.gic.haoban.app.aggregation.api.service.evaluation.OrderVerificationRecordApiService;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.order.integral.ClerkQo;
import com.gic.haoban.manage.web.vo.order.EvaluateVO;
import com.gic.haoban.manage.web.vo.order.MemberInfoVO;
import com.gic.haoban.manage.web.vo.order.OrderCountVO;
import com.gic.haoban.manage.web.vo.order.OrderDetailItemVO;
import com.gic.haoban.manage.web.vo.order.OrderDetailVO;
import com.gic.haoban.manage.web.vo.order.OrderListItemVO;
import com.gic.haoban.manage.web.vo.order.OrderListVO;
import com.gic.haoban.manage.web.vo.order.integral.CheckVO;
import com.gic.haoban.manage.web.vo.order.integral.HxOrderCountVO;
import com.gic.haoban.manage.web.vo.order.integral.ProductSku;
import com.gic.haoban.manage.web.vo.order.integral.ProductVO;
import com.gic.haoban.manage.web.vo.order.integral.ScanVO;
import com.gic.integralmall.api.dto.IntegralMallExchangeLogDTO;
import com.gic.integralmall.api.enums.IntegralMallExchangeLogStatusEnums;
import com.gic.integralmall.api.service.IntegralmallService;
import com.gic.integralmall.api.service.result.DubboResult;
import com.gic.store.goods.dto.stock.GoodsStockBaseQDTO;
import com.gic.store.goods.enums.ProductStockChannelType;
import com.gic.store.goods.service.ProductStockApiService;
@RestController
@RequestMapping("/order")
public class GicOrderController {
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(GicOrderController.class);
@Autowired
private WebOrderManageApiService webOrderManageApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private MemberReferClerkApiService memberReferClerkApiService;
@Autowired
private IntegralmallService integralmallService;
@Autowired
private OrderVerificationRecordApiService orderVerificationRecordApiService;
@Autowired
private ProductStockApiService productStockApiService;
@Autowired
private OrderSettingApiService orderSettingApiService;
@Autowired
private EvaluateDataApiService evaluateDataApiService;
// 发货订单列表 (0全部,待发货2+待收货3,部分发货7)
@RequestMapping("list-order")
public RestResponse<Object> orderList(String enterpriseId, String storeId, String clerkId, String search,
@RequestParam(defaultValue = "0") int status, BasePageInfo pageInfo) {
String strStatus = "" + status;
if (status == 0) {
strStatus = "2,3,7";
}
if (status == 2) {
strStatus = "2,7";
}
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setOrderStep(strStatus);
// 微商城
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(1);
// 库存 - 门店库存2
qdto.setDeliveryMode(2);
if (StringUtils.isNotEmpty(search)) {
qdto.setSearchOrderType(SearchOrderTypeEnum.GOODS_NAME_OR_ORDER_NUMBER.getType());
qdto.setSearchOrderParam(search);
}
qdto.setBelongStoreId(storeId);
logger.info("发货订单查询,qdto={}", JSON.toJSONString(qdto));
return this.orderListSelect(qdto, pageInfo, false);
}
// 数量查询(待发货+待收货)
// orderType:2待发货 3待收货
@RequestMapping("order-deliver-count")
public RestResponse<Object> orderCount(String enterpriseId, String storeId) {
OrderCountVO vo = new OrderCountVO();
if (StringUtils.isEmpty(storeId)) {
return RestResponse.successResult(vo);
}
CountOrderStatusQDTO qdto = new CountOrderStatusQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(1);
// 库存 - 门店库存2
qdto.setDeliveryMode(2);
qdto.setBelongStoreId(storeId);
ServiceResponse<List<OrderStatusDTO>> resp = this.webOrderManageApiService.countOrderStatus(qdto);
List<OrderStatusDTO> list = resp.getResult();
if (CollectionUtils.isNotEmpty(list)) {
long noDeliver = 0, deliver = 0;
for (OrderStatusDTO item : list) {
if (item.getOrderStep() == 3) {
deliver = item.getTotal();
}
if (item.getOrderStep() == 2 || item.getOrderStep() == 7) {
noDeliver = noDeliver + item.getTotal();
}
}
vo.setDeliverCount((int) deliver);
vo.setNoDeliverCount((int) noDeliver);
vo.setTotal((int) (deliver + noDeliver));
}
return RestResponse.successResult(vo);
}
// 核销订单查询
// status 0全部 1待核销 2已核销
@RequestMapping("list-verification-order")
public RestResponse<Object> mallOrderList(String enterpriseId, String storeId, String clerkId,
@RequestParam(defaultValue = "0") int status, String search, BasePageInfo pageInfo) {
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(2);
qdto.setPickUpStoreId(storeId);
if (status == 1) {
qdto.setOrderStep("2");
}
if (status == 2) {
qdto.setWriteOffClerkId(clerkId);
qdto.setOrderStep("4");
qdto.setDeliveryOptType(1);
}
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
qdto.setSearchOrderParam(search);
return this.orderListSelect(qdto, pageInfo, false);
}
// 订单详情 (客户信息+收货地址+商品详情+订单信息 + 订单状态)
@RequestMapping("order-detail")
public RestResponse<Object> orderDetail(String enterpriseId, String clerkId, String searchParams,
@RequestParam(defaultValue = "1") int orderType, String orderId, String storeId) {
QueryOrderDetailQDTO queryOrderDetailQDTO = new QueryOrderDetailQDTO();
queryOrderDetailQDTO.setOrderId(orderId);
queryOrderDetailQDTO.setEnterpriseId(enterpriseId);
ServiceResponse<OrderDetailDTO> ret = webOrderManageApiService.getOrderDetail(queryOrderDetailQDTO);
if (!ret.isSuccess()) {
return RestResponse.failure(ret.getCode(), ret.getMessage());
}
logger.info("订单信息={}", JSON.toJSONString(ret, true));
OrderDetailVO detail = this.getOrderDetail(enterpriseId, ret.getResult().getOrderInfo(),
ret.getResult().getOrderItemList(), storeId);
if (CollectionUtils.isNotEmpty(ret.getResult().getOrderWrapList())) {
List<String> idList = ret.getResult().getOrderWrapList().stream().map(o -> o.getMallOrderLogisticsId())
.collect(Collectors.toList());
detail.setOrderLogisticsIdList(idList);
}
detail.setCreateTime(OrderDetailDTO.getNodeTimeStatic(OrderEnum.OrderNodeEnum.PLACE_AN_ORDER,
ret.getResult().getOrderNodeList()));
detail.setPayTime(OrderDetailDTO.getNodeTimeStatic(OrderEnum.OrderNodeEnum.PAY_ORDER,
ret.getResult().getOrderNodeList()));
// 如果是自提
if (null != detail.getDeliveryChannel() && detail.getDeliveryChannel() == 2) {
detail.setPickUpTime(OrderDetailDTO.getNodeTimeStatic(OrderEnum.OrderNodeEnum.SUCCESSFUL,
ret.getResult().getOrderNodeList()));
}
// 自动收货时间
List<OrderNodeDTO> stepList = ret.getResult().getOrderNodeList();
if (CollectionUtils.isNotEmpty(stepList)) {
stepList.forEach(item -> {
if (item.getOrderStep() == 3) {
ServiceResponse<MallOrderSettingDTO> setResp = this.orderSettingApiService
.getOrderSetting(enterpriseId);
int autoDay = setResp.getResult().getAutoConfirm();
if (0 != autoDay) {
detail.setAutoTaskOverTime(DateUtil.addNumForDay(item.getCreateTime(), autoDay));
return;
}
}
});
}
return RestResponse.successResult(detail);
}
/**
* 扫码二维码
*/
@RequestMapping("/scan")
public RestResponse<Object> scan(String enterpriseId, String writeOffCode, String storeId) {
if (StringUtils.isEmpty(writeOffCode)) {
return RestResponse.failure("9999", "核销码为空");
}
// 微商城
if (writeOffCode.startsWith("M")) {
// 通过核销码查询
QueryOrderDetailQDTO qdto = new QueryOrderDetailQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setWriteOffCode(writeOffCode);
ServiceResponse<OrderDetailDTO> ret = webOrderManageApiService.getOrderDetail(qdto);
OrderDetailDTO detail = ret.getResult();
logger.info("订单信息={}", JSON.toJSONString(ret, true));
if (ret.isSuccess()) {
// 已核销,且不是好办核销的
if (null != detail.getOrderInfo().getDeliveryOptType()
&& detail.getOrderInfo().getDeliveryOptType() != 1) {
logger.info("已核销,且不是好办核销的={}", writeOffCode);
return RestResponse.failure("9999", "此自提点无法核销");
}
if (!storeId.equals(detail.getOrderInfo().getPickUpStoreId())) {
return RestResponse.failure("9999", "此自提点无法核销");
}
OrderDetailVO orderDetailVO = this.getOrderDetail(enterpriseId, ret.getResult().getOrderInfo(),
ret.getResult().getOrderItemList(), storeId);
return RestResponse.successResult(orderDetailVO);
} else {
return RestResponse.failure("9999", ret.getMessage());
}
} else {
// 积分商城
DubboResult<IntegralMallExchangeLogDTO> integralResult = integralmallService
.getIntegralMallExchangeLogByWriteOffCode(enterpriseId, writeOffCode);
if (null != integralResult && null != integralResult.getData()) {
ScanVO vo = integralMallScan(integralResult.getData());
return RestResponse.successResult(vo);
}
}
return RestResponse.failure("9999", "订单查询不到");
}
// 单笔订单发货商品列表
@RequestMapping("order-deliver-list")
public RestResponse<Object> orderDeliverList(String enterpriseId, String storeId, String orderId) {
QueryOrderDetailQDTO qdto = new QueryOrderDetailQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setOrderId(orderId);
ServiceResponse<OrderDetailDTO> resp = webOrderManageApiService.getOrderDetail(qdto);
List<ListOrderItemDTO> list = resp.getResult().getOrderItemList();
List<OrderListItemVO> voList = new ArrayList<>();
for (ListOrderItemDTO item : list) {
if (StringUtils.isEmpty(item.getLogisticsId())) {
OrderListItemVO vo = EntityUtil.changeEntityByJSON(OrderListItemVO.class, item);
GoodsStockBaseQDTO stockQDTO = new GoodsStockBaseQDTO();
stockQDTO.setEnterpriseId(enterpriseId);
stockQDTO.setGoodsId(vo.getMallProId());
stockQDTO.setSkuId(vo.getMallProSkuId());
stockQDTO.setStoreId(storeId);
stockQDTO.setChannelType(ProductStockChannelType.MALL.getCode());
ServiceResponse<Integer> stockResp = this.productStockApiService.queryGoodsStock(stockQDTO);
logger.info("门店库存查询orderId={},qdto={},result={}", orderId, JSON.toJSONString(stockQDTO),
JSON.toJSONString(stockResp));
if (stockResp.isSuccess() && null != stockResp.getResult()) {
vo.setStoreStock(stockResp.getResult());
}
voList.add(vo);
}
}
return RestResponse.successResult(voList);
}
// 订单-发货
@RequestMapping("order-logistics-deliver")
public RestResponse<Object> orderDeliver(String enterpriseId, String orderId, String storeId, String orderItemIds,
String companyCode, String logisticsNo, String companyId, String companyName) {
OrderShipmentQDTO qdto = new OrderShipmentQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setLogisticsCompanyCode(companyCode);
qdto.setLogisticsCompanyName(companyName);
qdto.setLogisticsCompanyId(companyId);
qdto.setCourierNumber(logisticsNo);
qdto.setOrderId(orderId);
// 门店发货
qdto.setDeliveryMode(2);
// 好办后台发货
qdto.setSource(DeliveryOptTypeEnum.HAOBAN.getCode());
List<String> orderItemIdList = Arrays.asList(orderItemIds.split(","));
List<OrderItemShipmentQDTO> list = new ArrayList<>();
orderItemIdList.forEach(o -> {
OrderItemShipmentQDTO item = new OrderItemShipmentQDTO();
item.setOrderItemId(o);
item.setStoreId(storeId);
list.add(item);
});
qdto.setOrderItemShipment(list);
ServiceResponse<Boolean> resp = webOrderManageApiService.orderShipment(qdto);
if (!resp.isSuccess()) {
/*
* String code = resp.getCode(); if (Arrays.asList("900001",
* "300105", "200001").contains(code)) { return
* RestResponse.failure(HaoBanErrCode.ERR_9600.getCode() + "",
* "请刷新页面"); }
*/
return RestResponse.failure(HaoBanErrCode.ERR_9600.getCode() + "", "请刷新页面");
}
return RestResponse.successResult(resp.getResult());
}
// 我的客户-会员订单列表
// deliveryChannel 0全部 1快递 2自提
// -1全部 1待付款 2待发货 7部分发货 4已完成 0已取消 5售后中
// orderType -1 全部 0:会员自行购买 1导购推荐订单
@RequestMapping("list-member-order")
public RestResponse<Object> orderList(String enterpriseId, String memberId, String search,
@RequestParam(defaultValue = "-1") int status, @RequestParam(defaultValue = "0") int deliveryChannel,
@RequestParam(defaultValue = "-1") int orderType, BasePageInfo pageInfo, String startTime, String endTime) {
if (StringUtils.isEmpty(memberId)) {
return RestResponse.failure("9999", "memberId为空");
}
String strStatus = "" + status;
// 全部
if (status == -1) {
strStatus = null;
}
// 售后中
if (status == 5) {
strStatus = "11";
}
Date startDate = null;
if (StringUtils.isNotEmpty(startTime)) {
startDate = DateUtil.strToDate(startTime, "yyyy-MM-dd");
}
Date endDate = null;
if (StringUtils.isNotEmpty(endTime)) {
endDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
endDate = DateUtil.getEndTimeOfDay(endDate);
}
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setOrderStep(strStatus);
qdto.setMemberId(memberId);
qdto.setStartDate(startDate);
qdto.setEndDate(endDate);
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
if (StringUtils.isNotEmpty(search)) {
qdto.setSearchOrderType(SearchOrderTypeEnum.ORDER_NUMBER.getType());
qdto.setSearchOrderParam(search);
}
return this.orderListSelect(qdto, pageInfo, true);
}
// 修改物流
// type : 1: 下单 2:换货
@RequestMapping("modify-order-logistics")
public RestResponse<Object> modifyOrderDeliver(String memberId, String enterpriseId, String orderId, String storeId,
String logisticsId, String companyCode, String logisticsNo, String companyId, String companyName,
@RequestParam(defaultValue = "1") int type) {
logger.info("修改物流={},{}", orderId, type);
UpdateOrderLogisticsQDTO qdto = new UpdateOrderLogisticsQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setLogisticsCompanyCode(companyCode);
qdto.setLogisticsCompanyName(companyName);
qdto.setLogisticsCompanyId(companyId);
qdto.setCourierNumber(logisticsNo);
qdto.setOrderId(orderId);
qdto.setLogisticsId(logisticsId);
qdto.setType(type);
this.webOrderManageApiService.updateOrderLogistics(qdto);
return RestResponse.successResult();
}
/**
* 核销订单
*/
@RequestMapping("/verification")
public RestResponse<Object> verification(String enterpriseId, String clerkId, String writeOffCode, String orderId) {
if (StringUtils.isEmpty(writeOffCode)) {
return RestResponse.failure("9999", "核销码为空");
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
if (null == clerkDTO) {
return RestResponse.failure("9999", "核销人不存在");
}
// 微商城核销
if (writeOffCode.startsWith("M")) {
if (StringUtils.isEmpty(orderId)) {
return RestResponse.failure("9999", "订单ID为空");
}
SelfPickOffQDTO qdto = new SelfPickOffQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setWriteOffClerkId(clerkId);
qdto.setWriteOffCode(writeOffCode);
qdto.setSource(1);
qdto.setWriteOffClerkCode(clerkDTO.getClerkCode());
qdto.setOrderId(orderId);
ServiceResponse<Boolean> response = webOrderManageApiService.selfPickOff(qdto);
if (!response.isSuccess()) {
return RestResponse.failure(response.getCode(), response.getMessage());
}
return RestResponse.successResult(response.getResult());
} else {
ClerkQo clerkQo = new ClerkQo();
clerkQo.setClerkCode(clerkDTO.getClerkCode());
clerkQo.setClerkId(clerkDTO.getClerkId());
clerkQo.setStoreId(clerkDTO.getStoreId());
clerkQo.setClerkName(clerkDTO.getClerkName());
clerkQo.setEnterpriseId(enterpriseId);
logger.info("积分商城订单核销开始,核销码:{} ,核销人:{} ", writeOffCode, clerkQo.getClerkId());
enterpriseId = clerkDTO.getEnterpriseId();
DubboResult<Boolean> check = integralmallService.haobanVerificationExchangeLog(enterpriseId, writeOffCode,
clerkQo.getClerkCode(), clerkQo.getClerkName(), clerkQo.getStoreId());
logger.info("核销结果:{} ", JSON.toJSONString(check));
CheckVO checkVO = new CheckVO();
if (check.getSuccess()) {
// 积分商城核销成功-添加核销记录
String recordId = createIntegralRecord(enterpriseId, 1, clerkQo, writeOffCode);
checkVO.setId(recordId);
checkVO.setSuccess(Boolean.TRUE);
checkVO.setCode(HaoBanErrCode.ERR_1.getCode());
return RestResponse.successResult(checkVO);
}
/*
* 核销失败情况 10001 兑换记录不存在 10002 当前订单状态无法核销 10003 该订单已经核销 10004 订单已经取消
* 10005 10006 超期核销
*/
checkVO.setCode(check.getErrorCode());
checkVO.setMessage(check.getErrMessage());
checkVO.setSuccess(Boolean.FALSE);
if (check.getErrorCode() == HaoBanErrCode.ERR_100010.getCode()) {
// 订单已核销
OrderVerificationRecordDTO record = orderVerificationRecordApiService
.getRecordByClerkIdAndWriteOffCode(clerkQo.getClerkId(), writeOffCode);
if (Objects.nonNull(record)) {
checkVO.setSuccess(Boolean.TRUE);
checkVO.setId(record.getRecordId());
return RestResponse.successResult(checkVO);
}
// 超期核销
checkVO.setCode(HaoBanErrCode.ERR_100014.getCode());
checkVO.setMessage(HaoBanErrCode.ERR_100014.getMsg());
}
if (!checkVO.getSuccess()) {
HaobanResponse response = new HaobanResponse();
response.setMessage(checkVO.getMessage());
response.setErrorCode(checkVO.getCode());
response.setResult(checkVO.getId());
response.setDetailError("");
return RestResponse.successResult(checkVO);
}
}
return null;
}
// 核销数量
@RequestMapping("/verification-count")
public RestResponse<Object> verificationCountNew(String enterpriseId, String storeId, String clerkId) {
Page<IntegralMallExchangeLogDTO> page = new Page<IntegralMallExchangeLogDTO>();
page.setPageSize(1);
page.setCurrentPage(1);
Map<String, Object> params = new HashMap<>();
params.put("enterpriseId", enterpriseId);
params.put("proType", 2);
params.put("changeType", 4);
// 订单状态
params.put("orderStatus", 1);
params.put("goodsPointStoreId", storeId);
page.setParams(params);
page = integralmallService.listOnlineByPage(page);
int integralUndoneCount = page.getTotalCount();
int integralDoneCount = this.orderVerificationRecordApiService.countByGicClerkId(clerkId);
// 查询微商城
int mallDoneCount = this.count(enterpriseId, storeId, clerkId, 4);
int mallUndoneCount = this.count(enterpriseId, storeId, clerkId, 2);
HxOrderCountVO vo = new HxOrderCountVO();
vo.setIntegralDoneCount(integralDoneCount);
vo.setIntegralUndoneCount(integralUndoneCount);
vo.setMallDoneCount(mallDoneCount);
vo.setMallUndoneCount(mallUndoneCount);
vo.setTotalDoneCount(integralDoneCount + mallDoneCount);
vo.setTotalUndownCount(integralUndoneCount + mallUndoneCount);
return RestResponse.successResult(vo);
}
private int count(String enterpriseId, String storeId, String clerkId, int step) {
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(2);
qdto.setPickUpStoreId(storeId);
if (step == 4) {
qdto.setWriteOffClerkId(clerkId);
qdto.setDeliveryOptType(1);
}
qdto.setOrderStep("" + step);
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
qdto.setPageNum(1);
qdto.setPageSize(1);
ServiceResponse<Page<ListOrderDTO>> ret = webOrderManageApiService.listOrder(qdto);
logger.info("核销订单数={}");
return ret.getResult().getTotalCount();
}
// 订单详情
private OrderDetailVO getOrderDetail(String enterpriseId, OrderInfoDTO orderInfo,
List<ListOrderItemDTO> orderItemDTOList, String storeId) {
OrderDetailVO orderDetailVO = EntityUtil.changeEntityByJSON(OrderDetailVO.class, orderInfo);
orderDetailVO.setBuyerRemark(orderInfo.getRemarks());
List<OrderDetailItemVO> orderItemList = EntityUtil.changeEntityListNew(OrderDetailItemVO.class,
orderItemDTOList);
orderDetailVO.setOrderItemList(orderItemList);
String memberId = orderInfo.getMemberId();
MemberInfoVO member = new MemberInfoVO();
member.setMemberId(memberId);
if (StringUtils.isNotEmpty(memberId)) {
ServiceResponse<MemberStoreInfoDTO> memberResp = this.memberReferClerkApiService.getMemberInfo(enterpriseId,
memberId);
MemberStoreInfoDTO memberInfo = memberResp.getResult();
if (null != memberInfo) {
member = EntityUtil.changeEntityByJSON(MemberInfoVO.class, memberInfo);
}
}
member.setAddressPhone(orderInfo.getBuyerPhone());
member.setAddressName(orderInfo.getBuyerName());
member.setAddressDetail(orderInfo.getFullName() + orderInfo.getAddressInfo());
orderDetailVO.setAddressInfo(orderInfo.getFullName() + orderInfo.getAddressInfo());
orderDetailVO.setMember(member);
// 判断能否发货
// 导购发货,一笔订单仅允许单门店发货
boolean canDeliverFlag = false;
// 发货操作类型(0后台/1好办门店):用于判断好办操作发货还是后台,防止双边发货
Integer deliveryOptType = orderInfo.getDeliveryOptType();
logger.info("发货类型1好办={},orderId={}", deliveryOptType, orderInfo.getOrderId());
if (null == deliveryOptType) {
canDeliverFlag = true;
} else if (deliveryOptType == 1) {
canDeliverFlag = true;
}
orderDetailVO.setCanDeliverFlag(canDeliverFlag);
// 核销导购
String verificationClerkName = orderInfo.getWriteOffClerkName();
orderDetailVO.setVerificationClerkName(verificationClerkName);
return orderDetailVO;
}
// 订单列表
private RestResponse<Object> orderListSelect(ListOrderManageQDTO qdto, BasePageInfo pageInfo, boolean evaluteFlag) {
qdto.setPageNum(pageInfo.getPageNum());
qdto.setPageSize(pageInfo.getPageSize());
ServiceResponse<Page<ListOrderDTO>> ret = webOrderManageApiService.listOrder(qdto);
logger.info("订单信息={}", JSON.toJSONString(ret, true));
if (ret.isSuccess()) {
Page<ListOrderDTO> page = ret.getResult();
List<OrderListVO> voList = new ArrayList<>();
List<String> orderIdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(page.getResult())) {
List<ListOrderDTO> orderList = page.getResult();
for (ListOrderDTO order : orderList) {
orderIdList.add(order.getOrderId());
OrderListVO vo = EntityUtil.changeEntityByJSON(OrderListVO.class, order);
List<ListOrderItemDTO> itemList = order.getOrderItemDTOList();
List<OrderListItemVO> voItemList = EntityUtil.changeEntityListNew(OrderListItemVO.class, itemList);
vo.setOrderItemList(voItemList);
vo.setPickUpTime(order.getWriteOffTime());
// 核销导购
String verificationClerkName = order.getWriteOffClerkName();
vo.setVerificationClerkName(verificationClerkName);
String clerkId = order.getBelongClerkId();
if (StringUtils.isNotEmpty(clerkId)) {
ClerkDTO clerkDTO = this.clerkService.getclerkById(clerkId);
if (null != clerkDTO) {
vo.setBelongClerkName(clerkDTO.getClerkName());
}
}
voList.add(vo);
}
}
String enterpriseId = qdto.getEnterpriseId();
// 评价
if (evaluteFlag && CollectionUtils.isNotEmpty(orderIdList)) {
ServiceResponse<List<StoreEvaluateInfoDTO>> evaluateResp = evaluateDataApiService
.getEvaluateScoreAndContent(enterpriseId, orderIdList);
Map<String, List<EvaluateVO>> evaluateMap = Optional.ofNullable(evaluateResp)
.map(ServiceResponse::getResult).orElse(new ArrayList<>()).stream().map(data -> {
EvaluateVO evaluateVO = new EvaluateVO();
String evaluateContent = data.getEvaluateContent();
evaluateVO.setEvaluateScoreList(new ArrayList<>());
if (CollectionUtils.isNotEmpty(data.getEvaluateRuleScores())) {
for (EvaluateRuleScoreDTO evaluateScoresDTO : data.getEvaluateRuleScores()) {
EvaluateVO.EvaluateScore evaluateScore = new EvaluateVO.EvaluateScore();
evaluateScore.setName(evaluateScoresDTO.getRuleName());
evaluateScore.setValue(evaluateScoresDTO.getScore());
evaluateVO.getEvaluateScoreList().add(evaluateScore);
}
}
evaluateVO.setReviews(evaluateContent);
evaluateVO.setOrderId(data.getOrderId());
return evaluateVO;
}).collect(Collectors.groupingBy(EvaluateVO::getOrderId));
voList.forEach(item -> {
if (null != evaluateMap.get(item.getOrderId())) {
item.setEvaluateVO(evaluateMap.get(item.getOrderId()).get(0));
}
});
}
Page<OrderListVO> retPage = PageHelperUtils.changePageToCurrentPage(ret.getResult(), OrderListVO.class);
retPage.setResult(voList);
return RestResponse.successResult(retPage);
}
return RestResponse.failure(ret.getCode(), ret.getMessage());
}
private String createIntegralRecord(String enterpriseId, int status, ClerkQo clerkDTO, String writeOffCode) {
DubboResult<IntegralMallExchangeLogDTO> integralResult = integralmallService
.getIntegralMallExchangeLogByWriteOffCode(enterpriseId, writeOffCode);
IntegralMallExchangeLogDTO data = integralResult.getData();
CreateRecordRequest record = new CreateRecordRequest();
record.setRecordId(data.getIntegralMallProExchangeId());
record.setStatus(status);
record.setEnterpriseId(data.getEnterpriseId());
record.setExchangeId(data.getIntegralMallProExchangeId());
record.setFinishTime(data.getFinishTime());
record.setWriteOffCode(data.getWriteOffCode());
// 提货人
record.setConsignee(data.getGoodsPerson());
record.setConsigneePhone(data.getGoodsPhone());
record.setPoint(data.getGoodsPoint());
record.setAddress(data.getGoodsAddress());
record.setTakeTime(data.getGoodsTime());
record.setFetchCode(writeOffCode);
// 核销人
record.setClerkId(clerkDTO.getClerkId());
record.setClerkCode(clerkDTO.getClerkCode());
record.setClerkName(clerkDTO.getClerkName());
record.setHaobanClerkId(clerkDTO.getHaobanClerkId());
record.setHaobanEnterpriseId(clerkDTO.getHaobanEnterpriseId());
// 商品信息
OrderProductRequest productDTO = new OrderProductRequest();
productDTO.setProName(data.getProName());
productDTO.setProImage(data.getPhotoUrl());
productDTO.setProCode(data.getProCode());
productDTO.setProNumber(data.getGoodsNum());
productDTO.setProSku(
StringUtils.isBlank(data.getSku()) ? "[]" : JSONArray.parseArray(data.getSku()).toJSONString());
productDTO.setProPrice((data.getCashShouldPay() / data.getGoodsNum()));
productDTO.setProIntegral((data.getIntegralShouldPay() / data.getGoodsNum()));
List<OrderProductRequest> productDTOS = new ArrayList<>(2);
productDTOS.add(productDTO);
record.setProducts(productDTOS);
record.setCreateTime(data.getCreateTime());
record.setUpdateTime(new Date());
// 订单信息
record.setAllCostIntegral(data.getAllCostIntegral());
record.setPayCost(data.getPayCost());
record.setOrderNo(data.getDefinedCode());
record.setPayNumber(data.getPayNumber());
record.setPayTime(data.getPayTime());
record.setOrigin(2);
return orderVerificationRecordApiService.createRecord(record);
}
private ScanVO integralMallScan(IntegralMallExchangeLogDTO exchangeLogDTO) {
ScanVO scanVO = new ScanVO();
scanVO.setHasOrder(1);
scanVO.setOrderNo(exchangeLogDTO.getDefinedCode());
scanVO.setEnterpriseId(exchangeLogDTO.getEnterpriseId());
scanVO.setExchangeId(exchangeLogDTO.getIntegralMallProExchangeId());
scanVO.setAllCostIntegral(exchangeLogDTO.getAllCostIntegral());
scanVO.setPayCost(exchangeLogDTO.getPayCost());
scanVO.setPayNumber(exchangeLogDTO.getPayNumber());
scanVO.setPayTime(exchangeLogDTO.getPayTime());
ProductVO productVO = new ProductVO();
productVO.setProName(exchangeLogDTO.getProName());
productVO.setProCode(exchangeLogDTO.getProCode());
productVO.setProSku(StringUtils.isBlank(exchangeLogDTO.getSku()) ? new ArrayList<>()
: JSONArray.parseArray(exchangeLogDTO.getSku(), ProductSku.class));
productVO.setProNumber(exchangeLogDTO.getGoodsNum());
productVO.setProImage(exchangeLogDTO.getPhotoUrl());
productVO.setProPrice((exchangeLogDTO.getCashShouldPay() / exchangeLogDTO.getGoodsNum()));
productVO.setProIntegral((exchangeLogDTO.getIntegralShouldPay() / exchangeLogDTO.getGoodsNum()));
scanVO.pushProduct(productVO);
scanVO.setWriteOffCode(exchangeLogDTO.getWriteOffCode());
scanVO.setFetchCode(exchangeLogDTO.getWriteOffCode());
scanVO.setConsignee(exchangeLogDTO.getGoodsPerson());
scanVO.setConsigneePhone(exchangeLogDTO.getGoodsPhone());
scanVO.setPoint(exchangeLogDTO.getGoodsPoint());
scanVO.setAddress(exchangeLogDTO.getGoodsAddress());
scanVO.setTakeTime(exchangeLogDTO.getGoodsTime());
scanVO.setCreateTime(exchangeLogDTO.getCreateTime());
// 兑换状态 -2兑换取消(退货) -1兑换无效 0兑换取消(礼品未付款) 11兑换中(加钱购待支付) 3已发货(礼品) 1兑换功成
// 2领取(卡券) 4成功
// 其实只需要 1 2 4
scanVO.setStatus(exchangeLogDTO.getStatus() == 4 ? 1 : 0);
scanVO.setChecked(0);
if (scanVO.getStatus() == 1) {
scanVO.setRecordId(exchangeLogDTO.getIntegralMallProExchangeId());
OrderVerificationRecordDTO info = orderVerificationRecordApiService.recordInfo(scanVO.getRecordId());
if (null != info) {
// 说明已经核销了
scanVO.setFinishTime(info.getFinishTime());
scanVO.setChecked(1);
}
if (exchangeLogDTO.getStatus() == IntegralMallExchangeLogStatusEnums.CONFIRM.getStatus()) {
scanVO.setFinishTime(exchangeLogDTO.getFinishTime());
scanVO.setChecked(1);
}
}
return scanVO;
}
}
package com.gic.haoban.manage.web.controller.order;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.business.order.dto.member.MemberStoreInfoDTO;
import com.gic.business.order.dto.ordermanage.ListOrderDTO;
import com.gic.business.order.dto.ordermanage.ListOrderItemDTO;
import com.gic.business.order.dto.ordermanage.OrderDetailDTO;
import com.gic.business.order.dto.ordermanage.OrderInfoDTO;
import com.gic.business.order.dto.ordermanage.OrderNodeDTO;
import com.gic.business.order.dto.ordermanage.OrderStatusDTO;
import com.gic.business.order.dto.setting.MallOrderSettingDTO;
import com.gic.business.order.enums.OrderEnum;
import com.gic.business.order.enums.OrderEnum.DeliveryOptTypeEnum;
import com.gic.business.order.enums.OrderEnum.SearchOrderTypeEnum;
import com.gic.business.order.qdto.ordermanage.CountOrderStatusQDTO;
import com.gic.business.order.qdto.ordermanage.ListOrderManageQDTO;
import com.gic.business.order.qdto.ordermanage.OrderItemShipmentQDTO;
import com.gic.business.order.qdto.ordermanage.OrderShipmentQDTO;
import com.gic.business.order.qdto.ordermanage.QueryOrderDetailQDTO;
import com.gic.business.order.qdto.ordermanage.SelfPickOffQDTO;
import com.gic.business.order.qdto.ordermanage.UpdateOrderLogisticsQDTO;
import com.gic.business.order.service.activity.MemberReferClerkApiService;
import com.gic.business.order.service.ordermanage.WebOrderManageApiService;
import com.gic.business.order.service.setting.OrderSettingApiService;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.evaluate.manage.api.dto.EvaluateRuleScoreDTO;
import com.gic.evaluate.manage.api.dto.StoreEvaluateInfoDTO;
import com.gic.evaluate.manage.api.service.EvaluateDataApiService;
import com.gic.haoban.app.aggregation.api.dto.evaluation.CreateRecordRequest;
import com.gic.haoban.app.aggregation.api.dto.evaluation.OrderProductRequest;
import com.gic.haoban.app.aggregation.api.dto.evaluation.OrderVerificationRecordDTO;
import com.gic.haoban.app.aggregation.api.service.evaluation.OrderVerificationRecordApiService;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.order.integral.ClerkQo;
import com.gic.haoban.manage.web.vo.order.EvaluateVO;
import com.gic.haoban.manage.web.vo.order.MemberInfoVO;
import com.gic.haoban.manage.web.vo.order.OrderCountVO;
import com.gic.haoban.manage.web.vo.order.OrderDetailItemVO;
import com.gic.haoban.manage.web.vo.order.OrderDetailVO;
import com.gic.haoban.manage.web.vo.order.OrderListItemVO;
import com.gic.haoban.manage.web.vo.order.OrderListVO;
import com.gic.haoban.manage.web.vo.order.integral.CheckVO;
import com.gic.haoban.manage.web.vo.order.integral.HxOrderCountVO;
import com.gic.haoban.manage.web.vo.order.integral.ProductSku;
import com.gic.haoban.manage.web.vo.order.integral.ProductVO;
import com.gic.haoban.manage.web.vo.order.integral.ScanVO;
import com.gic.integralmall.api.dto.IntegralMallExchangeLogDTO;
import com.gic.integralmall.api.enums.IntegralMallExchangeLogStatusEnums;
import com.gic.integralmall.api.service.IntegralmallService;
import com.gic.integralmall.api.service.result.DubboResult;
import com.gic.store.goods.dto.stock.GoodsStockBaseQDTO;
import com.gic.store.goods.enums.ProductStockChannelType;
import com.gic.store.goods.service.ProductStockApiService;
@RestController
@RequestMapping("/order")
public class GicOrderController {
private static final org.apache.logging.log4j.Logger logger = LogManager.getLogger(GicOrderController.class);
@Autowired
private WebOrderManageApiService webOrderManageApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private MemberReferClerkApiService memberReferClerkApiService;
@Autowired
private IntegralmallService integralmallService;
@Autowired
private OrderVerificationRecordApiService orderVerificationRecordApiService;
@Autowired
private ProductStockApiService productStockApiService;
@Autowired
private OrderSettingApiService orderSettingApiService;
@Autowired
private EvaluateDataApiService evaluateDataApiService;
// 发货订单列表 (0全部,待发货2+待收货3,部分发货7)
@RequestMapping("list-order")
public RestResponse<Object> orderList(String enterpriseId, String storeId, String clerkId, String search,
@RequestParam(defaultValue = "0") int status, BasePageInfo pageInfo) {
String strStatus = "" + status;
if (status == 0) {
strStatus = "2,3,7";
}
if (status == 2) {
strStatus = "2,7";
}
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setOrderStep(strStatus);
// 微商城
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(1);
// 库存 - 门店库存2
qdto.setDeliveryMode(2);
if (StringUtils.isNotEmpty(search)) {
qdto.setSearchOrderType(SearchOrderTypeEnum.GOODS_NAME_OR_ORDER_NUMBER.getType());
qdto.setSearchOrderParam(search);
}
qdto.setBelongStoreId(storeId);
logger.info("发货订单查询,qdto={}", JSON.toJSONString(qdto));
return this.orderListSelect(qdto, pageInfo, false);
}
// 数量查询(待发货+待收货)
// orderType:2待发货 3待收货
@RequestMapping("order-deliver-count")
public RestResponse<Object> orderCount(String enterpriseId, String storeId) {
OrderCountVO vo = new OrderCountVO();
if (StringUtils.isEmpty(storeId)) {
return RestResponse.successResult(vo);
}
CountOrderStatusQDTO qdto = new CountOrderStatusQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(1);
// 库存 - 门店库存2
qdto.setDeliveryMode(2);
qdto.setBelongStoreId(storeId);
ServiceResponse<List<OrderStatusDTO>> resp = this.webOrderManageApiService.countOrderStatus(qdto);
List<OrderStatusDTO> list = resp.getResult();
if (CollectionUtils.isNotEmpty(list)) {
long noDeliver = 0, deliver = 0;
for (OrderStatusDTO item : list) {
if (item.getOrderStep() == 3) {
deliver = item.getTotal();
}
if (item.getOrderStep() == 2 || item.getOrderStep() == 7) {
noDeliver = noDeliver + item.getTotal();
}
}
vo.setDeliverCount((int) deliver);
vo.setNoDeliverCount((int) noDeliver);
vo.setTotal((int) (deliver + noDeliver));
}
return RestResponse.successResult(vo);
}
// 核销订单查询
// status 0全部 1待核销 2已核销
@RequestMapping("list-verification-order")
public RestResponse<Object> mallOrderList(String enterpriseId, String storeId, String clerkId,
@RequestParam(defaultValue = "0") int status, String search, BasePageInfo pageInfo) {
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(2);
qdto.setPickUpStoreId(storeId);
if (status == 1) {
qdto.setOrderStep("2");
}
if (status == 2) {
qdto.setWriteOffClerkId(clerkId);
qdto.setOrderStep("4");
qdto.setDeliveryOptType(1);
}
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
qdto.setSearchOrderParam(search);
return this.orderListSelect(qdto, pageInfo, false);
}
// 订单详情 (客户信息+收货地址+商品详情+订单信息 + 订单状态)
@RequestMapping("order-detail")
public RestResponse<Object> orderDetail(String enterpriseId, String clerkId, String searchParams,
@RequestParam(defaultValue = "1") int orderType, String orderId, String storeId) {
QueryOrderDetailQDTO queryOrderDetailQDTO = new QueryOrderDetailQDTO();
queryOrderDetailQDTO.setOrderId(orderId);
queryOrderDetailQDTO.setEnterpriseId(enterpriseId);
ServiceResponse<OrderDetailDTO> ret = webOrderManageApiService.getOrderDetail(queryOrderDetailQDTO);
if (!ret.isSuccess()) {
return RestResponse.failure(ret.getCode(), ret.getMessage());
}
logger.info("订单信息={}", JSON.toJSONString(ret, true));
OrderDetailVO detail = this.getOrderDetail(enterpriseId, ret.getResult().getOrderInfo(),
ret.getResult().getOrderItemList(), storeId);
if (CollectionUtils.isNotEmpty(ret.getResult().getOrderWrapList())) {
List<String> idList = ret.getResult().getOrderWrapList().stream().map(o -> o.getMallOrderLogisticsId())
.collect(Collectors.toList());
detail.setOrderLogisticsIdList(idList);
}
detail.setCreateTime(OrderDetailDTO.getNodeTimeStatic(OrderEnum.OrderNodeEnum.PLACE_AN_ORDER,
ret.getResult().getOrderNodeList()));
detail.setPayTime(OrderDetailDTO.getNodeTimeStatic(OrderEnum.OrderNodeEnum.PAY_ORDER,
ret.getResult().getOrderNodeList()));
// 如果是自提
if (null != detail.getDeliveryChannel() && detail.getDeliveryChannel() == 2) {
detail.setPickUpTime(OrderDetailDTO.getNodeTimeStatic(OrderEnum.OrderNodeEnum.SUCCESSFUL,
ret.getResult().getOrderNodeList()));
}
// 自动收货时间
List<OrderNodeDTO> stepList = ret.getResult().getOrderNodeList();
if (CollectionUtils.isNotEmpty(stepList)) {
stepList.forEach(item -> {
if (item.getOrderStep() == 3) {
ServiceResponse<MallOrderSettingDTO> setResp = this.orderSettingApiService
.getOrderSetting(enterpriseId);
int autoDay = setResp.getResult().getAutoConfirm();
if (0 != autoDay) {
detail.setAutoTaskOverTime(DateUtil.addNumForDay(item.getCreateTime(), autoDay));
return;
}
}
});
}
return RestResponse.successResult(detail);
}
/**
* 扫码二维码
*/
@RequestMapping("/scan")
public RestResponse<Object> scan(String enterpriseId, String writeOffCode, String storeId) {
if (StringUtils.isEmpty(writeOffCode)) {
return RestResponse.failure("9999", "核销码为空");
}
// 微商城
if (writeOffCode.startsWith("M")) {
// 通过核销码查询
QueryOrderDetailQDTO qdto = new QueryOrderDetailQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setWriteOffCode(writeOffCode);
ServiceResponse<OrderDetailDTO> ret = webOrderManageApiService.getOrderDetail(qdto);
OrderDetailDTO detail = ret.getResult();
logger.info("订单信息={}", JSON.toJSONString(ret, true));
if (ret.isSuccess()) {
// 已核销,且不是好办核销的
if (null != detail.getOrderInfo().getDeliveryOptType()
&& detail.getOrderInfo().getDeliveryOptType() != 1) {
logger.info("已核销,且不是好办核销的={}", writeOffCode);
return RestResponse.failure("9999", "此自提点无法核销");
}
if (!storeId.equals(detail.getOrderInfo().getPickUpStoreId())) {
return RestResponse.failure("9999", "此自提点无法核销");
}
OrderDetailVO orderDetailVO = this.getOrderDetail(enterpriseId, ret.getResult().getOrderInfo(),
ret.getResult().getOrderItemList(), storeId);
return RestResponse.successResult(orderDetailVO);
} else {
return RestResponse.failure("9999", ret.getMessage());
}
} else {
// 积分商城
DubboResult<IntegralMallExchangeLogDTO> integralResult = integralmallService
.getIntegralMallExchangeLogByWriteOffCode(enterpriseId, writeOffCode);
if (null != integralResult && null != integralResult.getData()) {
ScanVO vo = integralMallScan(integralResult.getData());
return RestResponse.successResult(vo);
}
}
return RestResponse.failure("9999", "订单查询不到");
}
// 单笔订单发货商品列表
@RequestMapping("order-deliver-list")
public RestResponse<Object> orderDeliverList(String enterpriseId, String storeId, String orderId) {
QueryOrderDetailQDTO qdto = new QueryOrderDetailQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setOrderId(orderId);
ServiceResponse<OrderDetailDTO> resp = webOrderManageApiService.getOrderDetail(qdto);
List<ListOrderItemDTO> list = resp.getResult().getOrderItemList();
List<OrderListItemVO> voList = new ArrayList<>();
for (ListOrderItemDTO item : list) {
if (StringUtils.isEmpty(item.getLogisticsId())) {
OrderListItemVO vo = EntityUtil.changeEntityByJSON(OrderListItemVO.class, item);
GoodsStockBaseQDTO stockQDTO = new GoodsStockBaseQDTO();
stockQDTO.setEnterpriseId(enterpriseId);
stockQDTO.setGoodsId(vo.getMallProId());
stockQDTO.setSkuId(vo.getMallProSkuId());
stockQDTO.setStoreId(storeId);
stockQDTO.setChannelType(ProductStockChannelType.MALL.getCode());
ServiceResponse<Integer> stockResp = this.productStockApiService.queryGoodsStock(stockQDTO);
logger.info("门店库存查询orderId={},qdto={},result={}", orderId, JSON.toJSONString(stockQDTO),
JSON.toJSONString(stockResp));
if (stockResp.isSuccess() && null != stockResp.getResult()) {
vo.setStoreStock(stockResp.getResult());
}
voList.add(vo);
}
}
return RestResponse.successResult(voList);
}
// 订单-发货
@RequestMapping("order-logistics-deliver")
public RestResponse<Object> orderDeliver(String enterpriseId, String orderId, String storeId, String orderItemIds,
String companyCode, String logisticsNo, String companyId, String companyName) {
OrderShipmentQDTO qdto = new OrderShipmentQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setLogisticsCompanyCode(companyCode);
qdto.setLogisticsCompanyName(companyName);
qdto.setLogisticsCompanyId(companyId);
qdto.setCourierNumber(logisticsNo);
qdto.setOrderId(orderId);
// 门店发货
qdto.setDeliveryMode(2);
// 好办后台发货
qdto.setSource(DeliveryOptTypeEnum.HAOBAN.getCode());
List<String> orderItemIdList = Arrays.asList(orderItemIds.split(","));
List<OrderItemShipmentQDTO> list = new ArrayList<>();
orderItemIdList.forEach(o -> {
OrderItemShipmentQDTO item = new OrderItemShipmentQDTO();
item.setOrderItemId(o);
item.setStoreId(storeId);
list.add(item);
});
qdto.setOrderItemShipment(list);
ServiceResponse<Boolean> resp = webOrderManageApiService.orderShipment(qdto);
if (!resp.isSuccess()) {
/*
* String code = resp.getCode(); if (Arrays.asList("900001",
* "300105", "200001").contains(code)) { return
* RestResponse.failure(HaoBanErrCode.ERR_9600.getCode() + "",
* "请刷新页面"); }
*/
return RestResponse.failure(HaoBanErrCode.ERR_9600.getCode() + "", "请刷新页面");
}
return RestResponse.successResult(resp.getResult());
}
// 我的客户-会员订单列表
// deliveryChannel 0全部 1快递 2自提
// -1全部 1待付款 2待发货 7部分发货 4已完成 0已取消 5售后中
// orderType -1 全部 0:会员自行购买 1导购推荐订单
@RequestMapping("list-member-order")
public RestResponse<Object> orderList(String enterpriseId, String memberId, String search,
@RequestParam(defaultValue = "-1") int status, @RequestParam(defaultValue = "0") int deliveryChannel,
@RequestParam(defaultValue = "-1") int orderType, BasePageInfo pageInfo, String startTime, String endTime) {
if (StringUtils.isEmpty(memberId)) {
return RestResponse.failure("9999", "memberId为空");
}
String strStatus = "" + status;
// 全部
if (status == -1) {
strStatus = null;
}
// 售后中
if (status == 5) {
strStatus = "11";
}
Date startDate = null;
if (StringUtils.isNotEmpty(startTime)) {
startDate = DateUtil.strToDate(startTime, "yyyy-MM-dd");
}
Date endDate = null;
if (StringUtils.isNotEmpty(endTime)) {
endDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
endDate = DateUtil.getEndTimeOfDay(endDate);
}
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setOrderStep(strStatus);
qdto.setMemberId(memberId);
qdto.setStartDate(startDate);
qdto.setEndDate(endDate);
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
if (StringUtils.isNotEmpty(search)) {
qdto.setSearchOrderType(SearchOrderTypeEnum.ORDER_NUMBER.getType());
qdto.setSearchOrderParam(search);
}
return this.orderListSelect(qdto, pageInfo, true);
}
// 修改物流
// type : 1: 下单 2:换货
@RequestMapping("modify-order-logistics")
public RestResponse<Object> modifyOrderDeliver(String memberId, String enterpriseId, String orderId, String storeId,
String logisticsId, String companyCode, String logisticsNo, String companyId, String companyName,
@RequestParam(defaultValue = "1") int type) {
logger.info("修改物流={},{}", orderId, type);
UpdateOrderLogisticsQDTO qdto = new UpdateOrderLogisticsQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setLogisticsCompanyCode(companyCode);
qdto.setLogisticsCompanyName(companyName);
qdto.setLogisticsCompanyId(companyId);
qdto.setCourierNumber(logisticsNo);
qdto.setOrderId(orderId);
qdto.setLogisticsId(logisticsId);
qdto.setType(type);
this.webOrderManageApiService.updateOrderLogistics(qdto);
return RestResponse.successResult();
}
/**
* 核销订单
*/
@RequestMapping("/verification")
public RestResponse<Object> verification(String enterpriseId, String clerkId, String writeOffCode, String orderId) {
if (StringUtils.isEmpty(writeOffCode)) {
return RestResponse.failure("9999", "核销码为空");
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
if (null == clerkDTO) {
return RestResponse.failure("9999", "核销人不存在");
}
// 微商城核销
if (writeOffCode.startsWith("M")) {
if (StringUtils.isEmpty(orderId)) {
return RestResponse.failure("9999", "订单ID为空");
}
SelfPickOffQDTO qdto = new SelfPickOffQDTO();
qdto.setEnterpriseId(enterpriseId);
qdto.setWriteOffClerkId(clerkId);
qdto.setWriteOffCode(writeOffCode);
qdto.setSource(1);
qdto.setWriteOffClerkCode(clerkDTO.getClerkCode());
qdto.setOrderId(orderId);
ServiceResponse<Boolean> response = webOrderManageApiService.selfPickOff(qdto);
if (!response.isSuccess()) {
return RestResponse.failure(response.getCode(), response.getMessage());
}
return RestResponse.successResult(response.getResult());
} else {
ClerkQo clerkQo = new ClerkQo();
clerkQo.setClerkCode(clerkDTO.getClerkCode());
clerkQo.setClerkId(clerkDTO.getClerkId());
clerkQo.setStoreId(clerkDTO.getStoreId());
clerkQo.setClerkName(clerkDTO.getClerkName());
clerkQo.setEnterpriseId(enterpriseId);
logger.info("积分商城订单核销开始,核销码:{} ,核销人:{} ", writeOffCode, clerkQo.getClerkId());
enterpriseId = clerkDTO.getEnterpriseId();
DubboResult<Boolean> check = integralmallService.haobanVerificationExchangeLog(enterpriseId, writeOffCode,
clerkQo.getClerkCode(), clerkQo.getClerkName(), clerkQo.getStoreId());
logger.info("核销结果:{} ", JSON.toJSONString(check));
CheckVO checkVO = new CheckVO();
if (check.getSuccess()) {
// 积分商城核销成功-添加核销记录
String recordId = createIntegralRecord(enterpriseId, 1, clerkQo, writeOffCode);
checkVO.setId(recordId);
checkVO.setSuccess(Boolean.TRUE);
checkVO.setCode(HaoBanErrCode.ERR_1.getCode());
return RestResponse.successResult(checkVO);
}
/*
* 核销失败情况 10001 兑换记录不存在 10002 当前订单状态无法核销 10003 该订单已经核销 10004 订单已经取消
* 10005 10006 超期核销
*/
checkVO.setCode(check.getErrorCode());
checkVO.setMessage(check.getErrMessage());
checkVO.setSuccess(Boolean.FALSE);
if (check.getErrorCode() == HaoBanErrCode.ERR_100010.getCode()) {
// 订单已核销
OrderVerificationRecordDTO record = orderVerificationRecordApiService
.getRecordByClerkIdAndWriteOffCode(clerkQo.getClerkId(), writeOffCode);
if (Objects.nonNull(record)) {
checkVO.setSuccess(Boolean.TRUE);
checkVO.setId(record.getRecordId());
return RestResponse.successResult(checkVO);
}
// 超期核销
checkVO.setCode(HaoBanErrCode.ERR_100014.getCode());
checkVO.setMessage(HaoBanErrCode.ERR_100014.getMsg());
}
if (!checkVO.getSuccess()) {
HaobanResponse response = new HaobanResponse();
response.setMessage(checkVO.getMessage());
response.setErrorCode(checkVO.getCode());
response.setResult(checkVO.getId());
response.setDetailError("");
return RestResponse.failure("9999", checkVO.getMessage());
}
return RestResponse.successResult(checkVO) ;
}
}
// 核销数量
@RequestMapping("/verification-count")
public RestResponse<Object> verificationCountNew(String enterpriseId, String storeId, String clerkId) {
Page<IntegralMallExchangeLogDTO> page = new Page<IntegralMallExchangeLogDTO>();
page.setPageSize(1);
page.setCurrentPage(1);
Map<String, Object> params = new HashMap<>();
params.put("enterpriseId", enterpriseId);
params.put("proType", 2);
params.put("changeType", 4);
// 订单状态
params.put("orderStatus", 1);
params.put("goodsPointStoreId", storeId);
page.setParams(params);
page = integralmallService.listOnlineByPage(page);
int integralUndoneCount = page.getTotalCount();
int integralDoneCount = this.orderVerificationRecordApiService.countByGicClerkId(clerkId);
// 查询微商城
int mallDoneCount = this.count(enterpriseId, storeId, clerkId, 4);
int mallUndoneCount = this.count(enterpriseId, storeId, clerkId, 2);
HxOrderCountVO vo = new HxOrderCountVO();
vo.setIntegralDoneCount(integralDoneCount);
vo.setIntegralUndoneCount(integralUndoneCount);
vo.setMallDoneCount(mallDoneCount);
vo.setMallUndoneCount(mallUndoneCount);
vo.setTotalDoneCount(integralDoneCount + mallDoneCount);
vo.setTotalUndownCount(integralUndoneCount + mallUndoneCount);
return RestResponse.successResult(vo);
}
private int count(String enterpriseId, String storeId, String clerkId, int step) {
// 查询门店
ListOrderManageQDTO qdto = new ListOrderManageQDTO();
qdto.setEnterpriseId(enterpriseId);
// 配送方式 -1:所有 2:门店自提 1:快递发货
qdto.setDeliveryChannel(2);
qdto.setPickUpStoreId(storeId);
if (step == 4) {
qdto.setWriteOffClerkId(clerkId);
qdto.setDeliveryOptType(1);
}
qdto.setOrderStep("" + step);
qdto.setBusinessType(OrderEnum.BusinessTypeEnum.MICRO_MALL.getType());
qdto.setPageNum(1);
qdto.setPageSize(1);
ServiceResponse<Page<ListOrderDTO>> ret = webOrderManageApiService.listOrder(qdto);
logger.info("核销订单数={}");
return ret.getResult().getTotalCount();
}
// 订单详情
private OrderDetailVO getOrderDetail(String enterpriseId, OrderInfoDTO orderInfo,
List<ListOrderItemDTO> orderItemDTOList, String storeId) {
OrderDetailVO orderDetailVO = EntityUtil.changeEntityByJSON(OrderDetailVO.class, orderInfo);
orderDetailVO.setBuyerRemark(orderInfo.getRemarks());
List<OrderDetailItemVO> orderItemList = EntityUtil.changeEntityListNew(OrderDetailItemVO.class,
orderItemDTOList);
orderDetailVO.setOrderItemList(orderItemList);
String memberId = orderInfo.getMemberId();
MemberInfoVO member = new MemberInfoVO();
member.setMemberId(memberId);
if (StringUtils.isNotEmpty(memberId)) {
ServiceResponse<MemberStoreInfoDTO> memberResp = this.memberReferClerkApiService.getMemberInfo(enterpriseId,
memberId);
MemberStoreInfoDTO memberInfo = memberResp.getResult();
if (null != memberInfo) {
member = EntityUtil.changeEntityByJSON(MemberInfoVO.class, memberInfo);
}
}
member.setAddressPhone(orderInfo.getBuyerPhone());
member.setAddressName(orderInfo.getBuyerName());
member.setAddressDetail(orderInfo.getFullName() + orderInfo.getAddressInfo());
orderDetailVO.setAddressInfo(orderInfo.getFullName() + orderInfo.getAddressInfo());
orderDetailVO.setMember(member);
// 判断能否发货
// 导购发货,一笔订单仅允许单门店发货
boolean canDeliverFlag = false;
// 发货操作类型(0后台/1好办门店):用于判断好办操作发货还是后台,防止双边发货
Integer deliveryOptType = orderInfo.getDeliveryOptType();
logger.info("发货类型1好办={},orderId={}", deliveryOptType, orderInfo.getOrderId());
if (null == deliveryOptType) {
canDeliverFlag = true;
} else if (deliveryOptType == 1) {
canDeliverFlag = true;
}
orderDetailVO.setCanDeliverFlag(canDeliverFlag);
// 核销导购
String verificationClerkName = orderInfo.getWriteOffClerkName();
orderDetailVO.setVerificationClerkName(verificationClerkName);
return orderDetailVO;
}
// 订单列表
private RestResponse<Object> orderListSelect(ListOrderManageQDTO qdto, BasePageInfo pageInfo, boolean evaluteFlag) {
qdto.setPageNum(pageInfo.getPageNum());
qdto.setPageSize(pageInfo.getPageSize());
ServiceResponse<Page<ListOrderDTO>> ret = webOrderManageApiService.listOrder(qdto);
logger.info("订单信息={}", JSON.toJSONString(ret, true));
if (ret.isSuccess()) {
Page<ListOrderDTO> page = ret.getResult();
List<OrderListVO> voList = new ArrayList<>();
List<String> orderIdList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(page.getResult())) {
List<ListOrderDTO> orderList = page.getResult();
for (ListOrderDTO order : orderList) {
orderIdList.add(order.getOrderId());
OrderListVO vo = EntityUtil.changeEntityByJSON(OrderListVO.class, order);
List<ListOrderItemDTO> itemList = order.getOrderItemDTOList();
List<OrderListItemVO> voItemList = EntityUtil.changeEntityListNew(OrderListItemVO.class, itemList);
vo.setOrderItemList(voItemList);
vo.setPickUpTime(order.getWriteOffTime());
// 核销导购
String verificationClerkName = order.getWriteOffClerkName();
vo.setVerificationClerkName(verificationClerkName);
String clerkId = order.getBelongClerkId();
if (StringUtils.isNotEmpty(clerkId)) {
ClerkDTO clerkDTO = this.clerkService.getclerkById(clerkId);
if (null != clerkDTO) {
vo.setBelongClerkName(clerkDTO.getClerkName());
}
}
voList.add(vo);
}
}
String enterpriseId = qdto.getEnterpriseId();
// 评价
if (evaluteFlag && CollectionUtils.isNotEmpty(orderIdList)) {
ServiceResponse<List<StoreEvaluateInfoDTO>> evaluateResp = evaluateDataApiService
.getEvaluateScoreAndContent(enterpriseId, orderIdList);
Map<String, List<EvaluateVO>> evaluateMap = Optional.ofNullable(evaluateResp)
.map(ServiceResponse::getResult).orElse(new ArrayList<>()).stream().map(data -> {
EvaluateVO evaluateVO = new EvaluateVO();
String evaluateContent = data.getEvaluateContent();
evaluateVO.setEvaluateScoreList(new ArrayList<>());
if (CollectionUtils.isNotEmpty(data.getEvaluateRuleScores())) {
for (EvaluateRuleScoreDTO evaluateScoresDTO : data.getEvaluateRuleScores()) {
EvaluateVO.EvaluateScore evaluateScore = new EvaluateVO.EvaluateScore();
evaluateScore.setName(evaluateScoresDTO.getRuleName());
evaluateScore.setValue(evaluateScoresDTO.getScore());
evaluateVO.getEvaluateScoreList().add(evaluateScore);
}
}
evaluateVO.setReviews(evaluateContent);
evaluateVO.setOrderId(data.getOrderId());
return evaluateVO;
}).collect(Collectors.groupingBy(EvaluateVO::getOrderId));
voList.forEach(item -> {
if (null != evaluateMap.get(item.getOrderId())) {
item.setEvaluateVO(evaluateMap.get(item.getOrderId()).get(0));
}
});
}
Page<OrderListVO> retPage = PageHelperUtils.changePageToCurrentPage(ret.getResult(), OrderListVO.class);
retPage.setResult(voList);
return RestResponse.successResult(retPage);
}
return RestResponse.failure(ret.getCode(), ret.getMessage());
}
private String createIntegralRecord(String enterpriseId, int status, ClerkQo clerkDTO, String writeOffCode) {
DubboResult<IntegralMallExchangeLogDTO> integralResult = integralmallService
.getIntegralMallExchangeLogByWriteOffCode(enterpriseId, writeOffCode);
IntegralMallExchangeLogDTO data = integralResult.getData();
CreateRecordRequest record = new CreateRecordRequest();
record.setRecordId(data.getIntegralMallProExchangeId());
record.setStatus(status);
record.setEnterpriseId(data.getEnterpriseId());
record.setExchangeId(data.getIntegralMallProExchangeId());
record.setFinishTime(data.getFinishTime());
record.setWriteOffCode(data.getWriteOffCode());
// 提货人
record.setConsignee(data.getGoodsPerson());
record.setConsigneePhone(data.getGoodsPhone());
record.setPoint(data.getGoodsPoint());
record.setAddress(data.getGoodsAddress());
record.setTakeTime(data.getGoodsTime());
record.setFetchCode(writeOffCode);
// 核销人
record.setClerkId(clerkDTO.getClerkId());
record.setClerkCode(clerkDTO.getClerkCode());
record.setClerkName(clerkDTO.getClerkName());
record.setHaobanClerkId(clerkDTO.getHaobanClerkId());
record.setHaobanEnterpriseId(clerkDTO.getHaobanEnterpriseId());
// 商品信息
OrderProductRequest productDTO = new OrderProductRequest();
productDTO.setProName(data.getProName());
productDTO.setProImage(data.getPhotoUrl());
productDTO.setProCode(data.getProCode());
productDTO.setProNumber(data.getGoodsNum());
productDTO.setProSku(
StringUtils.isBlank(data.getSku()) ? "[]" : JSONArray.parseArray(data.getSku()).toJSONString());
productDTO.setProPrice((data.getCashShouldPay() / data.getGoodsNum()));
productDTO.setProIntegral((data.getIntegralShouldPay() / data.getGoodsNum()));
List<OrderProductRequest> productDTOS = new ArrayList<>(2);
productDTOS.add(productDTO);
record.setProducts(productDTOS);
record.setCreateTime(data.getCreateTime());
record.setUpdateTime(new Date());
// 订单信息
record.setAllCostIntegral(data.getAllCostIntegral());
record.setPayCost(data.getPayCost());
record.setOrderNo(data.getDefinedCode());
record.setPayNumber(data.getPayNumber());
record.setPayTime(data.getPayTime());
record.setOrigin(2);
return orderVerificationRecordApiService.createRecord(record);
}
private ScanVO integralMallScan(IntegralMallExchangeLogDTO exchangeLogDTO) {
ScanVO scanVO = new ScanVO();
scanVO.setHasOrder(1);
scanVO.setOrderNo(exchangeLogDTO.getDefinedCode());
scanVO.setEnterpriseId(exchangeLogDTO.getEnterpriseId());
scanVO.setExchangeId(exchangeLogDTO.getIntegralMallProExchangeId());
scanVO.setAllCostIntegral(exchangeLogDTO.getAllCostIntegral());
scanVO.setPayCost(exchangeLogDTO.getPayCost());
scanVO.setPayNumber(exchangeLogDTO.getPayNumber());
scanVO.setPayTime(exchangeLogDTO.getPayTime());
ProductVO productVO = new ProductVO();
productVO.setProName(exchangeLogDTO.getProName());
productVO.setProCode(exchangeLogDTO.getProCode());
productVO.setProSku(StringUtils.isBlank(exchangeLogDTO.getSku()) ? new ArrayList<>()
: JSONArray.parseArray(exchangeLogDTO.getSku(), ProductSku.class));
productVO.setProNumber(exchangeLogDTO.getGoodsNum());
productVO.setProImage(exchangeLogDTO.getPhotoUrl());
productVO.setProPrice((exchangeLogDTO.getCashShouldPay() / exchangeLogDTO.getGoodsNum()));
productVO.setProIntegral((exchangeLogDTO.getIntegralShouldPay() / exchangeLogDTO.getGoodsNum()));
scanVO.pushProduct(productVO);
scanVO.setWriteOffCode(exchangeLogDTO.getWriteOffCode());
scanVO.setFetchCode(exchangeLogDTO.getWriteOffCode());
scanVO.setConsignee(exchangeLogDTO.getGoodsPerson());
scanVO.setConsigneePhone(exchangeLogDTO.getGoodsPhone());
scanVO.setPoint(exchangeLogDTO.getGoodsPoint());
scanVO.setAddress(exchangeLogDTO.getGoodsAddress());
scanVO.setTakeTime(exchangeLogDTO.getGoodsTime());
scanVO.setCreateTime(exchangeLogDTO.getCreateTime());
// 兑换状态 -2兑换取消(退货) -1兑换无效 0兑换取消(礼品未付款) 11兑换中(加钱购待支付) 3已发货(礼品) 1兑换功成
// 2领取(卡券) 4成功
// 其实只需要 1 2 4
scanVO.setStatus(exchangeLogDTO.getStatus() == 4 ? 1 : 0);
scanVO.setChecked(0);
if (scanVO.getStatus() == 1) {
scanVO.setRecordId(exchangeLogDTO.getIntegralMallProExchangeId());
OrderVerificationRecordDTO info = orderVerificationRecordApiService.recordInfo(scanVO.getRecordId());
if (null != info) {
// 说明已经核销了
scanVO.setFinishTime(info.getFinishTime());
scanVO.setChecked(1);
}
if (exchangeLogDTO.getStatus() == IntegralMallExchangeLogStatusEnums.CONFIRM.getStatus()) {
scanVO.setFinishTime(exchangeLogDTO.getFinishTime());
scanVO.setChecked(1);
}
}
return scanVO;
}
}
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