优化订单详情腾讯key的提示,商品后台JPA关联优化等

This commit is contained in:
hupeng
2020-04-02 15:34:24 +08:00
parent e8e618c459
commit cc1a6b6de8
29 changed files with 182 additions and 146 deletions

View File

@ -14,5 +14,9 @@ CREATE TABLE `yx_system_store_staff` (
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='门店店员表';
ALTER TABLE `yshop`.`yx_user_recharge`
ALTER TABLE `yx_user_recharge`
ADD COLUMN `give_price` decimal(8, 2) NULL DEFAULT 0 COMMENT '赠送金额' AFTER `price`
ALTER TABLE `yx_system_attachment`
ADD COLUMN `uid` int(0) UNSIGNED NULL DEFAULT 0 COMMENT '用户id' AFTER `module_type`,
ADD COLUMN `invite_code` varchar(50) NULL DEFAULT '' COMMENT '邀请码' AFTER `uid`

View File

@ -1,47 +0,0 @@
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50723
Source Host : localhost:3306
Source Schema : yxshop
Target Server Type : MySQL
Target Server Version : 50723
File Encoding : 65001
Date: 06/03/2020 21:11:30
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for yx_system_store
-- ----------------------------
DROP TABLE IF EXISTS `yx_system_store`;
CREATE TABLE `yx_system_store` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '门店名称',
`introduction` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '简介',
`phone` char(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '手机号码',
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '省市区',
`detailed_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '详细地址',
`image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '门店logo',
`latitude` char(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '纬度',
`longitude` char(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '经度',
`valid_time` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '核销有效日期',
`day_time` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '每日营业开关时间',
`add_time` int(11) NOT NULL DEFAULT 0 COMMENT '添加时间',
`is_show` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示',
`is_del` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
`day_time_end` datetime(0) NULL DEFAULT NULL,
`day_time_start` datetime(0) NULL DEFAULT NULL,
`valid_time_end` datetime(0) NULL DEFAULT NULL,
`valid_time_start` datetime(0) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `phone`(`phone`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '门店自提' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -1,42 +0,0 @@
/*
Navicat Premium Data Transfer
Source Server : localhost
Source Server Type : MySQL
Source Server Version : 50723
Source Host : localhost:3306
Source Schema : yxshop
Target Server Type : MySQL
Target Server Version : 50723
File Encoding : 65001
Date: 06/03/2020 21:11:57
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for yx_user_recharge
-- ----------------------------
DROP TABLE IF EXISTS `yx_user_recharge`;
CREATE TABLE `yx_user_recharge` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` int(10) NULL DEFAULT NULL COMMENT '充值用户UID',
`nickname` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '',
`order_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '订单号',
`price` decimal(8, 2) NULL DEFAULT NULL COMMENT '充值金额',
`recharge_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '充值类型',
`paid` tinyint(1) NULL DEFAULT NULL COMMENT '是否充值',
`pay_time` int(10) NULL DEFAULT NULL COMMENT '充值支付时间',
`add_time` int(12) NULL DEFAULT NULL COMMENT '充值时间',
`refund_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '退款金额',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `order_id`(`order_id`) USING BTREE,
INDEX `uid`(`uid`) USING BTREE,
INDEX `recharge_type`(`recharge_type`) USING BTREE,
INDEX `paid`(`paid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户充值表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@ -41,10 +41,10 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* <p>
* 商品秒杀产品 前端控制器
* 商品秒杀产品前端控制器
* </p>
*
* @author xuwenbo
* @author hupeng
* @since 2019-12-14
*/
@Slf4j

View File

@ -1459,13 +1459,14 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
// 积分抵扣
double deductionPrice = 0;
System.out.println("a:"+userInfo.getIntegral().doubleValue());
if(useIntegral > 0 && userInfo.getIntegral().doubleValue() > 0){
Double integralMax = Double.valueOf(cacheDTO.getOther().getIntegralMax());
Double integralFull = Double.valueOf(cacheDTO.getOther().getIntegralFull());
Double integralRatio = Double.valueOf(cacheDTO.getOther().getIntegralRatio());
if(computeDTO.getTotalPrice() >= integralFull){
Double userIntegral = userInfo.getIntegral().doubleValue();
if(userIntegral >= integralMax) userIntegral = integralMax;
if(integralMax > 0 && userIntegral >= integralMax) userIntegral = integralMax;
deductionPrice = NumberUtil.mul(userIntegral, integralRatio);
if(deductionPrice < payPrice){
payPrice = NumberUtil.sub(payPrice.doubleValue(),deductionPrice);

View File

@ -450,10 +450,11 @@ public class StoreOrderController extends BaseController {
if(ObjectUtil.isNull(storeOrder)){
return ApiResult.fail("订单不存在");
}
String mapKey = RedisUtil.get("tengxun_map_key");
if(StrUtil.isBlank(mapKey)) return ApiResult.fail("请配置腾讯地图key");
//门店
if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(storeOrder.getShippingType())){
String mapKey = RedisUtil.get("tengxun_map_key");
if(StrUtil.isBlank(mapKey)) return ApiResult.fail("请配置腾讯地图key");
String apiUrl = systemConfigService.getData("api_url");
if(StrUtil.isEmpty(apiUrl)){
return ApiResult.fail("未配置api地址");

View File

@ -522,8 +522,10 @@ public class AuthController {
//设置推广关系
if (StrUtil.isNotBlank(param.getInviteCode())) {
YxSystemAttachment systemAttachment = systemAttachmentService.getByCode(param.getInviteCode());
userService.setSpread(systemAttachment.getUid(),
user.getUid());
if(systemAttachment != null){
userService.setSpread(systemAttachment.getUid(),
user.getUid());
}
}
return ApiResult.ok("注册成功");

View File

@ -1,3 +1,11 @@
/**
* Copyright (C) 2018-2019
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.shop.service.impl;
import cn.hutool.core.util.NumberUtil;

View File

@ -1,3 +1,11 @@
/**
* Copyright (C) 2018-2019
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.modules.shop.service.impl;
import co.yixiang.modules.shop.entity.YxSystemStoreStaff;

View File

@ -4,7 +4,7 @@ spring:
druid:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://localhost:3306/yshop?serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:log4jdbc:mysql://localhost:3306/yshop?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: yshop
password:

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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);
}

View File

@ -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,

View File

@ -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("演示环境禁止操作");

View File

@ -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")

View File

@ -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;
}

View File

@ -173,6 +173,8 @@ public class YxStoreOrderDTO implements Serializable {
// 门店id
private Integer storeId;
private String storeName;
// 配送方式 1=快递 2=门店自提
private Integer shippingType;

View File

@ -54,4 +54,7 @@ public class YxStoreOrderQueryCriteria{
@Query
private Integer shippingType;
@Query
private Integer storeId;
}

View File

@ -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;

View File

@ -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;
// 某种商品类型(普通商品、秒杀商品)

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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()));

View File

@ -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

View File

@ -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);

View File

@ -39,7 +39,7 @@ spring:
jpa:
hibernate:
# 生产环境设置成 none避免程序运行时自动更新数据库结构
ddl-auto: update
ddl-auto: none
show-sql: true
redis: