| | |
| | | |
| | | import com.taoke.autopay.dao.KeyOrderMapper; |
| | | import com.taoke.autopay.dao.WxUserSettingsMapper; |
| | | import com.taoke.autopay.dto.ChannelOrderStatistic; |
| | | import com.taoke.autopay.dto.DYOrderDto; |
| | | import com.taoke.autopay.entity.*; |
| | | import com.taoke.autopay.entity.agent.ChannelAgent; |
| | | import com.taoke.autopay.exception.KeyOrderException; |
| | | import com.taoke.autopay.exception.KeyVerifyException; |
| | | import com.taoke.autopay.exception.WxOrderCountException; |
| | |
| | | import com.taoke.autopay.service.SystemConfigService; |
| | | import com.taoke.autopay.service.WxUserOrderCountService; |
| | | import com.taoke.autopay.service.WxUserSettingService; |
| | | import com.taoke.autopay.service.agent.ChannelAgentService; |
| | | import com.taoke.autopay.service.agent.ChannelAgentSharingRatioService; |
| | | import com.taoke.autopay.utils.*; |
| | | import com.taoke.autopay.utils.order.DYOrderApi; |
| | | import com.taoke.autopay.vo.SubmitKeyInfo; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.net.URI; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private ChannelAgentService channelAgentService; |
| | | |
| | | @Resource |
| | | private ChannelAgentSharingRatioService channelAgentSharingRatioService; |
| | | |
| | | |
| | | @Override |
| | | public KeyOrder selectById(String id) { |
| | |
| | | throw new KeyOrderException("请勿重复提交口令"); |
| | | } |
| | | order = new KeyOrder(); |
| | | // 解析referer中的链接 |
| | | if (!StringUtil.isNullOrEmpty(keyInfo.getReferer())) { |
| | | Map<String, String> paramsMap = HttpUtil.getPramsFromUrl(keyInfo.getReferer()); |
| | | if (paramsMap.containsKey("a")) { |
| | | String alias = paramsMap.get("a"); |
| | | ChannelAgent agent = channelAgentService.selectByAlias(alias); |
| | | if (agent == null) { |
| | | throw new KeyOrderException("渠道不存在"); |
| | | } |
| | | |
| | | if (agent.getStatus() != ChannelAgent.STATUS_NOMAL) { |
| | | throw new KeyOrderException("渠道受限"); |
| | | } |
| | | order.setAgentId(agent.getId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | order.setId(id); |
| | | order.setKey(keyInfo.getKey()); |
| | | if(!StringUtil.isNullOrEmpty(keyInfo.getMoney())){ |
| | |
| | | public long count(KeyOrderMapper.DaoQuery query) { |
| | | return keyOrderMapper.count(query); |
| | | } |
| | | |
| | | @Override |
| | | public List<KeyOrder> listWithUser(KeyOrderMapper.DaoQuery query) { |
| | | return keyOrderMapper.listWithUser(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countWithUser(KeyOrderMapper.DaoQuery query) { |
| | | return keyOrderMapper.countWithUser(query); |
| | | } |
| | | |
| | | @Override |
| | | public ChannelOrderStatistic statisticWithUser(KeyOrderMapper.DaoQuery query) { |
| | | Map<OrderChannelEnum, BigDecimal> shareMoneyMap = channelAgentSharingRatioService.getShareMoneyMap(query.agentId); |
| | | List<ChannelOrderStatistic> channelOrderStatisticList = keyOrderMapper.statisticChannelOrders(query); |
| | | BigDecimal totalMoney = new BigDecimal(0); |
| | | for (ChannelOrderStatistic s : channelOrderStatisticList) { |
| | | |
| | | for (OrderChannelEnum channel : OrderChannelEnum.values()) { |
| | | if (channel.getKey().equalsIgnoreCase(s.getOrderChannel())) { |
| | | |
| | | if (shareMoneyMap.containsKey(channel)) { |
| | | totalMoney = totalMoney.add(shareMoneyMap.get(channel).multiply(new BigDecimal(s.getCount()))); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | long userCount = keyOrderMapper.countUser(query); |
| | | ChannelOrderStatistic statistic = new ChannelOrderStatistic(); |
| | | statistic.setCount(userCount); |
| | | statistic.setMoney(totalMoney); |
| | | return statistic; |
| | | } |
| | | |
| | | @Override |
| | | public List<ChannelOrderStatistic> statisticChannelOrders(Long agentId, Date startTime, Date endTime) { |
| | | KeyOrderMapper.DaoQuery daoQuery=new KeyOrderMapper.DaoQuery(); |
| | | daoQuery.oMinCreateTime=startTime; |
| | | daoQuery.oMaxCreateTime=endTime; |
| | | daoQuery.agentId = agentId; |
| | | daoQuery.state =KeyOrder.STATE_PAY; |
| | | daoQuery.hasPayTime=true; |
| | | |
| | | return keyOrderMapper.statisticChannelOrders(daoQuery); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Long getCanDistributeUid() { |
| | |
| | | public void removeDistributedClient(String id) { |
| | | keyOrderMapper.removeDistributedClient(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> listAgentId(KeyOrderMapper.DaoQuery query) { |
| | | return keyOrderMapper.listAgentId(query); |
| | | } |
| | | |
| | | @Override |
| | | public long countAgentId(KeyOrderMapper.DaoQuery query) { |
| | | return keyOrderMapper.countAgentId(query); |
| | | } |
| | | } |