Commit 60eff80f authored by xuxin's avatar xuxin

修复部分父账户数据缺失的usershop信息

parent fc8e8d2f
...@@ -162,7 +162,10 @@ public class AccountController { ...@@ -162,7 +162,10 @@ public class AccountController {
emailService.sendHtmlMail("sales@cloudam.io", "客户联系:" + contactUs.getName(), sb.toString()); emailService.sendHtmlMail("sales@cloudam.io", "客户联系:" + contactUs.getName(), sb.toString());
} }
// 消费总览
/**
* 费用明细
*/
@RequestMapping(path = "/userbilling", method = RequestMethod.POST) @RequestMapping(path = "/userbilling", method = RequestMethod.POST)
public ResultDto getUserBills0(Principal principal, @RequestBody UserPrePaidBillingRequestDto userPrePaidBillingRequestDto) { public ResultDto getUserBills0(Principal principal, @RequestBody UserPrePaidBillingRequestDto userPrePaidBillingRequestDto) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
...@@ -264,6 +267,9 @@ public class AccountController { ...@@ -264,6 +267,9 @@ public class AccountController {
return paymentService.wxCheckOrderStatus(tradno, chargeType); return paymentService.wxCheckOrderStatus(tradno, chargeType);
} }
/**
* 使用 支付宝 充值 成功后回调
*/
@RequestMapping(path = "/0xalipaycallback/{tradno}", method = RequestMethod.GET) @RequestMapping(path = "/0xalipaycallback/{tradno}", method = RequestMethod.GET)
public void alipayPayCallback(@PathVariable String tradno) { public void alipayPayCallback(@PathVariable String tradno) {
paymentService.alipaCallback(tradno); paymentService.alipaCallback(tradno);
...@@ -274,6 +280,10 @@ public class AccountController { ...@@ -274,6 +280,10 @@ public class AccountController {
return paymentService.aliCheckOrderStatus(tradno, chargeType); return paymentService.aliCheckOrderStatus(tradno, chargeType);
} }
/**
* 使用 支付宝 充值
*/
@RequestMapping(path = "/0xalipay/{amount}", method = RequestMethod.GET) @RequestMapping(path = "/0xalipay/{amount}", method = RequestMethod.GET)
public void alipayPutOrder(HttpServletRequest request, HttpServletResponse response, @PathVariable int amount) throws Exception { public void alipayPutOrder(HttpServletRequest request, HttpServletResponse response, @PathVariable int amount) throws Exception {
......
package com.edgec.browserbackend.account.dto; package com.edgec.browserbackend.account.dto;
import com.edgec.browserbackend.account.domain.Promotion; import com.edgec.browserbackend.account.domain.Promotion;
import com.edgec.browserbackend.account.domain.UserPrePaidBilling;
import org.springframework.data.domain.Page;
import java.util.List;
public class BillQueryResultDto { public class BillQueryResultDto {
double parentExpense; double parentExpense;
......
...@@ -204,6 +204,19 @@ public class ShopController { ...@@ -204,6 +204,19 @@ public class ShopController {
return resultDto; return resultDto;
} }
@GetMapping(value = "/deal_dirtydata")
public ResultDto dealDirtydata() {
Integer num = shopService.dealDirtyData();
ResultDto resultDto = new ResultDto();
resultDto.setStatus(0);
resultDto.setData("修复脏数据" + num + "条");
return resultDto;
}
private void dealClientRequestException(ResultDto resultDto, ClientRequestException e) { private void dealClientRequestException(ResultDto resultDto, ClientRequestException e) {
resultDto.setStatus(-1); resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>(); Map<String, Object> statusInfo = new HashMap<>();
......
...@@ -9,7 +9,12 @@ import java.util.List; ...@@ -9,7 +9,12 @@ import java.util.List;
public interface ShopRepository extends MongoRepository<Shop, String> { public interface ShopRepository extends MongoRepository<Shop, String> {
Page<Shop> findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(List<String> shopIds, String shopAccount, Pageable pageable); Page<Shop> findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc(List<String> shopIds, String shopAccount, Pageable pageable);
Page<Shop> findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(List<String> shopIds, String shopName, Pageable pageable); Page<Shop> findByShopIdInAndShopNameLikeOrderByCreateTimeDesc(List<String> shopIds, String shopName, Pageable pageable);
Page<Shop> findByShopIdInOrderByCreateTimeDesc(List<String> shopIds, Pageable pageable); Page<Shop> findByShopIdInOrderByCreateTimeDesc(List<String> shopIds, Pageable pageable);
List<Shop> findByShopIdIn(List<String> shopIds); List<Shop> findByShopIdIn(List<String> shopIds);
List<Shop> findByOwnerIn(List<String> owners);
} }
...@@ -26,9 +26,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -26,9 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
...@@ -546,6 +544,67 @@ public class ShopServiceImpl implements ShopService { ...@@ -546,6 +544,67 @@ public class ShopServiceImpl implements ShopService {
return shopUsers; return shopUsers;
} }
@Override
public Integer dealDirtyData() {
List<Account> all = accountRepository.findAll();
List<Account> parents = all.stream().filter(x -> StringUtils.isEmpty(x.getParent())).collect(Collectors.toList());
// 移除 父账户,剩下的都是子账户了
all.removeAll(parents);
// 父账户, 子账户列表
Map<Account, List<Account>> map = new HashMap<>();
for (Account account : parents) {
List<Account> list = new ArrayList<>();
for (Account child : all) {
if (child.getParent().equals(account.getName())) {
list.add(child);
}
}
if (list.size() != 0) {
map.put(account, list);
}
}
Integer result = 0;
Iterator<Map.Entry<Account, List<Account>>> entries = map.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<Account, List<Account>> entry = entries.next();
List<Account> children = entry.getValue();
// 查找子类所拥有的店铺
List<Shop> childrenShop = shopRepository.findByOwnerIn(children.stream().map(Account::getName).collect(Collectors.toList()));
if (childrenShop.size() == 0) {
continue;
}
List<String> ids = childrenShop.stream().map(x -> x.getShopId()).collect(Collectors.toList());
// 查出来 父账户已有的 usershop信息
List<UserShop> parentUserShops = userShopRepository.findByUsernameAndShopIdIn(entry.getKey().getName(), ids);
List<String> parentShopIds = parentUserShops.stream().map(x -> x.getShopId()).collect(Collectors.toList());
// 剩下的就是 父账户的 usershop 缺失的信息
ids.removeAll(parentShopIds);
// 构建父账户缺失的 usershop 信息并保存
List<UserShop> userShops = new ArrayList<>();
for (String id : ids) {
UserShop userShop = new UserShop();
userShop.setShopId(id);
userShop.setUsername(entry.getKey().getName());
userShop.setGroupId("-1");
userShops.add(userShop);
}
if (userShops.size() != 0) {
// 将父账户缺失的 usershop 信息补充完整
List<UserShop> userShops1 = userShopRepository.saveAll(userShops);
result += userShops1.size();
}
}
return result;
}
private String getShopId(String username, ShopResultDto shopResultDto) { private String getShopId(String username, ShopResultDto shopResultDto) {
Shop shop = new Shop(); Shop shop = new Shop();
......
package com.edgec.browserbackend.browser.service; package com.edgec.browserbackend.browser.service;
import com.edgec.browserbackend.browser.domain.Shop;
import com.edgec.browserbackend.browser.domain.ShopSummary; import com.edgec.browserbackend.browser.domain.ShopSummary;
import com.edgec.browserbackend.browser.dto.*; import com.edgec.browserbackend.browser.dto.ShopFilterDto;
import com.edgec.browserbackend.browser.dto.ShopPageResultDto;
import com.edgec.browserbackend.browser.dto.ShopResultDto;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
...@@ -31,4 +32,6 @@ public interface ShopService { ...@@ -31,4 +32,6 @@ public interface ShopService {
List<String> getShopUsers(String username, String shopId); List<String> getShopUsers(String username, String shopId);
List<String> getBatchShopUsers(String username, List<String> shopIds); List<String> getBatchShopUsers(String username, List<String> shopIds);
Integer dealDirtyData();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment