parent
fa02cabad8
commit
a825db6dee
|
@ -10,4 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
public interface OrderFeignClient {
|
||||
@GetMapping("/auth/getOrderInfoByOrderNo/{orderNo}")
|
||||
Result<OrderInfo> getOrderInfoByOrderNo(@PathVariable String orderNo);
|
||||
|
||||
@GetMapping("auth/updateOrderStatusPayed/{orderNo}/{orderStatus}")
|
||||
Result<String> updateOrderStatus(@PathVariable(value = "orderNo") String orderNo, @PathVariable(value = "orderStatus") Integer orderStatus);
|
||||
}
|
|
@ -1,13 +1,21 @@
|
|||
package com.atguigu.feign.product;
|
||||
|
||||
import com.atguigu.spzx.model.dto.product.SkuSaleDto;
|
||||
import com.atguigu.spzx.model.entity.product.ProductSku;
|
||||
import com.atguigu.spzx.model.vo.result.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(value = "service-product", path = "/api/product/")
|
||||
public interface ProductFeignClient {
|
||||
@GetMapping("getBySkuId/{skuId}")
|
||||
Result<ProductSku> getBySkuId(@PathVariable Long skuId);
|
||||
|
||||
@PostMapping("updateSkuSaleNum")
|
||||
Boolean updateSkuSaleNum(@RequestBody List<SkuSaleDto> skuSaleDtoList);
|
||||
}
|
||||
|
|
|
@ -67,4 +67,11 @@ public class OrderInfoController {
|
|||
OrderInfo orderInfo = orderInfoService.getByOrderNo(orderNo);
|
||||
return Result.build(orderInfo, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取订单分页列表")
|
||||
@GetMapping("auth/updateOrderStatusPayed/{orderNo}/{orderStatus}")
|
||||
public Result<String> updateOrderStatus(@PathVariable(value = "orderNo") String orderNo, @PathVariable(value = "orderStatus") Integer orderStatus) {
|
||||
orderInfoService.updateOrderStatus(orderNo, orderStatus);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -31,4 +31,19 @@ public interface OrderInfoMapper {
|
|||
* @return 订单信息
|
||||
*/
|
||||
OrderInfo getOrderInfoByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 更新订单状态
|
||||
*
|
||||
* @param orderInfo orderInfo
|
||||
*/
|
||||
void updateById(OrderInfo orderInfo);
|
||||
|
||||
/**
|
||||
* 根据订单ID获取
|
||||
*
|
||||
* @param orderNo 定点杆编号
|
||||
* @return OrderInfo
|
||||
*/
|
||||
OrderInfo getByOrderNo(String orderNo);
|
||||
}
|
||||
|
|
|
@ -54,4 +54,12 @@ public interface OrderInfoService {
|
|||
* @return OrderInfo
|
||||
*/
|
||||
OrderInfo getByOrderNo(String orderNo);
|
||||
|
||||
/**
|
||||
* 获取订单分页列表
|
||||
*
|
||||
* @param orderNo orderNo
|
||||
* @param orderStatus orderStatus
|
||||
*/
|
||||
void updateOrderStatus(String orderNo, Integer orderStatus);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -223,4 +224,27 @@ public class OrderInfoServiceImpl implements OrderInfoService {
|
|||
orderInfo.setOrderItemList(orderItemList);
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单分页列表
|
||||
*
|
||||
* @param orderNo orderNo
|
||||
* @param orderStatus orderStatus
|
||||
*/
|
||||
@Override
|
||||
public void updateOrderStatus(String orderNo, Integer orderStatus) {
|
||||
// 更新订单状态
|
||||
OrderInfo orderInfo = orderInfoMapper.getByOrderNo(orderNo);
|
||||
orderInfo.setOrderStatus(1);
|
||||
orderInfo.setPayType(orderStatus);
|
||||
orderInfo.setPaymentTime(new Date());
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
// 记录日志
|
||||
OrderLog orderLog = new OrderLog();
|
||||
orderLog.setOrderId(orderInfo.getId());
|
||||
orderLog.setProcessStatus(1);
|
||||
orderLog.setNote("支付宝支付成功");
|
||||
orderLogMapper.save(orderLog);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,83 @@
|
|||
#{cancelReason})
|
||||
</insert>
|
||||
|
||||
<!-- 更新订单状态 -->
|
||||
<update id="updateById">
|
||||
update order_info set
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="nickName != null and nickName != ''">
|
||||
nick_name = #{nickName},
|
||||
</if>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
order_no = #{orderNo},
|
||||
</if>
|
||||
<if test="couponId != null and couponId != ''">
|
||||
coupon_id = #{couponId},
|
||||
</if>
|
||||
<if test="totalAmount != null and totalAmount != ''">
|
||||
total_amount = #{totalAmount},
|
||||
</if>
|
||||
<if test="couponAmount != null and couponAmount != ''">
|
||||
coupon_amount = #{couponAmount},
|
||||
</if>
|
||||
<if test="originalTotalAmount != null and originalTotalAmount != ''">
|
||||
original_total_amount = #{originalTotalAmount},
|
||||
</if>
|
||||
<if test="feightFee != null and feightFee != ''">
|
||||
feight_fee = #{feightFee},
|
||||
</if>
|
||||
<if test="payType != null">
|
||||
pay_type = #{payType},
|
||||
</if>
|
||||
<if test="orderStatus != null">
|
||||
order_status = #{orderStatus},
|
||||
</if>
|
||||
<if test="receiverName != null and receiverName != ''">
|
||||
receiver_name = #{receiverName},
|
||||
</if>
|
||||
<if test="receiverPhone != null and receiverPhone != ''">
|
||||
receiver_phone = #{receiverPhone},
|
||||
</if>
|
||||
<if test="receiverTagName != null and receiverTagName != ''">
|
||||
receiver_tag_name = #{receiverTagName},
|
||||
</if>
|
||||
<if test="receiverProvince != null and receiverProvince != ''">
|
||||
receiver_province = #{receiverProvince},
|
||||
</if>
|
||||
<if test="receiverCity != null and receiverCity != ''">
|
||||
receiver_city = #{receiverCity},
|
||||
</if>
|
||||
<if test="receiverDistrict != null and receiverDistrict != ''">
|
||||
receiver_district = #{receiverDistrict},
|
||||
</if>
|
||||
<if test="receiverAddress != null and receiverAddress != ''">
|
||||
receiver_address = #{receiverAddress},
|
||||
</if>
|
||||
<if test="paymentTime != null">
|
||||
payment_time = #{paymentTime},
|
||||
</if>
|
||||
<if test="deliveryTime != null">
|
||||
delivery_time = #{deliveryTime},
|
||||
</if>
|
||||
<if test="receiveTime != null">
|
||||
receive_time = #{receiveTime},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark = #{remark},
|
||||
</if>
|
||||
<if test="cancelTime != null and cancelTime != ''">
|
||||
cancel_time = #{cancelTime},
|
||||
</if>
|
||||
<if test="cancelReason != null and cancelReason != ''">
|
||||
cancel_reason = #{cancelReason},
|
||||
</if>
|
||||
update_time = now()
|
||||
where
|
||||
id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 获取订单信息 -->
|
||||
<select id="getById" resultType="com.atguigu.spzx.model.entity.order.OrderInfo">
|
||||
select
|
||||
|
@ -89,4 +166,12 @@
|
|||
from order_info
|
||||
where order_no = #{orderNo};
|
||||
</select>
|
||||
|
||||
<!-- 根据订单ID获取 -->
|
||||
<select id="getByOrderNo" resultType="com.atguigu.spzx.model.entity.order.OrderInfo">
|
||||
select
|
||||
<include refid="columns"/>
|
||||
from order_info
|
||||
where order_no = #{orderNo};
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -54,7 +54,7 @@ public class PaymentInfoServiceImpl implements PaymentInfoService {
|
|||
/**
|
||||
* 支付完成后更新状态
|
||||
*
|
||||
* @param paramMap paramMap
|
||||
* @param map paramMap
|
||||
* @param i i
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.atguigu.product.controller;
|
|||
|
||||
import com.atguigu.product.service.ProductService;
|
||||
import com.atguigu.spzx.model.dto.h5.ProductSkuDto;
|
||||
import com.atguigu.spzx.model.dto.product.SkuSaleDto;
|
||||
import com.atguigu.spzx.model.entity.product.ProductSku;
|
||||
import com.atguigu.spzx.model.vo.h5.ProductItemVo;
|
||||
import com.atguigu.spzx.model.vo.result.Result;
|
||||
|
@ -10,10 +11,9 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "商品列表管理")
|
||||
@RestController
|
||||
|
@ -44,4 +44,10 @@ public class ProductController {
|
|||
ProductSku productSku = productService.getBySkuId(skuId);
|
||||
return Result.success(productSku);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新商品sku销量")
|
||||
@PostMapping("updateSkuSaleNum")
|
||||
public Boolean updateSkuSaleNum(@RequestBody List<SkuSaleDto> skuSaleDtoList) {
|
||||
return productService.updateSkuSaleNum(skuSaleDtoList);
|
||||
}
|
||||
}
|
|
@ -38,4 +38,12 @@ public interface ProductSkuMapper {
|
|||
* @return List<ProductSku>
|
||||
*/
|
||||
List<ProductSku> findByProductId(Long productId);
|
||||
|
||||
/**
|
||||
* 更新商品sku销量
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param num num
|
||||
*/
|
||||
void updateSale(Long skuId, Integer num);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.atguigu.product.service;
|
||||
|
||||
import com.atguigu.spzx.model.dto.h5.ProductSkuDto;
|
||||
import com.atguigu.spzx.model.dto.product.SkuSaleDto;
|
||||
import com.atguigu.spzx.model.entity.product.ProductSku;
|
||||
import com.atguigu.spzx.model.vo.h5.ProductItemVo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
@ -40,4 +41,12 @@ public interface ProductService {
|
|||
* @return 获取ProductSku
|
||||
*/
|
||||
ProductSku getBySkuId(Long skuId);
|
||||
|
||||
/**
|
||||
* 更新商品sku销量
|
||||
*
|
||||
* @param skuSaleDtoList skuSaleDtoList
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean updateSkuSaleNum(List<SkuSaleDto> skuSaleDtoList);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.atguigu.product.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.atguigu.product.mapper.ProductDetailMapper;
|
||||
import com.atguigu.product.mapper.ProductMapper;
|
||||
import com.atguigu.product.mapper.ProductSkuMapper;
|
||||
import com.atguigu.product.service.ProductService;
|
||||
import com.atguigu.spzx.model.dto.h5.ProductSkuDto;
|
||||
import com.atguigu.spzx.model.dto.product.SkuSaleDto;
|
||||
import com.atguigu.spzx.model.entity.product.Product;
|
||||
import com.atguigu.spzx.model.entity.product.ProductDetails;
|
||||
import com.atguigu.spzx.model.entity.product.ProductSku;
|
||||
|
@ -15,6 +17,7 @@ import com.github.pagehelper.PageHelper;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -100,4 +103,21 @@ public class ProductServiceImpl implements ProductService {
|
|||
public ProductSku getBySkuId(Long skuId) {
|
||||
return productSkuMapper.getById(skuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品sku销量
|
||||
*
|
||||
* @param skuSaleDtoList skuSaleDtoList
|
||||
* @return Boolean
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public Boolean updateSkuSaleNum(List<SkuSaleDto> skuSaleDtoList) {
|
||||
if (!CollectionUtils.isEmpty(skuSaleDtoList)) {
|
||||
for (SkuSaleDto skuSaleDto : skuSaleDtoList) {
|
||||
productSkuMapper.updateSale(skuSaleDto.getSkuId(), skuSaleDto.getNum());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<?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.atguigu.product.mapper.ProductSkuMapper">
|
||||
<!-- 更新商品sku销量 -->
|
||||
<update id="updateSale">
|
||||
update product_sku
|
||||
set sale_num = sale_num + #{num},
|
||||
stock_num = stock_num - #{num},
|
||||
update_time = now()
|
||||
where id = #{skuId}
|
||||
</update>
|
||||
<!-- 根据销量排序,获取前十条数据 -->
|
||||
<select id="selectProductSkuBySale" resultType="com.atguigu.spzx.model.entity.product.ProductSku">
|
||||
SELECT psku.*
|
||||
|
|
Loading…
Reference in New Issue