记得上下班打卡 | git大法好,push需谨慎

Commit ef3d6ded authored by Tice's avatar Tice

Merge branch 'dev_merchant_tice' into dev_merchant

parents 47732d73 9d6b14a5
......@@ -3,9 +3,12 @@ package com.liquidnet.service.merchant.constant;
public class MerchantRedisConst {
public static final String PREFIX = "merchant:";
// 场地详情
// 场地详情(场地)
public static final String INFO_FIELD = PREFIX.concat("info:fields:");
// 个人全部的场地申请
// 场地常用验票员(场地)
public static final String INFO_FIELD_CHECKERS = PREFIX.concat("info:field_checkers:");
// 场地申请(个人)
public static final String INFO_FIELD_APPLIES = PREFIX.concat("info:field_applies:");
}
package com.liquidnet.service.merchant.dto.vo;
public class MerchantFieldCheckersVo {
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.merchant.entity.MerchantFieldCheckers;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ApiModel(value = "MerchantFieldAppliesVo", description = "申请的场地")
@Data
public class MerchantFieldCheckersVo implements java.io.Serializable, Cloneable {
private static final long serialVersionUID = 5965779904967405763L;
@ApiModelProperty(position = 10, value = "验票授权ID")
private String fieldCheckerId;
@ApiModelProperty(position = 11, value = "场地ID")
private String fieldId;
@ApiModelProperty(position = 12, value = "权利账号")
private String uid;
@ApiModelProperty(position = 13, value = "手机号")
private String mobile;
@ApiModelProperty(position = 14, value = "姓名")
private String name;
@ApiModelProperty(position = 15, value = "授权账号")
private String cuid;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
private LocalDateTime createdAt;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
private LocalDateTime updatedAt;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
private LocalDateTime deletedAt;
private static final MerchantFieldCheckersVo obj = new MerchantFieldCheckersVo();
public static MerchantFieldCheckersVo getNew() {
try {
return (MerchantFieldCheckersVo) obj.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return new MerchantFieldCheckersVo();
}
public MerchantFieldCheckersVo copy(MerchantFieldCheckers source) {
if (null == source) return this;
this.setFieldCheckerId(source.getFieldCheckerId());
this.setFieldId(source.getFieldId());
this.setUid(source.getUid());
this.setMobile(source.getMobile());
this.setName(source.getName());
this.setCuid(source.getCuid());
this.setCreatedAt(source.getCreatedAt());
this.setUpdatedAt(source.getUpdatedAt());
this.setDeletedAt(source.getDeletedAt());
return this;
}
}
......@@ -2,12 +2,21 @@ package com.liquidnet.service.merchant.service;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.merchant.dto.param.MerchantFieldApplyParam;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldCheckersVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldsVo;
import java.util.List;
public interface IMerchantFieldsAppliesService {
PagedResult<MerchantFieldsVo> search(String name, int page, int size);
String apply(String uid, MerchantFieldApplyParam parameter);
void editIsCheck(String uid, String fieldId, int isCheck);
List<MerchantFieldCheckersVo> checkers(String cuid, String fieldId);
void checkerAdd(String cuid, String fieldId, String uid, String mobile, String name);
void checkerDel(String cuid, String fieldId, String uid);
}
......@@ -44,6 +44,16 @@ public class MerchantAuthorizationRecords implements Serializable {
*/
private String uid;
/**
* 手机号
*/
private String mobile;
/**
* 姓名
*/
private String name;
/**
* 授权人演出角色[creator|sponsor|fielder]
*/
......
......@@ -39,11 +39,23 @@ public class MerchantFieldCheckers implements Serializable {
*/
private String uid;
/**
* 手机号
*/
private String mobile;
/**
* 姓名
*/
private String name;
/**
* 授权人账号
*/
private String cuid;
private LocalDateTime deletedAt;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
......
......@@ -43,12 +43,15 @@ drop table if exists merchant_field_checkers;
create table merchant_field_checkers
(
mid bigint unsigned auto_increment primary key,
field_checker_id varchar(64) not null comment 'field_apply_id',
field_id varchar(64) default '' not null comment '要认领的或创建的场地ID',
uid varchar(64) default '' not null comment '验票员账号',
cuid varchar(64) default '' not null comment '授权人账号',
created_at timestamp null,
updated_at timestamp null
field_checker_id varchar(64) not null comment 'field_apply_id',
field_id varchar(64) default '' not null comment '要认领的或创建的场地ID',
uid varchar(64) default '' not null comment '验票员账号',
mobile varchar(255) default '' not null comment '手机号',
name varchar(255) default '' not null comment '姓名',
cuid varchar(64) default '' not null comment '授权人账号',
deleted_at timestamp null,
created_at timestamp null,
updated_at timestamp null
) engine=InnoDB default charset=utf8mb4 collate=utf8mb4_unicode_ci comment '场地默认验票员表';
create index cuid_index on merchant_field_checkers (cuid);
......@@ -192,6 +195,8 @@ create table merchant_authorization_records
performance_id varchar(64) not null comment '演出ID',
uid_role varchar(255) default '' not null comment '权利人演出角色[creator|sponsor|fielder|checker]',
uid varchar(64) not null comment '权利人',
mobile varchar(255) default '' not null comment '手机号',
name varchar(255) default '' not null comment '姓名',
cuid_role varchar(255) default '' not null comment '授权人演出角色[creator|sponsor|fielder]',
cuid varchar(64) not null comment '授权人',
start_time datetime null comment '授权开始时间',
......
......@@ -6,6 +6,7 @@ import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.merchant.dto.param.MerchantFieldApplyParam;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldCheckersVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldsVo;
import com.liquidnet.service.merchant.service.IMerchantFieldsAppliesService;
import io.swagger.annotations.Api;
......@@ -16,6 +17,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* <p>
......@@ -39,9 +41,9 @@ public class MerchantFieldsController {
@ApiOperationSupport(order = 10)
@ApiOperation(value = "场地搜索")
@GetMapping("search")
public ResponseDto<PagedResult<MerchantFieldsVo>> list(@RequestParam(required = true) String name,
@RequestParam(defaultValue = "1", required = false) int page,
@RequestParam(defaultValue = "10", required = false) int size) {
public ResponseDto<PagedResult<MerchantFieldsVo>> search(@RequestParam(required = true) String name,
@RequestParam(defaultValue = "1", required = false) int page,
@RequestParam(defaultValue = "10", required = false) int size) {
return ResponseDto.success(merchantFieldsAppliesService.search(name, page, size));
}
......@@ -57,11 +59,47 @@ public class MerchantFieldsController {
@ApiOperationSupport(order = 12)
@ApiOperation(value = "更改场地是否审核演出")
@PostMapping("editIsCheck")
public ResponseDto<Object> editIsCheck(@RequestParam(required = true) String fieldId, @RequestParam(required = true) int isCheck){
public ResponseDto<Object> editIsCheck(@RequestParam(required = true) String fieldId,
@RequestParam(required = true) int isCheck){
String currentUid = CurrentUtil.getCurrentUid();
merchantFieldsAppliesService.editIsCheck(currentUid, fieldId, isCheck);
return ResponseDto.success();
}
@ApiOperationSupport(order = 13)
@ApiOperation(value = "默认验票员列表")
@GetMapping("checkers")
public ResponseDto<List<MerchantFieldCheckersVo>> checkers(@RequestParam(required = true) String fieldId) {
String currentUid = CurrentUtil.getCurrentUid();
return ResponseDto.success(merchantFieldsAppliesService.checkers(currentUid, fieldId));
}
@ApiOperationSupport(order = 14)
@ApiOperation(value = "添加默认验票员")
@PostMapping("checker/add")
public ResponseDto<Object> checkerAdd(@RequestParam(required = true) String fieldId,
@RequestParam(required = true) String uid,
@RequestParam(required = true) String mobile,
@RequestParam(required = true) String name){
String currentUid = CurrentUtil.getCurrentUid();
merchantFieldsAppliesService.checkerAdd(currentUid, fieldId, uid, mobile, name);
return ResponseDto.success();
}
@ApiOperationSupport(order = 15)
@ApiOperation(value = "移除默认验票员")
@PostMapping("checker/del")
public ResponseDto<Object> checkerDel(@RequestParam(required = true) String fieldId,
@RequestParam(required = true) String uid){
String currentUid = CurrentUtil.getCurrentUid();
merchantFieldsAppliesService.checkerDel(currentUid, fieldId, uid);
return ResponseDto.success();
}
}
......@@ -3,11 +3,13 @@ package com.liquidnet.service.merchant.service;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.merchant.constant.MerchantRedisConst;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldAppliesVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldCheckersVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldsVo;
import com.liquidnet.service.merchant.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
......@@ -31,7 +33,7 @@ public class MerchantRdmService {
}
public List<MerchantFieldAppliesVo> getFieldsAppliesVosByUid(String uid) {
public List<MerchantFieldAppliesVo> getFieldAppliesVosByUid(String uid) {
String key = MerchantRedisConst.INFO_FIELD_APPLIES.concat(uid);
long s = System.currentTimeMillis();
List<MerchantFieldAppliesVo> vos = (List<MerchantFieldAppliesVo>) redisUtil.get(key);
......@@ -39,7 +41,7 @@ public class MerchantRdmService {
return vos;
}
public boolean addFieldsAppliesVoByUid(String uid, List<MerchantFieldAppliesVo> vos, MerchantFieldAppliesVo vo) {
public boolean addFieldAppliesVoByUid(String uid, List<MerchantFieldAppliesVo> vos, MerchantFieldAppliesVo vo) {
if (null == vos) {
vos = ObjectUtil.getMerchantFieldAppliesVoArrayList();
}
......@@ -48,4 +50,28 @@ public class MerchantRdmService {
}
public List<MerchantFieldCheckersVo> getFieldCheckersVosByFieldId(String fieldId) {
String key = MerchantRedisConst.INFO_FIELD_CHECKERS.concat(fieldId);
long s = System.currentTimeMillis();
List<MerchantFieldCheckersVo> vos = (List<MerchantFieldCheckersVo>) redisUtil.get(key);
log.debug("#RDM耗时:{}ms", System.currentTimeMillis() - s);
return vos;
}
public boolean addFieldCheckersVoByFieldId(String fieldId, List<MerchantFieldCheckersVo> vos, MerchantFieldCheckersVo vo) {
if (null == vos) {
vos = ObjectUtil.getMerchantFieldCheckersVoArrayList();
}
vos.add(vo);
return redisUtil.set(MerchantRedisConst.INFO_FIELD_CHECKERS.concat(fieldId), vos);
}
public boolean delFieldCheckersVoByFieldId(String fieldId, List<MerchantFieldCheckersVo> vos, MerchantFieldCheckersVo vo) {
if (CollectionUtils.isEmpty(vos)) {
return true;
}
vos.removeIf(r -> r.getFieldCheckerId().equals(vo.getFieldCheckerId()));
return redisUtil.set(MerchantRedisConst.INFO_FIELD_CHECKERS.concat(fieldId), vos);
}
}
......@@ -2,7 +2,6 @@ package com.liquidnet.service.merchant.service.impl;
import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.PagedResult;
......@@ -10,6 +9,7 @@ import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.merchant.dto.param.MerchantFieldApplyParam;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldAppliesVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldCheckersVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldsVo;
import com.liquidnet.service.merchant.service.IMerchantFieldsAppliesService;
import com.liquidnet.service.merchant.service.MerchantRdmService;
......@@ -32,6 +32,7 @@ import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.IntStream;
@Slf4j
@Service
......@@ -48,18 +49,22 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
@Override
public PagedResult<MerchantFieldsVo> search(String name, int page, int size) {
// 查询条件
Query query = new Query();
String regex = String.format("%s%s%s", "^.*", name, ".*$");
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
query.addCriteria(Criteria.where("name").regex(pattern));
query.addCriteria(Criteria.where("isOnline").is(1));
// 总数
long count = mongoTemplate.count(query, MerchantFieldsVo.class, MerchantFieldsVo.class.getSimpleName());
// 分页
PagedResult<MerchantFieldsVo> pagedResult = ObjectUtil.getMerchantFieldsVoPagedResult();
if (count > 0) {
query.fields().include("fieldId").include("isOnline").include("claimStatus").include("name");
// 查询分页
Pageable pageable = PageRequest.of(page - 1, size, Sort.by(Sort.Direction.DESC, "createdAt"));
query.with(pageable);
List<MerchantFieldsVo> fieldsVoList = mongoTemplate.find(query, MerchantFieldsVo.class, MerchantFieldsVo.class.getSimpleName());
......@@ -72,8 +77,6 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
@Override
public String apply(String uid, MerchantFieldApplyParam parameter) {
LocalDateTime now = LocalDateTime.now();
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> fieldUpdateObjs = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> fieldApplyInsertObjs = CollectionUtil.linkedListObjectArr();
......@@ -93,14 +96,15 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
}
// 申请场地 vos 上限
List<MerchantFieldAppliesVo> fieldsAppliesVos = merchantRdmService.getFieldsAppliesVosByUid(uid);
if (!CollectionUtils.isEmpty(fieldsAppliesVos)) {
if (fieldsAppliesVos.size() >= 10) {
List<MerchantFieldAppliesVo> fieldAppliesVos = merchantRdmService.getFieldAppliesVosByUid(uid);
if (!CollectionUtils.isEmpty(fieldAppliesVos)) {
if (fieldAppliesVos.size() >= 10) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13003");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
}
LocalDateTime now = LocalDateTime.now();
long s = System.currentTimeMillis();
if (null != fieldsVo) {
// 场地 vo 更改场地状态
......@@ -113,22 +117,22 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
}
// 申请场地 vo
MerchantFieldAppliesVo fieldsAppliesVo = MerchantFieldAppliesVo.getNew();
BeanUtils.copyProperties(parameter, fieldsAppliesVo);
fieldsAppliesVo.setFieldApplyId(IDGenerator.nextSnowId());
fieldsAppliesVo.setApplyStatus(0);
MerchantFieldAppliesVo fieldAppliesVo = MerchantFieldAppliesVo.getNew();
BeanUtils.copyProperties(parameter, fieldAppliesVo);
fieldAppliesVo.setFieldApplyId(IDGenerator.nextSnowId());
fieldAppliesVo.setApplyStatus(0);
if (null != fieldsVo) {
fieldsAppliesVo.setApplyType("claim");
fieldAppliesVo.setApplyType("claim");
} else {
fieldsAppliesVo.setApplyType("create");
fieldAppliesVo.setApplyType("create");
}
fieldsAppliesVo.setReject("");
fieldsAppliesVo.setUid(uid);
fieldsAppliesVo.setCreatedAt(now);
fieldAppliesVo.setReject("");
fieldAppliesVo.setUid(uid);
fieldAppliesVo.setCreatedAt(now);
// 申请场地 redis
s = System.currentTimeMillis();
merchantRdmService.addFieldsAppliesVoByUid(uid, fieldsAppliesVos, fieldsAppliesVo);
merchantRdmService.addFieldAppliesVoByUid(uid, fieldAppliesVos, fieldAppliesVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
if (null != fieldsVo) {
......@@ -141,11 +145,11 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
// 申请场地 sql
toMqSqls.add(SqlMapping.get("merchant_field_applies.insert"));
fieldApplyInsertObjs.add(new Object[]{
fieldsAppliesVo.getFieldApplyId(), fieldsAppliesVo.getApplyStatus(), fieldsAppliesVo.getApplyType(), fieldsAppliesVo.getReject(), fieldsAppliesVo.getUid(), fieldsAppliesVo.getFieldId(),
fieldsAppliesVo.getName(), fieldsAppliesVo.getLogo(), fieldsAppliesVo.getBackground(), fieldsAppliesVo.getDescription(), fieldsAppliesVo.getBuiltDate(),
fieldsAppliesVo.getProvinceId(), fieldsAppliesVo.getProvinceName(), fieldsAppliesVo.getCityId(), fieldsAppliesVo.getCityName(), fieldsAppliesVo.getDistrictId(), fieldsAppliesVo.getDistrictName(), fieldsAppliesVo.getAddress(), fieldsAppliesVo.getLongitude(), fieldsAppliesVo.getLatitude(),
fieldsAppliesVo.getContactName(), fieldsAppliesVo.getContactEmail(), fieldsAppliesVo.getCompanyName(), fieldsAppliesVo.getLicenseCode(), fieldsAppliesVo.getLicenseImg(),
fieldsAppliesVo.getLegalName(), fieldsAppliesVo.getLegalIdentity(), fieldsAppliesVo.getLegalIdentityObverse(), fieldsAppliesVo.getLegalIdentityReverse(), fieldsAppliesVo.getCreatedAt()
fieldAppliesVo.getFieldApplyId(), fieldAppliesVo.getApplyStatus(), fieldAppliesVo.getApplyType(), fieldAppliesVo.getReject(), fieldAppliesVo.getUid(), fieldAppliesVo.getFieldId(),
fieldAppliesVo.getName(), fieldAppliesVo.getLogo(), fieldAppliesVo.getBackground(), fieldAppliesVo.getDescription(), fieldAppliesVo.getBuiltDate(),
fieldAppliesVo.getProvinceId(), fieldAppliesVo.getProvinceName(), fieldAppliesVo.getCityId(), fieldAppliesVo.getCityName(), fieldAppliesVo.getDistrictId(), fieldAppliesVo.getDistrictName(), fieldAppliesVo.getAddress(), fieldAppliesVo.getLongitude(), fieldAppliesVo.getLatitude(),
fieldAppliesVo.getContactName(), fieldAppliesVo.getContactEmail(), fieldAppliesVo.getCompanyName(), fieldAppliesVo.getLicenseCode(), fieldAppliesVo.getLicenseImg(),
fieldAppliesVo.getLegalName(), fieldAppliesVo.getLegalIdentity(), fieldAppliesVo.getLegalIdentityObverse(), fieldAppliesVo.getLegalIdentityReverse(), fieldAppliesVo.getCreatedAt()
});
// mq
......@@ -163,21 +167,20 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
}
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
return fieldsAppliesVo.getFieldApplyId();
return fieldAppliesVo.getFieldApplyId();
}
@Override
public void editIsCheck(String uid, String fieldId, int isCheck) {
LocalDateTime now = LocalDateTime.now();
// 当前用户是否管理该场地
MerchantFieldsVo fieldsVo = merchantRdmService.getFieldsVoByFieldId(fieldId);
if (null == fieldsVo || !fieldsVo.getUid().equals(uid)) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13001");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
// 场地 vo 更改是否自动审核
LocalDateTime now = LocalDateTime.now();
fieldsVo.setIsCheck(isCheck > 0 ? 1 : 0);
fieldsVo.setUpdatedAt(now);
......@@ -207,4 +210,124 @@ public class MerchantFieldsAppliesServiceImpl implements IMerchantFieldsAppliesS
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
@Override
public List<MerchantFieldCheckersVo> checkers(String cuid, String fieldId) {
// 当前用户是否管理该场地
this.checkFieldAccount(cuid, fieldId);
List<MerchantFieldCheckersVo> fieldCheckersVos = merchantRdmService.getFieldCheckersVosByFieldId(fieldId);
return null;
}
@Override
public void checkerAdd(String cuid, String fieldId, String uid, String mobile, String name) {
// 当前用户是否管理该场地
this.checkFieldAccount(cuid, fieldId);
// 场地默认验票员,是否已经添加
List<MerchantFieldCheckersVo> fieldCheckersVos = merchantRdmService.getFieldCheckersVosByFieldId(fieldId);
if (!CollectionUtils.isEmpty(fieldCheckersVos)) {
for (MerchantFieldCheckersVo vo : fieldCheckersVos) {
if (vo.getUid().equals(uid)) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13011");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
}
}
// 场地默认验票员 vo
LocalDateTime now = LocalDateTime.now();
MerchantFieldCheckersVo fieldCheckersVo = MerchantFieldCheckersVo.getNew();
fieldCheckersVo.setFieldCheckerId(IDGenerator.nextSnowId());
fieldCheckersVo.setFieldId(fieldId);
fieldCheckersVo.setUid(uid);
fieldCheckersVo.setMobile(mobile);
fieldCheckersVo.setName(name);
fieldCheckersVo.setCuid(cuid);
fieldCheckersVo.setCreatedAt(now);
// 场地默认验票员 redis
long s = System.currentTimeMillis();
merchantRdmService.addFieldCheckersVoByFieldId(fieldId, fieldCheckersVos, fieldCheckersVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
// 场地默认验票员 sql
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> fieldCheckerInsertObjs = CollectionUtil.linkedListObjectArr();
toMqSqls.add(SqlMapping.get("merchant_field_checkers.insert"));
fieldCheckerInsertObjs.add(new Object[]{
fieldCheckersVo.getFieldCheckerId(), fieldCheckersVo.getFieldId(), fieldCheckersVo.getUid(), fieldCheckersVo.getMobile(), fieldCheckersVo.getName(), fieldCheckersVo.getCuid(), fieldCheckersVo.getCreatedAt()
});
// mq
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(
MQConst.MerchantQueue.SQL_MERCHANT_FIELD.getKey(),
SqlMapping.gets(toMqSqls, fieldCheckerInsertObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
@Override
public void checkerDel(String cuid, String fieldId, String uid) {
// 当前用户是否管理该场地
this.checkFieldAccount(cuid, fieldId);
// 查找场地默认验票员,是否已经添加
List<MerchantFieldCheckersVo> fieldCheckersVos = merchantRdmService.getFieldCheckersVosByFieldId(fieldId);
if (CollectionUtils.isEmpty(fieldCheckersVos)) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13012");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
int idx = IntStream.range(0, fieldCheckersVos.size())
.filter(i -> fieldCheckersVos.get(i).getUid().equals(uid))
.findFirst()
.orElse(-1);
if (idx < 0) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13012");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
// 场地默认验票员 vo
LocalDateTime now = LocalDateTime.now();
MerchantFieldCheckersVo fieldCheckersVo = fieldCheckersVos.get(idx);
fieldCheckersVo.setCuid(cuid);
fieldCheckersVo.setUpdatedAt(now);
fieldCheckersVo.setDeletedAt(now);
// 场地默认验票员 redis
long s = System.currentTimeMillis();
merchantRdmService.delFieldCheckersVoByFieldId(fieldId, fieldCheckersVos, fieldCheckersVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
// 场地默认验票员 sql
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> fieldCheckerUpdateObjs = CollectionUtil.linkedListObjectArr();
toMqSqls.add(SqlMapping.get("merchant_field_checkers.update"));
fieldCheckerUpdateObjs.add(new Object[]{
fieldCheckersVo.getCuid(), fieldCheckersVo.getUpdatedAt(), fieldCheckersVo.getDeletedAt(), fieldCheckersVo.getFieldCheckerId()
});
// mq
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(
MQConst.MerchantQueue.SQL_MERCHANT_FIELD.getKey(),
SqlMapping.gets(toMqSqls, fieldCheckerUpdateObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
private MerchantFieldsVo checkFieldAccount(String uid, String fieldId) {
// 当前用户是否管理该场地
MerchantFieldsVo fieldsVo = merchantRdmService.getFieldsVoByFieldId(fieldId);
if (null == fieldsVo || !fieldsVo.getUid().equals(uid)) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13001");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
return fieldsVo;
}
}
......@@ -2,6 +2,7 @@ package com.liquidnet.service.merchant.util;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldAppliesVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldCheckersVo;
import com.liquidnet.service.merchant.dto.vo.MerchantFieldsVo;
import com.mongodb.BasicDBObject;
......@@ -10,6 +11,7 @@ import java.util.ArrayList;
public class ObjectUtil {
private static final ArrayList<MerchantFieldAppliesVo> merchantFieldAppliesVoArrayList = new ArrayList<>();
private static final ArrayList<MerchantFieldCheckersVo> merchantFieldCheckersVoArrayList = new ArrayList<>();
private static final PagedResult<MerchantFieldsVo> merchantFieldsVoPagedResult = new PagedResult<>();
......@@ -20,6 +22,10 @@ public class ObjectUtil {
return (ArrayList<MerchantFieldAppliesVo>) merchantFieldAppliesVoArrayList.clone();
}
public static ArrayList<MerchantFieldCheckersVo> getMerchantFieldCheckersVoArrayList() {
return (ArrayList<MerchantFieldCheckersVo>) merchantFieldCheckersVoArrayList.clone();
}
public static PagedResult<MerchantFieldsVo> getMerchantFieldsVoPagedResult() {
return merchantFieldsVoPagedResult.clone();
}
......
......@@ -8,3 +8,5 @@
13002=场地已被认领
13003=场地申请已达到上限
13011=验票员已存在
13012=验票员不存在
......@@ -4,3 +4,7 @@ merchant_fields.update_is_check=UPDATE merchant_fields SET is_check = ?, updated
# ---------------------------------------------------------------------------------------------------------------------
merchant_field_applies.insert=INSERT INTO merchant_field_applies (field_apply_id, apply_status, apply_type, reject, uid, field_id, name, logo, background, description, built_date, province_id, province_name, city_id, city_name, district_id, district_name, address, longitude, latitude, contact_name, contact_email, company_name, license_code, license_img, legal_name, legal_identity, legal_identity_obverse, legal_identity_reverse, created_at) VALUE (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
# ---------------------------------------------------------------------------------------------------------------------
merchant_field_checkers.insert=INSERT INTO merchant_field_checkers (field_checker_id, field_id, uid, mobile, name, cuid, created_at) VALUE (?, ?, ?, ?, ?, ?, ?)
merchant_field_checkers.update=UPDATE merchant_field_checkers SET cuid = ?, updated_at = ?, delete_at = ? WHERE field_checker_id = ?
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment