订单相关等修改
This commit is contained in:
1 parent
fbd1af0c5e
commit
bde31ea21b
7 files changed
+53
-9
No files matched your search
@@ -26,7 +26,7 @@ public interface StoreCouponMapper extends BaseMapper<StoreCoupon> {
|
|||||||
@Update("update store_coupon set use_num=use_num+1 where id=#{id}")
|
@Update("update store_coupon set use_num=use_num+1 where id=#{id}")
|
||||||
void incUserNum(int id);
|
void incUserNum(int id);
|
||||||
|
|
||||||
@Select("<script>select s.id,c.money,c.name,c.condition from store_coupon_list s left join store_coupon c " +
|
@Select("<script>select s.id,c.money,c.name,c.condition,c.use_end_time as useEndTime from store_coupon_list s left join store_coupon c " +
|
||||||
"on s.cid=c.id where s.uid=#{userId} and s.status=0" +
|
"on s.cid=c.id where s.uid=#{userId} and s.status=0" +
|
||||||
" <if test='orderTotalPrice > 0'>and c.condition <![CDATA[<= ]]> #{orderTotalPrice}</if>" +
|
" <if test='orderTotalPrice > 0'>and c.condition <![CDATA[<= ]]> #{orderTotalPrice}</if>" +
|
||||||
" and c.use_start_time <![CDATA[<= ]]> now() and c.use_end_time <![CDATA[>= ]]> now()</script>")
|
" and c.use_start_time <![CDATA[<= ]]> now() and c.use_end_time <![CDATA[>= ]]> now()</script>")
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CartAttrDTO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -127,6 +129,9 @@ public class StoreOrderGoods extends Model<StoreOrderGoods> {
|
|||||||
*/
|
*/
|
||||||
private String sku;
|
private String sku;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<CartAttrDTO> specList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ public class UserController {
|
|||||||
@ApiOperation(value = "订单列表",notes = "订单列表")
|
@ApiOperation(value = "订单列表",notes = "订单列表")
|
||||||
public R orderList(@RequestParam(value = "status",defaultValue = "0") int status,
|
public R orderList(@RequestParam(value = "status",defaultValue = "0") int status,
|
||||||
@RequestParam(value = "page",defaultValue = "1") int page,
|
@RequestParam(value = "page",defaultValue = "1") int page,
|
||||||
@RequestParam(value = "limit",defaultValue = "10") int limit){
|
@RequestParam(value = "page_num",defaultValue = "10") int limit){
|
||||||
|
|
||||||
int userId = userOperator.getUser().getId();
|
int userId = userOperator.getUser().getId();
|
||||||
return R.success(orderService.orderList(status,userId,page,limit));
|
return R.success(orderService.orderList(status,userId,page,limit));
|
||||||
@@ -137,9 +137,10 @@ public class UserController {
|
|||||||
|
|
||||||
@PostMapping(value = "/shop/user-order-handle")
|
@PostMapping(value = "/shop/user-order-handle")
|
||||||
@ApiOperation(value = "订单操作",notes = "订单操作")
|
@ApiOperation(value = "订单操作",notes = "订单操作")
|
||||||
public R handleOrder(@RequestParam(value = "order_id",defaultValue = "0") int orderId,
|
public R handleOrder(@Validated @RequestBody String jsonStr){
|
||||||
@RequestParam(value = "type",defaultValue = "1") int type){
|
|
||||||
int userId = userOperator.getUser().getId();
|
int userId = userOperator.getUser().getId();
|
||||||
|
int orderId = Integer.valueOf(JSON.parseObject(jsonStr).get("order_id").toString());
|
||||||
|
int type = Integer.valueOf(JSON.parseObject(jsonStr).get("type").toString());
|
||||||
orderService.orderHandle(orderId,type,userId);
|
orderService.orderHandle(orderId,type,userId);
|
||||||
return R.success("操作成功");
|
return R.success("操作成功");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class MallController {
|
|||||||
@GetMapping("/shop/mall-goods-list")
|
@GetMapping("/shop/mall-goods-list")
|
||||||
@ApiOperation(value = "获取商品列表",notes = "获取商品列表")
|
@ApiOperation(value = "获取商品列表",notes = "获取商品列表")
|
||||||
public R goodsList(@RequestParam(value = "page",defaultValue = "0") int page,
|
public R goodsList(@RequestParam(value = "page",defaultValue = "0") int page,
|
||||||
@RequestParam(value = "limit",defaultValue = "10") int limit,
|
@RequestParam(value = "page_num",defaultValue = "10") int limit,
|
||||||
@RequestParam(value = "cat_id",defaultValue = "0") int catId,
|
@RequestParam(value = "cat_id",defaultValue = "0") int catId,
|
||||||
@RequestParam(value = "keywords",defaultValue = "") String keywords){
|
@RequestParam(value = "keywords",defaultValue = "") String keywords){
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.app.modular.shop.service.dto;
|
package com.ruoyi.app.modular.shop.service.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -17,5 +19,6 @@ public class CouponDTO implements Serializable {
|
|||||||
private String name;
|
private String name;
|
||||||
private Double money;
|
private Double money;
|
||||||
private Double condition;
|
private Double condition;
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
|
||||||
private Date useEndTime;
|
private Date useEndTime;
|
||||||
}
|
}
|
||||||
+21
-4
@@ -21,6 +21,7 @@ import com.ruoyi.app.modular.shop.service.dto.CouponDTO;
|
|||||||
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
|
import com.ruoyi.app.modular.shop.service.dto.GoodsDTO;
|
||||||
import com.ruoyi.app.modular.shop.service.dto.OrderDTO;
|
import com.ruoyi.app.modular.shop.service.dto.OrderDTO;
|
||||||
import com.ruoyi.app.modular.shop.service.mapper.GoodsMapper;
|
import com.ruoyi.app.modular.shop.service.mapper.GoodsMapper;
|
||||||
|
import com.ruoyi.app.modular.shop.service.mapper.OrderGoodsMapper;
|
||||||
import com.ruoyi.app.modular.shop.service.mapper.OrderMapper;
|
import com.ruoyi.app.modular.shop.service.mapper.OrderMapper;
|
||||||
import com.ruoyi.app.modular.shop.service.vo.CartAttrVO;
|
import com.ruoyi.app.modular.shop.service.vo.CartAttrVO;
|
||||||
import com.ruoyi.app.modular.shop.service.vo.CartVO;
|
import com.ruoyi.app.modular.shop.service.vo.CartVO;
|
||||||
@@ -49,6 +50,8 @@ public class OrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOrder>
|
|||||||
private final StoreOrderGoodsMapper storeOrderGoodsMapper;
|
private final StoreOrderGoodsMapper storeOrderGoodsMapper;
|
||||||
private final OrderMapper orderMapper;
|
private final OrderMapper orderMapper;
|
||||||
private final StorePointsMoneyLogMapper storePointsMoneyLogMapper;
|
private final StorePointsMoneyLogMapper storePointsMoneyLogMapper;
|
||||||
|
private final OrderGoodsMapper orderGoodsMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 购物车提交
|
* 购物车提交
|
||||||
@@ -305,10 +308,17 @@ public class OrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOrder>
|
|||||||
List<OrderDTO> orderDTOList = new ArrayList<>();
|
List<OrderDTO> orderDTOList = new ArrayList<>();
|
||||||
for (StoreOrder storeOrder : list) {
|
for (StoreOrder storeOrder : list) {
|
||||||
QueryWrapper<StoreOrderGoods> wrapperGoods = new QueryWrapper<>();
|
QueryWrapper<StoreOrderGoods> wrapperGoods = new QueryWrapper<>();
|
||||||
wrapperGoods.eq("order_id",storeOrder.getOrderId());
|
wrapperGoods.eq("order_id",storeOrder.getOrderId()).groupBy("goods_id");
|
||||||
List<StoreOrderGoods> storeGoods = storeOrderGoodsMapper.selectList(wrapperGoods);
|
List<StoreOrderGoods> storeGoods = storeOrderGoodsMapper.selectList(wrapperGoods);
|
||||||
|
List<StoreOrderGoods> newStoreGoods = new ArrayList<>();
|
||||||
|
for (StoreOrderGoods storeGood : storeGoods) {
|
||||||
|
QueryWrapper<StoreOrderGoods> wrapper2 = new QueryWrapper<>();
|
||||||
|
wrapper2.eq("order_id",storeOrder.getOrderId()).eq("goods_id",storeGood.getGoodsId());
|
||||||
|
storeGood.setSpecList(orderGoodsMapper.toDto(storeOrderGoodsMapper.selectList(wrapper2)));
|
||||||
|
newStoreGoods.add(storeGood);
|
||||||
|
}
|
||||||
OrderDTO orderDTO = orderMapper.toDto(storeOrder);
|
OrderDTO orderDTO = orderMapper.toDto(storeOrder);
|
||||||
orderDTO.setGoodsList(storeGoods);
|
orderDTO.setGoodsList(newStoreGoods);
|
||||||
//处理订单状态
|
//处理订单状态
|
||||||
orderDTO.setStatus(OrderUtil.orderStatus(storeOrder.getPayStatus(),
|
orderDTO.setStatus(OrderUtil.orderStatus(storeOrder.getPayStatus(),
|
||||||
storeOrder.getShippingStatus(),storeOrder.getOrderStatus()));
|
storeOrder.getShippingStatus(),storeOrder.getOrderStatus()));
|
||||||
@@ -335,11 +345,18 @@ public class OrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOrder>
|
|||||||
StoreOrder storeOrder = baseMapper.selectOne(wrapper);
|
StoreOrder storeOrder = baseMapper.selectOne(wrapper);
|
||||||
|
|
||||||
QueryWrapper<StoreOrderGoods> wrapperGoods = new QueryWrapper<>();
|
QueryWrapper<StoreOrderGoods> wrapperGoods = new QueryWrapper<>();
|
||||||
wrapperGoods.eq("order_id",storeOrder.getOrderId());
|
wrapperGoods.eq("order_id",storeOrder.getOrderId()).groupBy("goods_id");
|
||||||
List<StoreOrderGoods> orderGoodsList = storeOrderGoodsMapper
|
List<StoreOrderGoods> orderGoodsList = storeOrderGoodsMapper
|
||||||
.selectList(wrapperGoods);
|
.selectList(wrapperGoods);
|
||||||
OrderDTO orderDTO = orderMapper.toDto(storeOrder);
|
OrderDTO orderDTO = orderMapper.toDto(storeOrder);
|
||||||
orderDTO.setGoodsList(orderGoodsList);
|
List<StoreOrderGoods> newStoreGoods = new ArrayList<>();
|
||||||
|
for (StoreOrderGoods storeGood : orderGoodsList) {
|
||||||
|
QueryWrapper<StoreOrderGoods> wrapper2 = new QueryWrapper<>();
|
||||||
|
wrapper2.eq("order_id",storeOrder.getOrderId()).eq("goods_id",storeGood.getGoodsId());
|
||||||
|
storeGood.setSpecList(orderGoodsMapper.toDto(storeOrderGoodsMapper.selectList(wrapper2)));
|
||||||
|
newStoreGoods.add(storeGood);
|
||||||
|
}
|
||||||
|
orderDTO.setGoodsList(newStoreGoods);
|
||||||
//处理订单状态
|
//处理订单状态
|
||||||
orderDTO.setStatus(OrderUtil.orderStatus(storeOrder.getPayStatus(),
|
orderDTO.setStatus(OrderUtil.orderStatus(storeOrder.getPayStatus(),
|
||||||
storeOrder.getShippingStatus(),storeOrder.getOrderStatus()));
|
storeOrder.getShippingStatus(),storeOrder.getOrderStatus()));
|
||||||
|
|||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.app.modular.shop.service.mapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.app.common.persistence.model.StoreOrderGoods;
|
||||||
|
import com.ruoyi.app.modular.mapper.EntityMapper;
|
||||||
|
import com.ruoyi.app.modular.shop.service.dto.CartAttrDTO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2019-09-10
|
||||||
|
*/
|
||||||
|
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
public interface OrderGoodsMapper extends EntityMapper<CartAttrDTO, StoreOrderGoods> {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user