微信统一下单 退款
This commit is contained in:
parent
05d46a3adf
commit
332e8116f8
@ -0,0 +1,221 @@
|
|||||||
|
package com.ruoyi.winery.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||||
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
||||||
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.winery.domain.AppOrder;
|
||||||
|
import com.ruoyi.winery.domain.AppOrderDetail;
|
||||||
|
import com.ruoyi.winery.domain.goods.GoodsMain;
|
||||||
|
import com.ruoyi.winery.domain.winery.WineryOrders;
|
||||||
|
import com.ruoyi.winery.service.IAppOrderDetailService;
|
||||||
|
import com.ruoyi.winery.service.IAppOrderService;
|
||||||
|
import com.ruoyi.winery.service.IGoodsMainService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.ruoyi.common.core.domain.AjaxResult.error;
|
||||||
|
import static com.ruoyi.common.core.domain.AjaxResult.success;
|
||||||
|
import static com.ruoyi.common.utils.SecurityUtils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/winery/order")
|
||||||
|
public class AppOrderController extends BaseController {
|
||||||
|
|
||||||
|
private final IAppOrderService iAppOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxPayService wxPayService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGoodsMainService goodsMainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAppOrderDetailService detailService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:order:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(AppOrder appOrder) {
|
||||||
|
startPage();
|
||||||
|
LambdaQueryWrapper<AppOrder> lqw = Wrappers.lambdaQuery(appOrder);
|
||||||
|
if (appOrder.getDeptId() != null) {
|
||||||
|
lqw.eq(AppOrder::getDeptId, appOrder.getDeptId());
|
||||||
|
}
|
||||||
|
if (appOrder.getUserId() != null) {
|
||||||
|
lqw.eq(AppOrder::getUserId, appOrder.getUserId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appOrder.getAddressId())) {
|
||||||
|
lqw.eq(AppOrder::getAddressId, appOrder.getAddressId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appOrder.getPayMsg())) {
|
||||||
|
lqw.eq(AppOrder::getPayMsg, appOrder.getPayMsg());
|
||||||
|
}
|
||||||
|
if (appOrder.getTotalFee() != null) {
|
||||||
|
lqw.eq(AppOrder::getTotalFee, appOrder.getTotalFee());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appOrder.getTransportNo())) {
|
||||||
|
lqw.eq(AppOrder::getTransportNo, appOrder.getTransportNo());
|
||||||
|
}
|
||||||
|
if (appOrder.getStatus() != null) {
|
||||||
|
lqw.eq(AppOrder::getStatus, appOrder.getStatus());
|
||||||
|
}
|
||||||
|
if (appOrder.getPayTime() != null) {
|
||||||
|
lqw.eq(AppOrder::getPayTime, appOrder.getPayTime());
|
||||||
|
}
|
||||||
|
if (appOrder.getCancelTime() != null) {
|
||||||
|
lqw.eq(AppOrder::getCancelTime, appOrder.getCancelTime());
|
||||||
|
}
|
||||||
|
lqw.orderByDesc(AppOrder::getCreateTime);
|
||||||
|
List<AppOrder> list = iAppOrderService.list(lqw);
|
||||||
|
for (AppOrder order : list) {
|
||||||
|
LambdaQueryWrapper<AppOrderDetail> wrapper = new LambdaQueryWrapper<AppOrderDetail>();
|
||||||
|
wrapper.eq(AppOrderDetail::getOrderId, order.getId());
|
||||||
|
List<AppOrderDetail> detailList = detailService.list(wrapper);
|
||||||
|
for (AppOrderDetail detail : detailList) {
|
||||||
|
detail.setGoods(goodsMainService.getById(detail.getGoodsId()));
|
||||||
|
}
|
||||||
|
order.setOrderDetailList(detailList);
|
||||||
|
}
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出订单列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:order:export')")
|
||||||
|
@Log(title = "订单", businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export")
|
||||||
|
public AjaxResult export(AppOrder appOrder) {
|
||||||
|
LambdaQueryWrapper<AppOrder> lqw = new LambdaQueryWrapper<AppOrder>(appOrder);
|
||||||
|
List<AppOrder> list = iAppOrderService.list(lqw);
|
||||||
|
ExcelUtil<AppOrder> util = new ExcelUtil<AppOrder>(AppOrder.class);
|
||||||
|
return util.exportExcel(list, "order");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:order:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||||
|
AppOrder order = iAppOrderService.getById(id);
|
||||||
|
LambdaQueryWrapper<AppOrderDetail> wrapper = new LambdaQueryWrapper<AppOrderDetail>();
|
||||||
|
wrapper.eq(AppOrderDetail::getOrderId, order.getId());
|
||||||
|
List<AppOrderDetail> detailList = detailService.list(wrapper);
|
||||||
|
order.setOrderDetailList(detailList);
|
||||||
|
for (AppOrderDetail detail : detailList) {
|
||||||
|
detail.setGoods(goodsMainService.getById(detail.getGoodsId()));
|
||||||
|
}
|
||||||
|
return success(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增订单
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:order:add')")
|
||||||
|
@Log(title = "订单", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@Transactional
|
||||||
|
public AjaxResult add(@RequestBody AppOrder appOrder, HttpServletRequest req) {
|
||||||
|
Long userId = getLoginUser().getUser().getUserId();
|
||||||
|
String username = getUsername();
|
||||||
|
Long deptId = getDeptId();
|
||||||
|
String id = System.currentTimeMillis() + RandomUtil.randomNumbers(6);
|
||||||
|
appOrder.setId(id);
|
||||||
|
appOrder.setDeptId(getDeptId());
|
||||||
|
appOrder.setUserId(userId);
|
||||||
|
|
||||||
|
// 计算总金额
|
||||||
|
List<AppOrderDetail> orderDetailList = appOrder.getOrderDetailList();
|
||||||
|
Integer totalFee = 0;
|
||||||
|
for (AppOrderDetail detail : orderDetailList) {
|
||||||
|
GoodsMain goods = goodsMainService.getById(detail.getGoodsId());
|
||||||
|
detail.setUserId(userId);
|
||||||
|
detail.setOrderId(id);
|
||||||
|
detail.setDeptId(deptId);
|
||||||
|
detail.setStatus(0);
|
||||||
|
detailService.save(detail);
|
||||||
|
totalFee += (goods.getGoodsPrice().multiply(new BigDecimal(100)).intValue() * detail.getGoodsCount());
|
||||||
|
}
|
||||||
|
appOrder.setTotalFee(totalFee);
|
||||||
|
|
||||||
|
// 统一下单
|
||||||
|
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
||||||
|
String openId = "";
|
||||||
|
if (username.contains("mini-")) {
|
||||||
|
openId = username.split("-")[1];
|
||||||
|
}
|
||||||
|
request.setOpenid(openId);
|
||||||
|
request.setTotalFee(totalFee);
|
||||||
|
request.setBody("订单编号" + id);
|
||||||
|
request.setOutTradeNo(id);
|
||||||
|
request.setSpbillCreateIp(req.getRemoteAddr());
|
||||||
|
request.setTradeType("JSAPI");
|
||||||
|
|
||||||
|
try {
|
||||||
|
WxPayMpOrderResult payMsg = wxPayService.createOrder(request);
|
||||||
|
appOrder.setPayMsg(((JSONObject) JSONObject.toJSON(payMsg)).toJSONString());
|
||||||
|
appOrder.setStatus(0);
|
||||||
|
iAppOrderService.save(appOrder);
|
||||||
|
|
||||||
|
return success("success", payMsg);
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:order:edit')")
|
||||||
|
@Log(title = "订单", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody AppOrder appOrder) {
|
||||||
|
return toAjax(iAppOrderService.updateById(appOrder) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除订单
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:order:remove')")
|
||||||
|
@Log(title = "订单", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable String[] ids) {
|
||||||
|
return toAjax(iAppOrderService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,188 @@
|
|||||||
|
package com.ruoyi.winery.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
||||||
|
import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
||||||
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||||
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.winery.domain.AppOrder;
|
||||||
|
import com.ruoyi.winery.domain.goods.GoodsMain;
|
||||||
|
import com.ruoyi.winery.service.IAppOrderService;
|
||||||
|
import com.ruoyi.winery.service.IGoodsMainService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.winery.domain.AppOrderDetail;
|
||||||
|
import com.ruoyi.winery.service.IAppOrderDetailService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
import static com.ruoyi.common.core.domain.AjaxResult.error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单明细Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/winery/detail" )
|
||||||
|
public class AppOrderDetailController extends BaseController {
|
||||||
|
|
||||||
|
private final IAppOrderDetailService iAppOrderDetailService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGoodsMainService goodsMainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxPayService wxPayService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAppOrderService orderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单明细列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(AppOrderDetail appOrderDetail)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
LambdaQueryWrapper<AppOrderDetail> lqw = Wrappers.lambdaQuery(appOrderDetail);
|
||||||
|
if (appOrderDetail.getDeptId() != null){
|
||||||
|
lqw.eq(AppOrderDetail::getDeptId ,appOrderDetail.getDeptId());
|
||||||
|
}
|
||||||
|
if (appOrderDetail.getUserId() != null){
|
||||||
|
lqw.eq(AppOrderDetail::getUserId ,appOrderDetail.getUserId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appOrderDetail.getOrderId())){
|
||||||
|
lqw.eq(AppOrderDetail::getOrderId ,appOrderDetail.getOrderId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appOrderDetail.getGoodsId())){
|
||||||
|
lqw.eq(AppOrderDetail::getGoodsId ,appOrderDetail.getGoodsId());
|
||||||
|
}
|
||||||
|
if (appOrderDetail.getGoodsCount() != null){
|
||||||
|
lqw.eq(AppOrderDetail::getGoodsCount ,appOrderDetail.getGoodsCount());
|
||||||
|
}
|
||||||
|
if (appOrderDetail.getStatus() != null){
|
||||||
|
lqw.eq(AppOrderDetail::getStatus ,appOrderDetail.getStatus());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(appOrderDetail.getRefundNo())){
|
||||||
|
lqw.eq(AppOrderDetail::getRefundNo ,appOrderDetail.getRefundNo());
|
||||||
|
}
|
||||||
|
if (appOrderDetail.getRefundTime() != null){
|
||||||
|
lqw.eq(AppOrderDetail::getRefundTime ,appOrderDetail.getRefundTime());
|
||||||
|
}
|
||||||
|
List<AppOrderDetail> list = iAppOrderDetailService.list(lqw);
|
||||||
|
for (AppOrderDetail detail : list) {
|
||||||
|
detail.setGoods(goodsMainService.getById(detail.getGoodsId()));
|
||||||
|
}
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出订单明细列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:export')" )
|
||||||
|
@Log(title = "订单明细" , businessType = BusinessType.EXPORT)
|
||||||
|
@GetMapping("/export" )
|
||||||
|
public AjaxResult export(AppOrderDetail appOrderDetail) {
|
||||||
|
LambdaQueryWrapper<AppOrderDetail> lqw = new LambdaQueryWrapper<AppOrderDetail>(appOrderDetail);
|
||||||
|
List<AppOrderDetail> list = iAppOrderDetailService.list(lqw);
|
||||||
|
ExcelUtil<AppOrderDetail> util = new ExcelUtil<AppOrderDetail>(AppOrderDetail. class);
|
||||||
|
return util.exportExcel(list, "detail" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单明细详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:query')" )
|
||||||
|
@GetMapping(value = "/{id}" )
|
||||||
|
public AjaxResult getInfo(@PathVariable("id" ) String id) {
|
||||||
|
AppOrderDetail detail = iAppOrderDetailService.getById(id);
|
||||||
|
detail.setGoods(goodsMainService.getById(detail.getGoodsId()));
|
||||||
|
return AjaxResult.success(detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增订单明细
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:add')" )
|
||||||
|
@Log(title = "订单明细" , businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody AppOrderDetail appOrderDetail) {
|
||||||
|
return toAjax(iAppOrderDetailService.save(appOrderDetail) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单明细
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:edit')" )
|
||||||
|
@Log(title = "订单明细" , businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody AppOrderDetail appOrderDetail) {
|
||||||
|
return toAjax(iAppOrderDetailService.updateById(appOrderDetail) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除订单明细
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:remove')" )
|
||||||
|
@Log(title = "订单明细" , businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}" )
|
||||||
|
public AjaxResult remove(@PathVariable String[] ids) {
|
||||||
|
return toAjax(iAppOrderDetailService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("@ss.hasPermi('winery:detail:remove')")
|
||||||
|
@Log(title = "退款", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/refund/{id}")
|
||||||
|
AjaxResult refund(@PathVariable String id) {
|
||||||
|
AppOrderDetail detail = iAppOrderDetailService.getById(id);
|
||||||
|
AppOrder order = orderService.getById(detail.getOrderId());
|
||||||
|
GoodsMain goods = goodsMainService.getById(detail.getGoodsId());
|
||||||
|
Integer fee = goods.getGoodsPrice().multiply(new BigDecimal(100)).intValue() * detail.getGoodsCount();
|
||||||
|
|
||||||
|
String refundNo = System.currentTimeMillis() + RandomUtil.randomNumbers(6);
|
||||||
|
WxPayRefundRequest request = new WxPayRefundRequest();
|
||||||
|
request.setRefundFee(fee);
|
||||||
|
request.setTotalFee(order.getTotalFee());
|
||||||
|
request.setOutTradeNo(detail.getOrderId());
|
||||||
|
request.setOutRefundNo(refundNo);
|
||||||
|
WxPayRefundResult refund = null;
|
||||||
|
try {
|
||||||
|
wxPayService.refund(request);
|
||||||
|
detail.setRefundTime(DateUtils.getNowDate());
|
||||||
|
detail.setRefundNo(refundNo);
|
||||||
|
detail.setStatus(3);
|
||||||
|
iAppOrderDetailService.updateById(detail);
|
||||||
|
return AjaxResult.success(detail);
|
||||||
|
} catch (WxPayException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.winery.controller.winery;
|
package com.ruoyi.winery.controller.winery;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
@ -114,45 +115,47 @@ public class WineryOrdersController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增客户订单
|
* 新增客户订单
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('winery:user_orders:add')")
|
// @PreAuthorize("@ss.hasPermi('winery:user_orders:add')")
|
||||||
@Log(title = "客户订单", businessType = BusinessType.INSERT)
|
// @Log(title = "客户订单", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
// @PostMapping
|
||||||
public AjaxResult add(@RequestBody WineryOrders wineryOrders, HttpServletRequest req) {
|
// public AjaxResult add(@RequestBody List<WineryOrders> wineryOrders, HttpServletRequest req) {
|
||||||
wineryOrders.setCreateBy(getUsername());
|
// String username = getUsername();
|
||||||
wineryOrders.setDeptId(getDeptId());
|
// Long deptId = getDeptId();
|
||||||
|
// String outTradeNo = RandomUtil.randomNumbers(15);
|
||||||
// 统一下单
|
// wineryOrders.setCreateBy(getUsername());
|
||||||
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
// wineryOrders.setDeptId(getDeptId());
|
||||||
String userName = getLoginUser().getUser().getUserName();
|
//
|
||||||
String openId = "";
|
// // 统一下单
|
||||||
if (userName.contains("mini-")) {
|
// WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
||||||
openId = userName.split("-")[1];
|
// String userName = getLoginUser().getUser().getUserName();
|
||||||
}
|
// String openId = "";
|
||||||
request.setOpenid(openId);
|
// if (userName.contains("mini-")) {
|
||||||
request.setTotalFee(wineryOrders.getGoodsPrice().multiply(new BigDecimal(100)).intValue());
|
// openId = userName.split("-")[1];
|
||||||
request.setBody(wineryOrders.getGoodsName());
|
// }
|
||||||
String outTradeNo = UUID.randomUUID().toString().replace("-", "");
|
// request.setOpenid(openId);
|
||||||
request.setOutTradeNo(outTradeNo);
|
// request.setTotalFee(wineryOrders.getGoodsPrice().multiply(new BigDecimal(100)).intValue());
|
||||||
request.setNotifyUrl("");
|
// request.setBody("小程序名-订单编号");
|
||||||
request.setSpbillCreateIp(req.getRemoteAddr());
|
// request.setOutTradeNo(outTradeNo);
|
||||||
request.setTradeType("JSAPI");
|
// request.setNotifyUrl("");
|
||||||
|
// request.setSpbillCreateIp(req.getRemoteAddr());
|
||||||
|
// request.setTradeType("JSAPI");
|
||||||
Map<String, Object> map = new HashMap<>();
|
//
|
||||||
try {
|
//
|
||||||
map.put("orderId", wineryOrders.getId());
|
// Map<String, Object> map = new HashMap<>();
|
||||||
WxPayMpOrderResult payMsg = wxPayService.createOrder(request);
|
// try {
|
||||||
map.put("payMsg", payMsg);
|
// map.put("orderId", wineryOrders.getId());
|
||||||
wineryOrders.setPayMsg(((JSONObject) JSONObject.toJSON(payMsg)).toJSONString());
|
// WxPayMpOrderResult payMsg = wxPayService.createOrder(request);
|
||||||
wineryOrders.setOutTradeNo(outTradeNo);
|
// map.put("payMsg", payMsg);
|
||||||
wineryOrders.setOrderStatus(0);
|
// wineryOrders.setPayMsg(((JSONObject) JSONObject.toJSON(payMsg)).toJSONString());
|
||||||
iWineryOrdersService.save(wineryOrders);
|
// wineryOrders.setOutTradeNo(outTradeNo);
|
||||||
return success("success", map);
|
// wineryOrders.setOrderStatus(0);
|
||||||
} catch (WxPayException e) {
|
// iWineryOrdersService.save(wineryOrders);
|
||||||
e.printStackTrace();
|
// return success("success", map);
|
||||||
return error();
|
// } catch (WxPayException e) {
|
||||||
}
|
// e.printStackTrace();
|
||||||
}
|
// return error();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改客户订单
|
* 修改客户订单
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.ruoyi.winery.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单对象 app_order
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("app_order")
|
||||||
|
public class AppOrder implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
|
||||||
|
/** 订单ID */
|
||||||
|
@TableId(value = "id", type = IdType.INPUT)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/** 部门ID */
|
||||||
|
@Excel(name = "部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
@Excel(name = "用户ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 收货地址ID */
|
||||||
|
@Excel(name = "收货地址ID")
|
||||||
|
private String addressId;
|
||||||
|
|
||||||
|
/** 支付参数 */
|
||||||
|
@Excel(name = "支付参数")
|
||||||
|
private String payMsg;
|
||||||
|
|
||||||
|
/** 总金额 */
|
||||||
|
@Excel(name = "总金额")
|
||||||
|
private Integer totalFee;
|
||||||
|
|
||||||
|
/** 运单号 */
|
||||||
|
@Excel(name = "运单号")
|
||||||
|
private String transportNo;
|
||||||
|
|
||||||
|
/** 订单状态(0待支付1已取消2已支付3待收货4交易完成) */
|
||||||
|
@Excel(name = "订单状态" , readConverterExp = "0=待支付,1=已取消,2=已支付,3=待收货,4=交易完成")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/** 支付时间 */
|
||||||
|
@Excel(name = "支付时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date payTime;
|
||||||
|
|
||||||
|
/** 备注 */
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/** 取消时间 */
|
||||||
|
@Excel(name = "取消时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date cancelTime;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/** 更新时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<AppOrderDetail> orderDetailList;
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.ruoyi.winery.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.ruoyi.winery.domain.goods.GoodsMain;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单明细对象 app_order_detail
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ToString
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("app_order_detail")
|
||||||
|
public class AppOrderDetail implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
|
||||||
|
/** 明细ID */
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/** 部门ID */
|
||||||
|
@Excel(name = "部门ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
@Excel(name = "用户ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 订单ID */
|
||||||
|
@Excel(name = "订单ID")
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
/** 商品ID */
|
||||||
|
@Excel(name = "商品ID")
|
||||||
|
private String goodsId;
|
||||||
|
|
||||||
|
/** 商品数量 */
|
||||||
|
@Excel(name = "商品数量")
|
||||||
|
private Integer goodsCount;
|
||||||
|
|
||||||
|
/** 明细状态:
|
||||||
|
* 0 未退款
|
||||||
|
1.退款申请
|
||||||
|
2.退款中
|
||||||
|
3.退款成功 */
|
||||||
|
@Excel(name = "明细状态")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/** 统一退单号 */
|
||||||
|
@Excel(name = "统一退单号")
|
||||||
|
private String refundNo;
|
||||||
|
|
||||||
|
/** 退款时间 */
|
||||||
|
@Excel(name = "退款时间" , width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date refundTime;
|
||||||
|
|
||||||
|
/** 创建时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/** 更新时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private GoodsMain goods;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.winery.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.winery.domain.AppOrderDetail;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单明细Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
public interface AppOrderDetailMapper extends BaseMapper<AppOrderDetail> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.winery.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.winery.domain.AppOrder;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
public interface AppOrderMapper extends BaseMapper<AppOrder> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.winery.service;
|
||||||
|
|
||||||
|
import com.ruoyi.winery.domain.AppOrderDetail;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单明细Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
public interface IAppOrderDetailService extends IService<AppOrderDetail> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.winery.service;
|
||||||
|
|
||||||
|
import com.ruoyi.winery.domain.AppOrder;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
public interface IAppOrderService extends IService<AppOrder> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.winery.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.winery.mapper.AppOrderDetailMapper;
|
||||||
|
import com.ruoyi.winery.domain.AppOrderDetail;
|
||||||
|
import com.ruoyi.winery.service.IAppOrderDetailService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单明细Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AppOrderDetailServiceImpl extends ServiceImpl<AppOrderDetailMapper, AppOrderDetail> implements IAppOrderDetailService {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.winery.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.winery.mapper.AppOrderMapper;
|
||||||
|
import com.ruoyi.winery.domain.AppOrder;
|
||||||
|
import com.ruoyi.winery.service.IAppOrderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2021-01-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AppOrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> implements IAppOrderService {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
<?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.ruoyi.winery.mapper.AppOrderDetailMapper">
|
||||||
|
|
||||||
|
<resultMap type="AppOrderDetail" id="AppOrderDetailResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="deptId" column="dept_id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="orderId" column="order_id" />
|
||||||
|
<result property="goodsId" column="goods_id" />
|
||||||
|
<result property="goodsCount" column="goods_count" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="refundNo" column="refund_no" />
|
||||||
|
<result property="refundTime" column="refund_time" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?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.ruoyi.winery.mapper.AppOrderMapper">
|
||||||
|
|
||||||
|
<resultMap type="AppOrder" id="AppOrderResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="deptId" column="dept_id" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="addressId" column="address_id" />
|
||||||
|
<result property="payMsg" column="pay_msg" />
|
||||||
|
<result property="totalFee" column="total_fee" />
|
||||||
|
<result property="transportNo" column="transport_no" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="payTime" column="pay_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="cancelTime" column="cancel_time" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<collection property="orderDetailList" column="order_id" javaType="java.util.List" resultMap="AppOrderDetailResult" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
13
pom.xml
13
pom.xml
@ -270,6 +270,19 @@
|
|||||||
<encoding>${project.build.sourceEncoding}</encoding>
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<configuration>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<!-- 过滤后缀不需要转码的文件后缀名.crt/.p8 -->
|
||||||
|
<nonFilteredFileExtensions>
|
||||||
|
<nonFilteredFileExtension>p12</nonFilteredFileExtension>
|
||||||
|
</nonFilteredFileExtensions>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
BIN
ruoyi-admin/src/main/resources/cert/apiclient_cert1486984962.p12
Normal file
BIN
ruoyi-admin/src/main/resources/cert/apiclient_cert1486984962.p12
Normal file
Binary file not shown.
53
ruoyi-ui/src/api/winery/detail.js
Normal file
53
ruoyi-ui/src/api/winery/detail.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询订单明细列表
|
||||||
|
export function listDetail(query) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/detail/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询订单明细详细
|
||||||
|
export function getDetail(id) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/detail/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增订单明细
|
||||||
|
export function addDetail(data) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/detail',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改订单明细
|
||||||
|
export function updateDetail(data) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/detail',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除订单明细
|
||||||
|
export function delDetail(id) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/detail/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出订单明细
|
||||||
|
export function exportDetail(query) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/detail/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
53
ruoyi-ui/src/api/winery/order.js
Normal file
53
ruoyi-ui/src/api/winery/order.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询订单列表
|
||||||
|
export function listOrder(query) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/order/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询订单详细
|
||||||
|
export function getOrder(id) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/order/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增订单
|
||||||
|
export function addOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/order',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改订单
|
||||||
|
export function updateOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/order',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除订单
|
||||||
|
export function delOrder(id) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/order/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出订单
|
||||||
|
export function exportOrder(query) {
|
||||||
|
return request({
|
||||||
|
url: '/winery/order/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
401
ruoyi-ui/src/views/winery/detail/index.vue
Normal file
401
ruoyi-ui/src/views/winery/detail/index.vue
Normal file
@ -0,0 +1,401 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="部门ID" prop="deptId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.deptId"
|
||||||
|
placeholder="请输入部门ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户ID" prop="userId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userId"
|
||||||
|
placeholder="请输入用户ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="订单ID" prop="orderId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.orderId"
|
||||||
|
placeholder="请输入订单ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品ID" prop="goodsId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.goodsId"
|
||||||
|
placeholder="请输入商品ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品数量" prop="goodsCount">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.goodsCount"
|
||||||
|
placeholder="请输入商品数量"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="明细状态:
|
||||||
|
5.退款申请
|
||||||
|
6.退款中
|
||||||
|
7.退款成功" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择明细状态:
|
||||||
|
5.退款申请
|
||||||
|
6.退款中
|
||||||
|
7.退款成功" clearable size="small">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="统一退单号" prop="refundNo">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.refundNo"
|
||||||
|
placeholder="请输入统一退单号"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="退款时间" prop="refundTime">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="queryParams.refundTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择退款时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['winery:detail:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['winery:detail:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['winery:detail:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['winery:detail:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="detailList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="明细ID" align="center" prop="id" v-if="false"/>
|
||||||
|
<el-table-column label="部门ID" align="center" prop="deptId" />
|
||||||
|
<el-table-column label="用户ID" align="center" prop="userId" />
|
||||||
|
<el-table-column label="订单ID" align="center" prop="orderId" />
|
||||||
|
<el-table-column label="商品ID" align="center" prop="goodsId" />
|
||||||
|
<el-table-column label="商品数量" align="center" prop="goodsCount" />
|
||||||
|
<el-table-column label="明细状态:
|
||||||
|
5.退款申请
|
||||||
|
6.退款中
|
||||||
|
7.退款成功" align="center" prop="status" />
|
||||||
|
<el-table-column label="统一退单号" align="center" prop="refundNo" />
|
||||||
|
<el-table-column label="退款时间" align="center" prop="refundTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.refundTime, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['winery:detail:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['winery:detail:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改订单明细对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="部门ID" prop="deptId">
|
||||||
|
<el-input v-model="form.deptId" placeholder="请输入部门ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户ID" prop="userId">
|
||||||
|
<el-input v-model="form.userId" placeholder="请输入用户ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="订单ID" prop="orderId">
|
||||||
|
<el-input v-model="form.orderId" placeholder="请输入订单ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品ID" prop="goodsId">
|
||||||
|
<el-input v-model="form.goodsId" placeholder="请输入商品ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品数量" prop="goodsCount">
|
||||||
|
<el-input v-model="form.goodsCount" placeholder="请输入商品数量" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="明细状态:
|
||||||
|
5.退款申请
|
||||||
|
6.退款中
|
||||||
|
7.退款成功">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="统一退单号" prop="refundNo">
|
||||||
|
<el-input v-model="form.refundNo" placeholder="请输入统一退单号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="退款时间" prop="refundTime">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="form.refundTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择退款时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listDetail, getDetail, delDetail, addDetail, updateDetail, exportDetail } from "@/api/winery/detail";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Detail",
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 订单明细表格数据
|
||||||
|
detailList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
deptId: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
orderId: undefined,
|
||||||
|
goodsId: undefined,
|
||||||
|
goodsCount: undefined,
|
||||||
|
status: undefined,
|
||||||
|
refundNo: undefined,
|
||||||
|
refundTime: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
userId: [
|
||||||
|
{ required: true, message: "用户ID不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
orderId: [
|
||||||
|
{ required: true, message: "订单ID不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
goodsId: [
|
||||||
|
{ required: true, message: "商品ID不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
status: [
|
||||||
|
{ required: true, message: "明细状态:
|
||||||
|
5.退款申请
|
||||||
|
6.退款中
|
||||||
|
7.退款成功不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
createTime: [
|
||||||
|
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
updateTime: [
|
||||||
|
{ required: true, message: "更新时间不能为空", trigger: "blur" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询订单明细列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listDetail(this.queryParams).then(response => {
|
||||||
|
this.detailList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
orderId: undefined,
|
||||||
|
goodsId: undefined,
|
||||||
|
goodsCount: undefined,
|
||||||
|
status: 0,
|
||||||
|
refundNo: undefined,
|
||||||
|
refundTime: undefined,
|
||||||
|
createTime: undefined,
|
||||||
|
updateTime: undefined
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加订单明细";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids
|
||||||
|
getDetail(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改订单明细";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateDetail(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addDetail(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$confirm('是否确认删除订单明细编号为"' + ids + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return delDetail(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有订单明细数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportDetail(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
408
ruoyi-ui/src/views/winery/order/index.vue
Normal file
408
ruoyi-ui/src/views/winery/order/index.vue
Normal file
@ -0,0 +1,408 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="部门ID" prop="deptId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.deptId"
|
||||||
|
placeholder="请输入部门ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户ID" prop="userId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userId"
|
||||||
|
placeholder="请输入用户ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="收货地址ID" prop="addressId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.addressId"
|
||||||
|
placeholder="请输入收货地址ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="支付参数" prop="payMsg">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.payMsg"
|
||||||
|
placeholder="请输入支付参数"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="总金额" prop="totalFee">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.totalFee"
|
||||||
|
placeholder="请输入总金额"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="运单号" prop="transportNo">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.transportNo"
|
||||||
|
placeholder="请输入运单号"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="订单状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择订单状态" clearable size="small">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="支付时间" prop="payTime">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="queryParams.payTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择支付时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="取消时间" prop="cancelTime">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="queryParams.cancelTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择取消时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['winery:order:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['winery:order:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['winery:order:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['winery:order:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="订单ID" align="center" prop="id" v-if="false"/>
|
||||||
|
<el-table-column label="部门ID" align="center" prop="deptId" />
|
||||||
|
<el-table-column label="用户ID" align="center" prop="userId" />
|
||||||
|
<el-table-column label="收货地址ID" align="center" prop="addressId" />
|
||||||
|
<el-table-column label="支付参数" align="center" prop="payMsg" />
|
||||||
|
<el-table-column label="总金额" align="center" prop="totalFee" />
|
||||||
|
<el-table-column label="运单号" align="center" prop="transportNo" />
|
||||||
|
<el-table-column label="订单状态" align="center" prop="status" />
|
||||||
|
<el-table-column label="支付时间" align="center" prop="payTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="取消时间" align="center" prop="cancelTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.cancelTime, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['winery:order:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['winery:order:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改订单对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="部门ID" prop="deptId">
|
||||||
|
<el-input v-model="form.deptId" placeholder="请输入部门ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户ID" prop="userId">
|
||||||
|
<el-input v-model="form.userId" placeholder="请输入用户ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="收货地址ID" prop="addressId">
|
||||||
|
<el-input v-model="form.addressId" placeholder="请输入收货地址ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="支付参数" prop="payMsg">
|
||||||
|
<el-input v-model="form.payMsg" placeholder="请输入支付参数" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="总金额" prop="totalFee">
|
||||||
|
<el-input v-model="form.totalFee" placeholder="请输入总金额" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="运单号" prop="transportNo">
|
||||||
|
<el-input v-model="form.transportNo" placeholder="请输入运单号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="订单状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="支付时间" prop="payTime">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="form.payTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择支付时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="取消时间" prop="cancelTime">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="form.cancelTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择取消时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder } from "@/api/winery/order";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Order",
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 订单表格数据
|
||||||
|
orderList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
deptId: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
addressId: undefined,
|
||||||
|
payMsg: undefined,
|
||||||
|
totalFee: undefined,
|
||||||
|
transportNo: undefined,
|
||||||
|
status: undefined,
|
||||||
|
payTime: undefined,
|
||||||
|
cancelTime: undefined,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
userId: [
|
||||||
|
{ required: true, message: "用户ID不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
status: [
|
||||||
|
{ required: true, message: "订单状态不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
createTime: [
|
||||||
|
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
updateTime: [
|
||||||
|
{ required: true, message: "更新时间不能为空", trigger: "blur" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询订单列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listOrder(this.queryParams).then(response => {
|
||||||
|
this.orderList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
userId: undefined,
|
||||||
|
addressId: undefined,
|
||||||
|
payMsg: undefined,
|
||||||
|
totalFee: undefined,
|
||||||
|
transportNo: undefined,
|
||||||
|
status: 0,
|
||||||
|
payTime: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
cancelTime: undefined,
|
||||||
|
createTime: undefined,
|
||||||
|
updateTime: undefined
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加订单";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids
|
||||||
|
getOrder(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改订单";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateOrder(this.form).then(response => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addOrder(this.form).then(response => {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$confirm('是否确认删除订单编号为"' + ids + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return delOrder(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有订单数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return exportOrder(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user