Commit 08493dea authored by unset's avatar unset

修改支付信息

parent d69b1193
......@@ -2,6 +2,8 @@ package com.upyuns.platform.rs.website.dto;
import lombok.Data;
import java.util.List;
/**
* @ClassName : ConfirmOrderDto
* @Description : 确认订单
......@@ -11,19 +13,5 @@ import lombok.Data;
@Data
public class ConfirmOrderDto {
/**
* 类型: 1、标准数据,2、影像图库,3、行业应用信息, 4、购物车确认订单
*/
private Integer type;
/**
* 购物车或者商品id, 逗号分隔
* 如果是影像图库,传的是图像ID imageRelationInfo
*/
private String ids;
/**
* 数量
*/
private Integer number;
List<ItemInfoDto> itemInfoDtoList;
}
package com.upyuns.platform.rs.website.dto;
import lombok.Data;
/**
* @ClassName : itemInfoDto
* @Description : 商品信息
* @Author : jiaoruizhen
* @Date: 2020-12-16 16:56
*/
@Data
public class ItemInfoDto {
Integer id;
Integer number;
/**
* 类型: 1、标准数据,2、影像图库,3、行业应用信息, 4、购物车确认订单
*/
private Integer type;
}
......@@ -50,30 +50,6 @@ public class ConfirmOrderInfoVo {
*/
private BigDecimal fee;
/**
* 类型: 1、标准数据,2、影像图库,3、行业应用信息, 4、购物车确认订单
*/
private Integer type;
/**
* 购物车或者商品id, 逗号分隔
*/
String ids;
/**
* 购物车信息列表
*/
List<ShoppingCartInfo> shoppingCartInfoList;
/**
* 行业应用信息列表
*/
List<IndustryApplicationInfo> industryApplicationInfoList;
/**
* 影像图库信息列表
*/
List<ImageImgStorage> imageImgStorageList;
private List<ItemInfoVo> itemInfoVoList;
}
......@@ -2,20 +2,20 @@ package com.upyuns.platform.rs.website.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* @ClassName : ItemInfoVo
* @Description : 商品信息
* @Author : jiaoruizhen
* @Date: 2020-12-16 15:09
* @Date: 2020-12-16 16:59
*/
@Data
public class ItemInfoVo {
private String name;
/**
* 商品参数
*/
private Integer id;
private String detailJson;
private Integer number;
private BigDecimal price;
private Integer type;
private String img;
}
package com.upyuns.platform.rs.website.service;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.upyuns.platform.rs.universal.constant.DictionaryKey;
import com.upyuns.platform.rs.universal.entity.Dictionary;
import com.upyuns.platform.rs.universal.feign.ThirdFeign;
import com.upyuns.platform.rs.website.biz.*;
import com.upyuns.platform.rs.website.dto.ConfirmOrderDto;
import com.upyuns.platform.rs.website.dto.UserAddressDto;
import com.upyuns.platform.rs.website.dto.UserInvoiceDto;
import com.upyuns.platform.rs.website.dto.ItemInfoDto;
import com.upyuns.platform.rs.website.entity.*;
import com.upyuns.platform.rs.website.type.OrderTypeEnum;
import com.upyuns.platform.rs.website.vo.ConfirmOrderInfoVo;
import com.upyuns.platform.rs.website.vo.ItemInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
......@@ -48,98 +47,91 @@ public class ConfirmOrderService {
@Autowired
ThirdFeign thirdFeign;
@Autowired
UserAddressBiz userAddressBiz;
@Autowired
UserInvoiceBiz userInvoiceBiz;
/**
* 确认订单
* @param confirmOrderDto
* @return
*/
public ObjectRestResponse confirmOrderInfo(ConfirmOrderDto confirmOrderDto) {
if (confirmOrderDto == null || confirmOrderDto.getType() == null || StringUtils.isBlank(confirmOrderDto.getIds())) {
if (confirmOrderDto == null || confirmOrderDto.getItemInfoDtoList() == null) {
return ObjectRestResponse.paramIsEmpty();
}
String[] idArr = confirmOrderDto.getIds().split(",");
Set<Integer> idList = Arrays.asList(idArr).stream().map(s -> Integer.parseInt(s.trim())).collect(Collectors.toSet());
ConfirmOrderInfoVo confirmOrderInfoVo = new ConfirmOrderInfoVo();
confirmOrderInfoVo.setType(confirmOrderDto.getType());
confirmOrderInfoVo.setIds(confirmOrderDto.getIds());
switch (OrderTypeEnum.getByCode(confirmOrderDto.getType())) {
//标准数据
case STANDARD_DATA:
break;
//行业应用
case INDUSTRY_INFO:
List<IndustryApplicationInfo> industryApplicationInfoList = industryApplicationInfoBiz.getAllByIds(idList);
if (industryApplicationInfoList != null && industryApplicationInfoList.size() > 0) {
confirmOrderInfoVo.setIndustryApplicationInfoList(industryApplicationInfoList);
//总数量
Double amount = industryApplicationInfoList.stream().mapToDouble(e->e.getPrice().doubleValue()).reduce(0, Double::sum);
confirmOrderInfoVo.setTotalAmount(new BigDecimal(amount));
confirmOrderInfoVo.setNumber(industryApplicationInfoList.size());
}
break;
//影像图库
case IMAGE_STORAGE:
List<ImageInfoRelation> imageInfoRelationList = imageInfoRelationBiz.getAllByIds(confirmOrderDto.getIds());
if (imageInfoRelationList != null && imageInfoRelationList.size() > 0) {
Map<Integer, List<ImageInfoRelation>> map = imageInfoRelationList.stream().collect(Collectors.groupingBy(ImageInfoRelation::getRelationId));
List<ImageImgStorage> imageImgStorageList = imageImgStorageBiz.getAllByIds(imageInfoRelationList.stream().map(ImageInfoRelation::getRelationId).collect(Collectors.toSet()));
if (imageImgStorageList != null && imageImgStorageList.size() > 0) {
imageImgStorageList.parallelStream().forEach(imageImgStorage -> {
if (map != null && map.get(imageImgStorage.getId()) != null) {
imageImgStorage.setImageInfoRelationList(map.get(imageImgStorage.getId()));
List<ItemInfoDto> itemInfoDtoList = confirmOrderDto.getItemInfoDtoList();
if (itemInfoDtoList != null && itemInfoDtoList.size() > 0) {
List<ItemInfoVo> itemInfoVoList = new ArrayList<>();
AtomicReference<Integer> number = new AtomicReference<>(0);
AtomicReference<Double> amount = new AtomicReference<>((double) 0);
itemInfoDtoList.parallelStream().forEach(itemInfoDto -> {
switch (OrderTypeEnum.getByCode(itemInfoDto.getType())) {
//标准数据
case STANDARD_DATA:
break;
//行业应用
case INDUSTRY_INFO:
IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.getOneById(itemInfoDto.getId()).getData();
if (industryApplicationInfo != null) {
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(industryApplicationInfo.getId());
itemInfoVo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
itemInfoVo.setImg(industryApplicationInfo.getCoverImg());
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setType(itemInfoDto.getType());
itemInfoVo.setPrice(industryApplicationInfo.getPrice());
itemInfoVoList.add(itemInfoVo);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = industryApplicationInfo.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber()));
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
break;
//影像图库
case IMAGE_STORAGE:
ImageInfoRelation imageInfoRelation = imageInfoRelationBiz.selectById(itemInfoDto.getId());
if (imageInfoRelation != null ) {
ImageImgStorage imageImgStorage = imageImgStorageBiz.getDetail(itemInfoDto.getId()).getData();
if (imageImgStorage != null) {
List<ImageInfoRelation> imageInfoRelationList = new ArrayList<>();
imageInfoRelationList.add(imageInfoRelation);
imageImgStorage.setImageInfoRelationList(imageInfoRelationList);
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(imageImgStorage.getId());
itemInfoVo.setPrice(imageInfoRelation.getPrice());
itemInfoVo.setType(itemInfoDto.getType());
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setImg(imageImgStorage.getCoverImg());
itemInfoVo.setDetailJson(JSONObject.toJSONString(imageImgStorage));
itemInfoVoList.add(itemInfoVo);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = imageInfoRelation.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber()));
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
});
confirmOrderInfoVo.setImageImgStorageList(imageImgStorageList);
//总数量
confirmOrderInfoVo.setNumber(imageInfoRelationList.size());
Double amount = imageInfoRelationList.stream().mapToDouble(e->e.getPrice().doubleValue()).reduce(0, Double::sum);
confirmOrderInfoVo.setTotalAmount(new BigDecimal(amount));
}
}
break;
//购物车
case SHOPPING_CART_INFO:
List<ShoppingCartInfo> shoppingCartInfoList = shoppingCartInfoBiz.getAllByIds(idList);
if (shoppingCartInfoList != null && shoppingCartInfoList.size() > 0) {
confirmOrderInfoVo.setShoppingCartInfoList(shoppingCartInfoList);
Double amount = shoppingCartInfoList.stream().mapToDouble(e->e.getTotalAmount().doubleValue()).reduce(0, Double::sum);
confirmOrderInfoVo.setTotalAmount(new BigDecimal(amount));
}
break;
//购物车
case SHOPPING_CART_INFO:
ShoppingCartInfo shoppingCartInfo = shoppingCartInfoBiz.selectById(itemInfoDto.getId());
if (shoppingCartInfo != null) {
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = shoppingCartInfo.getTotalAmount();
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
break;
default:
break;
}
break;
default:
break;
});
confirmOrderInfoVo.setTotalAmount(new BigDecimal(amount.get()));
confirmOrderInfoVo.setNumber(number.get());
}
confirmOrderInfoVo.setActAmount(confirmOrderInfoVo.getTotalAmount());
confirmOrderInfoVo.setActAmount(confirmOrderInfoVo.getTotalAmount());
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DictionaryKey.APP_ORDER, DictionaryKey.SEND_FEE);
if (dictionary != null && StringUtils.isBlank(dictionary.getDetail())) {
confirmOrderInfoVo.setFee(new BigDecimal(dictionary.getDetail()));
}
try {
List<UserAddress> userAddressList = userAddressBiz.getUserAddress(new UserAddressDto(){{setPage(1); setLimit(Integer.MAX_VALUE);}}).getData().getData();
if (userAddressList != null && userAddressList.size() > 0) {
confirmOrderInfoVo.setUserAddressList(userAddressList);
}
} catch (Exception e) {
log.error("用户地址信息错误: {}", e);
}
try {
List<UserInvoice> userInvoiceList = userInvoiceBiz.getUserInvoiceInfo(new UserInvoiceDto(){{setPage(1); setLimit(Integer.MAX_VALUE);}}).getData().getData();
if (userInvoiceList != null && userInvoiceList.size() > 0) {
confirmOrderInfoVo.setUserInvoiceList(userInvoiceList);
}
} catch (Exception e) {
log.error("用户发票信息错误: {}", e);
}
return ObjectRestResponse.succ(confirmOrderInfoVo);
}
......
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