xiongzhu 3 年之前
父節點
當前提交
06e29b6568

+ 15 - 0
src/main/java/com/izouma/nineth/service/AdapayMerchantService.java

@@ -17,6 +17,7 @@ import com.izouma.nineth.dto.adapay.PaymentList;
 import com.izouma.nineth.dto.adapay.SettleAccountsItem;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.AdapayMerchantRepo;
+import com.izouma.nineth.utils.DateTimeUtils;
 import com.izouma.nineth.utils.JpaUtils;
 import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
@@ -28,6 +29,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
+import java.time.LocalDate;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -288,4 +290,17 @@ public class AdapayMerchantService {
         }
     }
 
+
+    public Object querySettle(Long merchantId, LocalDate start, LocalDate end, Long userId) throws BaseAdaPayException {
+        AdapayMerchant merchant = adapayMerchantRepo.findById(merchantId).orElseThrow(new BusinessException("商户不存在"));
+
+        Map<String, Object> queryParams = new HashMap<>(5);
+        queryParams.put("member_id", userId.toString());
+        queryParams.put("app_id", merchant.getAppId());
+        queryParams.put("begin_date", DateTimeUtils.format(start, "yyyyMMdd"));
+        queryParams.put("end_date", DateTimeUtils.format(end, "yyyyMMdd"));
+        Map<String, Object> settleCount = SettleAccount.detail(queryParams, merchant.getName());
+        log.info(JSON.toJSONString(settleCount, SerializerFeature.PrettyFormat));
+        return settleCount;
+    }
 }

+ 7 - 0
src/main/java/com/izouma/nineth/web/AdapayMerchantController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.time.LocalDate;
 import java.util.List;
 
 @RestController
@@ -68,5 +69,11 @@ public class AdapayMerchantController extends BaseController {
     public Object refund(@RequestParam Long id, @RequestParam String orderId) throws BaseAdaPayException {
         return adapayMerchantService.refund(id, orderId);
     }
+
+    @PostMapping("/querySettle")
+    public Object querySettle(@RequestParam Long id, @RequestParam LocalDate start,
+                              @RequestParam LocalDate end, @RequestParam Long userId) throws BaseAdaPayException {
+        return adapayMerchantService.querySettle(id, start, end, userId);
+    }
 }
 

+ 8 - 0
src/main/vue/src/router.js

@@ -518,6 +518,14 @@ const router = new Router({
                     meta: {
                         title: 'ada',
                     },
+                },
+                {
+                    path: '/querySettle',
+                    name: 'QuerySettle',
+                    component: () => import(/* webpackChunkName: "querySettle" */ '@/views/QuerySettle.vue'),
+                    meta: {
+                        title: '结算查询',
+                    },
                 }
                 /**INSERT_LOCATION**/
             ]

+ 150 - 0
src/main/vue/src/views/QuerySettle.vue

@@ -0,0 +1,150 @@
+<template>
+    <div class="list-view" v-loading="loading">
+        <page-title> </page-title>
+        <div class="filters-container">
+            <el-date-picker
+                start-placeholder="开始日期"
+                end-placeholder="结束日期"
+                :picker-options="pickerOptions"
+                type="daterange"
+                class="filter-item"
+                value-format="yyyy-MM-dd"
+                v-model="range"
+            ></el-date-picker>
+            <el-select v-model="merchantId" class="filter-item" placeholder="请选支付通道">
+                <el-option v-for="item in merchantList" :value="item.id" :key="item.id" :label="item.name"></el-option>
+            </el-select>
+            <el-input v-model="userId" placeholder="用户ID" class="filter-item"></el-input>
+            <el-button @click="getData" class="filter-item" type="primary">查询</el-button>
+        </div>
+        <el-table
+            :height="tableHeight"
+            :data="tableData"
+            row-key="id"
+            ref="table"
+            header-row-class-name="table-header-row"
+            header-cell-class-name="table-header-cell"
+            row-class-name="table-row"
+            cell-class-name="table-cell"
+        >
+            <el-table-column type="index" label="#" width="60"></el-table-column>
+            <el-table-column prop="settle_date" label="日期" width="100"> </el-table-column>
+            <el-table-column prop="card_name" label="姓名" width="100"> </el-table-column>
+            <el-table-column prop="card_no" label="卡号"> </el-table-column>
+            <el-table-column prop="settle_amt" label="金额" width="120"> </el-table-column>
+            <el-table-column prop="settle_stat" label="状态" width="100" align="center">
+                <template v-slot="{ row }">
+                    <el-tag :type="row.settle_stat === 'succeeded' ? 'success' : 'danger'">{{
+                        row.settle_stat === 'succeeded' ? '成功' : '失败'
+                    }}</el-tag>
+                </template>
+            </el-table-column>
+            <el-table-column prop="settle_message" label="描述" show-overflow-tooltip></el-table-column>
+        </el-table>
+        <div class="pagination-wrapper">
+            <!-- <div class="multiple-mode-wrapper">
+                <el-button v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
+                <el-button-group v-else>
+                    <el-button @click="operation1">批量操作1</el-button>
+                    <el-button @click="operation2">批量操作2</el-button>
+                    <el-button @click="toggleMultipleMode(false)">取消</el-button>
+                </el-button-group>
+            </div> -->
+        </div>
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import { parse, format, addDays, addMonths } from 'date-fns';
+export default {
+    data() {
+        return {
+            tableHeight: 200,
+            loading: false,
+            tableData: [],
+            range: null,
+            userId: null,
+            merchantList: [],
+            merchantId: null,
+            userId: null,
+            pickerOptions: {
+                shortcuts: [
+                    {
+                        text: '今天',
+                        onClick(picker) {
+                            picker.$emit('pick', [new Date(), new Date()]);
+                        }
+                    },
+                    {
+                        text: '昨天',
+                        onClick(picker) {
+                            picker.$emit('pick', [addDays(new Date(), -1), new Date()]);
+                        }
+                    },
+                    {
+                        text: '最近一周',
+                        onClick(picker) {
+                            picker.$emit('pick', [addDays(new Date(), -7), new Date()]);
+                        }
+                    },
+                    {
+                        text: '最近一月',
+                        onClick(picker) {
+                            picker.$emit('pick', [addMonths(new Date(), -1), new Date()]);
+                        }
+                    }
+                ]
+            }
+        };
+    },
+    computed: {},
+    created() {
+        this.$http.post('/adapayMerchant/all', { size: 1000 }, { body: 'json' }).then(res => {
+            this.merchantList = res.content;
+        });
+        this.range = [format(addDays(new Date(), -7), 'yyyy-MM-dd'), format(new Date(), 'yyyy-MM-dd')];
+    },
+    mounted() {
+        this.tableHeight = document.querySelector('.el-table').getBoundingClientRect().height;
+    },
+    methods: {
+        getData() {
+            if (!(this.range && this.range.length == 2)) {
+                this.$message.error('请选择日期');
+                return;
+            }
+            if (!this.merchantId) {
+                this.$message.error('请选支付通道');
+                return;
+            }
+            if (!this.userId) {
+                this.$message.error('请输入用户ID');
+                return;
+            }
+            this.loading = true;
+            this.$http
+                .post('/adapayMerchant/querySettle', {
+                    start: this.range[0],
+                    end: this.range[1],
+                    id: this.merchantId,
+                    userId: this.userId
+                })
+                .then(res => {
+                    this.loading = false;
+                    console.log(res);
+                    if (res.status === 'succeeded') {
+                        this.tableData = (res.settle_details || []).filter(i => i.settle_type !== 'B');
+                    } else {
+                        this.$message.error(res.error_msg);
+                    }
+                })
+                .catch(e => {
+                    this.loading = false;
+                    this.$message.error(e.error || '查询失败');
+                });
+        }
+    }
+};
+</script>
+<style lang="less" scoped>
+</style>

+ 12 - 4
src/test/java/com/izouma/nineth/service/AdapayTest.java

@@ -7,10 +7,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.huifu.adapay.Adapay;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.model.AdapayCommon;
-import com.huifu.adapay.model.MerConfig;
-import com.huifu.adapay.model.Payment;
-import com.huifu.adapay.model.Refund;
+import com.huifu.adapay.model.*;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
 import com.izouma.nineth.utils.excel.BigIntegerConverter;
 import com.izouma.nineth.utils.excel.LocalDateConverter;
@@ -220,4 +217,15 @@ public class AdapayTest {
         Map<String, Object> map = Payment.query("002112022021816391410340666733272313856");
         System.out.println(JSON.toJSONString(map, SerializerFeature.PrettyFormat));
     }
+
+    @Test
+    public void querySettle() throws BaseAdaPayException {
+        Map<String, Object> queryParams = new HashMap<>(5);
+        queryParams.put("member_id", "736136");
+        queryParams.put("app_id", appId);
+        queryParams.put("begin_date", "20220201");
+        queryParams.put("end_date", "20220302");
+        Map<String, Object> settleCount = SettleAccount.detail(queryParams);
+        System.out.println(JSON.toJSONString(settleCount, SerializerFeature.PrettyFormat));
+    }
 }