Commit a8bb5bc2 authored by unset's avatar unset

添加标准数据处理

parent 2836d950
...@@ -10,6 +10,8 @@ import com.github.wxiaoqi.security.common.util.OrderUtil; ...@@ -10,6 +10,8 @@ import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.upyuns.platform.rs.datacenter.fegin.DatacenterFeign;
import com.upyuns.platform.rs.datacenter.pojo.ImageDataVO;
import com.upyuns.platform.rs.universal.constant.DictionaryKey; import com.upyuns.platform.rs.universal.constant.DictionaryKey;
import com.upyuns.platform.rs.universal.entity.Dictionary; import com.upyuns.platform.rs.universal.entity.Dictionary;
import com.upyuns.platform.rs.universal.feign.ThirdFeign; import com.upyuns.platform.rs.universal.feign.ThirdFeign;
...@@ -80,6 +82,9 @@ public class OrderInfoBiz extends BaseBiz<OrderInfoMapper, OrderInfo> { ...@@ -80,6 +82,9 @@ public class OrderInfoBiz extends BaseBiz<OrderInfoMapper, OrderInfo> {
@Autowired @Autowired
UserInvoiceBiz userInvoiceBiz; UserInvoiceBiz userInvoiceBiz;
@Autowired
DatacenterFeign datacenterFeign;
/** /**
* 添加订单 * 添加订单
* @param orderInfo * @param orderInfo
...@@ -253,7 +258,22 @@ public class OrderInfoBiz extends BaseBiz<OrderInfoMapper, OrderInfo> { ...@@ -253,7 +258,22 @@ public class OrderInfoBiz extends BaseBiz<OrderInfoMapper, OrderInfo> {
switch (OrderTypeEnum.getByCode(itemInfoDto.getType())) { switch (OrderTypeEnum.getByCode(itemInfoDto.getType())) {
//标准数据 //标准数据
case STANDARD_DATA: case STANDARD_DATA:
List<ImageDataVO> imageDataVOList = datacenterFeign.queryByIds(orderInfoDto.getDetailId() + "").getData();
if (imageDataVOList != null && imageDataVOList.size() > 0) {
ImageDataVO imageDataVO = imageDataVOList.get(0);
OrderItem orderItem = new OrderItem();
orderItem.setType(itemInfoDto.getType());
orderItem.setTotalAmount(imageDataVO.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber())));
orderItem.setPrice(imageDataVO.getPrice());
orderItem.setNumber(itemInfoDto.getNumber());
orderItem.setDetailJson(JSONObject.toJSONString(imageDataVO));
orderItem.setDetailId(Long.valueOf(imageDataVO.getId()));
orderItemList.add(orderItem);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = imageDataVO.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber()));
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
break; break;
//行业应用 //行业应用
case INDUSTRY_INFO: case INDUSTRY_INFO:
......
...@@ -9,10 +9,13 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -9,10 +9,13 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query; import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.upyuns.platform.rs.datacenter.fegin.DatacenterFeign;
import com.upyuns.platform.rs.datacenter.pojo.ImageDataVO;
import com.upyuns.platform.rs.website.dto.CartOrderDto; import com.upyuns.platform.rs.website.dto.CartOrderDto;
import com.upyuns.platform.rs.website.dto.OrderInfoDto; import com.upyuns.platform.rs.website.dto.OrderInfoDto;
import com.upyuns.platform.rs.website.entity.*; import com.upyuns.platform.rs.website.entity.*;
import com.upyuns.platform.rs.website.type.OrderTypeEnum; import com.upyuns.platform.rs.website.type.OrderTypeEnum;
import com.upyuns.platform.rs.website.vo.ItemInfoVo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -56,6 +59,9 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin ...@@ -56,6 +59,9 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin
@Autowired @Autowired
HttpServletRequest request; HttpServletRequest request;
@Autowired
DatacenterFeign datacenterFeign;
/** /**
* 添加购物车 * 添加购物车
* *
...@@ -112,14 +118,41 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin ...@@ -112,14 +118,41 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin
//标准数据 //标准数据
if (OrderTypeEnum.STANDARD_DATA.getType().equals(orderInfoDto.getType())) { if (OrderTypeEnum.STANDARD_DATA.getType().equals(orderInfoDto.getType())) {
List<ImageDataVO> imageDataVOList = datacenterFeign.queryByIds(orderInfoDto.getDetailId() + "").getData();
if (imageDataVOList != null && imageDataVOList.size() > 0) {
ImageDataVO imageDataVO = imageDataVOList.get(0);
ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), Long.valueOf(imageDataVO.getId()));
if (old != null) {
old.setNumber(old.getNumber() + orderInfoDto.getNumber());
old.setTotalAmount(old.getPrice().multiply(new BigDecimal(old.getNumber())));
updateSelectiveByIdRe(old);
} else {
ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(Long.valueOf(imageDataVO.getId()));
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(imageDataVO));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
shoppingCartInfo.setNumber(orderInfoDto.getNumber());
shoppingCartInfo.setTotalAmount(orderInfoDto.getPrice().multiply(new BigDecimal(orderInfoDto.getNumber())));
shoppingCartInfo.setType(orderInfoDto.getType());
//添加用户信息
shoppingCartInfo.setRealName(appUserDTO.getRealname());
shoppingCartInfo.setNickname(appUserDTO.getNickname());
shoppingCartInfo.setHeadImg(appUserDTO.getHeadimgurl());
shoppingCartInfo.setPhone(appUserDTO.getUsername());
shoppingCartInfo.setUserId(appUserDTO.getUserid());
addUpdate(shoppingCartInfo);
}
} else {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
}
} }
//影像图库 //影像图库
if (OrderTypeEnum.IMAGE_STORAGE.getType().equals(orderInfoDto.getType())) { if (OrderTypeEnum.IMAGE_STORAGE.getType().equals(orderInfoDto.getType())) {
ImageImgStorage imageImgStorage = imageImgStorageBiz.selectById(orderInfoDto.getDetailId()); ImageImgStorage imageImgStorage = imageImgStorageBiz.selectById(orderInfoDto.getDetailId());
if (imageImgStorage != null) { if (imageImgStorage != null) {
ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), imageImgStorage.getId()); ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), Long.valueOf(imageImgStorage.getId()));
if (old != null) { if (old != null) {
old.setNumber(old.getNumber() + orderInfoDto.getNumber()); old.setNumber(old.getNumber() + orderInfoDto.getNumber());
old.setTotalAmount(old.getPrice().multiply(new BigDecimal(old.getNumber()))); old.setTotalAmount(old.getPrice().multiply(new BigDecimal(old.getNumber())));
...@@ -152,7 +185,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin ...@@ -152,7 +185,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin
if (OrderTypeEnum.INDUSTRY_INFO.getType().equals(orderInfoDto.getType())) { if (OrderTypeEnum.INDUSTRY_INFO.getType().equals(orderInfoDto.getType())) {
IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.selectById(orderInfoDto.getDetailId()); IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.selectById(orderInfoDto.getDetailId());
if (industryApplicationInfo != null) { if (industryApplicationInfo != null) {
ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), industryApplicationInfo.getId()); ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), Long.valueOf(industryApplicationInfo.getId()));
if (old != null) { if (old != null) {
old.setNumber(old.getNumber() + orderInfoDto.getNumber()); old.setNumber(old.getNumber() + orderInfoDto.getNumber());
old.setTotalAmount(old.getPrice().multiply(new BigDecimal(old.getNumber()))); old.setTotalAmount(old.getPrice().multiply(new BigDecimal(old.getNumber())));
...@@ -184,7 +217,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin ...@@ -184,7 +217,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
public ShoppingCartInfo selectByUser(Integer userId, Integer detailId) { public ShoppingCartInfo selectByUser(Integer userId, Long detailId) {
Example example = new Example(ShoppingCartInfo.class); Example example = new Example(ShoppingCartInfo.class);
example.createCriteria().andEqualTo("detailId", detailId).andEqualTo("userId", userId); example.createCriteria().andEqualTo("detailId", detailId).andEqualTo("userId", userId);
return mapper.selectOneByExample(example); return mapper.selectOneByExample(example);
......
...@@ -3,6 +3,7 @@ package com.upyuns.platform.rs.website.service; ...@@ -3,6 +3,7 @@ package com.upyuns.platform.rs.website.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.upyuns.platform.rs.datacenter.fegin.DatacenterFeign; import com.upyuns.platform.rs.datacenter.fegin.DatacenterFeign;
import com.upyuns.platform.rs.datacenter.pojo.ImageDataVO;
import com.upyuns.platform.rs.universal.constant.DictionaryKey; import com.upyuns.platform.rs.universal.constant.DictionaryKey;
import com.upyuns.platform.rs.universal.entity.Dictionary; import com.upyuns.platform.rs.universal.entity.Dictionary;
import com.upyuns.platform.rs.universal.feign.ThirdFeign; import com.upyuns.platform.rs.universal.feign.ThirdFeign;
...@@ -70,7 +71,21 @@ public class ConfirmOrderService { ...@@ -70,7 +71,21 @@ public class ConfirmOrderService {
switch (OrderTypeEnum.getByCode(itemInfoDto.getType())) { switch (OrderTypeEnum.getByCode(itemInfoDto.getType())) {
//标准数据 //标准数据
case STANDARD_DATA: case STANDARD_DATA:
List<ImageDataVO> imageDataVOList = datacenterFeign.queryByIds(itemInfoDto.getId() + "").getData();
if (imageDataVOList != null && imageDataVOList.size() > 0) {
ImageDataVO imageDataVO = imageDataVOList.get(0);
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(Long.valueOf(imageDataVO.getId()));
itemInfoVo.setDetailJson(JSONObject.toJSONString(imageDataVO));
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setType(itemInfoDto.getType());
itemInfoVo.setPrice(imageDataVO.getPrice());
itemInfoVoList.add(itemInfoVo);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = imageDataVO.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber()));
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
break; break;
//行业应用 //行业应用
case INDUSTRY_INFO: case INDUSTRY_INFO:
......
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