fix:小程序首次添加用户失败问题

This commit is contained in:
haoxr 2021-03-23 06:39:45 +08:00
parent 10b38721c0
commit 1167c88380
19 changed files with 44 additions and 77 deletions

View File

@ -18,4 +18,6 @@ public class OrderItemDTO extends BaseVO {
private Integer count;
private String pic;
private Long price;
private String spuName;
}

View File

@ -38,5 +38,7 @@ public class CartVO implements Serializable {
private Integer stock;// 商品库存数量页面控制能选择最大数量
private String spuName;
}
}

View File

@ -146,7 +146,7 @@
<version>1.0.0</version>
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<!-- <execution>
<!--<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
@ -171,9 +171,9 @@
<entryPoint>["java","-jar","${project.build.finalName}.jar"]</entryPoint>
<!-- 指定远程 Docker API地址 -->
<dockerHost>https://b.youlai.store:2376</dockerHost>
<dockerHost>https://www.gorun996.com:2376</dockerHost>
<!-- 指定tls证书的目录 -->
<dockerCertPath>C:\cert\docker\b.youlai.store</dockerCertPath>
<dockerCertPath>C:\cert\docker\d.youlai.store</dockerCertPath>
<!-- 复制 jar包到docker容器指定目录-->
<resources>

View File

@ -42,8 +42,6 @@ public class CartController {
return Result.judge(result);
}
@ApiOperation(value = "添加购物车商品")
@ApiImplicitParam(name = "skuId", value = "SKU ID", required = true, paramType = "param", dataType = "Long")
@PostMapping

View File

@ -3,6 +3,7 @@ package com.youlai.mall.oms.controller.app;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.youlai.common.result.Result;
import com.youlai.common.web.util.RequestUtils;
import com.youlai.mall.oms.enums.PayTypeEnum;
import com.youlai.mall.oms.pojo.domain.OmsOrder;
import com.youlai.mall.oms.pojo.dto.OrderConfirmDTO;
@ -44,7 +45,10 @@ public class OrderController {
@RequestParam(defaultValue = "10") Long limit,
Integer status
) {
IPage<OmsOrder> result = orderService.list(new Page<>(page, limit), new OmsOrder().setStatus(status));
IPage<OmsOrder> result = orderService.list(new Page<>(page, limit),
new OmsOrder()
.setStatus(status)
.setMemberId(RequestUtils.getUserId()));
return Result.success(result.getRecords(), result.getTotal());
}

View File

@ -19,7 +19,7 @@ import java.util.List;
public interface OrderItemMapper extends BaseMapper<OmsOrderItem> {
@Select("<script>" +
" select id,order_id,sku_id,sku_name,sku_pic,sku_price,sku_quantity,sku_total_price from oms_order_item where order_id=#{orderId}" +
" select id,order_id,sku_id,sku_name,sku_pic,sku_price,sku_quantity,sku_total_price,spu_name from oms_order_item where order_id=#{orderId}" +
"</script>")
List<OmsOrderItem> listByOrderId(Long orderId);

View File

@ -23,6 +23,9 @@ public interface OrderMapper extends BaseMapper<OmsOrder> {
" <if test ='order.status !=null ' >" +
" AND status= #{order.status} " +
" </if>" +
" <if test ='order.memberId !=null ' >" +
" AND member_id= #{order.memberId} " +
" </if>" +
" <if test ='order.orderSn !=null and order.orderSn.trim() neq \"\"' >" +
" AND order_sn= #{order.orderSn} " +
" </if>" +

View File

@ -6,6 +6,7 @@ import com.youlai.mall.oms.pojo.vo.CartVO;
import com.youlai.mall.oms.service.ICartService;
import com.youlai.mall.pms.api.app.PmsSkuFeignService;
import com.youlai.mall.pms.pojo.domain.PmsSku;
import com.youlai.mall.pms.pojo.dto.SkuDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.BoundHashOperations;
@ -85,7 +86,7 @@ public class CartServiceImpl implements ICartService {
// 购物车不存在该商品添加商品至购物车
cartItem = new CartVO.CartItem();
CompletableFuture<Void> cartItemCompletableFuture = CompletableFuture.runAsync(() -> {
PmsSku sku = skuFeignService.getSkuById(skuId).getData();
SkuDTO sku = skuFeignService.getSkuById(skuId).getData();
if (sku != null) {
cartItem.setSkuId(sku.getId());
cartItem.setCount(1);
@ -95,6 +96,7 @@ public class CartServiceImpl implements ICartService {
cartItem.setSkuName(sku.getName());
cartItem.setStock(sku.getStock());
cartItem.setSkuCode(sku.getCode());
cartItem.setSpuName(sku.getSpuName());
cartItem.setChecked(true);
}
});

View File

@ -28,6 +28,7 @@ import com.youlai.mall.oms.service.IOrderItemService;
import com.youlai.mall.oms.service.IOrderService;
import com.youlai.mall.pms.api.app.PmsSkuFeignService;
import com.youlai.mall.pms.pojo.domain.PmsSku;
import com.youlai.mall.pms.pojo.dto.SkuDTO;
import com.youlai.mall.pms.pojo.dto.SkuLockDTO;
import com.youlai.mall.ums.api.UmsAddressFeignService;
import com.youlai.mall.ums.api.UmsMemberFeignService;
@ -83,11 +84,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
.skuId(orderConfirmDTO.getSkuId())
.count(orderConfirmDTO.getCount())
.build();
PmsSku sku = skuFeignService.getSkuById(orderConfirmDTO.getSkuId()).getData();
SkuDTO sku = skuFeignService.getSkuById(orderConfirmDTO.getSkuId()).getData();
orderItemDTO.setPrice(sku.getPrice());
orderItemDTO.setPic(sku.getPic());
orderItemDTO.setSkuName(sku.getName());
orderItemDTO.setSkuCode(sku.getCode());
orderItemDTO.setSpuName(sku.getSpuName());
orderItems.add(orderItemDTO);
} else { // 购物车中商品结算
List<CartVO.CartItem> cartItems = cartService.getCartItems(memberId);
@ -99,6 +101,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
.price(cartItem.getPrice())
.skuName(cartItem.getSkuName())
.skuCode(cartItem.getSkuCode())
.spuName(cartItem.getSpuName())
.pic(cartItem.getPic())
.build())
.collect(Collectors.toList());
@ -149,7 +152,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OmsOrder> impleme
// 订单验价
Long currentTotalPrice = orderItems.stream().map(item -> {
PmsSku sku = skuFeignService.getSkuById(item.getSkuId()).getData();
SkuDTO sku = skuFeignService.getSkuById(item.getSkuId()).getData();
if (sku != null) {
return sku.getPrice() * item.getCount();
}

View File

@ -12,17 +12,11 @@ import java.util.List;
@FeignClient(value = "mall-pms")
public interface PmsSkuFeignService {
/**
* 获取库存列表
*/
@GetMapping("/api.app/v1/skus")
Result<List<SkuDTO>> listBySkuIds(@RequestParam List<Long> ids);
/**
* 获取库存信息
*/
@GetMapping("/api.app/v1/skus/{id}")
Result<PmsSku> getSkuById(@PathVariable Long id);
Result<SkuDTO> getSkuById(@PathVariable Long id);
/**
* 锁定库存

View File

@ -12,17 +12,12 @@ import lombok.Data;
public class SkuDTO {
private Long id;
private String code;
private String title;
private String name;
private String pic;
private Long price;
private Long spuId;
private Integer stock;
private String spuName;
}

View File

@ -149,13 +149,13 @@
<version>1.0.0</version>
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<!-- <execution>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>-->
</execution>
</executions>
<configuration>

View File

@ -25,7 +25,7 @@ public class SkuController {
@ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path", dataType = "Long")
@GetMapping("/{id}")
public Result detail(@PathVariable Long id) {
PmsSku sku = iPmsSkuService.getById(id);
SkuDTO sku = iPmsSkuService.getSkuById(id);
return Result.success(sku);
}
@ -63,12 +63,5 @@ public class SkuController {
return Result.judge(result);
}
@ApiOperation(value = "商品列表")
@ApiImplicitParam(name = "skuIds", value = "商品ID集合", required = true, paramType = "body", dataType = "String")
@GetMapping
public Result list(@RequestParam List<Long> ids) {
List<SkuDTO> list = iPmsSkuService.listBySkuIds(ids);
return Result.success(list);
}
}

View File

@ -17,33 +17,10 @@ public interface PmsSkuMapper extends BaseMapper<PmsSku> {
List<PmsSku> listBySpuId(Long spuId);
@Select({
"<script>",
" SELECT",
" t1.id,",
" t1.CODE,",
" t1.NAME,",
" t1.pic,",
" t1.origin_price,",
" t1.price price,",
" t1.stock stock,",
" t2.id spu_id,",
" t2.NAME product_name,",
" t2.pic product_pic,",
" t3.id category_id,",
" t3.NAME category_name,",
" t4.id brand_id,",
" t4.NAME brand_name",
" FROM",
" pms_sku t1",
" LEFT JOIN pms_spu t2 ON t1.spu_id = t2.id",
" LEFT JOIN pms_category t3 ON t2.category_id = t3.id",
" LEFT JOIN pms_brand t4 ON t2.brand_id = t4.id",
" WHERE t1.id in ",
" <foreach collection='skuIds' item='skuId' open='(' separator=',' close=')'>",
" #{skuId}",
" </foreach>",
"</script>"
})
List<SkuDTO> listBySkuIds(List<Long> skuIds);
@Select("<script>" +
" select t1.id,t1.code,t1.name,t1.pic,t1.price,(t1.stock-t1.locked_stock) as stock,t2.name as spu_name from pms_sku t1" +
" left join pms_spu t2 on t1.spu_id=t2.id" +
" where t1.id=#{id}" +
"</script>")
SkuDTO getSkuById(Long id);
}

View File

@ -29,9 +29,5 @@ public interface IPmsSkuService extends IService<PmsSku> {
*/
Integer getStockById(Long id);
/**
* 获取商品列表
*/
List<SkuDTO> listBySkuIds(List<Long> ids);
SkuDTO getSkuById(Long id);
}

View File

@ -170,13 +170,11 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
}
return stock;
}
@Override
public List<SkuDTO> listBySkuIds(List<Long> ids) {
return this.baseMapper.listBySkuIds(ids);
public SkuDTO getSkuById(Long id) {
return this.baseMapper.getSkuById(id);
}
}

View File

@ -127,9 +127,9 @@
<entryPoint>["java","-jar","${project.build.finalName}.jar"]</entryPoint>
<!-- 指定远程 Docker API地址 -->
<dockerHost>https://c.youlai.store:2376</dockerHost>
<dockerHost>https://www.gorun996.com:2376</dockerHost>
<!-- 指定tls证书的目录 -->
<dockerCertPath>C:\cert\docker\c.youlai.store</dockerCertPath>
<dockerCertPath>C:\cert\docker\d.youlai.store</dockerCertPath>
<!-- 复制 jar包到docker容器指定目录-->
<resources>

View File

@ -35,7 +35,7 @@ public class CouponController {
}
@ApiOperation("查询优惠券详情")
@RequestMapping("/${couponId}/detail")
@RequestMapping("/{couponId}/detail")
public Result detail(@ApiParam("删除商品分页列表查询") @PathVariable("couponId") String couponId) {
return Result.success(couponService.detail(couponId));
}

View File

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
* @date 2021/3/4
*/
@Api(tags = "秒杀活动场次管理")
@RestController
@RestController("AdminSeckillController")
@RequestMapping("/api.admin/v1/seckill")
public class SeckillController {
}