|
|
|
@ -35,6 +35,11 @@ import cc.hiver.mall.pojo.vo.QueryShopRevenueVO; |
|
|
|
import cc.hiver.mall.service.ShopAreaService; |
|
|
|
import cc.hiver.mall.service.ShopService; |
|
|
|
import cc.hiver.mall.service.ShopUserService; |
|
|
|
import cc.hiver.mall.warehouse.constant.WarehouseConstant; |
|
|
|
import cc.hiver.mall.warehouse.entity.Warehouse; |
|
|
|
import cc.hiver.mall.warehouse.entity.WarehouseShop; |
|
|
|
import cc.hiver.mall.warehouse.service.WarehouseService; |
|
|
|
import cc.hiver.mall.warehouse.service.WarehouseShopService; |
|
|
|
import cn.hutool.core.text.CharSequenceUtil; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
@ -42,6 +47,7 @@ import io.swagger.annotations.ApiParam; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
@ -76,6 +82,12 @@ public class ShopController { |
|
|
|
@Autowired |
|
|
|
private InviteLogService inviteLogService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseService warehouseService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarehouseShopService warehouseShopService; |
|
|
|
|
|
|
|
@RequestMapping(value = "/getAll", method = RequestMethod.GET) |
|
|
|
@ApiOperation("获取全部数据") |
|
|
|
public Result<List<Shop>> getAll() { |
|
|
|
@ -206,11 +218,54 @@ public class ShopController { |
|
|
|
|
|
|
|
@RequestMapping(value = "/enable", method = RequestMethod.POST) |
|
|
|
@ApiOperation("启用店铺") |
|
|
|
@Transactional |
|
|
|
public Result enable(@RequestParam String id) { |
|
|
|
final Shop shop = shopService.get(id); |
|
|
|
shop.setStatus(ShopConstant.SHOP_STATUS_NORMAL); |
|
|
|
shopService.update(shop); |
|
|
|
return ResultUtil.success("操作成功"); |
|
|
|
if(StringUtils.isEmpty(id)){ |
|
|
|
return ResultUtil.error("id不能为空"); |
|
|
|
} |
|
|
|
try{ |
|
|
|
final Shop shop = shopService.get(id); |
|
|
|
shop.setStatus(ShopConstant.SHOP_STATUS_NORMAL); |
|
|
|
shopService.update(shop); |
|
|
|
// 20240803启用店铺,增加默认仓库。
|
|
|
|
// 根据店铺的ownerId查,有没有仓库,没有直接给一个“默认仓库”
|
|
|
|
if (StringUtils.isNotEmpty(shop.getShopOwnerId())) { |
|
|
|
// 获取店主信息
|
|
|
|
final User loadUser = securityUtil.getCurrUser(); |
|
|
|
final User owner = userService.findById(shop.getShopOwnerId()); |
|
|
|
final List<Warehouse> warehouses = warehouseService.getWarehouseByShopOwnerId(shop.getShopOwnerId()); |
|
|
|
if (warehouses.isEmpty()) { |
|
|
|
final Warehouse warehouse = new Warehouse(); |
|
|
|
warehouse.setCreateBy(loadUser.getId()); |
|
|
|
warehouse.setCreateByName(loadUser.getNickname()); |
|
|
|
warehouse.setShopOwnerId(shop.getShopOwnerId()); |
|
|
|
warehouse.setShopOwnerName(owner.getNickname()); |
|
|
|
warehouse.setWarehouseName("默认仓库"); |
|
|
|
// 默认为共用
|
|
|
|
warehouse.setWarehouseStatus(WarehouseConstant.WAREHOUSE_STATUS[0]); |
|
|
|
// 默认为启用
|
|
|
|
warehouse.setIsUse(WarehouseConstant.IS_USE[0]); |
|
|
|
warehouse.setSort(0); |
|
|
|
warehouseService.addWarehouse(warehouse); |
|
|
|
// 增加店铺与仓库的关联关系
|
|
|
|
final WarehouseShop warehouseShop = new WarehouseShop(); |
|
|
|
warehouseShop.setCreateBy(loadUser.getId()); |
|
|
|
warehouseShop.setCreateByName(loadUser.getNickname()); |
|
|
|
warehouseShop.setShopOwnerId(shop.getShopOwnerId()); |
|
|
|
warehouseShop.setShopOwnerName(owner.getNickname()); |
|
|
|
warehouseShop.setShopId(shop.getId()); |
|
|
|
warehouseShop.setShopName(shop.getShopName()); |
|
|
|
warehouseShop.setWarehouseId(warehouse.getId()); |
|
|
|
warehouseShop.setWarehouseName(warehouse.getWarehouseName()); |
|
|
|
warehouseShopService.addWarehouseShop(warehouseShop); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return ResultUtil.success("操作成功"); |
|
|
|
}catch (Exception e){ |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
return ResultUtil.error("启用失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping(value = "/disable", method = RequestMethod.POST) |
|
|
|
@ -254,48 +309,50 @@ public class ShopController { |
|
|
|
|
|
|
|
@RequestMapping(value = "/getShopRebateBalance", method = RequestMethod.POST) |
|
|
|
@ApiOperation("获取返佣余额及累计返佣") |
|
|
|
public Result getShopRebateBalance(){ |
|
|
|
final Map<String,String> shopRebateBalance = shopService.getShopRebateBalance(); |
|
|
|
public Result getShopRebateBalance() { |
|
|
|
final Map<String, String> shopRebateBalance = shopService.getShopRebateBalance(); |
|
|
|
return ResultUtil.data(shopRebateBalance); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据店铺id获取店铺信息 |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/7/27 |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @return Result |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/7/27 |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/getShopInfoById", method = RequestMethod.POST) |
|
|
|
@ApiOperation("根据店铺id获取店铺信息") |
|
|
|
public Result getShopInfoById(String id){ |
|
|
|
if(StringUtils.isEmpty(id)){ |
|
|
|
public Result getShopInfoById(String id) { |
|
|
|
if (StringUtils.isEmpty(id)) { |
|
|
|
return ResultUtil.error("店铺id不能为空"); |
|
|
|
} |
|
|
|
final Shop shop = shopService.findById(id); |
|
|
|
final Shop shop = shopService.findById(id); |
|
|
|
return ResultUtil.data(shop); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新店铺图标及备注 |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/7/27 |
|
|
|
* |
|
|
|
* @param shop |
|
|
|
* @return Result |
|
|
|
* @author 王富康 |
|
|
|
* @date 2024/7/27 |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/updateShopIconAndRemark", method = RequestMethod.POST) |
|
|
|
@ApiOperation("更新店铺图标及备注") |
|
|
|
public Result updateShopIconAndRemark(@RequestBody Shop shop) { |
|
|
|
final String id = shop.getId(); |
|
|
|
if(StringUtils.isEmpty(id)){ |
|
|
|
if (StringUtils.isEmpty(id)) { |
|
|
|
return ResultUtil.error("店铺id不能为空"); |
|
|
|
} |
|
|
|
final Shop oldShop = shopService.get(id); |
|
|
|
// 20240803 不更新店铺图标,可更新店铺地址
|
|
|
|
if(shop.getShopAddress() != null){ |
|
|
|
if (shop.getShopAddress() != null) { |
|
|
|
oldShop.setShopAddress(shop.getShopAddress()); |
|
|
|
} |
|
|
|
if(shop.getRemark() != null){ |
|
|
|
if (shop.getRemark() != null) { |
|
|
|
oldShop.setRemark(shop.getRemark()); |
|
|
|
} |
|
|
|
shopService.update(oldShop); |
|
|
|
|