浏览代码

Merge branch '2.0.0' of http://git.ycjcjy.com/fuxingfan/smartCommunity into 2.0.0

魏熙美 6 年前
父节点
当前提交
70bdf611ef

+ 77
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/TpShopController.java 查看文件

1
 package com.community.huiju.controller;
1
 package com.community.huiju.controller;
2
 
2
 
3
 
3
 
4
+import com.alibaba.fastjson.JSONArray;
5
+import com.alibaba.fastjson.JSONObject;
4
 import com.community.commom.mode.ResponseBean;
6
 import com.community.commom.mode.ResponseBean;
5
 import com.community.commom.session.UserElement;
7
 import com.community.commom.session.UserElement;
6
 import com.community.huiju.common.base.BaseController;
8
 import com.community.huiju.common.base.BaseController;
21
 
23
 
22
 import javax.servlet.http.HttpSession;
24
 import javax.servlet.http.HttpSession;
23
 import java.time.LocalDateTime;
25
 import java.time.LocalDateTime;
26
+import java.util.ArrayList;
27
+import java.util.List;
24
 
28
 
25
 /**
29
 /**
26
  * <p>
30
  * <p>
87
 		responseBean.addSuccess(tpShop);
91
 		responseBean.addSuccess(tpShop);
88
 		return responseBean;
92
 		return responseBean;
89
 	}
93
 	}
94
+	
95
+	@ApiOperation(value = "更新商铺", notes = "更新商铺")
96
+	@ApiImplicitParams({
97
+			@ApiImplicitParam(paramType = "body", dataType = "TpShop", name = "shop", value = "商铺"),
98
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
99
+	})
100
+	@RequestMapping(value = "/shop/update",method = RequestMethod.POST)
101
+	public ResponseBean updateShop(@RequestBody TpShop shop, HttpSession session){
102
+		ResponseBean responseBean = new ResponseBean();
103
+		UserElement userElement = getUserElement(session);
104
+		responseBean = shopService.updateShop(shop,userElement);
105
+		return responseBean;
106
+	}
107
+	
108
+	@ApiOperation(value = "上架商铺", notes = "上架商铺")
109
+	@ApiImplicitParams({
110
+			@ApiImplicitParam(paramType = "body", dataType = "String", name = "jsonString", value = "商铺id集合"),
111
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
112
+	})
113
+	@RequestMapping(value = "/shop/shelf",method = RequestMethod.POST)
114
+	public ResponseBean shelfShop(@RequestBody String jsonString, HttpSession session){
115
+		ResponseBean responseBean = new ResponseBean();
116
+		UserElement userElement = getUserElement(session);
117
+		JSONObject jsonObject = JSONObject.parseObject(jsonString);
118
+		JSONArray ids = jsonObject.getJSONArray("idArray");
119
+		List<TpShop> tpShopList = new ArrayList<>();
120
+		for (Object id : ids){
121
+			TpShop tpShop = new TpShop();
122
+			tpShop.setId((Integer) id);
123
+			tpShop.setShopStatus("1");
124
+			tpShop.setUpdateUser(userElement.getId());
125
+			tpShop.setUpdateDate(LocalDateTime.now());
126
+			tpShopList.add(tpShop);
127
+		}
128
+		
129
+		boolean state = shopService.updateBatchById(tpShopList);
130
+		if (state){
131
+			responseBean.addSuccess("上架成功");
132
+		}else{
133
+			responseBean.addError("上架失败");
134
+		}
135
+		return responseBean;
136
+	}
137
+	
138
+	@ApiOperation(value = "下架商铺", notes = "下架商铺")
139
+	@ApiImplicitParams({
140
+			@ApiImplicitParam(paramType = "body", dataType = "String", name = "jsonString", value = "商铺id集合"),
141
+			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
142
+	})
143
+	@RequestMapping(value = "/shop/obtained",method = RequestMethod.POST)
144
+	public ResponseBean obtainedShop(@RequestBody String jsonString, HttpSession session){
145
+		ResponseBean responseBean = new ResponseBean();
146
+		UserElement userElement = getUserElement(session);
147
+		JSONObject jsonObject = JSONObject.parseObject(jsonString);
148
+		JSONArray ids = jsonObject.getJSONArray("idArray");
149
+		List<TpShop> tpShopList = new ArrayList<>();
150
+		for (Object id : ids){
151
+			TpShop tpShop = new TpShop();
152
+			tpShop.setId((Integer) id);
153
+			tpShop.setShopStatus("2");
154
+			tpShop.setUpdateUser(userElement.getId());
155
+			tpShop.setUpdateDate(LocalDateTime.now());
156
+			tpShopList.add(tpShop);
157
+		}
158
+		
159
+		boolean state = shopService.updateBatchById(tpShopList);
160
+		if (state){
161
+			responseBean.addSuccess("下架成功");
162
+		}else{
163
+			responseBean.addError("下架失败");
164
+		}
165
+		return responseBean;
166
+	}
90
 }
167
 }

+ 8
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/ITpShopService.java 查看文件

42
 	 * @return
42
 	 * @return
43
 	 */
43
 	 */
44
 	TpShop getShopById(Integer id);
44
 	TpShop getShopById(Integer id);
45
+	
46
+	/**
47
+	 * 更新商铺信息
48
+	 * @param shop
49
+	 * @param userElement
50
+	 * @return
51
+	 */
52
+	ResponseBean updateShop(TpShop shop, UserElement userElement);
45
 }
53
 }

+ 52
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TpShopServiceImpl.java 查看文件

12
 import com.community.huiju.service.ITpShopService;
12
 import com.community.huiju.service.ITpShopService;
13
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
15
 
16
 
16
 import java.time.LocalDateTime;
17
 import java.time.LocalDateTime;
17
 import java.util.ArrayList;
18
 import java.util.ArrayList;
28
  * @since 2019-05-10
29
  * @since 2019-05-10
29
  */
30
  */
30
 @Service
31
 @Service
32
+@Transactional(rollbackFor = Exception.class)
31
 public class TpShopServiceImpl extends ServiceImpl<TpShopMapper, TpShop> implements ITpShopService {
33
 public class TpShopServiceImpl extends ServiceImpl<TpShopMapper, TpShop> implements ITpShopService {
32
 
34
 
33
 	@Autowired
35
 	@Autowired
152
 		tpShop.setAppCarouselImg(carouselUrlList);
154
 		tpShop.setAppCarouselImg(carouselUrlList);
153
 		return tpShop;
155
 		return tpShop;
154
 	}
156
 	}
157
+	
158
+	/**
159
+	 * 更新商铺信息
160
+	 *
161
+	 * @param shop
162
+	 * @param userElement
163
+	 * @return
164
+	 */
165
+	@Override
166
+	public ResponseBean updateShop(TpShop shop, UserElement userElement) {
167
+		ResponseBean responseBean = new ResponseBean();
168
+		shopMapper.updateById(shop);
169
+		//添加商铺app首页图片信息
170
+		TpShopImg appIndexShopImg = new TpShopImg();
171
+		appIndexShopImg.setImgUrl(shop.getAppIndexImg());
172
+		QueryWrapper<TpShopImg> tpShopImgQueryWrapper = new QueryWrapper<>();
173
+		tpShopImgQueryWrapper.eq("community_id",shop.getCommunityId());
174
+		tpShopImgQueryWrapper.eq("shop_id",shop.getId());
175
+		tpShopImgQueryWrapper.eq("img_type","1");
176
+		shopImgMapper.update(appIndexShopImg,tpShopImgQueryWrapper);
177
+		//添加商铺app列表图片信息
178
+		TpShopImg appListShopImg = new TpShopImg();
179
+		appListShopImg.setImgUrl(shop.getAppListImg());
180
+		QueryWrapper<TpShopImg> tpShopImgListWrapper = new QueryWrapper<>();
181
+		tpShopImgListWrapper.eq("community_id",shop.getCommunityId());
182
+		tpShopImgListWrapper.eq("shop_id",shop.getId());
183
+		tpShopImgListWrapper.eq("img_type","2");
184
+		shopImgMapper.update(appListShopImg,tpShopImgListWrapper);
185
+		//先删除在批量添加app轮播图片
186
+		QueryWrapper<TpShopImg> tpShopImgCarouselWrapper = new QueryWrapper<>();
187
+		tpShopImgCarouselWrapper.eq("community_id",shop.getCommunityId());
188
+		tpShopImgCarouselWrapper.eq("shop_id",shop.getId());
189
+		tpShopImgCarouselWrapper.eq("img_type","3");
190
+		shopImgMapper.delete(tpShopImgCarouselWrapper);
191
+		//重新添加
192
+		List<String> list = shop.getAppCarouselImg();
193
+		List<TpShopImg> carouselList = new ArrayList<>();
194
+		list.stream().forEach(e -> {
195
+			TpShopImg appCarouselImg = new TpShopImg();
196
+			appCarouselImg.setCommunityId(shop.getCommunityId());
197
+			appCarouselImg.setCreateDate(LocalDateTime.now());
198
+			appCarouselImg.setImgType("3");
199
+			appCarouselImg.setShopId(shop.getId());
200
+			appCarouselImg.setImgUrl(e);
201
+			carouselList.add(appCarouselImg);
202
+		});
203
+		shopImgMapper.batchSave(carouselList);
204
+		responseBean.addSuccess("修改成功");
205
+		return responseBean;
206
+	}
155
 }
207
 }

+ 28
- 0
VUECODE/smart-property-manage/src/api/shopType.js 查看文件

56
   })
56
   })
57
 }
57
 }
58
 
58
 
59
+export function updateShop(listQuery) {
60
+  return request({
61
+    url: '/shop/update',
62
+    method: 'post',
63
+    data: listQuery
64
+  })
65
+}
66
+
59
 export function deleteShopType(ids) {
67
 export function deleteShopType(ids) {
60
   return request({
68
   return request({
61
     url: '/shop/delete/type',
69
     url: '/shop/delete/type',
66
   })
74
   })
67
 }
75
 }
68
 
76
 
77
+export function obtainedShop(ids) {
78
+  return request({
79
+    url: '/shop/obtained',
80
+    method: 'post',
81
+    data: {
82
+      idArray: ids
83
+    }
84
+  })
85
+}
86
+
87
+export function shelfShop(ids) {
88
+  return request({
89
+    url: '/shop/shelf',
90
+    method: 'post',
91
+    data: {
92
+      idArray: ids
93
+    }
94
+  })
95
+}
96
+
69
 export function fetchShopList(query) {
97
 export function fetchShopList(query) {
70
   return request({
98
   return request({
71
     url: '/shops',
99
     url: '/shops',

+ 28
- 1
VUECODE/smart-property-manage/src/store/modules/shopType.js 查看文件

1
-import { fetchShopTypeList, changeShopSetting, addShopType, getShopType, updateShopType, deleteShopType, fetchShopList, fetchShopTypeSelect, addShop, getShop } from '@/api/shopType'
1
+import { fetchShopTypeList, changeShopSetting, addShopType, getShopType, updateShopType, deleteShopType, fetchShopList, fetchShopTypeSelect, addShop, getShop, updateShop, shelfShop, obtainedShop } from '@/api/shopType'
2
 
2
 
3
 const transaction = {
3
 const transaction = {
4
   namespaced: true,
4
   namespaced: true,
75
         })
75
         })
76
       })
76
       })
77
     },
77
     },
78
+    UpdateShop({ commit }, listQuery) {
79
+      return new Promise((resolve, reject) => {
80
+        updateShop(listQuery).then(response => {
81
+          resolve(response)
82
+        }).catch(error => {
83
+          reject(error)
84
+        })
85
+      })
86
+    },
78
     DeleteShopType({ commit }, ids) {
87
     DeleteShopType({ commit }, ids) {
79
       return new Promise((resolve, reject) => {
88
       return new Promise((resolve, reject) => {
80
         deleteShopType(ids).then(response => {
89
         deleteShopType(ids).then(response => {
84
         })
93
         })
85
       })
94
       })
86
     },
95
     },
96
+    ShelfShop({ commit }, ids) {
97
+      return new Promise((resolve, reject) => {
98
+        shelfShop(ids).then(response => {
99
+          resolve(response)
100
+        }).catch(error => {
101
+          reject(error)
102
+        })
103
+      })
104
+    },
105
+    ObtainedShop({ commit }, ids) {
106
+      return new Promise((resolve, reject) => {
107
+        obtainedShop(ids).then(response => {
108
+          resolve(response)
109
+        }).catch(error => {
110
+          reject(error)
111
+        })
112
+      })
113
+    },
87
     FetchShopList({ commit }, listQuery) {
114
     FetchShopList({ commit }, listQuery) {
88
       return new Promise((resolve, reject) => {
115
       return new Promise((resolve, reject) => {
89
         fetchShopList(listQuery).then(response => {
116
         fetchShopList(listQuery).then(response => {

+ 4
- 4
VUECODE/smart-property-manage/src/views/shop/shopEdit.vue 查看文件

242
     submitForm(formName) { // 提交
242
     submitForm(formName) { // 提交
243
       this.$refs[formName].validate((valid) => {
243
       this.$refs[formName].validate((valid) => {
244
         if (valid) {
244
         if (valid) {
245
-          this.addShop()
245
+          this.updateShop()
246
         } else {
246
         } else {
247
           console.log('error submit!!')
247
           console.log('error submit!!')
248
           return false
248
           return false
258
       console.log(this.isRegistered)
258
       console.log(this.isRegistered)
259
       this.$refs[formName].resetFields()
259
       this.$refs[formName].resetFields()
260
     },
260
     },
261
-    addShop() {
261
+    updateShop() {
262
       // 加载框
262
       // 加载框
263
       const loading = this.$loading({
263
       const loading = this.$loading({
264
         lock: true,
264
         lock: true,
266
         spinner: 'el-icon-loading',
266
         spinner: 'el-icon-loading',
267
         background: 'rgba(0, 0, 0, 0.7)'
267
         background: 'rgba(0, 0, 0, 0.7)'
268
       })
268
       })
269
-      this.$store.dispatch('shopType/AddShop', this.listData).then((res) => {
269
+      this.$store.dispatch('shopType/UpdateShop', this.listData).then((res) => {
270
         if (res.code === '0') {
270
         if (res.code === '0') {
271
           this.$message({
271
           this.$message({
272
             message: res.message,
272
             message: res.message,
280
         loading.close()
280
         loading.close()
281
       }).catch(() => {
281
       }).catch(() => {
282
         loading.close()
282
         loading.close()
283
-        console.log('error AddBuilding')
283
+        console.log('error UpdateShop')
284
       })
284
       })
285
     }
285
     }
286
   }
286
   }

+ 34
- 5
VUECODE/smart-property-manage/src/views/shop/shopIndex.vue 查看文件

27
     <div class="button">
27
     <div class="button">
28
       <el-button type="primary" @click="add">添加</el-button>
28
       <el-button type="primary" @click="add">添加</el-button>
29
       <el-button type="warning" @click="edit">修改</el-button>
29
       <el-button type="warning" @click="edit">修改</el-button>
30
-      <el-button type="danger" @click="deleteAnnouncement">下架商铺</el-button>
31
-      <el-button type="danger" @click="deleteAnnouncement">上架商铺</el-button>
30
+      <el-button type="danger" @click="shelfShop">上架商铺</el-button>
31
+      <el-button type="danger" @click="obtainedShop">下架商铺</el-button>
32
     </div>
32
     </div>
33
     <el-table
33
     <el-table
34
       v-loading="listLoading"
34
       v-loading="listLoading"
43
         width="55"/>
43
         width="55"/>
44
       <el-table-column prop="id" label="商铺编号" align="center"/>
44
       <el-table-column prop="id" label="商铺编号" align="center"/>
45
       <el-table-column prop="shopName" label="商铺名称" align="center" >
45
       <el-table-column prop="shopName" label="商铺名称" align="center" >
46
-        <template slot-scope="scope"><a><span style="color: #63B8FF" @click="clickTitle(scope.row.shopName)">{{ scope.row.shopName }}</span></a></template>
46
+        <template slot-scope="scope"><a><span style="color: #63B8FF" @click="clickTitle(scope.row.id)">{{ scope.row.shopName }}</span></a></template>
47
       </el-table-column>
47
       </el-table-column>
48
       <el-table-column prop="imgUrl" label="首页展示图" align="center">
48
       <el-table-column prop="imgUrl" label="首页展示图" align="center">
49
         <template scope="scope">
49
         <template scope="scope">
215
         this.deleteId()     
215
         this.deleteId()     
216
       })    
216
       })    
217
     },
217
     },
218
-
218
+    shelfShop() {
219
+      this.listLoading = true
220
+      const ids = this.deleteIds
221
+      if (ids < 1) {
222
+        this.$message.error('请至少选择一行数据上架!')
223
+        return
224
+      }
225
+      this.$store.dispatch('shopType/ShelfShop', ids).then((res) => {
226
+        this.listLoading = false
227
+        this.dataQuery()
228
+      }).catch(() => {
229
+        this.listLoading = false
230
+        console.log('error DeleteAnnouncement')
231
+      })
232
+    },
233
+    obtainedShop() {
234
+      this.listLoading = true
235
+      const ids = this.deleteIds
236
+      if (ids < 1) {
237
+        this.$message.error('请至少选择一行数据下架!')
238
+        return
239
+      }
240
+      this.$store.dispatch('shopType/ObtainedShop', ids).then((res) => {
241
+        this.listLoading = false
242
+        this.dataQuery()
243
+      }).catch(() => {
244
+        this.listLoading = false
245
+        console.log('error DeleteAnnouncement')
246
+      })
247
+    },
219
     deleteId(){
248
     deleteId(){
220
        const ids = this.deleteIds
249
        const ids = this.deleteIds
221
       this.listLoading = true
250
       this.listLoading = true
232
 
261
 
233
 
262
 
234
     clickTitle(id) {
263
     clickTitle(id) {
235
-      this.$router.push({ name: 'contentParticulars-details', query: { id: id }})
264
+      this.$router.push({ name: 'shop-edit', query: { id: id }})
236
     },
265
     },
237
     formatDate(val) {
266
     formatDate(val) {
238
       if (val === null) {
267
       if (val === null) {