licailing 5 лет назад
Родитель
Сommit
2aa619e663

+ 3 - 1
src/main/java/com/izouma/jiashanxia/domain/Coupon.java

@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Where;
 
 import javax.persistence.Entity;
 import javax.persistence.Transient;
@@ -18,9 +19,10 @@ import java.time.LocalDateTime;
 @Builder
 @Entity
 @ApiModel("优惠券")
+@Where(clause = "del = 0")
 public class Coupon extends BaseEntity {
     @ApiModelProperty(value = "品牌")
-    private String attractionsId;
+    private Long attractionsId;
 
     private String name;
 

+ 12 - 0
src/main/java/com/izouma/jiashanxia/domain/UserCoupon.java

@@ -6,19 +6,31 @@ import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import org.hibernate.annotations.Where;
 
+import javax.persistence.Entity;
 import java.time.LocalDateTime;
 
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
 @Builder
+@Entity
 @ApiModel("用户优惠券")
+@Where(clause = "del = 0")
 public class UserCoupon extends BaseEntity {
     private Long userId;
 
     private Long couponId;
 
+    @ApiModelProperty(value = "是否已使用")
+    private boolean isUse;
+
+    private LocalDateTime useTime;
+
+    @ApiModelProperty(value = "核销人")
+    private Long writeOffUserId;
+
     @ApiModelProperty(value = "有效期")
     private LocalDateTime period;
 

+ 3 - 0
src/main/java/com/izouma/jiashanxia/repo/AttractionsRepo.java

@@ -7,10 +7,13 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.util.List;
 
 public interface AttractionsRepo extends JpaRepository<Attractions, Long>, JpaSpecificationExecutor<Attractions> {
     @Query("update Attractions t set t.del = true where t.id = ?1")
     @Modifying
     @Transactional
     void softDelete(Long id);
+
+    List<Attractions> findAllByBrand(boolean brand);
 }

+ 4 - 0
src/main/java/com/izouma/jiashanxia/repo/CouponRepo.java

@@ -7,10 +7,14 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.time.LocalDateTime;
+import java.util.List;
 
 public interface CouponRepo extends JpaRepository<Coupon, Long>, JpaSpecificationExecutor<Coupon> {
     @Query("update Coupon t set t.del = true where t.id = ?1")
     @Modifying
     @Transactional
     void softDelete(Long id);
+
+    List<Coupon> findAllByIdInAndPeriodAfter(Iterable<Long> id, LocalDateTime period);
 }

+ 16 - 0
src/main/java/com/izouma/jiashanxia/repo/UserCouponRepo.java

@@ -0,0 +1,16 @@
+package com.izouma.jiashanxia.repo;
+
+import com.izouma.jiashanxia.domain.UserCoupon;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.transaction.Transactional;
+
+public interface UserCouponRepo extends JpaRepository<UserCoupon, Long>, JpaSpecificationExecutor<UserCoupon> {
+    @Query("update UserCoupon t set t.del = true where t.id = ?1")
+    @Modifying
+    @Transactional
+    void softDelete(Long id);
+}

+ 21 - 1
src/main/java/com/izouma/jiashanxia/service/CouponService.java

@@ -1,20 +1,40 @@
 package com.izouma.jiashanxia.service;
 
 import com.izouma.jiashanxia.domain.Coupon;
+import com.izouma.jiashanxia.domain.OrderInfo;
+import com.izouma.jiashanxia.domain.Package;
 import com.izouma.jiashanxia.dto.PageQuery;
+import com.izouma.jiashanxia.exception.BusinessException;
 import com.izouma.jiashanxia.repo.CouponRepo;
+import com.izouma.jiashanxia.repo.OrderInfoRepo;
+import com.izouma.jiashanxia.repo.PackageRepo;
 import com.izouma.jiashanxia.utils.JpaUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+import java.util.List;
+
 @Service
 @AllArgsConstructor
 public class CouponService {
 
-    private final CouponRepo couponRepo;
+    private final CouponRepo    couponRepo;
+    private final OrderInfoRepo orderInfoRepo;
+    private final PackageRepo   packageRepo;
 
     public Page<Coupon> all(PageQuery pageQuery) {
         return couponRepo.findAll(JpaUtils.toSpecification(pageQuery, Coupon.class), JpaUtils.toPageRequest(pageQuery));
     }
+
+    /*
+    可选择的优惠券
+    核销套餐后,可选择的优惠券
+     */
+    public List<Coupon> chooseByOrder(Long orderInfoId) {
+        OrderInfo orderInfo = orderInfoRepo.findById(orderInfoId).orElseThrow(new BusinessException("无订单"));
+        Package aPackage = packageRepo.findById(orderInfo.getPackageId()).orElseThrow(new BusinessException("无套餐"));
+        return couponRepo.findAllByIdInAndPeriodAfter(aPackage.getCouponId(), LocalDateTime.now());
+    }
 }

+ 71 - 0
src/main/java/com/izouma/jiashanxia/service/UserCouponService.java

@@ -0,0 +1,71 @@
+package com.izouma.jiashanxia.service;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.izouma.jiashanxia.domain.Coupon;
+import com.izouma.jiashanxia.domain.User;
+import com.izouma.jiashanxia.domain.UserCoupon;
+import com.izouma.jiashanxia.dto.PageQuery;
+import com.izouma.jiashanxia.exception.BusinessException;
+import com.izouma.jiashanxia.repo.CouponRepo;
+import com.izouma.jiashanxia.repo.UserCouponRepo;
+import com.izouma.jiashanxia.repo.UserRepo;
+import com.izouma.jiashanxia.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+@Service
+@AllArgsConstructor
+public class UserCouponService {
+
+    private final UserCouponRepo userCouponRepo;
+    private final UserRepo       userRepo;
+    private final CouponRepo     couponRepo;
+
+    public Page<UserCoupon> all(PageQuery pageQuery) {
+        return userCouponRepo.findAll(JpaUtils.toSpecification(pageQuery, UserCoupon.class), JpaUtils.toPageRequest(pageQuery));
+    }
+
+    /*
+    获得优惠券
+     */
+    public UserCoupon getCoupon(Long userId, Long couponId) {
+        Coupon coupon = couponRepo.findById(couponId).orElseThrow(new BusinessException("无优惠券啊"));
+        UserCoupon build = UserCoupon.builder()
+                .period(coupon.getPeriod())
+                .couponId(couponId)
+                .isUse(false)
+                .userId(userId)
+                .build();
+        return userCouponRepo.save(build);
+    }
+
+    /*
+    核销优惠券
+     */
+    public void writeOff(Long userCouponId, Long writeOffUserId) {
+        UserCoupon userCoupon = userCouponRepo.findById(userCouponId).orElseThrow(new BusinessException("无用户优惠券"));
+        User user = userRepo.findById(writeOffUserId).orElseThrow(new BusinessException("无核销人员"));
+        if (userCoupon.isUse()) {
+            throw new BusinessException("已使用");
+        }
+
+        LocalDateTime now = LocalDateTime.now();
+        if (now.isBefore(userCoupon.getPeriod())) {
+            throw new BusinessException("已过期");
+        }
+
+        Coupon coupon = couponRepo.findById(userCoupon.getCouponId()).orElseThrow(new BusinessException("无优惠券"));
+        if (ObjectUtil.isNotNull(user.getAttractionsId()) && !coupon.getAttractionsId()
+                .equals(user.getAttractionsId())) {
+            throw new BusinessException("不是此品牌核销人员");
+        }
+
+        userCoupon.setUse(true);
+        userCoupon.setUseTime(now);
+        userCoupon.setWriteOffUserId(writeOffUserId);
+        userCouponRepo.save(userCoupon);
+    }
+}

+ 9 - 11
src/main/java/com/izouma/jiashanxia/service/UserService.java

@@ -135,16 +135,14 @@ public class UserService {
             if (userInfo != null) {
                 // 插入上级
                 if (ObjectUtil.isNotNull(parent)) {
-//                    Long parent1 = this.getParent(parent, userInfo);
+                    if (this.getParent(parent, userInfo)) {
+                        userInfo.setParent(parent);
+                    }
                     // 邀请成为创客
                     if (expert && !userInfo.isVip()) {
                         userInfo.setVip(true);
                         userInfo.setMember(Member.EXPERT);
                     }
-                    // 成为他的上级
-                    if (ObjectUtil.isNull(userInfo.getParent())) {
-                        userInfo.setParent(parent);
-                    }
                     userRepo.saveAndFlush(userInfo);
                 }
                 userInfo.setSessionKey(sessionKey);
@@ -180,26 +178,26 @@ public class UserService {
     /*
     获取上级
      */
-    public Long getParent(Long parent, User userInfo) {
+    public boolean getParent(Long parent, User userInfo) {
         // 用户上级为空
         if (ObjectUtil.isNull(userInfo.getParent())) {
-            return parent;
+            return true;
         }
         // 用户原有上级不为空
         User userParent = userRepo.findById(userInfo.getParent()).orElse(null);
         if (ObjectUtil.isNull(userParent)) {
-            return parent;
+            return true;
         }
-        // 不是达人
+        // 不是达人 现有用户的上级是普通用户
         if (Member.NORMAL.equals(userParent.getMember())) {
             // 传过来的上级
             User user1 = userRepo.findById(parent).orElse(null);
 
             if (ObjectUtil.isNotNull(user1) && !Member.NORMAL.equals(user1.getMember())) {
-                return parent;
+                return true;
             }
         }
-        return null;
+        return false;
     }
 
     public User getMaUserInfo(String sessionKey, String rawData, String signature,

+ 25 - 3
src/main/java/com/izouma/jiashanxia/web/CouponController.java

@@ -1,5 +1,8 @@
 package com.izouma.jiashanxia.web;
+
+import com.izouma.jiashanxia.domain.Attractions;
 import com.izouma.jiashanxia.domain.Coupon;
+import com.izouma.jiashanxia.repo.AttractionsRepo;
 import com.izouma.jiashanxia.service.CouponService;
 import com.izouma.jiashanxia.dto.PageQuery;
 import com.izouma.jiashanxia.exception.BusinessException;
@@ -14,13 +17,16 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/coupon")
 @AllArgsConstructor
 public class CouponController extends BaseController {
-    private CouponService couponService;
-    private CouponRepo couponRepo;
+    private final CouponService   couponService;
+    private final CouponRepo      couponRepo;
+    private final AttractionsRepo attractionsRepo;
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
@@ -37,7 +43,13 @@ public class CouponController extends BaseController {
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/all")
     public Page<Coupon> all(@RequestBody PageQuery pageQuery) {
-        return couponService.all(pageQuery);
+        Map<Long, String> attractionsMap = attractionsRepo.findAllByBrand(true)
+                .stream()
+                .collect(Collectors.toMap(Attractions::getId, Attractions::getName));
+        return couponService.all(pageQuery).map(coupon -> {
+            coupon.setAttractionsName(attractionsMap.get(coupon.getAttractionsId()));
+            return coupon;
+        });
     }
 
     @GetMapping("/get/{id}")
@@ -56,5 +68,15 @@ public class CouponController extends BaseController {
         List<Coupon> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
     }
+
+    /**
+     * 核销套餐后,可获得一张优惠券
+     * @param orderInfoId 订单id
+     * @return 可选择的优惠券列表
+     */
+    @PostMapping("/chooseByOrder")
+    public List<Coupon> chooseByOrder(@RequestParam Long orderInfoId) {
+        return couponService.chooseByOrder(orderInfoId);
+    }
 }
 

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

@@ -52,7 +52,7 @@ public class PackageController extends BaseController {
         Map<Long, String> categoryMap = categoryRepo.findAll()
                 .stream()
                 .collect(Collectors.toMap(Category::getId, Category::getName));
-        Map<Long, String> attractionsMap = attractionsRepo.findAll()
+        Map<Long, String> attractionsMap = attractionsRepo.findAllByBrand(false)
                 .stream()
                 .collect(Collectors.toMap(Attractions::getId, Attractions::getName));
 

+ 81 - 0
src/main/java/com/izouma/jiashanxia/web/UserCouponController.java

@@ -0,0 +1,81 @@
+package com.izouma.jiashanxia.web;
+
+import com.izouma.jiashanxia.domain.UserCoupon;
+import com.izouma.jiashanxia.service.UserCouponService;
+import com.izouma.jiashanxia.dto.PageQuery;
+import com.izouma.jiashanxia.exception.BusinessException;
+import com.izouma.jiashanxia.repo.UserCouponRepo;
+import com.izouma.jiashanxia.utils.ObjUtils;
+import com.izouma.jiashanxia.utils.SecurityUtils;
+import com.izouma.jiashanxia.utils.excel.ExcelUtils;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+@RestController
+@RequestMapping("/userCoupon")
+@AllArgsConstructor
+public class UserCouponController extends BaseController {
+    private UserCouponService userCouponService;
+    private UserCouponRepo    userCouponRepo;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/save")
+    public UserCoupon save(@RequestBody UserCoupon record) {
+        if (record.getId() != null) {
+            UserCoupon orig = userCouponRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
+            ObjUtils.merge(orig, record);
+            return userCouponRepo.save(orig);
+        }
+        return userCouponRepo.save(record);
+    }
+
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<UserCoupon> all(@RequestBody PageQuery pageQuery) {
+        return userCouponService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public UserCoupon get(@PathVariable Long id) {
+        return userCouponRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @PostMapping("/del/{id}")
+    public void del(@PathVariable Long id) {
+        userCouponRepo.softDelete(id);
+    }
+
+    @GetMapping("/excel")
+    @ResponseBody
+    public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
+        List<UserCoupon> data = all(pageQuery).getContent();
+        ExcelUtils.export(response, data);
+    }
+
+    /**
+     * 核销优惠券
+     *
+     * @param id 用户优惠券id => userCouponId
+     */
+    @PreAuthorize("hasRole('WRITER')")
+    @PostMapping("/writeOff")
+    @ApiOperation("核销优惠券")
+    public void writeOff(@RequestParam Long id) {
+        userCouponService.writeOff(id, SecurityUtils.getAuthenticatedUser().getId());
+    }
+
+    @PostMapping("/getCoupon")
+    @ApiOperation("获得优惠券")
+    public UserCoupon getCoupon(@RequestParam Long couponId) {
+        return userCouponService.getCoupon(SecurityUtils.getAuthenticatedUser().getId(), couponId);
+    }
+}
+

+ 1 - 0
src/main/resources/genjson/UserCoupon.json

@@ -0,0 +1 @@
+{"tableName":"UserCoupon","className":"UserCoupon","remark":"用户优惠券","genTable":true,"genClass":true,"genList":true,"genForm":true,"genRouter":true,"javaPath":"/Users/qiufangchao/Desktop/project/jiashanxia/src/main/java/com/izouma/jiashanxia","viewPath":"/Users/qiufangchao/Desktop/project/jiashanxia/src/main/vue/src/views","routerPath":"/Users/qiufangchao/Desktop/project/jiashanxia/src/main/vue/src","resourcesPath":"/Users/qiufangchao/Desktop/project/jiashanxia/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"userId","modelName":"userId","remark":"用户id","showInList":true,"showInForm":true,"formType":"number"},{"name":"couponId","modelName":"couponId","remark":"优惠券id","showInList":true,"showInForm":true,"formType":"number"},{"name":"isUse","modelName":"isUse","remark":"是否已使用","showInList":true,"showInForm":true,"formType":"singleLineText"},{"name":"useTime","modelName":"useTime","remark":"使用时间","showInList":true,"showInForm":true,"formType":"datetime"},{"name":"writeOffUserId","modelName":"writeOffUserId","remark":"核销人","showInList":true,"showInForm":true,"formType":"number"},{"name":"period","modelName":"period","remark":"有效期","showInList":true,"showInForm":true,"formType":"datetime"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.jiashanxia","tablePackage":"com.izouma.jiashanxia.domain.UserCoupon"}

+ 1 - 1
src/main/resources/templates/ServiceTemplate.ftl

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
 @AllArgsConstructor
 public class ${model.className}Service {
 
-    private ${model.className}Repo ${model.className?uncap_first}Repo;
+    private final ${model.className}Repo ${model.className?uncap_first}Repo;
 
     public Page<${model.className}> all(PageQuery pageQuery) {
         return ${model.className?uncap_first}Repo.findAll(JpaUtils.toSpecification(pageQuery, ${model.className}.class), JpaUtils.toPageRequest(pageQuery));

+ 21 - 2
src/main/vue/src/components/PackageEdit.vue

@@ -165,6 +165,14 @@
                     :step="0.01"
                 ></el-input-number>
             </el-form-item>
+            <el-form-item label="优惠券" prop="couponId">
+                <el-select multiple v-model="formData.couponId" class="select-width">
+                    <el-option v-for="item in coupons" :key="item.id" :label="item.name" :value="item.id">
+                        <span style="float: left">{{ item.name }}</span>
+                        <span style="float: right; color: #8492a6; font-size: 13px">{{ item.attractionsName }}</span>
+                    </el-option>
+                </el-select>
+            </el-form-item>
             <el-form-item>
                 <el-button @click="onSave" :loading="saving" type="primary" v-if="$route.query.id">保存</el-button>
                 <el-button @click="onSave" :loading="saving" type="primary" v-else>下一步</el-button>
@@ -225,6 +233,15 @@ export default {
                 console.log(e);
                 this.$message.error(e.error);
             });
+        this.$http
+            .post('/coupon/all', { size: 1000, query: { del: false } }, { body: 'json' })
+            .then(res => {
+                this.coupons = res.content;
+            })
+            .catch(e => {
+                console.log(e);
+                this.$message.error(e.error);
+            });
     },
     data() {
         return {
@@ -232,7 +249,8 @@ export default {
             formData: {
                 img: [],
                 tag: [],
-                repeatedly: false
+                repeatedly: false,
+                couponId: []
             },
             rules: {
                 attractionsId: [
@@ -273,7 +291,8 @@ export default {
             attractionsOptions: [],
             categoryOptions: [],
             stockList: [],
-            packageId: 0
+            packageId: 0,
+            coupons: []
         };
     },
     computed: {

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

@@ -121,6 +121,22 @@ const router = new Router({
                         title: '充值核销记录'
                     }
                 },
+                {
+                    path: '/brandList',
+                    name: 'BrandList',
+                    component: () => import(/* webpackChunkName: "brandList" */ '@/views/BrandList.vue'),
+                    meta: {
+                        title: '品牌管理'
+                    }
+                },
+                {
+                    path: '/brandEdit',
+                    name: 'BrandEdit',
+                    component: () => import(/* webpackChunkName: "brandEdit" */ '@/views/BrandEdit.vue'),
+                    meta: {
+                        title: '品牌管理'
+                    }
+                },
                 {
                     path: '/userEdit',
                     name: 'userEdit',
@@ -420,6 +436,22 @@ const router = new Router({
                     meta: {
                         title: '优惠券'
                     }
+                },
+                {
+                    path: '/userCouponEdit',
+                    name: 'UserCouponEdit',
+                    component: () => import(/* webpackChunkName: "userCouponEdit" */ '@/views/UserCouponEdit.vue'),
+                    meta: {
+                        title: '用户优惠券编辑'
+                    }
+                },
+                {
+                    path: '/userCouponList',
+                    name: 'UserCouponList',
+                    component: () => import(/* webpackChunkName: "userCouponList" */ '@/views/UserCouponList.vue'),
+                    meta: {
+                        title: '用户优惠券'
+                    }
                 }
                 /**INSERT_LOCATION**/
             ]

+ 3 - 1
src/main/vue/src/views/AttractionsEdit.vue

@@ -51,7 +51,9 @@ export default {
     data() {
         return {
             saving: false,
-            formData: {},
+            formData: {
+                brand: false
+            },
             rules: {
                 phone: [
                     {

+ 114 - 0
src/main/vue/src/views/BrandEdit.vue

@@ -0,0 +1,114 @@
+<template>
+    <div class="edit-view">
+        <el-form
+            :model="formData"
+            :rules="rules"
+            ref="form"
+            label-width="52px"
+            label-position="right"
+            size="small"
+            style="max-width: 500px;"
+        >
+            <el-form-item prop="name" label="名称">
+                <el-input v-model="formData.name"></el-input>
+            </el-form-item>
+            <el-form-item prop="img" label="图片">
+                <multi-upload v-model="formData.img"></multi-upload>
+            </el-form-item>
+            <el-form-item prop="introduction" label="介绍">
+                <el-input type="textarea" :autosize="{ minRows: 2 }" v-model="formData.introduction"></el-input>
+            </el-form-item>
+            <el-form-item prop="phone" label="电话">
+                <el-input v-model="formData.phone"></el-input>
+            </el-form-item>
+            <el-form-item prop="address" label="地址">
+                <el-input v-model="formData.address"></el-input>
+            </el-form-item>
+            <el-form-item>
+                <el-button @click="onSave" :loading="saving" type="primary">保存</el-button>
+                <el-button @click="onDelete" :loading="saving" type="danger" v-if="formData.id">删除 </el-button>
+                <el-button @click="$router.go(-1)">取消</el-button>
+            </el-form-item>
+        </el-form>
+    </div>
+</template>
+<script>
+export default {
+    name: 'BrandEdit',
+    created() {
+        if (this.$route.query.id) {
+            this.$http
+                .get('attractions/get/' + this.$route.query.id)
+                .then(res => {
+                    this.formData = res;
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.$message.error(e.error);
+                });
+        }
+    },
+    data() {
+        return {
+            saving: false,
+            formData: {
+                brand: true
+            },
+            rules: {
+                phone: [
+                    {
+                        pattern: /^1[3-9]\d{9}$/,
+                        message: '请输入正确的手机号',
+                        trigger: 'blur'
+                    }
+                ]
+            }
+        };
+    },
+    methods: {
+        onSave() {
+            this.$refs.form.validate(valid => {
+                if (valid) {
+                    this.submit();
+                } else {
+                    return false;
+                }
+            });
+        },
+        submit() {
+            let data = { ...this.formData };
+
+            this.saving = true;
+            this.$http
+                .post('/attractions/save', data, { body: 'json' })
+                .then(res => {
+                    this.saving = false;
+                    this.$message.success('成功');
+                    this.$router.go(-1);
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.saving = false;
+                    this.$message.error(e.error);
+                });
+        },
+        onDelete() {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+                .then(() => {
+                    return this.$http.post(`/attractions/del/${this.formData.id}`);
+                })
+                .then(() => {
+                    this.$message.success('删除成功');
+                    this.$router.go(-1);
+                })
+                .catch(e => {
+                    if (e !== 'cancel') {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    }
+                });
+        }
+    }
+};
+</script>
+<style lang="less" scoped></style>

+ 3 - 3
src/main/vue/src/views/BrandList.vue

@@ -94,7 +94,7 @@ export default {
             return {
                 search: this.search,
                 query: {
-                    brand: false
+                    brand: true
                 }
             };
         },
@@ -106,7 +106,7 @@ export default {
         },
         addRow() {
             this.$router.push({
-                path: '/attractionsEdit',
+                path: '/brandEdit',
                 query: {
                     ...this.$route.query
                 }
@@ -114,7 +114,7 @@ export default {
         },
         editRow(row) {
             this.$router.push({
-                path: '/attractionsEdit',
+                path: '/brandEdit',
                 query: {
                     id: row.id
                 }

+ 1 - 1
src/main/vue/src/views/CouponList.vue

@@ -25,7 +25,7 @@
         >
             <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
             <el-table-column prop="id" label="ID" width="100"> </el-table-column>
-            <el-table-column prop="attractionsId" label="品牌"> </el-table-column>
+            <el-table-column prop="attractionsName" label="品牌名称" show-overflow-tooltip> </el-table-column>
             <el-table-column prop="name" label="名称"> </el-table-column>
             <el-table-column prop="price" label="价格"> </el-table-column>
             <el-table-column prop="content" label="详情"> </el-table-column>

+ 119 - 0
src/main/vue/src/views/UserCouponEdit.vue

@@ -0,0 +1,119 @@
+<template>
+    <div class="edit-view">
+        <el-form
+            :model="formData"
+            :rules="rules"
+            ref="form"
+            label-width="94px"
+            label-position="right"
+            size="small"
+            style="max-width: 500px;"
+        >
+            <el-form-item prop="userId" label="用户id">
+                <el-input-number type="number" v-model="formData.userId"></el-input-number>
+            </el-form-item>
+            <el-form-item prop="couponId" label="优惠券id">
+                <el-input-number type="number" v-model="formData.couponId"></el-input-number>
+            </el-form-item>
+            <el-form-item prop="isUse" label="是否已使用">
+                <el-input v-model="formData.isUse"></el-input>
+            </el-form-item>
+            <el-form-item prop="useTime" label="使用时间">
+                <el-date-picker
+                    v-model="formData.useTime"
+                    type="datetime"
+                    value-format="yyyy-MM-dd HH:mm:ss"
+                    placeholder="选择日期时间"
+                >
+                </el-date-picker>
+            </el-form-item>
+            <el-form-item prop="writeOffUserId" label="核销人">
+                <el-input-number type="number" v-model="formData.writeOffUserId"></el-input-number>
+            </el-form-item>
+            <el-form-item prop="period" label="有效期">
+                <el-date-picker
+                    v-model="formData.period"
+                    type="datetime"
+                    value-format="yyyy-MM-dd HH:mm:ss"
+                    placeholder="选择日期时间"
+                >
+                </el-date-picker>
+            </el-form-item>
+            <el-form-item>
+                <el-button @click="onSave" :loading="saving" type="primary">保存</el-button>
+                <el-button @click="onDelete" :loading="saving" type="danger" v-if="formData.id">删除 </el-button>
+                <el-button @click="$router.go(-1)">取消</el-button>
+            </el-form-item>
+        </el-form>
+    </div>
+</template>
+<script>
+export default {
+    name: 'UserCouponEdit',
+    created() {
+        if (this.$route.query.id) {
+            this.$http
+                .get('userCoupon/get/' + this.$route.query.id)
+                .then(res => {
+                    this.formData = res;
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.$message.error(e.error);
+                });
+        }
+    },
+    data() {
+        return {
+            saving: false,
+            formData: {},
+            rules: {}
+        };
+    },
+    methods: {
+        onSave() {
+            this.$refs.form.validate(valid => {
+                if (valid) {
+                    this.submit();
+                } else {
+                    return false;
+                }
+            });
+        },
+        submit() {
+            let data = { ...this.formData };
+
+            this.saving = true;
+            this.$http
+                .post('/userCoupon/save', data, { body: 'json' })
+                .then(res => {
+                    this.saving = false;
+                    this.$message.success('成功');
+                    this.$router.go(-1);
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.saving = false;
+                    this.$message.error(e.error);
+                });
+        },
+        onDelete() {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+                .then(() => {
+                    return this.$http.post(`/userCoupon/del/${this.formData.id}`);
+                })
+                .then(() => {
+                    this.$message.success('删除成功');
+                    this.$router.go(-1);
+                })
+                .catch(e => {
+                    if (e !== 'cancel') {
+                        console.log(e);
+                        this.$message.error(e.error);
+                    }
+                });
+        }
+    }
+};
+</script>
+<style lang="less" scoped></style>

+ 161 - 0
src/main/vue/src/views/UserCouponList.vue

@@ -0,0 +1,161 @@
+<template>
+    <div class="list-view">
+        <div class="filters-container">
+            <el-input placeholder="输入关键字" v-model="search" clearable class="filter-item"></el-input>
+            <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button>
+            <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item">添加 </el-button>
+            <el-button
+                @click="download"
+                type="primary"
+                icon="el-icon-download"
+                :loading="downloading"
+                class="filter-item"
+                >导出EXCEL
+            </el-button>
+        </div>
+        <el-table
+            :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"
+            :height="tableHeight"
+        >
+            <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+            <el-table-column prop="id" label="ID" width="100"> </el-table-column>
+            <el-table-column prop="userId" label="用户id"> </el-table-column>
+            <el-table-column prop="couponId" label="优惠券id"> </el-table-column>
+            <el-table-column prop="isUse" label="是否已使用"> </el-table-column>
+            <el-table-column prop="useTime" label="使用时间"> </el-table-column>
+            <el-table-column prop="writeOffUserId" label="核销人"> </el-table-column>
+            <el-table-column prop="period" label="有效期"> </el-table-column>
+            <el-table-column label="操作" align="center" fixed="right" min-width="150">
+                <template slot-scope="{ row }">
+                    <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
+                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
+                </template>
+            </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> -->
+            <el-pagination
+                background
+                @size-change="onSizeChange"
+                @current-change="onCurrentChange"
+                :current-page="page"
+                :page-sizes="[10, 20, 30, 40, 50]"
+                :page-size="pageSize"
+                layout="total, sizes, prev, pager, next, jumper"
+                :total="totalElements"
+            >
+            </el-pagination>
+        </div>
+    </div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import pageableTable from '@/mixins/pageableTable';
+
+export default {
+    name: 'UserCouponList',
+    mixins: [pageableTable],
+    data() {
+        return {
+            multipleMode: false,
+            search: '',
+            url: '/userCoupon/all',
+            downloading: false
+        };
+    },
+    computed: {
+        selection() {
+            return this.$refs.table.selection.map(i => i.id);
+        }
+    },
+    methods: {
+        beforeGetData() {
+            return { search: this.search };
+        },
+        toggleMultipleMode(multipleMode) {
+            this.multipleMode = multipleMode;
+            if (!multipleMode) {
+                this.$refs.table.clearSelection();
+            }
+        },
+        addRow() {
+            this.$router.push({
+                path: '/userCouponEdit',
+                query: {
+                    ...this.$route.query
+                }
+            });
+        },
+        editRow(row) {
+            this.$router.push({
+                path: '/userCouponEdit',
+                query: {
+                    id: row.id
+                }
+            });
+        },
+        download() {
+            this.downloading = true;
+            this.$axios
+                .get('/userCoupon/excel', {
+                    responseType: 'blob',
+                    params: { size: 10000 }
+                })
+                .then(res => {
+                    console.log(res);
+                    this.downloading = false;
+                    const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+                    const link = document.createElement('a');
+                    link.href = downloadUrl;
+                    link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+                    document.body.appendChild(link);
+                    link.click();
+                    link.remove();
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.downloading = false;
+                    this.$message.error(e.error);
+                });
+        },
+        operation1() {
+            this.$notify({
+                title: '提示',
+                message: this.selection
+            });
+        },
+        operation2() {
+            this.$message('操作2');
+        },
+        deleteRow(row) {
+            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+                .then(() => {
+                    return this.$http.post(`/userCoupon/del/${row.id}`);
+                })
+                .then(() => {
+                    this.$message.success('删除成功');
+                    this.getData();
+                })
+                .catch(e => {
+                    if (e !== 'cancel') {
+                        this.$message.error(e.error);
+                    }
+                });
+        }
+    }
+};
+</script>
+<style lang="less" scoped></style>