feat:商城收获地址

This commit is contained in:
dzc committed 2026-06-08 12:40:34 +08:00
1 parent e7abf24692
commit 462a83af39
10 files changed
+515 -33

No files matched your search

+26
View File
@@ -596,6 +596,32 @@ CREATE TABLE hard_spu_category
PRIMARY KEY (id)
) ENGINE = InnoDB COMMENT ='硬件商品分类';
-- ----------------------------
-- Table structure for hard_user_map_address
-- ----------------------------
DROP TABLE IF EXISTS hard_user_map_address;
CREATE TABLE hard_user_map_address
(
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
user_id bigint DEFAULT NULL COMMENT '用户id',
input_address varchar(128) DEFAULT NULL COMMENT '详细地址,',
province varchar(128) NOT NULL COMMENT '省',
city varchar(128) NOT NULL COMMENT '市',
district varchar(128) NOT NULL COMMENT '区',
street varchar(128) NOT NULL COMMENT '街道',
adress_detail varchar(128) NOT NULL COMMENT '详细地址',
full_address varchar(128) DEFAULT NULL COMMENT '完整地址,拼接',
longitude decimal(16, 16) DEFAULT NULL COMMENT '经度',
latitude decimal(16, 16) DEFAULT NULL COMMENT '纬度',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB COMMENT ='用户地址(经纬度地址用户地图选择)';
-- ----------------------------
-- Table structure for hard_spu_repertory
-- ----------------------------
@@ -0,0 +1,9 @@
package com.bsd.pjcloud.hard.api.dto.address;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import lombok.Data;
@Data
public class HardUserMapAddressDto extends HardUserMapAddressEntity {
}
@@ -0,0 +1,131 @@
package com.bsd.pjcloud.hard.api.entity.address;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 用户地址(经纬度地址用户地图选择)
*/
@Data
@TenantTable
@TableName("hard_user_map_address")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "用户地址(经纬度地址用户地图选择)")
public class HardUserMapAddressEntity extends Model<HardUserMapAddressEntity> {
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "编号")
private Long id;
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 详细地址,
*/
@Schema(description = "详细地址,")
private String inputAddress;
/**
* 省
*/
@Schema(description = "省")
private String province;
/**
* 市
*/
@Schema(description = "市")
private String city;
/**
* 区
*/
@Schema(description = "区")
private String district;
/**
* 街道
*/
@Schema(description = "街道")
private String street;
/**
* 详细地址
*/
@Schema(description = "详细地址")
private String adressDetail;
/**
* 完整地址,拼接
*/
@Schema(description = "完整地址,拼接")
private String fullAddress;
/**
* 经度
*/
@Schema(description = "经度")
private BigDecimal longitude;
/**
* 纬度
*/
@Schema(description = "纬度")
private BigDecimal latitude;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -0,0 +1,9 @@
package com.bsd.pjcloud.hard.api.vo.address;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import lombok.Data;
@Data
public class HardUserMapAddressVo extends HardUserMapAddressEntity {
}
@@ -0,0 +1,137 @@
package com.bsd.pjcloud.hard.controller.address;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.hard.api.dto.address.HardUserMapAddressDto;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import com.bsd.pjcloud.hard.api.vo.address.HardUserMapAddressVo;
import com.bsd.pjcloud.hard.service.HardUserMapAddressService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 用户地址(经纬度地址用户地图选择)
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/hard-user-map-address")
@Tag(description = "hard-user-map-address", name = "用户地址(经纬度地址用户地图选择)管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardUserMapAddressController {
private final HardUserMapAddressService hardUserMapAddressService;
/* ************************************* start app start ************************************* */
@Operation(summary = "app分页查询", description = "app分页查询")
@GetMapping("/app/page")
public R<Page<HardUserMapAddressVo>> appPageList(@ParameterObject Page page, @ParameterObject HardUserMapAddressDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(hardUserMapAddressService.scopePageList(page, dto, null));
}
@Operation(summary = "app新增地址", description = "app新增地址")
@PostMapping("/app/create")
public R<Long> appCreate(@ParameterObject HardUserMapAddressDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(hardUserMapAddressService.create(dto));
}
@Operation(summary = "app修改地址", description = "app修改地址")
@PostMapping("/app/edit")
public R<Long> appEdit(@ParameterObject HardUserMapAddressDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(hardUserMapAddressService.edit(dto));
}
@Operation(summary = "app删除地址", description = "app删除地址")
@DeleteMapping("/app/del")
public R<Long> appDel(@RequestBody Long id) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardUserMapAddressService.del(id, user.getId()));
}
/* ************************************* start app start ************************************* */
/**
* 分页查询
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('hard_hardUserMapAddress_view')")
public R<Page<HardUserMapAddressVo>> getHardUserMapAddressPage(@ParameterObject Page page, @ParameterObject HardUserMapAddressDto dto) {
return R.ok(hardUserMapAddressService.scopePageList(page, dto, null));
}
/**
* 通过id查询用户地址(经纬度地址用户地图选择)
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('hard_hardUserMapAddress_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(hardUserMapAddressService.getById(id));
}
/**
* 新增用户地址(经纬度地址用户地图选择)
*/
@Operation(summary = "新增用户地址(经纬度地址用户地图选择)", description = "新增用户地址(经纬度地址用户地图选择)")
@SysLog("新增用户地址(经纬度地址用户地图选择)")
@PostMapping
@PreAuthorize("@pms.hasPermission('hard_hardUserMapAddress_add')")
public R save(@RequestBody HardUserMapAddressEntity dto) {
return R.ok(hardUserMapAddressService.save(dto));
}
/**
* 修改用户地址(经纬度地址用户地图选择)
*/
@Operation(summary = "修改用户地址(经纬度地址用户地图选择)", description = "修改用户地址(经纬度地址用户地图选择)")
@SysLog("修改用户地址(经纬度地址用户地图选择)")
@PutMapping
@PreAuthorize("@pms.hasPermission('hard_hardUserMapAddress_edit')")
public R updateById(@RequestBody HardUserMapAddressEntity dto) {
return R.ok(hardUserMapAddressService.updateById(dto));
}
/**
* 通过id删除用户地址(经纬度地址用户地图选择)
*/
@Operation(summary = "通过id删除用户地址(经纬度地址用户地图选择)", description = "通过id删除用户地址(经纬度地址用户地图选择)")
@SysLog("通过id删除用户地址(经纬度地址用户地图选择)")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('hard_hardUserMapAddress_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(hardUserMapAddressService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('hard_hardUserMapAddress_export')")
public List<HardUserMapAddressEntity> export(HardUserMapAddressEntity hardUserMapAddress, Long[] ids) {
return hardUserMapAddressService.list(Wrappers.lambdaQuery(hardUserMapAddress).in(ArrayUtil.isNotEmpty(ids), HardUserMapAddressEntity::getId, ids));
}
}
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.hard.mapper.address;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.dto.address.HardUserMapAddressDto;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import com.bsd.pjcloud.hard.api.vo.address.HardUserMapAddressVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface HardUserMapAddressMapper extends PjcloudBaseMapper<HardUserMapAddressEntity> {
Page<HardUserMapAddressVo> scopePageList(Page page, @Param("dto") HardUserMapAddressDto dto, DataScope dataScope);
}
@@ -0,0 +1,19 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.address.HardUserMapAddressDto;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import com.bsd.pjcloud.hard.api.vo.address.HardUserMapAddressVo;
public interface HardUserMapAddressService extends IService<HardUserMapAddressEntity> {
Page<HardUserMapAddressVo> scopePageList(Page page, HardUserMapAddressDto dto, DataScope dataScope);
Long create(HardUserMapAddressDto dto);
Long edit(HardUserMapAddressDto dto);
Long del(Long id, Long userId);
}
@@ -0,0 +1,77 @@
package com.bsd.pjcloud.hard.service.impl.address;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.address.HardUserMapAddressDto;
import com.bsd.pjcloud.hard.api.entity.address.HardUserMapAddressEntity;
import com.bsd.pjcloud.hard.api.vo.address.HardUserMapAddressVo;
import com.bsd.pjcloud.hard.mapper.address.HardUserMapAddressMapper;
import com.bsd.pjcloud.hard.service.HardUserMapAddressService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* 用户地址(经纬度地址用户地图选择)
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardUserMapAddressServiceImpl extends ServiceImpl<HardUserMapAddressMapper, HardUserMapAddressEntity> implements HardUserMapAddressService {
private final RemoteUserService remoteUserService;
@Override
public Page<HardUserMapAddressVo> scopePageList(Page page, HardUserMapAddressDto dto, DataScope dataScope) {
return baseMapper.scopePageList(page, dto, dataScope);
}
@Override
public Long create(HardUserMapAddressDto dto) {
if (ObjectUtil.isEmpty(dto.getUserId())) {
throw new RuntimeException("用户ID不能为空");
}
UserInfo user = remoteUserService.getInnerByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(user)) {
throw new RuntimeException("用户不存在");
}
HardUserMapAddressEntity entity = BeanUtils.toBean(dto, HardUserMapAddressEntity.class);
baseMapper.insert(entity);
return entity.getId();
}
@Override
public Long edit(HardUserMapAddressDto dto) {
if (ObjectUtil.isEmpty(dto.getUserId())) {
throw new RuntimeException("用户ID不能为空");
}
UserInfo user = remoteUserService.getInnerByUserId(dto.getUserId()).getData();
if (ObjectUtil.isEmpty(user)) {
throw new RuntimeException("用户不存在");
}
HardUserMapAddressEntity entity = BeanUtils.toBean(dto, HardUserMapAddressEntity.class);
baseMapper.updateById(entity);
return entity.getId();
}
@Override
public Long del(Long id, Long userId) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<HardUserMapAddressEntity>()
.eq(HardUserMapAddressEntity::getUserId, userId)
.eq(HardUserMapAddressEntity::getId, id)
);
if (count <= 0) {
throw new RuntimeException("地址记录不存在,无法删除");
}
baseMapper.deleteById(id);
return id;
}
}
@@ -185,41 +185,48 @@ public class HardXfjServiceImpl implements HardXfjService {
}
// 刷卡扣费
if (ObjectUtil.equals(dto.getMode(), 0)) {
WalletManageEntity wallet = walletService.getWalletByCardNumber(dto.getCardNo()).getData();
if (ObjectUtil.isEmpty(wallet)) {
throw new RuntimeException("非本单位饭卡");
}
// 查询用户
String username = "未知用户";
UserInfo user = remoteUserService.getInnerByUserId(wallet.getUserId()).getData();
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getSysUser().getName())) {
username = user.getSysUser().getName();
}
// 解析金额
int price = BigDecimal.valueOf(Double.valueOf(dto.getAmount())).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).intValue();
// 取餐
if (ObjectUtil.equals(dto.getPayType(), 3)) {
HardXfjFastCreateOrderDto payDto = new HardXfjFastCreateOrderDto();
payDto.setUserId(user.getSysUser().getUserId());
payDto.setHardId(entity.getId());
payDto.setPrice(price);
payDto.setOrderNo(dto.getOrder());
payDto.setWalletType(WalletTypeEnum.EAT);
payDto.setXfjPayType(HardXfjTypeEnum.CARD_PAY);
Long orderId = hardOrderService.xfjFastCreateOrder(payDto);
return null;
} else {
WalletManageEntity wallet = walletService.getWalletByCardNumber(dto.getCardNo()).getData();
if (ObjectUtil.isEmpty(wallet)) {
throw new RuntimeException("非本单位饭卡");
}
// 查询用户
String username = "未知用户";
UserInfo user = remoteUserService.getInnerByUserId(wallet.getUserId()).getData();
if (ObjectUtil.isNotEmpty(user) && ObjectUtil.isNotEmpty(user.getSysUser().getName())) {
username = user.getSysUser().getName();
}
// 解析金额
int price = BigDecimal.valueOf(Double.valueOf(dto.getAmount())).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).intValue();
HardXfjFastCreateOrderDto payDto = new HardXfjFastCreateOrderDto();
payDto.setUserId(user.getSysUser().getUserId());
payDto.setHardId(entity.getId());
payDto.setPrice(price);
payDto.setOrderNo(dto.getOrder());
payDto.setWalletType(WalletTypeEnum.EAT);
payDto.setXfjPayType(HardXfjTypeEnum.CARD_PAY);
Long orderId = hardOrderService.xfjFastCreateOrder(payDto);
result.setName(username);
result.setCardNo(wallet.getCardNumber());
result.setMoney(fenToYuan(BigDecimal.valueOf(wallet.getBalance())));
result.setSubsidy("0");
result.setTimes("0");
result.setIntegral("0");
result.setInTime("");
result.setOutTime("");
result.setCumulativeTime("");
result.setAmount(dto.getAmount());
result.setVoiceID("");
result.setText("购买成功\r\n总消费" + dto.getAmount() + "元");
return result;
}
result.setName(username);
result.setCardNo(wallet.getCardNumber());
result.setMoney(fenToYuan(BigDecimal.valueOf(wallet.getBalance())));
result.setSubsidy("0");
result.setTimes("0");
result.setIntegral("0");
result.setInTime("");
result.setOutTime("");
result.setCumulativeTime("");
result.setAmount(dto.getAmount());
result.setVoiceID("");
result.setText("购买成功\r\n总消费" + dto.getAmount() + "元");
return result;
}
// 现金充值
else if (ObjectUtil.equals(dto.getMode(), 1)) {
@@ -0,0 +1,50 @@
<?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.bsd.pjcloud.hard.mapper.address.HardUserMapAddressMapper">
<sql id="selectA">
select a.id,
a.user_id,
a.input_address,
a.province,
a.city,
a.district,
a.street,
a.adress_detail,
a.full_address,
a.longitude,
a.latitude,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.userId != null">
and a.user_id = #{dto.userId}
</if>
<if test="dto.inputAddress != null and dto.inputAddress != '' ">
and a.input_address LIKE concat('%',#{dto.inputAddress},'%')
</if>
<if test="dto.fullAddress != null and dto.fullAddress != '' ">
and a.full_address LIKE concat('%',#{dto.fullAddress},'%')
</if>
<if test="dto.adressDetail != null and dto.adressDetail != '' ">
and a.adress_detail LIKE concat('%',#{dto.adressDetail},'%')
</if>
</sql>
<select id="scopePageList" resultType="com.bsd.pjcloud.hard.api.vo.address.HardUserMapAddressVo">
<include refid="selectA"/>
from hard_user_map_address a
<where>
<include refid="whereA"/>
</where>
</select>
</mapper>