Browse Source

兑换码

yuhaitao14 7 years ago
parent
commit
c0f5c09074

+ 22 - 0
shop/src/main/java/com/zskk/shop/controller/admin/ExchangeCodeController.java

@@ -8,7 +8,9 @@
 
 package com.zskk.shop.controller.admin;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -97,4 +99,24 @@ public class ExchangeCodeController extends AbstractController {
 		}
 		return new ControllerResult(list);
 	}
+	
+	@RequestMapping("getitemdetail")
+	@ResponseBody
+	public ControllerResult getItemDetail(@RequestParam("eicode") String eicode){
+		ExchangeCodeItem item = exchangeCodeService.queryOneExchangeCodeItem(eicode);
+		if (item == null){
+			throw new ZSKKException(ErrorConstant.EICODE_ERROR);
+		}
+		//密码脱敏
+		item.setEipwd(item.getEipwd().replaceAll(".", "*"));
+		
+		ExchangeCode obj = exchangeCodeService.queryOneExchangeCode(item.getEid());
+		GoodBase good = goodService.queryOneGoodBase(obj.getGid());
+		obj.setGname(good.getName());
+		
+		Map<String, Object> result = new HashMap<>();
+		result.put("item", item);
+		result.put("exchangecode", obj);
+		return new ControllerResult(result);
+	}
 }

+ 1 - 0
shop/src/main/java/com/zskk/shop/exception/ErrorConstant.java

@@ -16,6 +16,7 @@ public class ErrorConstant {
 	public static final ZSKKError ORDER_PAYED_ERROR		= new ZSKKError(10001, "已支付");
 	public static final ZSKKError NO_SET_PACKAGE 		= new ZSKKError(100002, "您还没有设置套餐");
 	public static final ZSKKError NO_SET_DESCRIBE		= new ZSKKError(100002, "您还没有设置商品详细");
+	public static final ZSKKError EICODE_ERROR			= new ZSKKError(100003, "兑换码不存在");
 	
 	
 }

+ 6 - 2
shop/src/main/java/com/zskk/shop/service/ExchangeCodeService.java

@@ -144,12 +144,16 @@ public class ExchangeCodeService {
 		return exchangeCodeMapper.queryAllExchangeCodeItems(eid, status);
 	}
 	
+	public ExchangeCodeItem queryOneExchangeCodeItem(String eicode){
+		return exchangeCodeMapper.queryOneExchangeCodeItem(eicode);
+	}
+	
 	private String getTimesKey(String timeKey){
 		return "SHOP_EXCHANGE_CODE_DAY_TIMES" + timeKey;
 	}
 
 	
-	public String getItemCode(String timeKey, Long dayTimes, Integer i){
+	private String getItemCode(String timeKey, Long dayTimes, Integer i){
 		if (i < 10000){
 			return timeKey + DAY_TIME_FORMAT.format(dayTimes) + ITEM_CODE_FORMAT.format(i);
 		}else{
@@ -158,7 +162,7 @@ public class ExchangeCodeService {
 		
 	}
 	
-	public String randomPwd(){
+	private String randomPwd(){
 		return UUID.randomUUID().toString().substring(0, 6);
 	}
 	

+ 1 - 0
shop/static/manager/src/api/index.js

@@ -100,6 +100,7 @@ export default {
     exchangeCodeCreate: (params, vue) => post(`${serverPath}manage/exchangecode/create`, params, vue),
     exchangeCodeUpdate: (params, vue) => post(`${serverPath}manage/exchangecode/update`, params, vue),
     echangeCodeGetitems: (params, vue) => post(`${serverPath}manage/exchangecode/getitems`, params, vue),
+    echangeCodeGetItemdetail: (params, vue) => post(`${serverPath}manage/exchangecode/getitemdetail`, params, vue),
 
     loginout: (params, vue) => post(`${serverPath}help/loginout`, params, vue),
 }

+ 1 - 0
shop/static/manager/src/components/Sidebar.vue

@@ -45,6 +45,7 @@ export default {
       items.push({ icon: '', index: '/faqManage', title: '常见问题'})
       items.push({ icon: '', index: '/sysConfig', title: '系统配置'})
       items.push({ icon: '', index: '/bannerManage', title: 'Banner管理'})
+      items.push({ icon: '', index: '/exchangeCodeDetail', title: '兑换码查询'})
       this.items  = items
       for (var i in items){
           var item = items[i]

+ 171 - 0
shop/static/manager/src/components/page/exchange/Detail.vue

@@ -0,0 +1,171 @@
+<template>
+    <div>
+        <el-row>
+            <el-col :span="6">
+                <el-input v-model="eicode" placeholder="请输入兑换码"></el-input>
+            </el-col>
+            <el-col :span="1">
+                &nbsp;
+            </el-col>
+            <el-col :span="5">
+                <el-button type="primary" @click="search">查询</el-button>
+            </el-col>
+        </el-row>
+
+        <div v-bind:class="{show: isSearched, hidden:!isSearched}" class="ecdate">
+            <el-row>
+                <el-col :span="12" class="eccontent">
+                    <el-card class="box-card">
+                        <div slot="header" class="clearfix">
+                            <span>批次信息</span>
+                        </div>
+                        <div>
+                            <el-row>
+                                <el-col :span="8">商品名称:</el-col>
+                                <el-col :span="16">{{exchangecode.gname}}</el-col>
+                            </el-row>
+                            <el-row class="dataitem">
+                                <el-col :span="8">说明:</el-col>
+                                <el-col :span="16">{{exchangecode.remark}}</el-col>
+                            </el-row>
+                            <el-row class="dataitem">
+                                <el-col :span="8">创建人:</el-col>
+                                <el-col :span="16">{{exchangecode.cuname}}</el-col>
+                            </el-row>
+                            <el-row class="dataitem">
+                                <el-col :span="8">生成数量:</el-col>
+                                <el-col :span="16">{{exchangecode.num}}</el-col>
+                            </el-row>
+                            <el-row class="dataitem">
+                                <el-col :span="8">状态:</el-col>
+                                <el-col :span="16">
+                                    <template v-if="exchangecode.status === 1">
+                                        <p class="online">启用</p>
+                                    </template>
+                                    <template v-else>
+                                        <p class="offline">禁用</p>
+                                    </template>
+                                </el-col>
+                            </el-row>
+                            <el-row class="dataitem">
+                                <el-col :span="8">截止日期:</el-col>
+                                <el-col :span="16">{{exchangecode.endtime}}</el-col>
+                            </el-row>
+                        </div>
+
+                    </el-card>
+                </el-col>
+                <el-col :span="12" class="eccontent">
+                    <el-card class="box-card">
+                        <div slot="header" class="clearfix">
+                            <span>兑换码信息</span>
+                        </div>
+                        <el-row>
+                            <el-col :span="8">兑换码:</el-col>
+                            <el-col :span="16">{{item.eicode}}</el-col>
+                        </el-row>
+                        <el-row class="dataitem">
+                            <el-col :span="8">密码:</el-col>
+                            <el-col :span="16">{{item.eipwd}}</el-col>
+                        </el-row>
+                        <el-row class="dataitem">
+                            <el-col :span="8">使用状态:</el-col>
+                            <el-col :span="16">
+                                <template v-if="item.status === 1">
+                                    <p class="online">已使用</p>
+                                </template>
+                                <template v-else>
+                                    <p class="offline">未使用</p>
+                                </template>
+                            </el-col>
+                        </el-row>
+                        <el-row class="dataitem">
+                            <el-col :span="8">使用时间:</el-col>
+                            <el-col :span="16">{{item.utime}}</el-col>
+                        </el-row>
+                        <el-row class="dataitem">
+                            <el-col :span="8">使用信息:</el-col>
+                            <el-col :span="16">{{item.extend}}</el-col>
+                        </el-row>
+                    </el-card>
+                </el-col>
+            </el-row>
+        </div>
+    </div>
+</template>
+<script>
+import { timeFormater } from '../../../util'
+export default {
+  data() {
+    return {
+      eicode: '',
+      exchangecode: {},
+      item: {},
+      isSearched: false
+    }
+  },
+  methods: {
+    endTimeFormat(row) {
+      return timeFormater(row.endtime)
+    },
+    utimeFormat(row) {
+      if (row.utime === 0) {
+        return '-'
+      } else {
+        return timeFormater(row.utime)
+      }
+    },
+    utimeFormat(row) {
+      if (row.utime === 0) {
+        return '-'
+      } else {
+        return timeFormater(row.utime)
+      }
+    },
+    search: function() {
+      this.$http
+        .echangeCodeGetItemdetail({ eicode: this.eicode }, this)
+        .then(res => {
+          if (res.code === 0) {
+            let exchangecode = res.obj.exchangecode
+            exchangecode.endtime = this.endTimeFormat(exchangecode)
+            this.exchangecode = res.obj.exchangecode
+
+            let item = res.obj.item
+            item.utime = this.utimeFormat(item)
+            this.item = item
+            this.isSearched = true
+          }
+        })
+    }
+  }
+}
+</script>
+
+
+<style>
+.online {
+  color: #67c23a;
+}
+.offline {
+  color: #f56c6c;
+}
+
+.ecdate {
+  margin-top: 20px;
+}
+.dataitem {
+  margin-top: 10px;
+}
+.eccontent {
+  padding: 10px;
+}
+
+.show {
+  display: block;
+}
+
+.hidden {
+  display: none;
+}
+</style>

+ 4 - 0
shop/static/manager/src/router/index.js

@@ -85,6 +85,10 @@ export default new Router({
                 {
                     path: 'exchangeCodeEdit',
                     component: resolve => require(['../components/page/exchange/Edit'], resolve)
+                },
+                {
+                    path: 'exchangeCodeDetail',
+                    component: resolve => require(['../components/page/exchange/Detail'], resolve)
                 }
             ]
         },