Commit 3823de44 by guojuxing

开票户接口

parent f333a134
......@@ -50,4 +50,21 @@ public interface TabInvoiceAccountMapper {
* @return 更新条目数
*/
int updateByPrimaryKey(TabInvoiceAccount record);
/**
* 查询启用的那条数据,启用的只有一条
* @Title: getEnable

* @Description:

 * @author guojuxing 

* @return com.gic.finance.entity.TabInvoiceAccount


 */
TabInvoiceAccount getEnable();
/**
* 关闭状态
* @Title: closeStatus

* @Description:

 * @author guojuxing 

* @return int


 */
int closeStatus();
}
\ No newline at end of file
package com.gic.finance.service;
import com.gic.finance.dto.InvoiceAccountDTO;
import com.gic.finance.entity.TabInvoiceAccount;
/**
* 开票管理-开票账户
* @ClassName: InvoiceAccountService

* @Description: 

* @author guojuxing

* @date 2019/8/28 5:26 PM

*/
public interface InvoiceAccountService {
/**
* 新增
* @Title: save

* @Description:

 * @author guojuxing
* @param dto

* @return void


 */
void save(InvoiceAccountDTO dto);
/**
* 查询启用的那条数据,启用的只有一条
* @Title: getEnable

* @Description:

 * @author guojuxing 

* @return com.gic.finance.entity.TabInvoiceAccount


 */
TabInvoiceAccount getEnable();
TabInvoiceAccount getById(Integer id);
/**
* 更新
* @Title: update

* @Description:

 * @author guojuxing
* @param dto

* @return void


 */
void update(InvoiceAccountDTO dto);
/**
* 关闭
* @Title: closeStatus

* @Description:

 * @author guojuxing 

* @return void


 */
void closeStatus();
}
package com.gic.finance.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.finance.dao.mapper.TabInvoiceAccountMapper;
import com.gic.finance.dto.InvoiceAccountDTO;
import com.gic.finance.entity.TabInvoiceAccount;
import com.gic.finance.service.InvoiceAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("invoiceAccountService")
public class InvoiceAccountServiceImpl implements InvoiceAccountService{
@Autowired
private TabInvoiceAccountMapper tabInvoiceAccountMapper;
@Override
public void save(InvoiceAccountDTO dto) {
tabInvoiceAccountMapper.insert(EntityUtil.changeEntityNew(TabInvoiceAccount.class, dto));
}
@Override
public TabInvoiceAccount getEnable() {
return tabInvoiceAccountMapper.getEnable();
}
@Override
public TabInvoiceAccount getById(Integer id) {
return tabInvoiceAccountMapper.selectByPrimaryKey(id);
}
@Override
public void update(InvoiceAccountDTO dto) {
dto.setUpdateTime(new Date());
tabInvoiceAccountMapper.updateByPrimaryKeySelective(EntityUtil.changeEntityNew(TabInvoiceAccount.class, dto));
}
@Override
public void closeStatus() {
}
}
package com.gic.finance.service.outer.impl;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.valid.ValidParamsUtils;
import com.gic.finance.dto.InvoiceAccountDTO;
import com.gic.finance.entity.TabInvoiceAccount;
import com.gic.finance.service.InvoiceAccountApiService;
import com.gic.finance.service.InvoiceAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("invoiceAccountApiService")
public class InvoiceAccountApiServiceImpl implements InvoiceAccountApiService {
@Autowired
private InvoiceAccountService invoiceAccountService;
@Override
public ServiceResponse<Void> save(InvoiceAccountDTO invoiceAccountDTO) {
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(invoiceAccountDTO, InvoiceAccountDTO.Save.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
//关闭之前的
invoiceAccountService.closeStatus();
invoiceAccountDTO.setCreateTime(new Date());
invoiceAccountDTO.setUpdateTime(new Date());
//启用默认
invoiceAccountDTO.setStatus(1);
invoiceAccountService.save(invoiceAccountDTO);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> update(InvoiceAccountDTO invoiceAccountDTO) {
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(invoiceAccountDTO, InvoiceAccountDTO.Save.class,
InvoiceAccountDTO.Edit.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
TabInvoiceAccount tab = invoiceAccountService.getById(invoiceAccountDTO.getInvoiceAccountId());
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键有误");
}
invoiceAccountService.update(invoiceAccountDTO);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> enable(Integer id) {
TabInvoiceAccount tab = invoiceAccountService.getById(id);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键有误");
}
//关闭之前的
invoiceAccountService.closeStatus();
InvoiceAccountDTO dto = new InvoiceAccountDTO();
dto.setInvoiceAccountId(id);
dto.setStatus(1);
invoiceAccountService.update(dto);
return ServiceResponse.success();
}
@Override
public ServiceResponse<InvoiceAccountDTO> getById(Integer invoiceAccountId) {
TabInvoiceAccount tab = invoiceAccountService.getById(invoiceAccountId);
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键有误");
}
return ServiceResponse.success(EntityUtil.changeEntityNew(InvoiceAccountDTO.class, tab));
}
@Override
public ServiceResponse<InvoiceAccountDTO> getEnable() {
TabInvoiceAccount tab = invoiceAccountService.getEnable();
if (tab == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "没有开启数据,请添加");
}
return ServiceResponse.success(EntityUtil.changeEntityNew(InvoiceAccountDTO.class, tab));
}
}
......@@ -11,6 +11,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.valid.ValidParamsUtils;
import com.gic.finance.constant.InvoiceStatusEnum;
import com.gic.finance.dto.InvoiceManageDTO;
import com.gic.finance.entity.TabInvoiceManage;
......@@ -18,7 +19,6 @@ import com.gic.finance.qo.InvoiceManageListQueryQO;
import com.gic.finance.service.InvoiceManageApiService;
import com.gic.finance.service.InvoiceManageService;
import com.gic.store.utils.CreateSerialNumberUtils;
import com.gic.store.utils.valid.ValidUtil;
@Service("invoiceManageApiService")
public class InvoiceManageApiServiceImpl implements InvoiceManageApiService{
......@@ -26,7 +26,7 @@ public class InvoiceManageApiServiceImpl implements InvoiceManageApiService{
private InvoiceManageService invoiceManageService;
@Override
public ServiceResponse<Void> applyInvoice(InvoiceManageDTO invoiceManageDTO) {
ServiceResponse paramResponse = ValidUtil.allCheckValidate(invoiceManageDTO, InvoiceManageDTO.ApplyInvoiceValid.class);
ServiceResponse paramResponse = ValidParamsUtils.allCheckValidate(invoiceManageDTO, InvoiceManageDTO.ApplyInvoiceValid.class);
if (!paramResponse.isSuccess()) {
return paramResponse;
}
......
......@@ -6,6 +6,10 @@ import java.util.Date;
import com.alibaba.fastjson.JSONObject;
import com.gic.dubbo.util.DubboContextUtil;
import com.gic.dubbo.util.DubboInvokeUtil;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.utils.ReferenceConfigCache;
import org.apache.dubbo.rpc.service.GenericService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -135,7 +139,7 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
dto.setApprovalTime(new Date());
//todo 审批人等信息获取插入
//callBack(tab, accountAmount, TransferAccountApprovalStatusEnum.AGREE.getCode());
callBack(tab, accountAmount, TransferAccountApprovalStatusEnum.AGREE.getCode());
transferAccountsApprovalService.updateTransferAccountsApproval(dto);
return ServiceResponse.success();
}
......@@ -200,12 +204,35 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
}
private void callBack(TabTransferAccountsApproval tab, Double accountAmount, int status) {
ApplicationConfig applicationConfig = new ApplicationConfig();
applicationConfig.setName("dubbo-job");
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress("zookeeper://10.105.220.75:2199");
registryConfig.setProtocol("dubbo");
registryConfig.setId("customRegistry");
registryConfig.setTimeout(30000);
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(applicationConfig);
reference.setRegistry(registryConfig);
reference.setInterface("com.gic.enterprise.service.BillingPayInfoApiService");
reference.setGeneric(true);
reference.setCheck(false);
reference.setAsync(false);
reference.setTimeout(50000);
reference.setRetries(0);
reference.setGeneric(true);
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
GenericService genericService = cache.get(reference);
boolean isBilling = tab.getOrderType().intValue() == OrderTypeEnum.RECHARGE.getCode() ||
tab.getOrderType().intValue() == OrderTypeEnum.SHORT_MESSAGE_PACKAGE.getCode();
//回调计费中心、短信套餐包
if (isBilling) {
String taskService = "com.gic.enterprise.service.BillingPayInfoApiService";
String taskMethod = "offlineCallBack";
JSONObject param = new JSONObject();
param.put("orderSerialNumber", tab.getOrderNumber());
param.put("buyType", tab.getOrderType());
......@@ -213,8 +240,7 @@ public class TransferAccountsApprovalApiServiceImpl implements TransferAccountsA
param.put("auditStatus", status);
param.put("timeEnd", new SimpleDateFormat("yyyyMMdd").format(new Date()));
DubboContextUtil.initRegistryConfig("10.105.220.75", 2199);
GenericService genericService = DubboInvokeUtil.getGenericService(taskService);
genericService.$invoke(taskMethod, new String[]{String.class.getName()}, new String[]{param.toJSONString()});
Object name = genericService.$invoke("offlineCallBack", new String[]{String.class.getName()}, new String[]{param.toJSONString()});
}
}
}
......@@ -150,4 +150,15 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where invoice_account_id = #{invoiceAccountId,jdbcType=INTEGER}
</update>
<select id="getEnable" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_invoice_account
where status = 1
</select>
<update id="closeStatus">
update tab_invoice_account set status = 2
</update>
</mapper>
\ No newline at end of file
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