From d3f6e98decebe1e574a05cfc4973e4d650c2c3d0 Mon Sep 17 00:00:00 2001
From: "925116093-qq.com" <925116093@qq.com>
Date: Tue, 10 Jun 2025 11:56:57 +0800
Subject: [PATCH] 202506101156
---
.../system/controller/AppletController.java | 959 ++++++++++++++----
.../domain/AppleDoMain/AddressApple.java | 187 ++++
.../system/domain/AppleDoMain/OrderApple.java | 146 +++
.../com/ruoyi/system/mapper/OrderMapper.java | 12 +
.../ruoyi/system/service/IOrderService.java | 10 +-
.../system/service/impl/OrderServiceImpl.java | 12 +-
.../resources/mapper/system/OrderMapper.xml | 747 ++++++++++----
.../mapper/system/UserAddressMapper.xml | 2 +-
8 files changed, 1673 insertions(+), 402 deletions(-)
create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/AppleDoMain/AddressApple.java
create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/AppleDoMain/OrderApple.java
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java
index 0eb40ff..e60aca2 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/AppletController.java
@@ -4,8 +4,11 @@ import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.ControllerUtil.WechatApiUtil;
import com.ruoyi.system.domain.*;
+import com.ruoyi.system.domain.AppleDoMain.OrderApple;
+import com.ruoyi.system.domain.AppleDoMain.AddressApple;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
+
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
@@ -23,14 +27,16 @@ import org.springframework.web.bind.annotation.RequestBody;
import com.ruoyi.system.ControllerUtil.AppletControllerUtil;
import com.ruoyi.system.ControllerUtil.AppletLoginUtil;
import com.ruoyi.system.ControllerUtil.PageUtil;
+
import static com.ruoyi.common.core.domain.AjaxResult.error;
import static com.ruoyi.common.core.domain.AjaxResult.success;
import static com.ruoyi.common.utils.PageUtils.startPage;
+
import com.github.pagehelper.PageHelper;
/**
* 小程序控制器
- *
+ *
* 提供小程序端所需的API接口
* 主要功能:
* 1. 服务分类管理
@@ -40,8 +46,8 @@ import com.github.pagehelper.PageHelper;
* 5. 用户信息验证
*
* @author Mr. Zhang Pan
- * @date 2025-05-26
* @version 1.0
+ * @date 2025-05-26
*/
@RestController
public class AppletController extends BaseController {
@@ -58,12 +64,15 @@ public class AppletController extends BaseController {
private IServiceGoodsService serviceGoodsService;
@Autowired
private IUserAddressService userAddressService;
+ @Autowired
+ private IOrderService orderService;
+
/**
* 获取服务分类列表
- *
+ *
* @param request HTTP请求对象
* @return 分类列表数据
- *
+ *
* 接口说明:
* - 获取状态为启用的服务分类
* - 自动添加图片CDN前缀
@@ -74,20 +83,20 @@ public class AppletController extends BaseController {
try {
// 验证用户登录状态(可选)
Map userData = AppletControllerUtil.getUserData(request.getHeader("token"), usersService);
-
+
// 构建查询条件:状态启用且类型为服务
ServiceCate serviceCateQuery = new ServiceCate();
serviceCateQuery.setStatus(1L); // 启用状态
serviceCateQuery.setType(1L); // 服务类型
-
+
// 查询分类列表
List categoryList = serviceCateService.selectServiceCateList(serviceCateQuery);
-
+
// 为每个分类添加CDN前缀
for (ServiceCate category : categoryList) {
category.setIcon(AppletControllerUtil.buildImageUrl(category.getIcon()));
}
-
+
return success(categoryList);
} catch (Exception e) {
return error("获取服务分类列表失败:" + e.getMessage());
@@ -96,11 +105,11 @@ public class AppletController extends BaseController {
/**
* 获取系统配置信息
- *
- * @param name 配置项名称
+ *
+ * @param name 配置项名称
* @param request HTTP请求对象
* @return 配置信息数据
- *
+ *
* 接口说明:
* - 根据配置名称获取对应的配置值
* - 配置值以JSON格式返回
@@ -113,14 +122,14 @@ public class AppletController extends BaseController {
if (name == null || name.trim().isEmpty()) {
return error("配置名称不能为空");
}
-
+
// 构建查询条件
SiteConfig configQuery = new SiteConfig();
configQuery.setName(name.trim());
-
+
// 查询配置列表
List configList = siteConfigService.selectSiteConfigList(configQuery);
-
+
if (!configList.isEmpty()) {
// 解析配置值为JSON对象
String configValue = configList.get(0).getValue();
@@ -139,46 +148,50 @@ public class AppletController extends BaseController {
}
-
-
@GetMapping(value = "/api/public/get/config")
- public AjaxResult getconfig(HttpServletRequest request) {
+ public Map getconfig(HttpServletRequest request) {
+ Map map=new HashMap<>();
SiteConfig configQuery = new SiteConfig();
configQuery.setName("config_one");
List list = siteConfigService.selectSiteConfigList(configQuery);
- return success(list.get(0).getValue());
+ JSONObject jsonObject = JSONObject.parseObject(list.get(0).getValue());
+// map.put("data",list.get(0).getValue());
+// map.put("code",200);
+// map.put("msg","成功");
+
+
+ return success(jsonObject);
+
}
-
-
/**
* 查询用户收货地址列表
- *
- * @param limit 每页显示数量
- * @param page 页码
+ *
+ * @param limit 每页显示数量
+ * @param page 页码
* @param request HTTP请求对象
* @return 分页地址列表
- *
+ *
* 请求参数:
* - limit: 每页显示数量,默认15
* - page: 页码,默认1
- *
+ *
* 返回格式:
* {
- * "code": 200,
- * "msg": "OK",
- * "data": {
- * "current_page": 1,
- * "data": [...],
- * "from": 1,
- * "last_page": 1,
- * "next_page_url": null,
- * "per_page": "15",
- * "prev_page_url": null,
- * "to": 1,
- * "total": 1
- * }
+ * "code": 200,
+ * "msg": "OK",
+ * "data": {
+ * "current_page": 1,
+ * "data": [...],
+ * "from": 1,
+ * "last_page": 1,
+ * "next_page_url": null,
+ * "per_page": "15",
+ * "prev_page_url": null,
+ * "to": 1,
+ * "total": 1
+ * }
* }
*/
@GetMapping("/api/user/address/list")
@@ -192,53 +205,591 @@ public class AppletController extends BaseController {
if (!(Boolean) pageValidation.get("valid")) {
return error((String) pageValidation.get("message"));
}
-
+
// 2. 验证用户登录状态
String token = request.getHeader("token");
Map userValidation = AppletLoginUtil.validateUserToken(token, usersService);
if (!(Boolean) userValidation.get("valid")) {
return error("用户未登录或token无效");
}
-
+
// 3. 获取用户信息
Users user = (Users) userValidation.get("user");
if (user == null) {
return error("用户信息获取失败");
}
-
+
// 4. 设置分页参数
PageHelper.startPage(page, limit);
-
+
// 5. 查询用户地址列表
UserAddress userAddressQuery = new UserAddress();
userAddressQuery.setUid(user.getId());
List addressList = userAddressService.selectUserAddressList(userAddressQuery);
-
+
// 6. 获取分页信息并构建响应
TableDataInfo tableDataInfo = getDataTable(addressList);
-
+
// 7. 构建符合要求的分页响应格式
Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit);
-
+
return success(pageData);
-
+
} catch (Exception e) {
System.err.println("查询用户地址列表异常:" + e.getMessage());
return error("查询地址列表失败:" + e.getMessage());
}
}
-
+ /**
+ * 根据地址ID查询用户收货地址详情
+ *
+ * @param id 地址ID
+ * @param request HTTP请求对象
+ * @return 地址详细信息
+ *
+ * 接口说明:
+ * - 根据地址ID获取单个地址的详细信息
+ * - 验证用户登录状态和地址归属权
+ * - 返回AddressApple格式的地址数据,用于前端修改页面
+ *
+ * 返回格式:
+ * {
+ * "code": 200,
+ * "msg": "操作成功",
+ * "data": {
+ * "id": 160,
+ * "uid": 302,
+ * "name": "赵先生",
+ * "phone": "18709185987",
+ * "latitude": "34.15643",
+ * "longitude": "108.86683",
+ * "address_name": "陕西省西安市长安区榆林北段与建设大道交叉口处北侧",
+ * "address_info": "陕西省西安市长安区榆林北段与建设大道交叉口处",
+ * "info": "14号楼2302",
+ * "is_default": 0,
+ * "created_at": null,
+ * "updated_at": null
+ * }
+ * }
+ */
+ @GetMapping("/api/user/address/info/{id}")
+ public AjaxResult getAddressInfo(@PathVariable("id") Long id, HttpServletRequest request) {
+ try {
+ // 1. 参数验证
+ if (id == null || id <= 0) {
+ return error("地址ID无效");
+ }
+
+ // 2. 验证用户登录状态
+ String token = request.getHeader("token");
+ Map userValidation = AppletLoginUtil.validateUserToken(token, usersService);
+ if (!(Boolean) userValidation.get("valid")) {
+ return error("用户未登录或token无效");
+ }
+
+ // 3. 获取用户信息
+ Users user = (Users) userValidation.get("user");
+ if (user == null) {
+ return error("用户信息获取失败");
+ }
+
+ // 4. 查询地址信息
+ UserAddress userAddress = userAddressService.selectUserAddressById(id);
+ if (userAddress == null) {
+ return error("地址不存在");
+ }
+
+ // 5. 验证地址归属权
+ if (!userAddress.getUid().equals(user.getId())) {
+ return error("无权访问该地址信息");
+ }
+
+ // 6. 转换为AddressApple格式并返回
+ AddressApple addressApple = AddressApple.fromUserAddress(userAddress);
+
+ return success(addressApple);
+
+ } catch (Exception e) {
+ System.err.println("查询用户地址详情异常:" + e.getMessage());
+ return error("查询地址详情失败:" + e.getMessage());
+ }
+ }
+
+ /**
+ * 修改用户收货地址
+ *
+ * @param params 地址修改参数
+ * @param request HTTP请求对象
+ * @return 修改结果
+ *
+ * 请求参数格式:
+ * {
+ * "id": 160,
+ * "name": "赵先生",
+ * "phone": "18709185987",
+ * "address_name": "陕西省西安市长安区榆林北段与建设大道交叉口处北侧",
+ * "address_info": "海菱路8号",
+ * "info": "14号楼2302",
+ * "is_default": 1,
+ * "latitude": "34.15643",
+ * "longitude": "108.86683"
+ * }
+ *
+ * 接口说明:
+ * - 验证用户登录状态和地址归属权
+ * - 支持修改地址的所有字段
+ * - 自动处理默认地址逻辑(设为默认时会取消其他默认地址)
+ * - 返回修改后的地址信息
+ *
+ * 返回格式:
+ * {
+ * "code": 200,
+ * "msg": "操作成功",
+ * "data": "地址修改成功"
+ * }
+ */
+ @PostMapping("/api/user/address/edit")
+ public AjaxResult editAddress(@RequestBody Map params, HttpServletRequest request) {
+ try {
+ // 1. 参数验证
+ if (params == null || params.get("id") == null) {
+ return error("地址ID不能为空");
+ }
+
+ Long addressId;
+ try {
+ addressId = Long.valueOf(params.get("id").toString());
+ if (addressId <= 0) {
+ return error("地址ID无效");
+ }
+ } catch (NumberFormatException e) {
+ return error("地址ID格式错误");
+ }
+
+ // 2. 验证用户登录状态
+ String token = request.getHeader("token");
+ Map userValidation = AppletLoginUtil.validateUserToken(token, usersService);
+ if (!(Boolean) userValidation.get("valid")) {
+ return error("用户未登录或token无效");
+ }
+
+ // 3. 获取用户信息
+ Users user = (Users) userValidation.get("user");
+ if (user == null) {
+ return error("用户信息获取失败");
+ }
+
+ // 4. 查询原地址信息并验证归属权
+ UserAddress existingAddress = userAddressService.selectUserAddressById(addressId);
+ if (existingAddress == null) {
+ return error("地址不存在");
+ }
+
+ if (!existingAddress.getUid().equals(user.getId())) {
+ return error("无权修改该地址");
+ }
+
+ // 5. 构建更新的地址对象
+ UserAddress updateAddress = buildUpdateAddress(params, addressId, user.getId());
+
+ // 6. 验证必填字段
+ String validationResult = validateAddressParams(updateAddress);
+ if (validationResult != null) {
+ return error(validationResult);
+ }
+
+ // 7. 处理默认地址逻辑
+ if (updateAddress.getIsDefault() != null && updateAddress.getIsDefault() == 1L) {
+ // 如果设置为默认地址,先将该用户的所有地址设为非默认
+ userAddressService.updateUserAddressDefault(user.getId());
+ }
+
+ // 8. 执行地址更新
+ int updateResult = userAddressService.updateUserAddress(updateAddress);
+
+ if (updateResult > 0) {
+ return success("地址修改成功");
+ } else {
+ return error("地址修改失败");
+ }
+
+ } catch (Exception e) {
+ System.err.println("修改用户地址异常:" + e.getMessage());
+ return error("修改地址失败:" + e.getMessage());
+ }
+ }
+
+ /**
+ * 构建地址更新对象
+ *
+ * @param params 请求参数
+ * @param addressId 地址ID
+ * @param userId 用户ID
+ * @return UserAddress对象
+ */
+ private UserAddress buildUpdateAddress(Map params, Long addressId, Long userId) {
+ UserAddress address = new UserAddress();
+ address.setId(addressId);
+ address.setUid(userId);
+
+ // 设置收货人姓名
+ if (params.get("name") != null) {
+ address.setName(params.get("name").toString().trim());
+ }
+
+ // 设置联系电话
+ if (params.get("phone") != null) {
+ address.setPhone(params.get("phone").toString().trim());
+ }
+
+ // 设置纬度
+ if (params.get("latitude") != null) {
+ address.setLatitude(params.get("latitude").toString().trim());
+ }
+
+ // 设置经度
+ if (params.get("longitude") != null) {
+ address.setLongitude(params.get("longitude").toString().trim());
+ }
+
+ // 设置地址名称
+ if (params.get("address_name") != null) {
+ address.setAddressName(params.get("address_name").toString().trim());
+ }
+
+ // 设置地址信息
+ if (params.get("address_info") != null) {
+ address.setAddressInfo(params.get("address_info").toString().trim());
+ }
+
+ // 设置详细地址
+ if (params.get("info") != null) {
+ address.setInfo(params.get("info").toString().trim());
+ }
+
+ // 设置是否默认地址
+ if (params.get("is_default") != null) {
+ try {
+ Long isDefault = Long.valueOf(params.get("is_default").toString());
+ address.setIsDefault(isDefault);
+ } catch (NumberFormatException e) {
+ // 如果转换失败,设为非默认
+ address.setIsDefault(0L);
+ }
+ }
+
+ return address;
+ }
+
+ /**
+ * 验证地址参数
+ *
+ * @param address 地址对象
+ * @return 验证错误信息,null表示验证通过
+ */
+ private String validateAddressParams(UserAddress address) {
+ if (address.getName() == null || address.getName().isEmpty()) {
+ return "收货人姓名不能为空";
+ }
+
+ if (address.getPhone() == null || address.getPhone().isEmpty()) {
+ return "联系电话不能为空";
+ }
+
+ // 验证手机号格式(简单验证)
+ if (!address.getPhone().matches("^1[3-9]\\d{9}$")) {
+ return "联系电话格式不正确";
+ }
+
+ if (address.getInfo() == null || address.getInfo().isEmpty()) {
+ return "详细地址不能为空";
+ }
+
+ return null; // 验证通过
+ }
+
+ /**
+ * 新增用户收货地址
+ *
+ * @param params 地址新增参数
+ * @param request HTTP请求对象
+ * @return 新增结果
+ *
+ * 请求参数格式:
+ * {
+ * "name": "何飞飞",
+ * "phone": "15002954325",
+ * "address_name": "陕西省西安市未央区未央路3号(龙首原地铁站C出口步行180米)",
+ * "address_info": "凤鑫城购物中心(未央路店)",
+ * "info": "458",
+ * "is_default": true,
+ * "latitude": 34.294248,
+ * "longitude": 108.948261
+ * }
+ *
+ * 接口说明:
+ * - 验证用户登录状态
+ * - 支持新增地址的所有字段
+ * - 自动处理默认地址逻辑(设为默认时会取消其他默认地址)
+ * - 返回新增后的地址信息
+ *
+ * 返回格式:
+ * {
+ * "code": 200,
+ * "msg": "操作成功",
+ * "data": "地址新增成功"
+ * }
+ */
+ @PostMapping("/api/user/address/add")
+ public AjaxResult addAddress(@RequestBody Map params, HttpServletRequest request) {
+ try {
+ // 1. 验证用户登录状态
+ String token = request.getHeader("token");
+ Map userValidation = AppletLoginUtil.validateUserToken(token, usersService);
+ if (!(Boolean) userValidation.get("valid")) {
+ return error("用户未登录或token无效");
+ }
+
+ // 2. 获取用户信息
+ Users user = (Users) userValidation.get("user");
+ if (user == null) {
+ return error("用户信息获取失败");
+ }
+
+ // 3. 构建新增的地址对象
+ UserAddress newAddress = buildNewAddress(params, user.getId());
+
+ // 4. 验证必填字段
+ String validationResult = validateAddressParams(newAddress);
+ if (validationResult != null) {
+ return error(validationResult);
+ }
+
+ // 5. 处理默认地址逻辑
+ if (newAddress.getIsDefault() != null && newAddress.getIsDefault() == 1L) {
+ // 如果设置为默认地址,先将该用户的所有地址设为非默认
+ userAddressService.updateUserAddressDefault(user.getId());
+ }
+
+ // 6. 执行地址新增
+ int insertResult = userAddressService.insertUserAddress(newAddress);
+
+ if (insertResult > 0) {
+ return success("地址新增成功");
+ } else {
+ return error("地址新增失败");
+ }
+
+ } catch (Exception e) {
+ System.err.println("新增用户地址异常:" + e.getMessage());
+ return error("新增地址失败:" + e.getMessage());
+ }
+ }
+
+ /**
+ * 构建地址新增对象
+ *
+ * @param params 请求参数
+ * @param userId 用户ID
+ * @return UserAddress对象
+ */
+ private UserAddress buildNewAddress(Map params, Long userId) {
+ UserAddress address = new UserAddress();
+ address.setUid(userId);
+
+ // 设置收货人姓名
+ if (params.get("name") != null) {
+ address.setName(params.get("name").toString().trim());
+ }
+
+ // 设置联系电话
+ if (params.get("phone") != null) {
+ address.setPhone(params.get("phone").toString().trim());
+ }
+
+ // 设置纬度
+ if (params.get("latitude") != null) {
+ address.setLatitude(params.get("latitude").toString().trim());
+ }
+
+ // 设置经度
+ if (params.get("longitude") != null) {
+ address.setLongitude(params.get("longitude").toString().trim());
+ }
+
+ // 设置地址名称
+ if (params.get("address_name") != null) {
+ address.setAddressName(params.get("address_name").toString().trim());
+ }
+
+ // 设置地址信息
+ if (params.get("address_info") != null) {
+ address.setAddressInfo(params.get("address_info").toString().trim());
+ }
+
+ // 设置详细地址
+ if (params.get("info") != null) {
+ address.setInfo(params.get("info").toString().trim());
+ }
+
+ // 设置是否默认地址
+ if (params.get("is_default") != null) {
+ try {
+ // 处理布尔值或数字值
+ Object isDefaultObj = params.get("is_default");
+ Long isDefault = 0L;
+
+ if (isDefaultObj instanceof Boolean) {
+ isDefault = ((Boolean) isDefaultObj) ? 1L : 0L;
+ } else if (isDefaultObj instanceof Number) {
+ isDefault = ((Number) isDefaultObj).longValue();
+ } else {
+ String isDefaultStr = isDefaultObj.toString().toLowerCase();
+ if ("true".equals(isDefaultStr) || "1".equals(isDefaultStr)) {
+ isDefault = 1L;
+ }
+ }
+
+ address.setIsDefault(isDefault);
+ } catch (Exception e) {
+ // 如果转换失败,设为非默认
+ address.setIsDefault(0L);
+ }
+ } else {
+ // 如果没有指定,默认设为非默认地址
+ address.setIsDefault(0L);
+ }
+
+ return address;
+ }
+
+
+ @PostMapping("api/service/order/lst")
+ public AjaxResult getserviceorderlst(@RequestBody Map params,
+ HttpServletRequest request) {
+
+ int page = (int) params.get("page");
+ int limit = (int) params.get("limit");
+ String status = (String) params.get("status");
+
+ // 1. 验证分页参数
+ Map pageValidation = PageUtil.validatePageParams(page, limit);
+ if (!(Boolean) pageValidation.get("valid")) {
+ return error((String) pageValidation.get("message"));
+ }
+
+ // 2. 验证用户登录状态
+ String token = request.getHeader("token");
+ Map userValidation = AppletLoginUtil.validateUserToken(token, usersService);
+ if (!(Boolean) userValidation.get("valid")) {
+ return error("用户未登录或token无效");
+ }
+
+ // 3. 获取用户信息
+ Users user = (Users) userValidation.get("user");
+ if (user == null) {
+ return error("用户信息获取失败");
+ }
+
+ // 4. 设置分页参数
+ PageHelper.startPage(page, limit);
+
+ // 5. 查询用户地址列表
+ OrderApple order = new OrderApple();
+ order.setType(1);
+ order.setUid(user.getId());
+
+ if (StringUtils.isNotNull(status) && !"".equals(status)) {
+ order.setStatus(Long.valueOf(status));
+ }
+
+
+ List orderList = orderService.selectOrderAppleList(order);
+ for (OrderApple orderdata : orderList) {
+ Map jsonObject = new HashMap<>();
+ if (orderdata.getProduct_id() != null) {
+ ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(orderdata.getProduct_id());
+ if (serviceGoods != null) {
+ jsonObject.put("title", serviceGoods.getTitle());
+ jsonObject.put("icon", "https://img.huafurenjia.cn/" + serviceGoods.getIcon());
+ jsonObject.put("id", serviceGoods.getId());
+ jsonObject.put("price_zn", serviceGoods.getPriceZn());
+ jsonObject.put("sub_title", serviceGoods.getSubTitle());
+ orderdata.setProduct(jsonObject);
+ }
+ }
+ }
+
+ // 6. 获取分页信息并构建响应
+ TableDataInfo tableDataInfo = getDataTable(orderList);
+
+ // 7. 构建符合要求的分页响应格式
+ Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit);
+
+ return success(pageData);
+ }
+
+ @PostMapping("/api/goods/order/lst")
+ public AjaxResult getgoodsorderlst(@RequestBody Map params,
+ HttpServletRequest request) {
+
+ int page = (int) params.get("page");
+ int limit = (int) params.get("limit");
+ String status = (String) params.get("status");
+
+ // 1. 验证分页参数
+ Map pageValidation = PageUtil.validatePageParams(page, limit);
+ if (!(Boolean) pageValidation.get("valid")) {
+ return error((String) pageValidation.get("message"));
+ }
+
+ // 2. 验证用户登录状态
+ String token = request.getHeader("token");
+ Map userValidation = AppletLoginUtil.validateUserToken(token, usersService);
+ if (!(Boolean) userValidation.get("valid")) {
+ return error("用户未登录或token无效");
+ }
+
+ // 3. 获取用户信息
+ Users user = (Users) userValidation.get("user");
+ if (user == null) {
+ return error("用户信息获取失败");
+ }
+
+ // 4. 设置分页参数
+ PageHelper.startPage(page, limit);
+
+ // 5. 查询用户地址列表
+ OrderApple order = new OrderApple();
+ order.setType(2);
+ order.setUid(user.getId());
+
+ if (StringUtils.isNotNull(status) && !"".equals(status)) {
+ order.setStatus(Long.valueOf(status));
+ }
+
+
+ List orderList = orderService.selectOrderAppleList(order);
+
+ // 6. 获取分页信息并构建响应
+ TableDataInfo tableDataInfo = getDataTable(orderList);
+
+ // 7. 构建符合要求的分页响应格式
+ Map pageData = PageUtil.buildPageResponse(tableDataInfo, page, limit);
+
+ return success(pageData);
+ }
@PostMapping(value = "/api/user/login")
public AjaxResult getuserlogin(HttpServletRequest request) {
- String token=request.getHeader("token");
- Users users=usersService.selectUsersByRememberToken(token);
- if (users!=null){
+ String token = request.getHeader("token");
+ Users users = usersService.selectUsersByRememberToken(token);
+ if (users != null) {
users.setRemember_token(users.getRememberToken());
- return success(users);
- }else{
+ return success(users);
+ } else {
return error("用户不存在");
}
@@ -255,7 +806,7 @@ public class AppletController extends BaseController {
try {
Long cateId = null;
String keywords = null;
-
+
// 处理分类ID参数
if (params.get("cate_id") != null) {
Object cateIdObj = params.get("cate_id");
@@ -269,7 +820,7 @@ public class AppletController extends BaseController {
}
}
}
-
+
// 处理关键词参数
if (params.get("keywords") != null) {
keywords = params.get("keywords").toString().trim();
@@ -277,10 +828,10 @@ public class AppletController extends BaseController {
keywords = null;
}
}
-
+
// 构建返回数据结构
List