Browse Source

订单退款以及用户信息,增加了用户钱包表,再下单以及退款中继承了表中数据

LiRong 2 weeks ago
parent
commit
cb3b0748ff
25 changed files with 808 additions and 75 deletions
  1. 19 0
      leromro-admin/src/main/java/com/leromro/web/controller/system/SysUserController.java
  2. 14 0
      leromro-common/src/main/java/com/leromro/common/core/domain/entity/SysUser.java
  3. 129 0
      leromro-core/src/main/java/com/leromro/core/controller/ClientAccountChangeController.java
  4. 43 0
      leromro-core/src/main/java/com/leromro/core/controller/ClientAccountController.java
  5. 1 1
      leromro-core/src/main/java/com/leromro/core/controller/OrdersController.java
  6. 60 0
      leromro-core/src/main/java/com/leromro/core/domain/ClientAccountChange.java
  7. 3 0
      leromro-core/src/main/java/com/leromro/core/domain/OrderRefund.java
  8. 2 2
      leromro-core/src/main/java/com/leromro/core/domain/VolunteerAccountChange.java
  9. 24 0
      leromro-core/src/main/java/com/leromro/core/domain/vo/ClientAccountChangeListVO.java
  10. 13 0
      leromro-core/src/main/java/com/leromro/core/domain/vo/ClientAccountChangeVO.java
  11. 2 0
      leromro-core/src/main/java/com/leromro/core/domain/vo/WebOrderRefundVO.java
  12. 66 0
      leromro-core/src/main/java/com/leromro/core/mapper/ClientAccountChangeMapper.java
  13. 1 1
      leromro-core/src/main/java/com/leromro/core/mapper/MainOrdersMapper.java
  14. 65 0
      leromro-core/src/main/java/com/leromro/core/service/IClientAccountChangeService.java
  15. 3 0
      leromro-core/src/main/java/com/leromro/core/service/IClientAccountService.java
  16. 1 1
      leromro-core/src/main/java/com/leromro/core/service/IMainOrderService.java
  17. 120 0
      leromro-core/src/main/java/com/leromro/core/service/impl/ClientAccountChangeServiceImpl.java
  18. 3 0
      leromro-core/src/main/java/com/leromro/core/service/impl/ClientAccountServiceImpl.java
  19. 9 4
      leromro-core/src/main/java/com/leromro/core/service/impl/MainOrderServiceImpl.java
  20. 95 57
      leromro-core/src/main/java/com/leromro/core/service/impl/OrderRefundServiceImpl.java
  21. 124 0
      leromro-core/src/main/resources/mapper/core/ClientAccountChangeMapper.xml
  22. 0 0
      leromro-core/src/main/resources/mapper/core/IClientAccountChangeService.xml
  23. 6 3
      leromro-core/src/main/resources/mapper/core/MainOrdersMapper.xml
  24. 5 6
      leromro-core/src/main/resources/mapper/core/OrderRefundMapper.xml
  25. 0 0
      leromro-system/src/main/resources/mapper/system/IClientAccountChangeService.xml

+ 19 - 0
leromro-admin/src/main/java/com/leromro/web/controller/system/SysUserController.java

@@ -4,6 +4,8 @@ import java.util.List;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.leromro.common.core.domain.R;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.ArrayUtils;
@@ -79,6 +81,23 @@ public class SysUserController extends BaseController
         return getDataTable(list);
     }
 
+    @ApiOperation("小程序端用户信息回显")
+    @GetMapping("/userInfo")
+    public R<SysUser> userInfo()
+    {
+        Long userId = SecurityUtils.getUserId();
+        SysUser sysUserInfo = userService.userList(new SysUser(userId)).get(0);
+        return R.ok(sysUserInfo);
+    }
+    @ApiOperation("小程序端用户信息修改")
+    @PostMapping("/updateUserInfo")
+    public AjaxResult updateUserInfo(SysUser sysUser)
+    {
+        sysUser.setUserId(SecurityUtils.getUserId());
+        userService.updateById(sysUser);
+        return AjaxResult.success();
+    }
+
 
     @Log(title = "用户管理", businessType = BusinessType.EXPORT)
     @PreAuthorize("@ss.hasPermi('system:user:export')")

+ 14 - 0
leromro-common/src/main/java/com/leromro/common/core/domain/entity/SysUser.java

@@ -59,6 +59,11 @@ public class SysUser extends BaseEntity
     @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
     private String sex;
 
+    /** 用户性别 */
+    @Excel(name = "用户年龄")
+    private String age;
+
+
     /** 用户头像 */
     private String avatar;
 
@@ -217,6 +222,14 @@ public class SysUser extends BaseEntity
         return userPlatform;
     }
 
+    public String getAge() {
+        return age;
+    }
+
+    public void setAge(String age) {
+        this.age = age;
+    }
+
     public void setUserPlatform(Integer userPlatform) {
         this.userPlatform = userPlatform;
     }
@@ -473,6 +486,7 @@ public class SysUser extends BaseEntity
             .append("dept", getDept())
             .append("userPlatform",getUserPlatform())
             .append("userOrWorker",getUserOrWorker())
+            .append("age",getAge())
             .toString();
     }
 }

+ 129 - 0
leromro-core/src/main/java/com/leromro/core/controller/ClientAccountChangeController.java

@@ -0,0 +1,129 @@
+package com.leromro.core.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.leromro.common.utils.SecurityUtils;
+import com.leromro.core.domain.vo.ClientAccountChangeListVO;
+import com.leromro.core.domain.vo.ClientAccountChangeVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.leromro.common.core.domain.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.leromro.common.annotation.Log;
+import com.leromro.common.core.controller.BaseController;
+import com.leromro.common.core.domain.AjaxResult;
+import com.leromro.common.enums.BusinessType;
+import com.leromro.core.domain.ClientAccountChange;
+import com.leromro.core.service.IClientAccountChangeService;
+import com.leromro.common.utils.poi.ExcelUtil;
+import com.leromro.common.core.page.TableDataInfo;
+
+/**
+ * 用户钱包余额变更记录Controller
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+@RestController
+@Api(tags = "用户钱包余额变更记录")
+@RequestMapping("/core/client/account-change")
+public class ClientAccountChangeController extends BaseController
+{
+    @Autowired
+    private IClientAccountChangeService lClientAccountChangeService;
+
+    /**
+     * 查询用户自己的钱包变更记录
+     */
+
+    @ApiOperation("查询用户自己的账户变更记录 收入或支出字段在字典中 类型为:jlzj_money_change_type 用户变更来源 字典字段为:jlzj_client_source_type ")
+    @GetMapping
+    public R<ClientAccountChangeListVO> clientAccountChange(){
+        Long userId = SecurityUtils.getUserId();
+        return R.ok(lClientAccountChangeService.selectAccountChangeByuserId(userId));
+    }
+
+
+    /**
+     * 查询用户钱包余额变更记录列表
+     */
+    @ApiOperation("查询用户钱包余额变更记录列表")
+    //@PreAuthorize("@ss.hasPermi('core:change:list')")
+    @GetMapping("/list")
+    public TableDataInfo<ClientAccountChange> list(ClientAccountChange clientAccountChange)
+    {
+        startPage();
+        List<ClientAccountChange> list = lClientAccountChangeService.selectLClientAccountChangeList(clientAccountChange);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出用户钱包余额变更记录列表
+     */
+    @ApiOperation("导出用户钱包余额变更记录列表")
+    //@PreAuthorize("@ss.hasPermi('core:change:export')")
+    @Log(title = "用户钱包余额变更记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, ClientAccountChange clientAccountChange)
+    {
+        List<ClientAccountChange> list = lClientAccountChangeService.selectLClientAccountChangeList(clientAccountChange);
+        ExcelUtil<ClientAccountChange> util = new ExcelUtil<ClientAccountChange>(ClientAccountChange.class);
+        util.exportExcel(response, list, "用户钱包余额变更记录数据");
+    }
+
+    /**
+     * 获取用户钱包余额变更记录详细信息
+     */
+    @ApiOperation("获取用户钱包余额变更记录详细信息")
+   // @PreAuthorize("@ss.hasPermi('core:change:query')")
+    @GetMapping(value = "/{clientAccountChangeId}")
+    public R<ClientAccountChange> getInfo(@PathVariable("clientAccountChangeId") Long clientAccountChangeId)
+    {
+        return R.ok(lClientAccountChangeService.selectLClientAccountChangeByClientAccountChangeId(clientAccountChangeId));
+    }
+
+    /**
+     * 新增用户钱包余额变更记录
+     */
+    @ApiOperation("新增用户钱包余额变更记录")
+    //@PreAuthorize("@ss.hasPermi('core:change:add')")
+    @Log(title = "用户钱包余额变更记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody ClientAccountChange clientAccountChange)
+    {
+        return toAjax(lClientAccountChangeService.insertLClientAccountChange(clientAccountChange));
+    }
+
+    /**
+     * 修改用户钱包余额变更记录
+     */
+    @ApiOperation("修改用户钱包余额变更记录")
+    //@PreAuthorize("@ss.hasPermi('core:change:edit')")
+    @Log(title = "用户钱包余额变更记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody ClientAccountChange clientAccountChange)
+    {
+        return toAjax(lClientAccountChangeService.updateLClientAccountChange(clientAccountChange));
+    }
+
+    /**
+     * 删除用户钱包余额变更记录
+     */
+    @ApiOperation("删除用户钱包余额变更记录")
+    //@PreAuthorize("@ss.hasPermi('core:change:remove')")
+    @Log(title = "用户钱包余额变更记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{clientAccountChangeIds}")
+    public R<Integer> remove(@PathVariable Long[] clientAccountChangeIds)
+    {
+        return R.ok(lClientAccountChangeService.deleteLClientAccountChangeByClientAccountChangeIds(clientAccountChangeIds));
+    }
+}

+ 43 - 0
leromro-core/src/main/java/com/leromro/core/controller/ClientAccountController.java

@@ -0,0 +1,43 @@
+package com.leromro.core.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.leromro.common.core.controller.BaseController;
+import com.leromro.common.core.domain.R;
+import com.leromro.common.core.page.TableDataInfo;
+import com.leromro.common.utils.SecurityUtils;
+import com.leromro.core.domain.ClientAccount;
+import com.leromro.core.service.impl.ClientAccountServiceImpl;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@Api(tags = "用户账户")
+@RequestMapping("/core/client/account")
+public class ClientAccountController extends BaseController {
+    @Autowired
+    private ClientAccountServiceImpl clientAccountService;
+    /**
+     * 查询受服务地址列表
+     * 传入传入userI
+     */
+    @ApiOperation("查询自己的账户余额")
+    /*    @PreAuthorize("@ss.hasPermi('core:address:list')")*/
+    @GetMapping("/info")
+    public R<ClientAccount> clientAccountInfo(){
+        Long userId = SecurityUtils.getUserId();
+        ClientAccount clientAccount = clientAccountService.getOne(new LambdaQueryWrapper<ClientAccount>().eq(ClientAccount::getUserId,userId));
+        return R.ok(clientAccount);
+    }
+
+
+
+
+
+
+}

+ 1 - 1
leromro-core/src/main/java/com/leromro/core/controller/OrdersController.java

@@ -65,7 +65,7 @@ public class OrdersController extends BaseController {
      */
     @ApiOperation("用户查询订单列表")
     @GetMapping("/mainOrderList")
-    public R<List<MainOrdersVO>> selectOrderList(String orderStatus) {
+    public R<List<MainOrdersVO>> selectOrderList(String[] orderStatus) {
         startPage();
         Long userId = SecurityUtils.getUserId();
         List<MainOrdersVO> list = mainOrderService.selectByUserId(orderStatus, userId);

+ 60 - 0
leromro-core/src/main/java/com/leromro/core/domain/ClientAccountChange.java

@@ -0,0 +1,60 @@
+package com.leromro.core.domain;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.*;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import com.leromro.common.core.domain.BaseEntity;
+
+/**
+ * 用户钱包余额变更记录对象 l_client_account_change
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@TableName("l_client_account_change")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "LClientAccountChange", description = "用户钱包余额变更记录")
+public class ClientAccountChange extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+    private Long clientAccountChangeId;
+
+    @TableField("user_id")
+    @ApiModelProperty("用户id")
+    private Long userId;
+
+    @TableField("change_type")
+    @ApiModelProperty("变更类型 1增加 0减少 ")
+    private String changeType;
+
+    @TableField("source_type")
+    @ApiModelProperty("变更类型,1 订单支出 2订单退款 9钱包充值 10 钱包提现")
+    private String sourceType;
+
+    @TableField("change_money")
+    @ApiModelProperty("变更金额")
+    private BigDecimal changeMoney;
+
+    @TableField("before_balance")
+    @ApiModelProperty("变更前钱包余额")
+    private BigDecimal beforeBalance;
+
+    @TableField("after_balance")
+    @ApiModelProperty("变更后钱包余额")
+    private BigDecimal afterBalance;
+
+    @TableField("main_order_id")
+    @ApiModelProperty("相关主订单id")
+    private Long mainOrderId;
+}

+ 3 - 0
leromro-core/src/main/java/com/leromro/core/domain/OrderRefund.java

@@ -1,5 +1,7 @@
 package com.leromro.core.domain;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.*;
@@ -30,6 +32,7 @@ public class OrderRefund extends BaseEntity {
      */
     @TableField("order_refund_id")
     @ApiModelProperty("主键")
+    @TableId(type = IdType.AUTO)
     private Long orderRefundId;
 
     /**

+ 2 - 2
leromro-core/src/main/java/com/leromro/core/domain/VolunteerAccountChange.java

@@ -39,12 +39,12 @@ public class VolunteerAccountChange extends BaseEntity
     /** 变更类型 1增加0减少 */
     @TableField("change_type")
     @ApiModelProperty("变更类型 1增加0减少")
-    private Integer changeType;
+    private String changeType;
 
     /** 来源类型 1订单收入2评分奖励 10提现支出 */
     @TableField("source_type")
     @ApiModelProperty("来源类型 1订单收入2评分奖励 10提现支出")
-    private Integer sourceType;
+    private String sourceType;
 
     /** 变更金额 */
     @TableField("change_money")

+ 24 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/ClientAccountChangeListVO.java

@@ -0,0 +1,24 @@
+package com.leromro.core.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Getter
+@Setter
+@Data
+public class ClientAccountChangeListVO  {
+
+    @ApiModelProperty("总收入")
+    private List<ClientAccountChangeVO> clientAccountChangeVOlist;
+
+    @ApiModelProperty("总收入")
+    private BigDecimal totalEarning;
+    @ApiModelProperty("总支出")
+    private BigDecimal totalExpend;
+
+}

+ 13 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/ClientAccountChangeVO.java

@@ -0,0 +1,13 @@
+package com.leromro.core.domain.vo;
+
+import com.leromro.core.domain.ClientAccountChange;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ClientAccountChangeVO extends ClientAccountChange {
+    @ApiModelProperty("服务名称")
+    private String businessTierName;
+}

+ 2 - 0
leromro-core/src/main/java/com/leromro/core/domain/vo/WebOrderRefundVO.java

@@ -44,4 +44,6 @@ public class WebOrderRefundVO extends MainOrders {
 
     @ApiModelProperty("退款单号")
     private String orderRefundId;
+    @ApiModelProperty("申请退款时间")
+    private String refundTime;
 }

+ 66 - 0
leromro-core/src/main/java/com/leromro/core/mapper/ClientAccountChangeMapper.java

@@ -0,0 +1,66 @@
+package com.leromro.core.mapper;
+
+import java.util.List;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.leromro.core.domain.ClientAccountChange;
+import com.leromro.core.domain.vo.ClientAccountChangeListVO;
+import com.leromro.core.domain.vo.ClientAccountChangeVO;
+
+/**
+ * 用户钱包余额变更记录Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+public interface ClientAccountChangeMapper extends BaseMapper<ClientAccountChange>
+{
+    /**
+     * 查询用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeId 用户钱包余额变更记录主键
+     * @return 用户钱包余额变更记录
+     */
+    public ClientAccountChange selectLClientAccountChangeByClientAccountChangeId(Long clientAccountChangeId);
+
+    /**
+     * 查询用户钱包余额变更记录列表
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 用户钱包余额变更记录集合
+     */
+    public List<ClientAccountChange> selectLClientAccountChangeList(ClientAccountChange clientAccountChange);
+
+    /**
+     * 新增用户钱包余额变更记录
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 结果
+     */
+    public int insertLClientAccountChange(ClientAccountChange clientAccountChange);
+
+    /**
+     * 修改用户钱包余额变更记录
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 结果
+     */
+    public int updateLClientAccountChange(ClientAccountChange clientAccountChange);
+
+    /**
+     * 删除用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeId 用户钱包余额变更记录主键
+     * @return 结果
+     */
+    public int deleteLClientAccountChangeByClientAccountChangeId(Long clientAccountChangeId);
+
+    /**
+     * 批量删除用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteLClientAccountChangeByClientAccountChangeIds(Long[] clientAccountChangeIds);
+
+    List<ClientAccountChangeVO> selectClientAccountChangebyUserId(Long userId);
+}

+ 1 - 1
leromro-core/src/main/java/com/leromro/core/mapper/MainOrdersMapper.java

@@ -12,7 +12,7 @@ import java.util.List;
 public interface MainOrdersMapper extends BaseMapper<MainOrders> {
      // int insertMainOrders(MainOrders mainOrders);
 
-     List<MainOrdersVO> selectByUserId(@Param("orderStatus") String orderStatus, @Param("userId") Long userId);
+     List<MainOrdersVO> selectByUserId(@Param("orderStatus") String[] orderStatus, @Param("userId") Long userId);
 
     List<webMainOrderListVO> webMainOrderList(MainOrdersVO mainOrdersVO);
 

+ 65 - 0
leromro-core/src/main/java/com/leromro/core/service/IClientAccountChangeService.java

@@ -0,0 +1,65 @@
+package com.leromro.core.service;
+
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.leromro.core.domain.ClientAccountChange;
+import com.leromro.core.domain.vo.ClientAccountChangeListVO;
+
+/**
+ * 用户钱包余额变更记录Service接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+public interface IClientAccountChangeService extends IService<ClientAccountChange>
+{
+    /**
+     * 查询用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeId 用户钱包余额变更记录主键
+     * @return 用户钱包余额变更记录
+     */
+    public ClientAccountChange selectLClientAccountChangeByClientAccountChangeId(Long clientAccountChangeId);
+
+    /**
+     * 查询用户钱包余额变更记录列表
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 用户钱包余额变更记录集合
+     */
+    public List<ClientAccountChange> selectLClientAccountChangeList(ClientAccountChange clientAccountChange);
+
+    /**
+     * 新增用户钱包余额变更记录
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 结果
+     */
+    public Boolean insertLClientAccountChange(ClientAccountChange clientAccountChange);
+
+    /**
+     * 修改用户钱包余额变更记录
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 结果
+     */
+    public Boolean updateLClientAccountChange(ClientAccountChange clientAccountChange);
+
+    /**
+     * 批量删除用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeIds 需要删除的用户钱包余额变更记录主键集合
+     * @return 结果
+     */
+    public int deleteLClientAccountChangeByClientAccountChangeIds(Long[] clientAccountChangeIds);
+
+    /**
+     * 删除用户钱包余额变更记录信息
+     * 
+     * @param clientAccountChangeId 用户钱包余额变更记录主键
+     * @return 结果
+     */
+    public int deleteLClientAccountChangeByClientAccountChangeId(Long clientAccountChangeId);
+
+    ClientAccountChangeListVO selectAccountChangeByuserId(Long userId);
+}

+ 3 - 0
leromro-core/src/main/java/com/leromro/core/service/IClientAccountService.java

@@ -3,8 +3,11 @@ package com.leromro.core.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.leromro.core.domain.ClientAccount;
 
+import java.util.List;
+
 public interface IClientAccountService extends IService<ClientAccount> {
 
     void insertVolunteerAccount(Long userId);
 
+
 }

+ 1 - 1
leromro-core/src/main/java/com/leromro/core/service/IMainOrderService.java

@@ -15,7 +15,7 @@ import com.leromro.core.domain.vo.webMainOrderListVO;
 import java.util.List;
 
 public interface IMainOrderService extends IService<MainOrders> {
-    List<MainOrdersVO> selectByUserId(String orderStatus, Long userId);
+    List<MainOrdersVO> selectByUserId(String[] orderStatus, Long userId);
 
     R<OrderPaymentVO> createOrders(OrderRequestDTO orderRequest);
 

+ 120 - 0
leromro-core/src/main/java/com/leromro/core/service/impl/ClientAccountChangeServiceImpl.java

@@ -0,0 +1,120 @@
+package com.leromro.core.service.impl;
+
+import java.math.BigDecimal;
+import java.util.List;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.leromro.core.domain.vo.ClientAccountChangeListVO;
+import com.leromro.core.domain.vo.ClientAccountChangeVO;
+import com.leromro.core.mapper.ClientAccountChangeMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.leromro.core.domain.ClientAccountChange;
+import com.leromro.core.service.IClientAccountChangeService;
+
+/**
+ * 用户钱包余额变更记录Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-05-07
+ */
+@Service
+public class ClientAccountChangeServiceImpl extends ServiceImpl<ClientAccountChangeMapper, ClientAccountChange> implements IClientAccountChangeService
+{
+    @Autowired
+    private ClientAccountChangeMapper clientAccountChangeMapper;
+
+    /**
+     * 查询用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeId 用户钱包余额变更记录主键
+     * @return 用户钱包余额变更记录
+     */
+    @Override
+    public ClientAccountChange selectLClientAccountChangeByClientAccountChangeId(Long clientAccountChangeId)
+    {
+        return clientAccountChangeMapper.selectLClientAccountChangeByClientAccountChangeId(clientAccountChangeId);
+    }
+
+    /**
+     * 查询用户钱包余额变更记录列表
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 用户钱包余额变更记录
+     */
+    @Override
+    public List<ClientAccountChange> selectLClientAccountChangeList(ClientAccountChange clientAccountChange)
+    {
+        return clientAccountChangeMapper.selectLClientAccountChangeList(clientAccountChange);
+    }
+
+    /**
+     * 新增用户钱包余额变更记录
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 结果
+     */
+    @Override
+    public Boolean insertLClientAccountChange(ClientAccountChange clientAccountChange)
+    {
+        return this.save(clientAccountChange);
+    }
+
+    /**
+     * 修改用户钱包余额变更记录
+     * 
+     * @param clientAccountChange 用户钱包余额变更记录
+     * @return 结果
+     */
+    @Override
+    public Boolean updateLClientAccountChange(ClientAccountChange clientAccountChange)
+    {
+        return this.updateById(clientAccountChange);
+    }
+
+    /**
+     * 批量删除用户钱包余额变更记录
+     * 
+     * @param clientAccountChangeIds 需要删除的用户钱包余额变更记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLClientAccountChangeByClientAccountChangeIds(Long[] clientAccountChangeIds)
+    {
+        return clientAccountChangeMapper.deleteLClientAccountChangeByClientAccountChangeIds(clientAccountChangeIds);
+    }
+
+    /**
+     * 删除用户钱包余额变更记录信息
+     * 
+     * @param clientAccountChangeId 用户钱包余额变更记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteLClientAccountChangeByClientAccountChangeId(Long clientAccountChangeId)
+    {
+        return clientAccountChangeMapper.deleteLClientAccountChangeByClientAccountChangeId(clientAccountChangeId);
+    }
+
+    /**
+     * @param userId
+     * @return
+     */
+    @Override
+    public ClientAccountChangeListVO selectAccountChangeByuserId(Long userId) {
+        ClientAccountChangeListVO clientAccountChangeListVO = new ClientAccountChangeListVO();
+        List<ClientAccountChangeVO> list = clientAccountChangeMapper.selectClientAccountChangebyUserId(userId);
+        clientAccountChangeListVO.setClientAccountChangeVOlist(list);
+        //算出总收入以及总支出
+        BigDecimal totalEarning = list.stream()
+                .filter(vo -> "1".equals(vo.getChangeType()))
+                .map(ClientAccountChangeVO::getChangeMoney)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal totalExpend = list.stream()
+                .filter(vo -> "0".equals(vo.getChangeType()))
+                .map(ClientAccountChangeVO::getChangeMoney)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        clientAccountChangeListVO.setTotalExpend(totalExpend);
+        clientAccountChangeListVO.setTotalEarning(totalEarning);
+        return clientAccountChangeListVO;
+    }
+}

+ 3 - 0
leromro-core/src/main/java/com/leromro/core/service/impl/ClientAccountServiceImpl.java

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 @Service
 public class ClientAccountServiceImpl extends ServiceImpl<ClientAccountMapper, ClientAccount> implements IClientAccountService {
@@ -29,4 +30,6 @@ public class ClientAccountServiceImpl extends ServiceImpl<ClientAccountMapper, C
                     .build());
         }
     }
+
+
 }

+ 9 - 4
leromro-core/src/main/java/com/leromro/core/service/impl/MainOrderServiceImpl.java

@@ -46,13 +46,15 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
     private PlatformFinanceMapper platformFinanceMapper;
     @Autowired
     private AddressMapper addressMapper;
+    @Autowired
+    private ClientAccountChangeMapper clientAccountChangeMapper;
 
     /**
      * @param userId
      * @return
      */
     @Override
-    public List<MainOrdersVO> selectByUserId(String orderStatus, Long userId) {
+    public List<MainOrdersVO> selectByUserId(String[] orderStatus, Long userId) {
 
         List<MainOrdersVO> ordersVOS = mainOrdersMapper.selectByUserId(orderStatus,userId);
         return  ordersVOS;
@@ -88,8 +90,8 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
             BigDecimal totalPrice = orders.getServiceTotalPrice();
             ClientAccount clientAccount = clientAccountMapper.selectBalanceByuserID(userId);
             BigDecimal balanceOld = clientAccount.getBalance();
-            int compared = totalPrice.compareTo(balanceOld);
-            if (compared>0){
+            BigDecimal newBalance = balanceOld.subtract(totalPrice);
+            if (newBalance.compareTo(BigDecimal.ZERO) < 0){
                 throw new RuntimeException("余额不足,支付失败");
             }else {
                 BigDecimal balanceNew = balanceOld.subtract(totalPrice);
@@ -99,7 +101,10 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
             // 余额足够 直接支付 订单状态为已支付
             orders.setOrderStatus("1");
             seconderStatus = "1";
-
+            //向钱包变更记录表中新增 一条购买的数据
+            ClientAccountChange clientAccountChange = ClientAccountChange.builder().userId(userId).changeType("0").sourceType("1").changeMoney(totalPrice).beforeBalance(balanceOld).afterBalance(newBalance).mainOrderId(orderId).build();
+            clientAccountChange.setCreateTime(DateTimeUtil.getNowTime1());
+            clientAccountChangeMapper.insert(clientAccountChange);
         }else if (orders.getPaymentMethod().equals("2")){
             //待完成 微信支付
             System.out.println("微信支付");

+ 95 - 57
leromro-core/src/main/java/com/leromro/core/service/impl/OrderRefundServiceImpl.java

@@ -18,6 +18,7 @@ import com.leromro.core.mapper.*;
 import com.leromro.core.utils.DateTimeUtil;
 import org.apache.commons.math3.stat.inference.OneWayAnova;
 import org.hibernate.validator.internal.constraintvalidators.bv.time.futureorpresent.FutureOrPresentValidatorForReadableInstant;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.leromro.core.service.IOrderRefundService;
@@ -46,6 +47,8 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
     private VolunteerWorkDateMapper workDateMapper;
     @Autowired
     private MainOrdersMapper mainOrdersMapper;
+    @Autowired
+    private ClientAccountChangeMapper clientAccountChangeMapper;
 
     /**
      * 查询订单取消/退款
@@ -91,6 +94,25 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
             //查询小订单表
             QueryWrapper<SecondOrder> secondOrderQueryWrapper = new QueryWrapper<SecondOrder>().eq("main_order_id", mainOrderId);
             List<SecondOrder> secondOrderList = secondOrdersMapper.selectList(secondOrderQueryWrapper);
+            //通过支付方式来判断是余额还是微信 1 是余额  2是微信
+            if (mainOrders.getPaymentMethod().equals("1")){
+                //修改,用户账户表 把钱数加上
+                UpdateWrapper<ClientAccount> clientAccountUpdateWrapper = new UpdateWrapper<ClientAccount>().eq("user_id", mainOrders.getUserId()).setSql("balance = balance + " + totalPrice);
+                clientAccountMapper.update(null, clientAccountUpdateWrapper);
+                //查询用户账余额账户
+                BigDecimal Oldbalance = clientAccountMapper.selectBalanceByuserID(mainOrders.getUserId()).getBalance();
+                BigDecimal newBalance = Oldbalance.add(totalPrice);
+                //由于钱是退到钱包的,所以,向钱包变更记录中添加一条数据
+                ClientAccountChange clientAccountChange = ClientAccountChange.builder().userId(mainOrders.getUserId()).changeType("1").sourceType("2").changeMoney(totalPrice).beforeBalance(totalPrice).afterBalance(newBalance).mainOrderId(mainOrderId).build();
+                clientAccountChange.setCreateTime(DateTimeUtil.getNowTime1());
+                clientAccountChangeMapper.insert(clientAccountChange);
+
+            }else if (mainOrders.getPaymentMethod().equals("2")){
+                // 微信 支付
+
+            }else {
+                throw new RuntimeException("该支付方式还未开通退款功能");
+            }
             //修改志愿者工作时间表
             List<VolunteerReservationTime> volunteerReservationTimeList = secondOrderList.stream().map(secondOrder -> {
                 new VolunteerReservationTime();
@@ -98,11 +120,9 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
             }).collect(Collectors.toList());
             reservationTimeMapper.deleteVolunteerReservationTimeList(volunteerReservationTimeList);
             //修改状态已取消,用主订单Id
-            UpdateWrapper<MainOrders> mainOrderUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", 6);
+            UpdateWrapper<MainOrders> mainOrderUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", "6");
             mainOrdersMapper.update(null, mainOrderUpdateWrapper);
-            //修改,用户账户表 把钱数加上
-            UpdateWrapper<ClientAccount> clientAccountUpdateWrapper = new UpdateWrapper<ClientAccount>().eq("user_id", mainOrders.getUserId()).setSql("balance = balance + " + totalPrice);
-            clientAccountMapper.update(null,clientAccountUpdateWrapper);
+
             //平台资金流水表,扣减调总价。
             List<PlatformFinance> platformFinanceList = secondOrderList.stream().map(secondOrder -> {
                 new PlatformFinance();
@@ -112,8 +132,8 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
             }).collect(Collectors.toList());
             platformFinanceMapper.insertPlatformFinanceList(platformFinanceList);
             //修改,小订单表
-            UpdateWrapper<SecondOrder> secondOrderUpdateWrapper = new UpdateWrapper<SecondOrder>().eq("main_order_id", mainOrderId).set("order_status", 2);
-            secondOrdersMapper.update(null,secondOrderUpdateWrapper);
+            UpdateWrapper<SecondOrder> secondOrderUpdateWrapper = new UpdateWrapper<SecondOrder>().eq("main_order_id", mainOrderId).set("order_status", "6");
+            secondOrdersMapper.update(null, secondOrderUpdateWrapper);
             //志愿者预约时间表 还有 修改志愿者工作日的预约状态。
             //先把志愿者预约状态全部设置为0
             UpdateWrapper<VolunteerWorkDate> volunteerWorkDateUpdateWrapper1 = new UpdateWrapper<VolunteerWorkDate>().eq("volunteer_id", mainOrders.getVolunteerId()).set("has_reservation", 0);
@@ -121,7 +141,7 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
             //然后在查哪一天有预约,然后再把有的设置为1
             QueryWrapper<VolunteerReservationTime> reservationTimeQueryWrapper = new QueryWrapper<VolunteerReservationTime>().eq("volunteer_id", mainOrders.getVolunteerId());
             List<VolunteerReservationTime> reservationTimes = reservationTimeMapper.selectList(reservationTimeQueryWrapper);
-            if (!reservationTimes.isEmpty()){
+            if (!reservationTimes.isEmpty()) {
                 List<LocalDate> reservationDate = reservationTimes.stream().map(VolunteerReservationTime::getReservationDate).collect(Collectors.toList());
                 UpdateWrapper<VolunteerWorkDate> volunteerWorkDateUpdateWrapper12 = new UpdateWrapper<VolunteerWorkDate>().eq("volunteer_id", mainOrders.getVolunteerId()).in("work_date", reservationDate).set("has_reservation", 1);
                 workDateMapper.update(null, volunteerWorkDateUpdateWrapper12);
@@ -136,18 +156,18 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
             orderRefund.setStatus("0");
             orderRefund.setRefundAmount(mainOrders.getServiceOnePrice().multiply(new BigDecimal(mainOrders.getTotalTimes() - mainOrders.getFinishTimes())));
             this.save(orderRefund);
-            UpdateWrapper<MainOrders> mainOrderUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", 5);
+            UpdateWrapper<MainOrders> mainOrderUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", "5");
             mainOrdersMapper.update(null, mainOrderUpdateWrapper);
             return AjaxResult.success("已提交申请");
         } else if (mainOrders.getOrderStatus().equals("4") || mainOrders.getOrderStatus().equals("8")) {
             return AjaxResult.success("订单已全部完成,不可退款");
-        }else if (mainOrders.getOrderStatus().equals("5")) {
+        } else if (mainOrders.getOrderStatus().equals("5")) {
             return AjaxResult.success("订单退款申请正在审核中");
-        }else if (mainOrders.getOrderStatus().equals("6") || mainOrders.getOrderStatus().equals("7")) {
+        } else if (mainOrders.getOrderStatus().equals("6") || mainOrders.getOrderStatus().equals("7")) {
             return AjaxResult.success("订单已退款或部分退款,不可重复退款");
-        }else if (mainOrders.getOrderStatus().equals("0") || mainOrders.getOrderStatus().equals("2")) {
+        } else if (mainOrders.getOrderStatus().equals("0") || mainOrders.getOrderStatus().equals("2")) {
             return AjaxResult.success("订单未支付或支付失败,不可取消");
-        }else{
+        } else {
             return AjaxResult.success("请联系管理员或检查订单状态");
         }
 
@@ -198,7 +218,7 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
         OrderRefundVO refundVO = lOrderRefundMapper.selectOrderRefundInfoByMainOrderId(mainOrderId);
         refundVO.setRefundAmount(refundVO.getServiceOnePrice().multiply(new BigDecimal(refundVO.getTotalTimes() - refundVO.getFinishTimes())));
 
-        QueryWrapper<SecondOrder> secondOrderQueryWrapper = new QueryWrapper<SecondOrder>().eq("main_order_id", mainOrderId).eq("order_status", 1);
+        QueryWrapper<SecondOrder> secondOrderQueryWrapper = new QueryWrapper<SecondOrder>().eq("main_order_id", mainOrderId).eq("order_status", "1");
         List<SecondOrder> secondOrderList = secondOrdersMapper.selectList(secondOrderQueryWrapper);
         refundVO.setSecondOrder(secondOrderList);
         return refundVO;
@@ -215,58 +235,76 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
         //先查订单
         OrderRefund orderRefund = lOrderRefundMapper.selectById(orderRefund1.getOrderRefundId());
         //orderRefund.setStatus(orderRefund1.getStatus());
-
+        BeanUtils.copyProperties(orderRefund1, orderRefund);
         Long mainOrderId = orderRefund.getMainOrderId();
         QueryWrapper<MainOrders> mainOrdersQueryWrapper = new QueryWrapper<MainOrders>().eq("main_order_id", mainOrderId);
         MainOrders mainOrders = mainOrdersMapper.selectOne(mainOrdersQueryWrapper);
-        if (orderRefund.getStatus().equals("2")){
-        //更改状态 更改更新时间,更改审批状态、退款钱数、原因、图片。
+        if (orderRefund.getStatus().equals("2")) {
+            if (mainOrders.getPaymentMethod().equals("1")) {
+                //查询用户账余额账户
+                BigDecimal Oldbalance = clientAccountMapper.selectBalanceByuserID(mainOrders.getUserId()).getBalance();
+                BigDecimal newBalance = Oldbalance.add(orderRefund.getRefundAmount());
+                //向用户余额表中添加一条数据
+                ClientAccountChange clientAccountChange = ClientAccountChange.builder().userId(mainOrders.getUserId()).changeType("1").sourceType("2").changeMoney(orderRefund.getRefundAmount()).beforeBalance(Oldbalance).afterBalance(newBalance).mainOrderId(mainOrderId).build();
+                clientAccountChange.setCreateTime(DateTimeUtil.getNowTime1());
+                clientAccountChangeMapper.insert(clientAccountChange);
+                //恢复用户余额,用户账户表增加钱数
+                UpdateWrapper<ClientAccount> clientAccountUpdateWrapper = new UpdateWrapper<ClientAccount>().eq("user_id", mainOrders.getUserId()).setSql("balance = balance + " + orderRefund.getRefundAmount());
+                clientAccountMapper.update(null, clientAccountUpdateWrapper);
+            } else if (mainOrders.getPaymentMethod().equals("2")) {
+                //微信退款
+            }else {
+                throw new RuntimeException("该支付方式还未开通退款功能");
+            }
+            //更改状态 更改更新时间,更改审批状态、退款钱数、原因、图片。
             orderRefund.setUpdateTime(DateTimeUtil.getNowTime());
-        lOrderRefundMapper.updateLOrderRefund(orderRefund);
-        //小订单修改状态,并且
-        QueryWrapper<SecondOrder> secondOrderQueryWrapper = new QueryWrapper<SecondOrder>().eq("main_order_id", mainOrderId).eq("order_status", 1);
-        List<SecondOrder> secondOrderList = secondOrdersMapper.selectList(secondOrderQueryWrapper);
-        List<Long> secondOrderIdList = secondOrderList.stream().map(SecondOrder::getSecondOrderId).collect(Collectors.toList());
-        UpdateWrapper<SecondOrder> secondOrderUpdateWrapper = new UpdateWrapper<SecondOrder>().in("second_order_id", secondOrderIdList).eq("order_status", 1).set("order_status", 6);
-        secondOrdersMapper.update(null, secondOrderUpdateWrapper);
-        //根据小订单,删除志愿者预约时间表
-        List<VolunteerReservationTime> volunteerReservationTimeList = secondOrderList.stream().map(secondOrder -> {
-            new VolunteerReservationTime();
-            return VolunteerReservationTime.builder().volunteerId(secondOrder.getVolunteerId()).reservationDate(secondOrder.getWorkDate()).reservationTime(secondOrder.getWorkStartTime()).build();
-        }).collect(Collectors.toList());
-        reservationTimeMapper.deleteVolunteerReservationTimeList(volunteerReservationTimeList);
-        //修改志愿者工作日的预约状态。 1先把志愿者预约状态全部设置为0 然后在查哪一天有预约,然后再把有的设置为1
-        UpdateWrapper<VolunteerWorkDate> volunteerWorkDateUpdateWrapper = new UpdateWrapper<VolunteerWorkDate>().eq("volunteer_id", mainOrders.getVolunteerId()).set("has_reservation", 0);
-        workDateMapper.update(null, volunteerWorkDateUpdateWrapper);
-        QueryWrapper<VolunteerReservationTime> reservationTimeQueryWrapper = new QueryWrapper<VolunteerReservationTime>().eq("volunteer_id", mainOrders.getVolunteerId());
-        List<VolunteerReservationTime> reservationTimes = reservationTimeMapper.selectList(reservationTimeQueryWrapper);
-        if (!reservationTimes.isEmpty()){
-            List<LocalDate> reservationDate = reservationTimes.stream().map(VolunteerReservationTime::getReservationDate).collect(Collectors.toList());
-            UpdateWrapper<VolunteerWorkDate> volunteerWorkDateUpdateWrapper1 = new UpdateWrapper<VolunteerWorkDate>().eq("volunteer_id", mainOrders.getVolunteerId()).in("work_date", reservationDate).set("has_reservation", 0);
-            workDateMapper.update(null, volunteerWorkDateUpdateWrapper1);
-        }
-        //向平台流水表更改,减少其中的流水;
-        List<PlatformFinance> platformFinanceList = secondOrderList.stream().map(secondOrder -> {
-            new PlatformFinance();
-            return PlatformFinance.builder()
-                    .changeMoney(secondOrder.getServiceOnePrice()).changeType(0).moneyType(1).sourceType(2).secondOrderId(secondOrder.getSecondOrderId()).volunteerId(secondOrder.getVolunteerId())
-                    .build();
-        }).collect(Collectors.toList());
-        platformFinanceMapper.insertPlatformFinanceList(platformFinanceList);
-        //恢复用户余额,用户账户表增加钱数
-        UpdateWrapper<ClientAccount> clientAccountUpdateWrapper = new UpdateWrapper<ClientAccount>().eq("user_id", mainOrders.getUserId()).setSql("balance = balance + " + orderRefund.getRefundAmount());
-        clientAccountMapper.update(null, clientAccountUpdateWrapper);
-        //主订单修改状态
-        UpdateWrapper<MainOrders> mainOrdersMapperUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", 7);
-        mainOrdersMapper.update(null, mainOrdersMapperUpdateWrapper);
-        }else if (orderRefund.getStatus().equals("3")){
+            lOrderRefundMapper.updateLOrderRefund(orderRefund);
+            //小订单修改状态,并且
+            QueryWrapper<SecondOrder> secondOrderQueryWrapper = new QueryWrapper<SecondOrder>().eq("main_order_id", mainOrderId).eq("order_status", "1");
+            List<SecondOrder> secondOrderList = secondOrdersMapper.selectList(secondOrderQueryWrapper);
+            List<Long> secondOrderIdList = secondOrderList.stream().map(SecondOrder::getSecondOrderId).collect(Collectors.toList());
+            UpdateWrapper<SecondOrder> secondOrderUpdateWrapper = new UpdateWrapper<SecondOrder>().in("second_order_id", secondOrderIdList).set("order_status", "6");
+            secondOrdersMapper.update(null, secondOrderUpdateWrapper);
+            //根据小订单,删除志愿者预约时间表
+            List<VolunteerReservationTime> volunteerReservationTimeList = secondOrderList.stream().map(secondOrder -> {
+                new VolunteerReservationTime();
+                return VolunteerReservationTime.builder().volunteerId(secondOrder.getVolunteerId()).reservationDate(secondOrder.getWorkDate()).reservationTime(secondOrder.getWorkStartTime()).build();
+            }).collect(Collectors.toList());
+            reservationTimeMapper.deleteVolunteerReservationTimeList(volunteerReservationTimeList);
+            //修改志愿者工作日的预约状态。 1先把志愿者预约状态全部设置为0 然后在查哪一天有预约,然后再把有的设置为1
+            UpdateWrapper<VolunteerWorkDate> volunteerWorkDateUpdateWrapper = new UpdateWrapper<VolunteerWorkDate>().eq("volunteer_id", mainOrders.getVolunteerId()).set("has_reservation", 0);
+            workDateMapper.update(null, volunteerWorkDateUpdateWrapper);
+            QueryWrapper<VolunteerReservationTime> reservationTimeQueryWrapper = new QueryWrapper<VolunteerReservationTime>().eq("volunteer_id", mainOrders.getVolunteerId());
+            List<VolunteerReservationTime> reservationTimes = reservationTimeMapper.selectList(reservationTimeQueryWrapper);
+            if (!reservationTimes.isEmpty()) {
+                List<LocalDate> reservationDate = reservationTimes.stream().map(VolunteerReservationTime::getReservationDate).collect(Collectors.toList());
+                UpdateWrapper<VolunteerWorkDate> volunteerWorkDateUpdateWrapper1 = new UpdateWrapper<VolunteerWorkDate>().eq("volunteer_id", mainOrders.getVolunteerId()).in("work_date", reservationDate).set("has_reservation", 0);
+                workDateMapper.update(null, volunteerWorkDateUpdateWrapper1);
+            }
+            //向平台流水表更改,减少其中的流水;
+            List<PlatformFinance> platformFinanceList = secondOrderList.stream().map(secondOrder -> {
+                new PlatformFinance();
+                return PlatformFinance.builder()
+                        .changeMoney(secondOrder.getServiceOnePrice()).changeType(0).moneyType(1).sourceType(2).secondOrderId(secondOrder.getSecondOrderId()).volunteerId(secondOrder.getVolunteerId())
+                        .build();
+            }).collect(Collectors.toList());
+            platformFinanceMapper.insertPlatformFinanceList(platformFinanceList);
+
+            //主订单修改状态
+            UpdateWrapper<MainOrders> mainOrdersMapperUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", 7);
+            mainOrdersMapper.update(null, mainOrdersMapperUpdateWrapper);
+
+
+        } else if (orderRefund.getStatus().equals("3")) {
+            //不通过
+            orderRefund.setRefundApplyAmount(orderRefund.getRefundAmount());
             orderRefund.setRefundAmount(BigDecimal.valueOf(0));
             orderRefund.setUpdateTime(DateTimeUtil.getNowTime());
             //主订单修改状态 返回之前的状态
-            if(mainOrders.getTotalTimes()==mainOrders.getFinishTimes()){
+            if (mainOrders.getTotalTimes() == mainOrders.getFinishTimes()) {
                 UpdateWrapper<MainOrders> mainOrdersMapperUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", 4);
                 mainOrdersMapper.update(null, mainOrdersMapperUpdateWrapper);
-            }else {
+            } else {
                 UpdateWrapper<MainOrders> mainOrdersMapperUpdateWrapper = new UpdateWrapper<MainOrders>().eq("main_order_id", mainOrderId).set("order_status", 3);
                 mainOrdersMapper.update(null, mainOrdersMapperUpdateWrapper);
             }
@@ -281,6 +319,6 @@ public class OrderRefundServiceImpl extends ServiceImpl<OrderRefundMapper, Order
      */
     @Override
     public List<WebOrderRefundVO> selectWebOrderRefundList(MainOrders mainOrders) {
-        return  lOrderRefundMapper.selectWebOrderRefundList(mainOrders);
+        return lOrderRefundMapper.selectWebOrderRefundList(mainOrders);
     }
 }

+ 124 - 0
leromro-core/src/main/resources/mapper/core/ClientAccountChangeMapper.xml

@@ -0,0 +1,124 @@
+<?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.leromro.core.mapper.ClientAccountChangeMapper">
+
+    <resultMap type="ClientAccountChange" id="ClientAccountChangeResult">
+        <result property="clientAccountChangeId"    column="client_account_change_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="changeType"    column="change_type"    />
+        <result property="sourceType"    column="source_type"    />
+        <result property="changeMoney"    column="change_money"    />
+        <result property="beforeBalance"    column="before_balance"    />
+        <result property="afterBalance"    column="after_balance"    />
+        <result property="mainOrderId"    column="main_order_id"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectLClientAccountChangeVo">
+        select client_account_change_id, user_id, change_type, source_type, change_money, before_balance, after_balance,main_order_id, create_by, create_time, update_by, remark from l_client_account_change
+    </sql>
+
+    <select id="selectClientAccountChangebyUserId" resultType="com.leromro.core.domain.vo.ClientAccountChangeVO"
+            parameterType="java.lang.Long">
+        select lcac.user_id,
+               lcac.create_time,
+               lcac.source_type,
+               lcac.change_type,
+               lcac.change_money,
+               lcac.main_order_id,
+               lmo.business_management_id,
+               (select business_tier_name
+                from l_business_management lbm
+                where lmo.business_management_id = lbm.business_management_id) as business_tier_name
+        from l_client_account_change lcac
+                 left join l_main_orders lmo
+                           on lcac.main_order_id = lmo.main_order_id
+        where lcac.user_id = #{userId}
+
+    </select>
+
+
+    <select id="selectLClientAccountChangeList" parameterType="ClientAccountChange" resultMap="ClientAccountChangeResult">
+        <include refid="selectLClientAccountChangeVo"/>
+        <where>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="changeType != null  and changeType != ''"> and change_type = #{changeType}</if>
+            <if test="sourceType != null  and sourceType != ''"> and source_type = #{sourceType}</if>
+            <if test="changeMoney != null "> and change_money = #{changeMoney}</if>
+            <if test="beforeBalance != null "> and before_balance = #{beforeBalance}</if>
+            <if test="afterBalance != null "> and after_balance = #{afterBalance}</if>
+        </where>
+    </select>
+
+    <select id="selectLClientAccountChangeByClientAccountChangeId" parameterType="Long" resultMap="ClientAccountChangeResult">
+        <include refid="selectLClientAccountChangeVo"/>
+        where client_account_change_id = #{clientAccountChangeId}
+    </select>
+
+
+
+
+    <insert id="insertLClientAccountChange" parameterType="ClientAccountChange" useGeneratedKeys="true" keyProperty="clientAccountChangeId">
+        insert into l_client_account_change
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="changeType != null">change_type,</if>
+            <if test="sourceType != null">source_type,</if>
+            <if test="changeMoney != null">change_money,</if>
+            <if test="beforeBalance != null">before_balance,</if>
+            <if test="afterBalance != null">after_balance,</if>
+            <if test="mainOrderId != null">main_order_id,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="changeType != null">#{changeType},</if>
+            <if test="sourceType != null">#{sourceType},</if>
+            <if test="changeMoney != null">#{changeMoney},</if>
+            <if test="beforeBalance != null">#{beforeBalance},</if>
+            <if test="afterBalance != null">#{afterBalance},</if>
+            <if test="mainOrderId != null">#{mainOrderId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateLClientAccountChange" parameterType="ClientAccountChange">
+        update l_client_account_change
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="changeType != null">change_type = #{changeType},</if>
+            <if test="sourceType != null">source_type = #{sourceType},</if>
+            <if test="changeMoney != null">change_money = #{changeMoney},</if>
+            <if test="beforeBalance != null">before_balance = #{beforeBalance},</if>
+            <if test="afterBalance != null">after_balance = #{afterBalance},</if>
+            <if test="mainOrderId != null">main_order_id = #{mainOrderId},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where client_account_change_id = #{clientAccountChangeId}
+    </update>
+
+    <delete id="deleteLClientAccountChangeByClientAccountChangeId" parameterType="Long">
+        delete from l_client_account_change where client_account_change_id = #{clientAccountChangeId}
+    </delete>
+
+    <delete id="deleteLClientAccountChangeByClientAccountChangeIds" parameterType="String">
+        delete from l_client_account_change where client_account_change_id in
+        <foreach item="clientAccountChangeId" collection="array" open="(" separator="," close=")">
+            #{clientAccountChangeId}
+        </foreach>
+    </delete>
+</mapper>

leromro-core/src/main/resources/mapper/core/OrgStatDataMapper.xml → leromro-core/src/main/resources/mapper/core/IClientAccountChangeService.xml


+ 6 - 3
leromro-core/src/main/resources/mapper/core/MainOrdersMapper.xml

@@ -117,7 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isDelete != null">#{isDelete},</if>
          </trim>
     </insert>-->
-    <update id="startService" parameterType="java.lang.String">
+    <update id="startService" parameterType="java.lang.Long">
         update l_main_orders set order_status = 3 where main_order_id = (select main_order_id from l_second_order where second_order_id = #{secondOrderId});
     </update>
     <select id="selectByUserId" resultType="com.leromro.core.domain.vo.MainOrdersVO">
@@ -125,7 +125,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         lmo.*,lvi.name ,lvi.volunteer_picture as volunteerPicture,lvi.skill_describe,lvi.business_tier_name from  l_main_orders lmo left join l_volunteer_info lvi on lmo.volunteer_info_id = lvi.volunteer_info_id
         <where>
             <if test="orderStatus != null and orderStatus != ''">
-                and order_status = #{orderStatus}
+                AND order_status IN
+                <foreach item="status" collection="orderStatus" open="(" separator="," close=")">
+                    #{status}
+                </foreach>
             </if>
             <if test="userId != null">
                 and user_id = #{userId}
@@ -146,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by create_time desc
     </select>
     <select id="selectWebMainOrderInfoVO" resultType="com.leromro.core.domain.vo.WebMainOrdersInfoVO"
-            parameterType="java.lang.String">
+            parameterType="java.lang.Long">
         select lmo.*,
                lvi.name              as VolunteerName,
                lvi.phonenumber       as VolunteerTelephone,

+ 5 - 6
leromro-core/src/main/resources/mapper/core/OrderRefundMapper.xml

@@ -64,8 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     
     <select id="selectLOrderRefundByOrderRefundId" parameterType="Long" resultMap="LOrderRefundResult">
-        <include refid="selectLOrderRefundVo"/>
-        where order_refund_id = #{orderRefundId}
+       select * from l_order_refund
+       where order_refund_id = #{orderRefundId}
     </select>
     <select id="selectOrderRefundInfoByMainOrderId" resultType="com.leromro.core.domain.vo.OrderRefundVO"
             parameterType="java.lang.Long">
@@ -80,13 +80,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="selectWebOrderRefundList" resultType="com.leromro.core.domain.vo.WebOrderRefundVO"
             parameterType="com.leromro.core.domain.MainOrders">
-        select lmo.*, lor.refund_apply_amount,lor.status,lor.refund_amount, lor.refund_reason,lor.order_refund_id,lor.status as orderRefundStatus ,
+        select lmo.*, lor.refund_apply_amount,lor.status,lor.refund_amount, lor.refund_reason,lor.order_refund_id,lor.status as orderRefundStatus ,lor.create_time as refundTime,
         lor.refund_picture,(select business_tier_name from l_business_management lbm where lmo.business_management_id = lbm.business_management_id) as  businessTierName,
         (select name from l_volunteer_info lvi where lmo.volunteer_info_id = lvi.volunteer_info_id) as volunteerName
-        from l_main_orders lmo
-        left join l_order_refund lor on lmo.main_order_id = lor.main_order_id
+        from l_order_refund lor
+        left join  l_main_orders lmo on lmo.main_order_id = lor.main_order_id
         <where>
-            lmo.order_status = '5' or lmo.order_status ='6' or lmo.order_status ='7'
             <if test="clientName != null and clientName != ''">and lmo.client_name = #{clientName}</if>
             <if test="clientTelephone != null and clientTelephone != ''">and lmo.clien_telephone = #{clientTelephone}</if>
             <if test="businessManagementId != null and businessManagementId != ''">and lmo.business_management_id = #{businessManagementId}</if>

leromro-system/src/main/resources/mapper/system/SysDictDataMapper.xml → leromro-system/src/main/resources/mapper/system/IClientAccountChangeService.xml