refactor(商城): 订单列表

完善订单操作
master
wayn 4 years ago
parent c909b92596
commit 1087155d9b

@ -22,14 +22,15 @@ public class AdminOrderController extends BaseController {
return R.success().add("page", iAdminOrderService.selectListPage(page, order));
}
@PostMapping("refound/{orderId}")
public R refound(@PathVariable Long orderId) {
@DeleteMapping("{orderId}")
public R deleteOrder(@PathVariable Long orderId) {
return R.result(iAdminOrderService.removeById(orderId));
}
@DeleteMapping("{orderId}")
public R deleteOrder(@PathVariable Long orderId) {
@PostMapping("refund/{orderId}")
public R refund(@PathVariable Long orderId) {
return R.result(iAdminOrderService.removeById(orderId));
}
}

@ -1,4 +1,4 @@
package com.wayn.mobile.api.domain;
package com.wayn.common.core.domain.shop;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;

@ -1,7 +1,7 @@
package com.wayn.mobile.api.mapper;
package com.wayn.common.core.mapper.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wayn.mobile.api.domain.OrderGoods;
import com.wayn.common.core.domain.shop.OrderGoods;
/**
* <p>

@ -1,7 +1,7 @@
package com.wayn.mobile.api.service;
package com.wayn.common.core.service.shop;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wayn.mobile.api.domain.OrderGoods;
import com.wayn.common.core.domain.shop.OrderGoods;
/**
* <p>

@ -1,5 +1,6 @@
package com.wayn.common.core.service.shop.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
@ -7,17 +8,27 @@ import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.wayn.common.core.domain.shop.Order;
import com.wayn.common.core.domain.shop.OrderGoods;
import com.wayn.common.core.domain.tool.MailConfig;
import com.wayn.common.core.domain.vo.SendMailVO;
import com.wayn.common.core.mapper.shop.AdminOrderMapper;
import com.wayn.common.core.service.shop.IAdminOrderService;
import com.wayn.common.core.service.shop.IGoodsProductService;
import com.wayn.common.core.service.shop.IMemberService;
import com.wayn.common.core.service.shop.IOrderGoodsService;
import com.wayn.common.core.service.tool.IMailConfigService;
import com.wayn.common.core.util.OrderUtil;
import com.wayn.common.util.R;
import com.wayn.common.util.mail.MailUtil;
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.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
@ -25,9 +36,22 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, Order>
@Autowired
private AdminOrderMapper adminOrderMapper;
@Autowired
private WxPayService wxPayService;
@Autowired
private IOrderGoodsService iOrderGoodsService;
@Autowired
private IGoodsProductService iGoodsProductService;
@Autowired
private IMemberService iMemberService;
@Autowired
private IMailConfigService mailConfigService;
@Override
public IPage<Order> selectListPage(IPage<Order> page, Order order) {
return adminOrderMapper.selectOrderListPage(page, order);
@ -63,7 +87,7 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, Order>
}
if (!wxPayRefundResult.getReturnCode().equals("SUCCESS")) {
log.warn("refund fail: " + wxPayRefundResult.getReturnMsg());
return R.error( "订单退款失败");
return R.error("订单退款失败");
}
if (!wxPayRefundResult.getResultCode().equals("SUCCESS")) {
log.warn("refund fail: " + wxPayRefundResult.getReturnMsg());
@ -82,14 +106,14 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, Order>
order.setUpdateTime(new Date());
updateById(order);
// 商品货品数量增加
// List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(orderId);
// for (LitemallOrderGoods orderGoods : orderGoodsList) {
// Integer productId = orderGoods.getProductId();
// Short number = orderGoods.getNumber();
// if (productService.addStock(productId, number) == 0) {
// throw new RuntimeException("商品货品库存增加失败");
// }
// }
List<OrderGoods> orderGoodsList = iOrderGoodsService.list(new QueryWrapper<OrderGoods>().eq("order_id", orderId));
for (OrderGoods orderGoods : orderGoodsList) {
Long productId = orderGoods.getProductId();
Integer number = orderGoods.getNumber();
if (iGoodsProductService.addStock(productId, number)) {
throw new RuntimeException("商品货品库存增加失败");
}
}
// 返还优惠券
// List<LitemallCouponUser> couponUsers = couponUserService.findByOid(orderId);
@ -103,8 +127,17 @@ public class AdminOrderServiceImpl extends ServiceImpl<AdminOrderMapper, Order>
//TODO 发送邮件和短信通知,这里采用异步发送
// 退款成功通知用户, 例如“您申请的订单退款 [ 单号:{1} ] 已成功,请耐心等待到账。”
// 注意订单号只发后6位
String email = iMemberService.getById(order.getUserId()).getEmail();
if (StringUtils.isNotEmpty(email)) {
MailConfig mailConfig = mailConfigService.getById(1L);
SendMailVO sendMailVO = new SendMailVO();
sendMailVO.setTitle("订单已经退款");
sendMailVO.setContent(order.getOrderSn().substring(8, 14));
sendMailVO.setSendMail(email);
MailUtil.sendMail(mailConfig, sendMailVO, false);
}
// logHelper.logOrderSucceed("退款", "订单编号 " + order.getOrderSn());
// logHelper.logOrderSucceed("退款", "订单编号 " + order.getOrderSn());
return R.success();
}
}

@ -1,9 +1,9 @@
package com.wayn.mobile.api.service.impl;
package com.wayn.common.core.service.shop.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wayn.mobile.api.domain.OrderGoods;
import com.wayn.mobile.api.mapper.OrderGoodsMapper;
import com.wayn.mobile.api.service.IOrderGoodsService;
import com.wayn.common.core.domain.shop.OrderGoods;
import com.wayn.common.core.mapper.shop.OrderGoodsMapper;
import com.wayn.common.core.service.shop.IOrderGoodsService;
import org.springframework.stereotype.Service;
/**

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wayn.mobile.api.mapper.OrderGoodsMapper">
<mapper namespace="com.wayn.common.core.mapper.shop.OrderGoodsMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.wayn.mobile.api.domain.OrderGoods">
<resultMap id="BaseResultMap" type="com.wayn.common.core.domain.shop.OrderGoods">
<result column="id" property="id" />
<result column="order_id" property="orderId" />
<result column="goods_id" property="goodsId" />

@ -32,10 +32,10 @@ import com.wayn.common.util.R;
import com.wayn.common.util.ip.IpUtils;
import com.wayn.common.util.mail.MailUtil;
import com.wayn.mobile.api.domain.Cart;
import com.wayn.mobile.api.domain.OrderGoods;
import com.wayn.common.core.domain.shop.OrderGoods;
import com.wayn.mobile.api.mapper.OrderMapper;
import com.wayn.mobile.api.service.ICartService;
import com.wayn.mobile.api.service.IOrderGoodsService;
import com.wayn.common.core.service.shop.IOrderGoodsService;
import com.wayn.mobile.api.service.IOrderService;
import com.wayn.mobile.api.task.CancelOrderTask;
import com.wayn.mobile.api.util.OrderSnGenUtil;

@ -6,8 +6,8 @@ import com.wayn.common.core.service.shop.IGoodsProductService;
import com.wayn.common.core.util.OrderUtil;
import com.wayn.common.task.Task;
import com.wayn.common.util.spring.SpringContextUtil;
import com.wayn.mobile.api.domain.OrderGoods;
import com.wayn.mobile.api.service.IOrderGoodsService;
import com.wayn.common.core.domain.shop.OrderGoods;
import com.wayn.common.core.service.shop.IOrderGoodsService;
import com.wayn.mobile.api.service.IOrderService;
import com.wayn.mobile.framework.redis.RedisCache;
import lombok.extern.slf4j.Slf4j;

Loading…
Cancel
Save