| | |
| | | package com.ruoyi.order.controller; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.dto.ExchangeDto; |
| | | import com.ruoyi.common.core.utils.OrderCodeUtil; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.order.api.model.TShoppingOrder; |
| | | import com.ruoyi.order.dto.*; |
| | | import com.ruoyi.order.service.TShoppingOrderService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2024-08-07 |
| | | */ |
| | | @Api(tags = "购物订单") |
| | | @RestController |
| | | @RequestMapping("/t-shopping-order") |
| | | public class TShoppingOrderController { |
| | | |
| | | @Resource |
| | | private TShoppingOrderService shoppingOrderService; |
| | | |
| | | |
| | | @GetMapping("/getMyShoppingOrderList") |
| | | @ApiOperation(value = "获取购买订单列表", tags = {"小程序-商城购买订单"}) |
| | | public AjaxResult<List<MyShoppingOrderList>> getMyShoppingOrderList(GetMyShoppingOrderList query){ |
| | | List<MyShoppingOrderList> list = shoppingOrderService.getMyShoppingOrderList(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/getMyShoppingOrderInfo/{id}") |
| | | @ApiOperation(value = "获取购买订单详情", tags = {"小程序-商城购买订单"}) |
| | | public AjaxResult<MyShoppingOrderInfo> getMyShoppingOrderInfo(@PathVariable String id){ |
| | | MyShoppingOrderInfo info = shoppingOrderService.getMyShoppingOrderInfo(id); |
| | | return AjaxResult.success(info); |
| | | } |
| | | |
| | | |
| | | |
| | | @PutMapping("/confirmReceipt/{id}") |
| | | @ApiOperation(value = "确认收货操作", tags = {"小程序-商城购买订单"}) |
| | | public AjaxResult confirmReceipt(@PathVariable String id){ |
| | | TShoppingOrder shoppingOrder = shoppingOrderService.getById(id); |
| | | if(shoppingOrder.getStatus() == 3){ |
| | | return AjaxResult.error("不能重复确认收货"); |
| | | } |
| | | if(shoppingOrder.getStatus() == 1){ |
| | | return AjaxResult.error("订单还未发货呢"); |
| | | } |
| | | if(shoppingOrder.getStatus() == 4){ |
| | | return AjaxResult.error("订单已取消,不允许操作。"); |
| | | } |
| | | shoppingOrder.setStatus(3); |
| | | shoppingOrderService.updateById(shoppingOrder); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @PutMapping("/cancelOrder/{id}") |
| | | @ApiOperation(value = "取消订单操作", tags = {"小程序-商城购买订单"}) |
| | | public AjaxResult cancelOrder(@PathVariable String id){ |
| | | return shoppingOrderService.cancelOrder(id); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/getNoInvoicedOrder") |
| | | @ApiOperation(value = "获取未开票的订单数据", tags = {"小程序-充电发票"}) |
| | | public AjaxResult<List<MyShoppingOrderList>> getNoInvoicedOrder(GetNoInvoicedOrder query){ |
| | | List<MyShoppingOrderList> list = shoppingOrderService.getNoInvoicedOrder(query); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/create") |
| | | public R<TShoppingOrder> shopCreate(@RequestBody ExchangeDto exchangeDto){ |
| | | TShoppingOrder shoppingOrder = new TShoppingOrder(); |
| | | shoppingOrder.setCode(OrderCodeUtil.getOrderCode("GW")); |
| | | shoppingOrder.setAppUserId(exchangeDto.getUserId()); |
| | | shoppingOrder.setOrderType(exchangeDto.getGoodType()); |
| | | if (exchangeDto.getGoodType()==1) { |
| | | shoppingOrder.setGoodsId(exchangeDto.getGoodId()); |
| | | }else { |
| | | shoppingOrder.setCouponId(exchangeDto.getGoodId()); |
| | | } |
| | | shoppingOrder.setPurchaseQuantity(exchangeDto.getNum()); |
| | | shoppingOrder.setAppUserAddressId(Long.valueOf(exchangeDto.getAddressId())); |
| | | shoppingOrder.setOrderAmount(exchangeDto.getOrderPrice()); |
| | | if (exchangeDto.getCouponId()!=null) { |
| | | shoppingOrder.setAppCouponId(exchangeDto.getCouponId()); |
| | | } |
| | | shoppingOrder.setCouponDiscountAmount(exchangeDto.getDiscountPrice()); |
| | | shoppingOrder.setVipDiscount(new BigDecimal("0")); |
| | | shoppingOrder.setVipDiscountAmount(exchangeDto.getVipDiscount()); |
| | | shoppingOrder.setPaymentAmount(exchangeDto.getPayPrice()); |
| | | shoppingOrder.setPaymentStatus(1); |
| | | shoppingOrder.setPaymentType(exchangeDto.getPayMethod()); |
| | | shoppingOrder.setRemark(exchangeDto.getRemark()); |
| | | shoppingOrder.setStatus(1); |
| | | shoppingOrder.setCreateTime(LocalDateTime.now()); |
| | | shoppingOrder.setDelFlag(false); |
| | | shoppingOrderService.save(shoppingOrder); |
| | | |
| | | return R.ok(shoppingOrder); |
| | | |
| | | } |
| | | |
| | | @PostMapping("/callBack") |
| | | public R callBack(@RequestParam("code")String code,@RequestParam("outTradeNo")String outTradeNo){ |
| | | shoppingOrderService.callBack(code,outTradeNo); |
| | | return R.ok(); |
| | | |
| | | } |
| | | } |
| | | |