Commit 669e8990 by 徐高华

激活账号

parent ae2d6990
package com.gic.haoban.manage.service.dao.mapper.fee;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
/**
* 企业微信收费订单账号(激活码)(TabHaobanQywxFeeOrderAccount)表数据库访问层
......@@ -20,16 +18,7 @@ public interface TabHaobanQywxFeeOrderAccountMapper {
* @param feeAccountId 主键
* @return 实例对象
*/
TabHaobanQywxFeeOrderAccount queryById(Long feeAccountId);
/**
* 查询指定行数据
*
* @param tabHaobanQywxFeeOrderAccount 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<TabHaobanQywxFeeOrderAccount> queryAllByLimit(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount, @Param("pageable") Pageable pageable);
TabHaobanQywxFeeOrderAccount selectByOrderIdAndCode( @Param("wxEnterpriseId")String wxEnterpriseId , @Param("orderId")String orderId, @Param("activeCode")String activeCode);
/**
* 新增数据
......@@ -40,14 +29,6 @@ public interface TabHaobanQywxFeeOrderAccountMapper {
int insert(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount);
/**
* 批量新增数据(MyBatis原生foreach方法)
*
* @param entities List<TabHaobanQywxFeeOrderAccount> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TabHaobanQywxFeeOrderAccount> entities);
/**
* 修改数据
*
* @param tabHaobanQywxFeeOrderAccount 实例对象
......@@ -56,14 +37,6 @@ public interface TabHaobanQywxFeeOrderAccountMapper {
int update(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount);
/**
* 通过主键删除数据
*
* @param feeAccountId 主键
* @return 影响行数
*/
int deleteById(Long feeAccountId);
/**
* 根据状态查询用户数
*
* @param status
......
......@@ -11,36 +11,12 @@ import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
public interface HaobanQywxFeeOrderAccountService {
/**
* 通过ID查询单条数据
*
* @param feeAccountId 主键
* @return 实例对象
*/
TabHaobanQywxFeeOrderAccount queryById(Long feeAccountId);
/**
* 新增数据
*
* @param tabHaobanQywxFeeOrderAccount 实例对象
* @return 实例对象
*/
TabHaobanQywxFeeOrderAccount insert(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount);
/**
* 修改数据
*
* @param tabHaobanQywxFeeOrderAccount 实例对象
* @return 实例对象
*/
TabHaobanQywxFeeOrderAccount update(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount);
/**
* 通过主键删除数据
*
* @param feeAccountId 主键
* @return 是否成功
*/
boolean deleteById(Long feeAccountId);
TabHaobanQywxFeeOrderAccount save(TabHaobanQywxFeeOrderAccount activeAccount);
/**
* 未激活用户数
......
package com.gic.haoban.manage.service.service.fee.impl;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeOrderAccountMapper;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeOrderAccount;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeOrderAccountService;
......@@ -18,50 +19,25 @@ public class HaobanQywxFeeOrderAccountServiceImpl implements HaobanQywxFeeOrderA
private TabHaobanQywxFeeOrderAccountMapper tabHaobanQywxFeeOrderAccountMapper;
/**
* 通过ID查询单条数据
*
* @param feeAccountId 主键
* @return 实例对象
*/
@Override
public TabHaobanQywxFeeOrderAccount queryById(Long feeAccountId) {
return this.tabHaobanQywxFeeOrderAccountMapper.queryById(feeAccountId);
}
/**
* 新增数据
*
* @param tabHaobanQywxFeeOrderAccount 实例对象
* @return 实例对象
*/
@Override
public TabHaobanQywxFeeOrderAccount insert(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount) {
this.tabHaobanQywxFeeOrderAccountMapper.insert(tabHaobanQywxFeeOrderAccount);
return tabHaobanQywxFeeOrderAccount;
}
/**
* 修改数据
*
* @param tabHaobanQywxFeeOrderAccount 实例对象
* @return 实例对象
*/
@Override
public TabHaobanQywxFeeOrderAccount update(TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount) {
this.tabHaobanQywxFeeOrderAccountMapper.update(tabHaobanQywxFeeOrderAccount);
return this.queryById(tabHaobanQywxFeeOrderAccount.getFeeAccountId());
}
/**
* 通过主键删除数据
*
* @param feeAccountId 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long feeAccountId) {
return this.tabHaobanQywxFeeOrderAccountMapper.deleteById(feeAccountId) > 0;
public TabHaobanQywxFeeOrderAccount save(TabHaobanQywxFeeOrderAccount activeAccount) {
String wxEnterpriseId = activeAccount.getWxEnterpriseId() ;
String orderId = activeAccount.getOrderId() ;
String activeCode = activeAccount.getActiveCode() ;
TabHaobanQywxFeeOrderAccount tab = this.tabHaobanQywxFeeOrderAccountMapper.selectByOrderIdAndCode(wxEnterpriseId, orderId, activeCode) ;
if(tab==null) {
activeAccount.setFeeAccountId(UniqueIdUtils.uniqueLong());
this.tabHaobanQywxFeeOrderAccountMapper.insert(activeAccount);
}else {
activeAccount.setFeeAccountId(tab.getFeeAccountId());
this.tabHaobanQywxFeeOrderAccountMapper.update(activeAccount);
}
return activeAccount;
}
@Override
......
......@@ -55,7 +55,6 @@ 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")
......@@ -124,10 +123,13 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
return ;
}
for (AccountListDTO accountListDTO : accountListResponseDTO.getAccountList()) {
Map<String, String> map = new HashMap<>();
map.put("orderId", orderId);
map.put("activeCode", accountListDTO.getActiveCode());
activeCodeList.add(map);
// 只记录互通账号
if(accountListDTO.getType()==2) {
Map<String, String> map = new HashMap<>();
map.put("orderId", orderId);
map.put("activeCode", accountListDTO.getActiveCode());
activeCodeList.add(map);
}
}
cursor = accountListResponseDTO.getNextCursor() ;
......@@ -251,26 +253,21 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
for (Map<String, String> activeCodeMap : activeCodeList) {
String activeCode = activeCodeMap.get("activeCode");
String orderId = activeCodeMap.get("orderId");
ActiveInfoCodeResponseDTO activeInfoCodeResponseDTO = qywxUserApiService.getActiveInfoByCode(corpid, serviceCorpid, activeCode);
if (activeInfoCodeResponseDTO.getErrcode() != 0) {
logger.error("激活码详情报错:{}", activeInfoCodeResponseDTO.getErrmsg());
continue;
}
String userid = activeInfoCodeResponseDTO.getUserid();
if (StringUtils.isNotBlank(userid)) {
TabHaobanQywxFeeOrderAccount tabHaobanQywxFeeOrderAccount = new TabHaobanQywxFeeOrderAccount();
tabHaobanQywxFeeOrderAccount.setFeeAccountId(UniqueIdUtils.uniqueLong());
tabHaobanQywxFeeOrderAccount.setOrderId(orderId);
tabHaobanQywxFeeOrderAccount.setCorpId(corpid);
tabHaobanQywxFeeOrderAccount.setWxEnterpriseId(wxEnterpriseId);
tabHaobanQywxFeeOrderAccount.setWxUserId(userid);
tabHaobanQywxFeeOrderAccount.setActiveCode(activeInfoCodeResponseDTO.getActiveCode());
tabHaobanQywxFeeOrderAccount.setAccountType(activeInfoCodeResponseDTO.getType());
tabHaobanQywxFeeOrderAccount.setStatus(activeInfoCodeResponseDTO.getStatus());
tabHaobanQywxFeeOrderAccount.setExpireTime(DateUtil.date(activeInfoCodeResponseDTO.getExpireTime() * 1000));
tabHaobanQywxFeeOrderAccount.setActiveTime(DateUtil.date(activeInfoCodeResponseDTO.getActiveTime() * 1000));
haobanQywxFeeOrderAccountService.insert(tabHaobanQywxFeeOrderAccount);
TabHaobanQywxFeeOrderAccount activeAccount = new TabHaobanQywxFeeOrderAccount();
ActiveInfoCodeResponseDTO activeDetail = qywxUserApiService.getActiveInfoByCode(corpid, serviceCorpid, activeCode);
if (activeDetail.getErrcode() == 0) {
String userid = activeDetail.getUserid();
activeAccount.setWxUserId(userid);
activeAccount.setAccountType(activeDetail.getType());
activeAccount.setStatus(activeDetail.getStatus());
activeAccount.setExpireTime(DateUtil.date(activeDetail.getExpireTime() * 1000));
activeAccount.setActiveTime(DateUtil.date(activeDetail.getActiveTime() * 1000));
}
activeAccount.setOrderId(orderId);
activeAccount.setActiveCode(activeCode);
activeAccount.setCorpId(corpid);
activeAccount.setWxEnterpriseId(wxEnterpriseId);
haobanQywxFeeOrderAccountService.save(activeAccount);
}
}
......
......@@ -21,73 +21,21 @@
</sql>
<!--查询单个-->
<select id="queryById" resultMap="TabHaobanQywxFeeOrderAccountMap">
<select id="selectByOrderIdAndCode" resultMap="TabHaobanQywxFeeOrderAccountMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_qywx_fee_order_account
where fee_account_id = #{feeAccountId}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="TabHaobanQywxFeeOrderAccountMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_qywx_fee_order_account
<where>
<if test="feeAccountId != null">
and fee_account_id = #{feeAccountId}
</if>
<if test="orderId != null and orderId != ''">
and order_id = #{orderId}
</if>
<if test="corpId != null and corpId != ''">
and corp_id = #{corpId}
</if>
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="wxUserId != null and wxUserId != ''">
and wx_user_id = #{wxUserId}
</if>
<if test="activeCode != null and activeCode != ''">
and active_code = #{activeCode}
</if>
<if test="accountType != null">
and account_type = #{accountType}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="expireTime != null">
and expire_time = #{expireTime}
</if>
<if test="activeTime != null">
and active_time = #{activeTime}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
where order_id = #{orderId} and active_code = #{activeCode} and wx_enterprise_id = #{wxEnterpriseId}
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="feeAccountId" useGeneratedKeys="true">
<insert id="insert">
insert into tab_haoban_qywx_fee_order_account(fee_account_id, order_id, corp_id, wx_enterprise_id, wx_user_id,
active_code, account_type, status, expire_time, active_time)
values (#{feeAccountId}, #{orderId}, #{corpId}, #{wxEnterpriseId}, #{wxUserId}, #{activeCode}, #{accountType},
#{status}, #{expireTime}, #{activeTime})
</insert>
<insert id="insertBatch" keyProperty="feeAccountId" useGeneratedKeys="true">
insert into tab_haoban_qywx_fee_order_account(fee_account_id, order_id, corp_id, wx_enterprise_id, wx_user_id,
active_code, account_type, status, expire_time, active_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.feeAccountId}, #{entity.orderId}, #{entity.corpId}, #{entity.wxEnterpriseId}, #{entity.wxUserId},
#{entity.activeCode}, #{entity.accountType}, #{entity.status}, #{entity.expireTime}, #{entity.activeTime})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tab_haoban_qywx_fee_order_account
......@@ -123,14 +71,6 @@
where fee_account_id = #{feeAccountId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tab_haoban_qywx_fee_order_account
where fee_account_id = #{feeAccountId}
</delete>
<select id="countOrderAccountStatus" resultType="java.lang.Integer">
select
count(*)
......
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