xin
2025-06-24 9a66c01477b81f8d429a45b0a2922ab75e2e9c64
Merge remote-tracking branch 'origin/master' into xin
1 files added
9 files modified
155 ■■■■ changed files
oying-system/src/main/java/com/oying/modules/pc/product/domain/Product.java 8 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java 12 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java 4 ●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/product/view/ProductCustomerView.java 9 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/store/domain/Store.java 10 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/store/domain/dto/StoreCustomerDetailDto.java 12 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/store/service/impl/StoreQueryServiceImpl.java 20 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/store/view/CustomerStoreView.java 8 ●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/security/rest/AuthController.java 43 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/security/service/dto/AuthUserPhoneDto.java 29 ●●●●● patch | view | raw | blame | history
oying-system/src/main/java/com/oying/modules/pc/product/domain/Product.java
@@ -102,6 +102,14 @@
    @ApiModelProperty(value = "是否支持自提")
    private Integer selfPickup;
    @TableField(exist = false)
    @ApiModelProperty(value = "销量")
    private Integer totalUnitsSold = 0;
    @TableField(exist = false)
    @ApiModelProperty(value = "月销售量")
    private Integer monthlyUnitsSold = 0;
    @NotNull
    @ApiModelProperty(value = "是否删除")
    private Integer deletedFlag;
oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductController.java
@@ -1,6 +1,5 @@
package com.oying.modules.pc.product.rest;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.oying.annotation.Log;
@@ -17,7 +16,6 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -58,7 +56,7 @@
    @GetMapping(value = "/batch")
    @ApiOperation("查询商品(批量)")
    // @PreAuthorize("@el.check('product:list')")
    public ResponseEntity<?> getProductsByIds(@RequestBody List<Long> ids) {
    public ResponseEntity<?> getProductsByIds(@RequestParam(value = "ids") List<Long> ids) {
        return ResponseEntity.ok(R.success(productService.listByIds(ids)));
    }
@@ -112,9 +110,7 @@
    @Log("新增商品")
    @ApiOperation("新增商品")
    //@PreAuthorize("@el.check('merchant:product:add')")
    public ResponseEntity<?> createProduct(@PathVariable Long storeId,
                                           @Validated @RequestBody ProductMerchantCreateRequest request) {
        request.setStoreId(ObjectUtils.defaultIfNull(request.getStoreId(), storeId));
    public ResponseEntity<?> createProduct(@Validated @RequestBody ProductMerchantCreateRequest request) {
        productAdminService.create(request);
        return ResponseEntity.noContent().build();
    }
@@ -123,9 +119,7 @@
    @Log("修改商品")
    @ApiOperation("修改商品")
    // @PreAuthorize("@el.check('product:edit')")
    public ResponseEntity<?> updateProduct(@PathVariable Long productId,
                                           @Validated @RequestBody ProductMerchantUpdateRequest request) {
        request.setProductId(ObjectUtils.defaultIfNull(request.getProductId(), productId));
    public ResponseEntity<?> updateProduct(@Validated @RequestBody ProductMerchantUpdateRequest request) {
        productAdminService.update(request);
        return ResponseEntity.noContent().build();
    }
oying-system/src/main/java/com/oying/modules/pc/product/rest/ProductCustomerController.java
@@ -18,7 +18,6 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -75,6 +74,9 @@
    /*@PreAuthorize("@el.check('merchant:product:byProductId')")*/
    public ResponseEntity<?> getProductDetails(@PathVariable Long productId) {
        Product product = productService.getById(productId);
        if (ObjUtil.isEmpty(product)) {
            return ResponseEntity.ok(R.success());
        }
        ProductCustomerView customerView = new ProductCustomerView();
        BeanUtil.copyProperties(product, customerView);
        if (ObjUtil.isNotEmpty(product)) {
oying-system/src/main/java/com/oying/modules/pc/product/view/ProductCustomerView.java
@@ -1,12 +1,8 @@
package com.oying.modules.pc.product.view;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -75,8 +71,11 @@
    @ApiModelProperty(value = "版本号")
    private Long version;
    @ApiModelProperty(value = "销量")
    private Integer totalUnitsSold = 0;
    @ApiModelProperty(value = "月销售量")
    private Integer monthlySales = 0;
    private Integer monthlyUnitsSold = 0;
    private List<ProductImageCustomerView> images = new ArrayList<>();
    private List<ProductLabelCustomerView> labels = new ArrayList<>();
oying-system/src/main/java/com/oying/modules/pc/store/domain/Store.java
@@ -141,8 +141,16 @@
    private Integer deliveryDuration = 0;
    @TableField(exist = false)
    @ApiModelProperty(value = "配送时长")
    private Integer deliveryTime = 0;
    @TableField(exist = false)
    @ApiModelProperty(value = "销量")
    private Integer totalUnitsSold = 0;
    @TableField(exist = false)
    @ApiModelProperty(value = "月销售量")
    private Integer monthlySales = 0;
    private Integer monthlyUnitsSold = 0;
    @TableField(exist = false)
    @ApiModelProperty(value = "资质")
oying-system/src/main/java/com/oying/modules/pc/store/domain/dto/StoreCustomerDetailDto.java
@@ -1,6 +1,5 @@
package com.oying.modules.pc.store.domain.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -65,16 +64,19 @@
    @ApiModelProperty(value = "是否支持自提")
    private Integer selfPickup;
    @TableField(exist = false)
    @ApiModelProperty(value = "评分")
    private Double score = 0d;
    @TableField(exist = false)
    @ApiModelProperty(value = "配送距离")
    private Integer deliveryDuration = 0;
    @TableField(exist = false)
    @ApiModelProperty(value = "配送时长")
    private Integer deliveryTime = 0;
    @ApiModelProperty(value = "销量")
    private Integer totalUnitsSold = 0;
    @ApiModelProperty(value = "月销售量")
    private Integer monthlySales = 0;
    private Integer monthlyUnitsSold = 0;
}
oying-system/src/main/java/com/oying/modules/pc/store/service/impl/StoreQueryServiceImpl.java
@@ -1,4 +1,5 @@
package com.oying.modules.pc.store.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.NumberUtil;
import com.oying.modules.pc.store.domain.Store;
@@ -39,11 +40,12 @@
        if (total == null || total == 0) {
            // 初始化缓存
            List<Long> ids = storeMapper.queryStoreIds(criteria);
            int index = 0;
            for (Long id : ids) {
                redisTemplate.opsForZSet().add(setKey, id, 1);
                redisTemplate.opsForZSet().add(setKey, id, index++);
            }
            // 设置缓存过期时间
            redisTemplate.expire(setKey, 30, TimeUnit.MINUTES);
            redisTemplate.expire(setKey, 15, TimeUnit.MINUTES);
            total = (long) ids.size();
        }
@@ -51,13 +53,17 @@
        int current = (criteria.getPage() == null || criteria.getPage() < 1) ? 1 : criteria.getPage();
        int offset = (current - 1) * criteria.getSize();
        int end = offset + criteria.getSize() - 1;
        Set<Long> storeIds = Optional.ofNullable(redisTemplate.opsForZSet()
                        .range(setKey, offset, end))
        Set<Long> storeIds = Optional.ofNullable(redisTemplate.opsForZSet().range(setKey, offset, end))
                .orElse(Collections.emptySet())
                .stream().map(i-> (Long) i).collect(Collectors.toSet());
                .stream()
                .map(i-> (Long) i)
                .collect(Collectors.toSet());
        // 3. 获取详情数据
        List<Store> stores = Optional.ofNullable(storeService.listByIds(storeIds)).orElse(ListUtil.toList());
        // 3. 获取详情数据]
        List<Store> stores = Optional.of(storeIds)
                .filter(CollectionUtil::isNotEmpty)
                .map(storeService::listByIds)
                .orElse(ListUtil.toList());
        page.setContent(stores);
        page.setTotalElements(total);
oying-system/src/main/java/com/oying/modules/pc/store/view/CustomerStoreView.java
@@ -73,7 +73,13 @@
    @ApiModelProperty(value = "配送距离")
    private Integer deliveryDuration = 0;
    @ApiModelProperty(value = "配送时长")
    private Integer deliveryTime = 0;
    @ApiModelProperty(value = "销量")
    private Integer totalUnitsSold = 0;
    @ApiModelProperty(value = "月销售量")
    private Integer monthlySales = 0;
    private Integer monthlyUnitsSold = 0;
}
oying-system/src/main/java/com/oying/modules/security/rest/AuthController.java
@@ -11,6 +11,7 @@
import com.oying.modules.security.service.UserDetailsServiceImpl;
import com.oying.modules.security.service.WeiXinService;
import com.oying.modules.security.service.dto.AuthUserDto;
import com.oying.modules.security.service.dto.AuthUserPhoneDto;
import com.oying.modules.security.service.dto.AuthUserWeixinDto;
import com.oying.modules.security.service.dto.JwtUserDto;
import com.oying.modules.system.domain.DictDetail;
@@ -108,13 +109,51 @@
        return ResponseEntity.ok(R.success(authInfo));
    }
    @Log("短信验证码登录")
    @ApiOperation("短信验证码登录")
    @AnonymousPostMapping(value = "/login/phone")
    public ResponseEntity<Object> loginPhone(@Validated @RequestBody AuthUserPhoneDto authUser, HttpServletRequest request) {
        // 查询验证码
        String code = redisUtils.get(authUser.getUuid(), String.class);
        // 清除验证码
        redisUtils.del(authUser.getUuid());
        if (StringUtils.isBlank(code)) {
            throw new BadRequestException("验证码不存在或已过期");
        }
        if (StringUtils.isBlank(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) {
            throw new BadRequestException("验证码错误");
        }
        // 获取用户信息
        JwtUserDto jwtUser = userDetailsService.loadUserByUsername(authUser.getUsername());
        Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
        SecurityContextHolder.getContext().setAuthentication(authentication);
        // 生成令牌
        String token = tokenProvider.createToken(jwtUser);
        // 返回 token 与 用户信息
        Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
            put("token", properties.getTokenStartWith() + token);
            put("user", jwtUser);
        }};
        if (loginProperties.isSingleLogin()) {
            // 踢掉之前已经登录的token
            onlineUserService.kickOutForUsername(authUser.getUsername());
        }
        // 保存在线信息
        onlineUserService.save(jwtUser, token, request);
        // 返回登录信息
        return ResponseEntity.ok(R.success(authInfo));
    }
    public static final String OLD = "OLD";
    public static final String NEW = "NEW";
    @Log("微信授权登录")
    @ApiOperation("微信授权登录")
    @AnonymousPostMapping(value = "/login/weixin")
    public ResponseEntity<Object> loginWeixin(@Validated @RequestBody AuthUserWeixinDto authUser, HttpServletRequest request) throws Exception {
        JSONObject jsonObject;
        switch (authUser.getCode()) {
            case "OLD":
            case OLD:
                jsonObject = weiXinService.code2Session(authUser.getCode());
                String openid = jsonObject.getString("openid");
                User userDto = userService.findByOpenid(openid);
@@ -127,7 +166,7 @@
                }
                authUser.setUsername(userDto.getUsername());
                break;
            case "NEW":
            case NEW:
                jsonObject = weiXinService.getPhoneNumber(authUser.getCode());
                String phone = jsonObject.getJSONObject("phone_info").getString("purePhoneNumber");
                User user1 = userService.findByName(phone);
oying-system/src/main/java/com/oying/modules/security/service/dto/AuthUserPhoneDto.java
New file
@@ -0,0 +1,29 @@
package com.oying.modules.security.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
 * @author xin
 * @description 验证码登录
 * @date 2025/6/24 10:30
 */
@Getter
@Setter
public class AuthUserPhoneDto {
    @NotBlank
    @ApiModelProperty(value = "用户名")
    private String username;
    @NotBlank
    @ApiModelProperty(value = "验证码")
    private String code;
    @ApiModelProperty(value = "验证码的key")
    private String uuid = "";
}