Commit 10d3f72f by 墨竹

fix:收费

parent e04f07f9
...@@ -72,5 +72,15 @@ public interface TabHaobanQywxFeeOrderMapper { ...@@ -72,5 +72,15 @@ public interface TabHaobanQywxFeeOrderMapper {
* @date 2022-08-05 11:18:22 * @date 2022-08-05 11:18:22
*/ */
int countExternalContactCount(@Param("wxEnterpriseId") String wxEnterpriseId); int countExternalContactCount(@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 有订单
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-08-12 10:42:36
*/
int hasOrder(@Param("wxEnterpriseId") String wxEnterpriseId);
} }
...@@ -53,4 +53,15 @@ public interface HaobanQywxFeeOrderService { ...@@ -53,4 +53,15 @@ public interface HaobanQywxFeeOrderService {
int countExternalContactCount(String wxEnterpriseId); int countExternalContactCount(String wxEnterpriseId);
/**
* 是否有订单
*
* @param wxEnterpriseId wx企业标识
* @return boolean
* @author mozhu
* @date 2022-08-12 10:43:21
*/
boolean hasOrder(String wxEnterpriseId);
} }
...@@ -68,4 +68,10 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService ...@@ -68,4 +68,10 @@ public class HaobanQywxFeeOrderServiceImpl implements HaobanQywxFeeOrderService
public int countExternalContactCount(String wxEnterpriseId) { public int countExternalContactCount(String wxEnterpriseId) {
return tabHaobanQywxFeeOrderMapper.countExternalContactCount(wxEnterpriseId); return tabHaobanQywxFeeOrderMapper.countExternalContactCount(wxEnterpriseId);
} }
@Override
public boolean hasOrder(String wxEnterpriseId) {
int count = tabHaobanQywxFeeOrderMapper.hasOrder(wxEnterpriseId);
return count > 0;
}
} }
package com.gic.haoban.manage.service.service.out.impl.fee; package com.gic.haoban.manage.service.service.out.impl.fee;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -73,7 +74,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -73,7 +74,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
try { try {
instance.sendMessage("qywxAddFeeMq", wxEnterprise.getWxEnterpriseId()); instance.sendMessage("qywxAddFeeMq", wxEnterprise.getWxEnterpriseId());
} catch (Exception e) { } catch (Exception e) {
logger.info("发送消息处理异常:{}", e.getMessage(),e); logger.info("发送消息处理异常:{}", e.getMessage(), e);
} }
} }
} }
...@@ -96,12 +97,16 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -96,12 +97,16 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
return; return;
} }
logger.info("企微收费:{},{}", corpid, wxEnterpriseId); logger.info("企微收费:{},{}", corpid, wxEnterpriseId);
boolean hasOrder = haobanQywxFeeOrderService.hasOrder(wxEnterpriseId);
//更新订单 //更新订单
List<String> orderIds = new ArrayList<>(); List<String> orderIds = new ArrayList<>();
while (true) { while (true) {
FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO(); FeeOrderListQDTO feeOrderListQDTO = new FeeOrderListQDTO();
feeOrderListQDTO.setCorpid(corpid); feeOrderListQDTO.setCorpid(corpid);
if (hasOrder) {
feeOrderListQDTO.setStart_time(DateUtil.beginOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
feeOrderListQDTO.setEnd_time(DateUtil.endOfDay(new Date()).offsetNew(DateField.HOUR_OF_DAY, -1).getTime());
}
feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT); feeOrderListQDTO.setLimit(Manage3Constants.QW_LIMIT);
FeeOrderResponseList feeOrderResponseList = qywxUserApiService.listOrder(corpid, serviceCorpid, feeOrderListQDTO); FeeOrderResponseList feeOrderResponseList = qywxUserApiService.listOrder(corpid, serviceCorpid, feeOrderListQDTO);
int errcode = feeOrderResponseList.getErrcode(); int errcode = feeOrderResponseList.getErrcode();
...@@ -218,7 +223,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -218,7 +223,6 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
for (AccountListDTO accountListDTO : activeInfoList) { for (AccountListDTO accountListDTO : activeInfoList) {
TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff = new TabHaobanQywxFeeAccountStaff(); TabHaobanQywxFeeAccountStaff tabHaobanQywxFeeAccountStaff = new TabHaobanQywxFeeAccountStaff();
tabHaobanQywxFeeAccountStaff.setFeeAccountStaffId(UniqueIdUtils.uniqueLong()); tabHaobanQywxFeeAccountStaff.setFeeAccountStaffId(UniqueIdUtils.uniqueLong());
//tabHaobanQywxFeeAccountStaff.setOrderId();
tabHaobanQywxFeeAccountStaff.setCorpId(corpid); tabHaobanQywxFeeAccountStaff.setCorpId(corpid);
tabHaobanQywxFeeAccountStaff.setWxEnterpriseId(wxEnterpriseId); tabHaobanQywxFeeAccountStaff.setWxEnterpriseId(wxEnterpriseId);
tabHaobanQywxFeeAccountStaff.setWxUserId(userid); tabHaobanQywxFeeAccountStaff.setWxUserId(userid);
...@@ -243,6 +247,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -243,6 +247,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
//更新收费 //更新收费
HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = haobanQywxFeeAccountStaffService.feeIntercept(wxEnterpriseId); HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = haobanQywxFeeAccountStaffService.feeIntercept(wxEnterpriseId);
int permissionUserNum = haobanQywxFeeOrderAccountService.countOrderAccountStatus(1, wxEnterpriseId);
if (haobanQywxFeeDetailDTO != null) { if (haobanQywxFeeDetailDTO != null) {
TabHaobanQywxFee tabHaobanQywxFee = new TabHaobanQywxFee(); TabHaobanQywxFee tabHaobanQywxFee = new TabHaobanQywxFee();
tabHaobanQywxFee.setQwFeeId(UniqueIdUtils.uniqueLong()); tabHaobanQywxFee.setQwFeeId(UniqueIdUtils.uniqueLong());
...@@ -251,12 +256,17 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -251,12 +256,17 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFee.setWxEnterpriseId(wxEnterpriseId); tabHaobanQywxFee.setWxEnterpriseId(wxEnterpriseId);
tabHaobanQywxFee.setInterceptTime(haobanQywxFeeDetailDTO.getInterceptTime()); tabHaobanQywxFee.setInterceptTime(haobanQywxFeeDetailDTO.getInterceptTime());
tabHaobanQywxFee.setInterceptUserNum(haobanQywxFeeDetailDTO.getInterceptUserNum()); tabHaobanQywxFee.setInterceptUserNum(haobanQywxFeeDetailDTO.getInterceptUserNum());
tabHaobanQywxFee.setPermissionUserNum(haobanQywxFeeOrderAccountService.countOrderAccountStatus(1, wxEnterpriseId)); tabHaobanQywxFee.setPermissionUserNum(permissionUserNum);
tabHaobanQywxFee.setBuyPermissionUserNum(haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId)); tabHaobanQywxFee.setBuyPermissionUserNum(haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId));
tabHaobanQywxFee.setInterceptFlag(0); tabHaobanQywxFee.setInterceptFlag(0);
haobanQywxFeeService.insert(tabHaobanQywxFee); haobanQywxFeeService.insert(tabHaobanQywxFee);
//判断今天是否是本月最后一天
if (DateUtil.isSameDay(DateUtil.endOfMonth(new Date()), new Date())) {
int day1 = 0;
String content = "30天将有" + day1 + "个接口许可证即将过期,您总共还剩余" + permissionUserNum + "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
//告警 //告警
messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName()); messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName(), content);
}
} }
List<TabHaobanQywxFeeAccountInterceptLog> tabHaobanQywxFeeAccountInterceptLogs = haobanQywxFeeAccountInterceptLogService.queryByWxEnterpriseId(wxEnterpriseId); List<TabHaobanQywxFeeAccountInterceptLog> tabHaobanQywxFeeAccountInterceptLogs = haobanQywxFeeAccountInterceptLogService.queryByWxEnterpriseId(wxEnterpriseId);
...@@ -268,7 +278,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -268,7 +278,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFee.setWxEnterpriseId(wxEnterpriseId); tabHaobanQywxFee.setWxEnterpriseId(wxEnterpriseId);
tabHaobanQywxFee.setInterceptTime(DateUtil.offsetDay(new Date(), -1)); tabHaobanQywxFee.setInterceptTime(DateUtil.offsetDay(new Date(), -1));
tabHaobanQywxFee.setInterceptUserNum(tabHaobanQywxFeeAccountInterceptLogs.size()); tabHaobanQywxFee.setInterceptUserNum(tabHaobanQywxFeeAccountInterceptLogs.size());
tabHaobanQywxFee.setPermissionUserNum(haobanQywxFeeOrderAccountService.countOrderAccountStatus(1, wxEnterpriseId)); tabHaobanQywxFee.setPermissionUserNum(permissionUserNum);
tabHaobanQywxFee.setBuyPermissionUserNum(haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId)); tabHaobanQywxFee.setBuyPermissionUserNum(haobanQywxFeeOrderService.countExternalContactCount(wxEnterpriseId));
tabHaobanQywxFee.setInterceptFlag(1); tabHaobanQywxFee.setInterceptFlag(1);
haobanQywxFeeService.insert(tabHaobanQywxFee); haobanQywxFeeService.insert(tabHaobanQywxFee);
...@@ -313,7 +323,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -313,7 +323,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
* *
* @param wxEnterpriseId * @param wxEnterpriseId
*/ */
private void messageAlert(String wxEnterpriseId, String corpName, String corpid, String titleSub) { private void messageAlert(String wxEnterpriseId, String corpName, String corpid, String titleSub, String content) {
ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get(); ProviderLocalTag providerLocalTag = ProviderLocalTag.tag.get();
String traceId = providerLocalTag.traceId; String traceId = providerLocalTag.traceId;
AlertMessageDTO messageDTO = new AlertMessageDTO(); AlertMessageDTO messageDTO = new AlertMessageDTO();
...@@ -323,6 +333,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -323,6 +333,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("企业名称", corpName); map.put("企业名称", corpName);
map.put("企业id", corpid); map.put("企业id", corpid);
map.put("内容", content);
messageDTO.setContentMap(map); messageDTO.setContentMap(map);
messageDTO.setTraceId(traceId); messageDTO.setTraceId(traceId);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance(); GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
...@@ -332,4 +343,5 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService { ...@@ -332,4 +343,5 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
logger.info("异常:{}", e.getMessage(), e); logger.info("异常:{}", e.getMessage(), e);
} }
} }
} }
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
</delete> </delete>
<select id="countOrderAccountStatus" resultMap="TabHaobanQywxFeeOrderAccountMap"> <select id="countOrderAccountStatus" resultType="java.lang.Integer">
select select
count(*) count(*)
from tab_haoban_qywx_fee_order_account from tab_haoban_qywx_fee_order_account
......
...@@ -147,10 +147,16 @@ ...@@ -147,10 +147,16 @@
</delete> </delete>
<select id="countExternalContactCount" resultType="java.lang.Integer"> <select id="countExternalContactCount" resultType="java.lang.Integer">
select select sum(external_contact_count)
sum(external_contact_count) from tab_haoban_qywx_fee_order
where wx_enterprise_id = #{wxEnterpriseId}
</select>
<select id="hasOrder" resultType="java.lang.Integer">
select count(*)
from tab_haoban_qywx_fee_order from tab_haoban_qywx_fee_order
where wx_enterprise_id = #{wxEnterpriseId} where wx_enterprise_id = #{wxEnterpriseId}
</select> </select>
</mapper> </mapper>
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO; import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService; import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.config.Config;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService; import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
...@@ -35,6 +37,10 @@ public class ServiceTest { ...@@ -35,6 +37,10 @@ public class ServiceTest {
@Autowired @Autowired
private HmQrcodeApiService hmQrcodeApiService; private HmQrcodeApiService hmQrcodeApiService;
@Autowired
private HaobanQywxFeeApiService haobanQywxFeeApiService;
@Autowired
private Config config;
@Test @Test
...@@ -56,4 +62,15 @@ public class ServiceTest { ...@@ -56,4 +62,15 @@ public class ServiceTest {
public void test2() { public void test2() {
hmQrcodeApiService.checkStaffOpenContactByWxEnterpriseId("5bd929fd3b2c49deaa1184bcb0d669b3","ff8080815dacd3a2015dacd3ef5c0000"); hmQrcodeApiService.checkStaffOpenContactByWxEnterpriseId("5bd929fd3b2c49deaa1184bcb0d669b3","ff8080815dacd3a2015dacd3ef5c0000");
} }
@Test
public void test3() {
haobanQywxFeeApiService.addFee("5bd929fd3b2c49deaa1184bcb0d669b3");
}
@Test
public void test4() {
String autoActiveStatus = qywxUserApiService.getAutoActiveStatus("wp59NLDQAAJL6DsM6YwOGqJlhCBykkeA", config.getCorpid());
System.out.println(autoActiveStatus);
}
} }
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