Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.master.web.controller.rewardpoincustomer;
- import java.util.ArrayList;
- import java.util.List;
- import javax.annotation.PostConstruct;
- import org.jleaf.core.GeneralConstants;
- import org.jleaf.erp.master.api.MasterApi;
- import org.jleaf.util.Calc;
- import org.jleaf.web.helper.MessageHelper;
- import org.jleaf.web.helper.ServiceResult;
- import org.jleaf.web.jsf.template.BasicController;
- import org.jleaf.web.jsf.util.JSONObjectUtil;
- import org.json.simple.JSONObject;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.context.annotation.Scope;
- import org.springframework.stereotype.Controller;
- @Controller
- @Scope("view")
- public class RewardPoinCustomerNoSessionController extends BasicController implements MasterApi {
- private static final Logger log = LoggerFactory.getLogger(RewardPoinCustomerNoSessionController.class);
- private JSONObject rewardPoinData = new JSONObject();
- private JSONObject input = new JSONObject();
- private List<JSONObject> logDataList = new ArrayList<JSONObject>();
- private RewardPoinCustomerNoSessionController () {
- rewardPoinData = new JSONObject ();
- input = new JSONObject ();
- }
- @SuppressWarnings("unchecked")
- @PostConstruct
- private void init() {
- log.info("init() >>>>>>>>>>>>>>>>>>>>>>*<<<<<<<<<<<<<<<<<<<");
- this.rewardPoinData = new JSONObject();
- this.input = new JSONObject();
- input.put("tenantId", 10L);
- input.put("customerId", 151L);
- input.put("dateTo", "20210916");
- input.put("dateFrom", "20210616");
- String customerName = GeneralConstants.EMPTY_VALUE;
- String address = GeneralConstants.EMPTY_VALUE;
- String noHp = GeneralConstants.EMPTY_VALUE;
- Double saldoStpJelantah = new Double(0);
- Double saldoStpKertasNonKertas = new Double(0);
- JSONObject jsonInput = new JSONObject();
- jsonInput.put("tenantId", input.get("tenantId"));
- jsonInput.put("customerId", input.get("customerId"));
- log.info("init().jsonInput >>> :"+jsonInput);
- try {
- JSONObject output = new JSONObject();
- output = serviceContext.executeService(GET_REWARD_POIN_CUSTOMER_BALANCE_LIST, jsonInput);
- JSONObject result = JSONObjectUtil.getResult(output);
- if(ServiceResult.isOk(output)){
- List<JSONObject> list = ServiceResult.toArray(result.get("rewardPoinCustomerBalanceList"));
- if(list != null && list.size() > 0) {
- customerName = list.get(0).get("customerName").toString();
- address = list.get(0).get("address").toString();
- noHp = list.get(0).get("noHp").toString();
- saldoStpJelantah = Double.valueOf(list.get(0).get("stpJelantah").toString());
- saldoStpKertasNonKertas = new Calc(saldoStpKertasNonKertas)
- .add(Double.valueOf(list.get(0).get("stpKertas").toString()))
- .add(Double.valueOf(list.get(0).get("stpNonKertas").toString())).doubleValue();
- }
- } else{
- log.info("RESULT==============="+result);
- MessageHelper.displayError(result);
- }
- }catch(Exception ex){
- log.info("RESULT=11111=============="+ex.getMessage());
- MessageHelper.displayError(ex.getMessage());
- }
- rewardPoinData.put("customerName", customerName);
- rewardPoinData.put("address", address);
- rewardPoinData.put("noHp", noHp);
- rewardPoinData.put("saldoStpJelantah", saldoStpJelantah);
- rewardPoinData.put("saldoStpKertasNonKertas", saldoStpKertasNonKertas);
- }
- @SuppressWarnings("unchecked")
- public void doSearchLogData() {
- JSONObject jsonInput = new JSONObject();
- jsonInput.put("tenantId", input.get("tenantId"));
- jsonInput.put("customerId", input.get("customerId"));
- jsonInput.put("dateFrom", input.get("dateFrom"));
- jsonInput.put("dateTo", input.get("dateTo"));
- log.info("doSearchLogData().jsonInput >>> :"+jsonInput);
- try {
- JSONObject output = new JSONObject();
- output = serviceContext.executeService(GET_LOG_REWARD_POIN_CUSTOMER_LIST, jsonInput);
- JSONObject result = JSONObjectUtil.getResult(output);
- if(ServiceResult.isOk(output)){
- this.logDataList = ServiceResult.toArray(result.get("logRewardPoinCustomerList"));
- if(logDataList != null && logDataList.size() > 0) {
- for (JSONObject dataLog : logDataList) {
- Double totalStpKertas = Double.valueOf(dataLog.get("totalStpKertas").toString());
- Double totalStpNonkertas = Double.valueOf(dataLog.get("totalStpNonkertas").toString());
- dataLog.put("totalStpKertasAndNonKertas", new Calc(totalStpKertas).add(totalStpNonkertas).doubleValue());
- }
- }
- } else{
- log.info("RESULT==============="+result);
- MessageHelper.displayError(result);
- }
- }catch(Exception ex){
- log.info("RESULT=11111=============="+ex.getMessage());
- MessageHelper.displayError(ex.getMessage());
- }
- }
- // ----------------------------------------------------------------------------------------------------------- //
- public void setRewardPoinData(JSONObject rewardPoinData) {
- this.rewardPoinData = rewardPoinData;
- }
- public JSONObject getRewardPoinData() {
- return rewardPoinData;
- }
- public void setInput(JSONObject input) {
- this.input = input;
- }
- public JSONObject getInput() {
- return input;
- }
- public void setLogDataList(List<JSONObject> logDataList) {
- this.logDataList = logDataList;
- }
- public List<JSONObject> getLogDataList() {
- return logDataList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement