Java Code Examples for com.alibaba.druid.util.StringUtils

The following examples show how to use com.alibaba.druid.util.StringUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public List<LitemallCoupon> querySelective(String name, Short type, Short status, Integer page, Integer limit, String sort, String order) {
    LitemallCouponExample example = new LitemallCouponExample();
    LitemallCouponExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    if (type != null) {
        criteria.andTypeEqualTo(type);
    }
    if (status != null) {
        criteria.andStatusEqualTo(status);
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return couponMapper.selectByExample(example);
}
 
Example 2
public List<LitemallRole> querySelective(String name, Integer page, Integer limit, String sort, String order) {
    LitemallRoleExample example = new LitemallRoleExample();
    LitemallRoleExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return roleMapper.selectByExample(example);
}
 
Example 3
public List<DtsRole> querySelective(String roleName, Integer page, Integer size, String sort, String order) {
	DtsRoleExample example = new DtsRoleExample();
	DtsRoleExample.Criteria criteria = example.createCriteria();

	if (!StringUtils.isEmpty(roleName)) {
		criteria.andNameEqualTo("%" + roleName + "%");
	}
	criteria.andDeletedEqualTo(false);

	if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
		example.setOrderByClause(sort + " " + order);
	}

	PageHelper.startPage(page, size);
	return roleMapper.selectByExample(example);
}
 
Example 4
public List<DtsCoupon> querySelective(String name, Short type, Short status, Integer page, Integer limit,
		String sort, String order) {
	DtsCouponExample example = new DtsCouponExample();
	DtsCouponExample.Criteria criteria = example.createCriteria();

	if (!StringUtils.isEmpty(name)) {
		criteria.andNameLike("%" + name + "%");
	}
	if (type != null) {
		criteria.andTypeEqualTo(type);
	}
	if (status != null) {
		criteria.andStatusEqualTo(status);
	}
	criteria.andDeletedEqualTo(false);

	if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
		example.setOrderByClause(sort + " " + order);
	}

	PageHelper.startPage(page, limit);
	return couponMapper.selectByExample(example);
}
 
Example 5
Source Project: ZTuoExchange_framework   Source File: FinanceConsumer.java    License: MIT License 6 votes vote down vote up
/**
 * 处理充值消息,key值为币种的名称(注意是全称,如Bitcoin)
 *
 * @param record
 */
@KafkaListener(topics = {"deposit"})
public void handleDeposit(ConsumerRecord<String, String> record) {
    logger.info("topic={},key={},value={}", record.topic(), record.key(), record.value());
    if (StringUtils.isEmpty(record.value())) {
        return;
    }
    JSONObject json = JSON.parseObject(record.value());
    if (json == null) {
        return;
    }
    BigDecimal amount = json.getBigDecimal("amount");
    String txid = json.getString("txid");
    String address = json.getString("address");
    Coin coin = coinService.findOne(record.key());
    logger.info("coin={}", coin);

    if (coin != null && walletService.findDeposit(address, txid) == null) {
        MessageResult mr = walletService.recharge(coin, address, amount, txid);
        logger.info("wallet recharge result:{}", mr);
    }
}
 
Example 6
Source Project: ZTuoExchange_framework   Source File: FinanceConsumer.java    License: MIT License 6 votes vote down vote up
/**
 * 异步打钱后返回状态
 * @param record
 */
@KafkaListener(topics = {"withdraw-notify"})
public void withdrawNotify(ConsumerRecord<String, String> record){
    logger.info("topic={},accessKey={},value={}", record.topic(), record.key(), record.value());
    if (StringUtils.isEmpty(record.value())) {
        return;
    }
    JSONObject json = JSON.parseObject(record.value());
    Long withdrawId = json.getLong("withdrawId");
    WithdrawRecord withdrawRecord=withdrawRecordService.findOne(withdrawId);
    if(withdrawRecord==null){
        return;
    }
    String txid=json.getString("txid");
    int status=json.getInteger("status");
    //转账失败,状态变回等待放币
    if(status==0){
        withdrawRecord.setStatus(WithdrawStatus.WAITING);
        withdrawRecordService.save(withdrawRecord);
    }else if(status==1){
        withdrawRecordService.withdrawSuccess(withdrawId, txid);
    }
}
 
Example 7
Source Project: ZTuoExchange_framework   Source File: FinanceConsumer.java    License: MIT License 6 votes vote down vote up
/**
 * 处理充值消息,key值为币种的名称(注意是全称,如Bitcoin)
 *
 * @param record
 */
@KafkaListener(topics = {"deposit"})
public void handleDeposit(ConsumerRecord<String, String> record) {
    logger.info("topic={},key={},value={}", record.topic(), record.key(), record.value());
    if (StringUtils.isEmpty(record.value())) {
        return;
    }
    JSONObject json = JSON.parseObject(record.value());
    if (json == null) {
        return;
    }
    BigDecimal amount = json.getBigDecimal("amount");
    String txid = json.getString("txid");
    String address = json.getString("address");
    Coin coin = coinService.findOne(record.key());
    logger.info("coin={}", coin);

    if (coin != null && walletService.findDeposit(address, txid) == null) {
        MessageResult mr = walletService.recharge(coin, address, amount, txid);
        logger.info("wallet recharge result:{}", mr);
    }
}
 
Example 8
Source Project: mall   Source File: LitemallCouponService.java    License: MIT License 6 votes vote down vote up
public List<LitemallCoupon> querySelective(String name, Short type, Short status, Integer page, Integer limit, String sort, String order) {
    LitemallCouponExample example = new LitemallCouponExample();
    LitemallCouponExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    if (type != null) {
        criteria.andTypeEqualTo(type);
    }
    if (status != null) {
        criteria.andStatusEqualTo(status);
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return couponMapper.selectByExample(example);
}
 
Example 9
Source Project: litemall   Source File: LitemallCouponService.java    License: MIT License 6 votes vote down vote up
public List<LitemallCoupon> querySelective(String name, Short type, Short status, Integer page, Integer limit, String sort, String order) {
    LitemallCouponExample example = new LitemallCouponExample();
    LitemallCouponExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    if (type != null) {
        criteria.andTypeEqualTo(type);
    }
    if (status != null) {
        criteria.andStatusEqualTo(status);
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return couponMapper.selectByExample(example);
}
 
Example 10
Source Project: litemall   Source File: LitemallRoleService.java    License: MIT License 6 votes vote down vote up
public List<LitemallRole> querySelective(String name, Integer page, Integer limit, String sort, String order) {
    LitemallRoleExample example = new LitemallRoleExample();
    LitemallRoleExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(name)) {
        criteria.andNameLike("%" + name + "%");
    }
    criteria.andDeletedEqualTo(false);

    if (!StringUtils.isEmpty(sort) && !StringUtils.isEmpty(order)) {
        example.setOrderByClause(sort + " " + order);
    }

    PageHelper.startPage(page, limit);
    return roleMapper.selectByExample(example);
}
 
Example 11
Source Project: maintain   Source File: VeHeadSqlProvide.java    License: MIT License 6 votes vote down vote up
public String getVeHeadByVeNoSql(final String veNo) {
return new SQL() {{
	this.SELECT("ve_id");
	this.SELECT("ve_no");
	this.SELECT("ve_owner");
	this.SELECT("ve_run_num");
	this.SELECT("link_tel");
	this.SELECT("ve_cop_id");
	this.SELECT("ve_cop_name");
	this.SELECT("ic_card_id");
	this.SELECT("ve_e_no");
	this.SELECT("customs_code");
	this.SELECT("ve_wt");
	this.SELECT("input_date");
	this.FROM("pre_ve_head");
	
	if (!StringUtils.isEmpty(veNo)) {
		this.WHERE("ve_no = '" + veNo + "'");
	} else {
		this.WHERE("1 = 2");
	}
}}.toString();
}
 
Example 12
Source Project: maintain   Source File: InvtHeadSqlProvide.java    License: MIT License 6 votes vote down vote up
public String updateInvtStatusAndInvtNoSql(final InvtHead invtHead) {
	return new SQL(){{
		this.UPDATE("ceb2_invt_head");
		OracleTool.set(this, "app_status", invtHead.getAppStatus());
		if (!StringUtils.isEmpty(invtHead.getInvtNo())) {
			OracleTool.set(this, "invt_no", invtHead.getInvtNo());
		}
		if (StringUtils.isEmpty(invtHead.getOrderNo()) && StringUtils.isEmpty(invtHead.getCopNo())
				&& StringUtils.isEmpty(invtHead.getHeadGuid())) {
			this.WHERE("1 = 2");
		} else {
			OracleTool.where(this, "order_no", invtHead.getOrderNo());
			OracleTool.where(this, "cop_no", invtHead.getCopNo());
			OracleTool.where(this, "head_guid", invtHead.getHeadGuid());
		}
	}}.toString();
}
 
Example 13
/**
 * 检查用户名是否存在
 * @param userName
 * @return
 */
@RequestMapping("/checkUser/{loginName}")
public @ResponseBody Map<String, String> checkUserName(@PathVariable(value="loginName") String loginName) {
	Map<String, String> messageMap = new HashMap<String, String>();
	messageMap.put("isExists", "false");
	
	if (StringUtils.isEmpty(loginName)) {
		// 用户名不存在,返回
		return messageMap;
	}
	// 1.创建member对象
	Member member = new Member();
	member.setLoginName(loginName);
	
	// 2.验证某个用户名是否存在
	List<Member> memeberList = memberService.listMember(member);
	if (memeberList.size() > 0) {
		messageMap.put("isExists", "true");
	}
	
	return messageMap;
}
 
Example 14
Source Project: product-recommendation-system   Source File: MemberServiceImpl.java    License: MIT License 6 votes vote down vote up
@Override
public Member loginMember(String loginName, String password) {
	if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
		return null;
	}
	Member member = new Member();
	member.setLoginName(loginName);
	
	// 调用mapper去查询符合条件的用户列表
	List<Member> userList = this.memberMapper.listMember(member);
	if (userList.isEmpty()) {
		return null;
	}
	
	// 用户列表不为空则验证密码是否正确,正确则返回该用户
	Member plainUser = userList.get(0);
	String encryptedPassword = plainUser.getPassword();
	if (validatePsd(password, encryptedPassword)) {
		return plainUser;
	}
	
	return null;
}
 
Example 15
Source Project: maintain   Source File: GoodsController.java    License: MIT License 6 votes vote down vote up
@RequestMapping
public ModelAndView index(Good good) {
	AuthUser currUser = BaseController.getCurrUser();
	
	if (!StringUtils.isEmpty(currUser.getMember().getCompanyCode())) {
		if (null == good) {
			good = new Good();
		}
		good.setApplyCode(currUser.getMember().getCompanyCode());
	}
	
	PageInfo<Good> pageInfo = this.getPageInfo(good, Good.class, this.goodService, "getGoodList");
	ModelAndView mv = this.buildBaseModelAndView("goods/list", pageInfo);
	mv.addObject("good", good);
	mv.addObject("goodList", pageInfo.getList());
	mv.addObject("status", GoodConstant.getSTATUS());
	mv.addObject("country", ParaTool.getAllCountries(countryService));
	mv.addObject("unit", ParaTool.getAllUnits(unitService));
	return mv;
}
 
Example 16
Source Project: roncoo-pay   Source File: PmsRolePermissionServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 保存角色和权限之间的关联关系
 */
@Transactional(rollbackFor = Exception.class)
public void saveRolePermission(Long roleId, String rolePermissionStr){
	// 删除原来的角色与权限关联
	pmsRolePermissionDao.deleteByRoleId(roleId);
	if (!StringUtils.isEmpty(rolePermissionStr)) {
		// 创建新的关联
		String[] permissionIds = rolePermissionStr.split(",");
		for (int i = 0; i < permissionIds.length; i++) {
			Long permissionId = Long.valueOf(permissionIds[i]);
			PmsRolePermission item = new PmsRolePermission();
			item.setPermissionId(permissionId);
			item.setRoleId(roleId);
			pmsRolePermissionDao.insert(item);
		}
	}
}
 
Example 17
Source Project: roncoo-pay   Source File: PmsMenuRoleServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Transactional(rollbackFor = Exception.class)
public void saveRoleMenu(Long roleId, String roleMenuStr){
	// 删除原来的角色与权限关联
	pmsMenuRoleDao.deleteByRoleId(roleId);
	if (!StringUtils.isEmpty(roleMenuStr)) {
		// 创建新的关联
		String[] menuIds = roleMenuStr.split(",");
		for (int i = 0; i < menuIds.length; i++) {
			Long menuId = Long.valueOf(menuIds[i]);
			PmsMenuRole item = new PmsMenuRole();
			item.setMenuId(menuId);
			item.setRoleId(roleId);
			pmsMenuRoleDao.insert(item);
		}
	}
}
 
Example 18
Source Project: jshERP   Source File: Tools.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 获取访问者IP
 *
 * 在一般情况下使用Request.getRemoteAddr()即可,但是经过nginx等反向代理软件后,这个方法会失效。
 *
 * 本方法先从Header中获取X-Real-IP,如果不存在再从X-Forwarded-For获得第一个IP(用,分割),
 * 如果还不存在则调用Request .getRemoteAddr()。
 *
 * @param request
 * @return
 */
public static String getIpAddr(HttpServletRequest request) {
    String ip = request.getHeader("X-Real-IP");
    if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
        return ip;
    }
    ip = request.getHeader("X-Forwarded-For");
    if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
        // 多次反向代理后会有多个IP值,第一个为真实IP。
        int index = ip.indexOf(',');
        if (index != -1) {
            return ip.substring(0, index);
        } else {
            return ip;
        }
    } else {
        return request.getRemoteAddr();
    }
}
 
Example 19
Source Project: maintain   Source File: PersonsController.java    License: MIT License 6 votes vote down vote up
@RequestMapping("/statistics")
public ModelAndView statistics(PersonalInfo personalInfo) {
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    if (null == personalInfo) {
    	personalInfo = new PersonalInfo();
	}

	if (StringUtils.isEmpty(personalInfo.getGroupOne())) {
		personalInfo.setGroupOne("to_char(pil1.sys_date, 'yyyy-mm-dd')");
		personalInfo.setSysDateStr(sdf.format(Calendar.getInstance().getTime()));
	}
	final Map<String, String> groupField = new LinkedHashMap<String, String>(){{
		this.put("to_char(pil1.sys_date, 'yyyy-mm-dd hh')", "按小时");
		this.put("to_char(pil1.sys_date, 'yyyy-mm-dd')", "按天");
		this.put("to_char(pil1.sys_date, 'yyyy-mm')", "按月");
		this.put("to_char(pil1.sys_date, 'yyyy')", "按年");
	}};
	PageInfo<PersonalInfo> pageInfo = this.getPageInfo(personalInfo, PersonalInfo.class, this.personalInfoService, "statisticsPersonalInfo");
	ModelAndView mv = this.buildBaseModelAndView("persons/statistics", pageInfo);
	mv.addObject("personalInfo", personalInfo);
	mv.addObject("personalInfoList", pageInfo.getList());
	mv.addObject("groupField", groupField);
	return mv;
}
 
Example 20
Source Project: maintain   Source File: ImpInvtHeadSqlProvide.java    License: MIT License 6 votes vote down vote up
public String getInvtHeadListByInvtNoSql(final String invtNo) {
	return new SQL() {{
		this.SELECT("guid");
		this.SELECT("pre_no");
		this.SELECT("invt_no");
		this.SELECT("detailscode");
		this.SELECT("applycode");
		this.SELECT("audit_state");
		this.SELECT("bw_name");
		this.SELECT("apply_date");
		this.SELECT("payecode");
		this.SELECT("payename");
		this.FROM("imp_invt_head");
		
		if (!StringUtils.isEmpty(invtNo)) {
			this.WHERE("invt_no = '" + invtNo + "'");
		} else {
			this.WHERE("1 = 2");
		}
	}}.toString();
}
 
Example 21
Source Project: maintain   Source File: ImpInvtHeadSqlProvide.java    License: MIT License 6 votes vote down vote up
public String getInvtHeadListByCopNoSql(final String copNo) {
	return new SQL() {{
		this.SELECT("guid");
		this.SELECT("pre_no");
		this.SELECT("invt_no");
		this.SELECT("detailscode");
		this.SELECT("applycode");
		this.SELECT("audit_state");
		this.SELECT("bw_name");
		this.SELECT("apply_date");
		this.SELECT("payecode");
		this.SELECT("payename");
		this.FROM("imp_invt_head");
		
		if (!StringUtils.isEmpty(copNo)) {
			this.WHERE("cop_no = '" + copNo + "'");
		} else {
			this.WHERE("1 = 2");
		}
	}}.toString();
}
 
Example 22
Source Project: maintain   Source File: UserUserSqlProvide.java    License: MIT License 6 votes vote down vote up
public String getUsersSql(final UserUser user) {
	return new SQL() {{
		this.SELECT("user_id, login_name, user_name");
		this.FROM("user_user");
		this.WHERE("1 = 1");
		if (!StringUtils.isEmpty(user.getUserId())) {
			this.WHERE("user_id = '" + user.getUserId() + "'");
		}
		
		if (!StringUtils.isEmpty(user.getLoginName())) {
			this.WHERE("login_name like '%" + user.getLoginName() + "%'");
		}
		
		if (!StringUtils.isEmpty(user.getUserName())) {
			this.WHERE("user_name = '" + user.getUserName() + "'");
		}
		
		this.ORDER_BY("oper_time");
	}}.toString();
}
 
Example 23
Source Project: maintain   Source File: DxpReceMsgSqlProvide.java    License: MIT License 6 votes vote down vote up
public String getDxpReceMsgByMsgGuidSql(final String msgGuid) {
	return new SQL() {{
		this.SELECT("msg_guid");
		this.SELECT("encoding");
		this.SELECT("msg_size");
		this.SELECT("msg_blob");
		this.SELECT("biz_blob");
		this.SELECT("note");
		this.SELECT("sys_days");
		this.SELECT("sys_date");
		this.FROM("dxp_rece_msg");
		
		if (!StringUtils.isEmpty(msgGuid)) {
			OracleTool.where(this, "msg_guid", msgGuid);
		} else {
			this.WHERE("1 = 2");
		}
	}}.toString();
}
 
Example 24
Source Project: maintain   Source File: DistHeadSqlProvide.java    License: MIT License 6 votes vote down vote up
public String getDistHeadByInvtNoSql(final String invtNo) {
	return new SQL() {{
		this.SELECT("pdh.seq_no");
		this.SELECT("pdh.dist_no");
		this.SELECT("pdh.customs_code");
		this.SELECT("pdh.decl_code");
		this.SELECT("pdh.decl_name");
		this.SELECT("pdh.dist_stat");
		this.SELECT("pdh.input_date");
		this.SELECT("pdh.decl_date");
		this.SELECT("pdh.return_reason");
		this.SELECT("pdh.note");
		this.FROM("pre_dist_head pdh");
		this.INNER_JOIN("pre_dist_bill_list pdbl on pdh.seq_no = pdbl.seq_no");
		
		if(!StringUtils.isEmpty(invtNo)) {
			this.WHERE("pdbl.bill_no = '" + invtNo + "'");
		} else {
			this.WHERE("1 = 2");
		}
	}}.toString();
}
 
Example 25
/**
 * 查询所有发起的团购记录
 *
 * @param rulesId
 * @param page
 * @param size
 * @param sort
 * @param order
 * @return
 */
public List<LitemallGroupon> querySelective(String rulesId, Integer page, Integer size, String sort, String order) {
    LitemallGrouponExample example = new LitemallGrouponExample();
    LitemallGrouponExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(rulesId)) {
        criteria.andRulesIdEqualTo(Integer.parseInt(rulesId));
    }
    criteria.andDeletedEqualTo(false);
    criteria.andPayedEqualTo(true);
    criteria.andGrouponIdEqualTo(0);

    PageHelper.startPage(page, size);
    return mapper.selectByExample(example);
}
 
Example 26
/**
 * 获取团购活动列表
 *
 * @param goodsId
 * @param page
 * @param size
 * @param sort
 * @param order
 * @return
 */
public List<LitemallGrouponRules> querySelective(String goodsId, Integer page, Integer size, String sort, String order) {
    LitemallGrouponRulesExample example = new LitemallGrouponRulesExample();
    example.setOrderByClause(sort + " " + order);

    LitemallGrouponRulesExample.Criteria criteria = example.createCriteria();

    if (!StringUtils.isEmpty(goodsId)) {
        criteria.andGoodsIdEqualTo(Integer.parseInt(goodsId));
    }
    criteria.andDeletedEqualTo(false);

    PageHelper.startPage(page, size);
    return mapper.selectByExample(example);
}
 
Example 27
@Override
protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
	String id = WebUtils.toHttp(request).getHeader(LOGIN_TOKEN_KEY);
	if (!StringUtils.isEmpty(id)) {
		request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, REFERENCED_SESSION_ID_SOURCE);
		request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, id);
		request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
		return id;
	} else {
		return super.getSessionId(request, response);
	}
}
 
Example 28
Source Project: maintain   Source File: HttpClientTool.java    License: MIT License 5 votes vote down vote up
public static List<FileSystemInfo> getFileSystemInfoListJson(String url) {
	Gson gson = new Gson();
	String result = get(url + "fileSystemList");
	if (!StringUtils.isEmpty(result)) {
		return Arrays.asList(gson.fromJson(result, FileSystemInfo[].class));
	} else {
		return null;
	}
}
 
Example 29
/**
 * 查询所有发起的团购记录
 *
 * @param rulesId
 * @param page
 * @param size
 * @param sort
 * @param order
 * @return
 */
public List<DtsGroupon> querySelective(String rulesId, Integer page, Integer size, String sort, String order) {
	DtsGrouponExample example = new DtsGrouponExample();
	DtsGrouponExample.Criteria criteria = example.createCriteria();

	if (!StringUtils.isEmpty(rulesId)) {
		criteria.andRulesIdEqualTo(Integer.parseInt(rulesId));
	}
	criteria.andDeletedEqualTo(false);
	criteria.andPayedEqualTo(true);
	criteria.andGrouponIdEqualTo(0);

	PageHelper.startPage(page, size);
	return mapper.selectByExample(example);
}
 
Example 30
Source Project: ZTuoExchange_framework   Source File: FinanceConsumer.java    License: MIT License 5 votes vote down vote up
/**
     * 处理提交请求,调用钱包rpc,自动转账
     *
     * @param record
     */
    @KafkaListener(topics = {"withdraw"})
    public void handleWithdraw(ConsumerRecord<String, String> record) {
        logger.info("topic={},key={},value={}", record.topic(), record.key(), record.value());
        if (StringUtils.isEmpty(record.value())) {
            return;
        }
        JSONObject json = JSON.parseObject(record.value());
        Long withdrawId = json.getLong("withdrawId");
        try {
            String serviceName = "SERVICE-RPC-" + record.key().toUpperCase();
            String url = "http://" + serviceName + "/rpc/withdraw?address={1}&amount={2}&fee={3}";

            Coin coin = coinService.findByUnit(record.key());
            logger.info("coin = {}",coin.toString());
            if (coin != null && coin.getCanAutoWithdraw() == BooleanEnum.IS_TRUE) {
                BigDecimal minerFee = coin.getMinerFee();
                MessageResult result = restTemplate.getForObject(url,
                        MessageResult.class, json.getString("address"), json.getBigDecimal("arriveAmount"), minerFee);
                logger.info("=========================rpc 结束================================");
                logger.info("result = {}", result);
                if (result.getCode() == 0 && result.getData() != null) {
                    logger.info("====================== 处理成功,data为txid更新业务 ==================================");
                    //处理成功,data为txid,更新业务订单
                    String txid = (String) result.getData();
                    withdrawRecordService.withdrawSuccess(withdrawId, txid);
                } else {
                    logger.info("====================== 自动转账失败,转为人工处理 ==================================");
                    //自动转账失败,转为人工处理
                    withdrawRecordService.autoWithdrawFail(withdrawId);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("auto withdraw failed,error={}", e.getMessage());
            logger.info("====================== 自动转账失败,转为人工处理 ==================================");
//            自动转账失败,转为人工处理
            withdrawRecordService.autoWithdrawFail(withdrawId);
        }
    }