| | |
| | | package com.yeshi.fanli.service.impl.push;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Arrays;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | Integer amount = record.getAmount();
|
| | | if (amount == null || amount < 1) {
|
| | | throw new PushCouponException(1, "券数量不能小于1");
|
| | | if (amount == null) {
|
| | | throw new PushCouponException(1, "券数量不能为空");
|
| | | } else if (amount < 1 || amount > 5) {
|
| | | throw new PushCouponException(1, "券数量范围是 1~5");
|
| | | }
|
| | | |
| | | BigDecimal percent = record.getPercent();
|
| | | if (percent != null && (percent.compareTo(new BigDecimal(60)) > 0
|
| | | || percent.compareTo(new BigDecimal(1)) < 0)) {
|
| | | throw new PushCouponException(1, "券比例范围是1~60 的正整数");
|
| | | }
|
| | | |
| | |
|
| | | Long id = record.getId();
|
| | | if (id == null) {
|
| | |
| | | if (current == null) {
|
| | | throw new PushCouponException(1, "该记录已不存在");
|
| | | }
|
| | | |
| | | if(current.isPushed()) {
|
| | | throw new PushCouponException(1, "已推送的信息不能修改");
|
| | | }
|
| | |
|
| | | current.setTitle(title);
|
| | | current.setContent(content);
|
| | |
| | | // 更新数据
|
| | | updateByPrimaryKey(current);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | if (pushCoupon == null) {
|
| | | throw new PushCouponException(1, "推送信息已不存在");
|
| | | }
|
| | | |
| | | if(pushCoupon.isPushed()) {
|
| | | throw new PushCouponException(1, "该信息不能重复推送");
|
| | | }
|
| | | |
| | |
|
| | | String title = pushCoupon.getTitle();
|
| | | String content = pushCoupon.getContent();
|
| | |
| | | }
|
| | |
|
| | |
|
| | | // TODO 推送跳转
|
| | | |
| | | |
| | | List<String> listuid = null;
|
| | | String uids = pushCoupon.getUids();
|
| | | if (uids == null || uids.trim().length() == 0) {
|
| | | if (uids != null && uids.trim().length() > 0) {
|
| | | listuid = Arrays.asList(uids.split(","));
|
| | | if (listuid == null || listuid.size() == 0) {
|
| | | throw new PushCouponException(1, "用户id格式不正确");
|
| | | }
|
| | | }
|
| | | |
| | | 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, "版本号格式不正确\"");
|
| | | }
|
| | | }
|
| | | |
| | | if (listuid == null) {
|
| | | // 全推
|
| | | //pushService.pushZNX(null, title, content);
|
| | | pushService.pushWelfareCenter(null, title, content, listVersion);
|
| | |
|
| | | } else {
|
| | | // 指定用户推送
|
| | | String[] uidArray = uids.split(",");
|
| | | |
| | | if (uidArray != null) {
|
| | | for (int i = 0; i < uidArray.length; i++) {
|
| | | String str_uid = uidArray[i];
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | //pushService.pushZNX(Long.parseLong(str_uid), title, content);
|
| | | }
|
| | | for (String str_uid: listuid) {
|
| | | if (str_uid != null && str_uid.trim().length() > 0) {
|
| | | pushService.pushWelfareCenter(Long.parseLong(str_uid), title, content, listVersion);
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | // 已推送
|
| | |
| | |
|
| | | for (Long id: list) {
|
| | | long receivedCount = pushCouponRecordService.countByPushId(id);
|
| | | // 领取数量
|
| | | if (receivedCount > 0) {
|
| | | continue;
|
| | | }
|