Subversion Repositories SmartDukaan

Rev

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

Rev 26517 Rev 27067
Line 20... Line 20...
20
import org.springframework.beans.factory.annotation.Autowired;
20
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.mail.javamail.JavaMailSender;
21
import org.springframework.mail.javamail.JavaMailSender;
22
import org.springframework.mail.javamail.MimeMessageHelper;
22
import org.springframework.mail.javamail.MimeMessageHelper;
23
import org.springframework.stereotype.Controller;
23
import org.springframework.stereotype.Controller;
24
import org.springframework.ui.Model;
24
import org.springframework.ui.Model;
-
 
25
import org.springframework.web.bind.annotation.PostMapping;
25
import org.springframework.web.bind.annotation.RequestBody;
26
import org.springframework.web.bind.annotation.RequestBody;
26
import org.springframework.web.bind.annotation.RequestMapping;
27
import org.springframework.web.bind.annotation.RequestMapping;
27
import org.springframework.web.bind.annotation.RequestMethod;
28
import org.springframework.web.bind.annotation.RequestMethod;
28
import org.springframework.web.bind.annotation.RequestParam;
29
import org.springframework.web.bind.annotation.RequestParam;
-
 
30
import org.springframework.web.bind.annotation.RequestPart;
-
 
31
import org.springframework.web.multipart.MultipartFile;
29
 
32
 
30
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
33
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
31
import com.spice.profitmandi.common.model.CustomRetailer;
34
import com.spice.profitmandi.common.model.CustomRetailer;
32
import com.spice.profitmandi.common.model.ProfitMandiConstants;
35
import com.spice.profitmandi.common.model.ProfitMandiConstants;
33
import com.spice.profitmandi.common.model.UnsettledPaymentModel;
36
import com.spice.profitmandi.common.model.UnsettledPaymentModel;
-
 
37
import com.spice.profitmandi.common.util.ExcelUtils;
34
import com.spice.profitmandi.common.util.StringUtils;
38
import com.spice.profitmandi.common.util.StringUtils;
-
 
39
import com.spice.profitmandi.common.util.WalletHistoryModel;
35
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
40
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
36
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
41
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
37
import com.spice.profitmandi.dao.entity.transaction.UnsettledPayment;
42
import com.spice.profitmandi.dao.entity.transaction.UnsettledPayment;
38
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
43
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
39
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
44
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
40
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
45
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
41
import com.spice.profitmandi.dao.enumuration.transaction.TransactionType;
46
import com.spice.profitmandi.dao.enumuration.transaction.TransactionType;
-
 
47
import com.spice.profitmandi.dao.model.ContentPojo;
42
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
48
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
43
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
49
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
44
import com.spice.profitmandi.dao.repository.catalog.UnsettledPaymentsRepository;
50
import com.spice.profitmandi.dao.repository.catalog.UnsettledPaymentsRepository;
45
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
51
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
46
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
52
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
Line 104... Line 110...
104
	private RetailerRepository retailerRepository;
110
	private RetailerRepository retailerRepository;
105
 
111
 
106
	@Autowired
112
	@Autowired
107
	private UserRepository userRepository;
113
	private UserRepository userRepository;
108
	private static final Logger LOGGER = LogManager.getLogger(WalletController.class);
114
	private static final Logger LOGGER = LogManager.getLogger(WalletController.class);
-
 
115
	
-
 
116
	
-
 
117
	@PostMapping(value = "/wallet/upload")
-
 
118
	public String uploadContent(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
-
 
119
			throws Exception {
-
 
120
		List<WalletHistoryModel> walletHistoryModelList = ExcelUtils.parseWalletBulkCredit(file.getInputStream());
-
 
121
		for(WalletHistoryModel walletHistoryModel : walletHistoryModelList) {
-
 
122
			ManualPaymentType paymentType =
-
 
123
					manualPaymentRequestRepository.selectByReferenceType(walletHistoryModel.getWalletReferenceType());
-
 
124
			if (paymentType == null) {
-
 
125
				paymentType = new ManualPaymentType();
-
 
126
				paymentType.setReferenceType(walletHistoryModel.getWalletReferenceType());
-
 
127
			}
-
 
128
			paymentType.setCounter(paymentType.getCounter() + 1);
-
 
129
			manualPaymentRequestRepository.persist(paymentType);
-
 
130
			int reference = paymentType.getCounter();
-
 
131
			walletService.addAmountToWallet(walletHistoryModel.getFofoId(), reference, walletHistoryModel.getWalletReferenceType(), 
-
 
132
					walletHistoryModel.getDescription(), (float)walletHistoryModel.getAmount(), walletHistoryModel.getBusinessDate());
-
 
133
		}
-
 
134
 
-
 
135
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
-
 
136
		return "response";
-
 
137
	}
109
 
138
 
110
	@RequestMapping(value = "/walletDetails", method = RequestMethod.GET)
139
	@RequestMapping(value = "/walletDetails", method = RequestMethod.GET)
111
	public String dashboard(HttpServletRequest request,
140
	public String dashboard(HttpServletRequest request,
112
			@RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString,
141
			@RequestParam(name = ProfitMandiConstants.START_TIME, required = false) String startTimeString,
113
			@RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString,
142
			@RequestParam(name = ProfitMandiConstants.END_TIME, required = false) String endTimeString,
Line 643... Line 672...
643
			LOGGER.error("referenceType: " + referenceType);
672
			LOGGER.error("referenceType: " + referenceType);
644
			ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(referenceType);
673
			ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(referenceType);
645
 
674
 
646
			if (paymentType == null) {
675
			if (paymentType == null) {
647
				paymentType = new ManualPaymentType();
676
				paymentType = new ManualPaymentType();
-
 
677
				paymentType.setReferenceType(referenceType);
648
			}
678
			}
649
			paymentType.setReferenceType(referenceType);
-
 
650
			paymentType.setCounter(paymentType.getCounter() + 1);
679
			paymentType.setCounter(paymentType.getCounter() + 1);
651
			manualPaymentRequestRepository.persist(paymentType);
680
			manualPaymentRequestRepository.persist(paymentType);
652
			reference = paymentType.getCounter();
681
			reference = paymentType.getCounter();
653
			
682
			
654
		} else if(reference==0){
683
		} else if(reference==0){