Commit abbf0ad4 by weijiguang

优化店铺距离限制

parent 9ca18783
......@@ -162,7 +162,7 @@ public class OrderController extends BaseController {
order.setPaidAmount(order.getAmount().add(order.getCouponAmount()));
order.setCouponId(couponVo.getCouponId());
} else {
couponUserService.orderDetailCheckAndAssign(order.getOrderDetails());
couponUserService.orderDetailCheckAndAssign(order.getShopId(), order.getOrderDetails());
}
AjaxResult ajaxResult = orderService.insertOrder(loginUser, order, couponUserId);
......
......@@ -36,7 +36,7 @@ public interface GoodsSkuMapper
* @param ids
* @return
*/
List<GoodsSku> selectSkuListForOrder(@Param("ids") List<Long> ids);
List<GoodsSku> selectSkuListForOrder(@Param("shopId") Long shopId, @Param("ids") List<Long> ids);
/**
* 新增由规格选项组合生成商品sku
......
......@@ -31,5 +31,5 @@ public interface ICouponUserService {
void resovleCouponFitable(List<CouponVo> couponVos, Order order);
List<GoodsSku> orderDetailCheckAndAssign(List<OrderDetail> orderDetails);
List<GoodsSku> orderDetailCheckAndAssign(Long shopId, List<OrderDetail> orderDetails);
}
......@@ -178,11 +178,11 @@ public class CouponUserServiceImpl implements ICouponUserService {
/** 可用门店和时段的校验 */
this.checkShopAndWeeklyFitable(couponVos, order.getShopId());
/** 可用饮品范围的判断 */
checkGoodsFitable(couponVos, order.getOrderDetails());
checkGoodsFitable(order.getShopId(), couponVos, order.getOrderDetails());
}
private void checkGoodsFitable(List<CouponVo> couponVos, List<OrderDetail> orderDetails) {
List<GoodsSku> goodsSkus = this.orderDetailCheckAndAssign(orderDetails);
private void checkGoodsFitable(Long shopId, List<CouponVo> couponVos, List<OrderDetail> orderDetails) {
List<GoodsSku> goodsSkus = this.orderDetailCheckAndAssign(shopId, orderDetails);
List<Long> goodsIds = goodsSkus.stream().map(GoodsSku::getGoodsId).collect(Collectors.toList());
List<Goods> goods = goodsMapper.selectGoodsByIds(goodsIds);
Assert.notEmpty(goods, "未查询到匹配的商品信息[id=" + goodsIds + "]");
......@@ -234,11 +234,11 @@ public class CouponUserServiceImpl implements ICouponUserService {
}
@Override
public List<GoodsSku> orderDetailCheckAndAssign(List<OrderDetail> orderDetails) {
public List<GoodsSku> orderDetailCheckAndAssign(Long shopId, List<OrderDetail> orderDetails) {
Assert.notEmpty(orderDetails, "商品明细还未传递");
List<Long> skuIds = orderDetails.stream().map(OrderDetail::getSkuId).collect(Collectors.toList());
Assert.notEmpty(skuIds, "skuId还未传递");
List<GoodsSku> goodsSkus = goodsSkuMapper.selectSkuListForOrder(skuIds);
List<GoodsSku> goodsSkus = goodsSkuMapper.selectSkuListForOrder(shopId, skuIds);
log.info("sku id size is {} and query size is {}", skuIds.size(), goodsSkus.size());
Assert.isTrue(goodsSkus.size() == skuIds.size(), "未查询到匹配的sku记录");
// sku的ID和价格字典
......
......@@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSkuListForOrder" resultMap="GoodsSkuResult">
select gs.id, gs.goods_id, gs.price,
case when sgs.discount>=0 then sgs.discount else gs.discount end as discount,
gs.is_deleted from goods_sku gs
case when sgs.discount>=0 then sgs.discount else gs.discount end as discount, gs.is_deleted
from goods_sku gs
left join shop_goods_sku sgs on gs.goods_id = sgs.goods_id and gs.id = sgs.sku_id
where gs.id in
where sgs.shop_id = #{shopId}
and gs.id in
<foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment