|
|
@@ -13,6 +13,7 @@ import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import kr.co.zumo.app.R;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.PushBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.APIData;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CoinInfoBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CoinInfoResultBean;
|
|
|
@@ -119,6 +120,37 @@ public class GuestCoinManager {
|
|
|
return isRemoved;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 코인 만료 3일이 남았다면 알림 발송
|
|
|
+ *
|
|
|
+ * @return int 소멸 예정 코인 값
|
|
|
+ */
|
|
|
+ public int getCoinExtinctionValue(int day) {
|
|
|
+ // 코인 만료 3일이 남았다면 알림 발송
|
|
|
+ List<CoinInfoBean> list = coinInfoResultBean.getData();
|
|
|
+ long todayMillis = Calendar.getInstance().getTimeInMillis();
|
|
|
+ CoinInfoBean coinInfoBean;
|
|
|
+ int len = list.size();
|
|
|
+ int totalCoin = 0;
|
|
|
+ for (int i = 0; i < len; ++i) {
|
|
|
+ coinInfoBean = list.get(i);
|
|
|
+ long coinDayMillis = Formatter.dateStringToMillis(CoinInfoBean.DATE_PATTERN, coinInfoBean.getDate());
|
|
|
+ long limitDayMillis = TimeUnit.DAYS.toMillis(coinInfoBean.getLimitDays() + 1);
|
|
|
+ long targetDayMillis = limitDayMillis - TimeUnit.DAYS.toMillis(day); // 3일 전
|
|
|
+
|
|
|
+ if (targetDayMillis < todayMillis && coinInfoBean.isNotified() == false/* && todayMillis > targetDayMillis + TimeUnit.DAYS.toMillis(1)*/) {
|
|
|
+ // 3일 전 이라면
|
|
|
+ // -> 정확히 3일 남은 시점만 확인하면 2~1일 남은 것 중 알림이 되지 않은 것을 놓칠 수 있다. bean 에 알림을 했는지 표시해서 확인
|
|
|
+ coinInfoBean.setNotified(true);
|
|
|
+ totalCoin = Integer.parseInt(coinInfoBean.getGoodsAmount());
|
|
|
+ Log.d("APP# GuestCoinManager | notifyCoinExtinction", "|" + " totalCoin: " + totalCoin);
|
|
|
+ Log.d("APP# GuestCoinManager | notifyCoinExtinction", "|" + " coinInfoBean: " + coinInfoBean.toJson());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return totalCoin;
|
|
|
+ }
|
|
|
+
|
|
|
/***********************************
|
|
|
* Guest api result
|
|
|
***********************************/
|
|
|
@@ -247,4 +279,25 @@ public class GuestCoinManager {
|
|
|
shareCoinResultBean.setCode(LifeplusAPIBean.RETURN_SUCCESS);
|
|
|
return shareCoinResultBean;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param wrapper
|
|
|
+ */
|
|
|
+ public static void notifyCoinExtinction(CoinInfoResultBeanPrivateWrapper wrapper) {
|
|
|
+
|
|
|
+ GuestCoinManager manager = new GuestCoinManager(wrapper.coinInfoResultBean);
|
|
|
+ int result = manager.getCoinExtinctionValue(3);
|
|
|
+
|
|
|
+ if (result > 0) {
|
|
|
+ PushBean bean = new PushBean();
|
|
|
+ bean.setContents(ResourceUtil.getString(R.string.notice_guest_coin_extinction, result));
|
|
|
+ bean.setDateTime(Formatter.format(System.currentTimeMillis(), PushBean.DATE_FORMAT));
|
|
|
+ bean.setNeedSaving(APIData.TRUE);
|
|
|
+ bean.setPushType(PushBean.PUSH_TYPE_COIN);
|
|
|
+ bean.setScreenCode(PushMessageManager.CODE_EXTINCTION);
|
|
|
+
|
|
|
+ PushMessageManager.onReceived(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|