feat:
1. add merchant update address
This commit is contained in:
20
doc/sql/address_log.sql
Normal file
20
doc/sql/address_log.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
DROP TABLE IF EXISTS `ar_merchant_address_log`;
|
||||
CREATE TABLE `ar_merchant_address_log`
|
||||
(
|
||||
`id` bigint(20) NOT NULL COMMENT '主键',
|
||||
`user_id` bigint(20) not null default 0 comment '用户id',
|
||||
`old_value` text not null comment '旧值',
|
||||
`new_value` text not null comment '新值',
|
||||
`create_user` bigint(0) NULL DEFAULT NULL COMMENT '创建人',
|
||||
`create_dept` bigint(0) NULL DEFAULT NULL COMMENT '创建部门',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_user` bigint(0) NULL DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
|
||||
`status` int(0) NULL DEFAULT NULL COMMENT '状态',
|
||||
`is_deleted` int(0) NULL DEFAULT NULL COMMENT '是否已删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_user_id` (`user_id`) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT = 'AR商户地址变更日志'
|
||||
ROW_FORMAT = Dynamic;
|
||||
@@ -104,6 +104,16 @@ public class ArMerchantController {
|
||||
return Result.status(merchantManager.cancelApplyMerchant(request.setUserId(userId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* AR商家变更地址
|
||||
*
|
||||
*/
|
||||
@SecurityParameter
|
||||
@PostMapping("/update-address")
|
||||
public Result<Boolean> updateAddress(@RequestBody ARUpdateAddressRequest request) {
|
||||
return Result.status(merchantManager.updateAddress(request.setUserId(StpUtil.getLoginIdAsLong())));
|
||||
}
|
||||
|
||||
/**
|
||||
* AR商家申请记录分页
|
||||
*
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.fly.boot.biz.ar.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fly.boot.common.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* AR商家信息表(ArMerchant)实体类
|
||||
*
|
||||
* @author jack
|
||||
* @since 2025-09-06 16:45:40
|
||||
*/
|
||||
@Data
|
||||
@TableName("ar_merchant_address_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ArMerchantAddressLog extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 旧地址
|
||||
*/
|
||||
private String oldValue;
|
||||
/**
|
||||
* 新地址
|
||||
*/
|
||||
private String newValue;
|
||||
|
||||
}
|
||||
@@ -48,6 +48,7 @@ public class ARMerchantManager {
|
||||
private final ArUserRedPackService arUserRedPackService;
|
||||
private final ArPromotionService arPromotionService;
|
||||
private final ArStoreVerificationLogService arStoreVerificationLogService;
|
||||
private final ArMerchantAddressLogService arMerchantAddressLogService;
|
||||
|
||||
private final ApplicationEventPublisher publisher;
|
||||
|
||||
@@ -432,6 +433,46 @@ public class ARMerchantManager {
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = RuntimeException.class)
|
||||
public Boolean updateAddress(ARUpdateAddressRequest request) {
|
||||
ArMerchantInfo merchantInfo = arMerchantInfoService.getOne(
|
||||
Wrappers.lambdaQuery(ArMerchantInfo.class)
|
||||
.eq(ArMerchantInfo::getUserId, request.getUserId())
|
||||
.orderByDesc(ArMerchantInfo::getId)
|
||||
.last("limit 1")
|
||||
);
|
||||
|
||||
Assert.notNull(merchantInfo, "未授权商家");
|
||||
|
||||
String oldValue = merchantInfo.getAddress();
|
||||
|
||||
RegionInfo regionInfo = regionInfoService.getById(request.getRegionId());
|
||||
Assert.notNull(regionInfo, "无效地址");
|
||||
|
||||
String newValue = regionInfo.getFullName() + request.getAddress();
|
||||
|
||||
LocationDTO locationDTO = mapService.defaultLocation(newValue);
|
||||
merchantInfo.setRegionId(request.getRegionId());
|
||||
merchantInfo.setAddress(newValue);
|
||||
merchantInfo.setLat(BigDecimal.valueOf(locationDTO.getLatitude()));
|
||||
merchantInfo.setLng(BigDecimal.valueOf(locationDTO.getLongitude()));
|
||||
|
||||
boolean update = arMerchantInfoService.update(Wrappers.<ArMerchantInfo>lambdaUpdate()
|
||||
.eq(ArMerchantInfo::getId, merchantInfo.getId())
|
||||
.set(ArMerchantInfo::getRegionId, request.getRegionId())
|
||||
.set(ArMerchantInfo::getAddress, newValue)
|
||||
.set(ArMerchantInfo::getLat, BigDecimal.valueOf(locationDTO.getLatitude()))
|
||||
.set(ArMerchantInfo::getLng, BigDecimal.valueOf(locationDTO.getLongitude()))
|
||||
);
|
||||
|
||||
ArMerchantAddressLog log = new ArMerchantAddressLog();
|
||||
log.setUserId(request.getUserId());
|
||||
log.setOldValue(oldValue);
|
||||
log.setNewValue(newValue);
|
||||
|
||||
boolean save = arMerchantAddressLogService.save(log);
|
||||
Assert.isTrue(update && save, "更新操作失败");
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.fly.boot.biz.ar.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fly.boot.biz.ar.entity.ArMerchantAddressLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ArMerchantAddressLogMapper extends BaseMapper<ArMerchantAddressLog> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fly.boot.biz.ar.mapper.ArMerchantAddressLogMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.fly.boot.biz.ar.request;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ARUpdateAddressRequest implements Serializable {
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 地址id
|
||||
*/
|
||||
@NotNull(message = "地址不能为空")
|
||||
private Integer regionId;
|
||||
|
||||
/**
|
||||
* 地址详情
|
||||
*/
|
||||
@NotNull(message = "地址详情不能为空")
|
||||
private String address;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.fly.boot.biz.ar.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fly.boot.biz.ar.entity.ArMerchantAddressLog;
|
||||
|
||||
public interface ArMerchantAddressLogService extends IService<ArMerchantAddressLog> {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.fly.boot.biz.ar.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fly.boot.biz.ar.entity.ArMerchantAddressLog;
|
||||
import com.fly.boot.biz.ar.entity.ArUserScanLog;
|
||||
import com.fly.boot.biz.ar.mapper.ArMerchantAddressLogMapper;
|
||||
import com.fly.boot.biz.ar.mapper.ArUserScanLogMapper;
|
||||
import com.fly.boot.biz.ar.service.ArMerchantAddressLogService;
|
||||
import com.fly.boot.biz.ar.service.ArUserScanLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ArMerchantAddressLogServiceImpl extends ServiceImpl<ArMerchantAddressLogMapper, ArMerchantAddressLog> implements ArMerchantAddressLogService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user