拼团后端添加对属性的操作
This commit is contained in:
116
sql/yx_store_combination_update.sql
Normal file
116
sql/yx_store_combination_update.sql
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : 本地
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 50729
|
||||
Source Host : localhost:3306
|
||||
Source Schema : yshopb2c
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 50729
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 19/08/2020 17:07:08
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for yx_store_combination
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `yx_store_combination`;
|
||||
CREATE TABLE `yx_store_combination` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`product_id` bigint(20) UNSIGNED NOT NULL COMMENT '商品id',
|
||||
`mer_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '商户id',
|
||||
`image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '推荐图',
|
||||
`images` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '轮播图',
|
||||
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '活动标题',
|
||||
`attr` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '活动属性',
|
||||
`people` int(2) UNSIGNED NOT NULL COMMENT '参团人数',
|
||||
`info` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '简介',
|
||||
`price` decimal(10, 2) UNSIGNED NOT NULL COMMENT '价格',
|
||||
`product_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '商品原价',
|
||||
`sort` int(10) UNSIGNED NOT NULL COMMENT '排序',
|
||||
`sales` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '销量',
|
||||
`stock` int(10) UNSIGNED NOT NULL COMMENT '库存',
|
||||
`create_time` datetime(0) NOT NULL COMMENT '添加时间',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL,
|
||||
`is_host` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '推荐',
|
||||
`is_show` tinyint(1) UNSIGNED NOT NULL COMMENT '产品状态',
|
||||
`is_del` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
|
||||
`combination` tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
|
||||
`mer_use` tinyint(1) UNSIGNED NULL DEFAULT NULL COMMENT '商户是否可用1可用0不可用',
|
||||
`description` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '拼团内容',
|
||||
`start_time` datetime(0) NOT NULL COMMENT '拼团开始时间',
|
||||
`stop_time` datetime(0) NOT NULL COMMENT '拼团结束时间',
|
||||
`effective_time` int(11) NOT NULL DEFAULT 0 COMMENT '拼团订单有效时间',
|
||||
`cost` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '拼图产品成本',
|
||||
`browse` int(11) NULL DEFAULT 0 COMMENT '浏览量',
|
||||
`unit_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '单位名',
|
||||
`spec_type` tinyint(1) NULL DEFAULT NULL COMMENT '规格 0单 1多',
|
||||
`temp_id` int(10) NULL DEFAULT NULL COMMENT '运费模板ID',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '拼团产品表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of yx_store_combination
|
||||
-- ----------------------------
|
||||
INSERT INTO `yx_store_combination` VALUES (1, 19, 0, 'https://image.dayouqiantu.cn/5ca011a1cd487.jpg', 'https://image.dayouqiantu.cn/5ca01c7fc9238.jpg,https://image.dayouqiantu.cn/5ca01c7676042.jpg', '70gA4黑白打印复印', NULL, 2, '打印复印资料A4黑白彩色印刷画册书本装订图文数码快印服务', 0.10, 100.00, 1, 55, 94, '2020-06-19 16:55:51', '2020-06-25 23:00:45', 1, 1, 0, 1, 0, '1577289600', '2020-06-19 16:55:21', '2020-07-01 16:55:25', 10, 1, 1, '张', NULL, NULL);
|
||||
INSERT INTO `yx_store_combination` VALUES (2, 24, 0, 'https://image.dayouqiantu.cn/5ca011a1cd487.jpg', 'https://image.dayouqiantu.cn/5ca011a1cd487.jpg', '彩色打印', NULL, 1, '彩色打印', 0.00, NULL, 0, 10, 10, '2020-06-25 23:02:07', NULL, 1, 1, 0, 1, NULL, '<p>彩色打印</p>', '2020-06-25 23:01:21', '2020-06-30 00:00:00', 24, 0, 0, '张', NULL, NULL);
|
||||
INSERT INTO `yx_store_combination` VALUES (3, 29, 0, 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg', 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg,https://image.dayouqiantu.cn/5ca081af6183f.jpg', '喷绘写真', NULL, 1, '喷绘写真', 0.00, NULL, 0, 0, 331, '2020-07-05 12:23:41', NULL, 1, 1, 0, 1, NULL, '<p>喷绘写真</p>', '2020-07-05 12:23:19', '2020-07-29 00:00:00', 24, 0, 0, '平方', NULL, NULL);
|
||||
INSERT INTO `yx_store_combination` VALUES (4, 29, 0, 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg', 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg,https://image.dayouqiantu.cn/5ca081af6183f.jpg', 'qwewq', NULL, 3, 'eqweq', 7.00, NULL, 0, 13, 318, '2020-08-19 15:00:28', NULL, 0, 1, 0, 1, NULL, '<p>测试拼团</p><p><img src=\"http://127.0.0.1:8001/file/pic/20200811184905881166.png\"/></p>', '2020-08-19 14:49:36', '2020-08-28 00:00:00', 33, 0, 0, 'weqweqw', 1, NULL);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for yx_store_product_attr_value
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `yx_store_product_attr_value`;
|
||||
CREATE TABLE `yx_store_product_attr_value` (
|
||||
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`product_id` bigint(20) UNSIGNED NOT NULL COMMENT '商品ID',
|
||||
`sku` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '商品属性索引值 (attr_value|attr_value[|....])',
|
||||
`stock` int(10) UNSIGNED NOT NULL COMMENT '属性对应的库存',
|
||||
`sales` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '销量',
|
||||
`price` decimal(8, 2) UNSIGNED NOT NULL COMMENT '属性金额',
|
||||
`image` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图片',
|
||||
`unique` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '唯一值',
|
||||
`cost` decimal(8, 2) UNSIGNED NOT NULL COMMENT '成本价',
|
||||
`bar_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品条码',
|
||||
`ot_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '原价',
|
||||
`weight` decimal(8, 2) NOT NULL DEFAULT 0.00 COMMENT '重量',
|
||||
`volume` decimal(8, 2) NOT NULL DEFAULT 0.00 COMMENT '体积',
|
||||
`brokerage` decimal(8, 2) NOT NULL DEFAULT 0.00 COMMENT '一级返佣',
|
||||
`brokerage_two` decimal(8, 2) NOT NULL DEFAULT 0.00 COMMENT '二级返佣',
|
||||
`pink_price` decimal(8, 2) NULL DEFAULT NULL COMMENT '拼团价',
|
||||
`pink_stock` int(10) NULL DEFAULT NULL COMMENT '拼团库存',
|
||||
`seckill_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '秒杀价',
|
||||
`seckill_stock` int(10) NULL DEFAULT NULL COMMENT '秒杀库存',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `unique`(`unique`, `sku`) USING BTREE,
|
||||
INDEX `store_id`(`product_id`, `sku`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '商品属性值表' ROW_FORMAT = DYNAMIC;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of yx_store_product_attr_value
|
||||
-- ----------------------------
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (58, 28, '默认', 81, 19, 20.00, '', 'cc6bb7e388e54f65838e2635ae9ea0c7', 0.00, '', 0.00, 0.00, 0.00, 2.00, 1.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (60, 30, 'A4,白色', 2997, 0, 100.00, 'http://127.0.0.1:8001/file/pic/20200811184905881166.png', 'e22b36751d804f689c3b8f2890ddebb7', 1.00, '12312313', 200.00, 12.00, 12.00, 0.00, 0.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (61, 30, 'A4,红色', 0, 0, 0.00, 'http://127.0.0.1:8001/file/pic/20200811184905881166.png', '73aaf055b62543159f34a63b5ba08d12', 0.00, '', 0.00, 0.00, 0.00, 0.00, 0.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (62, 30, 'A3,白色', 0, 0, 0.00, 'http://127.0.0.1:8001/file/pic/20200811184905881166.png', '2f35645a0e5e4cc2aa852347a76ad8a9', 0.00, '', 0.00, 0.00, 0.00, 0.00, 0.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (63, 30, 'A3,红色', 0, 0, 0.00, 'http://127.0.0.1:8001/file/pic/20200811184905881166.png', '9b0ba66b83b1423a8bf54332513ba1fa', 0.00, '', 0.00, 0.00, 0.00, 0.00, 0.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (72, 29, 'A4,白色', 87, 0, 10.00, 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg', 'de1c221ef2a447e3b507cd095b17d76e', 0.00, '', 10.00, 0.00, 0.00, 1.00, 1.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (73, 29, 'A4,红色', 88, 0, 9.00, 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg', '55b272f734ab4572bd085c456a54eb32', 0.00, '', 10.00, 0.00, 0.00, 1.00, 1.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (74, 29, 'A3,白色', 77, 0, 8.00, 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg', '560be687e9b942c4adb9cf83c2fa158e', 0.00, '', 10.00, 0.00, 0.00, 1.00, 1.00, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `yx_store_product_attr_value` VALUES (75, 29, 'A3,红色', 66, 0, 7.00, 'https://image.dayouqiantu.cn/5ca0786c5d2c1.jpg', '2fdd28d9c98f4e2f9406ed56e81df7c5', 0.00, '', 10.00, 0.00, 0.00, 1.00, 1.00, NULL, NULL, NULL, NULL);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
-- 菜单
|
||||
INSERT INTO `menu` VALUES (244, b'0', '拼团商品添加', 'activity/combination/form', 63, 999, NULL, 'combinationAdd', b'0', b'1', 'CombinationAdd', '2020-08-13 21:28:45', 'YXSTORECOMBINATION_EDIT', 1, '2020-08-13 21:31:26', 0);
|
||||
INSERT INTO `menu` VALUES (245, b'0', '拼团商品修改', 'activity/combination/form', 63, 3, 'anq', 'combinationEdit/:id', b'0', b'1', 'CombinationEdit', '2019-12-24 13:02:23', 'YXSTORECOMBINATION_EDIT', 1, '2020-07-10 16:45:33', 0);
|
||||
|
||||
-- 菜单角色的关系
|
||||
INSERT INTO `roles_menus` VALUES (244, 1);
|
||||
INSERT INTO `roles_menus` VALUES (245, 1);
|
@ -0,0 +1,15 @@
|
||||
package co.yixiang.annotation;
|
||||
|
||||
import co.yixiang.enums.DataSourceType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataSource {
|
||||
/**
|
||||
* 切换数据源名称
|
||||
*/
|
||||
DataSourceType value() default DataSourceType.MASTER;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package co.yixiang.aspect;
|
||||
|
||||
import co.yixiang.annotation.DataSource;
|
||||
import co.yixiang.config.datasource.DynamicDataSourceContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Aspect
|
||||
@Order(1)
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DataSourceAspect {
|
||||
|
||||
@Pointcut("@annotation(co.yixiang.annotation.DataSource)")
|
||||
public void dsPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("dsPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
DataSource dataSource = method.getAnnotation(DataSource.class);
|
||||
if (dataSource != null) {
|
||||
DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name());
|
||||
}
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
// 销毁数据源 在执行方法之后
|
||||
DynamicDataSourceContextHolder.clearDataSourceType();
|
||||
}
|
||||
}
|
||||
}
|
@ -49,4 +49,8 @@ public class SystemConfigConstants {
|
||||
public final static String WX_NATIVE_APP_APPID="wx_native_app_appId";
|
||||
public final static String EXP_APPID = "exp_appId";
|
||||
|
||||
|
||||
//播放状态变化事件,detail = {code}
|
||||
public static final String BINDSTATECHANGE = "bindstatechange";
|
||||
|
||||
}
|
||||
|
@ -8,14 +8,19 @@ package co.yixiang.modules.activity.domain;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import co.yixiang.domain.BaseDomain;
|
||||
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
@ -105,14 +110,6 @@ public class YxStoreCombination extends BaseDomain {
|
||||
private Integer merUse;
|
||||
|
||||
|
||||
/** 是否包邮1是0否 */
|
||||
private Integer isPostage;
|
||||
|
||||
|
||||
/** 邮费 */
|
||||
private BigDecimal postage;
|
||||
|
||||
|
||||
/** 拼团内容 */
|
||||
@NotBlank(message = "请填写详情")
|
||||
private String description;
|
||||
@ -145,10 +142,23 @@ public class YxStoreCombination extends BaseDomain {
|
||||
/** 单位名 */
|
||||
private String unitName;
|
||||
|
||||
private Integer specType;
|
||||
|
||||
/** 运费模板ID */
|
||||
@JsonProperty("temp_id")
|
||||
private Long tempId;
|
||||
//属性项目
|
||||
@TableField(exist = false)
|
||||
private List<FromatDetailDto> items;
|
||||
|
||||
//sku结果集
|
||||
@TableField(exist = false)
|
||||
private List<Map<String,Object>> attrs;
|
||||
|
||||
|
||||
|
||||
public void copy(YxStoreCombination source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,4 +92,6 @@ public interface YxStoreCombinationService extends BaseService<YxStoreCombinati
|
||||
* @param status ShopCommonEnum
|
||||
*/
|
||||
void onSale(Long id, Integer status);
|
||||
|
||||
boolean saveCombination(YxStoreCombinationDto resources);
|
||||
}
|
||||
|
@ -5,18 +5,28 @@
|
||||
*/
|
||||
package co.yixiang.modules.activity.service.dto;
|
||||
|
||||
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class YxStoreCombinationDto implements Serializable {
|
||||
|
||||
private Long id;
|
||||
@ -30,9 +40,12 @@ public class YxStoreCombinationDto implements Serializable {
|
||||
// 推荐图
|
||||
private String image;
|
||||
|
||||
// 轮播图
|
||||
private String images;
|
||||
|
||||
/** 轮播图 */
|
||||
@JsonProperty("slider_image")
|
||||
private List<String> sliderImage;
|
||||
|
||||
//参与人数
|
||||
private Integer countPeopleAll;
|
||||
|
||||
@ -45,9 +58,6 @@ public class YxStoreCombinationDto implements Serializable {
|
||||
// 活动标题
|
||||
private String title;
|
||||
|
||||
// 活动属性
|
||||
private String attr;
|
||||
|
||||
// 参团人数
|
||||
private Integer people;
|
||||
|
||||
@ -109,4 +119,15 @@ public class YxStoreCombinationDto implements Serializable {
|
||||
// 单位名
|
||||
private String unitName;
|
||||
|
||||
/** 规格 0单 1多 */
|
||||
@JsonProperty("spec_type")
|
||||
private Integer specType;
|
||||
|
||||
private ProductFormatDto attr;
|
||||
//属性项目
|
||||
private List<FromatDetailDto> items;
|
||||
|
||||
//sku结果集
|
||||
private List<Map<String,Object>> attrs;
|
||||
|
||||
}
|
||||
|
@ -8,11 +8,15 @@
|
||||
*/
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import co.yixiang.api.YshopException;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.utils.QueryHelpPlus;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.enums.ShopCommonEnum;
|
||||
import co.yixiang.enums.SpecTypeEnum;
|
||||
import co.yixiang.modules.activity.domain.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.domain.YxStorePink;
|
||||
import co.yixiang.modules.activity.domain.YxStoreVisit;
|
||||
@ -26,7 +30,13 @@ import co.yixiang.modules.activity.service.mapper.YxStorePinkMapper;
|
||||
import co.yixiang.modules.activity.service.mapper.YxStoreVisitMapper;
|
||||
import co.yixiang.modules.activity.vo.StoreCombinationVo;
|
||||
import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo;
|
||||
import co.yixiang.modules.product.domain.YxStoreProduct;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrValueService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductReplyService;
|
||||
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||
import co.yixiang.modules.product.service.dto.ProductResultDto;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -39,6 +49,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@ -48,7 +59,7 @@ import java.util.*;
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombinationMapper, YxStoreCombination> implements YxStoreCombinationService {
|
||||
|
||||
@Autowired
|
||||
@ -65,6 +76,10 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
||||
private YxStoreProductReplyService replyService;
|
||||
@Autowired
|
||||
private YxStorePinkService storePinkService;
|
||||
@Autowired
|
||||
private YxStoreProductAttrService yxStoreProductAttrService;
|
||||
@Autowired
|
||||
private YxStoreProductAttrValueService yxStoreProductAttrValueService;
|
||||
|
||||
|
||||
/**
|
||||
@ -213,7 +228,6 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
||||
map.put("推荐图", yxStoreCombination.getImage());
|
||||
map.put("轮播图", yxStoreCombination.getImages());
|
||||
map.put("活动标题", yxStoreCombination.getTitle());
|
||||
map.put("活动属性", yxStoreCombination.getAttr());
|
||||
map.put("参团人数", yxStoreCombination.getPeople());
|
||||
map.put("简介", yxStoreCombination.getInfo());
|
||||
map.put("价格", yxStoreCombination.getPrice());
|
||||
@ -255,4 +269,99 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
||||
yxStoreCombination.setId(id);
|
||||
this.saveOrUpdate(yxStoreCombination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveCombination(YxStoreCombinationDto resources) {
|
||||
ProductResultDto resultDTO = this.computedProduct(resources.getAttrs());
|
||||
|
||||
//添加商品
|
||||
YxStoreCombination yxStoreCombination = new YxStoreCombination();
|
||||
BeanUtil.copyProperties(resources,yxStoreCombination,"images");
|
||||
if(resources.getImages().isEmpty()) throw new YshopException("请上传轮播图");
|
||||
|
||||
yxStoreCombination.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice()));
|
||||
yxStoreCombination.setCost(resultDTO.getMinCost().intValue());
|
||||
yxStoreCombination.setStock(resultDTO.getStock());
|
||||
yxStoreCombination.setImages(String.join(",", resources.getImages()));
|
||||
this.saveOrUpdate(yxStoreCombination);
|
||||
|
||||
//属性处理
|
||||
//处理单sKu
|
||||
if(SpecTypeEnum.TYPE_0.getValue().equals(resources.getSpecType())){
|
||||
FromatDetailDto fromatDetailDto = FromatDetailDto.builder()
|
||||
.value("规格")
|
||||
.detailValue("")
|
||||
.attrHidden("")
|
||||
.detail(ListUtil.toList("默认"))
|
||||
.build();
|
||||
List<Map<String,Object>> attrs = resources.getAttrs();
|
||||
Map<String,Object> map = attrs.get(0);
|
||||
map.put("value1","规格");
|
||||
map.put("detail", MapUtil.of(new String[][] {
|
||||
{"规格", "默认"}
|
||||
}));
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto),
|
||||
ListUtil.toList(map),resources.getProductId());
|
||||
}else{
|
||||
yxStoreProductAttrService.insertYxStoreProductAttr(resources.getItems(),
|
||||
resources.getAttrs(),resources.getProductId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算产品数据
|
||||
* @param attrs attrs
|
||||
* @return ProductResultDto
|
||||
*/
|
||||
private ProductResultDto computedProduct(List<Map<String,Object>> attrs){
|
||||
//取最小价格
|
||||
Double minPrice = ListMapToListBean(attrs)
|
||||
.stream()
|
||||
.map(ProductFormatDto::getPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minOtPrice = ListMapToListBean(attrs)
|
||||
.stream()
|
||||
.map(ProductFormatDto::getOtPrice)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
|
||||
Double minCost = ListMapToListBean(attrs)
|
||||
.stream()
|
||||
.map(ProductFormatDto::getCost)
|
||||
.min(Comparator.naturalOrder())
|
||||
.orElse(0d);
|
||||
//计算库存
|
||||
Integer stock = ListMapToListBean(attrs)
|
||||
.stream()
|
||||
.map(ProductFormatDto::getStock)
|
||||
.reduce(Integer::sum)
|
||||
.orElse(0);
|
||||
|
||||
if(stock <= 0) throw new YshopException("库存不能低于0");
|
||||
|
||||
return ProductResultDto.builder()
|
||||
.minPrice(minPrice)
|
||||
.minOtPrice(minOtPrice)
|
||||
.minCost(minCost)
|
||||
.stock(stock)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* mapTobean
|
||||
* @param listMap listMap
|
||||
* @return list
|
||||
*/
|
||||
private List<ProductFormatDto> ListMapToListBean(List<Map<String, Object>> listMap){
|
||||
List<ProductFormatDto> list = new ArrayList<>();
|
||||
// 循环遍历出map对象
|
||||
for (Map<String, Object> m : listMap) {
|
||||
list.add(BeanUtil.mapToBean(m,ProductFormatDto.class,true));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,11 @@ public class YxStoreProductAttrValue implements Serializable {
|
||||
/** 属性对应的库存 */
|
||||
private Integer stock;
|
||||
|
||||
/** 拼团库存属性对应的库存 */
|
||||
private Integer pinkStock;
|
||||
|
||||
/** 秒杀库存属性对应的库存 */
|
||||
private Integer seckillStock;
|
||||
|
||||
/** 销量 */
|
||||
private Integer sales;
|
||||
@ -51,7 +56,11 @@ public class YxStoreProductAttrValue implements Serializable {
|
||||
/** 属性金额 */
|
||||
private BigDecimal price;
|
||||
|
||||
/** 拼团属性对应的金额 */
|
||||
private BigDecimal pinkPrice;
|
||||
|
||||
/** 秒杀属性对应的金额 */
|
||||
private BigDecimal seckillPrice;
|
||||
/** 图片 */
|
||||
private String image;
|
||||
|
||||
|
@ -126,7 +126,7 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
|
||||
* @param jsonStr jsonStr
|
||||
* @return map
|
||||
*/
|
||||
Map<String,Object> getFormatAttr(Long id, String jsonStr);
|
||||
Map<String,Object> getFormatAttr(Long id, String jsonStr,boolean isActivity);
|
||||
|
||||
|
||||
|
||||
|
@ -50,6 +50,14 @@ public class ProductFormatDto {
|
||||
|
||||
private Double weight = 0d;
|
||||
|
||||
private Double pinkPrice = 0d;
|
||||
|
||||
private Integer pinkStock = 0;
|
||||
|
||||
private Double seckillPrice = 0d;
|
||||
|
||||
private Integer seckillStock = 0;
|
||||
|
||||
private Map<String, String> detail;
|
||||
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
* @return map
|
||||
*/
|
||||
@Override
|
||||
public Map<String,Object> getFormatAttr(Long id, String jsonStr) {
|
||||
public Map<String,Object> getFormatAttr(Long id, String jsonStr,boolean isActivity) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
Map<String,Object> resultMap = new LinkedHashMap<>(3);
|
||||
|
||||
@ -588,7 +588,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
|
||||
}
|
||||
|
||||
this.addMap(headerMap,headerMapList,align);
|
||||
this.addMap(headerMap,headerMapList,align,isActivity);
|
||||
|
||||
|
||||
resultMap.put("attr",fromatDetailDTOList);
|
||||
@ -664,7 +664,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
* @param headerMapList headerMapList
|
||||
* @param align align
|
||||
*/
|
||||
private void addMap(Map<String,Object> headerMap,List<Map<String,Object>> headerMapList,String align){
|
||||
private void addMap(Map<String,Object> headerMap,List<Map<String,Object>> headerMapList,String align,boolean isActivity){
|
||||
headerMap.put("title","图片");
|
||||
headerMap.put("slot", "pic");
|
||||
headerMap.put("align",align);
|
||||
@ -711,7 +711,32 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
||||
headerMap.put("slot", "volume");
|
||||
headerMap.put("align",align);
|
||||
headerMap.put("minWidth",140);
|
||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||
|
||||
if(isActivity){
|
||||
headerMap.put("title","拼团价");
|
||||
headerMap.put("slot", "pinkPrice");
|
||||
headerMap.put("align",align);
|
||||
headerMap.put("minWidth",140);
|
||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||
|
||||
headerMap.put("title","拼团活动库存");
|
||||
headerMap.put("slot", "pinkStock");
|
||||
headerMap.put("align",align);
|
||||
headerMap.put("minWidth",140);
|
||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||
|
||||
headerMap.put("title","秒杀价");
|
||||
headerMap.put("slot", "seckillPrice");
|
||||
headerMap.put("align",align);
|
||||
headerMap.put("minWidth",140);
|
||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||
|
||||
headerMap.put("title","秒杀活动库存");
|
||||
headerMap.put("slot", "seckillStock");
|
||||
headerMap.put("align",align);
|
||||
headerMap.put("minWidth",140);
|
||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||
}
|
||||
|
||||
headerMap.put("title","操作");
|
||||
headerMap.put("slot", "action");
|
||||
|
@ -5,15 +5,25 @@
|
||||
*/
|
||||
package co.yixiang.modules.activity.rest;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.enums.SpecTypeEnum;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.activity.domain.YxStoreCombination;
|
||||
import co.yixiang.modules.activity.service.YxStoreCombinationService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreCombinationDto;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreCombinationQueryCriteria;
|
||||
import co.yixiang.modules.aop.ForbidSubmit;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import co.yixiang.modules.product.domain.YxStoreProductAttrResult;
|
||||
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
||||
import co.yixiang.modules.product.service.YxStoreProductRuleService;
|
||||
import co.yixiang.modules.product.service.dto.ProductDto;
|
||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@ -30,6 +40,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-11-18
|
||||
@ -40,9 +52,14 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class StoreCombinationController {
|
||||
|
||||
private final YxStoreCombinationService yxStoreCombinationService;
|
||||
|
||||
public StoreCombinationController(YxStoreCombinationService yxStoreCombinationService) {
|
||||
private final YxShippingTemplatesService yxShippingTemplatesService;
|
||||
private final YxStoreProductRuleService yxStoreProductRuleService;
|
||||
private final YxStoreProductAttrResultService yxStoreProductAttrResultService;
|
||||
public StoreCombinationController(YxStoreCombinationService yxStoreCombinationService, YxShippingTemplatesService yxShippingTemplatesService, YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrResultService yxStoreProductAttrResultService) {
|
||||
this.yxStoreCombinationService = yxStoreCombinationService;
|
||||
this.yxShippingTemplatesService = yxShippingTemplatesService;
|
||||
this.yxStoreProductRuleService = yxStoreProductRuleService;
|
||||
this.yxStoreProductAttrResultService = yxStoreProductAttrResultService;
|
||||
}
|
||||
|
||||
@Log("查询拼团")
|
||||
@ -54,7 +71,79 @@ public class StoreCombinationController {
|
||||
}
|
||||
|
||||
|
||||
@Log("新增拼团")
|
||||
@ApiOperation(value = "新增拼团")
|
||||
@PostMapping(value = "/yxStoreCombination")
|
||||
@PreAuthorize("hasAnyRole('admin','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_EDIT')")
|
||||
public ResponseEntity add(@Validated @RequestBody YxStoreCombinationDto resources){
|
||||
return new ResponseEntity<>(yxStoreCombinationService.saveCombination(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商品信息")
|
||||
@GetMapping(value = "/yxStoreCombination/info/{id}")
|
||||
public ResponseEntity info(@PathVariable Long id){
|
||||
Map<String,Object> map = new LinkedHashMap<>(3);
|
||||
|
||||
//运费模板
|
||||
List<YxShippingTemplates> shippingTemplatesList = yxShippingTemplatesService.list();
|
||||
map.put("tempList", shippingTemplatesList);
|
||||
|
||||
// //商品分类
|
||||
// List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
|
||||
// .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||
// .list();
|
||||
|
||||
// List<Map<String,Object>> cateList = new ArrayList<>();
|
||||
// map.put("cateList", this.makeCate(storeCategories,cateList,0,1));
|
||||
|
||||
//商品规格
|
||||
map.put("ruleList",yxStoreProductRuleService.list());
|
||||
|
||||
|
||||
if(id == 0){
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
}
|
||||
|
||||
//处理商品详情
|
||||
YxStoreCombination yxStoreCombination = yxStoreCombinationService.getById(id);
|
||||
YxStoreCombinationDto productDto = new YxStoreCombinationDto();
|
||||
BeanUtil.copyProperties(yxStoreCombination,productDto,"images");
|
||||
productDto.setSliderImage(Arrays.asList(yxStoreCombination.getImages().split(",")));
|
||||
YxStoreProductAttrResult storeProductAttrResult = yxStoreProductAttrResultService
|
||||
.getOne(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
||||
.eq(YxStoreProductAttrResult::getProductId,yxStoreCombination.getProductId()).last("limit 1"));
|
||||
JSONObject result = JSON.parseObject(storeProductAttrResult.getResult());
|
||||
|
||||
if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreCombination.getSpecType())){
|
||||
productDto.setAttr(new ProductFormatDto());
|
||||
productDto.setAttrs(result.getObject("value",ArrayList.class));
|
||||
productDto.setItems(result.getObject("attr",ArrayList.class));
|
||||
}else{
|
||||
Map<String,Object> mapAttr = (Map<String,Object>)result.getObject("value",ArrayList.class).get(0);
|
||||
ProductFormatDto productFormatDto = ProductFormatDto.builder()
|
||||
.pic(mapAttr.get("pic").toString())
|
||||
.price(Double.valueOf(mapAttr.get("price").toString()))
|
||||
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||
.cost(Double.valueOf(mapAttr.get("cost").toString()))
|
||||
.otPrice(Double.valueOf(mapAttr.get("ot_price").toString()))
|
||||
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
|
||||
.pinkStock(Integer.valueOf(mapAttr.get("pink_stock").toString()))
|
||||
.barCode(mapAttr.get("bar_code").toString())
|
||||
.weight(Double.valueOf(mapAttr.get("weight").toString()))
|
||||
.volume(Double.valueOf(mapAttr.get("volume").toString()))
|
||||
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
|
||||
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||
.build();
|
||||
productDto.setAttr(productFormatDto);
|
||||
}
|
||||
|
||||
|
||||
map.put("productInfo",productDto);
|
||||
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
}
|
||||
@Log("修改拼团")
|
||||
@ApiOperation(value = "新增/修改拼团")
|
||||
@PutMapping(value = "/yxStoreCombination")
|
||||
|
@ -121,11 +121,16 @@ public class StoreProductController {
|
||||
yxStoreProductService.onSale(id,status);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation(value = "生成属性(添加活动产品专用)")
|
||||
@PostMapping(value = "/yxStoreProduct/isFormatAttrForActivity/{id}")
|
||||
public ResponseEntity isFormatAttrForActivity(@PathVariable Long id,@RequestBody String jsonStr){
|
||||
return new ResponseEntity<>(yxStoreProductService.getFormatAttr(id,jsonStr,true),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生成属性")
|
||||
@PostMapping(value = "/yxStoreProduct/isFormatAttr/{id}")
|
||||
public ResponseEntity isFormatAttr(@PathVariable Long id,@RequestBody String jsonStr){
|
||||
return new ResponseEntity<>(yxStoreProductService.getFormatAttr(id,jsonStr),HttpStatus.OK);
|
||||
return new ResponseEntity<>(yxStoreProductService.getFormatAttr(id,jsonStr,false),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import cn.binarywang.wx.miniapp.message.WxMaMessageHandler;
|
||||
import cn.binarywang.wx.miniapp.message.WxMaMessageRouter;
|
||||
import co.yixiang.constant.SystemConfigConstants;
|
||||
import co.yixiang.utils.RedisUtil;
|
||||
import co.yixiang.utils.RedisUtils;
|
||||
import co.yixiang.utils.ShopKeyUtils;
|
||||
@ -71,17 +72,12 @@ public class WxMaConfiguration {
|
||||
final WxMaMessageRouter router = new WxMaMessageRouter(service);
|
||||
router
|
||||
.rule().handler(wxMaMessageHandler).next()
|
||||
.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT).event(WxConsts.EventType.SUBSCRIBE).handler(templateMsgHandler).end();
|
||||
.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT).event(SystemConfigConstants.BINDSTATECHANGE).handler(bindstatechangeHandler).end();
|
||||
return router;
|
||||
}
|
||||
private static final WxMaMessageHandler templateMsgHandler = (wxMessage, context, service, sessionManager) -> {
|
||||
service.getMsgService().sendSubscribeMsg(WxMaSubscribeMessage.builder()
|
||||
.templateId("此处更换为自己的模板id")
|
||||
.page("")
|
||||
.data(Lists.newArrayList(
|
||||
new WxMaSubscribeMessage.Data("keyword1", "339208499")))
|
||||
.toUser(wxMessage.getFromUser())
|
||||
.build());
|
||||
private static final WxMaMessageHandler bindstatechangeHandler = (wxMessage, context, service, sessionManager) -> {
|
||||
wxMessage.getFromUser();
|
||||
wxMessage.getContent();
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user