Commit 1739b6ff authored by 王俊权's avatar 王俊权

关闭用户活跃订单

parent c268bf75
......@@ -52,8 +52,4 @@ public class OrderController {
return Result.buildSuccess(orderService.approveOpt(approveVo));
}
@PostMapping(value = "/cancel/loan",consumes = "application/json")
public Result cancel(@RequestBody @Valid OrderVo orderVo) {
return Result.buildSuccess(orderService.cancel(orderVo));
}
}
package cn.quantgroup.cashloanflowboss.api.order.entity;
import cn.quantgroup.cashloanflowboss.core.persistence.Primary;
import javax.persistence.Entity;
import javax.persistence.Table;
import lombok.Data;
import javax.persistence.Column;
......@@ -13,6 +15,8 @@ import javax.persistence.Column;
*/
@Data
@Entity
@Table(name = "order")
public class Order extends Primary {
@Column(name = "channel_order_number")
private String channelOrderNumber;
......@@ -21,9 +25,9 @@ public class Order extends Primary {
@Column(name = "channel_id")
private Long channelId;
@Column(name = "fund_id")
private Integer fundId;
private Long fundId;
@Column(name = "fund_type")
private Integer fundType;
private Long fundType;
@Column(name = "ext_data")
private String extData;
}
package cn.quantgroup.cashloanflowboss.api.order.service;
import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenter;
import java.util.Date;
import cn.quantgroup.cashloanflowboss.api.channel.entity.ChannelConf;
......@@ -54,6 +55,8 @@ public class OrderService {
private ClothoCenter clothoCenter;
@Autowired
private JolyneCenter jolyneCenter;
@Autowired
private CLFCenter clfCenter;
......@@ -141,8 +144,8 @@ public class OrderService {
order.setChannelOrderNumber(approveVo.getChannelOrderNumber());
order.setCreditNumber(orderMapping.getApplyNo());
order.setChannelId(orderMapping.getRegisteredFrom());
order.setFundId(fundId);
order.setFundType(approveVo.getFundType());
order.setFundId(fundId.longValue());
order.setFundType(approveVo.getFundType().longValue());
order.setCreateTime(new Date());
order.setUpdateTime(new Date());
orderRepository.save(order);
......@@ -172,29 +175,4 @@ public class OrderService {
}
}
public boolean cancel(OrderVo orderVo){
ClfOrderMapping orderMapping = clfOrderMappingRepository.findByChannelOrderNoLastOne(orderVo.getChannelOrderNumber());
if (orderMapping == null) {
log.info("cancel,关单失败,无订单 channelOrderNumber={}", orderVo.getChannelOrderNumber());
return false;
}
XUser xUser = xyqbUserService.findXUserById(orderMapping.getQgUserId());
if (xUser == null) {
log.info("cancel,关单失败,未找到用户 channelOrderNumber={}", orderVo.getChannelOrderNumber());
return false;
}
Long userId = xUser.getId();
ConcurrentMap<Object, Object> data = Maps.newConcurrentMap();
ArrayList<Object> cancel_list = Lists.newArrayList();
cancel_list.add("update xyqb.quota_credit set is_active=0 where user_id="+userId);
cancel_list.add("update xyqb.quota_account set is_active=0 where user_id="+userId);
cancel_list.add("update xyqb.loan_application_history set progress=16 where user_id="+userId);
cancel_list.add("update xyqb.loan_application_history set is_active=0 where user_id="+userId);
cancel_list.add("delete from apply_quota_record where user_id="+userId);
cancel_list.add("delete from user_operation_history where user_id="+userId);
data.put("sql",cancel_list);
String cancel_result = jolyneCenter.cancel(JSONTools.serialize(data));
return "success".equals(cancel_result);
}
}
......@@ -5,6 +5,9 @@ import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.api.user.model.RegisterUserFormModel;
import cn.quantgroup.cashloanflowboss.api.user.service.UserService;
import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty;
import cn.quantgroup.cashloanflowboss.spi.user.service.UserSysService;
import cn.quantgroup.cashloanflowboss.spi.user.service.XyqbUserService;
import cn.quantgroup.user.IUserSdkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
......@@ -20,6 +23,8 @@ public class UserController {
@Autowired
private UserService userService;
@Autowired
private XyqbUserService xyqbUserService;
/**
* 注册用户
......@@ -75,4 +80,26 @@ public class UserController {
return this.userService.removeUser(id);
}
/**
* 清除用户信息
*
* @param id 用户ID
* @return
*/
@PutMapping("/clean")
public Boolean cleanUser(@RequestParam @Valid @NotEmpty(message = "无效的用户ID") String phoneNo) {
return this.xyqbUserService.cleanUserExtInfo(phoneNo);
}
/**
* 清除用户活跃订单
*
* @param phoneNo 用户ID
* @return
*/
@PutMapping("/order/clean")
public Boolean cleanUserOrder(@RequestParam @Valid @NotEmpty(message = "无效的用户手机号") String phoneNo) {
return this.xyqbUserService.cleanUserOrder(phoneNo);
}
}
package cn.quantgroup.cashloanflowboss.core.configuration.data;
import cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowDataSource;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"cn.quantgroup"}, entityManagerFactoryRef = "xyqbUserEntityManager", transactionManagerRef = "xyqbUserTransactionManager", includeFilters = @ComponentScan.Filter(CashLoanFlowDataSource.class))
public class XyqbUserDataSourceConfiguration {
@Value("${data.xyqb.user.url}")
private String jdbcUrl;
@Value("${data.xyqb.user.password}")
private String password;
@Value("${data.xyqb.user.username}")
private String user;
private String uniquename = "clfDS";
@Value("${data.xyqb.user.pool-size}")
private Integer poolSize;
@Bean(name = "clfDataSource")
@ConfigurationProperties(prefix = "data.clf")
public DataSource createDataSource() {
DruidDataSource source = DruidDataSourceBuilder.create().build();
source.setMaxActive(200);
source.setInitialSize(10);
source.setMinIdle(10);
source.setMaxWait(500000);
source.setTimeBetweenEvictionRunsMillis(60000);
source.setMinEvictableIdleTimeMillis(300000);
source.setValidationQuery("SELECT 'x'");
source.setTestWhileIdle(true);
source.setTestOnBorrow(false);
source.setTestOnReturn(false);
source.setPoolPreparedStatements(Boolean.FALSE);
return source;
}
@Bean(name = "xyqbUserEntityManager")
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource())
.packages("cn.quantgroup.cashloanflowboss.spi.clf.entity")
.persistenceUnit(uniquename)
.build();
}
@Bean(name = "xyqbUserTransactionManager")
public PlatformTransactionManager transactionManager(@Qualifier("xyqbUserEntityManager") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
package cn.quantgroup.cashloanflowboss.spi.clf.service;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Component
@FeignClient(name = "CLFServiceCenter", url = "${qapi.https}", fallback = CLFCenter.Fallback.class)
public interface CLFCenter {
@PostMapping(value = "/test//loanMq/batch", consumes = "application/x-www-form-urlencoded")
public void loanMq(@RequestParam("json") String loanMq);
@Component
class Fallback implements CLFCenter {
@Override
public void loanMq(String loanMq) {
return ;
}
}
}
......@@ -51,5 +51,19 @@ public interface XyqbUserService {
*/
UserInfo findUserByUuid(String uuid);
/**
* 清除用户信息
* @param phoneNo
* @return
*/
Boolean cleanUserExtInfo(String phoneNo);
/**
* 清除用户活跃订单
* @param phoneNo
* @return
*/
Boolean cleanUserOrder(String phoneNo);
}
package cn.quantgroup.cashloanflowboss.spi.user.service;
import cn.quantgroup.cashloanflowboss.api.order.model.OrderVo;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderMapping;
import cn.quantgroup.cashloanflowboss.spi.jolyne.JolyneCenter;
import cn.quantgroup.cashloanflowboss.spi.util.HttpService;
import cn.quantgroup.cashloanflowboss.utils.JSONTools;
import cn.quantgroup.cashloanflowboss.utils.MD5Tools;
import cn.quantgroup.user.bean.UserInfo;
import cn.quantgroup.user.enums.IncomeEnum;
import cn.quantgroup.user.enums.IncomeRangeEnum;
import cn.quantgroup.user.retbean.XUser;
import cn.quantgroup.user.retbean.XUserDetail;
import cn.quantgroup.user.retbean.XUserExtInfo;
import cn.quantgroup.user.vo.UserSysResult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.concurrent.ConcurrentMap;
import lombok.extern.log4j.Log4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,11 +38,14 @@ public class XyqbUserServiceImpl implements XyqbUserService {
private UserSysService userSysService;
@Autowired
private HttpService httpService;
@Autowired
private JolyneCenter jolyneCenter;
@Value("${passportapi.http}")
private String passportapiHttp;
private static final ObjectMapper MAPPER = new ObjectMapper();
/**
* 查询用户
*
......@@ -117,5 +130,49 @@ public class XyqbUserServiceImpl implements XyqbUserService {
return userInfo.getData();
}
/**
* 清除用户信息
*/
@Override public Boolean cleanUserExtInfo(String phoneNo) {
if (StringUtils.isEmpty(phoneNo)) {
return false;
}
UserSysResult<XUser> user = userSysService.getService().findUserByPhoneNo(phoneNo);
if (Objects.isNull(user) || Objects.isNull(user.getData())) {
return false;
}
Long user_id = user.getData().getId();
UserSysResult<Boolean> result = userSysService.getService().disableUser(user_id);
UserSysResult<XUserExtInfo> userExtInfo = userSysService.getService().updateUserExtInfo(user_id, IncomeEnum.UNKNOWN,
IncomeRangeEnum.UNKNOWN, null, null, null, null, null, null, null);
if (!userExtInfo.isSuccess() || userExtInfo.getData() == null) {
return false;
}
return true;
}
/**
* 清除用户活跃订单
* @param phoneNo
* @return
*/
public Boolean cleanUserOrder(String phoneNo){
UserSysResult<XUser> xUser = userSysService.getService().findUserByPhoneNo(phoneNo);
if (xUser == null || xUser.getData() == null) {
LOGGER.info("cleanUserOrder,清除用户活跃订单失败,未找到用户 phoneNo={}", phoneNo);
return false;
}
Long userId = xUser.getData().getId();
ConcurrentMap<Object, Object> data = Maps.newConcurrentMap();
ArrayList<Object> cancel_list = Lists.newArrayList();
cancel_list.add("update xyqb.quota_credit set is_active=0 where user_id="+userId);
cancel_list.add("update xyqb.quota_account set is_active=0 where user_id="+userId);
cancel_list.add("update xyqb.loan_application_history set progress=16 where user_id="+userId);
cancel_list.add("update xyqb.loan_application_history set is_active=0 where user_id="+userId);
cancel_list.add("delete from apply_quota_record where user_id="+userId);
cancel_list.add("delete from user_operation_history where user_id="+userId);
data.put("sql",cancel_list);
String cancel_result = jolyneCenter.cancel(JSONTools.serialize(data));
return "success".equals(cancel_result);
}
}
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