Browse Source

查询时间范围内当前店铺的交易记录

master
wangfukang 2 days ago
parent
commit
681b163045
  1. 16
      hiver-admin/test-output/test-report.html
  2. 17
      hiver-core/src/main/java/cc/hiver/core/config/security/WebSecurityConfig.java
  3. 16
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
  4. 48
      hiver-modules/hiver-mall/src/main/resources/mapper/ProductMapper.xml

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

@ -35,7 +35,7 @@
<a href="#"><span class="badge badge-primary">Hiver</span></a>
</li>
<li class="m-r-10">
<a href="#"><span class="badge badge-primary">三月 10, 2026 17:20:14</span></a>
<a href="#"><span class="badge badge-primary">十一月 10, 2026 10:12:06</span></a>
</li>
</ul>
</div>
@ -84,7 +84,7 @@
<div class="test-detail">
<span class="meta text-white badge badge-sm"></span>
<p class="name">passTest</p>
<p class="text-sm"><span>17:20:14 下午</span> / <span>0.016 secs</span></p>
<p class="text-sm"><span>10:12:07 上午</span> / <span>0.015 secs</span></p>
</div>
<div class="test-contents d-none">
<div class="detail-head">
@ -92,9 +92,9 @@
<div class="info">
<div class='float-right'><span class='badge badge-default'>#test-id=1</span></div>
<h5 class="test-status text-pass">passTest</h5>
<span class='badge badge-success'>03.10.2026 17:20:14</span>
<span class='badge badge-danger'>03.10.2026 17:20:14</span>
<span class='badge badge-default'>0.016 secs</span>
<span class='badge badge-success'>11.10.2026 10:12:07</span>
<span class='badge badge-danger'>11.10.2026 10:12:07</span>
<span class='badge badge-default'>0.015 secs</span>
</div>
<div class="m-t-10 m-l-5"></div>
</div>
@ -104,7 +104,7 @@
<tbody>
<tr class="event-row">
<td><span class="badge log pass-bg">Pass</span></td>
<td>17:20:14</td>
<td>10:12:07</td>
<td>
Test passed
</td>
@ -128,13 +128,13 @@
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Started</p>
<h3>三月 10, 2026 17:20:14</h3>
<h3>十一月 10, 2026 10:12:06</h3>
</div></div>
</div>
<div class="col-md-3">
<div class="card"><div class="card-body">
<p class="m-b-0">Ended</p>
<h3>三月 10, 2026 17:20:14</h3>
<h3>十一月 10, 2026 10:12:07</h3>
</div></div>
</div>
<div class="col-md-3">

17
hiver-core/src/main/java/cc/hiver/core/config/security/WebSecurityConfig.java

@ -13,12 +13,16 @@ import cc.hiver.core.config.security.validate.ImageValidateFilter;
import cc.hiver.core.config.security.validate.SmsValidateFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@ -62,6 +66,19 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityUtil securityUtil;
@Autowired
private UserDetailsServiceImpl userDetailsService;
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http

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

@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@ -391,11 +392,18 @@ public class ProductController {
@RequestMapping(value = "/getByUserIdAndProductIds", method = RequestMethod.POST)
@ApiOperation("批量获取客户最近购买的商品价格及数量")
public Result getByUserIdAndProductIds(String userId, String productIds) {
String[] ids = {};
if(StringUtils.isNotEmpty(productIds)){
ids = productIds.split(",");
List<String> idList = new ArrayList<>();
if (StringUtils.isNotEmpty(productIds)) {
for (String id : productIds.split(",")) {
if (StringUtils.isNotBlank(id) && !idList.contains(id.trim())) {
idList.add(id.trim());
}
}
}
if (StringUtils.isEmpty(userId) || idList.isEmpty()) {
return new ResultUtil<List<ProductLastBuyVo>>().setData(new ArrayList<>());
}
final List<ProductLastBuyVo> byProductSn = productService.getByUserIdAndProductIds(userId, ids);
final List<ProductLastBuyVo> byProductSn = productService.getByUserIdAndProductIds(userId, idList.toArray(new String[0]));
if (byProductSn != null) {
return new ResultUtil<List<ProductLastBuyVo>>().setData(byProductSn);
} else {

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

@ -760,6 +760,7 @@
t_sale t
LEFT JOIN t_sale_detail s ON t.id = s.sale_id
WHERE
t.status = 4 and
s.product_id = #{productId,jdbcType=VARCHAR}
AND t.user_id = #{userId,jdbcType=VARCHAR}
group by s.product_id,s.sale_id,s.discount_amount
@ -769,24 +770,35 @@
<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
s.product_id AS productId,
s.discount_amount AS discountAmount
FROM t_sale t
INNER JOIN t_sale_detail s ON t.id = s.sale_id
INNER JOIN (
SELECT
s2.product_id,
MAX(t2.create_time) AS create_time
FROM t_sale t2
INNER JOIN t_sale_detail s2 ON t2.id = s2.sale_id
WHERE t2.status = 4
AND IFNULL(t2.del_flag, 0) = 0
AND IFNULL(s2.del_flag, 0) = 0
AND t2.user_id = #{userId,jdbcType=VARCHAR}
AND s2.product_count > 0
AND s2.discount_amount IS NOT NULL
AND s2.product_id IN
<foreach item="productId" index="index" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
GROUP BY s2.product_id
) latest ON latest.product_id = s.product_id AND latest.create_time = t.create_time
WHERE t.status = 4
AND IFNULL(t.del_flag, 0) = 0
AND IFNULL(s.del_flag, 0) = 0
AND t.user_id = #{userId,jdbcType=VARCHAR}
AND s.product_count > 0
AND s.discount_amount IS NOT NULL
</select>
<select id="getByIdOrBrcode" parameterType="java.lang.String" resultMap="BaseResultMap">

Loading…
Cancel
Save