|
|
|
@ -29,10 +29,8 @@ import cc.hiver.core.entity.User; |
|
|
|
import cc.hiver.core.entity.Worker; |
|
|
|
import cc.hiver.core.service.UserService; |
|
|
|
import cc.hiver.core.service.WorkerService; |
|
|
|
import cc.hiver.mall.entity.Shop; |
|
|
|
import cc.hiver.mall.entity.ShopArea; |
|
|
|
import cc.hiver.mall.entity.ShopTakeaway; |
|
|
|
import cc.hiver.mall.entity.ShopUser; |
|
|
|
import cc.hiver.mall.dao.ShopGateLocationDao; |
|
|
|
import cc.hiver.mall.entity.*; |
|
|
|
import cc.hiver.mall.invitelog.service.InviteLogService; |
|
|
|
import cc.hiver.mall.pojo.dto.ShopCacheDTO; |
|
|
|
import cc.hiver.mall.pojo.dto.ShopRevenue; |
|
|
|
@ -78,6 +76,7 @@ import java.util.stream.Collectors; |
|
|
|
@Api(tags = "店铺管理接口") |
|
|
|
@RequestMapping("/hiver/app/shop/") |
|
|
|
public class ShopController { |
|
|
|
private static final String TARGET_GATE_LOCATION_REGION_ID = "2110300467664916480"; |
|
|
|
private static final String GROUP_BUY_DEFAULT_PAGE_CACHE_PREFIX = "GROUP_BUY_DEFAULT_SHOP_PAGE:"; |
|
|
|
private static final long GROUP_BUY_DEFAULT_PAGE_CACHE_SECONDS = 30L; |
|
|
|
private static final DateTimeFormatter BUSINESS_TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm"); |
|
|
|
@ -87,6 +86,9 @@ public class ShopController { |
|
|
|
@Autowired |
|
|
|
private ShopService shopService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ShopGateLocationDao shopGateLocationDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ShopAreaService shopAreaService; |
|
|
|
|
|
|
|
@ -498,6 +500,83 @@ public class ShopController { |
|
|
|
return ResultUtil.success("编辑成功"); |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/gateLocation/list", method = RequestMethod.GET) |
|
|
|
@ApiOperation("查询商家送达地点") |
|
|
|
public Result<List<ShopGateLocation>> listGateLocation(@RequestParam String shopId) { |
|
|
|
Shop shop = requireTargetGateLocationShop(shopId); |
|
|
|
if (shop == null) { |
|
|
|
return ResultUtil.error("当前区域不支持送达地点"); |
|
|
|
} |
|
|
|
return new ResultUtil<List<ShopGateLocation>>().setData(shopGateLocationDao.findByShopIdOrderByCreateTimeAsc(shopId)); |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/gateLocation/save", method = RequestMethod.POST) |
|
|
|
@ApiOperation("新增或编辑商家送达地点") |
|
|
|
public Result<Object> saveGateLocation(@RequestParam String shopId, |
|
|
|
@RequestParam(required = false) String id, |
|
|
|
@RequestParam String locationName) { |
|
|
|
Shop shop = requireTargetGateLocationShop(shopId); |
|
|
|
if (shop == null) { |
|
|
|
return ResultUtil.error("当前区域不支持送达地点"); |
|
|
|
} |
|
|
|
String name = locationName == null ? "" : locationName.trim(); |
|
|
|
if (CharSequenceUtil.isBlank(name)) { |
|
|
|
return ResultUtil.error("请输入送达地点"); |
|
|
|
} |
|
|
|
if (name.length() > 50) { |
|
|
|
return ResultUtil.error("送达地点不能超过50个字"); |
|
|
|
} |
|
|
|
List<ShopGateLocation> exists = shopGateLocationDao.findByShopIdOrderByCreateTimeAsc(shopId); |
|
|
|
for (ShopGateLocation item : exists) { |
|
|
|
if (name.equals(item.getLocationName()) && (CharSequenceUtil.isBlank(id) || !id.equals(item.getId()))) { |
|
|
|
return ResultUtil.error("送达地点已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (CharSequenceUtil.isNotBlank(id)) { |
|
|
|
ShopGateLocation old = shopGateLocationDao.findById(id).orElse(null); |
|
|
|
if (old == null || !shopId.equals(old.getShopId())) { |
|
|
|
return ResultUtil.error("送达地点不存在"); |
|
|
|
} |
|
|
|
old.setLocationName(name); |
|
|
|
shopGateLocationDao.save(old); |
|
|
|
return ResultUtil.success("保存成功"); |
|
|
|
} |
|
|
|
ShopGateLocation location = new ShopGateLocation(); |
|
|
|
location.setShopId(shopId); |
|
|
|
location.setLocationName(name); |
|
|
|
shopGateLocationDao.save(location); |
|
|
|
return ResultUtil.success("保存成功"); |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/gateLocation/delete", method = RequestMethod.POST) |
|
|
|
@ApiOperation("删除商家送达地点") |
|
|
|
public Result<Object> deleteGateLocation(@RequestParam String id) { |
|
|
|
if (CharSequenceUtil.isBlank(id)) { |
|
|
|
return ResultUtil.error("送达地点不存在"); |
|
|
|
} |
|
|
|
ShopGateLocation old = shopGateLocationDao.findById(id).orElse(null); |
|
|
|
if (old == null) { |
|
|
|
return ResultUtil.error("送达地点不存在"); |
|
|
|
} |
|
|
|
Shop shop = requireTargetGateLocationShop(old.getShopId()); |
|
|
|
if (shop == null) { |
|
|
|
return ResultUtil.error("当前区域不支持送达地点"); |
|
|
|
} |
|
|
|
shopGateLocationDao.deleteById(id); |
|
|
|
return ResultUtil.success("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
private Shop requireTargetGateLocationShop(String shopId) { |
|
|
|
if (CharSequenceUtil.isBlank(shopId)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
Shop shop = shopService.findById(shopId); |
|
|
|
if (shop == null || !TARGET_GATE_LOCATION_REGION_ID.equals(String.valueOf(shop.getRegionId()))) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return shop; |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/findWorkerByMobile", method = RequestMethod.GET) |
|
|
|
@ApiOperation("根据手机号查询配送员") |
|
|
|
public Result<Map<String, Object>> findWorkerByMobile(@RequestParam String mobile) { |
|
|
|
|