|
|
@@ -64,7 +64,13 @@ public class PromoteQrcodePoolController extends BaseController<PromoteQrcodePoo
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
public Object list(@RequestBody GetPromoteQrcodePoolHandle pageHandle) {
|
|
|
- Object res = promoteQrcodePoolService.getlist(pageHandle);
|
|
|
+ PromoteCode promoteCode = promoteCodeService.getOne(new QueryWrapper<PromoteCode>().eq("id",pageHandle.getPromoteId()));
|
|
|
+ Object res = new Object();
|
|
|
+ if (promoteCode.getPromoteType().equals(1)){
|
|
|
+ res = promoteQrcodePoolService.getDefaultList(pageHandle);
|
|
|
+ }else{
|
|
|
+ res = promoteQrcodePoolService.getMobilePoolList(pageHandle);
|
|
|
+ }
|
|
|
return AjaxResult.success(res);
|
|
|
}
|
|
|
|
|
|
@@ -100,51 +106,6 @@ public class PromoteQrcodePoolController extends BaseController<PromoteQrcodePoo
|
|
|
return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @PostMapping("/add")
|
|
|
- public Object add(@Valid @RequestBody AddHandle<PromoteQrcodePool> addHandle, BindingResult bindingResult) {
|
|
|
- if (bindingResult.hasErrors()) {
|
|
|
- return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
- }
|
|
|
- //.排重
|
|
|
- PromoteQrcodePool hasone = promoteQrcodePoolService.getOne(new QueryWrapper<PromoteQrcodePool>()
|
|
|
- .eq("promote_id", addHandle.getRaw().getPromoteId())
|
|
|
- .eq("custservice_id", addHandle.getRaw().getCustserviceId()));
|
|
|
- if (hasone != null) {
|
|
|
- return AjaxResult.error(addHandle.getRaw().getCustserviceId() + "号个微码已经存在");
|
|
|
- }
|
|
|
- PromoteCode promoteCode = promoteCodeService.getOne(new QueryWrapper<PromoteCode>().eq("id", addHandle.getRaw().getPromoteId()));
|
|
|
- PromoteQrcodePool promoteQrcodePool = promoteQrcodePoolService.getOne(
|
|
|
- new QueryWrapper<PromoteQrcodePool>()
|
|
|
- .eq("promote_id", addHandle.getRaw().getPromoteId())
|
|
|
- .orderByDesc("weight")
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
- if (promoteQrcodePool != null) {
|
|
|
- Integer weight = promoteQrcodePool.getWeight();
|
|
|
- //.权重自动分配最大999
|
|
|
- if (weight >= 999) {
|
|
|
- addHandle.getRaw().setWeight(999);
|
|
|
- } else {
|
|
|
- addHandle.getRaw().setWeight(weight + 1);
|
|
|
- }
|
|
|
- }else{
|
|
|
- addHandle.getRaw().setWeight(1);
|
|
|
- }
|
|
|
- addHandle.getRaw().setDayUvMax(promoteCode.getDayUvMax());
|
|
|
- addHandle.getRaw().setHourUvMax(promoteCode.getHourUvMax());
|
|
|
- this.onInsert(addHandle.getRaw());
|
|
|
- Boolean res = promoteQrcodePoolService.save(addHandle.getRaw());
|
|
|
- if (res) {
|
|
|
- //.同步到redis
|
|
|
- promoteQrcodePoolService.addRedis(addHandle.getRaw().getPromoteId(), addHandle.getRaw().getCustserviceId(), addHandle.getRaw().getWeight());
|
|
|
- this.sync();
|
|
|
- return AjaxResult.success(Constants.SUCCESS, res);
|
|
|
- } else {
|
|
|
- return AjaxResult.error("新增失败", res);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping("/adds")
|
|
|
public Object adds(@Valid @RequestBody AddsHandle<PromoteQrcodePool> addsHandle, BindingResult bindingResult) {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
@@ -187,7 +148,6 @@ public class PromoteQrcodePoolController extends BaseController<PromoteQrcodePoo
|
|
|
if (res) {
|
|
|
//.同步到redis
|
|
|
promoteQrcodePoolService.addRedis(raw.getPromoteId(), raw.getCustserviceId(), raw.getWeight());
|
|
|
- this.sync();
|
|
|
successList.add(raw.getCustserviceId());
|
|
|
continue;
|
|
|
} else {
|
|
|
@@ -195,6 +155,8 @@ public class PromoteQrcodePoolController extends BaseController<PromoteQrcodePoo
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
+ this.syncDefault();
|
|
|
+ this.syncMobilePool();
|
|
|
result.put("successList", successList);
|
|
|
result.put("errorList", errorList);
|
|
|
return AjaxResult.success(result);
|
|
|
@@ -208,13 +170,21 @@ public class PromoteQrcodePoolController extends BaseController<PromoteQrcodePoo
|
|
|
}
|
|
|
onUpdate(editHandle);
|
|
|
promoteQrcodePoolService.update(editHandle.getRaw(), new QueryWrapper<PromoteQrcodePool>().in("id", editHandle.getIds()));
|
|
|
- this.sync();
|
|
|
+ this.syncDefault();
|
|
|
return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private Boolean sync(){
|
|
|
- List<PromoteQrcodePoolVo> list = promoteQrcodePoolService.getAlllist();
|
|
|
+ private Boolean syncDefault(){
|
|
|
+ List<PromoteQrcodePoolVo> list = promoteQrcodePoolService.getAllDefaultList();
|
|
|
+ for (PromoteQrcodePoolVo poolVo : list) {
|
|
|
+ stringRedisTemplate.opsForHash().put(RedisKey.PanPromoteCodePool+poolVo.getPromoteId(), Integer.toString(poolVo.getCustserviceId()), JSON.toJSONString(poolVo));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean syncMobilePool(){
|
|
|
+ List<PromoteQrcodePoolVo> list = promoteQrcodePoolService.getAllMobilePoolList();
|
|
|
for (PromoteQrcodePoolVo poolVo : list) {
|
|
|
stringRedisTemplate.opsForHash().put(RedisKey.PanPromoteCodePool+poolVo.getPromoteId(), Integer.toString(poolVo.getCustserviceId()), JSON.toJSONString(poolVo));
|
|
|
}
|