| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.feignClient.account.AppUserClient; |
| | | import com.dsh.course.feignClient.account.CityManagerClient; |
| | |
| | | import com.dsh.guns.core.base.tips.SuccessTip; |
| | | import com.dsh.guns.core.common.constant.factory.PageFactory; |
| | | import com.dsh.guns.core.util.ToolUtil; |
| | | import com.dsh.guns.modular.system.model.CouponDataVo; |
| | | import com.dsh.guns.modular.system.model.Region; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.service.IRegionService; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import com.dsh.guns.modular.system.model.*; |
| | | import com.dsh.guns.modular.system.service.*; |
| | | import com.dsh.guns.modular.system.util.OBSUploadUtil; |
| | | import com.dsh.guns.modular.system.util.OssUploadUtil; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | |
| | | @RequestMapping("/tCouponManage") |
| | | public class TCouponController { |
| | | |
| | | |
| | | |
| | | private String PREFIX = "/system/tCoupon/"; |
| | | |
| | | |
| | | @Resource |
| | | private IRegionService regiService; |
| | |
| | | |
| | | @Autowired |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | @Autowired |
| | | private IUserService userService; |
| | | @Autowired |
| | | private TOperatorService operatorService; |
| | | @Autowired |
| | | private TOperatorCityService operatorCityService; |
| | | |
| | | /** |
| | | * 跳转到优惠券管理首页 |
| | | */ |
| | | @RequestMapping("") |
| | | public String index(Model model) { |
| | | model.addAttribute("objectType",UserExt.getUser().getObjectType()); |
| | | return PREFIX + "TCoupon.html"; |
| | | } |
| | | |
| | |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | System.out.println(objectType); |
| | | model.addAttribute("userType",objectType); |
| | | return PREFIX + "TQuestionAdd.html"; |
| | | return PREFIX + "TCouponAdd.html"; |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/coupon_record/{id}") |
| | | public String memberCouponAdd(@PathVariable Integer id,Model model) { |
| | |
| | | model.addAttribute("type",coupon.getType()); |
| | | return PREFIX + "TCouponRecord.html"; |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping("/coupon_detail/{id}") |
| | | public String memberCouponDetail(@PathVariable Integer id,Model model) { |
| | |
| | | list = client.queryCity(coupon.getId()); |
| | | } |
| | | if(coupon.getUseScope()==3){ |
| | | // 门店ids |
| | | list1 = client.queryStore(coupon.getId()); |
| | | // 门店集合 |
| | | list2 = storeService.list(new LambdaQueryWrapper<TStore>().in(TStore::getId, list1)); |
| | | for (TStore tStore : list2) { |
| | | CityManager cityManager = cmgrClient.queryCityManagerById(tStore.getCityManagerId()); |
| | | if (ToolUtil.isNotEmpty(cityManager)){ |
| | | tStore.setProvince(tStore.getProvince()+tStore.getCity()); |
| | | tStore.setPhone(cityManager.getName()+"-"+cityManager.getPhone()); |
| | | if (coupon.getPublisherType() == 1){ |
| | | // 获取运营商id |
| | | Integer operatorId = tStore.getOperatorId(); |
| | | TOperator operator = operatorService.getById(operatorId); |
| | | User user = userService.getById(operator.getUserId()); |
| | | if (ToolUtil.isNotEmpty(user)){ |
| | | tStore.setProvince(tStore.getProvince()+tStore.getCity()); |
| | | tStore.setPhone(user.getName()+"-"+user.getPhone()); |
| | | } |
| | | } |
| | | if (coupon.getPublisherType() == 2) { |
| | | User byId = userService.getById(tStore.getStoreStaffId()); |
| | | |
| | | tStore.setProvince(tStore.getProvince() + tStore.getCity()); |
| | | tStore.setPhone(byId.getName() + "-" + byId.getPhone()); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | model.addAttribute("city",list); |
| | | model.addAttribute("store",list2); |
| | |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | System.out.println(objectType); |
| | | model.addAttribute("item",coupon); |
| | | model.addAttribute("objectType",objectType); |
| | | return PREFIX + "TCouponInfo.html"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping("/storeList") |
| | | public String storePage(Model model) { |
| | | return PREFIX + "TQuestionEdit.html"; |
| | | return PREFIX + "TStoreList.html"; |
| | | } |
| | | @RequestMapping("/updateType") |
| | | @ResponseBody |
| | |
| | | |
| | | @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(); |
| | | public Object listOfStore(String provinceId,String cityId,Integer operatorId,String storeName){ |
| | | if (UserExt.getUser().getObjectType()== 2){ |
| | | // 筛选这个运营商下的门店 |
| | | operatorId = UserExt.getUser().getObjectId(); |
| | | } |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | List<Map<String,Object>> storeList = storeService.queryListOfpage(provinceCode,cityCode,cityManagerId,storeName,page); |
| | | List<Map<String,Object>> storeList = storeService.queryListOfpage(provinceId,cityId,operatorId,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()); |
| | | Integer managerId = (Integer) stringObjectMap.get("operatorId"); |
| | | if (managerId == null){ |
| | | stringObjectMap.put("accountName","平台"); |
| | | }else{ |
| | | if (managerId==0){ |
| | | stringObjectMap.put("accountName","平台"); |
| | | }else{ |
| | | TOperator operator = operatorService.getOne(new QueryWrapper<TOperator>().eq("id", managerId)); |
| | | if (ToolUtil.isNotEmpty(operator)){ |
| | | stringObjectMap.put("accountName",operator.getName()); |
| | | }else{ |
| | | stringObjectMap.put("accountName","平台"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return storeList; |
| | | } |
| | | // 查询场地列表 |
| | | @RequestMapping("/siteDetailsOfSearch") |
| | | @ResponseBody |
| | | public Object siteDetailsOfSearch(String provinceId,String cityId,Integer operatorId,String storeName){ |
| | | Integer storeId = null; |
| | | if (UserExt.getUser().getObjectType()== 2){ |
| | | // 筛选这个运营商下的门店 |
| | | operatorId = UserExt.getUser().getObjectId(); |
| | | } |
| | | if (UserExt.getUser().getObjectType()== 3){ |
| | | // 筛选这个运营商下的门店 |
| | | storeId = UserExt.getUser().getObjectId(); |
| | | } |
| | | List<Map<String,Object>> storeList = storeService.querySiteListOfpage(provinceId,cityId,operatorId,storeName,storeId); |
| | | 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("operatorId"); |
| | | |
| | | Integer type = (Integer) stringObjectMap.get("type"); |
| | | if (type == 1){ |
| | | // 平台 |
| | | stringObjectMap.put("account","平台"); |
| | | }else{ |
| | | // 根据门店获取运营商id 查询运营商名称 |
| | | |
| | | // 查询运营商名称 |
| | | TOperator operator = operatorService.getOne(new QueryWrapper<TOperator>().eq("id", managerId)); |
| | | if (ToolUtil.isNotEmpty(operator)){ |
| | | stringObjectMap.put("account",operator.getName()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | return storeList; |
| | |
| | | ofSearch.setUserPopulation(userPopulation); |
| | | ofSearch.setStatus(status); |
| | | ofSearch.setState(state); |
| | | return client.getCouponListOfSearch(ofSearch); |
| | | if (UserExt.getUser().getObjectType()==2) { |
| | | // 门店ids |
| | | List<Integer> storeIds = storeService.list(new QueryWrapper<TStore>().eq("operatorId", UserExt.getUser().getObjectId())) |
| | | .stream().map(TStore::getId).collect(Collectors.toList()); |
| | | ofSearch.setStoreIds(storeIds); |
| | | ofSearch.setObjType(UserExt.getUser().getObjectType()); |
| | | ofSearch.setOperatorId(UserExt.getUser().getObjectId()); |
| | | // 查询当前门店属于哪个运营商 |
| | | List<TOperatorCity> operatorId = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("operatorId", UserExt.getUser().getObjectId())); |
| | | ofSearch.setOperatorCities(operatorId); |
| | | } |
| | | if (UserExt.getUser().getObjectType()==3) { |
| | | ofSearch.setStoreId(UserExt.getUser().getObjectId()); |
| | | ofSearch.setObjType(UserExt.getUser().getObjectType()); |
| | | } |
| | | // 运营商可以查看平台添加的优惠券应只展示使用范围为全国通用、 |
| | | // 指定城市有运营商管辖的、指定门店有运营商旗下门店 |
| | | List<Map<String, Object>> couponListOfSearch = client.getCouponListOfSearch(ofSearch); |
| | | |
| | | return couponListOfSearch; |
| | | } |
| | | /** |
| | | * 根据运营商ID 获取运营商管理的省市 |
| | | */ |
| | | |
| | | /** |
| | | * 获取 优惠券管理 |
| | | */ |
| | | @RequestMapping(value = "/list1") |
| | | @ResponseBody |
| | | public Object listOfDatas1(String name, Integer type, Integer distributionMethod , Integer userPopulation, Integer status, Integer state,String cityCode,Integer storeId) { |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | CouponListOfSearch ofSearch = new CouponListOfSearch(); |
| | | ofSearch.setPage(page); |
| | | ofSearch.setName(name); |
| | | ofSearch.setType(type); |
| | | ofSearch.setDistributionMethod(distributionMethod); |
| | | ofSearch.setUserPopulation(userPopulation); |
| | | ofSearch.setStatus(status); |
| | | ofSearch.setState(state); |
| | | ofSearch.setCityCode(cityCode); |
| | | ofSearch.setStoreId(storeId); |
| | | ofSearch.setObjType(UserExt.getUser().getObjectType()); |
| | | ofSearch.setOperatorId(UserExt.getUser().getObjectId()); |
| | | return client.getCouponListOfSearch1(ofSearch); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/listRecord") |
| | | @ResponseBody |
| | | public Object listRecord(Integer id,String name, Integer type, String phone) { |
| | | Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); |
| | | List<TAppUser> tAppUsers = appUserClient.queryByNamePhone(new QueryByNamePhone(name, phone)); |
| | | if(tAppUsers.size()==0){ |
| | | return new ArrayList<>(); |
| | | } |
| | | CouponRecordQuery ofSearch = new CouponRecordQuery(); |
| | | ofSearch.setId(id); |
| | | ofSearch.setLimit(page.getSize()); |
| | | ofSearch.setOffset(page.getCurrent()); |
| | | ofSearch.setIds(tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList())); |
| | | ofSearch.setType(type); |
| | | List<Map<String, Object>> maps = client.listRecord(ofSearch); |
| | |
| | | return regiService.list(new LambdaQueryWrapper<Region>() |
| | | .eq(Region::getParentId,province)); |
| | | } |
| | | @RequestMapping(value = "/getCity1") |
| | | @ResponseBody |
| | | public Object getCity1(String province){ |
| | | // 获取省的id |
| | | Integer code = regiService.getOne(new QueryWrapper<Region>().eq("code", province)).getId(); |
| | | return regiService.list(new LambdaQueryWrapper<Region>() |
| | | .eq(Region::getParentId,code)); |
| | | } |
| | | // 通过市 获取运营商 |
| | | @RequestMapping(value = "/getOperator") |
| | | @ResponseBody |
| | | public Object getOperator(String city){ |
| | | List<TOperatorCity> name = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("name", city)); |
| | | List<Integer> collect = name.stream().map(TOperatorCity::getOperatorId) |
| | | .collect(Collectors.toList()); |
| | | if (collect.size()==0){ |
| | | return new ArrayList<>(); |
| | | } |
| | | return operatorService.list(new QueryWrapper<TOperator>().in("id",collect)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/uploadPic") |
| | | @ResponseBody |
| | |
| | | System.out.println(dataVo); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | dataVo.setUserType(objectType); |
| | | dataVo.setCityManagerId(UserExt.getUser().getObjectId()); |
| | | if(UserExt.getUser().getObjectType()==2){ |
| | | dataVo.setCompany(3); |
| | | dataVo.setUserType(2); |
| | | dataVo.setCityManagerId(UserExt.getUser().getObjectId()); |
| | | }else if(UserExt.getUser().getObjectType()==3){ |
| | | dataVo.setStoreIds(UserExt.getUser().getObjectId().toString()); |
| | | dataVo.setCompany(3); |
| | | dataVo.setUserType(3); |
| | | }else{ |
| | | dataVo.setUserType(1); |
| | | } |
| | | dataVo.setObjType(UserExt.getUser().getObjectType()); |
| | | client.insertIntoData(dataVo); |
| | | return new SuccessTip<>(); |
| | | } |
| | | |
| | | |
| | | @PostMapping(value = "/update") |
| | | @ResponseBody |
| | | public Object update( Integer id,Integer num,Integer num1,String text){ |
| | |
| | | coupon.setQuantityIssued(num); |
| | | coupon.setPickUpQuantity(num1); |
| | | coupon.setIllustrate(text); |
| | | if (UserExt.getUser().getObjectType()==3) { |
| | | coupon.setAuditStatus(1); |
| | | } |
| | | client.updateCouponData(coupon); |
| | | return new SuccessTip<>(); |
| | | } |