修改了发票信息管理的模糊查询
增加了优惠券的批量激活 , 与批量短信整合发送
This commit is contained in:
parent
870c913b53
commit
0adb6b3bfd
@ -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({
|
||||
|
@ -212,10 +212,8 @@ public class ComplaintAppController extends DefaultBaseController {
|
||||
Map<String, String> 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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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<String> ids) {
|
||||
Map<String, List<CouponDTO>> params = new LinkedHashMap<>();
|
||||
// 手机号 ,
|
||||
for(String id : ids) {
|
||||
CouponDTO dto = get(id);
|
||||
if (dto.getStatus().getText().equals(CouponStatusEnum.ACTIVE.getText())) {
|
||||
throw new SaveException(dto.getTitle() + "</br>已激活");
|
||||
}
|
||||
if (dto.getType().getText().equals(CouponTypeEnum.QUOTA.getText())) {
|
||||
throw new SaveException(dto.getTitle() + "</br>非定额定向");
|
||||
}
|
||||
List<CouponRelatedUserDTO> list1 = dto.getRelatedUsers();
|
||||
if (list1.size() < 1) {
|
||||
throw new SaveException(dto.getTitle() + "</br>未指定用户群");
|
||||
}
|
||||
List<String> 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<CouponDTO> data = params.get(temp.toString());
|
||||
if(data == null) {
|
||||
data = new ArrayList<>();
|
||||
}
|
||||
data.add(dto);
|
||||
params.put(temp.toString(), data);
|
||||
}
|
||||
for(Map.Entry<String, List<CouponDTO>> m : params.entrySet()) {
|
||||
List<CouponDTO> list = m.getValue();
|
||||
Integer count = list.size();
|
||||
List<CouponRelatedUserDTO> 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<String, Object> 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<String, String> 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<String, Object> params = getHashMap(4);
|
||||
@ -337,4 +403,5 @@ public class CouponService extends DefaultBaseService {
|
||||
}
|
||||
couponRelatedUserService.saveBatch(couponId1, couponRelatedUserVOS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -157,10 +157,7 @@ public class ComplaintServiceImpl extends DefaultBaseService implements IComplai
|
||||
Map<String, String> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -242,7 +242,13 @@
|
||||
<if test="keywords != null and keywords != ''">
|
||||
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}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
|
@ -68,9 +68,9 @@
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||
<i class="fa fa-lg fa-trash"></i> 删除
|
||||
</button>
|
||||
<!-- <button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="activiEvent">
|
||||
<i class="fa fa-lg fa-globe"></i> 激活优惠券
|
||||
</button>-->
|
||||
<button type="button" class="layui-btn layui-btn-sm" lay-event="activiEvent">
|
||||
<i class="fa fa-lg fa-globe"></i> 定额定向批量激活
|
||||
</button>
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
@ -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("确定要批量激活这些优惠券吗?</br> * 激活后会向用户群发送短信通知", 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user