|
|
@@ -156,6 +156,10 @@ public class WxMerchantServiceImpl implements WxMerchantService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
WxMerchantRelationService wxMerchantRelationService; |
|
|
WxMerchantRelationService wxMerchantRelationService; |
|
|
|
|
|
|
|
|
|
|
|
@Lazy |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WxMallBuildingService wxMallBuildingService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
@Qualifier("objectCommonRedisTemplate") |
|
|
@Qualifier("objectCommonRedisTemplate") |
|
|
RedisTemplate<String, Object> redisTemplate; |
|
|
RedisTemplate<String, Object> redisTemplate; |
|
|
@@ -2167,8 +2171,102 @@ public class WxMerchantServiceImpl implements WxMerchantService { |
|
|
return wxMerchantMapper.findIdList(merchant); |
|
|
return wxMerchantMapper.findIdList(merchant); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private WxShop initShopByPoiId(TenantEntity tenantEntity,String poiId) throws Exception { |
|
|
|
|
|
String shopNumber = "DYPOI-"+poiId; |
|
|
|
|
|
WxShop shop = wxShopService.getShopByShopNumber(tenantEntity, shopNumber); |
|
|
|
|
|
if (null == shop) { |
|
|
|
|
|
Long buildingId = null; |
|
|
|
|
|
Long floorId = null; |
|
|
|
|
|
try { |
|
|
|
|
|
ResultData builds = wxMallBuildingService.getBuildingFloorList(tenantEntity); |
|
|
|
|
|
if (null == builds || null == builds.data) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层楼座未查询到."); |
|
|
|
|
|
} |
|
|
|
|
|
List<WxMallBuilding> wxMallBuildings = (List<WxMallBuilding>) builds.data; |
|
|
|
|
|
if (null == wxMallBuildings || wxMallBuildings.size() <= 0 ){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层楼座未查询到."); |
|
|
|
|
|
} |
|
|
|
|
|
WxMallBuilding building = wxMallBuildings.get(0); |
|
|
|
|
|
buildingId = building.getId() ; |
|
|
|
|
|
List<WxMallFloor> floors = building.getFloors(); |
|
|
|
|
|
if (null == floors || floors.size() <= 0 ){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼座"+building.getBuildingName()+"没有楼层"); |
|
|
|
|
|
} |
|
|
|
|
|
floorId = floors.get(0).getId(); |
|
|
|
|
|
} catch(Exception e) { |
|
|
|
|
|
logger.error("initMerchantByPoi error.",e); |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"楼层楼座查询错误."+e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
shop = new WxShop(); |
|
|
|
|
|
shop.updateTenantInfo(tenantEntity); |
|
|
|
|
|
shop.setBuildArea("0"); |
|
|
|
|
|
shop.setShopNumber(shopNumber); |
|
|
|
|
|
shop.setBuilding(buildingId); |
|
|
|
|
|
shop.setFloor(floorId); |
|
|
|
|
|
shop.setOperationArea("0"); |
|
|
|
|
|
shop.setBusinessId(0); |
|
|
|
|
|
shop.setRentUnit(2); |
|
|
|
|
|
wxShopService.saveOrUpdate(shop); |
|
|
|
|
|
} |
|
|
|
|
|
return shop; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private WxMerchant initMerchantByPoiId(WxShop shop,MallUserInfo user,String poiName, String poiId,String phone) { |
|
|
|
|
|
WxMerchant merchantQ = new WxMerchant(); |
|
|
|
|
|
merchantQ.updateTenantInfo(user); |
|
|
|
|
|
merchantQ.setCreateFrom(EnumMerchantCreateFrom.DOUYIN_LAIKE.getCode()); |
|
|
|
|
|
merchantQ.setCreateFromId(poiId); |
|
|
|
|
|
Map<String,WxMerchant> poiCreateMerchant = this.findMerchantMapByCreateFromId(merchantQ); |
|
|
|
|
|
WxMerchant merchant = null; |
|
|
|
|
|
if (null != poiCreateMerchant) { |
|
|
|
|
|
merchant = poiCreateMerchant.get(poiId); |
|
|
|
|
|
} |
|
|
|
|
|
if (null == merchant) { |
|
|
|
|
|
merchant = new WxMerchant(); |
|
|
|
|
|
merchant.setIsAdmin(EnumMerchantAdmin.PUBLIC_COMMON.getCode()); |
|
|
|
|
|
merchant.setCarVendorType(0); |
|
|
|
|
|
merchant.setImgUrl("https://formall.oss-accelerate.aliyuncs.com/234/WechatIMG5071.png"); |
|
|
|
|
|
merchant.setName(poiName); |
|
|
|
|
|
if (StringUtils.isBlank(phone)) { |
|
|
|
|
|
merchant.setLinkPhone("11111111111"); |
|
|
|
|
|
}else { |
|
|
|
|
|
merchant.setLinkPhone(phone); |
|
|
|
|
|
} |
|
|
|
|
|
merchant.setLinkPerson("default"); |
|
|
|
|
|
List<Long> shopIds = new ArrayList<Long>(); |
|
|
|
|
|
shopIds.add(shop.getId()); |
|
|
|
|
|
merchant.setShopids(shopIds); |
|
|
|
|
|
merchant.setBusinessId(shop.getBusinessId()); |
|
|
|
|
|
merchant.setType(1); |
|
|
|
|
|
merchant.setCreateFrom(EnumMerchantCreateFrom.DOUYIN_LAIKE.getCode()); |
|
|
|
|
|
merchant.setCreateFromId(poiId); |
|
|
|
|
|
this.addMerchant(merchant, user.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
return merchant; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void initMerchantByPoi(String poiName, String poiId) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public WxMerchant initMerchantByPoi(MallUserInfo user,String poiName, String poiId,String phone) throws Exception{ |
|
|
|
|
|
WxShop shop = initShopByPoiId(user,poiId); |
|
|
|
|
|
if (null == shop) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"商铺信息初始化失败"); |
|
|
|
|
|
} |
|
|
|
|
|
WxMerchant merchant = initMerchantByPoiId(shop, user, poiName, poiId, phone); |
|
|
|
|
|
if (null == merchant) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"商户信息初始化失败"); |
|
|
|
|
|
} |
|
|
|
|
|
//加管理员 |
|
|
|
|
|
if (StringUtils.isNotBlank(phone)) { |
|
|
|
|
|
List<WxMerchantBUser> users = new ArrayList<WxMerchantBUser>(); |
|
|
|
|
|
WxMerchantBUser buser = new WxMerchantBUser(); |
|
|
|
|
|
buser.setName("管理员"); |
|
|
|
|
|
buser.setPhone(phone); |
|
|
|
|
|
buser.setUserPwd("123456Abc"); |
|
|
|
|
|
buser.setIsAdmin(merchant.getIsAdmin()); |
|
|
|
|
|
users.add(buser); |
|
|
|
|
|
merchant.setUsers(users); |
|
|
|
|
|
this.updateMerchantAdmin(merchant) ; |
|
|
|
|
|
} |
|
|
|
|
|
return merchant; |
|
|
|
|
|
} |
|
|
|
|
|
} |