优化订单详情腾讯key的提示,商品后台JPA关联优化等
This commit is contained in:
@ -9,6 +9,7 @@ import lombok.Setter;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -36,6 +37,10 @@ public class YxStoreCategory implements Serializable {
|
||||
@NotBlank(message = "分类名称不能为空")
|
||||
private String cateName;
|
||||
|
||||
// @OneToMany
|
||||
// @JoinColumn(name = "cate_id")
|
||||
// private List<YxStoreProduct> storeProducts;
|
||||
|
||||
// 排序
|
||||
@Column(name = "sort",nullable = false)
|
||||
private Integer sort;
|
||||
|
@ -59,10 +59,10 @@ public class YxStoreProduct implements Serializable {
|
||||
@Column(name = "bar_code",nullable = false)
|
||||
private String barCode;
|
||||
|
||||
// 分类id
|
||||
@Column(name = "cate_id",nullable = false)
|
||||
@NotBlank(message = "请选择分类")
|
||||
private String cateId;
|
||||
|
||||
@ManyToOne(fetch=FetchType.LAZY,optional = false)
|
||||
@JoinColumn(name = "cate_id")
|
||||
private YxStoreCategory storeCategory;
|
||||
|
||||
// 商品价格
|
||||
@Column(name = "price",nullable = false)
|
||||
|
@ -23,8 +23,12 @@ public class YxStoreProductReply implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
// 用户ID
|
||||
@Column(name = "uid",nullable = false)
|
||||
private Integer uid;
|
||||
// @Column(name = "uid",nullable = false)
|
||||
// private Integer uid;
|
||||
|
||||
@ManyToOne(fetch=FetchType.LAZY,optional = false)
|
||||
@JoinColumn(name = "uid")
|
||||
private YxUser user;
|
||||
|
||||
// 订单ID
|
||||
@Column(name = "oid",nullable = false)
|
||||
@ -35,8 +39,12 @@ public class YxStoreProductReply implements Serializable {
|
||||
private String unique;
|
||||
|
||||
// 产品id
|
||||
@Column(name = "product_id",nullable = false)
|
||||
private Integer productId;
|
||||
// @Column(name = "product_id",nullable = false)
|
||||
// private Integer productId;
|
||||
|
||||
@ManyToOne(fetch=FetchType.LAZY,optional = false)
|
||||
@JoinColumn(name = "product_id")
|
||||
private YxStoreProduct storeProduct;
|
||||
|
||||
// 某种商品类型(普通商品、秒杀商品)
|
||||
@Column(name = "reply_type",nullable = false)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package co.yixiang.modules.shop.repository;
|
||||
|
||||
import co.yixiang.modules.shop.domain.YxStoreCategory;
|
||||
import co.yixiang.modules.shop.domain.YxStoreProduct;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
@ -21,5 +22,5 @@ public interface YxStoreProductRepository extends JpaRepository<YxStoreProduct,
|
||||
@Query(value = "update yx_store_product set is_del = ?1 where id = ?2",nativeQuery = true)
|
||||
void updateDel(int status, int id);
|
||||
|
||||
List<YxStoreProduct> findByCateId(String cateId);
|
||||
List<YxStoreProduct> findByStoreCategory(YxStoreCategory storeCategory);
|
||||
}
|
@ -15,10 +15,7 @@ import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStorePinkDTO;
|
||||
import co.yixiang.modules.shop.domain.YxStoreOrder;
|
||||
import co.yixiang.modules.shop.domain.YxStoreOrderStatus;
|
||||
import co.yixiang.modules.shop.service.YxExpressService;
|
||||
import co.yixiang.modules.shop.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.shop.service.YxStoreOrderStatusService;
|
||||
import co.yixiang.modules.shop.service.YxWechatUserService;
|
||||
import co.yixiang.modules.shop.service.*;
|
||||
import co.yixiang.modules.shop.service.dto.YxExpressDTO;
|
||||
import co.yixiang.modules.shop.service.dto.YxStoreOrderDTO;
|
||||
import co.yixiang.modules.shop.service.dto.YxStoreOrderQueryCriteria;
|
||||
@ -61,6 +58,7 @@ public class StoreOrderController {
|
||||
private final YxStorePinkService storePinkService;
|
||||
private final ExpressService expressService;
|
||||
|
||||
|
||||
public StoreOrderController(YxStoreOrderService yxStoreOrderService, YxStoreOrderStatusService yxStoreOrderStatusService,
|
||||
YxExpressService yxExpressService, YxWechatUserService wechatUserService,
|
||||
RedisTemplate<String, String> redisTemplate,
|
||||
|
@ -48,6 +48,7 @@ public class SystemConfigController {
|
||||
@Log("新增或修改")
|
||||
@ApiOperation(value = "新增或修改")
|
||||
@PostMapping(value = "/yxSystemConfig")
|
||||
@CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true)
|
||||
@PreAuthorize("@el.check('admin','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_CREATE')")
|
||||
public ResponseEntity create(@RequestBody String jsonStr){
|
||||
//if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作");
|
||||
|
@ -39,6 +39,15 @@ public class SystemStoreController {
|
||||
this.yxSystemStoreService = yxSystemStoreService;
|
||||
}
|
||||
|
||||
|
||||
@Log("所有门店")
|
||||
@ApiOperation("所有门店")
|
||||
@GetMapping(value = "/all")
|
||||
@PreAuthorize("@el.check('yxSystemStore:list')")
|
||||
public ResponseEntity<Object> getAll(YxSystemStoreQueryCriteria criteria) {
|
||||
return new ResponseEntity<>(yxSystemStoreService.queryAll(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
|
@ -0,0 +1,26 @@
|
||||
package co.yixiang.modules.shop.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-03
|
||||
*/
|
||||
@Data
|
||||
public class YxStoreCategorySmallDTO implements Serializable {
|
||||
|
||||
// 商品分类表ID
|
||||
private Integer id;
|
||||
|
||||
|
||||
// 分类名称
|
||||
private String cateName;
|
||||
|
||||
|
||||
|
||||
}
|
@ -173,6 +173,8 @@ public class YxStoreOrderDTO implements Serializable {
|
||||
// 门店id
|
||||
private Integer storeId;
|
||||
|
||||
private String storeName;
|
||||
|
||||
// 配送方式 1=快递 ,2=门店自提
|
||||
private Integer shippingType;
|
||||
|
||||
|
@ -54,4 +54,7 @@ public class YxStoreOrderQueryCriteria{
|
||||
|
||||
@Query
|
||||
private Integer shippingType;
|
||||
|
||||
@Query
|
||||
private Integer storeId;
|
||||
}
|
@ -40,7 +40,9 @@ public class YxStoreProductDTO implements Serializable {
|
||||
// 分类id
|
||||
private String cateId;
|
||||
|
||||
private String cateName;
|
||||
//private String cateName;
|
||||
|
||||
private YxStoreCategorySmallDTO storeCategory;
|
||||
|
||||
// 商品价格
|
||||
private BigDecimal price;
|
||||
|
@ -18,7 +18,7 @@ public class YxStoreProductReplyDTO implements Serializable {
|
||||
// 用户ID
|
||||
private Integer uid;
|
||||
|
||||
private String username;
|
||||
private YxUserSmallDTO user;
|
||||
|
||||
// 订单ID
|
||||
private Integer oid;
|
||||
@ -29,7 +29,7 @@ public class YxStoreProductReplyDTO implements Serializable {
|
||||
// 产品id
|
||||
private Integer productId;
|
||||
|
||||
private String productName;
|
||||
private YxStoreProductSmallDTO storeProduct;
|
||||
|
||||
|
||||
// 某种商品类型(普通商品、秒杀商品)
|
||||
|
@ -0,0 +1,27 @@
|
||||
package co.yixiang.modules.shop.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-04
|
||||
*/
|
||||
@Data
|
||||
public class YxStoreProductSmallDTO implements Serializable {
|
||||
|
||||
// 商品id
|
||||
private Integer id;
|
||||
|
||||
// 商品图片
|
||||
private String image;
|
||||
|
||||
|
||||
// 商品名称
|
||||
private String storeName;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package co.yixiang.modules.shop.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-06
|
||||
*/
|
||||
@Data
|
||||
public class YxUserSmallDTO implements Serializable {
|
||||
|
||||
// 用户id
|
||||
private Integer uid;
|
||||
|
||||
// 用户昵称
|
||||
private String nickname;
|
||||
|
||||
// 用户头像
|
||||
private String avatar;
|
||||
|
||||
// 手机号码
|
||||
private String phone;
|
||||
|
||||
|
||||
}
|
@ -107,9 +107,12 @@ public class YxStoreCategoryServiceImpl implements YxStoreCategoryService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Integer id) {
|
||||
YxStoreCategory storeCategory = yxStoreCategoryRepository.findByPid(id);
|
||||
if(storeCategory != null) throw new BadRequestException("请先删除子类");
|
||||
|
||||
List<YxStoreProduct> storeProduct = yxStoreProductRepository.findByCateId(String.valueOf(id));
|
||||
if(storeCategory != null) throw new BadRequestException("请先删除子类");
|
||||
YxStoreCategory category = new YxStoreCategory();
|
||||
category.setId(id);
|
||||
List<YxStoreProduct> storeProduct = yxStoreProductRepository.findByStoreCategory(category);
|
||||
|
||||
if(!storeProduct.isEmpty()) throw new BadRequestException("此分类下有商品,不能删除");
|
||||
|
||||
yxStoreCategoryRepository.deleteById(id);
|
||||
|
@ -15,10 +15,7 @@ import co.yixiang.modules.shop.domain.YxUserBill;
|
||||
import co.yixiang.modules.shop.repository.YxStoreOrderCartInfoRepository;
|
||||
import co.yixiang.modules.shop.repository.YxStoreOrderRepository;
|
||||
import co.yixiang.modules.shop.repository.YxUserRepository;
|
||||
import co.yixiang.modules.shop.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.shop.service.YxStoreOrderStatusService;
|
||||
import co.yixiang.modules.shop.service.YxUserBillService;
|
||||
import co.yixiang.modules.shop.service.YxUserService;
|
||||
import co.yixiang.modules.shop.service.*;
|
||||
import co.yixiang.modules.shop.service.dto.*;
|
||||
import co.yixiang.modules.shop.service.mapper.YxStoreOrderMapper;
|
||||
import co.yixiang.mp.service.YxMiniPayService;
|
||||
@ -59,10 +56,11 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
private final YxUserService userService;
|
||||
private final YxPayService payService;
|
||||
private final YxMiniPayService miniPayService;
|
||||
private final YxSystemStoreService systemStoreService;
|
||||
|
||||
public YxStoreOrderServiceImpl(YxStoreOrderRepository yxStoreOrderRepository, YxStoreOrderCartInfoRepository yxStoreOrderCartInfoRepository, YxUserRepository userRepository,
|
||||
YxStorePinkRepository storePinkRepository, YxStoreOrderMapper yxStoreOrderMapper, YxUserBillService yxUserBillService,
|
||||
YxStoreOrderStatusService yxStoreOrderStatusService,
|
||||
YxStoreOrderStatusService yxStoreOrderStatusService, YxSystemStoreService systemStoreService,
|
||||
YxUserService userService, YxPayService payService, YxMiniPayService miniPayService) {
|
||||
this.yxStoreOrderRepository = yxStoreOrderRepository;
|
||||
this.yxStoreOrderCartInfoRepository = yxStoreOrderCartInfoRepository;
|
||||
@ -74,6 +72,7 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
this.userService = userService;
|
||||
this.payService = payService;
|
||||
this.miniPayService = miniPayService;
|
||||
this.systemStoreService = systemStoreService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -223,10 +222,16 @@ public class YxStoreOrderServiceImpl implements YxStoreOrderService {
|
||||
Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(),yxStoreOrder.getStatus(),
|
||||
yxStoreOrder.getRefundStatus());
|
||||
|
||||
if(yxStoreOrder.getStoreId() > 0) {
|
||||
String storeName = systemStoreService.findById(yxStoreOrder.getStoreId()).getName();
|
||||
yxStoreOrderDTO.setStoreName(storeName);
|
||||
}
|
||||
|
||||
//订单状态
|
||||
String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid()
|
||||
,yxStoreOrder.getStatus(),yxStoreOrder.getShippingType()
|
||||
,yxStoreOrder.getRefundStatus());
|
||||
|
||||
if(_status == 3){
|
||||
String refundTime = OrderUtil.stampToDate(String.valueOf(yxStoreOrder
|
||||
.getRefundReasonTime()));
|
||||
|
@ -8,6 +8,7 @@ import co.yixiang.modules.shop.service.YxUserService;
|
||||
import co.yixiang.modules.shop.service.dto.YxStoreProductReplyDTO;
|
||||
import co.yixiang.modules.shop.service.dto.YxStoreProductReplyQueryCriteria;
|
||||
import co.yixiang.modules.shop.service.mapper.YxStoreProductReplyMapper;
|
||||
import co.yixiang.utils.PageUtil;
|
||||
import co.yixiang.utils.QueryHelp;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import org.springframework.data.domain.Page;
|
||||
@ -43,25 +44,8 @@ public class YxStoreProductReplyServiceImpl implements YxStoreProductReplyServic
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(YxStoreProductReplyQueryCriteria criteria, Pageable pageable){
|
||||
Page<YxStoreProductReply> page = yxStoreProductReplyRepository
|
||||
.findAll((root, criteriaQuery, criteriaBuilder)
|
||||
-> QueryHelp.getPredicate(root,criteria,criteriaBuilder)
|
||||
,pageable);
|
||||
List<YxStoreProductReplyDTO> productReplyDTOS = new ArrayList<>();
|
||||
for (YxStoreProductReply reply : page.getContent()) {
|
||||
YxStoreProductReplyDTO productReplyDTO = yxStoreProductReplyMapper.toDto(reply);
|
||||
try{
|
||||
productReplyDTO.setUsername(userService.findById(reply.getUid()).getAccount());
|
||||
productReplyDTO.setProductName(productService.findById(reply.getProductId()).getStoreName());
|
||||
}catch (Exception e){
|
||||
continue;
|
||||
}
|
||||
productReplyDTOS.add(productReplyDTO);
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content",productReplyDTOS);
|
||||
map.put("totalElements",page.getTotalElements());
|
||||
return map;
|
||||
Page<YxStoreProductReply> page = yxStoreProductReplyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(yxStoreProductReplyMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,11 +65,9 @@ public class YxStoreProductServiceImpl implements YxStoreProductService {
|
||||
,pageable);
|
||||
List<YxStoreProductDTO> storeProductDTOS = new ArrayList<>();
|
||||
for (YxStoreProduct product : page.getContent()) {
|
||||
if(StrUtil.isEmpty(product.getCateId())) continue;
|
||||
String cateName = yxStoreCategoryRepository
|
||||
.findNameById(Integer.valueOf(product.getCateId()));
|
||||
|
||||
YxStoreProductDTO yxStoreProductDTO = yxStoreProductMapper.toDto(product);
|
||||
yxStoreProductDTO.setCateName(cateName);
|
||||
|
||||
//规格属性库存
|
||||
Integer newStock = yxStoreProductAttrValueRepository.sumStock(product.getId());
|
||||
if(newStock != null) yxStoreProductDTO.setStock(newStock);
|
||||
|
Reference in New Issue
Block a user