| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | import com.yeshi.fanli.service.inter.push.PushCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.push.PushCouponService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class PushCouponServiceImpl implements PushCouponService {
|
| | |
| | | if(pushCoupon.isPushed()) {
|
| | | throw new PushCouponException(1, "该信息不能重复推送");
|
| | | }
|
| | | String versions = pushCoupon.getVersions();
|
| | | if (versions == null || versions.trim().length() == 0 ) {
|
| | | throw new PushCouponException(1, "推送版本不能为空");
|
| | | }
|
| | |
|
| | |
|
| | | String title = pushCoupon.getTitle();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | List<String> listVersion = null;
|
| | | String versions = pushCoupon.getVersions();
|
| | | if (versions != null && versions.trim().length() > 0) {
|
| | | listVersion = Arrays.asList(versions.split(","));
|
| | | if (listVersion == null || listVersion.size() == 0) {
|
| | | throw new PushCouponException(1, "版本号格式不正确\"");
|
| | | List<String> listIOS = new ArrayList<String>();
|
| | | JSONObject json = JSONObject.fromObject(versions);
|
| | | String versionsIOS = json.getString("IOS");
|
| | | if (versionsIOS != null && versionsIOS.trim().length() > 0) {
|
| | | if (versionsIOS.contains("全推")) {
|
| | | listIOS = null;
|
| | | } else {
|
| | | listIOS = Arrays.asList(versionsIOS.split(","));
|
| | | }
|
| | | }
|
| | |
|
| | | List<String> listAndroid = new ArrayList<String>();
|
| | | String versionsAndroid = json.getString("Android");
|
| | | if (versionsAndroid != null && versionsAndroid.trim().length() > 0) {
|
| | | if (versionsAndroid.contains("全推")) {
|
| | | listAndroid = null;
|
| | | } else {
|
| | | listAndroid = Arrays.asList(versionsAndroid.split(","));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | pushService.pushWelfareCenter(null, title, content, listVersion);
|
| | | pushService.pushWelfareCenter(null, title, content, listIOS, listAndroid);
|
| | |
|
| | | } else {
|
| | | // 指定用户推送
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listVersion);
|
| | | pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listIOS, listAndroid);
|
| | | }
|
| | | }
|
| | | }
|