diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 460e6503..2da77f62 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -468,5 +468,56 @@ public class HighCouponController { } } + @RequestMapping(value="/getMerchantCouponTree",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询商户下的卡卷【树结构】") + public ResponseData getMerchantCouponTree(HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (userInfoModel.getBsCompany() == null) { + log.error("HighCouponController -> getCouponList() error!","权限不足"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + + // 查询商户 + Map map = new HashMap<>(); + map.put("companyId", userInfoModel.getBsCompany().getId()); + List merchantList = highMerchantService.getMerchantList(map); + + + List> parentMap = new ArrayList<>(); + Map merchantMap; + + List> couponMapList; + Map couponMap; + + + for (HighMerchant highMerchant : merchantList) { + merchantMap = new HashMap<>(); + merchantMap.put("key", highMerchant.getId()); + merchantMap.put("title", highMerchant.getMerchantName()); + couponMapList = new ArrayList<>(); + // 查询门店下的卡卷 + List list = highCouponService.getCouponListByMerchant(highMerchant.getId()); + if (list.size() > 0) { + for (HighCoupon highCoupon : list) { + couponMap = new HashMap<>(); + couponMap.put("key", highCoupon.getId()); + couponMap.put("title", highCoupon.getCouponName()); + couponMap.put("isLeaf", true); + couponMapList.add(couponMap); + } + } + merchantMap.put("children", couponMapList); + parentMap.add(merchantMap); + } + return ResponseMsgUtil.success(parentMap); + + } catch (Exception e) { + log.error("HighCouponController -> getMerchantCouponTree() error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index ab9c22d9..2c6c5784 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -8,6 +8,7 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.BsCompany; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.*; @@ -47,6 +48,9 @@ public class HighCouponController { @Resource private HighCouponHandselService highCouponHandselService; + @Resource + private BsCompanyService bsCompanyService; + @Resource private HighCouponCodeService highCouponCodeService; @@ -56,30 +60,28 @@ public class HighCouponController { @RequestMapping(value="/getCouponList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷列表") - public ResponseData getCouponList(@RequestParam(name = "regionId", required = true) Long regionId, + public ResponseData getCouponList(@RequestParam(name = "regionId", required = true) String regionId, @RequestParam(name = "merchantId", required = false) Long merchantId, @RequestParam(name = "couponName", required = false) String couponName, @RequestParam(name = "couponType", required = false) Integer couponType, @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { + @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { - Map map = new HashMap<>(); - - SessionObject sessionObject = userCenter.getSessionObject(request); - UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - if (userInfoModel.getBsCompany() == null) { - log.error("HighCouponController -> getCouponList() error!","权限不足"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(regionId); + if (bsCompany != null) { + Map map = new HashMap<>(); + map.put("companyId", bsCompany.getRegionId()); + map.put("merchantId", merchantId); + map.put("couponName", couponName); + map.put("couponType", couponType); + map.put("status", 2); + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map))); } - map.put("regionId", regionId); - map.put("merchantId", merchantId); - map.put("couponName", couponName); - map.put("couponType", couponType); - map.put("status", 2); - - PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map))); + + return ResponseMsgUtil.success(new PageInfo<>()); + } catch (Exception e) { log.error("HighCouponController -> getCouponList() error!",e); return ResponseMsgUtil.exception(e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighMerchantStoreController.java b/hai-cweb/src/main/java/com/cweb/controller/HighMerchantStoreController.java index 0b6d1e12..886b6c20 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighMerchantStoreController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighMerchantStoreController.java @@ -9,11 +9,14 @@ import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.MemberValidateUtil; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighCoupon; import com.hai.entity.HighMerchant; import com.hai.entity.HighMerchantStore; +import com.hai.model.HighCouponModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.HighCouponService; import com.hai.service.HighMerchantService; import com.hai.service.HighMerchantStoreService; import com.hai.service.SecUserService; @@ -47,6 +50,9 @@ public class HighMerchantStoreController { @Autowired private UserCenter userCenter; + @Resource + private HighCouponService highCouponService; + @Resource private HighMerchantStoreService highMerchantStoreService; @@ -70,34 +76,22 @@ public class HighMerchantStoreController { } } - @RequestMapping(value="/getStoreListByCompany",method = RequestMethod.GET) + @RequestMapping(value="/getStoreListByCoupon",method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "根据公司 查询商户门店列表") - public ResponseData getStoreListByCompany(@RequestParam(name = "merchantId", required = false) Long merchantId, - @RequestParam(name = "telephone", required = false) String telephone, - @RequestParam(name = "storeName", required = false) String storeName, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize, - HttpServletRequest request) { + @ApiOperation(value = "根据卡卷查询门店列表") + public ResponseData getStoreListByCoupon(@RequestParam(name = "couponId", required = true) Long couponId) { try { - SessionObject sessionObject = userCenter.getSessionObject(request); - UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - if (userInfoModel.getBsCompany() == null) { - log.error("HighMerchantStoreController -> getStoreListByCompany() error!","权限不足"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); - } - Map map = new HashMap<>(); - map.put("companyId", userInfoModel.getBsCompany().getId()); - map.put("merchantId", merchantId); - map.put("telephone", telephone); - map.put("storeName", storeName); - - PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(highMerchantStoreService.getMerchantStoreList(map))); + HighCouponModel coupon = highCouponService.getCouponById(couponId); + if (coupon == null) { + ResponseMsgUtil.success(null); + } + Map map = new HashMap<>(); + map.put("merchantId", coupon.getMerchantId()); + return ResponseMsgUtil.success(highMerchantStoreService.getMerchantStoreList(map)); } catch (Exception e) { - log.error("HighMerchantStoreController -> getStoreListByCompany() error!",e); + log.error("HighMerchantStoreController -> getStoreListByCoupon() error!",e); return ResponseMsgUtil.exception(e); } } diff --git a/hai-service/src/main/java/com/hai/service/HighCouponService.java b/hai-service/src/main/java/com/hai/service/HighCouponService.java index 2ac64d35..f55b94cd 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -100,4 +100,11 @@ public interface HighCouponService { **/ List getCouponList(Map map); + /** + * @Author 胡锐 + * @Description 根据商户 查询处于已上架的卡卷 + * @Date 2021/3/24 18:29 + **/ + List getCouponListByMerchant(Long merchantId); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index 8286da7b..495364de 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -353,4 +353,11 @@ public class HighCouponServiceImpl implements HighCouponService { } return new ArrayList<>(); } + + @Override + public List getCouponListByMerchant(Long merchantId) { + HighCouponExample example = new HighCouponExample(); + example.createCriteria().andMerchantIdEqualTo(merchantId).andStatusEqualTo(1).andStatusNotEqualTo(0); + return highCouponMapper.selectByExample(example); + } }