Commit 5c52f91b authored by unset's avatar unset

修改支付信息

parent e3754e02
package com.upyuns.platform.rs.website.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import java.math.BigDecimal;
......@@ -11,7 +12,7 @@ import java.math.BigDecimal;
* @Date: 2020-12-12 17:09
*/
@Data
public class OrderInfoDto {
public class OrderInfoDto extends PageParam {
//详情ID
Integer detailId;
......
......@@ -89,6 +89,9 @@ public class CommonInfo implements Serializable {
@Column(name = "rank")
@ApiModelProperty(value = "排序")
private Integer rank;
/**
* 图标
*/
private String icon;
}
......@@ -6,7 +6,9 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.upyuns.platform.rs.website.dto.CartOrderDto;
import com.upyuns.platform.rs.website.dto.OrderInfoDto;
import com.upyuns.platform.rs.website.entity.*;
......@@ -74,14 +76,20 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/**
* 获取用户所有购物车商品
* @param userId
* @param orderInfoDto
* @return
*/
public ObjectRestResponse getUserAllCart(Integer userId) {
public ObjectRestResponse getUserAllCart(OrderInfoDto orderInfoDto) {
AppUserDTO appUserDTO = userFeign.userDetailByToken(request.getHeader("Authorization")).getData();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
}
Example example = new Example(ShoppingCartInfo.class);
example.createCriteria().andEqualTo("userId", userId).andEqualTo("isDel", 0);
example.createCriteria().andEqualTo("userId", appUserDTO.getUserid()).andEqualTo("isDel", 0);
example.orderBy("updTime").desc();
return ObjectRestResponse.succ(mapper.selectByExample(example));
Query query = new Query(orderInfoDto);
PageDataVO<ShoppingCartInfo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.selectByExample(example));
return ObjectRestResponse.succ();
}
/**
......@@ -107,23 +115,30 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
if (OrderTypeEnum.IMAGE_STORAGE.getType().equals(orderInfoDto.getType())) {
ImageImgStorage imageImgStorage = imageImgStorageBiz.selectById(orderInfoDto.getDetailId());
if (imageImgStorage != null) {
ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(imageImgStorage.getId());
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(imageImgStorage));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
shoppingCartInfo.setNumber(orderInfoDto.getNumber());
shoppingCartInfo.setItemPic(imageImgStorage.getCoverImg());
shoppingCartInfo.setName(imageImgStorage.getName());
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);
ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), imageImgStorage.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(imageImgStorage.getId());
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(imageImgStorage));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
shoppingCartInfo.setNumber(orderInfoDto.getNumber());
shoppingCartInfo.setItemPic(imageImgStorage.getCoverImg());
shoppingCartInfo.setName(imageImgStorage.getName());
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));
}
......@@ -133,24 +148,30 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
if (OrderTypeEnum.INDUSTRY_INFO.getType().equals(orderInfoDto.getType())) {
IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.selectById(orderInfoDto.getDetailId());
if (industryApplicationInfo != null) {
ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(industryApplicationInfo.getId());
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
shoppingCartInfo.setNumber(orderInfoDto.getNumber());
shoppingCartInfo.setItemPic(industryApplicationInfo.getCoverImg());
shoppingCartInfo.setName(industryApplicationInfo.getTitle());
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);
ShoppingCartInfo old = selectByUser(appUserDTO.getUserid(), industryApplicationInfo.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(industryApplicationInfo.getId());
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
shoppingCartInfo.setNumber(orderInfoDto.getNumber());
shoppingCartInfo.setItemPic(industryApplicationInfo.getCoverImg());
shoppingCartInfo.setName(industryApplicationInfo.getTitle());
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));
}
......@@ -159,6 +180,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
return ObjectRestResponse.succ();
}
public ShoppingCartInfo selectByUser(Integer userId, Integer detailId) {
Example example = new Example(ShoppingCartInfo.class);
example.createCriteria().andEqualTo("detailId", detailId).andEqualTo("userId", userId);
return mapper.selectOneByExample(example);
}
/**
* 购物车转为订单
* @param cartOrderDto
......
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.ShoppingCartInfoBiz;
import com.upyuns.platform.rs.website.dto.CartOrderDto;
import com.upyuns.platform.rs.website.dto.OrderInfoDto;
import com.upyuns.platform.rs.website.entity.ShoppingCartInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("shoppingCartInfo/web")
public class ShoppingCartInfoWebController extends BaseController<ShoppingCartInfoBiz,ShoppingCartInfo> {
@PostMapping(value = "addUpdate")
public ObjectRestResponse addUpdate(@RequestBody OrderInfoDto orderInfoDto) {
return baseBiz.addShoppingCart(orderInfoDto);
}
@GetMapping(value = "getUserShoppingCart")
public ObjectRestResponse getUserShoppingCart(OrderInfoDto orderInfoDto) {
return baseBiz.getUserAllCart(orderInfoDto);
}
@PostMapping(value = "convertToOrderInfo")
public ObjectRestResponse convertToOrderInfo(CartOrderDto cartOrderDto) {
return baseBiz.convertShopCartToOrderInfo(cartOrderDto);
}
}
\ No newline at end of file
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