@ -427,6 +427,8 @@ public class StoreEmployeeService {
//查询用户权限店铺
shopIds = new ArrayList < > ( privilageDomainService . listUserDatePermission ( userId ) ) ;
}
long s = System . currentTimeMillis ( ) ;
System . out . println ( s ) ;
List < StoreUserDTO > cpUserStoreDO = privilageCpUserStoreDOMapper . selectCpUserByShops ( shopIds ) ;
if ( CollectionUtils . isNotEmpty ( cpUserStoreDO ) ) {
int orderNum = 0 ;
@ -434,11 +436,11 @@ public class StoreEmployeeService {
//设置序号
cpUserStore . setOrderNum ( + + orderNum ) ;
//查询店铺绑定的企业微信
PoiStore poiStore = poiStoreDOMapper . selectById ( cpUserStore . getId ( ) ) ;
if ( null ! = poiStore ) {
cpUserStore . setName ( poiStore . getName ( ) ) ;
cpUserStore . setCode ( poiStore . getCode ( ) ) ;
}
// PoiStore poiStore = poiStoreDOMapper.selectById(cpUserStore.getId());
// if (null != poiStore) {
// cpUserStore.setName(poiStore.getName());
// cpUserStore.setCode(poiStore.getCode());
// }
//客户orgId
Long customerId = privilageDomainEntityDOMapper . selectDomainIdByShopEntity ( cpUserStore . getId ( ) ) ;
@ -452,38 +454,43 @@ public class StoreEmployeeService {
cpUserStore . setRegionName ( region . getName ( ) ) ;
}
String qrCodeAction = cpUserStore . getQrCodeAction ( ) ;
if ( StringUtils . isBlank ( qrCodeAction ) ) {
qrCodeAction = getQrCodeFromBSD ( cpUserStore . getCpUserId ( ) , BSD_REQ_QRCODE_TYPE_STORE , "0" , cpUserStore . getCode ( ) ) ;
cpUserStore . setQrCodeAction ( qrCodeAction ) ;
PrivilageCpUserDO update = new PrivilageCpUserDO ( ) ;
update . setId ( cpUserStore . getUserId ( ) ) ;
update . setQrCode ( qrCodeAction ) ;
privilageCpUserDOMapper . updateById ( update ) ;
}
// String qrCodeAction = cpUserStore.getQrCodeAction();
// if (StringUtils.isBlank(qrCodeAction)){
// qrCodeAction = getQrCodeFromBSD(cpUserStore.getCpUserId(),BSD_REQ_QRCODE_TYPE_STORE,"0",cpUserStore.getCode());
// cpUserStore.setQrCodeAction(qrCodeAction);
// PrivilageCpUserDO update = new PrivilageCpUserDO();
// update.setId(cpUserStore.getUserId());
// update.setQrCode(qrCodeAction);
// privilageCpUserDOMapper.updateById(update);
// }
//查询导购数目
List < Long > shops = Arrays . asList ( cpUserStore . getId ( ) ) ;
List< PoiStoreStaffDTO > sellerList = poiStoreStaffDOMapper . selectSellersByShopIds ( shops ) ;
int staffNum = 0 ;
if ( null ! = sellerList & & sellerList . size ( ) > 0 ) {
staffNum = sellerList . size ( ) ;
}
Integer staffNum = poiStoreStaffDOMapper . selectSellersByShopIds Count ( shops ) ;
// int staffNum = 0;
// if (null != sellerList && sellerList.size() > 0) {
// staffNum = sellerList.size();
// }
cpUserStore . setStaffNum ( staffNum ) ;
//客户数
QueryWrapper < OpSellerCustomerRelation > wrapper2 = new QueryWrapper < > ( ) ;
wrapper2 . eq ( "store_id" , cpUserStore . getId ( ) ) ;
List< OpSellerCustomerRelation > opRelations = opSellerCustomerRelationDOMapper . selectLis t( wrapper2 ) ;
long count = opRelations . stream ( ) . map ( OpSellerCustomerRelation : : getCustomerId ) . distinct ( ) . count ( ) ;
cpUserStore . setCustomerNum ( ( int ) count ) ;
Integer opRelations = opSellerCustomerRelationDOMapper . selectCoun t( wrapper2 ) ;
// long count = opRelations.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
cpUserStore . setCustomerNum ( opRelations ) ;
results . add ( cpUserStore ) ;
}
}
System . out . println ( s - System . currentTimeMillis ( ) ) ;
if ( CollectionUtils . isNotEmpty ( results ) ) {
createStoreUserExcel ( results , response ) ;
}
System . out . println ( s - System . currentTimeMillis ( ) ) ;
}
public void createStoreUserExcel ( List < StoreUserDTO > results , HttpServletResponse response ) throws IOException {
@ -530,10 +537,10 @@ public class StoreEmployeeService {
aliasCell . setCellValue ( cpUserExcelDTO . getCustomerNum ( ) ) ;
}
OutputStream output = response . getOutputStream ( ) ;
response . reset ( ) ;
response . setHeader ( "Content-disposition" , "attachment; filename=store.xls" ) ;
response . setContentType ( "application/ msexcel") ;
response . setContentType ( "application/ vnd. ms- excel") ;
ws . write ( output ) ;
ws . close ( ) ;
}
/ * *