Commit 5c52f91b authored by unset's avatar unset

修改支付信息

parent e3754e02
package com.upyuns.platform.rs.website.dto; package com.upyuns.platform.rs.website.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -11,7 +12,7 @@ import java.math.BigDecimal; ...@@ -11,7 +12,7 @@ import java.math.BigDecimal;
* @Date: 2020-12-12 17:09 * @Date: 2020-12-12 17:09
*/ */
@Data @Data
public class OrderInfoDto { public class OrderInfoDto extends PageParam {
//详情ID //详情ID
Integer detailId; Integer detailId;
......
...@@ -90,5 +90,8 @@ public class CommonInfo implements Serializable { ...@@ -90,5 +90,8 @@ public class CommonInfo implements Serializable {
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
private Integer rank; private Integer rank;
/**
* 图标
*/
private String icon;
} }
...@@ -6,7 +6,9 @@ import com.alibaba.fastjson.JSONObject; ...@@ -6,7 +6,9 @@ import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; 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.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.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.*;
...@@ -74,14 +76,20 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping ...@@ -74,14 +76,20 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
/** /**
* 获取用户所有购物车商品 * 获取用户所有购物车商品
* @param userId * @param orderInfoDto
* @return * @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 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(); 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,6 +115,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping ...@@ -107,6 +115,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
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());
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 shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(imageImgStorage.getId()); shoppingCartInfo.setDetailId(imageImgStorage.getId());
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(imageImgStorage)); shoppingCartInfo.setDetailJson(JSONObject.toJSONString(imageImgStorage));
...@@ -124,6 +138,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping ...@@ -124,6 +138,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
shoppingCartInfo.setPhone(appUserDTO.getUsername()); shoppingCartInfo.setPhone(appUserDTO.getUsername());
shoppingCartInfo.setUserId(appUserDTO.getUserid()); shoppingCartInfo.setUserId(appUserDTO.getUserid());
addUpdate(shoppingCartInfo); addUpdate(shoppingCartInfo);
}
} else { } else {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE)); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
} }
...@@ -133,6 +148,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping ...@@ -133,6 +148,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
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());
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 shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(industryApplicationInfo.getId()); shoppingCartInfo.setDetailId(industryApplicationInfo.getId());
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo)); shoppingCartInfo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
...@@ -150,7 +171,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping ...@@ -150,7 +171,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
shoppingCartInfo.setPhone(appUserDTO.getUsername()); shoppingCartInfo.setPhone(appUserDTO.getUsername());
shoppingCartInfo.setUserId(appUserDTO.getUserid()); shoppingCartInfo.setUserId(appUserDTO.getUserid());
addUpdate(shoppingCartInfo); addUpdate(shoppingCartInfo);
}
} else { } else {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE)); return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
} }
...@@ -159,6 +180,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping ...@@ -159,6 +180,12 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper,Shopping
return ObjectRestResponse.succ(); 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 * @param cartOrderDto
......
package com.upyuns.platform.rs.website.controller.web; 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.github.wxiaoqi.security.common.rest.BaseController;
import com.upyuns.platform.rs.website.biz.ShoppingCartInfoBiz; 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 com.upyuns.platform.rs.website.entity.ShoppingCartInfo;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("shoppingCartInfo/web") @RequestMapping("shoppingCartInfo/web")
public class ShoppingCartInfoWebController extends BaseController<ShoppingCartInfoBiz,ShoppingCartInfo> { 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