|
@@ -1,6 +1,7 @@
|
|
|
package com.yiqi.admin.controller.order;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Currency;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -16,6 +17,7 @@ import com.yiqi.common.constant.UrlConstants;
|
|
|
import com.yiqi.common.core.domain.R;
|
|
|
import com.yiqi.common.core.domain.entity.SysUser;
|
|
|
import com.yiqi.common.enums.*;
|
|
|
+import com.yiqi.common.utils.CurrencyUtil;
|
|
|
import com.yiqi.common.utils.DateUtils;
|
|
|
import com.yiqi.common.utils.SecurityUtils;
|
|
|
import com.yiqi.common.utils.bean.BeanUtils;
|
|
@@ -23,6 +25,9 @@ import com.yiqi.common.utils.poi.ExcelUtil;
|
|
|
import com.yiqi.order.domain.dto.*;
|
|
|
import com.yiqi.order.domain.dto.weapp.AppOrderGoodsCancelDTO;
|
|
|
import com.yiqi.order.domain.vo.*;
|
|
|
+import com.yiqi.recharge.domain.RechargePasswordCard;
|
|
|
+import com.yiqi.recharge.service.IRechargePasswordCardService;
|
|
|
+import com.yiqi.system.domain.SysStore;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -55,7 +60,9 @@ public class OrderGoodsController extends BaseController {
|
|
|
@Autowired
|
|
|
private IAppUserService appUserService;
|
|
|
|
|
|
- //<editor-folder desc="基础函数">
|
|
|
+ @Autowired
|
|
|
+ private IRechargePasswordCardService rechargePasswordCardService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询零售商品订单列表
|
|
|
*/
|
|
@@ -66,11 +73,11 @@ public class OrderGoodsController extends BaseController {
|
|
|
startPage();
|
|
|
List<GoodsOrderQueryVO> orderGoodsList = orderGoodsService.selectOrderGoodsList(goodsOrderQueryDTO);
|
|
|
List<Long> appUserIdList = orderGoodsList.stream().map(GoodsOrderQueryVO::getAppUserId).collect(Collectors.toList());
|
|
|
- if (CollUtil.isNotEmpty(appUserIdList)){
|
|
|
+ if (CollUtil.isNotEmpty(appUserIdList)) {
|
|
|
List<AppUserInfoVO> userInfoList = appUserService.getAppUserInfoByIds(appUserIdList);
|
|
|
Map<Long, AppUserInfoVO> userInfoVOMap = userInfoList.stream().collect(Collectors.toMap(AppUserInfoVO::getAppUserId, AppUserInfoVO -> AppUserInfoVO));
|
|
|
for (GoodsOrderQueryVO vo : orderGoodsList) {
|
|
|
- if(userInfoVOMap.containsKey(vo.getAppUserId())){
|
|
|
+ if (userInfoVOMap.containsKey(vo.getAppUserId())) {
|
|
|
BeanUtils.copyProperties(userInfoVOMap.get(vo.getAppUserId()), vo);
|
|
|
}
|
|
|
}
|
|
@@ -103,12 +110,37 @@ public class OrderGoodsController extends BaseController {
|
|
|
BeanUtils.copyProperties(orderGoods, goodsOrderInfoVO);
|
|
|
goodsOrderInfoVO.setOrderGoodsSkuList(orderGoodsService.selectOrderGoodsById(id));
|
|
|
AppUserInfoVO userInfo = appUserService.getAppUserInfoById(orderGoods.getAppUserId());
|
|
|
- if (userInfo != null){
|
|
|
+ if (userInfo != null) {
|
|
|
BeanUtils.copyProperties(userInfo, goodsOrderInfoVO);
|
|
|
}
|
|
|
return R.ok(goodsOrderInfoVO);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取零售商品订单详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/print/{id}")
|
|
|
+ @ApiOperation(value = "商品订单打印")
|
|
|
+ public R<OrderGoodsPrintVO> getPrintInfo(@PathVariable("id") Long id) {
|
|
|
+ OrderGoodsPrintVO goodsOrderInfoVO = new OrderGoodsPrintVO();
|
|
|
+ OrderGoods orderGoods = orderGoodsService.getById(id);
|
|
|
+ BeanUtils.copyProperties(orderGoods, goodsOrderInfoVO);
|
|
|
+ goodsOrderInfoVO.setOrderGoodsSkuList(orderGoodsService.selectOrderGoodsById(id));
|
|
|
+ AppUserInfoVO userInfo = appUserService.getAppUserInfoById(orderGoods.getAppUserId());
|
|
|
+ goodsOrderInfoVO.setAppUserInfoVO(userInfo);
|
|
|
+ RechargePasswordCard rechargePasswordCard = rechargePasswordCardService.selectTotalBalanceGroupByAppUser(orderGoods.getAppUserId(), OrderType.goods.getCode());
|
|
|
+ if (orderGoods.getPayType().equals(PayType.BALANCE.getCode())) {
|
|
|
+ goodsOrderInfoVO.setMemberBeforeBalance(CurrencyUtil.add(rechargePasswordCard.getTotalBalance(), orderGoods.getPayAmount()));
|
|
|
+ goodsOrderInfoVO.setMemberAfterBalance(rechargePasswordCard.getTotalBalance());
|
|
|
+ goodsOrderInfoVO.setMemberChangeAmount(orderGoods.getPayAmount());
|
|
|
+ } else {
|
|
|
+ goodsOrderInfoVO.setMemberBeforeBalance(rechargePasswordCard.getTotalBalance());
|
|
|
+ goodsOrderInfoVO.setMemberAfterBalance(rechargePasswordCard.getTotalBalance());
|
|
|
+ goodsOrderInfoVO.setMemberChangeAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ return R.ok(goodsOrderInfoVO);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增零售商品订单-下单
|
|
|
*/
|
|
@@ -123,19 +155,19 @@ public class OrderGoodsController extends BaseController {
|
|
|
List<OrderGoodsSkuInfoVO> orderGoodsSkuInfoVOS = orderGoodsService.getOrderSkuInfoByOrderSkuId(orderGoodsDTO);
|
|
|
BigDecimal totalPrice = orderGoodsSkuInfoVOS.stream().map(item -> item.getSalePrice().multiply(new BigDecimal(item.getBuyNum())))
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- if (BigDecimal.ZERO.equals(totalPrice)){
|
|
|
+ if (BigDecimal.ZERO.equals(totalPrice)) {
|
|
|
error("商品总价不能为0");
|
|
|
}
|
|
|
orderGoodsDTO.setTotalPrice(totalPrice);
|
|
|
|
|
|
// 设置门店线下参数
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
- orderGoodsDTO.setGoodsType(orderGoodsInsertDTO.getGoodsType() == null ? GoodsType.NORMAL.getCode() :orderGoodsInsertDTO.getGoodsType());
|
|
|
+ orderGoodsDTO.setGoodsType(orderGoodsInsertDTO.getGoodsType() == null ? GoodsType.NORMAL.getCode() : orderGoodsInsertDTO.getGoodsType());
|
|
|
orderGoodsDTO.setSourceType(user.getUserType());
|
|
|
orderGoodsDTO.setOrgId(user.getStoreId());
|
|
|
orderGoodsDTO.setSendTime(DateUtils.getNowDate());
|
|
|
orderGoodsDTO.setFinishTime(DateUtils.getNowDate());
|
|
|
- if (orderGoodsDTO.getDeductAmount() == null){
|
|
|
+ if (orderGoodsDTO.getDeductAmount() == null) {
|
|
|
orderGoodsDTO.setDeductAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
return R.ok(orderGoodsService.insertRetailOrderGoods(orderGoodsDTO, orderGoodsSkuInfoVOS));
|
|
@@ -157,7 +189,7 @@ public class OrderGoodsController extends BaseController {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@PostMapping("/rePayOrder")
|
|
|
@ApiOperation(value = "零售商品订单-重新支付")
|
|
|
- public R<OrderPayResultVO> rePayOrder(@RequestBody OrderGoodsDTO orderGoodsDTO) {
|
|
|
+ public R<OrderPayResultVO> rePayOrder(@RequestBody OrderGoodsDTO orderGoodsDTO) {
|
|
|
return R.ok(orderGoodsService.rePayOrder(orderGoodsDTO));
|
|
|
}
|
|
|
|
|
@@ -203,11 +235,11 @@ public class OrderGoodsController extends BaseController {
|
|
|
* 商品订单退款审核,审批同意
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- @GetMapping ("/refundApprovalPass")
|
|
|
+ @GetMapping("/refundApprovalPass")
|
|
|
@ApiOperation(value = "商品订单退款审核,审批同意")
|
|
|
public R refundApprovalPass(@RequestParam("orderId") Long orderId) {
|
|
|
// 操作人校验
|
|
|
- if (!SecurityUtils.getLoginUser().getSourceType().equals(SourceType.MANAGER.getCode())){
|
|
|
+ if (!SecurityUtils.getLoginUser().getSourceType().equals(SourceType.MANAGER.getCode())) {
|
|
|
throw new ServiceException("当前登录人没有权限操作");
|
|
|
}
|
|
|
return R.ok(orderGoodsService.refundApprovalPass(orderId));
|
|
@@ -221,7 +253,7 @@ public class OrderGoodsController extends BaseController {
|
|
|
@ApiOperation(value = "商品订单退款审核,审批驳回")
|
|
|
public R refundApprovalReject(@RequestParam("orderId") Long orderId) {
|
|
|
// 操作人校验
|
|
|
- if (!SecurityUtils.getLoginUser().getSourceType().equals(SourceType.MANAGER.getCode())){
|
|
|
+ if (!SecurityUtils.getLoginUser().getSourceType().equals(SourceType.MANAGER.getCode())) {
|
|
|
throw new ServiceException("当前登录人没有权限操作");
|
|
|
}
|
|
|
return R.ok(orderGoodsService.refundApprovalReject(orderId));
|
|
@@ -234,7 +266,7 @@ public class OrderGoodsController extends BaseController {
|
|
|
.eq(OrderGoods::getDelFlag, DeleteStatus.OK.getCode())
|
|
|
.eq(OrderGoods::getAppUserId, memberOrderQueryDTO.getAppUserId())
|
|
|
.ne(OrderGoods::getRefundStatus, OrderRefundStatus.REFUND_SUCCESS.getCode());
|
|
|
- if (SourceType.STORE.getCode().equals(SecurityUtils.getLoginUser().getSourceType())){
|
|
|
+ if (SourceType.STORE.getCode().equals(SecurityUtils.getLoginUser().getSourceType())) {
|
|
|
queryWrapper.eq(OrderGoods::getSourceType, SourceType.STORE.getCode());
|
|
|
queryWrapper.eq(OrderGoods::getOrgId, SecurityUtils.getLoginUser().getOrgId());
|
|
|
}
|
|
@@ -254,11 +286,11 @@ public class OrderGoodsController extends BaseController {
|
|
|
startPage();
|
|
|
List<GoodsOrderRefundQueryVO> orderGoodsList = orderGoodsService.getRefundOrderGoodsList(goodsOrderRefundQueryDTO);
|
|
|
List<Long> appUserIdList = orderGoodsList.stream().map(GoodsOrderRefundQueryVO::getAppUserId).collect(Collectors.toList());
|
|
|
- if (CollUtil.isNotEmpty(appUserIdList)){
|
|
|
+ if (CollUtil.isNotEmpty(appUserIdList)) {
|
|
|
List<AppUserInfoVO> userInfoList = appUserService.getAppUserInfoByIds(appUserIdList);
|
|
|
Map<Long, AppUserInfoVO> userInfoVOMap = userInfoList.stream().collect(Collectors.toMap(AppUserInfoVO::getAppUserId, AppUserInfoVO -> AppUserInfoVO));
|
|
|
for (GoodsOrderRefundQueryVO vo : orderGoodsList) {
|
|
|
- if(userInfoVOMap.containsKey(vo.getAppUserId())){
|
|
|
+ if (userInfoVOMap.containsKey(vo.getAppUserId())) {
|
|
|
BeanUtils.copyProperties(userInfoVOMap.get(vo.getAppUserId()), vo);
|
|
|
}
|
|
|
}
|
|
@@ -277,11 +309,11 @@ public class OrderGoodsController extends BaseController {
|
|
|
goodsOrderRefundQueryDTO.setPageSizeExport(50000);
|
|
|
List<GoodsOrderRefundQueryVO> orderGoodsList = orderGoodsService.getRefundOrderGoodsList(goodsOrderRefundQueryDTO);
|
|
|
List<Long> appUserIdList = orderGoodsList.stream().map(GoodsOrderRefundQueryVO::getAppUserId).collect(Collectors.toList());
|
|
|
- if (CollUtil.isNotEmpty(appUserIdList)){
|
|
|
+ if (CollUtil.isNotEmpty(appUserIdList)) {
|
|
|
List<AppUserInfoVO> userInfoList = appUserService.getAppUserInfoByIds(appUserIdList);
|
|
|
Map<Long, AppUserInfoVO> userInfoVOMap = userInfoList.stream().collect(Collectors.toMap(AppUserInfoVO::getAppUserId, AppUserInfoVO -> AppUserInfoVO));
|
|
|
for (GoodsOrderRefundQueryVO vo : orderGoodsList) {
|
|
|
- if(userInfoVOMap.containsKey(vo.getAppUserId())){
|
|
|
+ if (userInfoVOMap.containsKey(vo.getAppUserId())) {
|
|
|
BeanUtils.copyProperties(userInfoVOMap.get(vo.getAppUserId()), vo);
|
|
|
}
|
|
|
}
|