Subversion Repositories SmartDukaan

Rev

Rev 34288 | Rev 34322 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34288 Rev 34301
Line 17... Line 17...
17
import com.spice.profitmandi.dao.entity.dtr.User;
17
import com.spice.profitmandi.dao.entity.dtr.User;
18
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
18
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
19
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
19
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
20
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
20
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
21
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
21
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
-
 
22
import com.spice.profitmandi.dao.entity.fofo.RbmRating;
22
import com.spice.profitmandi.dao.entity.user.*;
23
import com.spice.profitmandi.dao.entity.user.*;
23
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
24
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
24
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
25
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
25
import com.spice.profitmandi.dao.enumuration.dtr.*;
26
import com.spice.profitmandi.dao.enumuration.dtr.*;
26
import com.spice.profitmandi.dao.model.*;
27
import com.spice.profitmandi.dao.model.*;
27
import com.spice.profitmandi.dao.repository.auth.*;
28
import com.spice.profitmandi.dao.repository.auth.*;
28
import com.spice.profitmandi.dao.repository.cs.*;
29
import com.spice.profitmandi.dao.repository.cs.*;
29
import com.spice.profitmandi.dao.repository.dtr.*;
30
import com.spice.profitmandi.dao.repository.dtr.*;
30
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
31
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
-
 
32
import com.spice.profitmandi.dao.repository.fofo.RbmRatingRepository;
31
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
33
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
32
import com.spice.profitmandi.dao.repository.user.AddressRepository;
34
import com.spice.profitmandi.dao.repository.user.AddressRepository;
33
import com.spice.profitmandi.service.AuthService;
35
import com.spice.profitmandi.service.AuthService;
34
import com.spice.profitmandi.service.NotificationService;
36
import com.spice.profitmandi.service.NotificationService;
35
import com.spice.profitmandi.service.PartnerCollectionService;
37
import com.spice.profitmandi.service.PartnerCollectionService;
36
import com.spice.profitmandi.service.user.RetailerService;
38
import com.spice.profitmandi.service.user.RetailerService;
37
import com.spice.profitmandi.service.user.StoreTimelineTatService;
39
import com.spice.profitmandi.service.user.StoreTimelineTatService;
38
import com.spice.profitmandi.web.req.CreateFranchiseeRequest;
40
import com.spice.profitmandi.web.req.CreateFranchiseeRequest;
-
 
41
import com.spice.profitmandi.web.req.RbmRatingRequest;
39
import com.spice.profitmandi.web.res.Partner;
42
import com.spice.profitmandi.web.res.Partner;
40
import io.swagger.annotations.ApiImplicitParam;
43
import io.swagger.annotations.ApiImplicitParam;
41
import io.swagger.annotations.ApiImplicitParams;
44
import io.swagger.annotations.ApiImplicitParams;
42
import org.apache.commons.csv.CSVRecord;
45
import org.apache.commons.csv.CSVRecord;
43
import org.apache.commons.io.output.ByteArrayOutputStream;
46
import org.apache.commons.io.output.ByteArrayOutputStream;
Line 58... Line 61...
58
 
61
 
59
import javax.servlet.http.HttpServletRequest;
62
import javax.servlet.http.HttpServletRequest;
60
import java.io.IOException;
63
import java.io.IOException;
61
import java.time.LocalDate;
64
import java.time.LocalDate;
62
import java.time.LocalDateTime;
65
import java.time.LocalDateTime;
-
 
66
import java.time.YearMonth;
63
import java.time.format.DateTimeFormatter;
67
import java.time.format.DateTimeFormatter;
64
import java.util.*;
68
import java.util.*;
65
import java.util.Map.Entry;
69
import java.util.Map.Entry;
66
import java.util.stream.Collectors;
70
import java.util.stream.Collectors;
67
 
71
 
Line 1585... Line 1589...
1585
 
1589
 
1586
        return responseSender.ok(true);
1590
        return responseSender.ok(true);
1587
 
1591
 
1588
    }
1592
    }
1589
 
1593
 
-
 
1594
    @Autowired
-
 
1595
    RbmRatingRepository rbmRatingRepository;
-
 
1596
 
-
 
1597
    @RequestMapping(value = "/rbmRating", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1598
    public ResponseEntity<?> rbmRating(HttpServletRequest request, @RequestBody RbmRatingRequest rbmRatingRequest, Model model) throws Exception {
-
 
1599
        int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
-
 
1600
        UserCart uc = userAccountRepository.getUserCart(userId);
-
 
1601
        int fofoId = uc.getUserId();
-
 
1602
        int rbmL1 = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1, fofoId);
-
 
1603
 
-
 
1604
        YearMonth currentMonth = YearMonth.now();
-
 
1605
        LocalDateTime startOfMonth = currentMonth.atDay(1).atStartOfDay();
-
 
1606
        LocalDateTime endOfMonth = currentMonth.atEndOfMonth().atTime(23, 59, 59);
-
 
1607
 
-
 
1608
        List<RbmRating> existingRatings = rbmRatingRepository.findByFofoIdAndRbmIdForCurrentMonth(fofoId, rbmL1, startOfMonth, endOfMonth);
-
 
1609
        if (!existingRatings.isEmpty()) {
-
 
1610
            return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Rating for this month already exists.");
-
 
1611
        }
-
 
1612
 
-
 
1613
        LOGGER.info("existingRatings {}", existingRatings);
-
 
1614
 
-
 
1615
        // Save the new rating
-
 
1616
        RbmRating rbmRating = new RbmRating();
-
 
1617
        rbmRating.setComment(rbmRatingRequest.getComment());
-
 
1618
        rbmRating.setRating(rbmRatingRequest.getRating());
-
 
1619
        rbmRating.setFofoId(fofoId);
-
 
1620
        rbmRating.setRbmId(rbmL1);
-
 
1621
        rbmRating.setCreateTimeStamp(LocalDateTime.now());
-
 
1622
        rbmRatingRepository.persist(rbmRating);
-
 
1623
 
-
 
1624
        return responseSender.ok(true);
-
 
1625
    }
-
 
1626
 
-
 
1627
 
1590
}
1628
}
1591
1629