diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/coupon/CouponController.java b/src/main/java/cn/com/tenlion/operator/controller/api/coupon/CouponController.java index abacb6c..25462e6 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/coupon/CouponController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/coupon/CouponController.java @@ -57,7 +57,6 @@ public class CouponController extends DefaultBaseController { return new SuccessResult(); } - @ApiOperation(value = "新增优惠券", notes = "新增优惠券接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PostMapping("save") @@ -67,6 +66,18 @@ public class CouponController extends DefaultBaseController { return new SuccessResult(); } + @ApiOperation(value = "批量激活", notes = "批量激活接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @ApiImplicitParams({ + @ApiImplicitParam(name = "couponId", value = "优惠券ID", paramType = "path") + }) + @PutMapping("activi-all/{ids}") + @CheckRequestBodyAnnotation + public synchronized SuccessResult update(@PathVariable("ids") String ids) { + couponService.activiAll(Arrays.asList(ids.split("\\_"))); + return new SuccessResult(); + } + @ApiOperation(value = "修改优惠券", notes = "修改优惠券接口") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @ApiImplicitParams({ diff --git a/src/main/java/cn/com/tenlion/operator/controller/app/api/complaint/ComplaintAppController.java b/src/main/java/cn/com/tenlion/operator/controller/app/api/complaint/ComplaintAppController.java index b227ea7..5c30e13 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/app/api/complaint/ComplaintAppController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/app/api/complaint/ComplaintAppController.java @@ -212,10 +212,8 @@ public class ComplaintAppController extends DefaultBaseController { Map templateParams = new HashMap<>(); templateParams.put("code", code); templateParams.put("time", EhCacheType.USER_VERIFICATION_CODE.getMinute() + ""); - Boolean result = TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00001", templateParams, phoneArray); - if(!result) { - throw new UpdateException("发送短信失败"); - } + TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00001", templateParams, phoneArray); + ehCacheService.remove(EhCacheType.USER_VERIFICATION_CODE, phone + "PhoneCode"); ehCacheService.put(EhCacheType.USER_VERIFICATION_CODE,phone + "PhoneCode", code); return new SuccessResultData<>("success"); diff --git a/src/main/java/cn/com/tenlion/operator/pojo/dtos/coupon/CouponSend.java b/src/main/java/cn/com/tenlion/operator/pojo/dtos/coupon/CouponSend.java new file mode 100644 index 0000000..d64b218 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/dtos/coupon/CouponSend.java @@ -0,0 +1,14 @@ +package cn.com.tenlion.operator.pojo.dtos.coupon; + +public class CouponSend { + + public Integer count; + + public Double money; + + public CouponSend(Integer count, Double money) { + this.count = count; + this.money = money; + } + +} diff --git a/src/main/java/cn/com/tenlion/operator/serviceother/copyright1/coupon/CouponService.java b/src/main/java/cn/com/tenlion/operator/serviceother/copyright1/coupon/CouponService.java index 655defe..3137393 100644 --- a/src/main/java/cn/com/tenlion/operator/serviceother/copyright1/coupon/CouponService.java +++ b/src/main/java/cn/com/tenlion/operator/serviceother/copyright1/coupon/CouponService.java @@ -4,6 +4,7 @@ import cn.com.tenlion.operator.daoother.copyright1.coupon.ICouponDao; import cn.com.tenlion.operator.enums.coupon.CouponStatusEnum; import cn.com.tenlion.operator.enums.coupon.CouponTypeEnum; import cn.com.tenlion.operator.pojo.dtos.coupon.CouponDTO; +import cn.com.tenlion.operator.pojo.dtos.coupon.CouponSend; import cn.com.tenlion.operator.pojo.dtos.coupon.CouponSimpleDTO; import cn.com.tenlion.operator.pojo.dtos.coupon.related.user.CouponRelatedUserDTO; import cn.com.tenlion.operator.pojo.dtos.coupon.related.user.RelatedUserDTO; @@ -35,10 +36,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -58,6 +56,77 @@ public class CouponService extends DefaultBaseService { @Autowired private CouponUserService couponUserService; + public void activiAll(List ids) { + Map> params = new LinkedHashMap<>(); + // 手机号 , + for(String id : ids) { + CouponDTO dto = get(id); + if (dto.getStatus().getText().equals(CouponStatusEnum.ACTIVE.getText())) { + throw new SaveException(dto.getTitle() + "
已激活"); + } + if (dto.getType().getText().equals(CouponTypeEnum.QUOTA.getText())) { + throw new SaveException(dto.getTitle() + "
非定额定向"); + } + List list1 = dto.getRelatedUsers(); + if (list1.size() < 1) { + throw new SaveException(dto.getTitle() + "
未指定用户群"); + } + List temp = new ArrayList<>(); + for(CouponRelatedUserDTO dto1 : list1) { + temp.add(dto1.getUserUsername()); + } + temp.add(dto.getUseGmtStart()); + temp.add(dto.getAmount() + ""); + temp.add(dto.getUseGmtEnd()); + Collections.sort(temp); + + List data = params.get(temp.toString()); + if(data == null) { + data = new ArrayList<>(); + } + data.add(dto); + params.put(temp.toString(), data); + } + for(Map.Entry> m : params.entrySet()) { + List list = m.getValue(); + Integer count = list.size(); + List tempList = list.get(0).getRelatedUsers(); + /** + * 1. 保存领取记录 / 更新领取数量 + */ + for(CouponDTO dd : list) { + for (CouponRelatedUserDTO userDTO : dd.getRelatedUsers()) { + CouponUserVO vo = new CouponUserVO(); + vo.setCouponId(dd.getCouponId()); + couponUserService.save(vo, userDTO.getUserId()); + } + Map dataParans = getHashMap(4); + dataParans.put("couponId", dd.getCouponId()); + dataParans.put("status", CouponStatusEnum.ACTIVE.name()); + setUpdateInfo(dataParans); + couponDao.updateStatus(dataParans); + } + /** + * 2. 向用户群发送短信 + */ + JSONArray phoneArray = new JSONArray(); + for (CouponRelatedUserDTO userDTO : tempList) { + JSONObject obj = new JSONObject(); + obj.put("phone", userDTO.getUserUsername()); + phoneArray.add(obj); + } + Map templateParams = new HashMap<>(); + templateParams.put("money", PayUtil.buiderMoney(list.get(0).getAmount()) + ""); + templateParams.put("count", count + ""); + + LocalDate startDate = LocalDate.parse(list.get(0).getUseGmtStart(), originalFormatter); + LocalDate endDate = LocalDate.parse(list.get(0).getUseGmtEnd(), originalFormatter); + templateParams.put("startTime", startDate.format(targetFormatter)); + templateParams.put("endTime", endDate.format(targetFormatter)); + TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00015", templateParams, phoneArray); + } + } + public void save(CouponVO couponVO) { if (couponVO.getReleaseQuantity() < 1) { throw new SaveException("发布数量不合法"); @@ -180,10 +249,7 @@ public class CouponService extends DefaultBaseService { LocalDate endDate = LocalDate.parse(couponDTO.getUseGmtEnd(), originalFormatter); templateParams.put("startTime", startDate.format(targetFormatter)); templateParams.put("endTime", endDate.format(targetFormatter)); - Boolean result = TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00006", templateParams, phoneArray); - if(!result) { - throw new UpdateException("向用户群发送短信失败"); - } + TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00006", templateParams, phoneArray); } } Map params = getHashMap(4); @@ -337,4 +403,5 @@ public class CouponService extends DefaultBaseService { } couponRelatedUserService.saveBatch(couponId1, couponRelatedUserVOS); } + } diff --git a/src/main/java/cn/com/tenlion/operator/serviceother/operator/complaint/impl/ComplaintServiceImpl.java b/src/main/java/cn/com/tenlion/operator/serviceother/operator/complaint/impl/ComplaintServiceImpl.java index 2bb28f0..1984721 100644 --- a/src/main/java/cn/com/tenlion/operator/serviceother/operator/complaint/impl/ComplaintServiceImpl.java +++ b/src/main/java/cn/com/tenlion/operator/serviceother/operator/complaint/impl/ComplaintServiceImpl.java @@ -157,10 +157,7 @@ public class ComplaintServiceImpl extends DefaultBaseService implements IComplai Map templateParams = new HashMap<>(); templateParams.put("title", handleContent.length() > 30 ? handleContent.substring(0 , 30) + "..." : handleContent); templateParams.put("date", date); - Boolean result = TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00004", templateParams, phoneArray); - if(!result) { - throw new UpdateException("向用户发送短信失败"); - } + TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00004", templateParams, phoneArray); } } diff --git a/src/main/resources/mybatis/mapper/invoiceconfig/invoiceconfig-mapper.xml b/src/main/resources/mybatis/mapper/invoiceconfig/invoiceconfig-mapper.xml index 24cd2b7..ca58b06 100644 --- a/src/main/resources/mybatis/mapper/invoiceconfig/invoiceconfig-mapper.xml +++ b/src/main/resources/mybatis/mapper/invoiceconfig/invoiceconfig-mapper.xml @@ -242,7 +242,13 @@ AND ( - t1.id LIKE CONCAT('%', #{keywords}, '%') + t1.invoice_name LIKE CONCAT('%', #{keywords}, '%') + OR + t1.invoice_number LIKE CONCAT('%', #{keywords}, '%') + OR + t1.invoice_banknumber LIKE CONCAT('%', #{keywords}, '%') + OR + t1.invoice_orgaddress LIKE CONCAT('%', #{keywords}, '%') ) diff --git a/src/main/resources/templates/coupon/list.html b/src/main/resources/templates/coupon/list.html index c548e98..e0708aa 100644 --- a/src/main/resources/templates/coupon/list.html +++ b/src/main/resources/templates/coupon/list.html @@ -68,9 +68,9 @@ - + @@ -362,6 +362,39 @@ } removeData(ids); } + } else if(layEvent === 'activiEvent') { + if(checkDatas.length === 0) { + top.dialog.msg(top.dataMessage.table.selectDelete); + } else { + var ids = ''; + for(var i = 0, item; item = checkDatas[i++];) { + if(i > 1) { + ids += '_'; + } + ids += item['couponId']; + if( item['type'] != 'QUOTA_USERS') { + layer.msg("* 仅支持定额定向的优惠券"); + return; + } + if( item['status'] != 'UN_ACTIVE') { + layer.msg("* 仅支持未激活的优惠券"); + return; + } + } + top.dialog.confirm("确定要批量激活这些优惠券吗?
* 激活后会向用户群发送短信通知", function(index) { + top.dialog.close(index); + var loadLayerIndex; + top.restAjax.put(`api/coupon/activi-all/${ids}`, {}, null, function(code, data) { + reloadTable(); + }, function(code, data) { + top.dialog.msg(data.msg); + }, function() { + loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); + }, function() { + top.dialog.close(loadLayerIndex); + }); + }); + } } });