| | |
| | | package com.dsh.guns.modular.system.controller.code; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.feignClient.account.CityManagerClient; |
| | | import com.dsh.course.feignClient.account.model.CityManager; |
| | | import com.dsh.course.feignClient.activity.CouponClient; |
| | | import com.dsh.course.feignClient.activity.model.CouponListOfSearch; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.core.common.constant.factory.PageFactory; |
| | | import com.dsh.guns.core.util.ToolUtil; |
| | | import com.dsh.guns.modular.system.model.Region; |
| | | import com.dsh.guns.modular.system.service.IRegionService; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import com.dsh.guns.modular.system.util.OBSUploadUtil; |
| | | import org.apache.commons.beanutils.ConvertUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | |
| | | @Resource |
| | | private IRegionService regiService; |
| | | |
| | | @Resource |
| | | private IStoreService storeService; |
| | | |
| | | @Resource |
| | | private CouponClient client; |
| | | |
| | | @Resource |
| | | private CityManagerClient cmgrClient; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 跳转到优惠券管理首页 |
| | |
| | | * 跳转到添加 |
| | | */ |
| | | @RequestMapping("/coupon_add") |
| | | public String memberCouponAdd() { |
| | | return PREFIX + "coupon_add.html"; |
| | | public String memberCouponAdd(Model model) { |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | System.out.println(objectType); |
| | | model.addAttribute("userType",objectType); |
| | | return PREFIX + "TCouponAdd.html"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 跳转到门店管理列表页 |
| | | */ |
| | | @RequestMapping("/storeList") |
| | | public String storePage(Model model) { |
| | | return PREFIX + "TStoreList.html"; |
| | | } |
| | | |
| | | @RequestMapping("/storeDetailsOfSearch") |
| | | @ResponseBody |
| | | public Object listOfStore(Integer provinceId,Integer cityId,Integer cityManagerId,String storeName){ |
| | | System.out.println("provinceId"+provinceId); |
| | | System.out.println("cityId"+cityId); |
| | | System.out.println("cityManagerId"+cityManagerId); |
| | | System.out.println("storeName"+storeName); |
| | | String provinceCode = null; |
| | | String cityCode = null; |
| | | if (ToolUtil.isNotEmpty(provinceId)){ |
| | | Region provinceRegion = regiService.getById(provinceId); |
| | | provinceCode = provinceRegion.getCode(); |
| | | } |
| | | if (ToolUtil.isNotEmpty(cityId)){ |
| | | Region cityRegion = regiService.getById(cityId); |
| | | cityCode = cityRegion.getCode(); |
| | | } |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | List<Map<String,Object>> storeList = storeService.queryListOfpage(provinceCode,cityCode,cityManagerId,storeName,page); |
| | | if (storeList.size() > 0 ){ |
| | | for (Map<String, Object> stringObjectMap : storeList) { |
| | | String provinceName = (String) stringObjectMap.get("province"); |
| | | String cityName = (String) stringObjectMap.get("city"); |
| | | stringObjectMap.put("provinceCity",provinceName+cityName); |
| | | Integer managerId = (Integer) stringObjectMap.get("cityManagerId"); |
| | | CityManager cityManager = cmgrClient.queryCityManagerById(managerId); |
| | | if (ToolUtil.isNotEmpty(cityManager)){ |
| | | stringObjectMap.put("accountName",cityManager.getName()+"+"+cityManager.getPhone()); |
| | | } |
| | | } |
| | | } |
| | | return storeList; |
| | | } |
| | | |
| | | /** |
| | |
| | | ofSearch.setUserPopulation(userPopulation); |
| | | ofSearch.setStatus(status); |
| | | ofSearch.setState(state); |
| | | List<Map<String, Object>> mapList = client.getCouponListOfSearch(ofSearch); |
| | | page.setRecords(mapList); |
| | | return page.getRecords(); |
| | | return client.getCouponListOfSearch(ofSearch); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getProvince") |
| | | @ResponseBody |
| | | public Object getProvince(){ |
| | | return regiService.list(new LambdaQueryWrapper<Region>() |
| | | .eq(Region::getParentId,0)); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/getCity") |
| | | @ResponseBody |
| | | public Object getCity(Integer province){ |
| | | return regiService.list(new LambdaQueryWrapper<Region>() |
| | | .eq(Region::getParentId,province)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/uploadPic") |
| | | @ResponseBody |
| | | public Object add(@RequestParam("file") MultipartFile imgFile) throws IOException { |
| | | String originalFilename = imgFile.getOriginalFilename(); |
| | | String newName = originalFilename.substring(imgFile.getOriginalFilename().lastIndexOf(".")); |
| | | String url = OBSUploadUtil.inputStreamUpload(imgFile); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | //是否上传成功 |
| | | map.put("state", "SUCCESS"); |
| | | //现在文件名称 |
| | | map.put("title", newName); |
| | | //文件原名称 |
| | | map.put("original", originalFilename); |
| | | //文件类型 .+后缀名 |
| | | map.put("type", originalFilename.substring(imgFile.getOriginalFilename().lastIndexOf("."))); |
| | | //文件路径 |
| | | map.put("url", url); |
| | | //文件大小(字节数) |
| | | map.put("size", imgFile.getSize() + ""); |
| | | System.out.println(map); |
| | | return url; |
| | | } |
| | | |
| | | /** |
| | | * 提交添加 |
| | | */ |
| | | @RequestMapping(value = "/commitData") |
| | | public void commitData(){ |
| | | |
| | | |
| | | |
| | | } |
| | | } |