| | |
| | | |
| | | |
| | | private void addKey(SubmitKeyInfo keyInfo, Long wxUid) throws KeyVerifyException, KeyOrderException, WxOrderCountException { |
| | | |
| | | // 查询没有处理的数量 |
| | | long notProcessCount = keyOrderService.countUserNotDoOrder(wxUid, new Date(System.currentTimeMillis() - 1000*60*30)); |
| | | if(notProcessCount>0){ |
| | | throw new WxOrderCountException("上一个口令尚未处理完!"); |
| | | } |
| | | |
| | | // 解析链接 |
| | | List<String> urllist = UrlUtils.parseUrlsFromText(keyInfo.getKey()); |
| | | |
| | | |
| | | String verifyAlipayKey = systemConfigService.getValueCache(SystemConfigKeyEnum.ALIPAY_KEY_VERIFY); |
| | | DYOrderDto orderDto =null; |
| | | int orderType = Constant.ORDER_TYPE_UNKNOWN; |
| | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("list") |
| | | public String listAgent(String key, String day, int page, int limit) { |
| | | public String listAgent(String key, String startDay,String endDay, int page, int limit) { |
| | | //先查询所有的数据 |
| | | ChannelAgentSettleRecordMapper.DaoQuery query = new ChannelAgentSettleRecordMapper.DaoQuery(); |
| | | query.settleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(day)?null:day; |
| | | query.minSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(startDay)?null:startDay; |
| | | query.maxSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(endDay)?null:endDay; |
| | | query.sortList = Arrays.asList(new String[]{"_create_time desc"}); |
| | | query.start = (long) (page - 1) * limit; |
| | | query.count = limit; |
| | |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 开始结算 |
| | | * @date 0:28 2024/10/14 |
| | | * @param: startDay 开始日期 |
| | | * @param: endDay 结束日期 |
| | | * @return java.lang.String |
| | | **/ |
| | | @ResponseBody |
| | | @RequestMapping("startSettle") |
| | | public String startSettle(String day) { |
| | | public String startSettle(String startDay, String endDay) { |
| | | if(StringUtil.isNullOrEmpty(startDay)||StringUtil.isNullOrEmpty(endDay)){ |
| | | return JsonUtil.loadFalseResult("结算日期输入不完整"); |
| | | } |
| | | if(Integer.parseInt(startDay.replace("-",""))>Integer.parseInt(endDay.replace("-",""))){ |
| | | return JsonUtil.loadFalseResult("开始日期不能大于结束日期"); |
| | | } |
| | | |
| | | long startTimeStamp = TimeUtil.convertToTimeTemp(startDay,"yyyy-MM-dd"); |
| | | long endTimeStamp = TimeUtil.convertToTimeTemp(endDay,"yyyy-MM-dd"); |
| | | |
| | | List<String> days=new ArrayList<>(); |
| | | for(int i=0;i<100;i++){ |
| | | if(endTimeStamp< startTimeStamp + i*24*60*60*1000L){ |
| | | break; |
| | | } |
| | | days.add(TimeUtil.getGernalTime(startTimeStamp + i*24*60*60*1000L,"yyyy-MM-dd")); |
| | | } |
| | | |
| | | try { |
| | | channelAgentSettleService.startSettle(day); |
| | | for(String day:days) { |
| | | channelAgentSettleService.startSettle(day); |
| | | } |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (ChannelAgentSettleException e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | |
| | | |
| | | |
| | | @RequestMapping("downloadSettleTable") |
| | | public void downloadSettleTable(String day, HttpServletResponse response) throws IOException { |
| | | public void downloadSettleTable(String startDay,String endDay, HttpServletResponse response) throws IOException { |
| | | ChannelAgentSettleRecordMapper.DaoQuery daoQuery=new ChannelAgentSettleRecordMapper.DaoQuery(); |
| | | daoQuery.settleDay = day; |
| | | daoQuery.minSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(startDay)?null:startDay; |
| | | daoQuery.maxSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(endDay)?null:endDay; |
| | | daoQuery.count = 10000; |
| | | daoQuery.status = ChannelAgentSettleRecord.STATUS_NOT_SETTLE; |
| | | List<ChannelAgentSettleRecord> list = channelAgentSettleService.list(daoQuery); |
| | |
| | | List<KeyOrder> list = keyOrderService.listWithUser(query); |
| | | long count = keyOrderService.countWithUser(query); |
| | | query.hasPayTime = true; |
| | | query.state = KeyOrder.STATE_PAY; |
| | | // 统计所有的 |
| | | ChannelOrderStatistic statistic = keyOrderService.statisticWithUser(query); |
| | | // 统计 |
| | | |
| | | List<AgentOrderVO> voList = new ArrayList<>(); |
| | | Map<OrderChannelEnum, BigDecimal> shareMoneyMap = channelAgentSharingRatioService.getShareMoneyMap(agent.getId()); |
| | |
| | | @ResponseBody |
| | | @RequestMapping("setOrderNoV2") |
| | | public String setOrderNoV2(AcceptData acceptData, String id, String orderNoDesc, String orderStatus, String money) { |
| | | loggerPay.info("setOrderNo: {}-{}-{}-{}", id, orderNoDesc, orderStatus, money); |
| | | loggerPay.info("setOrderNo[{}]: {}-{}-{}-{}", acceptData.getUid(), id, orderNoDesc, orderStatus, money); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | return JsonUtil.loadFalseResult("请上传id"); |
| | | } |
| | |
| | | |
| | | OrderChannelEnum orderChannel = null; |
| | | if (dyOrderDto != null) { |
| | | orderChannel =OrderChannelUtil.getChannelByKey(dyOrderDto.getOrderChannel()); |
| | | }else{ |
| | | orderChannel = OrderChannelUtil.getChannelByKey(dyOrderDto.getOrderChannel()); |
| | | } else { |
| | | orderChannel = OrderChannelEnum.unknown; |
| | | } |
| | | |
| | | // 验证渠道支付次数是否达到上限 |
| | | // 验证渠道支付次数是否达到上限 |
| | | if (order.getUid() != null) { |
| | | long todayCount = wxUserOrderCountService.sum(order.getUid(), null,orderChannel, TimeUtil.getGernalTime(System.currentTimeMillis(), Constant.DB_DAY_FORMAT)); |
| | | long totalCount = wxUserOrderCountService.sum(order.getUid(), null,orderChannel,null); |
| | | int maxPayCount = userSettingService.getLimitCountByTotalCount(totalCount, orderChannel); |
| | | if(todayCount>=maxPayCount){ |
| | | throw new Exception( String.format("老铁今日已达支付次数(%s)上限:%s" ,orderChannel.getName(), maxPayCount)); |
| | | } |
| | | OrderCountTypeEnum orderCountType=null; |
| | | if(orderType==Constant.ORDER_TYPE_DY){ |
| | | orderCountType=OrderCountTypeEnum.DY_ORDER_PAY; |
| | | }else if(orderType==Constant.ORDER_TYPE_KS){ |
| | | orderCountType=OrderCountTypeEnum.KS_ORDER_PAY; |
| | | } |
| | | long todayCount = wxUserOrderCountService.sum(order.getUid(), orderCountType, orderChannel, TimeUtil.getGernalTime(System.currentTimeMillis(), Constant.DB_DAY_FORMAT)); |
| | | long totalCount = wxUserOrderCountService.sum(order.getUid(), orderCountType, null, null); |
| | | int maxPayCount = userSettingService.getLimitCountByTotalCount(orderType, totalCount, orderChannel); |
| | | if (todayCount >= maxPayCount) { |
| | | throw new Exception(String.format("老铁今日已达支付次数(%s)上限:%s", orderChannel.getName(), maxPayCount)); |
| | | } |
| | | } |
| | | |
| | | // 设置进入 |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 设置商家是否可支付 |
| | | * @date 1:26 2025/2/8 |
| | | * @param: acceptData |
| | | * @param: id |
| | | * @param: merchant |
| | | * @return java.lang.String |
| | | **/ |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("isMerchantCanPay") |
| | | public String isMerchantCanPay(AcceptData acceptData, String id, String merchant) { |
| | | loggerPay.info("isMerchantCanPay: {}-{}", id, merchant); |
| | | loggerPay.info("isMerchantCanPay[{}]: {}-{}", acceptData.getUid(), id, merchant); |
| | | // 判断是否为卡金额 |
| | | KeyOrder keyOrder = keyOrderService.selectById(id); |
| | | if (keyOrder == null) { |
| | |
| | | } |
| | | |
| | | // 获取卡金额的设置信息 |
| | | PayMoneySetting payMoneySetting = payMoneySettingService.getSettingByMoney(keyOrder.getOrderMoney()); |
| | | if(payMoneySetting == null){ |
| | | PayMoneySetting payMoneySetting = payMoneySettingService.getSettingByMoney(keyOrder.getOrderMoney()); |
| | | if (payMoneySetting == null) { |
| | | return JsonUtil.loadFalseResult("该金额不属于卡金额范围"); |
| | | } |
| | | if(payMoneySetting.getVerifyMerchantChannel()==null||payMoneySetting.getVerifyMerchantChannel()==OrderChannelEnum.unknown){ |
| | | if (payMoneySetting.getVerifyMerchantChannel() == null || payMoneySetting.getVerifyMerchantChannel() == OrderChannelEnum.unknown) { |
| | | // 没有设置校验渠道 |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | try { |
| | | // 目前只判断超享佣 |
| | | boolean isCanPay = OrderChannelApiUtil.isMerchantCanPay(payMoneySetting.getVerifyMerchantChannel(), merchant); |
| | | if(isCanPay){ |
| | | boolean isCanPay = OrderChannelApiUtil.isMerchantCanPay(payMoneySetting.getVerifyMerchantChannel(), merchant, keyOrder.getOrderMoney()); |
| | | if (isCanPay) { |
| | | return JsonUtil.loadTrueResult(""); |
| | | }else{ |
| | | } else { |
| | | return JsonUtil.loadFalseResult("商家校验未通过"); |
| | | } |
| | | } catch (UnsupportedEncodingException e) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @return java.lang.String |
| | | * @author hxh |
| | | * @description 是否可以执行支付 |
| | | * @date 0:22 2024/12/28 |
| | | * @param: acceptData |
| | | * @param: id |
| | | **/ |
| | | @ResponseBody |
| | | @RequestMapping("canExcutePay") |
| | | public String canExcutePay(AcceptData acceptData, String id) { |
| | | try { |
| | | KeyOrder keyOrder = keyOrderService.selectByIdForUpdate(id); |
| | | if (keyOrder == null) { |
| | | throw new Exception("订单不存在"); |
| | | } |
| | | if (keyOrder.getState() == KeyOrder.STATE_PAY) { |
| | | throw new Exception("订单已支付"); |
| | | } |
| | | loggerPay.info("canExcutePay[{}]: {}-{}", acceptData.getUid(), id, "可以支付"); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (Exception e) { |
| | | loggerPay.error("canExcutePay[{}]: {}-{}", acceptData.getUid(), id, "不可以支付:" + e.getMessage()); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("setPayResult") |
| | | public String setPayResult(AcceptData acceptData, String id, boolean paySuccess, String msg,String payMerchant) { |
| | | loggerPay.info("setPayResult: {}-{}-{}-{}", id, paySuccess, msg, payMerchant); |
| | | public String setPayResult(AcceptData acceptData, String id, boolean paySuccess, String msg, String payMerchant) { |
| | | loggerPay.info("setPayResult[{}]: {}-{}-{}-{}", acceptData.getUid(), id, paySuccess, msg, payMerchant); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | return JsonUtil.loadFalseResult("请上传id"); |
| | | } |
| | |
| | | KeyOrder orderUpdate = new KeyOrder(); |
| | | orderUpdate.setId(id); |
| | | orderUpdate.setState(KeyOrder.STATE_NOT_PAY); |
| | | orderUpdate.setStateDesc("支付失败:"+msg); |
| | | orderUpdate.setStateDesc("支付失败:" + msg); |
| | | orderUpdate.setPayMerchant(payMerchant); |
| | | keyOrderService.update(orderUpdate); |
| | | } |
| | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("rejectPay") |
| | | public String rejectPay(AcceptData acceptData, Long uid, String id) { |
| | | loggerPay.info("rejectPay: {}-{}", uid, id); |
| | | public String rejectPay(AcceptData acceptData, String id) { |
| | | loggerPay.info("rejectPay: {}-{}", acceptData.getUid(), id); |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | return JsonUtil.loadFalseResult("请上传id"); |
| | | } |
| | |
| | | public Long id; |
| | | public Long agentId; |
| | | public String settleDay; |
| | | public String minSettleDay; |
| | | public String maxSettleDay; |
| | | public BigDecimal settleMoney; |
| | | public BigDecimal actualSettleMoney; |
| | | public Date minPayTime; |
New file |
| | |
| | | package com.taoke.autopay.dto; |
| | | |
| | | import com.taoke.autopay.entity.OrderChannelEnum; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: ChannelOrderCountDTO |
| | | * @description: TODO |
| | | * @date 2025/2/7 22:29 |
| | | */ |
| | | @Data |
| | | public class ChannelOrderCountDTO { |
| | | private OrderChannelEnum orderChannel; |
| | | private int orderCount; |
| | | |
| | | } |
| | |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: UserSubmitKeyLimitDto |
| | |
| | | @Data |
| | | @Builder |
| | | public class UserSubmitKeyLimitDto { |
| | | private int totalCount; |
| | | private int perCountCyx; |
| | | private int perCountBps; |
| | | private int perCountUnknown; |
| | | /** |
| | | * 订单类型 |
| | | */ |
| | | private int orderType; |
| | | /** |
| | | * 之前支付的数量 |
| | | */ |
| | | private int beforeCount; |
| | | /** |
| | | * 今日可支付的订单数量列表 |
| | | */ |
| | | private List<ChannelOrderCountDTO> todayOrderCountList; |
| | | |
| | | } |
| | | |
| | |
| | | public final static int STATE_NOT_PAY = 1; |
| | | // 已支付 |
| | | public final static int STATE_PAY = 2; |
| | | // 已支付 |
| | | // 已拒绝 |
| | | public final static int STATE_REJECT_PAY = 3; |
| | | |
| | | |
| | |
| | | |
| | | cyx("huohuo","超佣享"), |
| | | bps("bps","爆品社"), |
| | | own("own","自有渠道"), |
| | | unknown("unknown","卡金額") |
| | | ; |
| | | |
| | |
| | | AGENT_ADMIN_LINK("agent_admin_link", "代理后台管理链接"), |
| | | AGENT_ORDER_CHANNEL_SHARE_RATIO("agent_order_channel_share_ratio", "代理订单渠道分成比例"), |
| | | RE_EXCUTE_PAY_CLIENTS("re_excute_pay_clients", "重新执行支付的账号"), |
| | | USER_SUBMIT_KEY_COUNT_LIMIT("user_submit_key_count_limit", "用户提交口令次数限制"), |
| | | USER_SUBMIT_KEY_COUNT_LIMIT("user_submit_key_count_limit_v2", "用户提交口令次数限制"), |
| | | ; |
| | | |
| | | |
| | |
| | | **/ |
| | | public KeyOrder selectById(String id); |
| | | |
| | | public KeyOrder selectByIdForUpdate(String id); |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | |
| | | */ |
| | | public long countAgentId(KeyOrderMapper.DaoQuery query); |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 统计用户还没处理的订单数量 |
| | | * @date 18:26 2025/2/7 |
| | | * @param: uid |
| | | * @param: minCreateTime |
| | | * @return long |
| | | **/ |
| | | public long countUserNotDoOrder(Long uid, Date minCreateTime); |
| | | |
| | | } |
| | |
| | | * @author hxh |
| | | * @description 根据总提交次数获取每日提交次数 |
| | | * @date 22:47 2024/8/1 |
| | | * @param: orderType |
| | | * @param: totalCount |
| | | * @return int |
| | | **/ |
| | | public int getLimitCountByTotalCount(long totalCount, OrderChannelEnum orderChannel); |
| | | public int getLimitCountByTotalCount(int orderType, long totalCount, OrderChannelEnum orderChannel); |
| | | |
| | | } |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public KeyOrder selectByIdForUpdate(String id) { |
| | | return keyOrderMapper.selectByPrimaryKeyForUpdate(id); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public KeyOrder addKeyOrder(SubmitKeyInfo keyInfo, Long uid, String day, Integer orderType, DYOrderDto orderDto) throws KeyOrderException, WxOrderCountException { |
| | | // 判断提交次数是否过量 |
| | | if (uid != null) { |
| | |
| | | public long countAgentId(KeyOrderMapper.DaoQuery query) { |
| | | return keyOrderMapper.countAgentId(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countUserNotDoOrder(Long uid, Date minCreateTime) { |
| | | KeyOrderMapper.DaoQuery daoQuery=new KeyOrderMapper.DaoQuery(); |
| | | daoQuery.uid = uid; |
| | | daoQuery.stateList=Arrays.asList(new Integer[]{KeyOrder.STATE_NOT_PROCESS,KeyOrder.STATE_NOT_PAY}); |
| | | daoQuery.minCreateTime = minCreateTime; |
| | | return keyOrderMapper.count(daoQuery); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.taoke.autopay.dto.ChannelOrderCountDTO; |
| | | import com.taoke.autopay.dto.UserSubmitKeyLimitDto; |
| | | import com.taoke.autopay.entity.OrderChannelEnum; |
| | | import com.taoke.autopay.entity.SystemConfigKeyEnum; |
| | |
| | | limit = new ArrayList<>(); |
| | | } |
| | | limit.sort((UserSubmitKeyLimitDto o1, UserSubmitKeyLimitDto o2) -> |
| | | o2.getTotalCount() - o1.getTotalCount()); |
| | | o1.getOrderType()==o2.getOrderType() ? o2.getBeforeCount() - o1.getBeforeCount():o1.getOrderType() - o2.getOrderType()); |
| | | systemConfigService.setValue(SystemConfigKeyEnum.USER_SUBMIT_KEY_COUNT_LIMIT, new Gson().toJson(limit)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int getLimitCountByTotalCount(long totalCount, OrderChannelEnum orderChannel) { |
| | | public int getLimitCountByTotalCount(int orderType, long beforeCount, OrderChannelEnum orderChannel) { |
| | | List<UserSubmitKeyLimitDto> list = getUserSubmitKeyCountList(true); |
| | | if (list.size() == 0) { |
| | | return Integer.MAX_VALUE; |
| | | } |
| | | for (UserSubmitKeyLimitDto t : list) { |
| | | if (totalCount >= t.getTotalCount()) { |
| | | if(orderChannel==OrderChannelEnum.cyx){ |
| | | return t.getPerCountCyx(); |
| | | } |
| | | else if(orderChannel==OrderChannelEnum.bps){ |
| | | return t.getPerCountBps(); |
| | | } |
| | | else if(orderChannel==OrderChannelEnum.unknown){ |
| | | return t.getPerCountUnknown(); |
| | | if(t.getOrderType()!=orderType){ |
| | | continue; |
| | | } |
| | | if (beforeCount >= t.getBeforeCount()) { |
| | | for(ChannelOrderCountDTO tt:t.getTodayOrderCountList()){ |
| | | if(tt.getOrderChannel() ==orderChannel){ |
| | | return tt.getOrderCount(); |
| | | } |
| | | } |
| | | return Integer.MAX_VALUE; |
| | | } |
| | |
| | | if(totalCount>Integer.MAX_VALUE){ |
| | | totalCount = (long)Integer.MAX_VALUE; |
| | | } |
| | | int submitCount = userSettingService.getLimitCountByTotalCount((int)totalCount.longValue(), orderChannel); |
| | | int submitCount = userSettingService.getLimitCountByTotalCount(orderType.getType(), (int)totalCount.longValue(), orderChannel); |
| | | if(maxCount==null){ |
| | | maxCount =Integer.MAX_VALUE; |
| | | } |
| | |
| | | if(totalCount>Integer.MAX_VALUE){ |
| | | totalCount = (long)Integer.MAX_VALUE; |
| | | } |
| | | int submitCount = userSettingService.getLimitCountByTotalCount((int)totalCount.longValue(),orderChannel); |
| | | int submitCount = userSettingService.getLimitCountByTotalCount(orderType.getType(), (int)totalCount.longValue(),orderChannel); |
| | | if(maxCount==null){ |
| | | maxCount =Integer.MAX_VALUE; |
| | | } |
| | |
| | | |
| | | public final static int ORDER_TYPE_KS=2; |
| | | |
| | | // 超佣享 |
| | | public final static String ORDER_CHANNEL_CYX = "huohuo"; |
| | | |
| | | // 爆品社 |
| | | public final static String ORDER_CHANNEL_BPS = "bps"; |
| | | |
| | | // 自有渠道 |
| | | public final static String ORDER_CHANNEL_OWN = "own"; |
| | | |
| | | // 根据订单号支付 |
| | | public final static int PAY_TYPE_WITH_ORDER_NO = 1; |
| | |
| | | // 根据金额支付 |
| | | public final static int PAY_TYPE_WITH_MONEY = 2; |
| | | |
| | | public final static int MAX_PAY_ACCOUNT_QUEUE_SIZE = 4; |
| | | public final static int MAX_PAY_ACCOUNT_QUEUE_SIZE = 1; |
| | | |
| | | public final static String DB_DAY_FORMAT="yyyyMMdd"; |
| | | |
| | |
| | | |
| | | import com.taoke.autopay.entity.OrderChannelEnum; |
| | | import com.taoke.autopay.utils.HttpUtil; |
| | | import com.taoke.autopay.utils.StringUtil; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @author hxh |
| | |
| | | * @param: channel |
| | | * @param: orderChannelName |
| | | **/ |
| | | public static boolean isMerchantCanPay(OrderChannelEnum channel, String merchant) throws UnsupportedEncodingException { |
| | | public static boolean isMerchantCanPay(OrderChannelEnum channel, String merchant, BigDecimal payMoney) throws UnsupportedEncodingException { |
| | | if (channel == OrderChannelEnum.cyx) { |
| | | String url = String.format("https://api.youihuo.com/open/free.checkKsCompanyName?bsName=%s&apiKey=%s", URLEncoder.encode(merchant, "UTF-8"), OrderChannelUtil.CYX_API_KEY); |
| | | String result = HttpUtil.get(url); |
| | | logger.info(String.format("超佣享商家付款判断:%s-%s", merchant, result)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | String result = HttpUtil.get(url); |
| | | logger.info(String.format("超佣享商家付款判断:%s-%s-%s", merchant, result, payMoney!=null?payMoney.setScale(2,RoundingMode.HALF_UP).toString():null)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | System.out.println(result); |
| | | if(root.optInt("code") == 1000){ |
| | | if (root.optInt("code") == 1000) { |
| | | return true; |
| | | } |
| | | } else if (channel == OrderChannelEnum.bps) { |
| | | String url = String.format("https://api.bpshe.com/mall/douyinOMS/getSubsidyOrderInfo?appKey=cdaef330f1324961a73e15a85ab67fd2&payAccount=%s", URLEncoder.encode(merchant, StandardCharsets.UTF_8.displayName())); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Accept", "application/json;charset=utf-8"); |
| | | String result = HttpUtil.get(url, headers); |
| | | logger.info(String.format("爆品社商家付款判断:%s-%s-%s", merchant, result, payMoney!=null?payMoney.setScale(2,RoundingMode.HALF_UP).toString():null)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | if (root.optInt("errCode") == 0) { |
| | | JSONArray array = root.optJSONObject("data").optJSONArray("payAmounts"); |
| | | if (array != null) { |
| | | if (payMoney == null) { |
| | | return true; |
| | | } |
| | | Set<String> moneys = new HashSet<>(); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | moneys.add(array.optString(i)); |
| | | } |
| | | return moneys.contains(payMoney.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | |
| | | |
| | | public static void main(String[] args) throws UnsupportedEncodingException { |
| | | |
| | | System.out.print( isMerchantCanPay(OrderChannelEnum.cyx,"广州市天河区长兴街安尔雅服饰商行1")); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | package com.taoke.autopay.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @title: AcceptData |
| | | * @description: 接口基础数据 |
| | | * @date 2021/11/16 17:40 |
| | | */ |
| | | @Data |
| | | public class AcceptData { |
| | | //时间戳 |
| | | private long timestamp; |
| | | private String sign; |
| | | private String packages; |
| | | private int version; |
| | | |
| | | |
| | | public long getTimestamp() { |
| | | return timestamp; |
| | | } |
| | | |
| | | public void setTimestamp(long timestamp) { |
| | | this.timestamp = timestamp; |
| | | } |
| | | |
| | | public String getSign() { |
| | | return sign; |
| | | } |
| | | |
| | | public void setSign(String sign) { |
| | | this.sign = sign; |
| | | } |
| | | |
| | | public String getPackages() { |
| | | return packages; |
| | | } |
| | | |
| | | public void setPackages(String packages) { |
| | | this.packages = packages; |
| | | } |
| | | |
| | | public int getVersion() { |
| | | return version; |
| | | } |
| | | |
| | | public void setVersion(int version) { |
| | | this.version = version; |
| | | } |
| | | //客户端ID |
| | | private Long uid; |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: pro |
| | | active: dev |
| | |
| | | <if test="query.id!=null">AND _id = #{query.id}</if> |
| | | <if test="query.agentId!=null">AND _agent_id = #{query.agentId}</if> |
| | | <if test="query.settleDay!=null">AND _settle_day = #{query.settleDay}</if> |
| | | |
| | | <if test="query.minSettleDay!=null">AND _settle_day >= #{query.minSettleDay}</if> |
| | | |
| | | <if test="query.maxSettleDay!=null">AND #{query.maxSettleDay} >=_settle_day</if> |
| | | |
| | | |
| | | |
| | | |
| | | <if test="query.settleMoney!=null">AND _settle_money = #{query.settleMoney}</if> |
| | | <if test="query.actualSettleMoney!=null">AND _actual_settle_money = #{query.actualSettleMoney}</if> |
| | | <if test="query.minPayTime!=null">AND _pay_time >= #{query.minPayTime}</if> |
| | |
| | | <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > _create_time</if> |
| | | <if test="query.minUpdateTime!=null">AND _update_time >= #{query.minUpdateTime}</if> |
| | | <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > _update_time</if> |
| | | |
| | | |
| | | |
| | | </sql> |
| | | <select id="list" resultMap="BaseResultMap">select |
| | | <include refid="Base_Column_List"/> |
| | |
| | | class="layui-input"> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <input type="text" name="day" placeholder="日期" autocomplete="off" class="layui-input"> |
| | | <input type="text" name="startDay" placeholder="开始日期" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <input type="text" name="endDay" placeholder="结束日期" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <button class="layui-btn layui-btn-normal" lay-submit lay-filter="search" id="search"><i |
| | |
| | | } |
| | | |
| | | function start_settle() { |
| | | if ($("input[name=day]").val().length < 1) { |
| | | layer.msg("请选择日期"); |
| | | if ($("input[name=startDay]").val().length < 1) { |
| | | layer.msg("请选择开始日期"); |
| | | return false; |
| | | } |
| | | if ($("input[name=endDay]").val().length < 1) { |
| | | layer.msg("请选择结束日期"); |
| | | return false; |
| | | } |
| | | $.post("/admin/api/agentsettle/startSettle", { |
| | | day: $("input[name=day]").val() |
| | | }, function(response) { |
| | | startDay: $("input[name=startDay]").val(), |
| | | endDay: $("input[name=endDay]").val() |
| | | }, function(response) { |
| | | if (response.code == 0) { |
| | | layer.msg("预结算成功"); |
| | | } else { |
| | |
| | | } |
| | | |
| | | function download_settle_table() { |
| | | if ($("input[name=day]").val().length < 1) { |
| | | layer.msg("请选择日期"); |
| | | return false; |
| | | } |
| | | var href = "/admin/api/agentsettle/downloadSettleTable?day=" + $("input[name=day]").val(); |
| | | if ($("input[name=startDay]").val().length < 1) { |
| | | layer.msg("请选择开始日期"); |
| | | return false; |
| | | } |
| | | if ($("input[name=endDay]").val().length < 1) { |
| | | layer.msg("请选择结束日期"); |
| | | return false; |
| | | } |
| | | var href = "/admin/api/agentsettle/downloadSettleTable?startDay=" + $("input[name=startDay]").val()+"&endDay =" + $("input[name=endDay]").val(); |
| | | window.open(href, '_blank'); |
| | | } |
| | | |
| | |
| | | var laydate = layui.laydate; |
| | | |
| | | laydate.render({ |
| | | elem: "input[name=day]", |
| | | elem: "input[name=startDay]", |
| | | type: "date", |
| | | value: new Date(), |
| | | isInitValue: false |
| | | }); |
| | | laydate.render({ |
| | | elem: "input[name=endDay]", |
| | | type: "date", |
| | | value: new Date(), |
| | | isInitValue: false |
| | | }); |
| | | |
| | | //执行实例 |
| | | var uploadInst = upload.render({ |
| | |
| | | url: '/admin/api/agentsettle/list', //数据接口 |
| | | where: { |
| | | 'key': $("#key").val(), |
| | | 'day': $("input[name=day]").val(), |
| | | 'startDay': $("input[name=startDay]").val(), |
| | | 'endDay': $("input[name=endDay]").val(), |
| | | }, |
| | | parseData: function(res) { //res 即为原始返回的数据 |
| | | let flist = new Array(); |
| | |
| | | <script type="text/html" id="payMoneyTemplate"> |
| | | <div class="layui-form-item"> |
| | | |
| | | <span>以往订单>=</span> |
| | | <input type="text" name="totalCount_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.totalCount }}" class="layui-input totalCount"> |
| | | <span>以往</span> |
| | | |
| | | |
| | | |
| | | <select lay-verify="required" name="orderType_{{d.index}}" style="display: inline"> |
| | | <option value="1" {{d.orderType==1?'selected':''}}>抖音</option> |
| | | <option value="2" {{d.orderType==2?'selected':''}}>快手</option> |
| | | </select> |
| | | |
| | | <span> 订单>=</span> |
| | | <input type="text" name="beforeCount_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.beforeCount }}" class="layui-input totalCount"> |
| | | <span>单,限制提交:</span> |
| | | |
| | | <span>超佣享</span> |
| | | <input type="text" name="perCountCyx_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.perCountCyx }}" class="layui-input"> |
| | | <input type="text" name="cyx_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.cyx }}" class="layui-input"> |
| | | <span>单,</span> |
| | | |
| | | <span>爆品社</span> |
| | | <input type="text" name="perCountBps_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.perCountBps }}" class="layui-input"> |
| | | <input type="text" name="bps_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.bps }}" class="layui-input"> |
| | | <span>单,</span> |
| | | |
| | | <span>卡金额</span> |
| | | <input type="text" name="perCountUnknown_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.perCountUnknown }}" class="layui-input"> |
| | | <span>自渠</span> |
| | | <input type="text" name="own_{{d.index}}" required lay-verify="required|num" placeholder="正整数" |
| | | autocomplete="off" value="{{ d.own}}" class="layui-input"> |
| | | <span>单</span> |
| | | |
| | | <span class="layui-icon layui-icon-close delete"></span> |
| | |
| | | const index = $(".totalCount").length + 1; |
| | | laytpl($('#payMoneyTemplate').html()).render({ |
| | | "index": index, |
| | | "totalCount": "", |
| | | "perCountCyx": "", |
| | | "perCountBps": "", |
| | | "perCountUnknown": "", |
| | | "beforeCount": "", |
| | | "cyx": "", |
| | | "bps": "", |
| | | "own": "", |
| | | }, function(html) { |
| | | $("#add").parent().parent().before(html); |
| | | }); |
| | |
| | | // 设置资金 |
| | | for (var i = 0; i < response.data.length; i++) { |
| | | let item = response.data[i]; |
| | | laytpl($('#payMoneyTemplate').html()).render({ |
| | | "index": i + 1, |
| | | "totalCount": item.totalCount, |
| | | "perCountCyx": item.perCountCyx, |
| | | "perCountBps": item.perCountBps, |
| | | "perCountUnknown": item.perCountUnknown, |
| | | }, function(html) { |
| | | var params= { |
| | | "index": i + 1, |
| | | "orderType": item.orderType, |
| | | "beforeCount": item.beforeCount, |
| | | "cyx": 0, |
| | | "bps": 0, |
| | | "own": 0, |
| | | }; |
| | | item.todayOrderCountList.forEach(function(e){ |
| | | params[e["orderChannel"]] = e["orderCount"]; |
| | | }); |
| | | laytpl($('#payMoneyTemplate').html()).render(params, function(html) { |
| | | $("#add").parent().parent().before(html); |
| | | $(".delete").bind("click", function(e) { |
| | | $(e.target).parent().remove(); |
| | |
| | | |
| | | var params = []; |
| | | for (var key in data.field) { |
| | | if (key.indexOf("totalCount_") == 0) { |
| | | let index = key.replace("totalCount_", ""); |
| | | params.push({ |
| | | "totalCount": data.field[key], |
| | | "perCountCyx": data.field["perCountCyx_" + index], |
| | | "perCountBps": data.field["perCountBps_" + index], |
| | | "perCountUnknown": data.field["perCountUnknown_" + index] |
| | | }); |
| | | if (key.indexOf("beforeCount_") == 0) { |
| | | let index = key.replace("beforeCount_", ""); |
| | | var fdata= { |
| | | "beforeCount": data.field[key], |
| | | "orderType": data.field["orderType_" + index], |
| | | "todayOrderCountList": [], |
| | | "perCountUnknown": data.field["perCountUnknown_" + index] |
| | | }; |
| | | fdata.todayOrderCountList.push({"orderChannel":"cyx","orderCount":data.field["cyx_" + index]}) |
| | | fdata.todayOrderCountList.push({"orderChannel":"bps","orderCount":data.field["bps_" + index]}) |
| | | fdata.todayOrderCountList.push({"orderChannel":"own","orderCount":data.field["own_" + index]}) |
| | | params.push(fdata); |
| | | } |
| | | } |
| | | console.log(params); |
| | |
| | | public void getPercount() { |
| | | int[] tc = new int[]{1000, 500, 400, 300, 200, 100}; |
| | | for (int t : tc) { |
| | | System.out.println(t + "=>" + userSettingService.getLimitCountByTotalCount(t, OrderChannelEnum.bps)); |
| | | System.out.println(t + "=>" + userSettingService.getLimitCountByTotalCount(1, t, OrderChannelEnum.bps)); |
| | | } |
| | | } |
| | | |
| | |
| | | OrderChannelEnum orderChannel= OrderChannelEnum.bps; |
| | | long todayCount = wxUserOrderCountService.sum(uid, null,orderChannel, TimeUtil.getGernalTime(System.currentTimeMillis(), Constant.DB_DAY_FORMAT)); |
| | | long totalCount = wxUserOrderCountService.sum(uid, null,orderChannel,null); |
| | | int maxPayCount = userSettingService.getLimitCountByTotalCount(totalCount, orderChannel); |
| | | int maxPayCount = userSettingService.getLimitCountByTotalCount(2, totalCount, orderChannel); |
| | | if(todayCount>=maxPayCount){ |
| | | ; |
| | | } |
| | |
| | | public void test1() throws WxOrderCountException { |
| | | WxUserOrderCountMapper.DaoQuery daoQuery=new WxUserOrderCountMapper.DaoQuery(); |
| | | daoQuery.uid = 45678942L; |
| | | System.out.println( wxUserOrderCountMapper.sumOrderCount(daoQuery)); |
| | | System.out.println(wxUserOrderCountMapper.sumOrderCount(daoQuery)); |
| | | } |
| | | |
| | | |