From 3ecac8d30b932b142f1c4f49edec9d4aea2d2797 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 23 十二月 2025 17:05:31 +0800
Subject: [PATCH] 后台接口

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java                |  112 ++++++++++++++----
 ruoyi-system/src/main/java/com/ruoyi/system/vo/TAppUserVo.java                                |  144 ++++++++++++++++++++++++
 ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java            |    2 
 ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml                              |    3 
 ruoyi-system/src/main/java/com/ruoyi/system/query/AppUserListQuery.java                       |    2 
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java |   26 ++++
 ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml                  |   12 ++
 ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java          |    1 
 ruoyi-system/src/main/java/com/ruoyi/system/export/TBigGiftPackageOrderUserExport.java        |   51 ++++++++
 9 files changed, 325 insertions(+), 28 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
index b8cd676..3daff40 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
@@ -22,9 +22,7 @@
 import com.ruoyi.system.dto.BatchUpdateIntegralDto;
 import com.ruoyi.system.dto.GoldChangeDto;
 import com.ruoyi.system.dto.UpdateAppUserDto;
-import com.ruoyi.system.export.AppUserGoldImport;
-import com.ruoyi.system.export.AppUserImport;
-import com.ruoyi.system.export.BigGiftPackageImport;
+import com.ruoyi.system.export.*;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.model.*;
 import com.ruoyi.system.query.*;
@@ -33,6 +31,7 @@
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.transaction.annotation.Propagation;
@@ -71,34 +70,35 @@
 @Api(tags = "(嘉视达)用户管理")
 public class TAppUserController {
 
+    private final TAppUserService appUserService;
 
-    @Resource
-    private TAppUserService appUserService;
+    private  final RedisTemplate redisTemplate;
 
+    private final TokenService tokenService;
 
-    @Autowired
-    private RedisTemplate redisTemplate;
+    private final TCompanyService companyService;
 
-    @Autowired
-    private TokenService tokenService;
+    private final TGoldChangeRecordService goldChangeRecordService;
 
-    @Autowired
-    private TCompanyService companyService;
+    private final TIntegralChangeRecordService integralChangeRecordService;
 
-    @Autowired
-    private TGoldChangeRecordService goldChangeRecordService;
+    private final SysUserMapper sysUserMapper;
 
-    @Autowired
-    private TIntegralChangeRecordService integralChangeRecordService;
+    private final TBigGiftPackageOrderService bigGiftPackageOrderService;
 
-    @Autowired
-    private SysUserMapper sysUserMapper;
+    private final TIntegralSettlementService integralSettlementService;
 
-    @Autowired
-    private TBigGiftPackageOrderService bigGiftPackageOrderService;
-
-    @Autowired
-    private TIntegralSettlementService integralSettlementService;
+    public TAppUserController(TAppUserService appUserService, RedisTemplate redisTemplate, TokenService tokenService, TCompanyService companyService, TGoldChangeRecordService goldChangeRecordService, TIntegralChangeRecordService integralChangeRecordService, SysUserMapper sysUserMapper, TBigGiftPackageOrderService bigGiftPackageOrderService, TIntegralSettlementService integralSettlementService) {
+        this.appUserService = appUserService;
+        this.redisTemplate = redisTemplate;
+        this.tokenService = tokenService;
+        this.companyService = companyService;
+        this.goldChangeRecordService = goldChangeRecordService;
+        this.integralChangeRecordService = integralChangeRecordService;
+        this.sysUserMapper = sysUserMapper;
+        this.bigGiftPackageOrderService = bigGiftPackageOrderService;
+        this.integralSettlementService = integralSettlementService;
+    }
 
 
     @ApiOperation(value = "用户管理分页列表")
@@ -156,8 +156,17 @@
 
     @ApiOperation(value = "查看详情")
     @GetMapping(value = "/detail")
-    public R<TAppUser> detail(@RequestParam String id) {
-        return R.ok(appUserService.getById(id));
+    public R<TAppUserVo> detail(@RequestParam String id) {
+        TAppUser appUser = appUserService.getById(id);
+        TAppUserVo tAppUserVo = new TAppUserVo();
+        BeanUtils.copyProperties(appUser, tAppUserVo);
+        if(appUser.getCompanyId()!=null){
+            tAppUserVo.setReferrerCompany(companyService.getById(appUser.getCompanyId()));
+        }
+        if(appUser.getReferrerUserId()!=null && appUser.getReferrerStatus()==2){
+            tAppUserVo.setReferrerUser(appUserService.getById(appUser.getReferrerUserId()));
+        }
+        return R.ok(tAppUserVo);
     }
 
 
@@ -443,13 +452,11 @@
     }
 
 
-
     @ApiOperation(value = "积分修改记录")
     @PostMapping(value = "/integralChangeRecord")
     public R<PageInfo<IntegralChangeRecordVo>> integralChangeRecord(@RequestBody IntegralChangeRecordQuery query) {
         return R.ok(integralChangeRecordService.integralChangeRecord(query));
     }
-
 
 
     @ApiOperation(value = "积分修改记录导出")
@@ -537,6 +544,7 @@
         return R.ok();
     }
 
+
     @ApiOperation(value = "金币扣除")
     @PostMapping(value = "/goldSub")
     @Log(title = "小程序用户-金币扣除", businessType = BusinessType.UPDATE)
@@ -573,6 +581,55 @@
     }
 
 
+    @ApiOperation(value = "用户-购买记录导出")
+    @PostMapping(value = "/pageOrderListExport")
+    @Log(title = "购买记录-导出", businessType = BusinessType.EXPORT)
+    public void pageOrderListExport(@RequestBody @Valid GoldChangeRecordQuery query){
+        List<TBigGiftPackageOrder> list = bigGiftPackageOrderService.pageOrderListExport(query);
+        ArrayList<TBigGiftPackageOrderUserExport> tBigGiftPackageOrderUserExports = new ArrayList<>();
+        for (TBigGiftPackageOrder order : list) {
+            TBigGiftPackageOrderUserExport export = new TBigGiftPackageOrderUserExport();
+            export.setOrderNo(order.getCode());
+            export.setCreateTime(order.getCreateTime());
+            export.setUsername(order.getUserName());
+            export.setUserPhone(order.getPhone());
+            export.setOrderAmount(order.getOrderPrice());
+            export.setGoodsName(order.getBigGiftPackageName());
+            export.setPayMethod("微信支付");
+            export.setDeposit(order.getDeposit());
+            export.setBalance(order.getFinalPayment());
+            export.setOrderStatus(order.getStatus());
+            tBigGiftPackageOrderUserExports.add(export);
+        }
+
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TBigGiftPackageOrderUserExport.class, tBigGiftPackageOrderUserExports);
+        HttpServletResponse response = WebUtils.response();
+        assert response != null;
+        response.setContentType("application/vnd.ms-excel");
+        response.setCharacterEncoding("utf-8");
+        ServletOutputStream outputStream = null;
+        try {
+            String fileName = URLEncoder.encode("购买记录导出信息.xls", "utf-8");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+            response.setHeader("Pragma", "no-cache");
+            response.setHeader("Cache-Control", "no-cache");
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                outputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+
+
     @ApiOperation(value = "用户- 推广记录")
     @PostMapping("/promotionPageList")
     public R<Page<UserPromotionPageListVo>> promotionPageList(@RequestBody @Valid UserPromotionPageListQuery query) {
@@ -581,7 +638,6 @@
         page.setRecords(list);
         return R.ok(page);
     }
-
 
 
     @ApiOperation(value = "用户-推广记录导出")
@@ -668,6 +724,7 @@
         return R.ok(integralSettlementPage);
     }
 
+
     @ApiOperation(value = "用户结算记录导出")
     @PostMapping(value = "/exportSettlementPageList")
     @Log(title = "结算记录-导出", businessType = BusinessType.EXPORT)
@@ -698,7 +755,6 @@
             }
         }
     }
-
 
 
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/export/TBigGiftPackageOrderUserExport.java b/ruoyi-system/src/main/java/com/ruoyi/system/export/TBigGiftPackageOrderUserExport.java
new file mode 100644
index 0000000..77ef862
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/export/TBigGiftPackageOrderUserExport.java
@@ -0,0 +1,51 @@
+package com.ruoyi.system.export;
+
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+
+/**
+ * 大礼包订单导出DTO
+ * 
+ * @author ruoyi
+ */
+@Data
+@ApiModel(value = "用户大礼包订单导出")
+public class TBigGiftPackageOrderUserExport
+{
+
+    @Excel(name = "订单编号")
+    private String orderNo;
+
+    @Excel(name = "下单时间", width = 30, exportFormat = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @Excel(name = "下单用户")
+    private String username;
+
+    @Excel(name = "用户手机号")
+    private String userPhone;
+
+    @Excel(name = "订单价格")
+    private BigDecimal orderAmount;
+
+    @Excel(name = "商品名称")
+    private String goodsName;
+
+    @Excel(name = "支付方式")
+    private String payMethod;
+
+    @Excel(name = "定金")
+    private BigDecimal deposit;
+
+    @Excel(name = "尾款")
+    private BigDecimal balance;
+
+    @Excel(name = "订单状态" ,replace = { "待付款_1", "已付订金_2", "已支付_3", "已确认收货_4", "已退款_5"})
+    private Integer orderStatus;
+}
\ No newline at end of file
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java
index c81f912..2868fc1 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBigGiftPackageOrderMapper.java
@@ -38,4 +38,6 @@
 
     List<UserProfitPageListVo> profitUserPageListExport(@Param("query") UserProfitPageListQuery query, @Param("sTime") String sTime, @Param("eTime") String eTime);
 
+    List<TBigGiftPackageOrder> pageOrderListExport(@Param("query") GoldChangeRecordQuery query);
+
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/AppUserListQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/AppUserListQuery.java
index 6c3e98b..227d05e 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/query/AppUserListQuery.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/AppUserListQuery.java
@@ -15,4 +15,6 @@
     private String phoneNumber;
     @ApiModelProperty(value = "状态 1=使用中 2=冻结")
     private Integer status;
+    @ApiModelProperty(value = "推广状态有条件1 其他不传")
+    private Integer promotionStatus;
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java
index 82a8d42..891b307 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBigGiftPackageOrderService.java
@@ -61,4 +61,5 @@
 
     List<UserProfitPageListVo> profitUserPageListExport(@Valid UserProfitPageListQuery query);
 
+    List<TBigGiftPackageOrder> pageOrderListExport(@Valid GoldChangeRecordQuery query);
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java
index 229e1bc..9242efa 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBigGiftPackageOrderServiceImpl.java
@@ -273,6 +273,32 @@
     }
 
     @Override
+    public List<TBigGiftPackageOrder> pageOrderListExport(GoldChangeRecordQuery query) {
+        List<TBigGiftPackageOrder> tBigGiftPackageOrders =  this.baseMapper.pageOrderListExport( query);
+        if(!tBigGiftPackageOrders.isEmpty()){
+            List<Integer> companyId = tBigGiftPackageOrders.stream().map(TBigGiftPackageOrder::getCompanyId).collect(Collectors.toList());
+            List<TCompany> tCompanies = companyMapper.selectBatchIds(companyId);
+            tBigGiftPackageOrders.forEach(tBigGiftPackageOrder -> {
+                TCompany tCompany1 = tCompanies.stream().filter(tCompany -> tCompany.getId().equals(tBigGiftPackageOrder.getCompanyId())).findFirst().orElse(null);
+                if(tCompany1!=null){
+                    tBigGiftPackageOrder.setCompanyName(tCompany1.getName());
+                }
+            });
+            List<Integer> goodsIds = tBigGiftPackageOrders.stream().map(TBigGiftPackageOrder::getBigGiftPackageId).collect(Collectors.toList());
+            List<TBigGiftPackage> bigGiftPackages = bigGiftPackageMapper.selectBatchIds(goodsIds);
+            tBigGiftPackageOrders.forEach(tBigGiftPackageOrder -> {
+                TBigGiftPackage bigGiftPackage = bigGiftPackages.stream().filter(tBigGiftPackage -> tBigGiftPackage.getId().equals(tBigGiftPackageOrder.getBigGiftPackageId())).findFirst().orElse(null);
+                if(bigGiftPackage!=null){
+                    tBigGiftPackageOrder.setBigGiftPackageName(bigGiftPackage.getName());
+                }
+            });
+
+        }
+
+        return tBigGiftPackageOrders;
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public PlaceOrderVO placeOrder(BigGiftPlaceOrderDTO dto, Integer appUserId, String openid) {
         // 1. 校验商品是否存在
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/TAppUserVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/TAppUserVo.java
new file mode 100644
index 0000000..3a53c6f
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/TAppUserVo.java
@@ -0,0 +1,144 @@
+package com.ruoyi.system.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.system.model.TAppUser;
+import com.ruoyi.system.model.TCompany;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 小程序用户
+ * </p>
+ *
+ * @author xiaochen
+ * @since 2025-12-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("t_app_user")
+@ApiModel(value="TAppUser对象", description="小程序用户")
+public class TAppUserVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "经销商id")
+    @TableField("company_id")
+    private Integer companyId;
+
+    @ApiModelProperty(value = "姓名")
+    @TableField("name")
+    @Excel(name = "用户名", width = 20,orderNum = "1")
+    private String name;
+
+    @ApiModelProperty(value = "头像")
+    @TableField("profile_photo")
+    @Excel(name = "头像", width = 20, imageType = 1,type = 2,orderNum = "0")
+    private String profilePhoto;
+
+    @ApiModelProperty(value = "推广号")
+    @TableField("code")
+    @Excel(name = "推广号", width = 20,orderNum = "2")
+    private String code;
+
+    @ApiModelProperty(value = "推广二维码地址")
+    @TableField("promotion_qr_code")
+    private String promotionQrCode;
+
+    @ApiModelProperty(value = "手机号")
+    @TableField("phone")
+    @Excel(name = "联系电话", width = 20,orderNum = "3")
+    private String phone;
+
+    @ApiModelProperty(value = "性别(1=男,2=女)")
+    @TableField("gender")
+    @Excel(name = "性别", width = 20,orderNum = "4",replace = {"男_1","女_2"})
+    private Integer gender;
+
+    @ApiModelProperty(value = "生日")
+    @TableField("birthday")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "出生日期", width = 20,orderNum = "5",format = "yyyy-MM-dd")
+    private LocalDate birthday;
+
+    @ApiModelProperty(value = "微信openid")
+    @TableField("openid")
+    private String openid;
+// 1:游客;2:营销员;3:合伙人;
+    @ApiModelProperty(value = "角色(1=游客,2=营销员,3=合伙人)")
+    @TableField("user_type")
+    @Excel(name = "角色", width = 20,orderNum = "7",replace = {"游客_1","营销员_2","合伙人_3"})
+    private Integer userType;
+
+    @ApiModelProperty(value = "注册时间")
+    @TableField("create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "注册时间", width = 20,orderNum = "6",format = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "历史累计积分")
+    @TableField("total_accumulative_integral")
+    private Integer totalAccumulativeIntegral;
+
+    @ApiModelProperty(value = "累计积分")
+    @TableField("accumulative_integral")
+    private Integer accumulativeIntegral;
+
+    @ApiModelProperty(value = "推荐人id")
+    @TableField("referrer_user_id")
+    private Integer referrerUserId;
+
+    @ApiModelProperty(value = "推荐状态(1=临时,2=正式)")
+    @TableField("referrer_status")
+    private Integer referrerStatus;
+
+    @ApiModelProperty(value = "推荐时间")
+    @TableField("referrer_time")
+    private LocalDateTime referrerTime;
+
+    @ApiModelProperty(value = "推广状态(0=关闭,1=打开)")
+    @TableField("promotion_status")
+    private Integer promotionStatus;
+
+    @ApiModelProperty(value = "金币余额")
+    @TableField("gold_balance")
+    private BigDecimal goldBalance;
+
+    @ApiModelProperty(value = "状态(1=正常,2=冻结,3=删除)")
+    @TableField("status")
+    @Excel(name = "状态", width = 20,orderNum = "8",replace = {"正常_1","冻结_2","删除_3"})
+    private Integer status;
+
+    @ApiModelProperty(value = "股东ID")
+    @TableField("referrer_sys_user_id")
+    private Integer referrerSysUserId;
+
+    @ApiModelProperty(value = "当月预估积分")
+    @TableField(exist = false)
+    private BigDecimal estimatedMonthlyIntegral;
+
+
+
+    @ApiModelProperty("上级推荐人信息")
+    private TAppUser referrerUser;
+
+    @ApiModelProperty("上级经销商信息")
+    private TCompany referrerCompany;
+
+}
diff --git a/ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml
index 31469e6..17deb29 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TAppUserMapper.xml
@@ -36,6 +36,9 @@
         <if test="query.status != null">
             and t1.status = #{query.status}
         </if>
+        <if test="query.promotionStatus != null">
+            and t1.promotion_status =1
+        </if>
 
         order by t1.create_time desc
     </select>
diff --git a/ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml
index 15022eb..c82253c 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TBigGiftPackageOrderMapper.xml
@@ -164,5 +164,17 @@
         </if>
         order by t1.create_time desc
     </select>
+    <select id="pageOrderListExport" resultType="com.ruoyi.system.model.TBigGiftPackageOrder">
+        SELECT
+
+            t1.id, t1.code, t1.company_id, t1.app_user_id, t1.create_time, t1.big_gift_package_id, t1.big_gift_package,
+            t1.order_price, t1.deposit, t1.final_payment, t1.payment_price,
+            t1.status, t1.delivery_time, t1.payment_type, t1.deposit_time, t1.deposit_payment_method,
+            t1.deposit_payment_serial_number, t1.final_payment_time, t1.final_payment_method,
+            t1.final_payment_serial_number, t1.del_flag, t1.remark,t2.phone,t2.name userName
+        FROM t_big_gift_package_order t1 LEFT JOIN t_app_user t2 ON t1.app_user_id = t2.id
+        WHERE t1.del_flag = 0 and t2.id = #{query.userId}
+        order by t1.create_time desc
+    </select>
 
 </mapper>

--
Gitblit v1.7.1