Commit 5f5fb55c by 徐高华

激活码

parent a1e7f422
......@@ -14,8 +14,6 @@ public class TabHaobanQywxFeeAccountStaff implements Serializable {
private Long feeAccountStaffId;
private String orderId;
private String corpId;
private String wxEnterpriseId;
......@@ -49,14 +47,6 @@ public class TabHaobanQywxFeeAccountStaff implements Serializable {
this.feeAccountStaffId = feeAccountStaffId;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getCorpId() {
return corpId;
}
......
package com.gic.haoban.manage.service.service.fee.impl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,6 +17,11 @@ import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderService;
*/
@Service
public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService {
private static Logger logger = LogManager.getLogger(HaobanQywxFeeOrderService.class);
@Autowired
private TabHaobanQywxFeeOrderMapper tabHaobanQywxFeeOrderMapper;
......@@ -30,6 +37,7 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
String orderId = tabHaobanQywxFeeOrder.getOrderId() ;
TabHaobanQywxFeeOrder tab = this.tabHaobanQywxFeeOrderMapper.selectByOrderId(wxEnterpriseId, orderId) ;
if(null != tab) {
logger.info("订单记录已经存在,orderId={}",orderId);
return tab ;
}
this.tabHaobanQywxFeeOrderMapper.insert(tabHaobanQywxFeeOrder);
......
......@@ -47,6 +47,7 @@ import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderAccountServic
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderService;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.fee.AccountListDTO;
import com.gic.wechat.api.dto.qywx.fee.AccountListResponseDTO;
import com.gic.wechat.api.dto.qywx.fee.ActiveInfoCodeResponseDTO;
......@@ -55,6 +56,7 @@ import com.gic.wechat.api.dto.qywx.fee.FeeOrderResponseList;
import com.gic.wechat.api.dto.qywx.fee.qdto.FeeOrderListQDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
@Service("haobanQywxFeeApiService")
......@@ -98,11 +100,13 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
List<String> orderIds = new ArrayList<>();
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setCorpid(corpid);
//feeOrderListQDTO.setStartTime(DateUtil.beginOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
//feeOrderListQDTO.setEndTime(DateUtil.endOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
if(null == RedisUtil.getCache("qywx-order-search-date")) {
feeOrderListQDTO.setStartTime(DateUtil.beginOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
feeOrderListQDTO.setEndTime(DateUtil.endOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
}
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
FeeOrderResponseList feeOrderResponseList = qywxUserApiService.listOrder(corpid, config.getCorpid(), feeOrderListQDTO);
logger.error("查询订单列表,{}", JSON.toJSONString(feeOrderResponseList));
logger.error("查询激活码订单,{}", JSON.toJSONString(feeOrderResponseList));
int errcode = feeOrderResponseList.getErrcode();
if (errcode == 0) {
for (FeeOrderResponseList.OrderListDTO orderListDTO : feeOrderResponseList.getOrderList()) {
......@@ -112,6 +116,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
return orderIds ;
}
// 查询订单下的激活码code列表
private void getOrderAccount(String orderId , String corpid , String cursor , List<Map<String, String>> activeCodeList) {
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setOrderId(orderId);
......@@ -122,8 +127,8 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
logger.info("订单账号列表报错:{}", accountListResponseDTO.getErrmsg());
return ;
}
// 只记录互通账号
for (AccountListDTO accountListDTO : accountListResponseDTO.getAccountList()) {
// 只记录互通账号
if(accountListDTO.getType()==2) {
Map<String, String> map = new HashMap<>();
map.put("orderId", orderId);
......@@ -131,7 +136,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
activeCodeList.add(map);
}
}
cursor = accountListResponseDTO.getNextCursor() ;
Integer hasMore = accountListResponseDTO.getHasMore();
if (hasMore == 1 && StringUtils.isNotBlank(cursor)) {
......@@ -192,20 +196,22 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFeeOrder.setMonths(orderDTO.getAccountDuration().getMonths());
tabHaobanQywxFeeOrder.setCreateTime(DateUtil.date(orderDTO.getCreateTime() * 1000));
tabHaobanQywxFeeOrder.setPayTime(DateUtil.date(orderDTO.getPayTime() * 1000));
// 增加到订单表,如果存在不更新
this.haobanQywxFeeOrderService.insert(tabHaobanQywxFeeOrder);
// 查询订单下的激活码code列表,记录到activeCodeList
this.getOrderAccount(orderId, corpid, null, activeCodeList);
}
//处理订单账号
if (CollectionUtils.isNotEmpty(activeCodeList)) {
addOrderAccount(wxEnterpriseId, serviceCorpid, corpid, activeCodeList);
}
//处理订单下激活账号
this.addOrderAccount(wxEnterpriseId, serviceCorpid, corpid, activeCodeList);
//更新收费
//统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数
HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = haobanQywxFeeAccountStaffService.feeIntercept(wxEnterpriseId);
// 未激活数(状态1)
int permissionUserNum = haobanQywxFeeOrderAccountService.countOrderAccountStatus(1, wxEnterpriseId);
// 待转移数(状态4)
int transferUserNum = haobanQywxFeeOrderAccountService.countOrderAccountStatus(4, wxEnterpriseId);
int totalCount = this.haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId) ;
if (haobanQywxFeeDetailDTO != null && permissionUserNum > 0) {
TabHaobanQywxFee tabHaobanQywxFee = new TabHaobanQywxFee();
tabHaobanQywxFee.setQwFeeId(UniqueIdUtils.uniqueLong());
......@@ -216,7 +222,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFee.setInterceptUserNum(haobanQywxFeeDetailDTO.getInterceptUserNum());
tabHaobanQywxFee.setPermissionUserNum(permissionUserNum);
tabHaobanQywxFee.setTransferUserNum(transferUserNum);
tabHaobanQywxFee.setBuyPermissionUserNum(haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId));
tabHaobanQywxFee.setBuyPermissionUserNum(totalCount);
tabHaobanQywxFee.setInterceptFlag(0);
haobanQywxFeeService.insert(tabHaobanQywxFee);
//判断今天是否是本月最后一天
......@@ -227,24 +233,26 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName(), content);
}
}
List<TabHaobanQywxFeeAccountInterceptLog> tabHaobanQywxFeeAccountInterceptLogs = haobanQywxFeeAccountInterceptLogService.queryByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(tabHaobanQywxFeeAccountInterceptLogs)) {
// 更加企微通知记录已拦截数
List<TabHaobanQywxFeeAccountInterceptLog> interceptLogs = haobanQywxFeeAccountInterceptLogService.queryByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(interceptLogs)) {
TabHaobanQywxFee tabHaobanQywxFee = new TabHaobanQywxFee();
tabHaobanQywxFee.setQwFeeId(UniqueIdUtils.uniqueLong());
tabHaobanQywxFee.setCorpName(corpName);
tabHaobanQywxFee.setCorpId(corpid);
tabHaobanQywxFee.setWxEnterpriseId(wxEnterpriseId);
tabHaobanQywxFee.setInterceptTime(DateUtil.offsetDay(new Date(), -1));
tabHaobanQywxFee.setInterceptUserNum(tabHaobanQywxFeeAccountInterceptLogs.size());
tabHaobanQywxFee.setInterceptUserNum(interceptLogs.size());
tabHaobanQywxFee.setPermissionUserNum(permissionUserNum);
tabHaobanQywxFee.setTransferUserNum(transferUserNum);
tabHaobanQywxFee.setBuyPermissionUserNum(haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId));
tabHaobanQywxFee.setBuyPermissionUserNum(totalCount);
tabHaobanQywxFee.setInterceptFlag(1);
haobanQywxFeeService.insert(tabHaobanQywxFee);
}
}
// 保存订单下的激活码信息-tab_haoban_qywx_fee_order_account
private void addOrderAccount(String wxEnterpriseId, String serviceCorpid, String corpid, List<Map<String, String>> activeCodeList) {
if (CollectionUtils.isEmpty(activeCodeList)) {
logger.error("订单账号无激活码");
......@@ -254,6 +262,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
String activeCode = activeCodeMap.get("activeCode");
String orderId = activeCodeMap.get("orderId");
TabHaobanQywxFeeOrderAccount activeAccount = new TabHaobanQywxFeeOrderAccount();
// 查询激活码的详情
ActiveInfoCodeResponseDTO activeDetail = qywxUserApiService.getActiveInfoByCode(corpid, serviceCorpid, activeCode);
if (activeDetail.getErrcode() == 0) {
String userid = activeDetail.getUserid();
......
......@@ -4,7 +4,6 @@
<resultMap type="com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff" id="TabHaobanQywxFeeAccountStaffMap">
<result property="feeAccountStaffId" column="fee_account_staff_id" jdbcType="INTEGER"/>
<result property="orderId" column="order_id" jdbcType="VARCHAR"/>
<result property="corpId" column="corp_id" jdbcType="VARCHAR"/>
<result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/>
<result property="staffId" column="staff_id" jdbcType="VARCHAR"/>
......@@ -16,7 +15,7 @@
<sql id="Base_Column_List">
fee_account_staff_id
, order_id, corp_id, wx_enterprise_id, staff_id, active_code, account_type, expire_time, active_time
, corp_id, wx_enterprise_id, staff_id, active_code, account_type, expire_time, active_time
</sql>
<!--查询单个-->
......@@ -29,9 +28,9 @@
<!--新增所有列-->
<insert id="insert">
insert into tab_haoban_qywx_fee_account_staff(fee_account_staff_id, order_id, corp_id, wx_enterprise_id,
insert into tab_haoban_qywx_fee_account_staff(fee_account_staff_id, corp_id, wx_enterprise_id,
staff_id, active_code, account_type, expire_time, active_time)
values (#{feeAccountStaffId}, #{orderId}, #{corpId}, #{wxEnterpriseId}, #{staffId}, #{activeCode},
values (#{feeAccountStaffId}, #{corpId}, #{wxEnterpriseId}, #{staffId}, #{activeCode},
#{accountType}, #{expireTime}, #{activeTime})
</insert>
......@@ -39,9 +38,6 @@
<update id="update">
update tab_haoban_qywx_fee_account_staff
<set>
<if test="orderId != null and orderId != ''">
order_id = #{orderId},
</if>
<if test="corpId != null and corpId != ''">
corp_id = #{corpId},
</if>
......@@ -84,7 +80,7 @@
from tab_haoban_qywx_fee_account_staff
where wx_enterprise_id = #{wxEnterpriseId}
and expire_time between DATE(CURDATE()) and DATE_add(CURDATE(), INTERVAL 30 DAY)
order by expire_time desc limit 1
order by expire_time asc limit 1
</select>
<select id="lastFeeInterceptCount" resultType="java.lang.Integer">
......
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