licailing 5 年之前
父節點
當前提交
d66b45649d

+ 2 - 2
src/main/java/com/izouma/jiashanxia/service/OrderInfoService.java

@@ -87,7 +87,7 @@ public class OrderInfoService {
     /*
    下订单
     */
-    public OrderInfo createOrder1(CreateOrder createOrder) {
+    public OrderInfo createOrder1(CreateOrder createOrder,Long userId) {
         Package aPackage = packageRepo.findById(createOrder.getPackageId()).orElseThrow(new BusinessException("无套餐"));
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
         String localTime = df.format(LocalDateTime.now());
@@ -96,7 +96,7 @@ public class OrderInfoService {
         OrderInfo order = OrderInfo.builder()
                 .packageId(createOrder.getPackageId())
                 .status(OrderInfoStatus.UNPAID)
-                .userId(createOrder.getUserId())
+                .userId(userId)
                 .payMethod(createOrder.getPayMethod())
                 .orderNumber(localTime + orderNum)
                 .name(aPackage.getName())

+ 11 - 5
src/main/java/com/izouma/jiashanxia/service/StatisticService.java

@@ -125,8 +125,9 @@ public class StatisticService {
         return this.getDTOS(orderInfos, start, (int) day);
     }
 
-    public List<StatisticDTO> employeeOrderFee(int year, int month, Long userId) {
-        LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0);
+    public List<StatisticDTO> employeeOrderFee(String time, Long userId) {
+//        LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0);
+        LocalDateTime start = DateTimeUtils.toLocalDateTime(time, "yyyy-MM-dd HH:mm:ss");
         LocalDateTime end = start.plusMonths(1);
         long day = end.toLocalDate().toEpochDay() - start.toLocalDate().toEpochDay() - 1;
         List<Long> childrenId = userService.childrenId(userId);
@@ -139,14 +140,18 @@ public class StatisticService {
         }));
 
         Map<Integer, List<WxFee>> collect = wxFeeList.stream().collect(Collectors.groupingBy(WxFee::getAction));
+        List<WxFee> fees = new ArrayList<>();
         List<WxFee> wxFees = collect.get(0);
+        if (CollUtil.isNotEmpty(wxFees)) {
+            fees = wxFees;
+        }
         List<WxFee> refunds = new ArrayList<>();
         List<WxFee> wxFees1 = collect.get(1);
         if (CollUtil.isNotEmpty(wxFees1)) {
             refunds = wxFees1;
         }
 
-        return getDTOS2(wxFees, refunds, start, (int) day);
+        return getDTOS2(fees, refunds, start, (int) day);
     }
 
     public List<StatisticDTO> getDTOS(List<OrderInfo> orderInfos, LocalDateTime start, int day) {
@@ -195,8 +200,9 @@ public class StatisticService {
         return dtos;
     }
 
-    public List<StatisticDTO> employeeCommission(int year, int month, Long userId) {
-        LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0);
+    public List<StatisticDTO> employeeCommission(String time, Long userId) {
+//        LocalDateTime start = LocalDateTime.of(year, month, 1, 0, 0);
+        LocalDateTime start = DateTimeUtils.toLocalDateTime(time, "yyyy-MM-dd HH:mm:ss");
         LocalDateTime end = start.plusMonths(1);
         long day = end.toLocalDate().toEpochDay() - start.toLocalDate().toEpochDay() - 1;
         List<CommissionRecord> recordList = commissionRecordRepo.findAllByUserIdAndCreatedAtBetween(userId, start, end);

+ 1 - 1
src/main/java/com/izouma/jiashanxia/web/OrderInfoController.java

@@ -75,7 +75,7 @@ public class OrderInfoController extends BaseController {
     @ApiOperation("创建订单")
     public OrderInfo create(@RequestBody CreateOrder order) {
 //        return orderInfoService.createOrder(SecurityUtils.getAuthenticatedUser().getId(), packageId, payMethod);
-        return orderInfoService.createOrder1(order);
+        return orderInfoService.createOrder1(order,SecurityUtils.getAuthenticatedUser().getId());
     }
 
     @PostMapping("/cancel")

+ 4 - 4
src/main/java/com/izouma/jiashanxia/web/StatisticController.java

@@ -44,14 +44,14 @@ public class StatisticController {
 
     @ApiOperation("员工订单金额日销售")
     @GetMapping("/dayAddEmployee1")
-    public List<StatisticDTO> dayAddEmployee1(int year, int month, Long userId) {
-        return statisticService.employeeOrderFee(year, month, userId);
+    public List<StatisticDTO> dayAddEmployee1(String start, Long userId) {
+        return statisticService.employeeOrderFee(start, userId);
     }
 
     @ApiOperation("员工收益金额日销售")
     @GetMapping("/dayAddEmployee2")
-    public List<StatisticDTO> dayAddEmployee2(int year, int month, Long userId) {
-        return statisticService.employeeCommission(year, month, userId);
+    public List<StatisticDTO> dayAddEmployee2(String start, Long userId) {
+        return statisticService.employeeCommission(start, userId);
     }
 
 }

+ 3 - 3
src/main/vue/src/main.js

@@ -16,8 +16,8 @@ import DistrictChoose from '@/components/DistrictChoose';
 import Formatters from '@/mixins/formatters';
 import 'normalize.css/normalize.css';
 import 'element-ui/lib/theme-chalk/index.css';
-import { DropdownMenu, DropdownItem } from 'vant';
-import 'vant/lib/index.less';
+// import { DropdownMenu, DropdownItem } from 'vant';
+// import 'vant/lib/index.less';
 
 // import VueAMap from "vue-amap";
 // Vue.use(VueAMap);
@@ -53,7 +53,7 @@ Vue.component('rich-text', RichText);
 Vue.component('crop-upload', CropUpload);
 Vue.component('district-choose', DistrictChoose);
 Vue.mixin(Formatters);
-Vue.use(DropdownMenu).use(DropdownItem);
+// Vue.use(DropdownMenu).use(DropdownItem);
 
 new Vue({
     router,

+ 51 - 4
src/main/vue/src/views/UserEdit.vue

@@ -59,11 +59,29 @@
                     placeholder="请选择"
                     value-key="name"
                     style="width:100%"
+                    @change="getAdmin"
                 >
                     <el-option v-for="item in authorities" :key="item.name" :label="item.description" :value="item">
                     </el-option>
                 </el-select>
             </el-form-item>
+            <el-form-item prop="attractionsId" label="品牌" v-if="display">
+                <el-select
+                    v-model="formData.attractionsId"
+                    clearable
+                    filterable
+                    placeholder="请选择"
+                    style="width:100%"
+                >
+                    <el-option
+                        v-for="item in attractionsIdOptions"
+                        :key="item.value"
+                        :label="item.label"
+                        :value="item.value"
+                    >
+                    </el-option>
+                </el-select>
+            </el-form-item>
             <el-form-item>
                 <el-button @click="onSave" :loading="$store.state.fetchingData" type="primary">保存</el-button>
                 <el-button @click="del" :loading="$store.state.fetchingData" type="danger" v-if="formData.id"
@@ -90,6 +108,7 @@ export default {
                 .get(`/user/get/${this.$route.query.id}`)
                 .then(res => {
                     this.formData = res;
+                    this.getAdmin;
                 })
                 .catch(e => {
                     console.log(e);
@@ -104,13 +123,29 @@ export default {
             .catch(e => {
                 console.log(e);
             });
+        // this.$http
+        //     .get('/company/allList')
+        //     .then(res => {
+        //         this.companies = res;
+        //     })
+        //     .catch(e => {
+        //         console.log(e);
+        //     });
         this.$http
-            .get('/company/allList')
+            .post('/attractions/all', { size: 1000, query: { del: false, brand: true } }, { body: 'json' })
             .then(res => {
-                this.companies = res;
+                if (res.content.length > 0) {
+                    res.content.forEach(item => {
+                        this.attractionsIdOptions.push({
+                            label: item.name,
+                            value: item.id
+                        });
+                    });
+                }
             })
             .catch(e => {
                 console.log(e);
+                this.$message.error(e.error);
             });
     },
     data() {
@@ -144,7 +179,7 @@ export default {
                 packageId: [{ required: true, message: '请选择套餐', trigger: 'blur' }]
             },
             authorities: [],
-            companies: [],
+            // companies: [],
             userDialog: false,
             employee: [],
             id: 0,
@@ -155,7 +190,9 @@ export default {
                 { label: '创客', value: 'MAKER' },
                 { label: '全职', value: 'EMPLOYEE' },
                 { label: '108将/创客', value: 'GENERAL_MAKER' }
-            ]
+            ],
+            attractionsIdOptions: [],
+            display: false
         };
     },
     methods: {
@@ -236,6 +273,16 @@ export default {
                 .catch(e => {
                     console.log(e);
                 });
+        },
+        getAdmin() {
+            let data = this.formData.authorities;
+            this.display = false;
+            for (let item in data) {
+                if (data[item].name === 'ROLE_WRITER') {
+                    this.display = true;
+                    break;
+                }
+            }
         }
     }
 };

+ 9 - 9
src/main/vue/src/views/employee/EmployeeDashboard.vue

@@ -36,18 +36,18 @@ import UserWidget from '@/widgets/UserWidget';
 import OrderWidget from '@/widgets/OrderWidget';
 import CompanyWidget from '@/widgets/CompanyWidget';
 import FeeWidget from '@/widgets/FeeWidget';
-import RecentSales from '@/widgets/RecentSales';
+import RecentSalesEmployee from '@/widgets/RecentSalesEmployee';
 import RecentOrderEmployee from '@/widgets/RecentOrderEmployee';
 import { mapState } from 'vuex';
 
 export default {
     created() {
-        this.$axios.get('/statistic/data').then(res => {
-            this.user = res.data['user'];
-            this.company = res.data['company'];
-            this.order = res.data['order'];
-            this.fee = res.data['fee'];
-        });
+        // this.$axios.get('/statistic/data').then(res => {
+        //     this.user = res.data['user'];
+        //     this.company = res.data['company'];
+        //     this.order = res.data['order'];
+        //     this.fee = res.data['fee'];
+        // });
         this.getAdmin();
     },
     data() {
@@ -58,7 +58,7 @@ export default {
                 // { x: 6, y: 0, w: 3, h: 3, i: '2', name: 'OrderWidget', key: 'order' },
                 // { x: 9, y: 0, w: 3, h: 3, i: '3', name: 'FeeWidget', key: 'fee' },
                 { x: 0, y: 4, w: 12, h: 12, i: '0', name: 'RecentOrderEmployee' },
-                { x: 0, y: 10, w: 12, h: 12, i: '1', name: 'RecentSales' }
+                { x: 0, y: 10, w: 12, h: 12, i: '1', name: 'RecentSalesEmployee' }
                 /*{ x: 6, y: 4, w: 6, h: 12, i: '6', name: 'PieChartWidget' }*/
             ],
             editable: false,
@@ -94,7 +94,7 @@ export default {
         // OrderWidget,
         // FeeWidget,
         // CompanyWidget,
-        RecentSales,
+        RecentSalesEmployee,
         RecentOrderEmployee
     }
 };

+ 106 - 0
src/main/vue/src/widgets/RecentOrderEmployee copy.vue

@@ -0,0 +1,106 @@
+<template>
+    <widget-card :bodyStyle="bodyStyle" ref="container">
+        <div style="width:100%;min-height:80px;" :loading="loading">
+            <div style="margin: 0 0 1px 15px">
+                <!-- <van-dropdown-menu class="van-width">
+                    <van-dropdown-item v-model="chooseDate" @change="changeDate" :options="dateList" />
+                </van-dropdown-menu> -->
+                <el-date-picker
+                    v-model="chooseDate"
+                    @change="changeDate"
+                    type="month"
+                    placeholder="选择月"
+                    value-format="yyyy-MM-dd HH:mm:ss"
+                >
+                </el-date-picker>
+            </div>
+            <bar-chart :chart-data="chartData" v-if="chartData"> </bar-chart>
+        </div>
+    </widget-card>
+</template>
+<script>
+import WidgetCard from './WidgetCard';
+import BarChart from '../components/BarChart';
+import { parse, addYears, format, addMonths, addDays } from 'date-fns';
+
+export default {
+    data() {
+        return {
+            bodyStyle: {
+                alignItems: 'center'
+            },
+            chartData: null,
+            loading: false,
+            chooseDate: ''
+        };
+    },
+    // created() {
+    //     this.getData();
+    // },
+    computed: {
+        dateList() {
+            var list = [];
+            for (var i = 0; i < 6; i++) {
+                let time = parse(format(addMonths(new Date(), 0 - i), 'yyyy-MM') + '-01', 'yyyy-MM-dd', new Date());
+                list.push({
+                    text: format(time, 'yyyy年MM月'),
+                    value: format(time, 'yyyy-MM') + '-01 00:00:00'
+                    // '-01 00:00:00,' +
+                    // format(addDays(addMonths(time, 1), 0 - 1), 'yyyy-MM-dd') +
+                    // ' 23:59:59'
+                });
+            }
+            return list;
+        }
+    },
+    mounted() {
+        this.$nextTick(() => {
+            this.chooseDate = this.dateList[0].value;
+            this.getData();
+        });
+    },
+    methods: {
+        changeDate() {
+            this.page = 0;
+            this.last = false;
+            this.getData();
+        },
+        getData() {
+            this.loading = true;
+            this.$http
+                .get('/statistic/dayAddEmployee', {
+                    start: this.chooseDate,
+                    userId: this.$route.query.id
+                })
+                .then(res => {
+                    this.loading = false;
+                    this.chartData = {
+                        labels: res.map(i => format(parse(i.date, 'yyyy-MM-dd', new Date()), 'dd')),
+                        datasets: [
+                            {
+                                label: '订单数',
+                                data: res.map(i => i.dayOrder),
+                                backgroundColor: 'rgba(54, 162, 235, 0.2)',
+                                borderColor: 'rgba(54, 162, 235, 1)',
+                                borderWidth: 1
+                            }
+                        ]
+                    };
+                })
+                .catch(e => {
+                    this.loading = false;
+                    this.$message.error(e.error);
+                });
+        }
+    },
+    components: {
+        WidgetCard,
+        BarChart
+    }
+};
+</script>
+<style lang="less" scoped>
+.van-width {
+    width: 200px;
+}
+</style>

+ 11 - 3
src/main/vue/src/widgets/RecentOrderEmployee.vue

@@ -1,10 +1,18 @@
 <template>
     <widget-card :bodyStyle="bodyStyle" ref="container">
         <div style="width:100%;min-height:80px;" :loading="loading">
-            <div style="margin-bottom:1px">
-                <van-dropdown-menu class="van-width">
+            <div style="margin: 0 0 1px 15px">
+                <!-- <van-dropdown-menu class="van-width">
                     <van-dropdown-item v-model="chooseDate" @change="changeDate" :options="dateList" />
-                </van-dropdown-menu>
+                </van-dropdown-menu> -->
+                <el-date-picker
+                    v-model="chooseDate"
+                    @change="changeDate"
+                    type="month"
+                    placeholder="选择月"
+                    value-format="yyyy-MM-dd HH:mm:ss"
+                >
+                </el-date-picker>
             </div>
             <bar-chart :chart-data="chartData" v-if="chartData"> </bar-chart>
         </div>

+ 43 - 10
src/main/vue/src/widgets/RecentSalesEmployee.vue

@@ -1,11 +1,15 @@
 <template>
     <widget-card :bodyStyle="bodyStyle" ref="container">
         <div style="width:100%;min-height:80px;" :loading="loading">
-            <div style="margin-bottom:5px">
-                <el-radio-group v-model="recentDays" size="mini" @change="getData">
-                    <el-radio-button label="7">近7天</el-radio-button>
-                    <el-radio-button label="30">近30天</el-radio-button>
-                </el-radio-group>
+            <div style="margin: 0 0 1px 15px">
+                <el-date-picker
+                    v-model="chooseDate"
+                    @change="changeDate"
+                    type="month"
+                    placeholder="选择月"
+                    value-format="yyyy-MM-dd HH:mm:ss"
+                >
+                </el-date-picker>
             </div>
             <line-chart :chart-data="chartData" v-if="chartData"> </line-chart>
         </div>
@@ -14,6 +18,7 @@
 <script>
 import WidgetCard from './WidgetCard';
 import LineChart from '../components/LineChart';
+import { parse, addYears, format, addMonths, addDays } from 'date-fns';
 
 export default {
     data() {
@@ -22,20 +27,48 @@ export default {
                 display: 'flex',
                 alignItems: 'center'
             },
-            recentDays: 7,
+            chooseDate: '',
             chartData: null,
             loading: false
         };
     },
-    created() {
-        this.getData();
+    // created() {
+    //     this.getData();
+    // },
+    computed: {
+        dateList() {
+            var list = [];
+            for (var i = 0; i < 6; i++) {
+                let time = parse(format(addMonths(new Date(), 0 - i), 'yyyy-MM') + '-01', 'yyyy-MM-dd', new Date());
+                list.push({
+                    text: format(time, 'yyyy年MM月'),
+                    value: format(time, 'yyyy-MM') + '-01 00:00:00'
+                    // '-01 00:00:00,' +
+                    // format(addDays(addMonths(time, 1), 0 - 1), 'yyyy-MM-dd') +
+                    // ' 23:59:59'
+                });
+            }
+            return list;
+        }
+    },
+    mounted() {
+        this.$nextTick(() => {
+            this.chooseDate = this.dateList[0].value;
+            this.getData();
+        });
     },
     methods: {
+        changeDate() {
+            this.page = 0;
+            this.last = false;
+            this.getData();
+        },
         getData() {
             this.loading = true;
             this.$http
-                .get('/statistic/dayAdd', {
-                    day: this.recentDays
+                .get('/statistic/dayAddEmployee1', {
+                    start: this.chooseDate,
+                    userId: this.$route.query.id
                 })
                 .then(res => {
                     this.loading = false;

+ 1 - 1
src/test/java/com/izouma/jiashanxia/service/OrderInfoServiceTest.java

@@ -55,6 +55,6 @@ public class OrderInfoServiceTest {
                 .userId(916L)
                 .payMethod(PayMethod.WEIXIN)
                 .build();
-        System.out.println(orderInfoService.createOrder1(build));
+        System.out.println(orderInfoService.createOrder1(build,916L));
     }
 }

+ 3 - 3
src/test/java/com/izouma/jiashanxia/service/StatisticServiceTest.java

@@ -33,13 +33,13 @@ public class StatisticServiceTest {
 
     @Test
     public void test1() {
-        List<StatisticDTO> employee = statisticService.employeeOrder("2021-01-01 00:00:00",921L);
+        List<StatisticDTO> employee = statisticService.employeeOrder("2021-01-01 00:00:00", 921L);
         employee.forEach(System.out::println);
     }
 
     @Test
     public void test2() {
-        List<StatisticDTO> employee = statisticService.employeeOrderFee(2021, 1, 921L);
+        List<StatisticDTO> employee = statisticService.employeeOrderFee("2021-01-01 00:00:00", 921L);
 //        List<StatisticDTO> employee = statisticService.employeeOrderFee(LocalDateTime.of(2021, 1, 1, 0, 0), LocalDateTime
 //                .of(2021, 1, 31, 59, 59), 921L);
         employee.forEach(System.out::println);
@@ -47,7 +47,7 @@ public class StatisticServiceTest {
 
     @Test
     public void test3() {
-        List<StatisticDTO> statisticDTOS = statisticService.employeeCommission(2021, 1, 921L);
+        List<StatisticDTO> statisticDTOS = statisticService.employeeCommission("2021-01-01 00:00:00", 921L);
         statisticDTOS.forEach(System.out::println);
     }
 }