优化订单导出逻辑。解决用户缺失导致错
This commit is contained in:
@ -54,4 +54,6 @@ public interface YxStoreOrderRepository extends JpaRepository<YxStoreOrder, Inte
|
||||
* @return
|
||||
*/
|
||||
YxStoreOrder findByUnique(String unique);
|
||||
}
|
||||
|
||||
List<YxStoreOrder> findByOrderIdIn(List<String> ids);
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -388,21 +389,14 @@ public class StoreOrderController {
|
||||
@RequestParam(name = "orderStatus") String orderStatus,
|
||||
@RequestParam(name = "orderType") String orderType,
|
||||
@RequestParam(name = "listContent") String listContent) throws IOException, ParseException {
|
||||
List<YxStoreOrderDTO> list = (List)getYxStoreList(criteria, pageable, orderStatus, orderType).get("content");
|
||||
List<YxStoreOrderDTO> list;
|
||||
if(StringUtils.isEmpty(listContent)){
|
||||
yxStoreOrderService.download(list, response);
|
||||
list = (List)getYxStoreList(criteria, pageable, orderStatus, orderType).get("content");
|
||||
}else {
|
||||
List<String> idList = JSONArray.parseArray(listContent).toJavaList(String.class);
|
||||
List<YxStoreOrderDTO> yxStoreOrderDTOS = new ArrayList<>();
|
||||
for(YxStoreOrderDTO yx : list){
|
||||
for(String ids : idList){
|
||||
if(yx.getOrderId().equals(ids)){
|
||||
yxStoreOrderDTOS.add(yx);
|
||||
}
|
||||
}
|
||||
}
|
||||
yxStoreOrderService.download(yxStoreOrderDTOS, response);
|
||||
list = (List)yxStoreOrderService.queryAll(idList).get("content");
|
||||
}
|
||||
yxStoreOrderService.download(list, response);
|
||||
}
|
||||
|
||||
public Map<String,Object> getYxStoreList(YxStoreOrderQueryCriteria criteria,
|
||||
|
@ -79,4 +79,7 @@ public interface YxStoreOrderService {
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void delete(Integer id);
|
||||
}
|
||||
|
||||
|
||||
Map<String,Object> queryAll(List<String> ids);
|
||||
}
|
||||
|
@ -319,7 +319,70 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
public Map<String,Object> queryAll(List<String> ids){
|
||||
List<YxStoreOrder> yxStoreOrders = yxStoreOrderRepository.findByOrderIdIn(ids);
|
||||
List<YxStoreOrderDTO> storeOrderDTOS = new ArrayList<>();
|
||||
for (YxStoreOrder yxStoreOrder :yxStoreOrders) {
|
||||
YxStoreOrderDTO yxStoreOrderDTO = yxStoreOrderMapper.toDto(yxStoreOrder);
|
||||
|
||||
|
||||
Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(),yxStoreOrder.getStatus(),
|
||||
yxStoreOrder.getRefundStatus());
|
||||
|
||||
if(yxStoreOrder.getStoreId() > 0) {
|
||||
String storeName = systemStoreService.findById(yxStoreOrder.getStoreId()).getName();
|
||||
yxStoreOrderDTO.setStoreName(storeName);
|
||||
}
|
||||
|
||||
//订单状态
|
||||
String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid()
|
||||
,yxStoreOrder.getStatus(),yxStoreOrder.getShippingType()
|
||||
,yxStoreOrder.getRefundStatus());
|
||||
|
||||
if(_status == 3){
|
||||
String refundTime = OrderUtil.stampToDate(String.valueOf(yxStoreOrder
|
||||
.getRefundReasonTime()));
|
||||
String str = "<b style='color:#f124c7'>申请退款</b><br/>"+
|
||||
"<span>退款原因:"+yxStoreOrder.getRefundReasonWap()+"</span><br/>" +
|
||||
"<span>备注说明:"+yxStoreOrder.getRefundReasonWapExplain()+"</span><br/>" +
|
||||
"<span>退款时间:"+refundTime+"</span><br/>";
|
||||
orderStatusStr = str;
|
||||
}
|
||||
yxStoreOrderDTO.setStatusName(orderStatusStr);
|
||||
|
||||
yxStoreOrderDTO.set_status(_status);
|
||||
|
||||
String payTypeName = OrderUtil.payTypeName(yxStoreOrder.getPayType()
|
||||
,yxStoreOrder.getPaid());
|
||||
yxStoreOrderDTO.setPayTypeName(payTypeName);
|
||||
|
||||
yxStoreOrderDTO.setPinkName(orderType(yxStoreOrder.getId()
|
||||
,yxStoreOrder.getPinkId(),yxStoreOrder.getCombinationId()
|
||||
,yxStoreOrder.getSeckillId(),yxStoreOrder.getBargainId(),
|
||||
yxStoreOrder.getShippingType()));
|
||||
|
||||
List<StoreOrderCartInfo> cartInfos = yxStoreOrderCartInfoRepository
|
||||
.findByOid(yxStoreOrder.getId());
|
||||
List<StoreOrderCartInfoDTO> cartInfoDTOS = new ArrayList<>();
|
||||
for (StoreOrderCartInfo cartInfo : cartInfos) {
|
||||
StoreOrderCartInfoDTO cartInfoDTO = new StoreOrderCartInfoDTO();
|
||||
cartInfoDTO.setCartInfoMap(JSON.parseObject(cartInfo.getCartInfo()));
|
||||
|
||||
cartInfoDTOS.add(cartInfoDTO);
|
||||
}
|
||||
yxStoreOrderDTO.setCartInfoList(cartInfoDTOS);
|
||||
yxStoreOrderDTO.setUserDTO(userService.findById(yxStoreOrder.getUid()));
|
||||
|
||||
storeOrderDTOS.add(yxStoreOrderDTO);
|
||||
|
||||
}
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",storeOrderDTOS);
|
||||
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
public List<YxStoreOrderDTO> queryAll(YxStoreOrderQueryCriteria criteria){
|
||||
return yxStoreOrderMapper.toDto(yxStoreOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
@ -406,4 +469,4 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,11 @@ public class YxUserServiceImpl implements YxUserService {
|
||||
@Override
|
||||
public YxUserDTO findById(Integer uid) {
|
||||
Optional<YxUser> yxUser = yxUserRepository.findById(uid);
|
||||
ValidationUtil.isNull(yxUser,"YxUser","uid",uid);
|
||||
return yxUserMapper.toDto(yxUser.get());
|
||||
// ValidationUtil.isNull(yxUser,"YxUser","uid",uid);
|
||||
if(yxUser.isPresent()){
|
||||
return yxUserMapper.toDto(yxUser.get());
|
||||
}
|
||||
return new YxUserDTO();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,4 +147,4 @@ public class YxUserServiceImpl implements YxUserService {
|
||||
public void incBrokeragePrice(double price, int uid) {
|
||||
yxUserRepository.incBrokeragePrice(price,uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user