Browse Source

[商户][修改][添加多商铺]

release_toaliyun_real
gongbiao 7 years ago
parent
commit
101563d775
2 changed files with 22 additions and 33 deletions
  1. +1
    -1
      mallinkService/src/main/java/com/iformall/common/ErrorCode.java
  2. +21
    -32
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java

+ 1
- 1
mallinkService/src/main/java/com/iformall/common/ErrorCode.java View File

@@ -328,7 +328,7 @@ public enum ErrorCode{
* */
SHOP_IS_NOT_FOUND(22000,"商铺不存在"),
SHOP_IS_RENT(22001,"商铺已出租"),
SHOP_NOT_SELECTED(22002, "未选择商铺"),
WIWIDE_INFO_NOT_FOUND(23001,"迈外迪信息未找到"),
WIWIDE_INFO_NOT_READY(23002,"迈外迪信息未就绪"),



+ 21
- 32
mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java View File

@@ -269,28 +269,30 @@ public class WxMerchantServiceImpl implements WxMerchantService {
long merchantId = idWorker.nextId();
//保存商户商铺的关联
List<Long> shopidlist = wxMerchant.getShopids();
if(null!=shopidlist && !shopidlist.isEmpty()){
Long shopid = shopidlist.get(0);
WxMerchantShop wxMerchantShop = new WxMerchantShop();
wxMerchantShop.setTenantId(wxMerchant.getTenantId());
wxMerchantShop.setShopId(shopid);
wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode());
long count = wxMerchantShopMapper.findList(wxMerchantShop).size();
if(count>0){
return new ResultData(ErrorCode.SHOP_IS_RENT);
}
//更新商铺状态
WxShop wxShop = new WxShop();
wxShop.setTenantId(wxMerchant.getTenantId());
wxShop.setId(shopid);
//已出租
if (!shopidlist.isEmpty()) {
return new ResultData(ErrorCode.SHOP_NOT_SELECTED);
}
//先检查是否存在已出租的商铺
List<WxShop> rentShopList = new ArrayList<>();
for (long shopid : shopidlist) {
WxShop shop = wxShopMapper.selectByPrimaryKey(shopid);
if (shop == null) {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND);
}
if (shop.getStatus().equals(EnumShopStatus.RENT.getCode())) {
return new ResultData(ErrorCode.SHOP_IS_RENT);
rentShopList.add(shop);
}
}
//已出租的商铺
if (!rentShopList.isEmpty()) {
return new ResultData(ErrorCode.SHOP_IS_RENT, rentShopList);
}
//更新商铺
for (long shopid : shopidlist) {
//更新商铺状态
WxShop shop = new WxShop();
shop.setId(shopid);
shop.setStatus(EnumShopStatus.RENT.getCode());
wxShopMapper.updateByPrimaryKeySelective(shop);
//关联表插入
WxMerchantShop wxMerchantShop = new WxMerchantShop();
wxMerchantShop.setId(idWorker.nextId());
wxMerchantShop.setMerchantId(merchantId);
wxMerchantShop.setTenantId(wxMerchant.getTenantId());
@@ -298,8 +300,6 @@ public class WxMerchantServiceImpl implements WxMerchantService {
wxMerchantShop.setUpdateDate(shopdate);
wxMerchantShop.setCreateDate(shopdate);
wxMerchantShopMapper.insertSelective(wxMerchantShop);
wxShop.setStatus(EnumShopStatus.RENT.getCode());
wxShopMapper.updateByPrimaryKeySelective(wxShop);
}

wxMerchant.setId(merchantId);
@@ -351,17 +351,6 @@ public class WxMerchantServiceImpl implements WxMerchantService {
if (wxMerchant.getId() == null) {
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND);
}

//更新商户商铺关联表
WxMerchantShop wxMerchantShopQuery = new WxMerchantShop();
wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId());
wxMerchantShopQuery.setMerchantId(wxMerchant.getId());
wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode());
List<WxMerchantShop> wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery);
WxMerchantShop wxMerchantShop = wxMerchantShopList.get(0);
wxMerchantShop.setUpdateDate(new Date());
wxMerchantShopMapper.updateByPrimaryKeySelective(wxMerchantShop);

//更新商户
Date date = new Date();
wxMerchant.setUpdateDate(date);


Loading…
Cancel
Save