Search in sources :

Example 6 with SupporterDeviceSubscription

use of net.osmand.server.api.repo.DeviceSubscriptionsRepository.SupporterDeviceSubscription in project OsmAnd-tools by osmandapp.

the class AdminController method searchSubscription.

@PostMapping(path = { "/search-subscription" })
public String searchSubscription(Model model, @RequestParam(required = true) String orderId, final RedirectAttributes redirectAttrs) throws JsonProcessingException {
    SupporterDeviceSubscription deviceSub = new SupporterDeviceSubscription();
    deviceSub.sku = "not found";
    deviceSub.orderId = "none";
    deviceSub.valid = false;
    if (emailSender.isEmail(orderId)) {
        PremiumUser pu = usersRepository.findByEmail(orderId);
        if (pu != null) {
            deviceSub.sku = orderId + " (pro email)";
            List<SupporterDeviceSubscription> ls = subscriptionsRepository.findByOrderId(pu.orderid);
            if (ls != null && ls.size() > 0) {
                deviceSub = ls.get(0);
            }
            if (deviceSub != null) {
                UserFilesResults ufs = userDataController.generateFiles(pu.id, null, null, true, false);
                ufs.allFiles.clear();
                ufs.uniqueFiles.clear();
                deviceSub.payload = gson.toJson(ufs);
            }
        }
    } else {
        List<SupporterDeviceSubscription> ls = subscriptionsRepository.findByOrderId(orderId);
        if (ls != null && ls.size() > 0) {
            deviceSub = ls.get(0);
        }
    }
    redirectAttrs.addFlashAttribute("subscriptions", Collections.singleton(deviceSub));
    return "redirect:info#audience";
}
Also used : SupporterDeviceSubscription(net.osmand.server.api.repo.DeviceSubscriptionsRepository.SupporterDeviceSubscription) UserFilesResults(net.osmand.server.controllers.pub.UserdataController.UserFilesResults) PremiumUser(net.osmand.server.api.repo.PremiumUsersRepository.PremiumUser) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

SupporterDeviceSubscription (net.osmand.server.api.repo.DeviceSubscriptionsRepository.SupporterDeviceSubscription)6 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 SupporterDeviceSubscriptionPrimaryKey (net.osmand.server.api.repo.DeviceSubscriptionsRepository.SupporterDeviceSubscriptionPrimaryKey)2 PremiumUser (net.osmand.server.api.repo.PremiumUsersRepository.PremiumUser)2 JsonObject (com.google.gson.JsonObject)1 Calendar (java.util.Calendar)1 Map (java.util.Map)1 InAppReceipt (net.osmand.live.subscriptions.ReceiptValidationHelper.InAppReceipt)1 Supporter (net.osmand.server.api.repo.SupportersRepository.Supporter)1 MessageParams (net.osmand.server.api.services.MotdService.MessageParams)1 UserFilesResults (net.osmand.server.controllers.pub.UserdataController.UserFilesResults)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1