规范化订单商品表内关联字段,修改订单list接口

This commit is contained in:
kuang.yifei@iwhalecloud.com 2022-06-09 15:11:02 +08:00
parent 6f37b29eb7
commit 0feed790ce
8 changed files with 28 additions and 25 deletions

View File

@ -113,7 +113,7 @@ public class OrderController extends BaseController {
// 批量生成订单商品
request.getGoodsList().forEach(goods -> {
OrderGoods orderGoods = new OrderGoods();
orderGoods.setGoodsId(goods.getGoodsStandardId());
orderGoods.setGoodsStandardId(goods.getGoodsStandardId());
orderGoods.setGoodsNum(goods.getNum());
orderGoods.setOrderId(od.getId());
orderGoods.setServerGoodsNum(0);

View File

@ -12,6 +12,7 @@ import com.ghy.customer.domain.Customer;
import com.ghy.customer.domain.CustomerAddress;
import com.ghy.customer.service.CustomerAddressService;
import com.ghy.customer.service.CustomerService;
import com.ghy.goods.domain.Goods;
import com.ghy.goods.domain.GoodsStandard;
import com.ghy.goods.service.GoodsService;
import com.ghy.goods.service.GoodsStandardService;
@ -101,11 +102,13 @@ public class OrderMasterController extends BaseController {
// 师傅信息
Worker worker = workerService.selectById(master.getWorkerId());
// 商品信息
OrderGoods orderGoods = orderGoodsService.selectByOrderMasterId(master.getId());
// 商品规格及信息
List<OrderGoods> orderStandardList = orderGoodsService.selectByOrderMasterId(master.getId());
// 规格信息
List<GoodsStandard> goodsStandardList = goodsStandardService.selectByGoodsStandardId(orderGoods.getGoodsId());
// 商品信息
GoodsStandard goodsStandard = goodsStandardService.selectById(orderStandardList.get(0).getGoodsStandardId());
Goods goods = goodsService.selectById(goodsStandard.getGoodsId());
// 财务信息
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(master.getId());
@ -113,17 +116,17 @@ public class OrderMasterController extends BaseController {
// 地址信息
CustomerAddress customerAddress = addressService.selectByCustomerAddressId(master.getAddressId());
for(GoodsStandard goodsStandard : goodsStandardList){
for(OrderGoods orderGoods : orderStandardList){
OrderStandard orderStandard = new OrderStandard();
orderStandard.setStandardName(goodsStandard.getGoodsStandardName());
orderStandard.setStandardNum(goodsStandard.getGoodsNum());
orderStandard.setStandardName(orderGoods.getGoodsName());
orderStandard.setStandardNum(orderGoods.getGoodsNum());
standardList.add(orderStandard);
}
// 编辑返回属性
orderListResponse.setOrderMasterId(master.getId());
orderListResponse.setGoodsName(orderGoods.getGoodsName());
orderListResponse.setGoodsLogoUrl(orderGoods.getGoodsLogoUrl());
orderListResponse.setGoodsName(goods.getGoodsName());
orderListResponse.setGoodsLogoUrl(goods.getGoodsImgUrl());
orderListResponse.setDiscountMoney(financialMaster.getDiscountMoney());
orderListResponse.setTotalMoney(financialMaster.getTotalMoney());
orderListResponse.setPayMoney(financialMaster.getPayMoney());
@ -199,7 +202,7 @@ public class OrderMasterController extends BaseController {
Map<Long, FinancialDetail> longFinancialDetailMap = financialDetailService.byOrderIdInMap(orderDetailsIdList);
for(OrderGoods orderGoods : orderGoodsList){
OrderDetailsResponseVo.OrderDetails orderDetails = OrderDetailsResponseVo.OrderDetails.modelDataSupplement(orderGoods);
FinancialDetail financialDetail = longFinancialDetailMap.get(orderGoods.getGoodsId());
FinancialDetail financialDetail = longFinancialDetailMap.get(orderGoods.getOrderGoodsId());
if(ObjectUtils.isNotNull(financialDetail)){
orderDetails.setDiscountMoney(financialDetail.getDiscountMoney());
orderDetails.setPayMoney(financialDetail.getPayMoney());

View File

@ -338,7 +338,7 @@ public class OrderDetailsResponseVo implements Serializable {
public static OrderDetails modelDataSupplement(OrderGoods orderGoods){
OrderDetails orderDetails = new OrderDetails();
if(ObjectUtils.isNotNull(orderGoods)){
orderDetails.setGoodsId(orderGoods.getGoodsId());
orderDetails.setGoodsId(orderGoods.getGoodsStandardId());
orderDetails.setGoodsName(orderGoods.getGoodsName());
orderDetails.setGoodsNum(orderGoods.getGoodsNum());
orderDetails.setServerGoodsNum(orderGoods.getServerGoodsNum());

View File

@ -24,7 +24,7 @@ public class OrderGoods extends BaseEntity {
private Long orderId;
@Excel(name = "商品规格id", cellType = Excel.ColumnType.NUMERIC)
private Long goodsId;
private Long goodsStandardId;
@Excel(name = "商品名称", cellType = Excel.ColumnType.STRING)
private String goodsName;
@ -46,9 +46,9 @@ public class OrderGoods extends BaseEntity {
public OrderGoods() {
}
public OrderGoods(Long orderId, Long goodsId, String goodsName, Integer goodsNum, Integer serverGoodsNum) {
public OrderGoods(Long orderId, Long goodsStandardId, String goodsName, Integer goodsNum, Integer serverGoodsNum) {
this.orderId = orderId;
this.goodsId = goodsId;
this.goodsStandardId = goodsStandardId;
this.goodsName = goodsName;
this.goodsNum = goodsNum;
this.serverGoodsNum = serverGoodsNum;

View File

@ -33,7 +33,7 @@ public interface OrderGoodsMapper {
*/
OrderGoods selectById(Long orderGoodsId);
OrderGoods selectByOrderId(Long orderId);
List<OrderGoods> selectByOrderId(Long orderId);
/**
* 批量删除订单商品信息

View File

@ -18,7 +18,7 @@ public interface OrderGoodsService {
*/
int insertOrderGoods(OrderGoods orderGoods);
OrderGoods selectByOrderMasterId(Long orderMasterId);
List<OrderGoods> selectByOrderMasterId(Long orderMasterId);
/**
* @param orderGoods 订单商品属性

View File

@ -27,7 +27,7 @@ public class OrderGoodsServiceImpl implements OrderGoodsService {
}
@Override
public OrderGoods selectByOrderMasterId(Long orderMasterId) {
public List<OrderGoods> selectByOrderMasterId(Long orderMasterId) {
return orderGoodsMapper.selectByOrderId(orderMasterId);
}

View File

@ -7,7 +7,7 @@
<resultMap id="OrderGoodsResult" type="com.ghy.order.domain.OrderGoods">
<id property="orderGoodsId" column="order_goods_id"/>
<result property="orderId" column="order_id"/>
<result property="goodsId" column="goods_id"/>
<result property="goodsStandardId" column="goods_standard_id"/>
<result property="goodsName" column="goods_name"/>
<result property="goodsNum" column="goods_num"/>
<result property="serverGoodsNum" column="server_goods_num"/>
@ -20,7 +20,7 @@
</resultMap>
<sql id="selectOrderGoods">
SELECT order_goods_id, order_id, goods_id, goods_name, goods_num, server_goods_num,
SELECT order_goods_id, order_id, goods_standard_id, goods_name, goods_num, server_goods_num,
finish_time, create_by, create_time, update_by, update_time, remark
FROM order_goods
</sql>
@ -29,7 +29,7 @@
UPDATE order_goods
<set>
<if test="orderId != null and orderId != 0">order_id = #{orderId},</if>
<if test="goodsId != null and goodsId != 0">goods_id = #{goodsId},</if>
<if test="goodsStandardId != null and goodsStandardId != 0">goods_standard_id = #{goodsStandardId},</if>
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="goodsNum != null">goods_num = #{goodsNum},</if>
<if test="serverGoodsNum != null">server_goods_num = #{serverGoodsNum},</if>
@ -44,7 +44,7 @@
keyProperty="orderGoodsId">
INSERT INTO order_goods(
<if test="orderId != null and orderId != 0">order_id,</if>
<if test="goodsId != null and goodsId != 0">goods_id,</if>
<if test="goodsStandardId != null and goodsStandardId != 0">goods_standard_id,</if>
<if test="goodsName != null and goodsName != ''">goods_name,</if>
<if test="goodsNum != null">goods_num,</if>
<if test="serverGoodsNum != null">server_goods_num,</if>
@ -53,7 +53,7 @@
create_time
)VALUES(
<if test="orderId != null and orderId != 0">#{orderId},</if>
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
<if test="goodsStandardId != null and goodsStandardId != 0">#{goodsStandardId},</if>
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
<if test="goodsNum != null">#{goodsNum},</if>
<if test="serverGoodsNum != null">#{serverGoodsNum},</if>
@ -69,8 +69,8 @@
<if test="orderId != null and orderId != 0">
AND order_id = #{orderId}
</if>
<if test="goodsId != null and goodsId != 0">
AND goods_id = #{goodsId}
<if test="goodsStandardId != null and goodsStandardId != 0">
AND goods_standard_id = #{goodsStandardId}
</if>
<if test="goodsName != null and goodsName != ''">
AND goods_name LIKE concat('%', #{goodsName}, '%')