Commit d376c0a8 authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents 72077691 fbcbb56e
......@@ -89,4 +89,9 @@ public class DictionaryKey {
* 取消时间缓冲(分钟)
*/
public static final String CANCEL_TIME_BUFFER = "CANCEL_TIME_BUFFER";
/**
* 运费
*/
public static final String SEND_FEE = "SEND_FEE";
}
package com.upyuns.platform.rs.website.dto;
import lombok.Data;
import java.util.List;
/**
* @ClassName : ConfirmOrderDto
* @Description : 确认订单
* @Author : jiaoruizhen
* @Date: 2020-12-16 14:51
*/
@Data
public class ConfirmOrderDto {
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;
}
package com.upyuns.platform.rs.website.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
......@@ -143,6 +144,11 @@ public class IndustryApplicationInfo implements Serializable {
*/
private Integer customized;
/**
* 价格信息
*/
private BigDecimal price;
@Transient
private String firstTitle;
......
......@@ -9,7 +9,8 @@ package com.upyuns.platform.rs.website.type;
public enum OrderTypeEnum {
STANDARD_DATA(1, "标准数据"),
INDUSTRY_INFO(3, "行业应用"),
IMAGE_STORAGE(2, "影像图库");
IMAGE_STORAGE(2, "影像图库"),
SHOPPING_CART_INFO(4, "购物车下单");
private Integer type;
private String msg;
......
package com.upyuns.platform.rs.website.vo;
import com.upyuns.platform.rs.website.entity.*;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @ClassName : ConfirmOrderInfoVo
* @Description : 确认订单
* @Author : jiaoruizhen
* @Date: 2020-12-16 14:57
*/
@Data
public class ConfirmOrderInfoVo {
/**
* 配送方式:1、线上配送,2、快递配送
*/
private Integer sendType;
/**
* 用户地址列表
*/
private List<UserAddress> userAddressList;
/**
* 用户发票列表
*/
private List<UserInvoice> userInvoiceList;
/**
* 订单商品数量
*/
private Integer number;
/**
* 总金额
*/
private BigDecimal totalAmount;
/**
* 实付金额
*/
private BigDecimal actAmount;
/**
* 运费
*/
private BigDecimal fee;
private List<ItemInfoVo> itemInfoVoList;
}
package com.upyuns.platform.rs.website.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* @ClassName : ItemInfoVo
* @Description : 商品信息
* @Author : jiaoruizhen
* @Date: 2020-12-16 16:59
*/
@Data
public class ItemInfoVo {
private Integer id;
private String detailJson;
private Integer number;
private BigDecimal price;
private Integer type;
private String img;
}
......@@ -17,7 +17,9 @@ import com.upyuns.platform.rs.website.mapper.ImageImgStorageMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* 影像图库
......@@ -118,7 +120,7 @@ public class ImageImgStorageBiz extends BaseBiz<ImageImgStorageMapper,ImageImgSt
* @param id
* @return
*/
public ObjectRestResponse getDetail(Integer id) {
public ObjectRestResponse<ImageImgStorage> getDetail(Integer id) {
if (id == null) {
return ObjectRestResponse.paramIsEmpty();
}
......@@ -147,4 +149,14 @@ public class ImageImgStorageBiz extends BaseBiz<ImageImgStorageMapper,ImageImgSt
return ObjectRestResponse.succ(mapper.selectByExample(example));
}
/**
* 根据ID List 获取所有图库信息
* @param idList
* @return
*/
public List<ImageImgStorage> getAllByIds(Set<Integer> idList) {
Example example = new Example(ImageImgStorage.class);
example.createCriteria().andIn("id", idList);
return mapper.selectByExample(example);
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -109,4 +110,16 @@ public class IndustryApplicationInfoBiz extends BaseBiz<IndustryApplicationInfoM
}
return ObjectRestResponse.succ(list);
}
/**
* 根据ID List获取行业应用信息
* @param idList
* @return
*/
public List<IndustryApplicationInfo> getAllByIds(Set<Integer> idList) {
Example example = new Example(IndustryApplicationInfo.class);
example.createCriteria().andIn("id", idList);
return mapper.selectByExample(example);
}
}
\ No newline at end of file
......@@ -26,6 +26,7 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
/**
* 购物车
......@@ -35,7 +36,7 @@ import java.util.List;
* @date 2020-12-03 13:29:23
*/
@Service
public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,ShoppingCartInfo> {
public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, ShoppingCartInfo> {
@Autowired
OrderInfoBiz orderInfoBiz;
......@@ -57,6 +58,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 添加购物车
*
* @param shoppingCartInfo
* @return
*/
......@@ -76,6 +78,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 获取用户所有购物车商品
*
* @param orderInfoDto
* @return
*/
......@@ -94,6 +97,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 前端用户添加购物车
*
* @param orderInfoDto 商品详情ID
* @return
*/
......@@ -188,6 +192,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 购物车转为订单
*
* @param cartOrderDto
* @return
*/
......@@ -215,11 +220,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 购物车转订单实现
*
* @param cartInfoList
*/
private void convertToOrderInfo(List<ShoppingCartInfo> cartInfoList, CartOrderDto cartOrderDto, AppUserDTO appUserDTO) {
//总金额
double amount = cartInfoList.parallelStream().mapToDouble(shoppingCartInfo ->shoppingCartInfo.getTotalAmount().doubleValue()).sum();
double amount = cartInfoList.parallelStream().mapToDouble(shoppingCartInfo -> shoppingCartInfo.getTotalAmount().doubleValue()).sum();
//总数量
Integer totalNumber = cartInfoList.parallelStream().mapToInt(ShoppingCartInfo::getNumber).sum();
OrderInfo orderInfo = new OrderInfo();
......@@ -248,6 +254,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 删除购物车
*
* @param id
* @return
*/
......@@ -266,6 +273,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 批量删除
*
* @param ids
* @return
*/
......@@ -285,4 +293,15 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
return ObjectRestResponse.succ();
}
/**
* 根据ID List 查询所有购物车信息
* @param idList
* @return
*/
public List<ShoppingCartInfo> getAllByIds(Set<Integer> idList) {
Example example = new Example(ShoppingCartInfo.class);
example.createCriteria().andIn("id", idList);
return mapper.selectByExample(example);
}
}
\ No newline at end of file
......@@ -93,7 +93,7 @@ public class UserAddressBiz extends BaseBiz<UserAddressMapper, UserAddress> {
*
* @return
*/
public ObjectRestResponse getUserAddress(UserAddressDto userAddressDto) {
public ObjectRestResponse<PageDataVO<UserAddress>> getUserAddress(UserAddressDto userAddressDto) {
AppUserDTO appUserVo = userFeign.userDetailByToken(request.getHeader("Authorization")).getData();
if (appUserVo == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
......
......@@ -104,7 +104,7 @@ public class UserInvoiceBiz extends BaseBiz<UserInvoiceMapper,UserInvoice> {
* @param userInvoiceDto
* @return
*/
public ObjectRestResponse getList(UserInvoiceDto userInvoiceDto) {
public ObjectRestResponse<PageDataVO<UserInvoice>> getList(UserInvoiceDto userInvoiceDto) {
Example example = new Example(UserInvoice.class);
Example.Criteria criteria = example.createCriteria();
if (userInvoiceDto.getUserId() != null) {
......@@ -131,7 +131,7 @@ public class UserInvoiceBiz extends BaseBiz<UserInvoiceMapper,UserInvoice> {
* @param userInvoiceDto
* @return
*/
public ObjectRestResponse getUserInvoiceInfo(UserInvoiceDto userInvoiceDto) {
public ObjectRestResponse<PageDataVO<UserInvoice>> getUserInvoiceInfo(UserInvoiceDto userInvoiceDto) {
AppUserDTO appUserDTO = userFeign.userDetailByToken(request.getHeader("Authorization")).getData();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
......
package com.upyuns.platform.rs.website.controller.web;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.upyuns.platform.rs.website.biz.OrderInfoBiz;
import com.upyuns.platform.rs.website.dto.ConfirmOrderDto;
import com.upyuns.platform.rs.website.entity.OrderInfo;
import com.upyuns.platform.rs.website.service.ConfirmOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -10,4 +16,13 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("orderInfo/web")
public class OrderInfoWebController extends BaseController<OrderInfoBiz,OrderInfo> {
@Autowired
ConfirmOrderService confirmOrderService;
@PostMapping(value = "confirmOrder")
public ObjectRestResponse confirmOrder(@RequestBody ConfirmOrderDto confirmOrderDto) {
return confirmOrderService.confirmOrderInfo(confirmOrderDto);
}
}
\ No newline at end of file
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.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.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* @ClassName : ConfirmOrderService
* @Description : 确认订单信息
* @Author : jiaoruizhen
* @Date: 2020-12-16 14:50
*/
@Service
@Slf4j
public class ConfirmOrderService {
@Autowired
IndustryApplicationInfoBiz industryApplicationInfoBiz;
@Autowired
ImageImgStorageBiz imageImgStorageBiz;
@Autowired
ShoppingCartInfoBiz shoppingCartInfoBiz;
@Autowired
ImageInfoRelationBiz imageInfoRelationBiz;
@Autowired
ThirdFeign thirdFeign;
/**
* 确认订单
* @param confirmOrderDto
* @return
*/
public ObjectRestResponse confirmOrderInfo(ConfirmOrderDto confirmOrderDto) {
if (confirmOrderDto == null || confirmOrderDto.getItemInfoDtoList() == null) {
return ObjectRestResponse.paramIsEmpty();
}
ConfirmOrderInfoVo confirmOrderInfoVo = new ConfirmOrderInfoVo();
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())));
}
}
break;
//购物车
case SHOPPING_CART_INFO:
ShoppingCartInfo shoppingCartInfo = shoppingCartInfoBiz.selectById(itemInfoDto.getId());
if (shoppingCartInfo != null) {
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(shoppingCartInfo.getCartId().intValue());
itemInfoVo.setPrice(shoppingCartInfo.getPrice());
itemInfoVo.setType(shoppingCartInfo.getType());
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setImg(shoppingCartInfo.getItemPic());
itemInfoVo.setDetailJson(shoppingCartInfo.getDetailJson());
itemInfoVoList.add(itemInfoVo);
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = shoppingCartInfo.getTotalAmount();
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
break;
default:
break;
}
});
confirmOrderInfoVo.setTotalAmount(new BigDecimal(amount.get()));
confirmOrderInfoVo.setNumber(number.get());
confirmOrderInfoVo.setItemInfoVoList(itemInfoVoList);
}
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DictionaryKey.APP_ORDER, DictionaryKey.SEND_FEE);
if (dictionary != null && StringUtils.isNotBlank(dictionary.getDetail())) {
confirmOrderInfoVo.setFee(new BigDecimal(dictionary.getDetail()));
}
if (confirmOrderInfoVo.getFee() != null) {
confirmOrderInfoVo.setActAmount(confirmOrderInfoVo.getTotalAmount().add(confirmOrderInfoVo.getFee()));
}
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