lsw il y a 1 an
Parent
commit
0a7be2b3b4

+ 31 - 4
admin-ui/src/assets/styles/extend.scss

@@ -28,6 +28,7 @@
   font-size: 17px;
   position: relative;
   margin-bottom: 20px;
+  z-index: 1;
   .bsg {
     position: absolute;
     width: 4px;
@@ -40,6 +41,7 @@
     margin-left: 10px;
     color: #545555;
     font-weight: bold;
+    z-index: 1;
     .gx {
       font-size: 12px;
       padding-left: 20px;
@@ -450,9 +452,34 @@
     }
   }
 }
-.mar0{
-  margin-right: 0px!important;
+.mar0 {
+  margin-right: 0px !important;
 }
-.mal0{
-  margin-left: 0px!important;
+.mal0 {
+  margin-left: 0px !important;
+}
+.years {
+  float: right;
+  margin-top: -40px;
+  overflow: hidden;
+  z-index: 111;
+  position: relative;
+  .dpicker {
+    float: left;
+    width: 150px;
+    border-radius: 0px;
+    margin-right: 5px;
+  }
+  .year {
+    float: left;
+    padding: 7px 15px;
+    background-color: #f6f6f6;
+    cursor: pointer;
+    font-size: 15px;
+    color: #545555;
+    &.active {
+      background-color: rgb(64, 158, 255);
+      color: white;
+    }
+  }
 }

+ 5 - 5
admin-ui/src/views/dashboard/BarChart.vue

@@ -77,7 +77,7 @@ export default {
       let seriesData = [];
       if (chartData) {
         chartData.forEach((item, index) => {
-          xAxisData.push(item.name);
+          xAxisData.push(item.name+'月');
           seriesData.push(item.value);
         });
       }
@@ -94,9 +94,9 @@ export default {
           data: [this.legend]
         },
         grid: {
-          top: '15%',
-          left: '2%',
-          right: '2%',
+          top: '13%',
+          left: '0%',
+          right: '0%',
           bottom: '2%',
           containLabel: true,
           show: false
@@ -180,7 +180,7 @@ export default {
                     color: '#545555',
                     fontSize: 14
                   },
-                  formatter: '{c}%'
+                  formatter: '{c}'
                 }
               }
             }

+ 41 - 2
admin-ui/src/views/index_company.vue

@@ -26,6 +26,21 @@
             </div>
           </div>
         </div>
+        <div class="out">
+          <div class="int">
+            <div class="bos">
+              <div class="lab">
+                <div class="bsg"></div>
+                <div class="tit">交易金额统计</div>
+              </div>
+              <div class="years">
+                <el-date-picker class="dpicker" :clearable="false" v-model="year" type="year" value-format="yyyy" placeholder="请选择年份"></el-date-picker>
+                <div class="year" :class="{ active: current == index }" @click="current = index" v-for="(item, index) in type" :key="index">{{ item.name }}</div>
+              </div>
+              <BarChart :chartData="chartData" height="270px"></BarChart>
+            </div>
+          </div>
+        </div>
       </div>
       <!--通知消息-->
       <div class="pop" style="width: 35%">
@@ -66,20 +81,39 @@
 import noticeDetail from '@/views/work/notice/detail';
 import top from '@/views/dashboard/top';
 import yrows from '@/views/dashboard/yrows';
+import BarChart from './dashboard/BarChart';
 export default {
   components: {
     top,
-    yrows
+    yrows,
+    BarChart
   },
   data() {
     return {
       user: this.$store.state.user,
       noticeList: [],
-      data: {}
+      data: {},
+      current: 0,
+      chartData: [],
+      year: this.util.getDate('year'),
+      type: [
+        { name: '充值金额', value: 0 },
+        { name: '提现金额', value: 1 },
+        { name: '发放金额', value: 2 }
+      ]
     };
   },
+  watch: {
+    current(val) {
+      this.getRecord();
+    },
+    year(val) {
+      this.getRecord();
+    }
+  },
   created() {
     this.getData();
+    this.getRecord();
   },
   methods: {
     getData() {
@@ -90,6 +124,11 @@ export default {
         this.noticeList = response.data;
       });
     },
+    getRecord() {
+      this.ajax({ url: '/work/company/statistics/chart', data: { year: this.year, type: this.current } }).then((response) => {
+        this.chartData = response.data;
+      });
+    },
     op(tag, row) {
       if (tag == 'noticeDetail') {
         this.iframe({ obj: noticeDetail, param: { id: row.id }, title: row.title, width: '58%', height: '75%' });

+ 8 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/controller/CompanyController.java

@@ -9,6 +9,7 @@ import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.web.work.domain.Company;
 import com.ruoyi.web.work.domain.dto.LockDto;
+import com.ruoyi.web.work.domain.dto.StatisticsDto;
 import com.ruoyi.web.work.mapper.CommonMapper;
 import com.ruoyi.web.work.service.ICompanyService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,10 +48,16 @@ public class CompanyController extends BaseController {
 
     @GetMapping("/statistics")
     public AjaxResult statistics() {
-        Map<String, Object> company=commonMapper.company(getLoginUser().getUser().getCompanyId());
+        Map<String, Object> company = commonMapper.company(getLoginUser().getUser().getCompanyId());
         return AjaxResult.success(company);
     }
 
+    @GetMapping("/statistics/chart")
+    public AjaxResult statistics_chart(@Validated StatisticsDto dto) {
+        dto.setCompanyId(getLoginUser().getUser().getCompanyId());
+        return AjaxResult.success(commonMapper.record(dto));
+    }
+
     @GetMapping("/index")
     public AjaxResult index() {
         Company company = companyService.getById(getLoginUser().getUser().getCompanyId());

+ 62 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/controller/RecordController.java

@@ -0,0 +1,62 @@
+package com.ruoyi.web.work.controller;
+
+import com.ruoyi.common.annotation.Log;
+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.enums.BusinessType;
+import com.ruoyi.web.work.domain.Record;
+import com.ruoyi.web.work.service.IRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 资金交易记录
+ * @author lsw
+ * @date 2024-04-26
+ */
+@RestController
+@RequestMapping("/work/record")
+public class RecordController extends BaseController {
+    @Autowired
+    private IRecordService recordService;
+
+    @PreAuthorize("@ss.hasPermi('work:record:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Record record){
+        startPage();
+        List<Record> list = recordService.selectList(record);
+        return getDataTable(list);
+    }
+
+    @PreAuthorize("@ss.hasPermi('work:record:query')")
+    @GetMapping(value = "/detail/{id}")
+    public AjaxResult detail(@PathVariable("id") Long id){
+        return AjaxResult.success(recordService.getById(id));
+    }
+
+    @PreAuthorize("@ss.hasPermi('work:record:add')")
+    @Log(title = "资金交易记录", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody Record record){
+        return toAjax(recordService.save(record));
+    }
+
+    @PreAuthorize("@ss.hasPermi('work:record:edit')")
+    @Log(title = "资金交易记录", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    public AjaxResult edit(@RequestBody Record record){
+        return toAjax(recordService.updateById(record));
+    }
+
+    @PreAuthorize("@ss.hasPermi('work:record:remove')")
+    @Log(title = "资金交易记录", businessType = BusinessType.DELETE)
+    @GetMapping("/remove/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids){
+        return toAjax(recordService.removeByIds(Arrays.asList(ids)));
+    }
+}

+ 41 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/Record.java

@@ -0,0 +1,41 @@
+package com.ruoyi.web.work.domain;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.experimental.Accessors;
+/**
+ * @author lsw
+ * @date 2024-04-26
+ */
+@Data
+@TableName(value = "tb_record")
+@Accessors(chain = true)
+public class Record{
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    @ApiModelProperty(value = "关联企业")
+    private Long companyId;
+
+    @ApiModelProperty(value = "关联充值")
+    private Long opId;
+
+    @ApiModelProperty(value = "交易类型")
+    private Integer type;
+
+    @ApiModelProperty(value = "金额")
+    private BigDecimal money;
+
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+
+}

+ 20 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/StatisticsDto.java

@@ -0,0 +1,20 @@
+package com.ruoyi.web.work.domain.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(chain = true)
+public class StatisticsDto {
+
+    private Long companyId;
+
+    @NotNull(message = "参数错误")
+    private Integer type;
+
+    @NotBlank(message = "参数错误")
+    private String year;
+}

+ 17 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/CommonMapper.java

@@ -1,11 +1,27 @@
 package com.ruoyi.web.work.mapper;
 
-import org.apache.ibatis.annotations.Param;
+import com.ruoyi.web.work.domain.dto.StatisticsDto;
+import io.lettuce.core.dynamic.annotation.Param;
 
+import java.util.List;
 import java.util.Map;
 
 
 public interface CommonMapper {
 
+    /**
+     * 后台企业端每月交易金额统计
+     *
+     * @param companyId
+     * @return
+     */
     Map<String, Object> company(@Param("companyId") Long companyId);
+
+    /**
+     * 后台企业端每月交易金额统计
+     *
+     * @param dto
+     * @return
+     */
+    List<Map<String, Object>> record(StatisticsDto dto);
 }

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/RecordMapper.java

@@ -0,0 +1,13 @@
+package com.ruoyi.web.work.mapper;
+
+import java.util.List;
+import com.ruoyi.web.work.domain.Record;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @author lsw
+ * @date 2024-04-26
+ */
+public interface RecordMapper extends BaseMapper<Record> {
+    List<Record> selectList(Record record);
+}

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/IRecordService.java

@@ -0,0 +1,13 @@
+package com.ruoyi.web.work.service;
+
+import java.util.List;
+import com.ruoyi.web.work.domain.Record;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @author lsw
+ * @date 2024-04-26
+ */
+public interface IRecordService extends IService<Record>{
+    List<Record> selectList(Record record);
+}

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/MoneyOutServiceImpl.java

@@ -6,11 +6,13 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.web.work.domain.Company;
 import com.ruoyi.web.work.domain.MoneyOut;
+import com.ruoyi.web.work.domain.Record;
 import com.ruoyi.web.work.domain.dto.MoneyOutDto;
 import com.ruoyi.web.work.mapper.MoneyOutMapper;
 import com.ruoyi.web.work.service.ICommonService;
 import com.ruoyi.web.work.service.ICompanyService;
 import com.ruoyi.web.work.service.IMoneyOutService;
+import com.ruoyi.web.work.service.IRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -33,6 +35,9 @@ public class MoneyOutServiceImpl extends ServiceImpl<MoneyOutMapper, MoneyOut> i
     @Autowired
     private ICommonService commonService;
 
+    @Autowired
+    private IRecordService recordService;
+
     @Override
     public List<MoneyOut> selectList(MoneyOut moneyOut) {
         return moneyOutMapper.selectList(moneyOut);
@@ -85,6 +90,14 @@ public class MoneyOutServiceImpl extends ServiceImpl<MoneyOutMapper, MoneyOut> i
             if (!companyService.updateById(company)) {
                 throw new ServerException("更新企业余额失败,请联系管理员");
             }
+            Record record=new Record();
+            record.setType(1);
+            record.setCompanyId(moneyOut.getCompanyId());
+            record.setOpId(moneyOut.getId());
+            record.setMoney(moneyOut.getMoney());
+            if (!recordService.save(record)) {
+                throw new ServerException("添加提现记录失败,请联系管理员");
+            }
         }
         return AjaxResult.success();
     }

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/RechargeServiceImpl.java

@@ -6,10 +6,12 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.web.work.domain.Company;
 import com.ruoyi.web.work.domain.Recharge;
+import com.ruoyi.web.work.domain.Record;
 import com.ruoyi.web.work.domain.dto.RechargeDto;
 import com.ruoyi.web.work.mapper.RechargeMapper;
 import com.ruoyi.web.work.service.ICompanyService;
 import com.ruoyi.web.work.service.IRechargeService;
+import com.ruoyi.web.work.service.IRecordService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -29,6 +31,9 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
     @Autowired
     private ICompanyService companyService;
 
+    @Autowired
+    private IRecordService recordService;
+
     @Override
     public List<Recharge> selectList(Recharge recharge) {
         return rechargeMapper.selectList(recharge);
@@ -74,6 +79,14 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
             if (!companyService.updateById(company)) {
                 throw new ServerException("更新企业余额失败,请联系管理员");
             }
+            Record record=new Record();
+            record.setType(0);
+            record.setCompanyId(recharge.getCompanyId());
+            record.setOpId(recharge.getId());
+            record.setMoney(recharge.getMoney());
+            if (!recordService.save(record)) {
+                throw new ServerException("添加充值记录失败,请联系管理员");
+            }
         }
         return AjaxResult.success();
     }

+ 24 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/RecordServiceImpl.java

@@ -0,0 +1,24 @@
+package com.ruoyi.web.work.service.impl;
+
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.web.work.mapper.RecordMapper;
+import com.ruoyi.web.work.domain.Record;
+import com.ruoyi.web.work.service.IRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @author lsw
+ * @date 2024-04-26
+ */
+@Service
+public class RecordServiceImpl extends ServiceImpl<RecordMapper, Record> implements IRecordService {
+    @Autowired
+    private RecordMapper recordMapper;
+
+    @Override
+    public List<Record> selectList(Record record) {
+        return recordMapper.selectList(record);
+    }
+}

+ 15 - 10
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/StatementServiceImpl.java

@@ -8,18 +8,12 @@ import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanValidators;
-import com.ruoyi.web.work.domain.Company;
-import com.ruoyi.web.work.domain.Platform;
-import com.ruoyi.web.work.domain.Statement;
-import com.ruoyi.web.work.domain.StatementDetail;
+import com.ruoyi.web.work.domain.*;
 import com.ruoyi.web.work.domain.dto.RejectDto;
 import com.ruoyi.web.work.domain.dto.StatementDto;
 import com.ruoyi.web.work.mapper.StatementDetailMapper;
 import com.ruoyi.web.work.mapper.StatementMapper;
-import com.ruoyi.web.work.service.ICommonService;
-import com.ruoyi.web.work.service.ICompanyService;
-import com.ruoyi.web.work.service.IStatementDetailService;
-import com.ruoyi.web.work.service.IStatementService;
+import com.ruoyi.web.work.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -57,6 +51,9 @@ public class StatementServiceImpl extends ServiceImpl<StatementMapper, Statement
     @Autowired
     private ICommonService commonService;
 
+    @Autowired
+    private IRecordService recordService;
+
     @Override
     public List<Statement> selectList(Statement statement) {
         return statementMapper.selectList(statement);
@@ -233,9 +230,9 @@ public class StatementServiceImpl extends ServiceImpl<StatementMapper, Statement
         return AjaxResult.success();
     }
 
-    @Transactional(rollbackFor = Exception.class)
+    @Transactional
     @Override
-    public AjaxResult payOk(Long id){
+    public AjaxResult payOk(Long id) throws ServerException {
         Statement statement = statementMapper.calculate(id);
         if (statement == null) {
             return AjaxResult.error("发放业务不存在");
@@ -261,6 +258,14 @@ public class StatementServiceImpl extends ServiceImpl<StatementMapper, Statement
         if (!statementDetailMapper.updateState(statement.getId())) {
             throw new ServiceException("更新结算单失败,请联系管理员");
         }
+        Record record=new Record();
+        record.setType(2);
+        record.setCompanyId(statement.getCompanyId());
+        record.setOpId(statement.getId());
+        record.setMoney(statement.getMoney());
+        if (!recordService.save(record)) {
+            throw new ServerException("添加发放记录失败,请联系管理员");
+        }
         return AjaxResult.success();
     }
 }

+ 30 - 0
ruoyi-admin/src/main/resources/mapper/work/CommonMapper.xml

@@ -16,5 +16,35 @@
                 ( SELECT SUM( service_money ) FROM tb_statement WHERE give = 2 AND company_id =#{companyId} ) AS serviceMoney,
                 ( SELECT SUM( peoples ) FROM tb_statement WHERE give = 2 AND company_id =#{companyId} ) AS peoples
     </select>
+    <!--后台企业端每月交易金额统计-->
+    <select id="record" resultType="java.util.Map">
+        SELECT
+            months.month AS name,
+            SUM(tb_record.money) AS value
+        FROM
+            (
+            SELECT 1 AS month UNION ALL
+            SELECT 2 AS month UNION ALL
+            SELECT 3 AS month UNION ALL
+            SELECT 4 AS month UNION ALL
+            SELECT 5 AS month UNION ALL
+            SELECT 6 AS month UNION ALL
+            SELECT 7 AS month UNION ALL
+            SELECT 8 AS month UNION ALL
+            SELECT 9 AS month UNION ALL
+            SELECT 10 AS month UNION ALL
+            SELECT 11 AS month UNION ALL
+            SELECT 12 AS month
+            ) AS months
+            LEFT JOIN
+            tb_record ON
+            MONTH(tb_record.create_time) = months.month AND YEAR(tb_record.create_time) =#{year}
+            AND tb_record.company_id=#{companyId} AND tb_record.type=#{type}
+        GROUP BY
+            months.month
+        ORDER BY
+            months.month
+    </select>
+
 
 </mapper>