Browse Source

增加批量获取客户最近购买的商品价格及数量接口getByUserIdAndProductIds

dev
qiaohui 2 years ago
parent
commit
f6c2f32c48
  1. 18
      hiver-admin/test-output/test-report.html
  2. 24
      hiver-core/src/main/java/cc/hiver/core/shopprint/controller/ShopPrintController.java
  3. 15
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
  4. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java
  5. 2
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java
  6. 6
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java
  7. 22
      hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml

18
hiver-admin/test-output/test-report.html

@ -5,7 +5,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Hiver测试报告</title> <title>Hiver测试报告</title>
<link rel="apple-touch-icon" href="spark/logo.png"> <link rel="apple-touch-icon" href="spark/logo.png">
<link rel="shortcut icon" href="spark/logo.png"> <link rel="shortcut icon" href="spark/logo.png">
<link rel="stylesheet" href="spark/spark-style.css"> <link rel="stylesheet" href="spark/spark-style.css">
@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a> <a href="#"><span class="badge badge-primary">Hiver</span></a>
</li> </li>
<li class="m-r-10"> <li class="m-r-10">
<a href="#"><span class="badge badge-primary">十月 19, 2024 22:12:49</span></a> <a href="#"><span class="badge badge-primary">十月 23, 2024 23:46:29</span></a>
</li> </li>
</ul> </ul>
</div> </div>
@ -84,7 +84,7 @@
<div class="test-detail"> <div class="test-detail">
<span class="meta text-white badge badge-sm"></span> <span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p> <p class="name">passTest</p>
<p class="text-sm"><span>22:12:51 下午</span> / <span>0.028 secs</span></p> <p class="text-sm"><span>23:46:29 下午</span> / <span>0.01 secs</span></p>
</div> </div>
<div class="test-contents d-none"> <div class="test-contents d-none">
<div class="detail-head"> <div class="detail-head">
@ -92,9 +92,9 @@
<div class="info"> <div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div> <div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5> <h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>10.19.2024 22:12:51</span> <span class='badge badge-success'>10.23.2024 23:46:29</span>
<span class='badge badge-danger'>10.19.2024 22:12:51</span> <span class='badge badge-danger'>10.23.2024 23:46:29</span>
<span class='badge badge-default'>0.028 secs</span> <span class='badge badge-default'>0.01 secs</span>
</div> </div>
<div class="m-t-10 m-l-5"></div> <div class="m-t-10 m-l-5"></div>
</div> </div>
@ -104,7 +104,7 @@
<tbody> <tbody>
<tr class="event-row"> <tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td> <td><span class="badge log pass-bg">Pass</span></td>
<td>22:12:51</td> <td>23:46:29</td>
<td> <td>
Test passed Test passed
</td> </td>
@ -128,13 +128,13 @@
<div class="col-md-3"> <div class="col-md-3">
<div class="card"><div class="card-body"> <div class="card"><div class="card-body">
<p class="m-b-0">Started</p> <p class="m-b-0">Started</p>
<h3>十月 19, 2024 22:12:49</h3> <h3>十月 23, 2024 23:46:29</h3>
</div></div> </div></div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="card"><div class="card-body"> <div class="card"><div class="card-body">
<p class="m-b-0">Ended</p> <p class="m-b-0">Ended</p>
<h3>十月 19, 2024 22:12:51</h3> <h3>十月 23, 2024 23:46:29</h3>
</div></div> </div></div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">

24
hiver-core/src/main/java/cc/hiver/core/shopprint/controller/ShopPrintController.java

@ -66,19 +66,12 @@ public class ShopPrintController {
} }
} }
/**
* 删除物流线路 @GetMapping(value = "/delete", produces = "application/json")
*
* @param id
* @return Result
* @author 王富康
* @date 2024/8/24
*/
@PostMapping(value = "/delete")
@ApiOperation("删除店铺打印内容") @ApiOperation("删除店铺打印内容")
public Result deleteLogisticsRoute(String id) { public Result deleteShopPrint(String id) {
if (StringUtils.isEmpty(id)) { if (StringUtils.isEmpty(id)) {
return ResultUtil.error("线路id不能为空!"); return ResultUtil.error("id不能为空!");
} }
final boolean b = shopPrintService.removeById(id); final boolean b = shopPrintService.removeById(id);
if (b) { if (b) {
@ -88,14 +81,7 @@ public class ShopPrintController {
} }
} }
/**
* 分页查询物流线路
*
* @param logisticsRouteQueryVo
* @return Result<IPage < LogisticsRoute>>
* @author 王富康
* @date 2024/8/24
*/
@RequestMapping(value = "/getList", method = RequestMethod.POST) @RequestMapping(value = "/getList", method = RequestMethod.POST)
@ApiOperation(value = "查询打印内容") @ApiOperation(value = "查询打印内容")
public Result<List<ShopPrint>> getLogisticsRoutePageList(@RequestBody(required = false) ShopPrintQueryVo shopPrintQueryVo) { public Result<List<ShopPrint>> getLogisticsRoutePageList(@RequestBody(required = false) ShopPrintQueryVo shopPrintQueryVo) {

15
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java

@ -378,4 +378,19 @@ public class ProductController {
return ResultUtil.success("未查到对应商品信息!"); return ResultUtil.success("未查到对应商品信息!");
} }
} }
@RequestMapping(value = "/getByUserIdAndProductIds", method = RequestMethod.POST)
@ApiOperation("批量获取客户最近购买的商品价格及数量")
public Result getByUserIdAndProductIds(String userId, String productIds) {
String[] ids = {};
if(StringUtils.isNotEmpty(productIds)){
ids = productIds.split(",");
}
final List<ProductLastBuyVo> byProductSn = productService.getByUserIdAndProductIds(userId, ids);
if (byProductSn != null) {
return new ResultUtil<List<ProductLastBuyVo>>().setData(byProductSn);
} else {
return ResultUtil.success("未查到对应商品信息!");
}
}
} }

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/dao/mapper/ProductMapper.java

@ -47,6 +47,8 @@ public interface ProductMapper extends BaseMapper<Product> {
ProductLastBuyVo getByUserIdAndProductId(@Param("userId") String userId, @Param("productId") String productId); ProductLastBuyVo getByUserIdAndProductId(@Param("userId") String userId, @Param("productId") String productId);
List<ProductLastBuyVo> getByUserIdAndProductIds(@Param("userId") String userId, @Param("array") String[] productIds);
Product getByIdOrBrcode(String id); Product getByIdOrBrcode(String id);
List<Product> getByBarcode(@Param("barcode") String barcode, @Param("shopId") String shopId); List<Product> getByBarcode(@Param("barcode") String barcode, @Param("shopId") String shopId);

2
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/service/mybatis/ProductService.java

@ -34,6 +34,8 @@ public interface ProductService extends IService<Product> {
ProductLastBuyVo getByUserIdAndProductId(String userId, String productId); ProductLastBuyVo getByUserIdAndProductId(String userId, String productId);
List<ProductLastBuyVo> getByUserIdAndProductIds(String userId, String[] productId);
Product getByIdOrBrcode(String id,String customerId); Product getByIdOrBrcode(String id,String customerId);
List<Product> getByBarcode(String barcode, String customerId); List<Product> getByBarcode(String barcode, String customerId);

6
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java

@ -182,6 +182,12 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
return baseMapper.getByUserIdAndProductId(userId, productId); return baseMapper.getByUserIdAndProductId(userId, productId);
} }
@Override
public List<ProductLastBuyVo> getByUserIdAndProductIds(String userId, String[] productIds) {
return baseMapper.getByUserIdAndProductIds(userId, productIds);
}
@Override @Override
public Product getByIdOrBrcode(String id, String customerId) { public Product getByIdOrBrcode(String id, String customerId) {
final Product byIdOrBrcode = baseMapper.getByIdOrBrcode(id); final Product byIdOrBrcode = baseMapper.getByIdOrBrcode(id);

22
hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml

@ -746,6 +746,28 @@
limit 1 limit 1
</select> </select>
<select id="getByUserIdAndProductIds" resultType="cc.hiver.mall.pojo.vo.ProductLastBuyVo">
select MAX(tt.discount_amount) as discount_amount, tt.product_id from t_sale_detail tt,
(SELECT
MAX(s.create_time) as create_time,s.product_id
FROM
t_sale t
LEFT JOIN t_sale_detail s ON t.id = s.sale_id
WHERE
s.product_id IN
<foreach item="productId" index="index" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
AND t.user_id = #{userId,jdbcType=VARCHAR}
GROUP BY
s.product_id) aa
where tt.create_time = aa.create_time and tt.product_id = aa.product_id GROUP BY tt.product_id
</select>
<select id="getByIdOrBrcode" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="getByIdOrBrcode" parameterType="java.lang.String" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>

Loading…
Cancel
Save