diff --git a/.gitignore b/.gitignore index 50ea37c0..95a6c0d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ ###################################################################### # Build Tools +/logs .gradle /build/ !gradle/wrapper/gradle-wrapper.jar - +.DS_Store target/ !.mvn/wrapper/maven-wrapper.jar diff --git a/pom.xml b/pom.xml index e0d63ace..0fab0160 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ yudao-module-infra yudao-module-pay zsw-farm + zsw-bxg ${project.artifactId} diff --git a/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml index 763c722c..b756beb6 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-biz-weixin/pom.xml @@ -31,13 +31,21 @@ + com.github.binarywang - - wx-java-mp-spring-boot-starter - 4.1.9.B + weixin-java-mp + 4.3.0 - + + + + com.github.binarywang + weixin-java-miniapp + 4.3.0 + + + diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java index f8eeeef8..76d69431 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java @@ -1,22 +1,39 @@ package cn.iocoder.yudao.framework.mybatis.config; import cn.iocoder.yudao.framework.mybatis.core.handler.DefaultDBFieldHandler; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.dynamic.datasource.provider.DynamicDataSourceProvider; +import com.baomidou.mybatisplus.core.config.GlobalConfig; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.defaults.DefaultSqlSessionFactory; import org.mybatis.spring.annotation.MapperScan; +import org.mybatis.spring.annotation.MapperScans; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import javax.sql.DataSource; +import java.util.Map; /** * MyBaits 配置类 * * @author 芋道源码 */ + +@MapperScans({ + @MapperScan(basePackages ={"co.yixiang.**.service.mapper", "co.yixiang.config"},sqlSessionFactoryRef = "shangcheng"), + @MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, + lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 +}) @Configuration -@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, - lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 public class YudaoMybatisAutoConfiguration { @Bean @@ -31,4 +48,27 @@ public class YudaoMybatisAutoConfiguration { return new DefaultDBFieldHandler(); // 自动填充参数类 } + @Bean + @Primary + public SqlSessionFactory sqlSessionFactoryMaster(DynamicDataSourceProvider dynamicDataSourceProvider) throws Exception { + //手动处理下原来的sqlsessionfactory + MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean(); + Map map = dynamicDataSourceProvider.loadDataSources(); + factory.setDataSource(map.get("master")); + GlobalConfig globalConfig = new GlobalConfig(); + globalConfig.setMetaObjectHandler(defaultMetaObjectHandler()); + factory.setPlugins(mybatisPlusInterceptor()); + factory.setGlobalConfig(globalConfig); + return factory.getObject(); + } + + @Bean("shangcheng") + public SqlSessionFactory sqlSessionFactory(DynamicDataSourceProvider dynamicDataSourceProvider) throws Exception { + MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean(); + Map map = dynamicDataSourceProvider.loadDataSources(); + factory.setDataSource(map.get("xiaohui")); + return factory.getObject(); + + } + } diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java index 65910b16..2e929fca 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/DefaultDBFieldHandler.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; import org.apache.ibatis.reflection.MetaObject; +import java.sql.Timestamp; import java.util.Date; import java.util.Objects; @@ -41,6 +42,30 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { if (Objects.nonNull(userId) && Objects.isNull(baseDO.getUpdater())) { baseDO.setUpdater(userId.toString()); } + + Timestamp time=new Timestamp(System.currentTimeMillis()); + if (metaObject.hasSetter("createTime")) { + this.setFieldValByName("createTime", time, metaObject); + } + if (metaObject.hasSetter("updateTime")) { + this.setFieldValByName("updateTime", time, metaObject); + } + if (metaObject.hasSetter("createDate")) { + this.setFieldValByName("createDate", time, metaObject); + } + if (metaObject.hasSetter("updateDate")) { + this.setFieldValByName("updateDate", time, metaObject); + } + if (metaObject.hasSetter("delFlag")) { + this.setFieldValByName("delFlag", false, metaObject); + } + if (metaObject.hasSetter("isDel")) { + this.setFieldValByName("isDel", 0, metaObject); + } + if (metaObject.hasSetter("addTime")) { + String timestamp = String.valueOf(System.currentTimeMillis() / 1000); + this.setFieldValByName("addTime", Integer.valueOf(timestamp), metaObject); + } } } @@ -58,5 +83,20 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { if (Objects.nonNull(userId) && Objects.isNull(modifier)) { setFieldValByName("updater", userId.toString(), metaObject); } + + + Timestamp time=new Timestamp(System.currentTimeMillis()); + if (metaObject.hasSetter("updateTime")) { + this.setFieldValByName("updateTime", time, metaObject); + } + if (metaObject.hasSetter("updateDate")) { + this.setFieldValByName("updateDate", time, metaObject); + } + if (metaObject.hasSetter("delFlag")) { + this.setFieldValByName("delFlag", null, metaObject); + } + if (metaObject.hasSetter("createTime")) { + this.setFieldValByName("createTime", null, metaObject); + } } } diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java index 08f391a5..14d85fdd 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/config/YudaoWebSecurityConfigurerAdapter.java @@ -130,6 +130,10 @@ public class YudaoWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdap // 设置 App API 无需认证 .antMatchers(buildAppApi("/**")).permitAll() .antMatchers("/common/**").permitAll() + + // 忽略宝享购全部 + .antMatchers("/bxgApp/**","/bxg/**").permitAll() + // ②:每个项目的自定义规则 .and().authorizeRequests(registry -> // 下面,循环设置自定义规则 authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(registry))) diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/authentication/MultiUserDetailsAuthenticationProvider.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/authentication/MultiUserDetailsAuthenticationProvider.java index 52ff43f7..7e6f237e 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/authentication/MultiUserDetailsAuthenticationProvider.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/authentication/MultiUserDetailsAuthenticationProvider.java @@ -140,7 +140,10 @@ public class MultiUserDetailsAuthenticationProvider extends AbstractUserDetailsA private UserTypeEnum getUserType(HttpServletRequest request) { // log.error("URI:{}",request.getRequestURI()); - if (request.getRequestURI().startsWith(properties.getAdminApi().getPrefix()) || request.getRequestURI().startsWith("/common/")) { + if (request.getRequestURI().startsWith(properties.getAdminApi().getPrefix()) + || request.getRequestURI().startsWith("/common/") + || request.getRequestURI().startsWith("/bxg") + ) { return UserTypeEnum.ADMIN; } if (request.getRequestURI().startsWith(properties.getAppApi().getPrefix())) { diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java index 6ebd29b1..d4553cfa 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java @@ -8,16 +8,15 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.ExampleBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestParameterBuilder; +import springfox.documentation.builders.*; +import springfox.documentation.schema.ModelRef; import springfox.documentation.service.*; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -61,6 +60,92 @@ public class YudaoSwaggerAutoConfiguration { .securityContexts(securityContexts()); } + + @Bean("SWAGGER_ADMIN") + @SuppressWarnings("all") + public Docket createRestApi1() { + SwaggerProperties properties = swaggerProperties(); + ParameterBuilder ticketPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + ticketPar.name("token").description("token") + .modelRef(new ModelRef("string")) + .parameterType("header") + .defaultValue("token " + " ") + .required(true) + .build(); + pars.add(ticketPar.build()); + return new Docket(DocumentationType.SWAGGER_2) + .groupName("ADMIN") + .enable(true) + .apiInfo(apiInfo(properties)) + .select() + .apis(RequestHandlerSelectors.basePackage("co.yixiang.modules")) + .paths(PathSelectors.regex("/error.*").negate()) + .build() + .globalOperationParameters(pars) + //添加登陆认证 + .securitySchemes(securitySchemes()) + .globalRequestParameters(globalRequestParameters()) + .securityContexts(securityContexts()); + } + + @Bean("SWAGGER_APP") + @SuppressWarnings("all") + public Docket createAppApi() { + SwaggerProperties properties = swaggerProperties(); + ParameterBuilder ticketPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + ticketPar.name("token").description("token") + .modelRef(new ModelRef("string")) + .parameterType("header") + .defaultValue("token" + " ") + .required(true) + .build(); + pars.add(ticketPar.build()); + return new Docket(DocumentationType.SWAGGER_2) + .groupName("APP") + .enable(true) + .apiInfo(apiInfo(properties)) + .select() + .apis(RequestHandlerSelectors.basePackage("co.yixiang.app.modules")) + .paths(PathSelectors.regex("/error.*").negate()) + .build() + .globalOperationParameters(pars) + //添加登陆认证 + .securitySchemes(securitySchemes()) + .globalRequestParameters(globalRequestParameters()) + .securityContexts(securityContexts()); + } + + + @Bean("SWAGGER_TOOL") + @SuppressWarnings("all") + public Docket createToolApi() { + SwaggerProperties properties = swaggerProperties(); + ParameterBuilder ticketPar = new ParameterBuilder(); + List pars = new ArrayList<>(); + ticketPar.name("token").description("token") + .modelRef(new ModelRef("string")) + .parameterType("header") + .defaultValue("token" + " ") + .required(true) + .build(); + pars.add(ticketPar.build()); + return new Docket(DocumentationType.SWAGGER_2) + .groupName("TOOL") + .enable(true) + .apiInfo(apiInfo(properties)) + .select() + .apis(RequestHandlerSelectors.basePackage("co.yixiang.tools")) + .paths(PathSelectors.regex("/error.*").negate()) + .build() + .globalOperationParameters(pars) + //添加登陆认证 + .securitySchemes(securitySchemes()) + .globalRequestParameters(globalRequestParameters()) + .securityContexts(securityContexts()); + } + // ========== apiInfo ========== /** diff --git a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/TestConfigure.java b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/TestConfigure.java new file mode 100644 index 00000000..51a9f310 --- /dev/null +++ b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/weixin/TestConfigure.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.member.controller.app.weixin; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class TestConfigure { + + @Bean + public WxMpService wxMpService(){ + WxMpService wxMpService = new WxMpServiceImpl(); + return wxMpService; + } + +} diff --git a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index f28af508..18d945b9 100644 --- a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -68,7 +68,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { @Resource private PasswordEncoder passwordEncoder; @Resource - private MemberUserMapper userMapper; + private MemberUserMapper memberUserMapper; @Override public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException { @@ -286,7 +286,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { MemberUserDO userDO = checkOldPassword(userId, reqVO.getOldPassword()); // 更新用户密码 - userMapper.updateById(MemberUserDO.builder().id(userDO.getId()) + memberUserMapper.updateById(MemberUserDO.builder().id(userDO.getId()) .password(passwordEncoder.encode(reqVO.getPassword())).build()); } @@ -300,7 +300,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { getClientIP())); // 更新密码 - userMapper.updateById(MemberUserDO.builder().id(userDO.getId()) + memberUserMapper.updateById(MemberUserDO.builder().id(userDO.getId()) .password(passwordEncoder.encode(reqVO.getPassword())).build()); } @@ -319,7 +319,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { */ @VisibleForTesting public MemberUserDO checkOldPassword(Long id, String oldPassword) { - MemberUserDO user = userMapper.selectById(id); + MemberUserDO user = memberUserMapper.selectById(id); if (user == null) { throw exception(USER_NOT_EXISTS); } @@ -331,7 +331,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { } public MemberUserDO checkUserIfExists(String mobile) { - MemberUserDO user = userMapper.selectByMobile(mobile); + MemberUserDO user = memberUserMapper.selectByMobile(mobile); if (user == null) { throw exception(USER_NOT_EXISTS); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 32f0a8e8..2526402e 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -46,7 +46,7 @@ public class AdminUserServiceImpl implements AdminUserService { private String userInitPassword; @Resource - private AdminUserMapper userMapper; + private AdminUserMapper adminUserMapper; @Resource private DeptService deptService; @@ -67,7 +67,7 @@ public class AdminUserServiceImpl implements AdminUserService { public Long createUser(UserCreateReqVO reqVO) { // 校验账户配合 tenantService.handleTenantInfo(tenant -> { - long count = userMapper.selectCount(); + long count = adminUserMapper.selectCount(); if (count >= tenant.getAccountCount()) { throw exception(USER_COUNT_MAX, tenant.getAccountCount()); } @@ -79,7 +79,7 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO user = UserConvert.INSTANCE.convert(reqVO); user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 user.setPassword(passwordEncoder.encode(reqVO.getPassword())); // 加密密码 - userMapper.insert(user); + adminUserMapper.insert(user); return user.getId(); } @@ -90,12 +90,12 @@ public class AdminUserServiceImpl implements AdminUserService { reqVO.getDeptId(), reqVO.getPostIds()); // 更新用户 AdminUserDO updateObj = UserConvert.INSTANCE.convert(reqVO); - userMapper.updateById(updateObj); + adminUserMapper.updateById(updateObj); } @Override public void updateUserLogin(Long id, String loginIp) { - userMapper.updateById(new AdminUserDO().setId(id).setLoginIp(loginIp).setLoginDate(new Date())); + adminUserMapper.updateById(new AdminUserDO().setId(id).setLoginIp(loginIp).setLoginDate(new Date())); } @Override @@ -105,7 +105,7 @@ public class AdminUserServiceImpl implements AdminUserService { this.checkEmailUnique(id, reqVO.getEmail()); this.checkMobileUnique(id, reqVO.getMobile()); // 执行更新 - userMapper.updateById(UserConvert.INSTANCE.convert(reqVO).setId(id)); + adminUserMapper.updateById(UserConvert.INSTANCE.convert(reqVO).setId(id)); } @Override @@ -115,7 +115,7 @@ public class AdminUserServiceImpl implements AdminUserService { // 执行更新 AdminUserDO updateObj = new AdminUserDO().setId(id); updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword())); // 加密密码 - userMapper.updateById(updateObj); + adminUserMapper.updateById(updateObj); } @Override @@ -127,7 +127,7 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO sysUserDO = new AdminUserDO(); sysUserDO.setId(id); sysUserDO.setAvatar(avatar); - userMapper.updateById(sysUserDO); + adminUserMapper.updateById(sysUserDO); return avatar; } @@ -139,7 +139,7 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO updateObj = new AdminUserDO(); updateObj.setId(id); updateObj.setPassword(passwordEncoder.encode(password)); // 加密密码 - userMapper.updateById(updateObj); + adminUserMapper.updateById(updateObj); } @Override @@ -150,7 +150,7 @@ public class AdminUserServiceImpl implements AdminUserService { AdminUserDO updateObj = new AdminUserDO(); updateObj.setId(id); updateObj.setStatus(status); - userMapper.updateById(updateObj); + adminUserMapper.updateById(updateObj); } @Override @@ -158,24 +158,24 @@ public class AdminUserServiceImpl implements AdminUserService { // 校验用户存在 this.checkUserExists(id); // 删除用户 - userMapper.deleteById(id); + adminUserMapper.deleteById(id); // 删除用户关联数据 permissionService.processUserDeleted(id); } @Override public AdminUserDO getUserByUsername(String username) { - return userMapper.selectByUsername(username); + return adminUserMapper.selectByUsername(username); } @Override public PageResult getUserPage(UserPageReqVO reqVO) { - return userMapper.selectPage(reqVO, this.getDeptCondition(reqVO.getDeptId())); + return adminUserMapper.selectPage(reqVO, this.getDeptCondition(reqVO.getDeptId())); } @Override public AdminUserDO getUser(Long id) { - return userMapper.selectById(id); + return adminUserMapper.selectById(id); } @Override @@ -183,7 +183,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (CollUtil.isEmpty(deptIds)) { return Collections.emptyList(); } - return userMapper.selectListByDeptIds(deptIds); + return adminUserMapper.selectListByDeptIds(deptIds); } @Override @@ -193,7 +193,7 @@ public class AdminUserServiceImpl implements AdminUserService { } // 过滤不符合条件的 // TODO 芋艿:暂时只能内存过滤。解决方案:1、新建一个关联表;2、基于 where + 函数;3、json 字段,适合 mysql 8+ 版本 - List users = userMapper.selectList(); + List users = adminUserMapper.selectList(); users.removeIf(user -> !CollUtil.containsAny(user.getPostIds(), postIds)); return users; } @@ -203,7 +203,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (CollUtil.isEmpty(ids)) { return Collections.emptyList(); } - return userMapper.selectBatchIds(ids); + return adminUserMapper.selectBatchIds(ids); } @Override @@ -212,7 +212,7 @@ public class AdminUserServiceImpl implements AdminUserService { return; } // 获得岗位信息 - List users = userMapper.selectBatchIds(ids); + List users = adminUserMapper.selectBatchIds(ids); Map userMap = CollectionUtils.convertMap(users, AdminUserDO::getId); // 校验 ids.forEach(id -> { @@ -228,17 +228,17 @@ public class AdminUserServiceImpl implements AdminUserService { @Override public List getUsers(UserExportReqVO reqVO) { - return userMapper.selectList(reqVO, this.getDeptCondition(reqVO.getDeptId())); + return adminUserMapper.selectList(reqVO, this.getDeptCondition(reqVO.getDeptId())); } @Override public List getUsersByNickname(String nickname) { - return userMapper.selectListByNickname(nickname); + return adminUserMapper.selectListByNickname(nickname); } @Override public List getUsersByUsername(String username) { - return userMapper.selectListByUsername(username); + return adminUserMapper.selectListByUsername(username); } /** @@ -278,7 +278,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (id == null) { return; } - AdminUserDO user = userMapper.selectById(id); + AdminUserDO user = adminUserMapper.selectById(id); if (user == null) { throw exception(USER_NOT_EXISTS); } @@ -289,7 +289,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (StrUtil.isBlank(username)) { return; } - AdminUserDO user = userMapper.selectByUsername(username); + AdminUserDO user = adminUserMapper.selectByUsername(username); if (user == null) { return; } @@ -307,7 +307,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (StrUtil.isBlank(email)) { return; } - AdminUserDO user = userMapper.selectByEmail(email); + AdminUserDO user = adminUserMapper.selectByEmail(email); if (user == null) { return; } @@ -325,7 +325,7 @@ public class AdminUserServiceImpl implements AdminUserService { if (StrUtil.isBlank(mobile)) { return; } - AdminUserDO user = userMapper.selectByMobile(mobile); + AdminUserDO user = adminUserMapper.selectByMobile(mobile); if (user == null) { return; } @@ -346,7 +346,7 @@ public class AdminUserServiceImpl implements AdminUserService { */ @VisibleForTesting public void checkOldPassword(Long id, String oldPassword) { - AdminUserDO user = userMapper.selectById(id); + AdminUserDO user = adminUserMapper.selectById(id); if (user == null) { throw exception(USER_NOT_EXISTS); } @@ -373,9 +373,9 @@ public class AdminUserServiceImpl implements AdminUserService { return; } // 判断如果不存在,在进行插入 - AdminUserDO existUser = userMapper.selectByUsername(importUser.getUsername()); + AdminUserDO existUser = adminUserMapper.selectByUsername(importUser.getUsername()); if (existUser == null) { - userMapper.insert(UserConvert.INSTANCE.convert(importUser) + adminUserMapper.insert(UserConvert.INSTANCE.convert(importUser) .setPassword(passwordEncoder.encode(userInitPassword))); // 设置默认密码 respVO.getCreateUsernames().add(importUser.getUsername()); return; @@ -387,7 +387,7 @@ public class AdminUserServiceImpl implements AdminUserService { } AdminUserDO updateUser = UserConvert.INSTANCE.convert(importUser); updateUser.setId(existUser.getId()); - userMapper.updateById(updateUser); + adminUserMapper.updateById(updateUser); respVO.getUpdateUsernames().add(importUser.getUsername()); }); return respVO; @@ -395,7 +395,7 @@ public class AdminUserServiceImpl implements AdminUserService { @Override public List getUsersByStatus(Integer status) { - return userMapper.selectListByStatus(status); + return adminUserMapper.selectListByStatus(status); } } diff --git a/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/user/UserServiceImplTest.java b/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/user/UserServiceImplTest.java index 34ea7835..2c4def13 100644 --- a/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/user/UserServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/user/UserServiceImplTest.java @@ -53,7 +53,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { private AdminUserServiceImpl userService; @Resource - private AdminUserMapper userMapper; + private AdminUserMapper adminUserMapper; @MockBean private DeptService deptService; @@ -100,7 +100,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 Long userId = userService.createUser(reqVO); // 断言 - AdminUserDO user = userMapper.selectById(userId); + AdminUserDO user = adminUserMapper.selectById(userId); assertPojoEquals(reqVO, user, "password"); assertEquals("yudaoyuanma", user.getPassword()); assertEquals(CommonStatusEnum.ENABLE.getStatus(), user.getStatus()); @@ -125,7 +125,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testUpdateUser_success() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 UserUpdateReqVO reqVO = randomPojo(UserUpdateReqVO.class, o -> { o.setId(dbUser.getId()); @@ -149,7 +149,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 userService.updateUser(reqVO); // 断言 - AdminUserDO user = userMapper.selectById(reqVO.getId()); + AdminUserDO user = adminUserMapper.selectById(reqVO.getId()); assertPojoEquals(reqVO, user); } @@ -157,7 +157,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testUpdateUserProfile_success() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 Long userId = dbUser.getId(); UserProfileUpdateReqVO reqVO = randomPojo(UserProfileUpdateReqVO.class, o -> { @@ -168,7 +168,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 userService.updateUserProfile(userId, reqVO); // 断言 - AdminUserDO user = userMapper.selectById(userId); + AdminUserDO user = adminUserMapper.selectById(userId); assertPojoEquals(reqVO, user); } @@ -176,7 +176,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testUpdateUserPassword_success() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(o -> o.setPassword("encode:tudou")); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 Long userId = dbUser.getId(); UserProfileUpdatePasswordReqVO reqVO = randomPojo(UserProfileUpdatePasswordReqVO.class, o -> { @@ -191,7 +191,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 userService.updateUserPassword(userId, reqVO); // 断言 - AdminUserDO user = userMapper.selectById(userId); + AdminUserDO user = adminUserMapper.selectById(userId); assertEquals("encode:yuanma", user.getPassword()); } @@ -199,7 +199,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testUpdateUserAvatar_success() throws Exception { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 Long userId = dbUser.getId(); byte[] avatarFileBytes = randomBytes(10); @@ -211,7 +211,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 userService.updateUserAvatar(userId, avatarFile); // 断言 - AdminUserDO user = userMapper.selectById(userId); + AdminUserDO user = adminUserMapper.selectById(userId); assertEquals(avatar, user.getAvatar()); } @@ -219,7 +219,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testUpdateUserPassword02_success() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 Long userId = dbUser.getId(); String password = "yudao"; @@ -230,7 +230,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 userService.updateUserPassword(userId, password); // 断言 - AdminUserDO user = userMapper.selectById(userId); + AdminUserDO user = adminUserMapper.selectById(userId); assertEquals("encode:" + password, user.getPassword()); } @@ -238,7 +238,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testUpdateUserStatus() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 Long userId = dbUser.getId(); Integer status = randomCommonStatus(); @@ -246,7 +246,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 调用 userService.updateUserStatus(userId, status); // 断言 - AdminUserDO user = userMapper.selectById(userId); + AdminUserDO user = adminUserMapper.selectById(userId); assertEquals(status, user.getStatus()); } @@ -254,14 +254,14 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testDeleteUser_success(){ // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 Long userId = dbUser.getId(); // 调用数据 userService.deleteUser(userId); // 校验结果 - assertNull(userMapper.selectById(userId)); + assertNull(adminUserMapper.selectById(userId)); // 校验调用次数 verify(permissionService, times(1)).processUserDeleted(eq(userId)); } @@ -325,17 +325,17 @@ public class UserServiceImplTest extends BaseDbUnitTest { o.setCreateTime(buildTime(2020, 12, 12)); o.setDeptId(2L); }); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 测试 username 不匹配 - userMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setUsername("dou"))); + adminUserMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setUsername("dou"))); // 测试 mobile 不匹配 - userMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setMobile("18818260888"))); + adminUserMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setMobile("18818260888"))); // 测试 status 不匹配 - userMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); + adminUserMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); // 测试 createTime 不匹配 - userMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setCreateTime(buildTime(2020, 11, 11)))); + adminUserMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setCreateTime(buildTime(2020, 11, 11)))); // 测试 dept 不匹配 - userMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setDeptId(0L))); + adminUserMapper.insert(ObjectUtils.cloneIgnoreId(dbUser, o -> o.setDeptId(0L))); return dbUser; } @@ -382,7 +382,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { UserImportRespVO respVO = userService.importUsers(newArrayList(importUser), true); // 断言 assertEquals(1, respVO.getCreateUsernames().size()); - AdminUserDO user = userMapper.selectByUsername(respVO.getCreateUsernames().get(0)); + AdminUserDO user = adminUserMapper.selectByUsername(respVO.getCreateUsernames().get(0)); assertPojoEquals(importUser, user); assertEquals("java", user.getPassword()); assertEquals(0, respVO.getUpdateUsernames().size()); @@ -396,7 +396,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testImportUsers_03() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 @@ -426,7 +426,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testImportUsers_04() { // mock 数据 AdminUserDO dbUser = randomAdminUserDO(); - userMapper.insert(dbUser); + adminUserMapper.insert(dbUser); // 准备参数 UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 @@ -445,7 +445,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 断言 assertEquals(0, respVO.getCreateUsernames().size()); assertEquals(1, respVO.getUpdateUsernames().size()); - AdminUserDO user = userMapper.selectByUsername(respVO.getUpdateUsernames().get(0)); + AdminUserDO user = adminUserMapper.selectByUsername(respVO.getUpdateUsernames().get(0)); assertPojoEquals(importUser, user); assertEquals(0, respVO.getFailureUsernames().size()); } @@ -460,7 +460,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 准备参数 String username = randomString(); // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); + adminUserMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); // 调用,校验异常 assertServiceException(() -> userService.checkUsernameUnique(null, username), @@ -473,7 +473,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { Long id = randomLongId(); String username = randomString(); // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); + adminUserMapper.insert(randomAdminUserDO(o -> o.setUsername(username))); // 调用,校验异常 assertServiceException(() -> userService.checkUsernameUnique(id, username), @@ -485,7 +485,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 准备参数 String email = randomString(); // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); + adminUserMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); // 调用,校验异常 assertServiceException(() -> userService.checkEmailUnique(null, email), @@ -498,7 +498,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { Long id = randomLongId(); String email = randomString(); // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); + adminUserMapper.insert(randomAdminUserDO(o -> o.setEmail(email))); // 调用,校验异常 assertServiceException(() -> userService.checkEmailUnique(id, email), @@ -510,7 +510,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { // 准备参数 String mobile = randomString(); // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); + adminUserMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); // 调用,校验异常 assertServiceException(() -> userService.checkMobileUnique(null, mobile), @@ -523,7 +523,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { Long id = randomLongId(); String mobile = randomString(); // mock 数据 - userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); + adminUserMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile))); // 调用,校验异常 assertServiceException(() -> userService.checkMobileUnique(id, mobile), @@ -540,7 +540,7 @@ public class UserServiceImplTest extends BaseDbUnitTest { public void testCheckOldPassword_passwordFailed() { // mock 数据 AdminUserDO user = randomAdminUserDO(); - userMapper.insert(user); + adminUserMapper.insert(user); // 准备参数 Long id = user.getId(); String oldPassword = user.getPassword(); diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 926f6fcc..eb91c22c 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -21,6 +21,13 @@ https://github.com/YunaiV/ruoyi-vue-pro + + + cn.iocoder.boot + zsw-bxg + ${revision} + + cn.iocoder.boot zsw-farm-impl diff --git a/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java b/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java index 4a963ded..d7abdcff 100644 --- a/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java +++ b/yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} -@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}) +@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module","co.yixiang"}) public class YudaoServerApplication { public static void main(String[] args) { diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 9c85f12a..10390d64 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -44,22 +44,28 @@ spring: datasource: master: name: ruoyi-vue-pro - url: jdbc:mysql://192.168.10.129:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT driver-class-name: com.mysql.jdbc.Driver username: root password: root slave: # 模拟从库,可根据自己需要修改 name: ruoyi-vue-pro - url: jdbc:mysql://192.168.10.129:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT driver-class-name: com.mysql.jdbc.Driver username: root password: root - farm: # 农场数据源 - name: zsw-farm - url: jdbc:mysql://192.168.10.129:3306/${spring.datasource.dynamic.datasource.farm.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + xiaohui: # 农场数据源 + name: xiaohui + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.xiaohui.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT driver-class-name: com.mysql.jdbc.Driver username: root password: root +# farm: # 农场数据源 +# name: zsw-farm +# url: jdbc:mysql://192.168.10.129:3306/${spring.datasource.dynamic.datasource.farm.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT +# driver-class-name: com.mysql.jdbc.Driver +# username: root +# password: root # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 redis: @@ -154,7 +160,7 @@ spring: # 日志文件配置 logging: file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + name: logs/${spring.application.name}.log # 日志文件名,全路径 level: # 配置自己写的 MyBatis Mapper 打印日志 cn.iocoder.yudao.module.bpm.dal.mysql: debug @@ -163,6 +169,7 @@ logging: cn.iocoder.yudao.module.system.dal.mysql: debug cn.iocoder.yudao.module.tool.dal.mysql: debug cn.iocoder.yudao.module.member.dal.mysql: debug + co.yixiang: debug --- #################### 微信公众号相关配置 #################### wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 76d5e045..5733a148 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -131,3 +131,15 @@ yudao: end-code: 9999 # 这里配置 9999 的原因是,测试方便。 debug: false + +yshop: + # 配置 + version: 3.2 + apiUrl: http://127.0.0.1:8009/api + security: + jwt-key: yshopmini + token-expired-in: 86400000 + +# sm.ms 图床的 token +smms: + token: 1oOP3ykFDI0K6ifmtvU7c8Y1eTWZSlyl \ No newline at end of file diff --git a/yudao-ui-admin b/yudao-ui-admin index c9d2e191..05fdb1d9 160000 --- a/yudao-ui-admin +++ b/yudao-ui-admin @@ -1 +1 @@ -Subproject commit c9d2e1910ab71bd78bf56c4ffe04f9bf86845ee4 +Subproject commit 05fdb1d9e71965bbb19e9e35b8732c861d7eab94 diff --git a/zsw-bxg/pom.xml b/zsw-bxg/pom.xml new file mode 100644 index 00000000..990860be --- /dev/null +++ b/zsw-bxg/pom.xml @@ -0,0 +1,160 @@ + + + + yudao + cn.iocoder.boot + ${revision} + + 4.0.0 + + jar + zsw-bxg + ${project.artifactId} + + + 0.10.6 + 1.4.7 + 7.9.5 + 0.10.6 + + + + + + cn.iocoder.boot + yudao-module-system-impl + 1.6.2-snapshot + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-weixin + ${revision} + + + + cn.iocoder.boot + yudao-common + ${revision} + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-pay + ${revision} + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + ${revision} + + + cn.iocoder.boot + yudao-spring-boot-starter-web + ${revision} + + + + cn.iocoder.boot + yudao-spring-boot-starter-redis + ${revision} + + + + cn.iocoder.boot + yudao-spring-boot-starter-security + ${revision} + + + + cn.iocoder.boot + yudao-spring-boot-starter-extension + ${revision} + + + + org.springframework.boot + spring-boot-starter-websocket + 2.5.10 + + + + + io.jsonwebtoken + jjwt + 0.9.1 + + + + + com.auth0 + java-jwt + 3.8.1 + + + + com.aliyun + aliyun-java-sdk-core + 4.0.3 + + + + com.vdurmont + emoji-java + 4.0.0 + + + + + javax.mail + mail + ${mail.version} + + + + + com.qiniu + qiniu-java-sdk + ${qiniu.version} + + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.4.2 + + + + net.sf.dozer + dozer-spring + 5.5.1 + + + + net.sf.dozer + dozer + 5.5.1 + + + + + + com.google.zxing + core + 3.2.1 + + + + com.alibaba + fastjson + 1.2.50 + + + + + diff --git a/zsw-bxg/src/main/java/co/yixiang/annotation/AnonymousAccess.java b/zsw-bxg/src/main/java/co/yixiang/annotation/AnonymousAccess.java new file mode 100644 index 00000000..9be0595e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/annotation/AnonymousAccess.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author jacky + * 用于标记匿名访问方法 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AnonymousAccess { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/annotation/Limit.java b/zsw-bxg/src/main/java/co/yixiang/annotation/Limit.java new file mode 100644 index 00000000..aafc97b6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/annotation/Limit.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.annotation; + +import co.yixiang.aspect.LimitType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author jacky + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Limit { + + // 资源名称,用于描述接口功能 + String name() default ""; + + // 资源 key + String key() default ""; + + // key prefix + String prefix() default ""; + + // 时间的,单位秒 + int period(); + + // 限制访问次数 + int count(); + + // 限制类型 + LimitType limitType() default LimitType.CUSTOMER; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/annotation/Query.java b/zsw-bxg/src/main/java/co/yixiang/annotation/Query.java new file mode 100644 index 00000000..c07eecdc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/annotation/Query.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author Zheng Jie + * @date 2019-6-4 13:52:30 + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Query { + + // Dong ZhaoYang 2017/8/7 基本对象的属性名 + String propName() default ""; + // Dong ZhaoYang 2017/8/7 查询方式 + Type type() default Type.EQUAL; + + /** + * 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username") + */ + String blurry() default ""; + + enum Type { + // jie 2019/6/4 相等 + EQUAL + // Dong ZhaoYang 2017/8/7 大于等于 + , GREATER_THAN + //大于 + , GREATER_THAN_NQ + // Dong ZhaoYang 2017/8/7 小于等于 + , LESS_THAN + // Dong ZhaoYang 2017/8/7 中模糊查询 + , INNER_LIKE + // Dong ZhaoYang 2017/8/7 左模糊查询 + , LEFT_LIKE + // Dong ZhaoYang 2017/8/7 右模糊查询 + , RIGHT_LIKE + // Dong ZhaoYang 2017/8/7 小于 + , LESS_THAN_NQ + // jie 2019/6/4 包含 + , IN + // 不等于 + ,NOT_EQUAL + // between + ,BETWEEN + // 不为空 + ,NOT_NULL + // 查询时间 + ,UNIX_TIMESTAMP + } + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/api/ApiCode.java b/zsw-bxg/src/main/java/co/yixiang/api/ApiCode.java new file mode 100644 index 00000000..2356fada --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/api/ApiCode.java @@ -0,0 +1,126 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.api; + + +/** + * API 响应码 + * @author hupeng + * @date 2020-04-30 + */ +public enum ApiCode { + + /** + * 操作成功 + **/ + SUCCESS(200, "操作成功"), + /** + * 非法访问 + **/ + UNAUTHORIZED(401, "非法访问"), + /** + * 没有权限 + **/ + NOT_PERMISSION(403, "没有权限"), + /** + * 你请求的资源不存在 + **/ + NOT_FOUND(404, "你请求的资源不存在"), + /** + * 操作失败 + **/ + FAIL(500, "操作失败"), + /** + * 登录失败 + **/ + LOGIN_EXCEPTION(4000, "登录失败"), + /** + * 系统异常 + **/ + SYSTEM_EXCEPTION(5000, "系统异常"), + /** + * 请求参数校验异常 + **/ + PARAMETER_EXCEPTION(5001, "请求参数校验异常"), + /** + * 请求参数解析异常 + **/ + PARAMETER_PARSE_EXCEPTION(5002, "请求参数解析异常"), + /** + * HTTP内容类型异常 + **/ + HTTP_MEDIA_TYPE_EXCEPTION(5003, "HTTP内容类型异常"), + /** + * 系统处理异常 + **/ + YSHOP_SYSTEM_EXCEPTION(5100, "系统处理异常"), + /** + * 业务处理异常 + **/ + BUSINESS_EXCEPTION(5101, "业务处理异常"), + /** + * 数据库处理异常 + **/ + DAO_EXCEPTION(5102, "数据库处理异常"), + /** + * 验证码校验异常 + **/ + VERIFICATION_CODE_EXCEPTION(5103, "验证码校验异常"), + /** + * 登录授权异常 + **/ + AUTHENTICATION_EXCEPTION(5104, "登录授权异常"), + /** + * 没有访问权限 + **/ + UNAUTHENTICATED_EXCEPTION(5105, "没有访问权限"), + /** + * 没有访问权限 + **/ + UNAUTHORIZED_EXCEPTION(5106, "没有访问权限"), + /** + * JWT Token解析异常 + **/ + JWTDECODE_EXCEPTION(5107, "Token解析异常"), + + HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION(5108, "METHOD NOT SUPPORTED"), + + /** + * 访问次数受限制 + **/ + BAD_LIMIT_EXCEPTION(5109, "访问次数受限制"), + ; + + private final int code; + private final String message; + + ApiCode(final int code, final String message) { + this.code = code; + this.message = message; + } + + public static ApiCode getApiCode(int code) { + ApiCode[] ecs = ApiCode.values(); + for (ApiCode ec : ecs) { + if (ec.getCode() == code) { + return ec; + } + } + return SUCCESS; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/api/ApiResult.java b/zsw-bxg/src/main/java/co/yixiang/api/ApiResult.java new file mode 100644 index 00000000..0ea84a84 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/api/ApiResult.java @@ -0,0 +1,231 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.api; + + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; +import org.apache.commons.lang3.StringUtils; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * API 返回结果 + * @author hupeng + * @date 2020-04-30 + */ +@Data +@Accessors(chain = true) +@Builder +@AllArgsConstructor +public class ApiResult implements Serializable { + private static final long serialVersionUID = 8004487252556526569L; + + /** + * 响应码 + */ + @ApiModelProperty(value = "响应码") + private int status; + + /** + * 是否成功 + */ + @ApiModelProperty(value = "是否成功:成功true,失败false") + private boolean success; + + /** + * 响应消息 + */ + @ApiModelProperty(value = "响应消息") + private String msg; + + /** + * 总条数 + */ + @ApiModelProperty(value = "总条数") + private Integer total; + + /** + * 总页数 + */ + @ApiModelProperty(value = "总页数") + private Integer totalPage; + + /** + * 响应数据 + */ + @ApiModelProperty(value = "响应数据") + private T data; + + /** + * 响应时间 + */ + @ApiModelProperty(value = "响应时间") + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date time; + + public ApiResult() { + time = new Date(); + } + + public static ApiResult result(boolean flag){ + if (flag){ + return ok(); + } + return fail(); + } + + public static ApiResult result(ApiCode apiCode){ + return result(apiCode,null); + } + + public static ApiResult result(ApiCode apiCode, T data){ + return result(apiCode,null,data); + } + + public static ApiResult resultPage(Integer total, Integer totalPage, T data){ + return (ApiResult) ApiResult.builder() + .total(total) + .totalPage(totalPage) + .status(200) + .msg(null) + .data(data) + .success(true) + .time(new Date()) + .build(); + } + + + public static ApiResult result(ApiCode apiCode, String message, T data){ + boolean success = false; + if (apiCode.getCode() == ApiCode.SUCCESS.getCode()){ + success = true; + } + if (StringUtils.isBlank(message)){ + message = apiCode.getMessage(); + } + return (ApiResult) ApiResult.builder() + .status(apiCode.getCode()) + .msg(message) + .data(data) + .success(success) + .time(new Date()) + .build(); + } + + public static ApiResult ok(){ + return ok(null); + } + + public static ApiResult ok(T data){ + return result(ApiCode.SUCCESS,data); + } + + public static ApiResult ok(T data, String message){ + return result(ApiCode.SUCCESS,message,data); + } + + public static ApiResult> okMap(String key, Object value){ + Map map = new HashMap<>(1); + map.put(key,value); + return ok(map); + } + + public static ApiResult fail(ApiCode apiCode){ + return result(apiCode,null); + } + + public static ApiResult fail(String message){ + return result(ApiCode.FAIL,message,null); + + } + + public static ApiResult fail(ApiCode apiCode, T data){ + if (ApiCode.SUCCESS == apiCode){ + throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode()); + } + return result(apiCode,data); + + } + + public static ApiResult fail(Integer errorCode, String message){ + return new ApiResult() + .setSuccess(false) + .setStatus(errorCode) + .setMsg(message); + } + + public static ApiResult> fail(String key, Object value){ + Map map = new HashMap<>(1); + map.put(key,value); + return result(ApiCode.FAIL,map); + } + + public static ApiResult resultPage(T t, int limit){ + List list = (List) t; + int count = list.size() / limit; + if (list.size() == 0) { + return (ApiResult) ApiResult.builder() + .total(0) + .totalPage(0) + .status(200) + .msg(null) + .data(list) + .success(true) + .time(new Date()) + .build(); + } + if (list.size() <= limit) { + return (ApiResult) ApiResult.builder() + .total(list.size()) + .totalPage(1) + .status(200) + .msg(null) + .data(list) + .success(true) + .time(new Date()) + .build(); + } else if (count % limit == 0) { + return (ApiResult) ApiResult.builder() + .total(list.size()) + .totalPage(count) + .status(200) + .msg(null) + .data(list) + .success(true) + .time(new Date()) + .build(); + } else { + return (ApiResult) ApiResult.builder() + .total(list.size()) + .totalPage(count+1) + .status(200) + .msg(null) + .data(list) + .success(true) + .time(new Date()) + .build(); + } + } + + public static ApiResult fail() { + return fail(ApiCode.FAIL); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/api/BusinessException.java b/zsw-bxg/src/main/java/co/yixiang/api/BusinessException.java new file mode 100644 index 00000000..42775d43 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/api/BusinessException.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.api; + + + + + +/** + * 业务异常 + * @author hupeng + * @date 2020-04-30 + */ +public class BusinessException extends YshopException { + private static final long serialVersionUID = -2303357122330162359L; + + public BusinessException(String message) { + super(message); + } + + public BusinessException(Integer errorCode, String message) { + super(errorCode, message); + } + + public BusinessException(ApiCode apiCode) { + super(apiCode); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/api/DaoException.java b/zsw-bxg/src/main/java/co/yixiang/api/DaoException.java new file mode 100644 index 00000000..07b8c2ad --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/api/DaoException.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.api; + + +/** + * DAO异常 + * @author hupeng + * @date 2020-04-30 + */ +public class DaoException extends YshopException { + private static final long serialVersionUID = -6912618737345878854L; + + public DaoException(String message) { + super(message); + } + + public DaoException(Integer errorCode, String message) { + super(errorCode, message); + } + + public DaoException(ApiCode apiCode) { + super(apiCode); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/api/UnAuthenticatedException.java b/zsw-bxg/src/main/java/co/yixiang/api/UnAuthenticatedException.java new file mode 100644 index 00000000..cef14ecf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/api/UnAuthenticatedException.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.api; + +/** + * 认证异常 + * @author hupeng + * @date 2020-04-30 + */ +public class UnAuthenticatedException extends YshopException { + public UnAuthenticatedException(String message) { + super(message); + } + + public UnAuthenticatedException(Integer errorCode, String message) { + super(errorCode, message); + } + + public UnAuthenticatedException(ApiCode apiCode) { + super(apiCode); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/api/YshopException.java b/zsw-bxg/src/main/java/co/yixiang/api/YshopException.java new file mode 100644 index 00000000..f0adfc27 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/api/YshopException.java @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.api; + + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 自定义异常 + * @author hupeng + * @date 2020-04-30 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class YshopException extends RuntimeException{ + + private static final long serialVersionUID = -2470461654663264392L; + + private Integer errorCode; + private String message; + + public YshopException() { + super(); + } + + public YshopException(String message) { + super(message); + this.message = message; + } + + public YshopException(Integer errorCode, String message) { + super(message); + this.errorCode = errorCode; + this.message = message; + } + + public YshopException(ApiCode apiCode) { + super(apiCode.getMessage()); + this.errorCode = apiCode.getCode(); + this.message = apiCode.getMessage(); + } + + public YshopException(String message, Throwable cause) { + super(message, cause); + } + + public YshopException(Throwable cause) { + super(cause); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/aop/NoRepeatSubmit.java b/zsw-bxg/src/main/java/co/yixiang/app/common/aop/NoRepeatSubmit.java new file mode 100644 index 00000000..bc77d3a0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/aop/NoRepeatSubmit.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface NoRepeatSubmit { + + /** + * 设置请求锁定时间 + * + * @return + */ + int lockTime() default 10; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/aspect/AppLogAspect.java b/zsw-bxg/src/main/java/co/yixiang/app/common/aspect/AppLogAspect.java new file mode 100644 index 00000000..0d5e96ff --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/aspect/AppLogAspect.java @@ -0,0 +1,101 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.app.common.aspect; + +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.logging.domain.Log; +import co.yixiang.logging.service.LogService; +import co.yixiang.utils.RequestHolder; +import co.yixiang.utils.StringUtils; +import co.yixiang.utils.ThrowableUtil; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author hupeng + * @date 2018-11-24 + */ +@Component +@Aspect +@Slf4j +public class AppLogAspect { + + private final LogService logService; + + ThreadLocal currentTime = new ThreadLocal<>(); + + public AppLogAspect(LogService logService) { + this.logService = logService; + } + + /** + * 配置切入点 + */ + @Pointcut("@annotation(co.yixiang.logging.aop.log.AppLog)") + public void logPointcut() { + // 该方法无方法体,主要为了让同类中其他方法使用此切入点 + } + + /** + * 配置环绕通知,使用在方法logPointcut()上注册的切入点 + * + * @param joinPoint join point for advice + */ + @Around("logPointcut()") + public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { + Object result; + currentTime.set(System.currentTimeMillis()); + result = joinPoint.proceed(); + Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get()); + currentTime.remove(); + HttpServletRequest request = RequestHolder.getHttpServletRequest(); + logService.saveApp(getUsername(), + StringUtils.getIp(RequestHolder.getHttpServletRequest()),joinPoint, + log,getUid()); + return result; + } + + /** + * 配置异常通知 + * + * @param joinPoint join point for advice + * @param e exception + */ + @AfterThrowing(pointcut = "logPointcut()", throwing = "e") + public void logAfterThrowing(JoinPoint joinPoint, Throwable e) { + Log log = new Log("ERROR",System.currentTimeMillis() - currentTime.get()); + currentTime.remove(); + log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes()); + HttpServletRequest request = RequestHolder.getHttpServletRequest(); + logService.save(getUsername(), + StringUtils.getIp(RequestHolder.getHttpServletRequest()), + (ProceedingJoinPoint)joinPoint, log,getUid()); + } + + public String getUsername() { + try { + return LocalUser.getUser().getUsername(); + }catch (Exception e){ + return ""; + } + } + + public Long getUid(){ + try { + return LocalUser.getUser().getUid(); + }catch (Exception e){ + return 0L; + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/bean/LocalUser.java b/zsw-bxg/src/main/java/co/yixiang/app/common/bean/LocalUser.java new file mode 100644 index 00000000..9ffb95fc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/bean/LocalUser.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.bean; + + +import co.yixiang.api.ApiCode; +import co.yixiang.api.UnAuthenticatedException; +import co.yixiang.app.common.util.JwtToken; +import co.yixiang.app.common.util.RequestUtils; +import co.yixiang.modules.user.domain.YxUser; +import com.auth0.jwt.interfaces.Claim; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * 全局user + * @author hupeng + * @date 2020-04-30 + */ +public class LocalUser { + private static ThreadLocal> threadLocal = new ThreadLocal<>(); + + public static void set(YxUser user, Integer scope) { + Map map = new HashMap<>(); + map.put("user", user); + map.put("scope", scope); + LocalUser.threadLocal.set(map); + } + + public static void clear() { + LocalUser.threadLocal.remove(); + } + + public static YxUser getUser() { + Map map = LocalUser.threadLocal.get(); + YxUser user = (YxUser)map.get("user"); + return user; + } + + public static Integer getScope() { + Map map = LocalUser.threadLocal.get(); + Integer scope = (Integer)map.get("scope"); + return scope; + } + + public static Long getUidByToken(){ + String bearerToken = RequestUtils.getRequest().getHeader("Authorization"); + if (StringUtils.isEmpty(bearerToken)) { + return 0L; + } + + if (!bearerToken.startsWith("Bearer")) { + return 0L; + } + String[] tokens = bearerToken.split(" "); + if (!(tokens.length == 2)) { + return 0L; + } + String token = tokens[1]; + + Optional> optionalMap = JwtToken.getClaims(token); + Map map = optionalMap + .orElseThrow(() -> new UnAuthenticatedException(ApiCode.UNAUTHORIZED)); + + return map.get("uid").asLong(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/bean/RequestDetail.java b/zsw-bxg/src/main/java/co/yixiang/app/common/bean/RequestDetail.java new file mode 100644 index 00000000..a7402afd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/bean/RequestDetail.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.bean; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +/** + * 请求详情信息 + * @author hupeng + * @date 2020-04-30 + */ +@Data +@Accessors(chain = true) +public class RequestDetail implements Serializable { + private static final long serialVersionUID = 2543641512850125440L; + + /** + * 请求ip地址 + */ + private String ip; + + /** + * 请求路径 + */ + private String path; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/constant/CommonConstant.java b/zsw-bxg/src/main/java/co/yixiang/app/common/constant/CommonConstant.java new file mode 100644 index 00000000..8ed77343 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/constant/CommonConstant.java @@ -0,0 +1,46 @@ +package co.yixiang.app.common.constant; + + +public interface CommonConstant { + + /** + * 默认页码为1 + */ + Integer DEFAULT_PAGE_INDEX = 1; + + /** + * 默认页大小为10 + */ + Integer DEFAULT_PAGE_SIZE = 10; + + /** + * 登录用户 + */ + String LOGIN_SYS_USER = "loginSysUser"; + + /** + * 登陆token + */ + String TOKEN = "token"; + /** + * 刷新token + */ + String REFRESH_TOKEN = "refresh_token"; + + /** + * 初始密码 + */ + String INIT_PWD = "123456"; + + /** + * 默认头像 + */ + String DEFAULT_HEAD_URL = ""; + + /** + * 管理员角色名称 + */ + String ADMIN_ROLE_NAME = "管理员"; + + String ADMIN_LOGIN = "adminLogin"; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/enums/SmsTypeEnum.java b/zsw-bxg/src/main/java/co/yixiang/app/common/enums/SmsTypeEnum.java new file mode 100644 index 00000000..6fc0fa27 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/enums/SmsTypeEnum.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 短信类型枚举 + */ +@Getter +@AllArgsConstructor +public enum SmsTypeEnum { + BIND("bind","绑定手机短信"), + LOGIN("login","登陆短信"), + REGISTER("register","注册短信"); + + private String value; + private String desc; + + public static SmsTypeEnum toType(String value) { + return Stream.of(SmsTypeEnum.values()) + .filter(c -> c.value == value) + .findAny() + .orElse(null); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/exception/BusinessException.java b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/BusinessException.java new file mode 100644 index 00000000..bb5e9a05 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/BusinessException.java @@ -0,0 +1,35 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.common.exception; +// +// +// +// +// +///** +// * 业务异常 +// * @author hupeng +// * @date 2020-04-30 +// */ +//public class BusinessException extends YshopException { +// private static final long serialVersionUID = -2303357122330162359L; +// +// public BusinessException(String message) { +// super(message); +// } +// +// public BusinessException(Integer errorCode, String message) { +// super(errorCode, message); +// } +// +// public BusinessException(ApiCode apiCode) { +// super(apiCode); +// } +// +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/exception/DaoException.java b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/DaoException.java new file mode 100644 index 00000000..10a50bfe --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/DaoException.java @@ -0,0 +1,34 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.common.exception; +// +// +//import co.yixiang.common.api.ApiCode; +// +// +///** +// * DAO异常 +// * @author hupeng +// * @date 2020-04-30 +// */ +//public class DaoException extends YshopException { +// private static final long serialVersionUID = -6912618737345878854L; +// +// public DaoException(String message) { +// super(message); +// } +// +// public DaoException(Integer errorCode, String message) { +// super(errorCode, message); +// } +// +// public DaoException(ApiCode apiCode) { +// super(apiCode); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/exception/UnAuthenticatedException.java b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/UnAuthenticatedException.java new file mode 100644 index 00000000..cc26eec9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/UnAuthenticatedException.java @@ -0,0 +1,30 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.common.exception; +// +//import co.yixiang.common.api.ApiCode; +// +///** +// * 认证异常 +// * @author hupeng +// * @date 2020-04-30 +// */ +//public class UnAuthenticatedException extends YshopException { +// public UnAuthenticatedException(String message) { +// super(message); +// } +// +// public UnAuthenticatedException(Integer errorCode, String message) { +// super(errorCode, message); +// } +// +// public UnAuthenticatedException(ApiCode apiCode) { +// super(apiCode); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/exception/YshopException.java b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/YshopException.java new file mode 100644 index 00000000..cfc11d4c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/exception/YshopException.java @@ -0,0 +1,60 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.common.exception; +// +// +// +//import co.yixiang.common.api.ApiCode; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +///** +// * 自定义异常 +// * @author hupeng +// * @date 2020-04-30 +// */ +//@Data +//@EqualsAndHashCode(callSuper = true) +//public class YshopException extends RuntimeException{ +// +// private static final long serialVersionUID = -2470461654663264392L; +// +// private Integer errorCode; +// private String message; +// +// public YshopException() { +// super(); +// } +// +// public YshopException(String message) { +// super(message); +// this.message = message; +// } +// +// public YshopException(Integer errorCode, String message) { +// super(message); +// this.errorCode = errorCode; +// this.message = message; +// } +// +// public YshopException(ApiCode apiCode) { +// super(apiCode.getMessage()); +// this.errorCode = apiCode.getCode(); +// this.message = apiCode.getMessage(); +// } +// +// public YshopException(String message, Throwable cause) { +// super(message, cause); +// } +// +// public YshopException(Throwable cause) { +// super(cause); +// } +// +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/handler/GlobalExceptionHandler.java b/zsw-bxg/src/main/java/co/yixiang/app/common/handler/GlobalExceptionHandler.java new file mode 100644 index 00000000..f5a5cb61 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/handler/GlobalExceptionHandler.java @@ -0,0 +1,186 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.app.common.handler; +// +// +//import co.yixiang.api.ApiCode; +//import co.yixiang.api.ApiResult; +//import co.yixiang.api.BusinessException; +//import co.yixiang.api.DaoException; +//import co.yixiang.api.UnAuthenticatedException; +//import co.yixiang.api.YshopException; +//import co.yixiang.app.common.bean.RequestDetail; +//import co.yixiang.app.common.util.RequestDetailThreadLocal; +//import co.yixiang.exception.BadLimitRequestException; +//import com.alibaba.fastjson.JSON; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.http.HttpStatus; +//import org.springframework.validation.BindingResult; +//import org.springframework.validation.FieldError; +//import org.springframework.web.HttpRequestMethodNotSupportedException; +//import org.springframework.web.bind.MethodArgumentNotValidException; +//import org.springframework.web.bind.annotation.ControllerAdvice; +//import org.springframework.web.bind.annotation.ExceptionHandler; +//import org.springframework.web.bind.annotation.ResponseStatus; +//import org.springframework.web.bind.annotation.RestController; +// +//import java.util.ArrayList; +//import java.util.Collections; +//import java.util.List; +// +///** +// * 全局异常 +// * @author hupeng +// * @date 2020-04-30 +// */ +//@ControllerAdvice +//@RestController +//@Slf4j +//public class GlobalExceptionHandler { +// +// /** +// * 非法参数验证异常 +// * +// * @param ex +// * @return +// */ +// @ExceptionHandler(MethodArgumentNotValidException.class) +// @ResponseStatus(value = HttpStatus.OK) +// public ApiResult handleMethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException ex) { +// printRequestDetail(); +// BindingResult bindingResult = ex.getBindingResult(); +// List list = new ArrayList<>(); +// List fieldErrors = bindingResult.getFieldErrors(); +// for (FieldError fieldError : fieldErrors) { +// list.add(fieldError.getDefaultMessage()); +// } +// +// Collections.sort(list); +// String msg = "不能为空"; +// if(!list.isEmpty()) { +// msg = list.get(0); +// } +// log.error(getApiCodeString(ApiCode.PARAMETER_EXCEPTION) + ":" + JSON.toJSONString(list)); +// return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION.getCode(), msg); +// } +// +// +// +// +// @ExceptionHandler(value = BadLimitRequestException.class) +// @ResponseStatus(HttpStatus.BAD_REQUEST) +// public ApiResult badLimitRequestException(BadLimitRequestException exception) { +// printRequestDetail(); +// printApiCodeException(ApiCode.SYSTEM_EXCEPTION, exception); +// return new ApiResult() +// .setStatus(ApiCode.BAD_LIMIT_EXCEPTION.getCode()) +// .setMsg(exception.getMessage()); +// } +// +// +// +// /** +// * 自定义业务/数据异常处理 +// * +// * @param exception +// * @return +// */ +// @ExceptionHandler(value = {YshopException.class}) +// @ResponseStatus(HttpStatus.OK) +// public ApiResult YshopException(YshopException exception) { +// printRequestDetail(); +// log.error("YshopException:", exception); +// int errorCode; +// if (exception instanceof BusinessException) { +// errorCode = ApiCode.BUSINESS_EXCEPTION.getCode(); +// } else if (exception instanceof DaoException) { +// errorCode = ApiCode.DAO_EXCEPTION.getCode(); +// } else if (exception instanceof UnAuthenticatedException) { +// errorCode = ApiCode.UNAUTHORIZED.getCode(); +// +// } else { +// errorCode = ApiCode.BUSINESS_EXCEPTION.getCode(); +// } +// System.out.println("======="); +// return new ApiResult() +// .setStatus(errorCode) +// .setMsg(exception.getMessage()); +// } +// +// +// +// +// +// /** +// * 默认的异常处理 +// * +// * @param exception +// * @return +// */ +// @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) +// @ResponseStatus(HttpStatus.OK) +// public ApiResult httpRequestMethodNotSupportedExceptionHandler(Exception exception) { +// printRequestDetail(); +// printApiCodeException(ApiCode.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION, exception); +// return ApiResult.fail(ApiCode.HTTP_REQUEST_METHOD_NOT_SUPPORTED_EXCEPTION.getCode(), exception.getMessage()); +// } +// +// /** +// * 默认的异常处理 +// * +// * @param exception +// * @return +// */ +// @ExceptionHandler(value = Exception.class) +// @ResponseStatus(HttpStatus.OK) +// public ApiResult exceptionHandler(Exception exception) { +// printRequestDetail(); +// printApiCodeException(ApiCode.SYSTEM_EXCEPTION, exception); +// // return ApiResult.fail(ApiCode.SYSTEM_EXCEPTION); +// +// return new ApiResult() +// .setStatus(ApiCode.FAIL.getCode()) +// .setMsg(exception.getMessage()); +// } +// +// +// /** +// * 打印请求详情 +// */ +// private void printRequestDetail() { +// RequestDetail requestDetail = RequestDetailThreadLocal.getRequestDetail(); +// if (requestDetail != null) { +// log.error("异常来源:ip: {}, path: {}", requestDetail.getIp(), requestDetail.getPath()); +// } +// } +// +// /** +// * 获取ApiCode格式化字符串 +// * +// * @param apiCode +// * @return +// */ +// private String getApiCodeString(ApiCode apiCode) { +// if (apiCode != null) { +// return String.format("errorCode: %s, errorMessage: %s", apiCode.getCode(), apiCode.getMessage()); +// } +// return null; +// } +// +// /** +// * 打印错误码及异常 +// * +// * @param apiCode +// * @param exception +// */ +// private void printApiCodeException(ApiCode apiCode, Exception exception) { +// log.error(getApiCodeString(apiCode), exception); +// } +// +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/interceptor/AuthCheck.java b/zsw-bxg/src/main/java/co/yixiang/app/common/interceptor/AuthCheck.java new file mode 100644 index 00000000..3c11ffb7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/interceptor/AuthCheck.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.interceptor; + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @ClassName 自定义权限注解 + * @Author hupeng <610796224@qq.com> + * @Date 2020/4/30 + **/ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface AuthCheck { + int value() default 4; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/interceptor/PermissionInterceptor.java b/zsw-bxg/src/main/java/co/yixiang/app/common/interceptor/PermissionInterceptor.java new file mode 100644 index 00000000..a6ff95f6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/interceptor/PermissionInterceptor.java @@ -0,0 +1,130 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.interceptor; + + +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiCode; +import co.yixiang.api.UnAuthenticatedException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.util.JwtToken; +import co.yixiang.constant.ShopConstants; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.RedisUtils; +import com.auth0.jwt.interfaces.Claim; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; +import java.util.Optional; + +/** + * 权限拦截器 + * @author hupeng + * @date 2020-04-30 + */ +public class PermissionInterceptor extends HandlerInterceptorAdapter { + + @Autowired + private YxUserService userService; + + @Autowired + private RedisUtils redisUtils; + + public PermissionInterceptor() { + super(); + } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + Optional authCheck = this.getAuthCheck(handler); + if (!authCheck.isPresent()) { + return true; + } + + String bearerToken = request.getHeader("Authorization"); + if (StrUtil.isEmpty(bearerToken)) { + throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED); + } + + if (!bearerToken.startsWith("Bearer")) { + throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED); + } + String[] tokens = bearerToken.split(" "); + if (!(tokens.length == 2)) { + throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED); + } + String token = tokens[1]; + + Optional> optionalMap = JwtToken.getClaims(token); + Map map = optionalMap + .orElseThrow(() -> new UnAuthenticatedException(ApiCode.UNAUTHORIZED)); + + String uName = map.get("uName").asString(); + + //检测用户是否被踢出 + if (redisUtils.get(ShopConstants.YSHOP_APP_LOGIN_USER + uName + ":" + token) == null) { + throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED); + } + boolean valid = this.hasPermission(authCheck.get(), map); + if(valid){ + this.setToThreadLocal(map); + } + return valid; + } + + private void setToThreadLocal(Map map) { + Integer uid = map.get("uid").asInt(); + Integer scope = map.get("scope").asInt(); + YxUser user = userService.getById(uid); + if(user == null) { + throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION); + } + LocalUser.set(user, scope); + } + + private boolean hasPermission(AuthCheck authCheck, Map map) { + Integer level = authCheck.value(); + Integer scope = map.get("scope").asInt(); + if (level > scope) { + throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION); + } + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + super.postHandle(request, response, handler, modelAndView); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + LocalUser.clear(); + super.afterCompletion(request, response, handler, ex); + } + + private Optional getAuthCheck(Object handler) { + if (handler instanceof HandlerMethod) { + HandlerMethod handlerMethod = (HandlerMethod) handler; + AuthCheck authCheck = handlerMethod.getMethod().getAnnotation(AuthCheck.class); + if (authCheck == null) { + return Optional.empty(); + } + return Optional.of(authCheck); + } + return Optional.empty(); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/param/QueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/common/param/QueryParam.java new file mode 100644 index 00000000..d985b515 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/param/QueryParam.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.param; + + +import co.yixiang.app.common.constant.CommonConstant; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + + +@Data +@ApiModel("查询参数对象") +public abstract class QueryParam implements Serializable{ + private static final long serialVersionUID = -3263921252635611410L; + + @ApiModelProperty(value = "页码,默认为1") + private Integer page = CommonConstant.DEFAULT_PAGE_INDEX; + @ApiModelProperty(value = "页大小,默认为10") + private Integer limit = CommonConstant.DEFAULT_PAGE_SIZE; + @ApiModelProperty(value = "搜索字符串") + private String keyword; + + public void setPage(Integer page) { + if (page == null || page <= 0){ + this.page = CommonConstant.DEFAULT_PAGE_INDEX; + }else{ + this.page = page; + } + } + + public void setLimit(Integer limit) { + if (limit == null || limit <= 0){ + this.limit = CommonConstant.DEFAULT_PAGE_SIZE; + }else{ + this.limit = limit; + } + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/BrowserUtil.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/BrowserUtil.java new file mode 100644 index 00000000..2aab3169 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/BrowserUtil.java @@ -0,0 +1,69 @@ +package co.yixiang.app.common.util; + +import javax.servlet.http.HttpServletRequest; + + +/** + * 浏览器工具类 + * @author hupeng + * @date 2020-04-30 + */ +public final class BrowserUtil { + public static final String IE = "msie"; + public static final String FIREFOX = "firefox"; + public static final String CHROME = "chrome"; + + private BrowserUtil() { + throw new AssertionError(); + } + + /** + * 获取当前浏览器名称 + * + * @param request + * @return 返回浏览器名称 + */ + public static String getCurrent(HttpServletRequest request) { + String userAgent = request.getHeader("USER-AGENT").toLowerCase(); + if (userAgent != null && !("".equals(userAgent.trim()))) { + if (userAgent.indexOf(CHROME) >= 0) { + return CHROME; + } else if (userAgent.indexOf(FIREFOX) >= 0) { + return FIREFOX; + } else if (userAgent.indexOf(IE) >= 0) { + return IE; + } + } + return null; + } + + /** + * 是否是IE浏览器 + * + * @param request + * @return + */ + public static boolean isIe(HttpServletRequest request) { + return IE.equals(getCurrent(request)); + } + + /** + * 是否是Firefox浏览器 + * + * @param request + * @return + */ + public static boolean isFirefox(HttpServletRequest request) { + return FIREFOX.equals(getCurrent(request)); + } + + /** + * 是否是Chrome浏览器 + * + * @param request + * @return + */ + public static boolean isChrome(HttpServletRequest request) { + return CHROME.equals(getCurrent(request)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/CityTreeUtil.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/CityTreeUtil.java new file mode 100644 index 00000000..2f21f3fa --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/CityTreeUtil.java @@ -0,0 +1,90 @@ +package co.yixiang.app.common.util; + + + +import co.yixiang.modules.user.vo.CityVo; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName 树形工具类 + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/22 + **/ +public class CityTreeUtil { + /** + * 获得指定节点下所有归档 + * + * @param list + * @param parentId + * @return + */ + public static List list2TreeConverter(List list, int parentId) { + List returnList = new ArrayList<>(); + + for (CityVo res : list) { + //判断对象是否为根节点 + + if (res.getPid() == parentId) { + //该节点为根节点,开始递归 + + //通过递归为节点设置childList + recursionFn(list, res); + + returnList.add(res); + } + } + + return returnList; + } + + /** + * 递归列表 + * 通过递归,给指定t节点设置childList + * + * @param list + * @param t + */ + public static void recursionFn(List list, CityVo t) { + //只能获取当前t节点的子节点集,并不是所有子节点集 + List childsList = getChildList(list, t); + + //设置他的子集对象集 + t.setC(childsList); + + //迭代子集对象集 + + //遍历完,则退出递归 + for (CityVo nextChild : childsList) { + + //判断子集对象是否还有子节点 + if (!CollectionUtils.isEmpty(childsList)) { + //有下一个子节点,继续递归 + recursionFn(list, nextChild); + } + } + } + + /** + * 获得指定节点下的所有子节点 + * + * @param list + * @param t + * @return + */ + public static List getChildList(List list, CityVo t) { + List childsList = new ArrayList<>(); + //遍历集合元素,如果元素的Parentid==指定元素的id,则说明是该元素的子节点 + for (CityVo t1 : list) { + if (t1.getPid().equals(t.getV())) { + childsList.add(t1); + } + } + + return childsList; + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/IpUtil.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/IpUtil.java new file mode 100644 index 00000000..9acdecb2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/IpUtil.java @@ -0,0 +1,66 @@ +package co.yixiang.app.common.util; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.net.InetAddress; +import java.net.UnknownHostException; + + +/** + * 获取IP地址工具类 + * @author hupeng + * @date 2020-04-30 + */ +public final class IpUtil { + + private static final String UNKNOWN = "unknown"; + private static final String IPV6_LOCAL = "0:0:0:0:0:0:0:1"; + + private IpUtil(){ + throw new AssertionError(); + } + + /** + * 获取请求用户的IP地址 + * @return + */ + public static String getRequestIp() { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest request = attributes.getRequest(); + return getRequestIp(request); + } + + /** + * 获取请求用户的IP地址 + * @param request + * @return + */ + public static String getRequestIp(HttpServletRequest request) { + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + + if (IPV6_LOCAL.equals(ip)){ + ip = getLocalhostIp(); + } + return ip; + } + + public static String getLocalhostIp(){ + try { + return InetAddress.getLocalHost().getHostAddress(); + } catch (UnknownHostException e) { + } + return null; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/JacksonUtil.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/JacksonUtil.java new file mode 100644 index 00000000..f4d491cb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/JacksonUtil.java @@ -0,0 +1,184 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.app.common.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class JacksonUtil { + + private static final Log logger = LogFactory.getLog(JacksonUtil.class); + + public static String parseString(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + return leaf.asText(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + + public static List parseStringList(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + + if (leaf != null) { + return mapper.convertValue(leaf, new TypeReference>() { + }); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Integer parseInteger(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + return leaf.asInt(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static List parseIntegerList(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + + if (leaf != null) { + return mapper.convertValue(leaf, new TypeReference>() { + }); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + + public static Boolean parseBoolean(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + return leaf.asBoolean(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Short parseShort(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + Integer value = leaf.asInt(); + return value.shortValue(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Byte parseByte(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + Integer value = leaf.asInt(); + return value.byteValue(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static T parseObject(String body, String field, Class clazz) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + node = node.get(field); + return mapper.treeToValue(node, clazz); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Object toNode(String json) { + if (json == null) { + return null; + } + ObjectMapper mapper = new ObjectMapper(); + try { + + return mapper.readTree(json); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + + return null; + } + + public static Map toMap(String data) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.readValue(data, new TypeReference>() { + }); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static String toJson(Object data) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.writeValueAsString(data); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/JwtToken.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/JwtToken.java new file mode 100644 index 00000000..9aa2a915 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/JwtToken.java @@ -0,0 +1,107 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.util; + +import cn.hutool.core.date.DateUtil; +import com.auth0.jwt.JWT; +import com.auth0.jwt.JWTVerifier; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.exceptions.JWTVerificationException; +import com.auth0.jwt.interfaces.Claim; +import com.auth0.jwt.interfaces.DecodedJWT; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * @ClassName JwtToken + * @Author hupeng <610796224@qq.com> + * @Date 2020/4/30 + **/ +@Component +public class JwtToken { + + private static String jwtKey; + private static Integer expiredTimeIn; + private static Integer defaultScope = 8; + + @Value("${yshop.security.jwt-key}") + public void setJwtKey(String jwtKey) { + JwtToken.jwtKey = jwtKey; + } + + @Value("${yshop.security.token-expired-in}") + public void setExpiredTimeIn(Integer expiredTimeIn) { + JwtToken.expiredTimeIn = expiredTimeIn; + } + + public static Optional> getClaims(String token) { + DecodedJWT decodedJWT; + Algorithm algorithm = Algorithm.HMAC256(JwtToken.jwtKey); + JWTVerifier jwtVerifier = JWT.require(algorithm).build(); + try { + decodedJWT = jwtVerifier.verify(token); + } catch (JWTVerificationException e) { + return Optional.empty(); + } + return Optional.of(decodedJWT.getClaims()); + } + + public static Boolean verifyToken(String token) { + try { + Algorithm algorithm = Algorithm.HMAC256(JwtToken.jwtKey); + JWTVerifier verifier = JWT.require(algorithm).build(); + verifier.verify(token); + } catch (JWTVerificationException e) { + return false; + } + return true; + } + + public static String getExpireTime(String token){ + return DateUtil.formatDateTime(JWT.decode(token).getExpiresAt()); + } + + + public static String makeToken(Long uid,String uName, Integer scope) { + return JwtToken.getToken(uid,uName, scope); + } + + public static String makeToken(Long uid,String uName) { + return JwtToken.getToken(uid,uName, JwtToken.defaultScope); + } + + private static String getToken(Long uid,String uName, Integer scope) { + Algorithm algorithm = Algorithm.HMAC256(JwtToken.jwtKey); + Map map = JwtToken.calculateExpiredIssues(); + + return JWT.create() + .withClaim("uid", uid) + .withClaim("scope", scope) + .withClaim("uName", uName) + .withExpiresAt(map.get("expiredTime")) + .withIssuedAt(map.get("now")) + .sign(algorithm); + } + + private static Map calculateExpiredIssues() { + Map map = new HashMap<>(); + Calendar calendar = Calendar.getInstance(); + Date now = calendar.getTime(); + calendar.add(Calendar.SECOND, JwtToken.expiredTimeIn); + map.put("now", now); + map.put("expiredTime", calendar.getTime()); + return map; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/PhoneUtil.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/PhoneUtil.java new file mode 100644 index 00000000..09d03aea --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/PhoneUtil.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.util; + + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +/** + * 手机号码工具类 + * @author hupeng + * @date 2020-04-30 + */ +@Slf4j +public class PhoneUtil { + + /** + * 手机号码长度 + */ + private static final int PHONE_LENGTH = 11; + + /** + * 脱敏*号 + */ + private static final String ASTERISK = "****"; + + /** + * 手机号码脱敏 + * 截取手机号码前三位,后4为,中间4位使用*号代替 + * 18812345678 + * 188****5678 + * + * @param phone + * @return + */ + public static String desensitize(String phone) { + // 校验手机号码 + if (StringUtils.isBlank(phone)) { + return null; + } + if (phone.length() != PHONE_LENGTH) { + log.error("手机号码不合法:" + phone); + return phone; + } + + String before = phone.substring(0,3); + String after = phone.substring(7,11); + String desensitizePhone = before + "****" + after; + return desensitizePhone; + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/RequestDetailThreadLocal.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/RequestDetailThreadLocal.java new file mode 100644 index 00000000..f75f294f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/RequestDetailThreadLocal.java @@ -0,0 +1,38 @@ +package co.yixiang.app.common.util; + +import co.yixiang.app.common.bean.RequestDetail; + + +/** + * 记录请求详情信息到当前线程中 + * @author hupeng + * @date 2020-04-30 + */ +public class RequestDetailThreadLocal { + + private static ThreadLocal threadLocal = new ThreadLocal<>(); + + /** + * 设置请求信息到当前线程中 + * + * @param requestDetail + */ + public static void setRequestDetail(RequestDetail requestDetail) { + threadLocal.set(requestDetail); + } + + /** + * 从当前线程中获取请求信息 + */ + public static RequestDetail getRequestDetail() { + return threadLocal.get(); + } + + /** + * 销毁 + */ + public static void remove() { + threadLocal.remove(); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/RequestUtils.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/RequestUtils.java new file mode 100644 index 00000000..4d10072f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/RequestUtils.java @@ -0,0 +1,20 @@ +package co.yixiang.app.common.util; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * @ClassName 获取Request工具类 + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/26 + **/ +public class RequestUtils { + + public static HttpServletRequest getRequest() { + ServletRequestAttributes ra= (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + return ra.getRequest(); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java new file mode 100644 index 00000000..a7c8f07d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java @@ -0,0 +1,70 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.common.util; + + +import co.yixiang.utils.RedisUtils; +import com.aliyuncs.CommonRequest; +import com.aliyuncs.CommonResponse; +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.http.MethodType; +import com.aliyuncs.profile.DefaultProfile; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +/** + * @ClassName 阿里云短信 + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/26 + **/ +@Slf4j +@Configuration(proxyBeanMethods = false) +public class SmsUtils { + + private static RedisUtils redisUtils; + + @Autowired + public SmsUtils(RedisUtils redisUtils){ + SmsUtils.redisUtils = redisUtils; + } + /** + * 发送短信 + * @param phoneNumbers 手机号 + * @param templateParam 短信模板变量对应的实际值,JSON格式 + */ + public static void sendSms(String phoneNumbers, String templateParam) throws ClientException { + String regionId = redisUtils.getY("sms_region"); + String accessKeyId = redisUtils.getY("sms_access_key"); + String accessKeySecret = redisUtils.getY("sms_access_secret"); + String sign = redisUtils.getY("sms_sign"); + String templateId = redisUtils.getY("sms_templateId"); + DefaultProfile profile = DefaultProfile.getProfile( + regionId, + accessKeyId, + accessKeySecret); + IAcsClient client = new DefaultAcsClient(profile); + + CommonRequest request = new CommonRequest(); + + request.setMethod(MethodType.POST); + request.setDomain("dysmsapi.aliyuncs.com"); + request.setVersion("2017-05-25"); + request.setAction("SendSms"); + request.putQueryParameter("RegionId", regionId); + request.putQueryParameter("PhoneNumbers", phoneNumbers); + request.putQueryParameter("SignName", sign); + request.putQueryParameter("TemplateCode", templateId); + request.putQueryParameter("TemplateParam", templateParam); + CommonResponse response = client.getCommonResponse(request); + System.out.println(response.getData()); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/SpringContextUtil.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/SpringContextUtil.java new file mode 100644 index 00000000..ee2f24e9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/SpringContextUtil.java @@ -0,0 +1,41 @@ +package co.yixiang.app.common.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + + +/** + * Spring工具类,获取Spring上下文对象等 + * @author hupeng + * @date 2020-04-30 + */ +@Component +public class SpringContextUtil implements ApplicationContextAware { + + private static ApplicationContext applicationContext = null; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + if(SpringContextUtil.applicationContext == null){ + SpringContextUtil.applicationContext = applicationContext; + } + } + + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + public static Object getBean(String name){ + return getApplicationContext().getBean(name); + } + + public static T getBean(Class clazz){ + return getApplicationContext().getBean(clazz); + } + + public static T getBean(String name,Class clazz){ + return getApplicationContext().getBean(name, clazz); + } +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/IdParam.java b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/IdParam.java new file mode 100644 index 00000000..632cb588 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/IdParam.java @@ -0,0 +1,19 @@ +package co.yixiang.app.common.web.param; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + +@Data +@ApiModel("ID参数") +public class IdParam implements Serializable { + private static final long serialVersionUID = -5353973980674510450L; + + @NotBlank(message="ID不能为空") + @ApiModelProperty(value = "地址ID") + private String id; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/IdStatusParam.java b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/IdStatusParam.java new file mode 100644 index 00000000..5fdb56ff --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/IdStatusParam.java @@ -0,0 +1,41 @@ +package co.yixiang.app.common.web.param; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +@ApiModel("主键状态VO") +public class IdStatusParam implements Serializable { + private static final long serialVersionUID = -7581307955242965701L; + + @ApiModelProperty("主键ID") + private String id; + + @ApiModelProperty("状态,1:启用 0:禁用") + private Integer status; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + @Override + public String toString() { + return "IdStatusVo{" + + "id='" + id + '\'' + + ", status=" + status + + '}'; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/NameParam.java b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/NameParam.java new file mode 100644 index 00000000..4017d6ea --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/NameParam.java @@ -0,0 +1,30 @@ +package co.yixiang.app.common.web.param; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + + +@ApiModel("名称参数") +public class NameParam implements Serializable { + private static final long serialVersionUID = -3710501706034574149L; + + @ApiModelProperty("名称") + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "NameParam{" + + "name='" + name + '\'' + + '}'; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/OrderQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/OrderQueryParam.java new file mode 100644 index 00000000..163140ef --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/web/param/OrderQueryParam.java @@ -0,0 +1,35 @@ +package co.yixiang.app.common.web.param; + +import cn.hutool.core.collection.CollectionUtil; +import co.yixiang.common.web.param.QueryParam; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Arrays; +import java.util.List; + + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("可排序查询参数对象") +public abstract class OrderQueryParam extends QueryParam { + private static final long serialVersionUID = 57714391204790143L; + + @ApiModelProperty(value = "排序") + private List orders; + + public void defaultOrder(OrderItem orderItem){ + this.defaultOrders(Arrays.asList(orderItem)); + } + + public void defaultOrders(List orderItems){ + if (CollectionUtil.isEmpty(orderItems)){ + return; + } + this.orders = orderItems; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/web/vo/CommonIdName.java b/zsw-bxg/src/main/java/co/yixiang/app/common/web/vo/CommonIdName.java new file mode 100644 index 00000000..ca5604ee --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/web/vo/CommonIdName.java @@ -0,0 +1,58 @@ +package co.yixiang.app.common.web.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + +@ApiModel("ID-NAME-VO") +public class CommonIdName { + + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("名称") + private String name; + + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public CommonIdName(String id, String name) { + super(); + this.id = id; + this.name = name; + + } + + + public CommonIdName() { + super(); + } + + + @Override + public String toString() { + return "CommonIdName [id=" + id + ", name=" + name + "]"; + } + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/web/vo/Paging.java b/zsw-bxg/src/main/java/co/yixiang/app/common/web/vo/Paging.java new file mode 100644 index 00000000..f7e89737 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/web/vo/Paging.java @@ -0,0 +1,60 @@ +package co.yixiang.app.common.web.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; + + +@ApiModel("分页") +@SuppressWarnings("unchecked") +public class Paging implements Serializable { + private static final long serialVersionUID = -1683800405530086022L; + + @ApiModelProperty("总行数") + @JSONField(name = "total") + @JsonProperty("total") + private long total = 0; + + @ApiModelProperty("数据列表") + @JSONField(name = "records") + @JsonProperty("records") + private List records = Collections.emptyList(); + + public Paging() { + } + + public Paging(IPage page) { + this.total = page.getTotal(); + this.records = page.getRecords(); + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public List getRecords() { + return records; + } + + public void setRecords(List records) { + this.records = records; + } + + @Override + public String toString() { + return "Paging{" + + "total=" + total + + ", records=" + records + + '}'; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/BargainShareParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/BargainShareParam.java new file mode 100644 index 00000000..b6f6ac93 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/BargainShareParam.java @@ -0,0 +1,24 @@ +package co.yixiang.app.modules.activity.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName BargainShareParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/20 + **/ +@Getter +@Setter +public class BargainShareParam { + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "砍价产品ID") + private String bargainId; + + @ApiModelProperty(value = "来源") + private String from; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/PinkCancelParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/PinkCancelParam.java new file mode 100644 index 00000000..68cb5940 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/PinkCancelParam.java @@ -0,0 +1,25 @@ +package co.yixiang.app.modules.activity.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName PinkCancelParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/23 + **/ +@Getter +@Setter +public class PinkCancelParam { + + @NotBlank(message = "参数错误") + @ApiModelProperty(value = "拼团产品ID") + private String id; + + @NotBlank(message = "参数错误") + @ApiModelProperty(value = "团购产品id") + private String cid; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/PinkShareParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/PinkShareParam.java new file mode 100644 index 00000000..12bbadf7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/PinkShareParam.java @@ -0,0 +1,22 @@ +package co.yixiang.app.modules.activity.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName BargainShareParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/20 + **/ +@Getter +@Setter +public class PinkShareParam { + @NotBlank(message = "参数有误") + private String id; + + @ApiModelProperty(value = "来源") + private String from; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainQueryParam.java new file mode 100644 index 00000000..c157849a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.activity.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 砍价表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="砍价表查询参数", description="砍价表查询参数") +public class YxStoreBargainQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainUserHelpQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainUserHelpQueryParam.java new file mode 100644 index 00000000..078e2618 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainUserHelpQueryParam.java @@ -0,0 +1,32 @@ +package co.yixiang.app.modules.activity.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * 砍价用户帮助表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="砍价用户帮助表查询参数", description="砍价用户帮助表查询参数") +public class YxStoreBargainUserHelpQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "砍价产品ID") + private String bargainId; + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "砍价用户id") + private String bargainUserUid; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainUserQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainUserQueryParam.java new file mode 100644 index 00000000..15a65326 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreBargainUserQueryParam.java @@ -0,0 +1,32 @@ +package co.yixiang.app.modules.activity.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * 用户参与砍价表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="用户参与砍价表查询参数", description="用户参与砍价表查询参数") +public class YxStoreBargainUserQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @NotBlank(message = "参数错误") + @ApiModelProperty(value = "砍价用户ID") + private String bargainUserUid; + + @ApiModelProperty(value = "砍价产品ID") + private String bargainId; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreCombinationQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreCombinationQueryParam.java new file mode 100644 index 00000000..d3dcb1e1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreCombinationQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.activity.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 拼团产品表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-11-19 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="拼团产品表查询参数", description="拼团产品表查询参数") +public class YxStoreCombinationQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStorePinkQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStorePinkQueryParam.java new file mode 100644 index 00000000..80bcc0cf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStorePinkQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.activity.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 拼团表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-11-19 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="拼团表查询参数", description="拼团表查询参数") +public class YxStorePinkQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreSeckillQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreSeckillQueryParam.java new file mode 100644 index 00000000..7d115b09 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/param/YxStoreSeckillQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.activity.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 商品秒杀产品表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-14 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="商品秒杀产品表查询参数", description="商品秒杀产品表查询参数") +public class YxStoreSeckillQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java new file mode 100644 index 00000000..7895f7ac --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreBargainController.java @@ -0,0 +1,310 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.activity.rest; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.activity.param.BargainShareParam; +import co.yixiang.app.modules.activity.param.YxStoreBargainUserHelpQueryParam; +import co.yixiang.app.modules.activity.param.YxStoreBargainUserQueryParam; +import co.yixiang.app.modules.services.CreatShareProductService; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.YxStoreBargainUserHelpService; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.vo.BargainCountVo; +import co.yixiang.modules.activity.vo.BargainVo; +import co.yixiang.modules.activity.vo.TopCountVo; +import co.yixiang.modules.activity.vo.YxStoreBargainQueryVo; +import co.yixiang.modules.activity.vo.YxStoreBargainUserHelpQueryVo; +import co.yixiang.modules.activity.vo.YxStoreBargainUserQueryVo; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.google.common.collect.Maps; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + *

+ * 砍价 前端控制器 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ + +@RestController +@RequestMapping +@Api(value = "砍价商品", tags = "营销:砍价商品") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@SuppressWarnings("unchecked") +public class AppStoreBargainController { + + private final YxStoreBargainService storeBargainService; + private final YxStoreBargainUserService storeBargainUserService; + private final YxStoreBargainUserHelpService storeBargainUserHelpService; + private final YxUserService userService; + private final YxSystemConfigService systemConfigService; + private final CreatShareProductService creatShareProductService; + + + + + + /** + * 砍价产品列表 + */ + @GetMapping("/bargain/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "砍价产品列表",notes = "砍价产品列表") + public ApiResult getYxStoreBargainPageList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + + return ApiResult.resultPage(storeBargainService.getList(page, limit),limit); + } + + /** + * 砍价详情 + */ + @AppLog(value = "查看砍价产品", type = 1) + @AuthCheck + @GetMapping("/bargain/detail/{id}") + @ApiOperation(value = "砍价详情",notes = "砍价详情",response = YxStoreBargainQueryVo.class) + public ApiResult getYxStoreBargain(@PathVariable Long id){ + if(ObjectUtil.isNull(id)) { + throw new YshopException("参数错误"); + } + YxUser yxUser = LocalUser.getUser(); + return ApiResult.ok(storeBargainService.getDetail(id,yxUser)); + } + + /** + * 砍价详情统计 + */ + @AppLog(value = "砍价详情统计", type = 1) + @AuthCheck + @PostMapping("/bargain/help/count") + @ApiOperation(value = "砍价详情统计",notes = "砍价详情统计") + public ApiResult helpCount(@Validated @RequestBody YxStoreBargainUserHelpQueryParam param){ + Long bargainId = Long.valueOf(param.getBargainId()); + Long bargainUserUid = Long.valueOf(param.getBargainUserUid()); + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(storeBargainService.helpCount(bargainId,bargainUserUid,uid)); + } + + /** + * 砍价顶部统计 + */ + @PostMapping("/bargain/share") + @ApiOperation(value = "砍价顶部统计",notes = "砍价顶部统计") + public ApiResult topCount(@Validated @RequestBody BargainShareParam param){ + Long bargainId = null; + if(NumberUtil.isNumber(param.getBargainId())) { + bargainId = Long.valueOf(param.getBargainId()); + } + return ApiResult.ok(storeBargainService.topCount(bargainId)); + } + + /** + * 参与砍价 + */ + @AppLog(value = "参与砍价", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/bargain/start") + @ApiOperation(value = "参与砍价",notes = "参与砍价") + public ApiResult start(@Validated @RequestBody BargainShareParam param){ + Long bargainId = null; + if(NumberUtil.isNumber(param.getBargainId())) { + bargainId = Long.valueOf(param.getBargainId()); + } + Long uid = LocalUser.getUser().getUid(); + storeBargainUserService.setBargain(bargainId,uid); + return ApiResult.ok(); + } + + /** + * 帮助好友砍价 + */ + @AppLog(value = "帮助好友砍价", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/bargain/help") + @ApiOperation(value = "帮助好友砍价",notes = "帮助好友砍价") + public ApiResult> help(@Validated @RequestBody YxStoreBargainUserHelpQueryParam param){ + Long bargainId = Long.valueOf(param.getBargainId()); + Long bargainUserUid = Long.valueOf(param.getBargainUserUid()); + Long uid = LocalUser.getUser().getUid(); + Map map = Maps.newHashMap(); + boolean isBargainUserHelp = storeBargainUserService + .isBargainUserHelp(bargainId,bargainUserUid,uid); + if(!isBargainUserHelp){ + map.put("status","SUCCESSFUL"); + return ApiResult.ok(map); + } + + storeBargainService.doHelp(bargainId,bargainUserUid,uid); + map.put("status","SUCCESS"); + return ApiResult.ok(map); + } + + /** + * 获取砍掉金额 + */ + @AuthCheck + @PostMapping("/bargain/help/price") + @ApiOperation(value = "获取砍掉金额",notes = "获取砍掉金额") + public ApiResult> price(@Validated @RequestBody YxStoreBargainUserHelpQueryParam param){ + Long bargainId = Long.valueOf(param.getBargainId()); + Long bargainUserUid = Long.valueOf(param.getBargainUserUid()); + Long uid = LocalUser.getUser().getUid(); + Map map = Maps.newHashMap(); + YxStoreBargainUser storeBargainUser = storeBargainUserService + .getBargainUserInfo(bargainId,bargainUserUid); + if(ObjectUtil.isNull(storeBargainUser)){ + map.put("price",0); + return ApiResult.ok(map); + } + YxStoreBargainUserHelp storeBargainUserHelp = storeBargainUserHelpService + .getOne(new LambdaQueryWrapper() + .eq(YxStoreBargainUserHelp::getBargainId,bargainId) + .eq(YxStoreBargainUserHelp::getBargainUserId,storeBargainUser.getId()) + .eq(YxStoreBargainUserHelp::getUid,uid).last("limit 1")); + if(ObjectUtil.isNull(storeBargainUserHelp)){ + map.put("price",0); + }else{ + map.put("price",storeBargainUserHelp.getPrice()); + } + return ApiResult.ok(map); + } + + /** + * 好友帮 + */ + @PostMapping("/bargain/help/list") + @ApiOperation(value = "好友帮",notes = "好友帮") + public ApiResult> helpList(@Validated @RequestBody YxStoreBargainUserHelpQueryParam param){ + Long bargainId = Long.valueOf(param.getBargainId()); + Long bargainUserUid = Long.valueOf(param.getBargainUserUid()); + return ApiResult.ok(storeBargainUserHelpService.getList(bargainId,bargainUserUid + ,param.getPage(),param.getLimit())); + } + + /** + * 获取开启砍价用户信息 + */ + @PostMapping("/bargain/start/user") + @ApiOperation(value = "获取开启砍价用户信息",notes = "获取开启砍价用户信息") + public ApiResult startUser(@Validated @RequestBody YxStoreBargainUserQueryParam param){ + Long bargainUserUid = Long.valueOf(param.getBargainUserUid()); + return ApiResult.ok(userService.getYxUserById(bargainUserUid)); + } + + /** + * 砍价海报 + */ + @AuthCheck + @PostMapping("/bargain/poster") + @ApiOperation(value = "砍价海报",notes = "砍价海报") + public ApiResult> poster(@Validated @RequestBody BargainShareParam param){ + Long bargainId = Long.valueOf(param.getBargainId()); + String siteUrl = systemConfigService.getData(SystemConfigConstants.SITE_URL); + if(StrUtil.isBlank(siteUrl)){ + throw new YshopException("未配置h5地址"); + } + String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL); + if(StrUtil.isBlank(apiUrl)){ + throw new YshopException("未配置api地址"); + } + YxUser userInfo = LocalUser.getUser(); + Map map = Maps.newHashMap(); + String url = creatShareProductService.getBargainPosterUrl(bargainId,userInfo,siteUrl,apiUrl,"",param.getFrom()); + map.put("url",url); + return ApiResult.ok(map); + } + + + /** + * 砍价列表(已参与) + */ + @AuthCheck + @GetMapping("/bargain/user/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "砍价列表(已参与)",notes = "砍价列表(已参与)") + public ApiResult> bargainUserList( + @RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + Long uid = LocalUser.getUser().getUid(); + List yxStoreBargainUserQueryVos = storeBargainUserService + .bargainUserList(uid,page,limit); + if(yxStoreBargainUserQueryVos.isEmpty()) { + throw new YshopException("暂无参与砍价"); + } + return ApiResult.ok(yxStoreBargainUserQueryVos); + } + + /** + * 砍价取消 + */ + @AppLog(value = "取消砍价", type = 1) + @AuthCheck + @PostMapping("/bargain/user/cancel") + @ApiOperation(value = "砍价取消",notes = "砍价取消") + public ApiResult bargainCancel(@Validated @RequestBody BargainShareParam param){ + Long bargainId = Long.valueOf(param.getBargainId()); + Long uid = LocalUser.getUser().getUid(); + storeBargainUserService.bargainCancel(bargainId,uid); + return ApiResult.ok(); + } + + + + + + + + + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java new file mode 100644 index 00000000..a272ea35 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreCombinationController.java @@ -0,0 +1,162 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.activity.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.activity.param.PinkCancelParam; +import co.yixiang.app.modules.activity.param.PinkShareParam; +import co.yixiang.app.modules.services.CreatShareProductService; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.modules.activity.service.YxStoreCombinationService; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.activity.vo.CombinationQueryVo; +import co.yixiang.modules.activity.vo.PinkInfoVo; +import co.yixiang.modules.activity.vo.StoreCombinationVo; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.user.domain.YxUser; +import com.google.common.collect.Maps; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + *

+ * 拼团前端控制器 + *

+ * + * @author hupeng + * @since 2019-11-19 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "拼团", tags = "营销:拼团") +public class AppStoreCombinationController { + + private final YxStoreCombinationService storeCombinationService; + private final YxStorePinkService storePinkService; + private final YxSystemConfigService systemConfigService; + private final YxStoreProductRelationService relationService; + private final CreatShareProductService creatShareProductService; + + private String path = ""; + + + /** + * 拼团产品列表 + */ + @GetMapping("/combination/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "拼团产品列表",notes = "拼团产品列表") + public ApiResult getList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + return ApiResult.ok(storeCombinationService.getList(page, limit)); + } + + /** + * 拼团产品详情 + */ + @AppLog(value = "查看拼团产品详情", type = 1) + @AuthCheck + @GetMapping("/combination/detail/{id}") + @ApiOperation(value = "拼团产品详情",notes = "拼团产品详情") + public ApiResult detail(@PathVariable Long id){ + if(ObjectUtil.isNull(id)) { + throw new YshopException("参数错误"); + } + Long uid = LocalUser.getUser().getUid(); + StoreCombinationVo storeCombinationVo = storeCombinationService.getDetail(id,uid); + storeCombinationVo.setUserCollect(relationService + .isProductRelation(storeCombinationVo.getStoreInfo().getProductId(),uid)); + return ApiResult.ok(storeCombinationVo); + } + + /** + * 拼团明细 + */ + @AppLog(value = "查看拼团明细", type = 1) + @AuthCheck + @GetMapping("/combination/pink/{id}") + @ApiOperation(value = "拼团明细",notes = "拼团明细") + public ApiResult pink(@PathVariable Long id){ + if(ObjectUtil.isNull(id)) { + throw new YshopException("参数错误"); + } + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(storePinkService.pinkInfo(id,uid)); + } + + /** + * 拼团海报 + */ + @AppLog(value = "生成拼团海报", type = 1) + @AuthCheck + @PostMapping("/combination/poster") + @ApiOperation(value = "拼团海报",notes = "拼团海报") + public ApiResult poster(@Validated @RequestBody PinkShareParam param){ + String siteUrl = systemConfigService.getData(SystemConfigConstants.SITE_URL); + if(StrUtil.isEmpty(siteUrl)){ + throw new YshopException("未配置h5地址"); + } + String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL); + if(StrUtil.isEmpty(apiUrl)){ + throw new YshopException("未配置api地址"); + } + YxUser userInfo = LocalUser.getUser(); + Map map = Maps.newHashMap(); + String spreadUrl = creatShareProductService.getPinkPosterUrl(Long.valueOf(param.getId()),userInfo, + siteUrl,apiUrl,path,param.getFrom()); + map.put("url",spreadUrl); + return ApiResult.ok(map); + } + + /** + * 取消开团 + */ + @AppLog(value = "取消开团", type = 1) + @AuthCheck + @PostMapping("/combination/remove") + @ApiOperation(value = "取消开团",notes = "取消开团") + public ApiResult remove(@Validated @RequestBody PinkCancelParam param){ + Long pinkId = Long.valueOf(param.getId()); + Long cId = Long.valueOf(param.getCid()); + Long uid = LocalUser.getUser().getUid(); + storePinkService.removePink(uid,cId,pinkId); + return ApiResult.ok(); + } + + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreSeckillController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreSeckillController.java new file mode 100644 index 00000000..aeb7b62e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/AppStoreSeckillController.java @@ -0,0 +1,161 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.activity.rest; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.ShopConstants; +import co.yixiang.modules.activity.service.YxStoreSeckillService; +import co.yixiang.modules.activity.service.dto.SeckillTimeDto; +import co.yixiang.modules.activity.vo.SeckillConfigVo; +import co.yixiang.modules.activity.vo.StoreSeckillVo; +import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.shop.domain.YxSystemGroupData; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria; +import co.yixiang.utils.OrderUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +/** + *

+ * 商品秒杀产品前端控制器 + *

+ * + * @author hupeng + * @since 2019-12-14 + */ +@Slf4j +@RestController +@RequestMapping +@Api(value = "商品秒杀", tags = "营销:商品秒杀") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class AppStoreSeckillController { + + private final YxStoreSeckillService yxStoreSeckillService; + private final YxSystemGroupDataService yxSystemGroupDataService; + private final YxStoreProductRelationService relationService; + + /** + * 秒杀产品列表 + */ + @GetMapping("/seckill/list/{time}") + @ApiOperation(value = "秒杀产品列表", notes = "秒杀产品列表") + public ApiResult> getYxStoreSeckillPageList(@PathVariable String time, + @RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + if (StrUtil.isBlank(time) || !NumberUtil.isNumber(time)){ + throw new YshopException("参数错误"); + } + return ApiResult.resultPage(yxStoreSeckillService.getList(page, limit, Integer.valueOf(time)),limit); + + } + + + /** + * 根据id获取商品秒杀产品详情 + */ + @AppLog(value = "根据id获取商品秒杀产品详情", type = 1) + @AuthCheck + @GetMapping("/seckill/detail/{id}") + @ApiOperation(value = "秒杀产品详情", notes = "秒杀产品详情") + public ApiResult getYxStoreSeckill(@PathVariable Long id){ + Long uid = LocalUser.getUser().getUid(); + StoreSeckillVo storeSeckillVo = yxStoreSeckillService.getDetail(id); + storeSeckillVo.setUserCollect(relationService + .isProductRelation(storeSeckillVo.getStoreInfo().getProductId(),uid)); + return ApiResult.ok(storeSeckillVo); + } + + + /** + * 秒杀产品时间区间 + */ + @GetMapping("/seckill/index") + @ApiOperation(value = "秒杀产品时间区间", notes = "秒杀产品时间区间") + public ApiResult getYxStoreSeckillIndex() { + //获取秒杀配置 + AtomicInteger seckillTimeIndex = new AtomicInteger(); + SeckillConfigVo seckillConfigVo = new SeckillConfigVo(); + + YxSystemGroupDataQueryCriteria queryCriteria = new YxSystemGroupDataQueryCriteria(); + queryCriteria.setGroupName(ShopConstants.YSHOP_SECKILL_TIME); + queryCriteria.setStatus(1); + List yxSystemGroupDataList = yxSystemGroupDataService.queryAll(queryCriteria); + + List list = new ArrayList<>(); + int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date())); + yxSystemGroupDataList.forEach(i -> { + String jsonStr = i.getValue(); + JSONObject jsonObject = JSON.parseObject(jsonStr); + int time = Integer.valueOf(jsonObject.get("time").toString());//时间 5 + int continued = Integer.valueOf(jsonObject.get("continued").toString());//活动持续事件 3 + SimpleDateFormat sdf = new SimpleDateFormat("HH"); + String nowTime = sdf.format(new Date()); + String index = nowTime.substring(0, 1); + int currentHour = "0".equals(index) ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime); + SeckillTimeDto seckillTimeDto = new SeckillTimeDto(); + seckillTimeDto.setId(i.getId()); + //活动结束时间 + int activityEndHour = time + continued; + if (activityEndHour > 24) { + seckillTimeDto.setState("即将开始"); + seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); + seckillTimeDto.setStatus(2); + seckillTimeDto.setStop(today + activityEndHour * 3600); + } else { + if (currentHour >= time && currentHour < activityEndHour) { + seckillTimeDto.setState("抢购中"); + seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); + seckillTimeDto.setStatus(1); + seckillTimeDto.setStop(today + activityEndHour * 3600); + seckillTimeIndex.set(yxSystemGroupDataList.indexOf(i)); + } else if (currentHour < time) { + seckillTimeDto.setState("即将开始"); + seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); + seckillTimeDto.setStatus(2); + seckillTimeDto.setStop(OrderUtil.dateToTimestamp(new Date()) + activityEndHour * 3600); + } else if (currentHour >= activityEndHour) { + seckillTimeDto.setState("已结束"); + seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); + seckillTimeDto.setStatus(0); + seckillTimeDto.setStop(today + activityEndHour * 3600); + } + } + list.add(seckillTimeDto); + }); + seckillConfigVo.setSeckillTimeIndex(seckillTimeIndex.get()); + seckillConfigVo.setSeckillTime(list); + return ApiResult.ok(seckillConfigVo); + } +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/StoreIntegralController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/StoreIntegralController.java new file mode 100644 index 00000000..3ed309b2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/activity/rest/StoreIntegralController.java @@ -0,0 +1,39 @@ +package co.yixiang.app.modules.activity.rest; + +import co.yixiang.api.ApiResult; +import co.yixiang.modules.product.param.YxStoreProductQueryParam; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 积分兑换前端控制器 + * @author yshop + */ +@Slf4j +@RestController +@RequestMapping +@Api(value = "积分兑换", tags = "营销:积分兑换") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class StoreIntegralController { + + private final YxStoreProductService storeProductService; + + /** + * 获取积分产品列表 + */ + @GetMapping("/products/integral") + @ApiOperation(value = "获取积分产品列表",notes = "获取积分产品列表") + public ApiResult> goodsList(YxStoreProductQueryParam productQueryParam){ + return ApiResult.ok(storeProductService.getGoodsList(productQueryParam)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/HLoginParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/HLoginParam.java new file mode 100644 index 00000000..90e96b42 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/HLoginParam.java @@ -0,0 +1,31 @@ +package co.yixiang.app.modules.auth.param; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName 登陆LoginDTO + * @Author hupeng <610796224@qq.com> + * @Date 2020/05/02 + **/ +@Getter +@Setter +public class HLoginParam { + + @NotBlank(message = "用户名必填") + @ApiModelProperty(value = "用户名") + private String username; + + @NotBlank(message = "密码必填") + @ApiModelProperty(value = "密码") + private String password; + + @ApiModelProperty(value = "分销绑定关系的ID") + private String spread; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/LoginParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/LoginParam.java new file mode 100644 index 00000000..ad8b5a21 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/LoginParam.java @@ -0,0 +1,28 @@ +package co.yixiang.app.modules.auth.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName LoginParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/01/15 + **/ +@Data +public class LoginParam { + + @NotBlank(message = "code参数缺失") + @ApiModelProperty(value = "小程序登陆code") + private String code; + + @ApiModelProperty(value = "分销绑定关系的ID") + private String spread; + + @ApiModelProperty(value = "小程序完整用户信息的加密数据") + private String encryptedData; + + @ApiModelProperty(value = "小程序加密算法的初始向量") + private String iv; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/LoginVerifyParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/LoginVerifyParam.java new file mode 100644 index 00000000..11b83c6c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/LoginVerifyParam.java @@ -0,0 +1,24 @@ +package co.yixiang.app.modules.auth.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @author : gzlv 2021/7/20 15:09 + */ +@Data +public class LoginVerifyParam { + + @NotBlank(message = "手机号必填") + @ApiModelProperty(value = "手机号码") + private String account; + + @NotBlank(message = "验证码必填") + @ApiModelProperty(value = "验证码") + private String captcha; + + @ApiModelProperty(value = "分销绑定关系的ID") + private String spread; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/RegParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/RegParam.java new file mode 100644 index 00000000..b0c81049 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/RegParam.java @@ -0,0 +1,33 @@ +package co.yixiang.app.modules.auth.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName RegParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/25 + **/ +@Data +public class RegParam { + + @NotBlank(message = "手机号必填") + @ApiModelProperty(value = "手机号码") + private String account; + + @NotBlank(message = "验证码必填") + @ApiModelProperty(value = "验证码") + private String captcha; + + @NotBlank(message = "密码必填") + @ApiModelProperty(value = "密码") + private String password; + + @ApiModelProperty(value = "分销绑定关系的ID") + private String spread; + + @ApiModelProperty(value = "邀请码") + private String inviteCode; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/UpdatePasswordParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/UpdatePasswordParam.java new file mode 100644 index 00000000..997c6f52 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/UpdatePasswordParam.java @@ -0,0 +1,25 @@ +package co.yixiang.app.modules.auth.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @author : gzlv 2021/7/20 17:27 + */ +@Data +public class UpdatePasswordParam { + + @NotBlank(message = "手机号必填") + @ApiModelProperty(value = "手机号码") + private String account; + + @NotBlank(message = "验证码必填") + @ApiModelProperty(value = "验证码") + private String captcha; + + @NotBlank(message = "密码必填") + @ApiModelProperty(value = "密码") + private String password; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/VerityParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/VerityParam.java new file mode 100644 index 00000000..e455d105 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/param/VerityParam.java @@ -0,0 +1,22 @@ +package co.yixiang.app.modules.auth.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName VerityParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/25 + **/ +@Data +public class VerityParam { + + @NotBlank(message = "手机号必填") + @ApiModelProperty(value = "手机号码") + private String phone; + + @ApiModelProperty(value = "短信类型 bind绑定手机短信 login登陆短信 register注册短信") + private String type; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java new file mode 100644 index 00000000..b0fdc11b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java @@ -0,0 +1,326 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.auth.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.enums.SmsTypeEnum; +import co.yixiang.app.common.util.JwtToken; +import co.yixiang.app.common.util.SmsUtils; +import co.yixiang.app.modules.auth.param.*; +import co.yixiang.app.modules.services.AppAuthService; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; + +import co.yixiang.utils.RedisUtils; +import com.alibaba.fastjson.JSONObject; +import com.aliyuncs.exceptions.ClientException; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @ClassName 认证服务 + * @Author hupeng <610796224@qq.com> + * @Date 2020/4/30 + **/ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "认证模块", tags = "商城:认证") +public class LetterAppAuthController { + + private final YxUserService userService; + private final RedisUtils redisUtil; + private final AppAuthService authService; + private Boolean singleLogin = false; + + + + /** + * 小程序登陆接口 + */ + @PostMapping("/wxapp/auth") + @ApiOperation(value = "小程序登陆", notes = "小程序登陆") + public ApiResult> login(@Validated @RequestBody LoginParam loginParam, + HttpServletRequest request) { + + YxUser yxUser = authService.wxappLogin(loginParam); + String token = JwtToken.makeToken(yxUser.getUid(), yxUser.getUsername()); + String expiresTimeStr = JwtToken.getExpireTime(token); + + // 返回 token + Map map = new LinkedHashMap<>(2); + + map.put("token", token); + map.put("expires_time", expiresTimeStr); + + // 保存在线信息 + authService.save(yxUser, token, request); + if (singleLogin) { + authService.checkLoginOnUser(yxUser.getUsername(), token); + } + + + return ApiResult.ok(map).setMsg("登陆成功"); + + } + + /** + * 根据手机号查询用户状态 + */ + @GetMapping("/wxapp/authPhone/{phone}") + @ApiOperation(value = "根据手机号查询用户状态", notes = "根据手机号查询用户状态") + public ApiResult authPhone(@PathVariable String phone) { + return ApiResult.ok(authService.authPhone(phone)).setMsg("获取成功"); + } + + @AuthCheck + @PostMapping("/wxapp/loginAuth") + @ApiOperation(value = "小程序获取用户信息", notes = "小程序获取用户信息") + public ApiResult loginAuth(@Validated @RequestBody LoginParam loginParam) { + Long uid = LocalUser.getUidByToken(); + String sessionKey = redisUtil.get(ShopConstants.YSHOP_MINI_SESSION_KET+ uid).toString(); + YxUser yxUser = authService.loginAuth(loginParam, uid, sessionKey); + return ApiResult.ok(yxUser).setMsg("获取成功"); + + } + /** + * 微信公众号授权 + */ + @GetMapping("/wechat/auth") + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "微信授权code", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "spread", value = "分销绑定关系的ID", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "微信公众号授权", notes = "微信公众号授权") + public ApiResult> authLogin(@RequestParam(value = "code") String code, + @RequestParam(value = "spread") String spread, + HttpServletRequest request) { + + YxUser yxUser = authService.wechatLogin(code,spread); + String token = JwtToken.makeToken(yxUser.getUid(),yxUser.getUsername()); + String expiresTimeStr = JwtToken.getExpireTime(token); + + // 返回 token + Map map = new HashMap(2) {{ + put("token", token); + put("expires_time", expiresTimeStr); + }}; + + // 保存在线信息 + authService.save(yxUser, token, request); + if(singleLogin){ + authService.checkLoginOnUser(yxUser.getUsername(),token); + } + + return ApiResult.ok(map).setMsg("登陆成功"); + + + } + + + @ApiOperation("H5登录授权") + @PostMapping(value = "/login") + public ApiResult> login(@Validated @RequestBody HLoginParam loginDTO, HttpServletRequest request) { + YxUser yxUser = userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getUsername,loginDTO.getUsername()) + .eq(YxUser::getPassword,SecureUtil.md5(loginDTO.getPassword())),false); + + if(yxUser == null) { + throw new YshopException("账号或者密码不正确"); + } + + String token = JwtToken.makeToken(yxUser.getUid(),yxUser.getUsername()); + String expiresTimeStr = JwtToken.getExpireTime(token); + + // 保存在线信息 + authService.save(yxUser, token, request); + // 返回 token + Map map = new HashMap(2) {{ + put("token", token); + put("expires_time", expiresTimeStr); + }}; + + userService.setSpread(loginDTO.getSpread(),yxUser.getUid()); + + if(singleLogin){ + //踢掉之前已经登录的token + authService.checkLoginOnUser(yxUser.getUsername(),token); + } + + return ApiResult.ok(map).setMsg("登陆成功"); + } + + @ApiOperation("H5验证码登录授权") + @PostMapping(value = "/login/mobile") + public ApiResult> loginVerify(@Validated @RequestBody LoginVerifyParam loginVerifyParam, HttpServletRequest request) { + Object codeObj = redisUtil.get("code_" + loginVerifyParam.getAccount()); + if(codeObj == null){ + throw new YshopException("请先获取验证码"); + } + String code = codeObj.toString(); + if (!StrUtil.equals(code, loginVerifyParam.getCaptcha())) { + throw new YshopException("验证码错误"); + } + YxUser yxUser = userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getUsername,loginVerifyParam.getAccount())); + + if(yxUser == null) { + throw new YshopException("账号不存在"); + } + + String token = JwtToken.makeToken(yxUser.getUid(),yxUser.getUsername()); + String expiresTimeStr = JwtToken.getExpireTime(token); + + // 保存在线信息 + authService.save(yxUser, token, request); + // 返回 token + Map map = new HashMap(2) {{ + put("token", token); + put("expires_time", expiresTimeStr); + }}; + + userService.setSpread(loginVerifyParam.getSpread(),yxUser.getUid()); + + if(singleLogin){ + //踢掉之前已经登录的token + authService.checkLoginOnUser(yxUser.getUsername(),token); + } + + return ApiResult.ok(map).setMsg("登陆成功"); + } + + @AuthCheck + @ApiOperation("修改密码") + @PostMapping(value = "/register/reset") + public ApiResult updatePassword(@Validated @RequestBody UpdatePasswordParam updatePasswordParam, HttpServletRequest request) { + Object codeObj = redisUtil.get("code_" + updatePasswordParam.getAccount()); + if(codeObj == null){ + throw new YshopException("请先获取验证码"); + } + String code = codeObj.toString(); + if (!StrUtil.equals(code, updatePasswordParam.getCaptcha())) { + throw new YshopException("验证码错误"); + } + YxUser yxUser = userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getUsername,updatePasswordParam.getAccount())); + + if(yxUser == null) { + throw new YshopException("账号不存在,数据错误"); + } + yxUser.setPassword(SecureUtil.md5(updatePasswordParam.getPassword())); + boolean b = userService.updateById(yxUser); + if (!b) { + throw new YshopException("修改失败"); + } + String bearerToken = request.getHeader("Authorization"); + String[] tokens = bearerToken.split(" "); + String token = tokens[1]; + authService.logout(LocalUser.getUser().getUsername(), token); + + return ApiResult.ok(true).setMsg("修改成功"); + } + + + @PostMapping("/register") + @ApiOperation(value = "H5/APP注册新用户", notes = "H5/APP注册新用户") + public ApiResult register(@Validated @RequestBody RegParam param) { + Object codeObj = redisUtil.get("code_" + param.getAccount()); + if(codeObj == null){ + return ApiResult.fail("请先获取验证码"); + } + String code = codeObj.toString(); + if (!StrUtil.equals(code, param.getCaptcha())) { + return ApiResult.fail("验证码错误"); + } + YxUser yxUser = userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getPhone,param.getAccount()),false); + if (ObjectUtil.isNotNull(yxUser)) { + return ApiResult.fail("用户已存在"); + } + + authService.register(param); + return ApiResult.ok("","注册成功"); + } + + + @PostMapping("/register/verify") + @ApiOperation(value = "短信验证码发送", notes = "短信验证码发送") + public ApiResult verify(@Validated @RequestBody VerityParam param) { + YxUser yxUser = userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getPhone,param.getPhone()),false); + if (SmsTypeEnum.REGISTER.getValue().equals(param.getType()) && ObjectUtil.isNotNull(yxUser)) { + return ApiResult.fail("手机号已注册"); + } + if (SmsTypeEnum.LOGIN.getValue().equals(param.getType()) && ObjectUtil.isNull(yxUser)) { + return ApiResult.fail("账号不存在"); + } + String codeKey = "code_" + param.getPhone(); + if (ObjectUtil.isNotNull(redisUtil.get(codeKey))) { + return ApiResult.fail("10分钟内有效:" + redisUtil.get(codeKey).toString()); + } + String code = RandomUtil.randomNumbers(ShopConstants.YSHOP_SMS_SIZE); + + //redis存储 + redisUtil.set(codeKey, code, ShopConstants.YSHOP_SMS_REDIS_TIME); + + String enable = redisUtil.getY("sms_enable"); + if (ShopCommonEnum.ENABLE_2.getValue().toString().equals(enable)) { + return ApiResult.fail("测试阶段验证码:" + code); + } + + //发送阿里云短信 + JSONObject json = new JSONObject(); + json.put("code",code); + try { + SmsUtils.sendSms(param.getPhone(),json.toJSONString()); + } catch (ClientException e) { + redisUtil.del(codeKey); + e.printStackTrace(); + return ApiResult.ok("发送失败:"+e.getErrMsg()); + } + return ApiResult.ok("发送成功,请注意查收"); + + + } + + @AuthCheck + @ApiOperation(value = "退出登录", notes = "退出登录") + @PostMapping(value = "/auth/logout") + public ApiResult logout(HttpServletRequest request) { + String bearerToken = request.getHeader("Authorization"); + String[] tokens = bearerToken.split(" "); + String token = tokens[1]; + authService.logout(LocalUser.getUser().getUsername(), token); + return ApiResult.ok("退出成功"); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartIdsParm.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartIdsParm.java new file mode 100644 index 00000000..c5109dc5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartIdsParm.java @@ -0,0 +1,20 @@ +package co.yixiang.app.modules.cart.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * @ClassName CartIds + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/15 + **/ +@Data +public class CartIdsParm { + + @NotNull(message = "参数有误") + @ApiModelProperty(value = "购物车ID,多个用,分隔开") + List ids; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartNumParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartNumParam.java new file mode 100644 index 00000000..2d57dc10 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartNumParam.java @@ -0,0 +1,29 @@ +package co.yixiang.app.modules.cart.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @ClassName 购物车数量CartNumParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/19 + **/ +@Getter +@Setter +public class CartNumParam { + + @Min(value = 1,message = "数量不在合法范围内") + @Max(value = 9999,message = "数量不在合法范围内") + @ApiModelProperty(value = "购物车数量") + private Integer number; + + @NotNull(message = "参数有误") + @ApiModelProperty(value = "购物车ID") + private Long id; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartParam.java new file mode 100644 index 00000000..ab0801c3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/CartParam.java @@ -0,0 +1,46 @@ +package co.yixiang.app.modules.cart.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +/** + * @ClassName 添加购物车CartParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/19 + **/ +@Getter +@Setter +public class CartParam { + + @Min(value = 1,message = "数量不在合法范围内") + @Max(value = 9999,message = "数量不在合法范围内") + @ApiModelProperty(value = "购物车数量") + private Integer cartNum; + + @JsonProperty(value = "new") + @ApiModelProperty(value = "是否新购买") + private Integer isNew = 0; + + @NotNull(message = "参数有误") + @ApiModelProperty(value = "产品ID") + private Long productId; + + //@NotBlank(message = "参数有误") + @ApiModelProperty(value = "唯一的ID") + private String uniqueId; + + @ApiModelProperty(value = "产品拼团ID") + private Long combinationId = 0L; + + @ApiModelProperty(value = "产品秒杀ID") + private Long secKillId = 0L; + + @ApiModelProperty(value = "产品砍价ID") + private Long bargainId = 0L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/YxStoreCartQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/YxStoreCartQueryParam.java new file mode 100644 index 00000000..f48f15eb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/param/YxStoreCartQueryParam.java @@ -0,0 +1,20 @@ +package co.yixiang.app.modules.cart.param; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +/** + *

+ * 购物车表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-25 + */ +@Data +@ApiModel(value="YxStoreCartQueryParam对象", description="购物车表查询参数") +public class YxStoreCartQueryParam { + private static final long serialVersionUID = 1L; + + private Integer numType = 0; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/rest/StoreCartController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/rest/StoreCartController.java new file mode 100644 index 00000000..a864dd32 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/cart/rest/StoreCartController.java @@ -0,0 +1,127 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.cart.rest; + +import co.yixiang.annotation.Limit; +import co.yixiang.api.ApiResult; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.cart.param.CartIdsParm; +import co.yixiang.app.modules.cart.param.CartParam; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.app.modules.cart.param.CartNumParam; +import co.yixiang.modules.cart.service.YxStoreCartService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + *

+ * 购物车控制器 + *

+ * + * @author hupeng + * @since 2019-10-25 + */ +@Slf4j +@RestController +@Api(value = "购物车", tags = "商城:购物车") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class StoreCartController { + + private final YxStoreCartService storeCartService; + + /** + * 购物车 获取数量 + */ + @AuthCheck + @GetMapping("/cart/count") + @ApiOperation(value = "获取数量",notes = "获取数量") + public ApiResult> count(){ + Map map = new LinkedHashMap<>(); + Long uid = LocalUser.getUser().getUid(); + map.put("count",storeCartService.getUserCartNum(uid)); + return ApiResult.ok(map); + } + + /** + * 购物车 添加 + */ + @AppLog(value = "购物车 添加", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/cart/add") + @ApiOperation(value = "添加购物车",notes = "添加购物车") + @Limit(key = "cart_limit", period = 60, count = 30, name = "cartLimit", prefix = "yshop") + public ApiResult> add(@Validated @RequestBody CartParam cartParam){ + Map map = new LinkedHashMap<>(); + Long uid = LocalUser.getUser().getUid(); + map.put("cartId",storeCartService.addCart(uid,cartParam.getProductId(),cartParam.getCartNum(), + cartParam.getUniqueId(),cartParam.getIsNew(),cartParam.getCombinationId(), + cartParam.getSecKillId(),cartParam.getBargainId())); + return ApiResult.ok(map); + } + + + /** + * 购物车列表 + */ + @AppLog(value = "查看购物车列表", type = 1) + @AuthCheck + @GetMapping("/cart/list") + @ApiOperation(value = "购物车列表",notes = "购物车列表") + public ApiResult> getList(){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(storeCartService.getUserProductCartList(uid,"",null)); + } + + /** + * 修改产品数量 + */ + @AppLog(value = "修改购物车产品数量", type = 1) + @AuthCheck + @PostMapping("/cart/num") + @ApiOperation(value = "修改产品数量",notes = "修改产品数量") + public ApiResult cartNum(@Validated @RequestBody CartNumParam param){ + Long uid = LocalUser.getUser().getUid(); + storeCartService.changeUserCartNum(param.getId(), param.getNumber(),uid); + return ApiResult.ok(); + } + + /** + * 购物车删除产品 + */ + @AppLog(value = "购物车删除产品", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/cart/del") + @ApiOperation(value = "购物车删除产品",notes = "购物车删除产品") + public ApiResult cartDel(@Validated @RequestBody CartIdsParm parm){ + Long uid = LocalUser.getUser().getUid(); + storeCartService.removeUserCart(uid, parm.getIds()); + return ApiResult.ok(); + } + + + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponIssueQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponIssueQueryParam.java new file mode 100644 index 00000000..849205be --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponIssueQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.coupon.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 优惠券前台领取表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreCouponIssueQueryParam对象", description="优惠券前台领取表查询参数") +public class YxStoreCouponIssueQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponIssueUserQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponIssueUserQueryParam.java new file mode 100644 index 00000000..f6320fb9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponIssueUserQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.coupon.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 优惠券前台用户领取记录表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreCouponIssueUserQueryParam对象", description="优惠券前台用户领取记录表查询参数") +public class YxStoreCouponIssueUserQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponQueryParam.java new file mode 100644 index 00000000..0c20190e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponQueryParam.java @@ -0,0 +1,28 @@ +package co.yixiang.app.modules.coupon.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * 优惠券表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreCouponQueryParam对象", description="优惠券表查询参数") +public class YxStoreCouponQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "优惠券ID") + private String couponId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponUserQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponUserQueryParam.java new file mode 100644 index 00000000..09bedc59 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/param/YxStoreCouponUserQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.coupon.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 优惠券发放记录表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreCouponUserQueryParam对象", description="优惠券发放记录表查询参数") +public class YxStoreCouponUserQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java new file mode 100644 index 00000000..1aeac632 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/coupon/rest/CouponController.java @@ -0,0 +1,143 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.coupon.rest; + +import cn.hutool.core.util.NumberUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.modules.activity.service.YxStoreCouponIssueService; +import co.yixiang.modules.activity.service.YxStoreCouponUserService; +import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo; +import co.yixiang.modules.activity.vo.YxStoreCouponUserQueryVo; +import co.yixiang.app.modules.coupon.param.YxStoreCouponQueryParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + *

+ * 优惠券 todo + *

+ * + * @author hupeng + * @since 2019-10-02 + */ +@Slf4j +@RestController +@Api(value = "优惠券", tags = "营销:优惠券") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class CouponController { + + private final YxStoreCouponIssueService couponIssueService; + private final YxStoreCouponUserService storeCouponUserService; + + /** + * 可领取优惠券列表 + */ + @AuthCheck + @GetMapping("/coupons") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "productId", value = "产品ID", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "type", value = "优惠券类型 0通用券 1商品券 2内部券", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "可领取优惠券列表",notes = "可领取优惠券列表") + public ApiResult> getList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit, + @RequestParam(value = "productId",required = false) Long productId, + @RequestParam(value = "type",required = false) Integer type){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(couponIssueService.getCouponList(page, limit,uid,productId,type)); + } + + /** + * 领取优惠券 + */ + @AppLog(value = "领取优惠券", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/coupon/receive") + @ApiOperation(value = "领取优惠券",notes = "领取优惠券") + public ApiResult receive(@Validated @RequestBody YxStoreCouponQueryParam param){ + Long uid = LocalUser.getUser().getUid(); + if(!NumberUtil.isNumber(param.getCouponId())){ + throw new YshopException("参数非法"); + } + Integer couponId = Integer.valueOf(param.getCouponId()); + couponIssueService.issueUserCoupon(couponId,uid); + return ApiResult.ok(); + } + + /** + * 用户已领取优惠券 + */ + @AppLog(value = "查看已领取优惠券", type = 1) + @AuthCheck + @GetMapping("/coupons/user/{type}") + @ApiOperation(value = "用户已领取优惠券",notes = "用户已领取优惠券") + public ApiResult> getUserList(){ + Long uid = LocalUser.getUser().getUid(); + List list = storeCouponUserService.getUserCoupon(uid); + return ApiResult.ok(list); + } + + /** + * 用户已领取优惠券pc + */ + @AppLog(value = "用户已领取优惠券pc", type = 1) + @AuthCheck + @GetMapping("/coupons/user/pc/{type}") + @ApiOperation(value = "用户已领取优惠券pc",notes = "用户已领取优惠券pc") + public ApiResult getUserPCList( + @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit, @PathVariable(value = "type") Integer type){ + Long uid = LocalUser.getUser().getUid(); + Map map = storeCouponUserService.getUserPCCoupon(uid,page,limit,type); + Long total = (Long) map.get("total"); + Long totalPage = (Long) map.get("totalPage"); + return ApiResult.resultPage(total.intValue(), totalPage.intValue(), map.get("list")); + } + + /** + * 优惠券 订单获取 + */ + @AuthCheck + @GetMapping("/coupons/order/{cartIds}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "cartIds", value = "购物车ID,多个用,分割", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "优惠券订单获取",notes = "优惠券订单获取") + public ApiResult> orderCoupon(@PathVariable String cartIds){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(storeCouponUserService.beUsableCouponList(uid,cartIds)); + } + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/dto/ChartDataDto.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/dto/ChartDataDto.java new file mode 100644 index 00000000..6da59ca9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/dto/ChartDataDto.java @@ -0,0 +1,16 @@ +package co.yixiang.app.modules.manage.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName ChartDataDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/25 + **/ +@Data +public class ChartDataDto implements Serializable { + private Double num; + private String time; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/OrderPriceParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/OrderPriceParam.java new file mode 100644 index 00000000..00ec05d3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/OrderPriceParam.java @@ -0,0 +1,24 @@ +package co.yixiang.app.modules.manage.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName OrderPriceParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/26 + **/ +@Data +public class OrderPriceParam implements Serializable { + + @NotBlank(message = "订单编号错误") + @ApiModelProperty(value = "订单ID") + private String orderId; + + @NotBlank(message = "修改价格必填") + @ApiModelProperty(value = "商品价格") + private String price; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/OrderRemarkParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/OrderRemarkParam.java new file mode 100644 index 00000000..2739734e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/OrderRemarkParam.java @@ -0,0 +1,24 @@ +package co.yixiang.app.modules.manage.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName OrderPriceParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/26 + **/ +@Data +public class OrderRemarkParam implements Serializable { + + @NotBlank(message = "订单编号错误") + @ApiModelProperty(value = "订单ID") + private String orderId; + + @NotBlank(message = "备注必填") + @ApiModelProperty(value = "备注") + private String remark; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/ShoperQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/ShoperQueryParam.java new file mode 100644 index 00000000..87ad3b6b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/ShoperQueryParam.java @@ -0,0 +1,26 @@ +package co.yixiang.app.modules.manage.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author hupeng + * @date 2019-02-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="商户查询参数", description="商户查询参数") +public class ShoperQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "商品状态,默认为0未支付 1待发货 2待收货 3待评价 4已完成 5退款中 6已退款 7退款") + private Integer status = 0; + + @ApiModelProperty(value = "分类") + private Integer cate = 1; + + private Integer type = 1; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/YxExpressQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/YxExpressQueryParam.java new file mode 100644 index 00000000..1767f3b9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/param/YxExpressQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.manage.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 快递公司表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-13 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxExpressQueryParam对象", description="快递公司表查询参数") +public class YxExpressQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/rest/ShoperController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/rest/ShoperController.java new file mode 100644 index 00000000..df627f42 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/rest/ShoperController.java @@ -0,0 +1,189 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.manage.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.modules.order.param.OrderDeliveryParam; +import co.yixiang.app.modules.order.param.OrderRefundParam; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.app.modules.manage.param.OrderPriceParam; +import co.yixiang.app.modules.manage.param.ShoperQueryParam; +import co.yixiang.modules.order.service.YxExpressService; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.vo.OrderDataVo; +import co.yixiang.modules.order.vo.ShoperOrderTimeDataVo; +import co.yixiang.modules.order.vo.UserOrderCountVo; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.math.BigDecimal; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName ShoperController + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/25 + **/ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "商家管理", tags = "商城:商家管理") +public class ShoperController { + + private final YxStoreOrderService storeOrderService; + private final YxExpressService expressService; + + /** + * 订单数据统计 + */ + @AuthCheck + @GetMapping("/admin/order/statistics") + @ApiOperation(value = "订单数据统计",notes = "订单数据统计") + public ApiResult> statistics(){ + UserOrderCountVo userOrderCountVo = storeOrderService.orderData(null); + ShoperOrderTimeDataVo orderTimeDataVo = storeOrderService.getShoperOrderTimeData(); + + Map map = new LinkedHashMap<>(); + map.put("orderCount",userOrderCountVo); + map.put("orderTimeCount",orderTimeDataVo); + return ApiResult.ok(map); + } + + /** + * 订单每月统计数据 + */ + @AuthCheck + @GetMapping("/admin/order/data") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "订单每月统计数据",notes = "订单每月统计数据") + public ApiResult> data(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + return ApiResult.ok(storeOrderService.getOrderDataPriceCount(page,limit)); + } + + + /** + * 订单列表 + */ + @AppLog(value = "查看订单列表", type = 1) + @AuthCheck + @GetMapping("/admin/order/list") + @ApiOperation(value = "订单列表",notes = "订单列表") + public ApiResult orderList(ShoperQueryParam queryParam) { + Map map = storeOrderService.orderList(null, queryParam.getStatus(), + queryParam.getPage(), queryParam.getLimit()); + return ApiResult.ok(map.get("list")); + } + + /** + * 订单详情 + */ + @AppLog(value = "查看订单详情", type = 1) + @AuthCheck + @GetMapping("/admin/order/detail/{key}") + @ApiOperation(value = "订单详情",notes = "订单详情") + public ApiResult orderDetail(@PathVariable String key){ + if(StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,null); + if(ObjectUtil.isNull(storeOrder)){ + throw new YshopException("订单不存在"); + } + return ApiResult.ok(storeOrderService.handleOrder(storeOrder)); + } + + /** + * 订单改价 + */ + @AppLog(value = "订单改价", type = 1) + @AuthCheck + @PostMapping("/admin/order/price") + @ApiOperation(value = "订单改价",notes = "订单改价") + public ApiResult orderPrice(@Validated @RequestBody OrderPriceParam param){ + storeOrderService.editOrderPrice(param.getOrderId(),param.getPrice()); + return ApiResult.ok(); + } + + /** + * 快递公司 + */ + @GetMapping("/logistics") + @ApiOperation(value = "快递公司",notes = "快递公司") + public ApiResult express(){ + return ApiResult.ok(expressService.list()); + } + + + /** + * 订单发货 + */ + @AppLog(value = "订单发货", type = 1) + @AuthCheck + @PostMapping("/admin/order/delivery/keep") + @ApiOperation(value = "订单发货",notes = "订单发货") + public ApiResult orderDelivery(@Validated @RequestBody OrderDeliveryParam param){ + storeOrderService.orderDelivery(param.getOrderId(),param.getDeliveryId(), + param.getDeliveryName(),param.getDeliveryType()); + return ApiResult.ok(); + } + + /** + * 订单退款 + */ + @AppLog(value = "订单退款", type = 1) + @AuthCheck + @PostMapping("/admin/order/refund") + @ApiOperation(value = "订单退款",notes = "订单退款") + public ApiResult orderRefund(@Validated @RequestBody OrderRefundParam param){ + storeOrderService.orderRefund(param.getOrderId(),new BigDecimal(param.getPrice()),param.getType()); + return ApiResult.ok(); + } + + + /** + * 订单交易额/订单数量时间chart统计 + */ + @Deprecated + @GetMapping("/admin/order/time") + @ApiOperation(value = "chart统计",notes = "chart统计") + public ApiResult chartCount(ShoperQueryParam queryParam){ +// return ApiResult.ok(storeOrderService.chartCount(queryParam.getCate().intValue(), +// queryParam.getType().intValue())); + return null; + } + + + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/vo/YxExpressQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/vo/YxExpressQueryVo.java new file mode 100644 index 00000000..f58548f5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/manage/vo/YxExpressQueryVo.java @@ -0,0 +1,37 @@ +package co.yixiang.app.modules.manage.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 快递公司表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-13 + */ +@Data +@ApiModel(value="YxExpressQueryVo对象", description="快递公司表查询参数") +public class YxExpressQueryVo implements Serializable{ + private static final long serialVersionUID = 1L; + +@ApiModelProperty(value = "快递公司id") +private Integer id; + +@ApiModelProperty(value = "快递公司简称") +private String code; + +@ApiModelProperty(value = "快递公司全称") +private String name; + +@ApiModelProperty(value = "排序") +private Integer sort; + +@ApiModelProperty(value = "是否显示") +private Boolean isShow; + +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/dto/OrderExtendDto.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/dto/OrderExtendDto.java new file mode 100644 index 00000000..0bf29349 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/dto/OrderExtendDto.java @@ -0,0 +1,31 @@ +package co.yixiang.app.modules.order.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Map; + +/** + * @ClassName OrderExtendDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/28 + **/ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class OrderExtendDto implements Serializable { + + @ApiModelProperty(value = "唯一的key") + private String key; + + @ApiModelProperty(value = "订单ID") + private String orderId; + + @ApiModelProperty(value = "微信相关配置") + private Map jsConfig; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/dto/PayDto.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/dto/PayDto.java new file mode 100644 index 00000000..2b376b10 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/dto/PayDto.java @@ -0,0 +1,17 @@ +package co.yixiang.app.modules.order.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName PayDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/7 + **/ +@Data +public class PayDto implements Serializable { + private String from; + private String paytype; + private String uni; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ComputeOrderParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ComputeOrderParam.java new file mode 100644 index 00000000..2a80cbc6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ComputeOrderParam.java @@ -0,0 +1,44 @@ +package co.yixiang.app.modules.order.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @ClassName ComputeOrderParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/22 + **/ +@Getter +@Setter +@ToString +public class ComputeOrderParam { + //@NotBlank(message = "请选择地址") + @ApiModelProperty(value = "地址ID") + private String addressId; + + @ApiModelProperty(value = "优惠券ID") + private String couponId; + + //@NotBlank(message = "请选择支付方式") + @ApiModelProperty(value = "支付方式") + private String payType; + + @ApiModelProperty(value = "使用积分 1-表示使用") + private String useIntegral; + + @JsonProperty(value = "shipping_type") + @ApiModelProperty(value = "配送方式 1=快递 ,2=门店自提") + private String shippingType; + + @ApiModelProperty(value = "砍价ID") + private String bargainId; + + @ApiModelProperty(value = "拼团ID") + private String pinkId; + + @ApiModelProperty(value = "拼团ID") + private String combinationId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ConfirmOrderParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ConfirmOrderParam.java new file mode 100644 index 00000000..e8f32862 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ConfirmOrderParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName 确认订单ConfirmOrderDTO + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/21 + **/ +@Getter +@Setter +public class ConfirmOrderParam { + + @NotBlank(message = "请提交购买的商品") + @ApiModelProperty(value = "购物车ID") + private String cartId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/DoOrderParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/DoOrderParam.java new file mode 100644 index 00000000..a83bfb33 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/DoOrderParam.java @@ -0,0 +1,20 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName HandleOrderParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/23 + **/ +@Getter +@Setter +public class DoOrderParam { + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "订单ID") + private String uni; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ExpressParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ExpressParam.java new file mode 100644 index 00000000..b5d5773f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ExpressParam.java @@ -0,0 +1,24 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName ExpressParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/9 + **/ +@Data +public class ExpressParam implements Serializable { + + @ApiModelProperty(value = "订单编号") + private String orderCode; + + @ApiModelProperty(value = "快递公司编码") + private String shipperCode; + + @ApiModelProperty(value = "物流单号") + private String logisticCode; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/HandleOrderParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/HandleOrderParam.java new file mode 100644 index 00000000..66a0c4d8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/HandleOrderParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName HandleOrderParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/23 + **/ +@Getter +@Setter +public class HandleOrderParam { + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "订单ID") + private String id; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderDeliveryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderDeliveryParam.java new file mode 100644 index 00000000..88f20ccc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderDeliveryParam.java @@ -0,0 +1,32 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName OrderPriceParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/26 + **/ +@Data +public class OrderDeliveryParam implements Serializable { + + @NotBlank(message = "订单编号错误") + @ApiModelProperty(value = "订单ID") + private String orderId; + + @NotBlank(message = "快递单号必填") + @ApiModelProperty(value = "快递单号") + private String deliveryId; + + @NotBlank(message = "快递公司必填") + @ApiModelProperty(value = "快递公司") + private String deliveryName; + + @NotBlank(message = "快递方式必填") + @ApiModelProperty(value = "快递方式") + private String deliveryType; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderRefundParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderRefundParam.java new file mode 100644 index 00000000..b86718a8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderRefundParam.java @@ -0,0 +1,29 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @ClassName OrderRefundParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/26 + **/ +@Data +public class OrderRefundParam implements Serializable { + + @NotBlank(message = "订单编号错误") + @ApiModelProperty(value = "订单ID") + private String orderId; + + @NotNull(message = "退款金额必填") + @ApiModelProperty(value = "退款金额") + private String price; + + @NotNull(message = "参数错误") + @ApiModelProperty(value = "类型:1同意 2拒绝") + private Integer type; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderVerifyParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderVerifyParam.java new file mode 100644 index 00000000..3cf96c7a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/OrderVerifyParam.java @@ -0,0 +1,24 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName OrderVerifyParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/03/05 + **/ +@Data +public class OrderVerifyParam implements Serializable { + + @ApiModelProperty(value = "订单核销状态:1确认0正常") + private Integer isConfirm; + + @NotBlank(message = "缺少核销码") + @ApiModelProperty(value = "核销码") + private String verifyCode; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/PayParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/PayParam.java new file mode 100644 index 00000000..5e82ae52 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/PayParam.java @@ -0,0 +1,27 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName PayDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/7 + **/ +@Data +public class PayParam implements Serializable { + + @ApiModelProperty(value = "来源") + private String from; + + @NotBlank(message = "选择支付类型") + @ApiModelProperty(value = "支付类型") + private String paytype; + + @NotBlank(message = "参数错误") + @ApiModelProperty(value = "订单ID") + private String uni; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductOrderParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductOrderParam.java new file mode 100644 index 00000000..28d92cd9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductOrderParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName ProductOrderParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/23 + **/ +@Getter +@Setter +public class ProductOrderParam { + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "订单唯一值") + private String unique; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java new file mode 100644 index 00000000..1f3c6183 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/ProductReplyParam.java @@ -0,0 +1,38 @@ +package co.yixiang.app.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * @ClassName ProductReplyParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/23 + **/ +@Getter +@Setter +public class ProductReplyParam { + + @NotBlank(message = "评论不能为空") + @Size(min = 1, max = 200,message = "长度超过了限制") + @ApiModelProperty(value = "商品评论内容") + private String comment; + + @ApiModelProperty(value = "商品评论图片地址") + private String pics; + + @NotBlank(message = "请为商品评分") + @ApiModelProperty(value = "商品评分") + private String productScore; + + @NotBlank(message = "请为商品评分") + @ApiModelProperty(value = "服务评分") + private String serviceScore; + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "订单唯一值") + private String unique; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/RefundParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/RefundParam.java new file mode 100644 index 00000000..a3659fb8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/RefundParam.java @@ -0,0 +1,33 @@ +package co.yixiang.app.modules.order.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName RefundParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/6 + **/ +@Data +public class RefundParam implements Serializable { + + @JsonProperty(value = "refund_reason_wap_explain") + @ApiModelProperty(value = "退款备注") + private String refundReasonWapExplain; + + @JsonProperty(value = "refund_reason_wap_img") + @ApiModelProperty(value = "退款图片") + private String refundReasonWapImg; + + @NotBlank(message = "请填写退款原因") + @ApiModelProperty(value = "退款原因") + private String text; + + @NotBlank(message = "参数错误") + @ApiModelProperty(value = "订单唯一值") + private String uni; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderCartInfoQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderCartInfoQueryParam.java new file mode 100644 index 00000000..2c9601c3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderCartInfoQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.order.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 订单购物详情表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreOrderCartInfoQueryParam对象", description="订单购物详情表查询参数") +public class YxStoreOrderCartInfoQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderQueryParam.java new file mode 100644 index 00000000..09afcd31 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderQueryParam.java @@ -0,0 +1,23 @@ +package co.yixiang.app.modules.order.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 订单表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreOrderQueryParam对象", description="订单表查询参数") +public class YxStoreOrderQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + private Integer type = 1; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderStatusQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderStatusQueryParam.java new file mode 100644 index 00000000..b5cc9722 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/param/YxStoreOrderStatusQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.order.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 订单操作记录表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreOrderStatusQueryParam对象", description="订单操作记录表查询参数") +public class YxStoreOrderStatusQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java new file mode 100644 index 00000000..c4e13d0a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/order/rest/AppStoreOrderController.java @@ -0,0 +1,485 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.order.rest; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.order.param.*; +import co.yixiang.app.modules.order.param.ExpressParam; +import co.yixiang.app.modules.services.CreatShareProductService; +import co.yixiang.app.modules.services.OrderSupplyService; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.enums.*; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.modules.mp.domain.YxWechatTemplate; +import co.yixiang.modules.mp.service.WeixinPayService; +import co.yixiang.modules.mp.service.YxWechatTemplateService; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.app.modules.order.dto.OrderExtendDto; +import co.yixiang.modules.order.param.*; +import co.yixiang.modules.order.service.YxStoreOrderCartInfoService; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.YxStoreOrderStatusService; +import co.yixiang.modules.order.service.dto.YxStoreOrderDto; +import co.yixiang.modules.order.vo.ComputeVo; +import co.yixiang.modules.order.vo.ConfirmOrderVo; +import co.yixiang.modules.order.vo.OrderCartInfoVo; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.tools.express.ExpressService; +import co.yixiang.tools.express.config.ExpressAutoConfiguration; +import co.yixiang.tools.express.dao.ExpressInfo; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.vdurmont.emoji.EmojiParser; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + *

+ * 订单控制器 + *

+ * + * @author hupeng + * @since 2019-10-27 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "订单模块", tags = "商城:订单模块") +public class AppStoreOrderController { + + private final YxStoreOrderService storeOrderService; + private final OrderSupplyService orderSupplyService; + private final CreatShareProductService creatShareProductService; + private final YxWechatTemplateService yxWechatTemplateService; + private final YxStoreOrderStatusService orderStatusService; + + private final YxStoreOrderCartInfoService storeOrderCartInfoService; + private final WeixinPayService weixinPayService; + + /** + * 订单确认 + */ + @AppLog(value = "订单确认", type = 1) + @AuthCheck + @PostMapping("/order/confirm") + @ApiOperation(value = "订单确认", notes = "订单确认") + public ApiResult confirm(@Validated @RequestBody ConfirmOrderParam param) { + YxUser yxUser = LocalUser.getUser(); + return ApiResult.ok(storeOrderService.confirmOrder(yxUser, param.getCartId())); + + } + + /** + * 计算订单金额 + */ + @AuthCheck + @PostMapping("/order/computed/{key}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "计算订单金额", notes = "计算订单金额") + public ApiResult> computedOrder(@Validated @RequestBody ComputeOrderParam param, + @PathVariable String key) { + YxUser yxUser = LocalUser.getUser(); + Map map = orderSupplyService.check(yxUser.getUid(), key, param); + if (OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status")) + || OrderLogEnum.PINK_ORDER_FAIL_1.getValue().equals(map.get("status")) + || OrderLogEnum.PINK_ORDER_FAIL_2.getValue().equals(map.get("status"))) { + return ApiResult.ok(map, map.get("msg").toString()); + } + + ComputeVo computeVo = storeOrderService.computedOrder(yxUser, key, + param.getCouponId(), + param.getUseIntegral(), + param.getShippingType(), + param.getAddressId()); + + map.put("result", computeVo); + map.put("status", OrderLogEnum.NONE_ORDER.getValue()); + return ApiResult.ok(map); + } + + /** + * 订单创建 + */ + @AppLog(value = "订单创建", type = 1) + @AuthCheck + @NoRepeatSubmit + @PostMapping("/order/create/{key}") + @ApiOperation(value = "订单创建", notes = "订单创建") + public ApiResult> create(@Valid @RequestBody OrderParam param, + @PathVariable String key) { + YxUser yxUser = LocalUser.getUser(); + ComputeOrderParam computeOrderParam = new ComputeOrderParam(); + BeanUtil.copyProperties(param, computeOrderParam); + Map map = orderSupplyService.check(yxUser.getUid(), key, computeOrderParam); + if (OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status")) + || OrderLogEnum.PINK_ORDER_FAIL_2.getValue().equals(map.get("status")) + || OrderLogEnum.PINK_ORDER_FAIL_1.getValue().equals(map.get("status"))) { + return ApiResult.ok(map, map.get("msg").toString()); + } + + + //创建订单 + YxStoreOrder order = storeOrderService.createOrder(yxUser, key, param); + + if (ObjectUtil.isNull(order)) { + throw new YshopException("订单生成失败"); + } + + String orderId = order.getOrderId(); + + OrderExtendDto orderDTO = new OrderExtendDto(); + orderDTO.setKey(key); + orderDTO.setOrderId(orderId); + map.put("status", OrderLogEnum.CREATE_ORDER_SUCCESS.getValue()); + map.put("result", orderDTO); + map.put("createTime", order.getCreateTime()); + + //开始处理支付 + //处理金额为0的情况 + if(order.getPayPrice().compareTo(BigDecimal.ZERO) <= 0&&!param.getPayType().equals(PayTypeEnum.INTEGRAL.getValue())){ + storeOrderService.yuePay(orderId,yxUser.getUid()); + map.put("payMsg","支付成功"); + return ApiResult.ok(map,"支付成功"); + } + + orderSupplyService.goPay(map,orderId,yxUser.getUid(), + param.getPayType(),param.getFrom(),orderDTO); + return ApiResult.ok(map, map.get("payMsg").toString()); + } + + + /** + * 订单支付 + */ + @AppLog(value = "订单支付", type = 1) + @AuthCheck + @PostMapping("/order/pay") + @ApiOperation(value = "订单支付", notes = "订单支付") + public ApiResult> pay(@Valid @RequestBody PayParam param) { + Map map = new LinkedHashMap<>(); + Long uid = LocalUser.getUser().getUid(); + YxStoreOrderQueryVo storeOrder = storeOrderService + .getOrderInfo(param.getUni(), uid); + if (ObjectUtil.isNull(storeOrder)) { + throw new YshopException("订单不存在"); + } + + if (OrderInfoEnum.REFUND_STATUS_1.getValue().equals(storeOrder.getPaid())) { + throw new YshopException("该订单已支付"); + } + + String orderId = storeOrder.getOrderId(); + + OrderExtendDto orderDTO = new OrderExtendDto(); + orderDTO.setOrderId(orderId); + map.put("status", "SUCCESS"); + map.put("result", orderDTO); + + + if (storeOrder.getPayPrice().compareTo(BigDecimal.ZERO) <= 0 && !param.getPaytype().equals(PayTypeEnum.INTEGRAL.getValue())) { + storeOrderService.yuePay(orderId, uid); + return ApiResult.ok(map, "支付成功"); + } + + //处理是否已经修改过订单价格,如果修改用新的单号去拉起支付 + if (StrUtil.isNotBlank(storeOrder.getExtendOrderId())) { + orderId = storeOrder.getExtendOrderId(); + } + + + orderSupplyService.goPay(map, orderId, uid, param.getPaytype(), param.getFrom(), orderDTO); + + return ApiResult.ok(map); + } + + + /** + * 订单列表 + */ + @AppLog(value = "查看订单列表", type = 1) + @AuthCheck + @GetMapping("/order/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "商品状态,-1全部 默认为0未支付 1待发货 2待收货 3待评价 4已完成 5退款中 6已退款 7退款", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "订单列表", notes = "订单列表") + public ApiResult orderList(@RequestParam(value = "type", defaultValue = "0") int type, + @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit) { + Long uid = LocalUser.getUser().getUid(); + Map map = storeOrderService.orderList(uid, type, page, limit); + Long total = (Long) map.get("total"); + Long totalPage = (Long) map.get("totalPage"); + return ApiResult.resultPage(total.intValue(), totalPage.intValue(), map.get("list")); + } + + + /** + * 订单详情 + */ + @AppLog(value = "查看订单详情", type = 1) + @AuthCheck + @GetMapping("/order/detail/{key}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "订单详情", notes = "订单详情") + public ApiResult detail(@PathVariable String key) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key, uid); + if (ObjectUtil.isNull(storeOrder)) { + throw new YshopException("订单不存在"); + } + storeOrder = creatShareProductService.handleQrcode(storeOrder, ""); + + return ApiResult.ok(storeOrderService.handleOrder(storeOrder)); + } + + + /** + * 订单收货 + */ + @AppLog(value = "订单收货", type = 1) + @AuthCheck + @PostMapping("/order/take") + @ApiOperation(value = "订单收货", notes = "订单收货") + public ApiResult orderTake(@Validated @RequestBody DoOrderParam param) { + Long uid = LocalUser.getUser().getUid(); + storeOrderService.takeOrder(param.getUni(), uid); + return ApiResult.ok(); + } + + /** + * 订单产品信息 + */ + @PostMapping("/order/product") + @ApiOperation(value = "订单产品信息", notes = "订单产品信息") + public ApiResult product(@Validated @RequestBody ProductOrderParam param) { + return ApiResult.ok(orderSupplyService.getProductOrder(param.getUnique())); + } + + /** + * 订单评价 + */ + @AppLog(value = "订单评价", type = 1) + @AuthCheck + @NoRepeatSubmit + @PostMapping("/order/comment") + @ApiOperation(value = "订单评价", notes = "订单评价") + public ApiResult comment(@Valid @RequestBody ProductReplyParam param) { + YxUser user = LocalUser.getUser(); + YxStoreOrderCartInfo orderCartInfo = storeOrderCartInfoService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreOrderCartInfo::getUnique,param.getUnique())); + storeOrderService.orderComment(orderCartInfo, user, param.getUnique(), + param.getComment(), + param.getPics(), param.getProductScore(), param.getServiceScore()); + + //增加状态 + orderStatusService.create(orderCartInfo.getOid(), + OrderLogEnum.EVAL_ORDER.getValue(), + OrderLogEnum.EVAL_ORDER.getDesc()); + return ApiResult.ok(); + } + + /** + * 订单评价 + */ + @AppLog(value = "订单评价", type = 1) + @AuthCheck + @NoRepeatSubmit + @PostMapping("/order/comments") + @ApiOperation(value = "订单评价", notes = "订单评价") + public ApiResult comments(@Valid @RequestBody List param) { + YxUser user = LocalUser.getUser(); + if (param.size() > 0) { + YxStoreOrderCartInfo orderCartInfo = storeOrderCartInfoService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreOrderCartInfo::getUnique,param.get(0).getUnique())); + + for (ProductReplyParam productReplyParam : param) { + storeOrderService.orderComment(orderCartInfo , user, productReplyParam.getUnique(), + productReplyParam.getComment(), + productReplyParam.getPics(), productReplyParam.getProductScore(), productReplyParam.getServiceScore()); + } + + //增加状态 + orderStatusService.create(orderCartInfo.getOid(), + OrderLogEnum.EVAL_ORDER.getValue(), + OrderLogEnum.EVAL_ORDER.getDesc()); + } + return ApiResult.ok(); + } + + + /** + * 订单删除 + */ + @AppLog(value = "订单删除", type = 1) + @AuthCheck + @PostMapping("/order/del") + @ApiOperation(value = "订单删除", notes = "订单删除") + public ApiResult orderDel(@Validated @RequestBody DoOrderParam param) { + Long uid = LocalUser.getUser().getUid(); + storeOrderService.removeOrder(param.getUni(), uid); + return ApiResult.ok(); + } + + /** + * 订单退款理由 + */ + @GetMapping("/order/refund/reason") + @ApiOperation(value = "订单退款理由", notes = "订单退款理由") + public ApiResult refundReason() { + ArrayList list = new ArrayList<>(); + list.add("收货地址填错了"); + list.add("与描述不符"); + list.add("信息填错了,重新拍"); + list.add("收到商品损坏了"); + list.add("未按预定时间发货"); + list.add("其它原因"); + + return ApiResult.ok(list); + } + + /** + * 订单退款审核 + */ + @AppLog(value = "订单退款审核", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/order/refund/verify") + @ApiOperation(value = "订单退款审核", notes = "订单退款审核") + public ApiResult refundVerify(@RequestBody RefundParam param) { + Long uid = LocalUser.getUser().getUid(); + storeOrderService.orderApplyRefund(param.getRefundReasonWapExplain(), + param.getRefundReasonWapImg(), + EmojiParser.removeAllEmojis(param.getText()), + param.getUni(), uid); + return ApiResult.ok(); + } + + /** + * 订单取消 未支付的订单回退积分,回退优惠券,回退库存 + */ + @AppLog(value = "订单取消", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/order/cancel") + @ApiOperation(value = "订单取消", notes = "订单取消") + public ApiResult cancelOrder(@Validated @RequestBody HandleOrderParam param) { + Long uid = LocalUser.getUser().getUid(); + YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(param.getId(), uid); + if (ObjectUtil.isNull(orderInfo)) { + throw new YshopException("订单不存在"); + } + if (orderInfo.getStatus() != 0) { + throw new YshopException("订单不能取消"); + } + if (orderInfo.getPaid() == 1) { + BigDecimal bigDecimal = new BigDecimal("100"); + int payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue(); + weixinPayService.refundOrder(param.getId(),payPrice); + } + storeOrderService.cancelOrder(param.getId(), uid); + return ApiResult.ok(); + } + + + /** + * 获取物流信息 + */ + @AuthCheck + @PostMapping("/order/express") + @ApiOperation(value = "获取物流信息", notes = "获取物流信息") + public ApiResult express(@RequestBody ExpressParam expressInfoDo) { + + //顺丰轨迹查询处理 + String lastFourNumber = ""; + if (expressInfoDo.getShipperCode().equals(ShipperCodeEnum.SF.getValue())) { + YxStoreOrderDto yxStoreOrderDto; + yxStoreOrderDto = storeOrderService.getOrderDetail(Long.valueOf(expressInfoDo.getOrderCode())); + lastFourNumber = yxStoreOrderDto.getUserPhone(); + if (lastFourNumber.length() == 11) { + lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4); + } + } + + ExpressService expressService = ExpressAutoConfiguration.expressService(); + ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(), + expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode(), lastFourNumber); + if (!expressInfo.isSuccess()) { + throw new YshopException(expressInfo.getReason()); + } + return ApiResult.ok(expressInfo); + } + + /** + * 订单核销 + */ + @AppLog(value = "订单核销", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/order/order_verific") + @ApiOperation(value = "订单核销", notes = "订单核销") + public ApiResult orderVerify(@RequestBody OrderVerifyParam param) { + Long uid = LocalUser.getUser().getUid(); + YxStoreOrderQueryVo orderQueryVo = storeOrderService.verifyOrder(param.getVerifyCode(), + param.getIsConfirm(), uid); + if (orderQueryVo != null) { + return ApiResult.ok(orderQueryVo); + } + + return ApiResult.ok("核销成功"); + } + + + @AuthCheck + @GetMapping("/order/getSubscribeTemplate") + @ApiOperation(value = "获取订阅消息模板ID", notes = "获取订阅消息模板ID") + public ApiResult> getSubscribeTemplate() { + List yxWechatTemplate = yxWechatTemplateService.lambdaQuery() + .eq(YxWechatTemplate::getType, "subscribe") + .eq(YxWechatTemplate::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()).list(); + List temId = yxWechatTemplate.stream().map(tem -> tem.getTempid()).collect(Collectors.toList()); + return ApiResult.ok(temId); + } + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/CollectDelFootParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/CollectDelFootParam.java new file mode 100644 index 00000000..51484fe7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/CollectDelFootParam.java @@ -0,0 +1,20 @@ +package co.yixiang.app.modules.product.param; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @author : gzlv 2021/6/26 19:17 + */ +@Getter +@Setter +@ApiModel("查询参数对象") +public class CollectDelFootParam { + + private List ids; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxArticleQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxArticleQueryParam.java new file mode 100644 index 00000000..f66667f6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxArticleQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 文章管理表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxArticleQueryParam对象", description="文章管理表查询参数") +public class YxArticleQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreCategoryQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreCategoryQueryParam.java new file mode 100644 index 00000000..965f2ad5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreCategoryQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 商品分类表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-22 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreCategoryQueryParam对象", description="商品分类表查询参数") +public class YxStoreCategoryQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrQueryParam.java new file mode 100644 index 00000000..80956ca6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 商品属性表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreProductAttrQueryParam对象", description="商品属性表查询参数") +public class YxStoreProductAttrQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrResultQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrResultQueryParam.java new file mode 100644 index 00000000..35770694 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrResultQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 商品属性详情表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreProductAttrResultQueryParam对象", description="商品属性详情表查询参数") +public class YxStoreProductAttrResultQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrValueQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrValueQueryParam.java new file mode 100644 index 00000000..478b67ac --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductAttrValueQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 商品属性值表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreProductAttrValueQueryParam对象", description="商品属性值表查询参数") +public class YxStoreProductAttrValueQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductRelationQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductRelationQueryParam.java new file mode 100644 index 00000000..26096ae9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductRelationQueryParam.java @@ -0,0 +1,29 @@ +package co.yixiang.app.modules.product.param; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + *

+ * 商品点赞和收藏表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Getter +@Setter +@ApiModel("查询参数对象") +public class YxStoreProductRelationQueryParam { + + @NotBlank(message = "参数有误") + @ApiModelProperty(value = "商品id",required=true) + private String id; + + @ApiModelProperty(value = "某种类型的商品(普通商品、秒杀商品)") + private String category = "root"; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductReplyQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductReplyQueryParam.java new file mode 100644 index 00000000..d9d1105b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/param/YxStoreProductReplyQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 评论表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreProductReplyQueryParam对象", description="评论表查询参数") +public class YxStoreProductReplyQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreCategoryController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreCategoryController.java new file mode 100644 index 00000000..0e1f5845 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreCategoryController.java @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.product.rest; + +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.api.ApiResult; +import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.utils.CateDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + *

+ * 商品分类前端控制器 + *

+ * + * @author hupeng + * @since 2019-10-22 + */ +@Slf4j +@RestController +@Api(value = "商品分类", tags = "商城:商品分类") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class AppStoreCategoryController { + + private final YxStoreCategoryService yxStoreCategoryService; + + + /** + * 商品分类列表 + */ + @AnonymousAccess + @GetMapping("/category") + @ApiOperation(value = "商品分类列表",notes = "商品分类列表") + public ApiResult> getYxStoreCategoryPageList(){ + return ApiResult.ok(yxStoreCategoryService.getList()); + } + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreProductController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreProductController.java new file mode 100644 index 00000000..8e79a750 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/product/rest/AppStoreProductController.java @@ -0,0 +1,311 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.product.rest; + + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.qrcode.QrCodeUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.product.param.CollectDelFootParam; +import co.yixiang.app.modules.product.param.YxStoreProductRelationQueryParam; +import co.yixiang.app.modules.services.CreatShareProductService; +import co.yixiang.constant.ShopConstants; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.AppFromEnum; +import co.yixiang.enums.ProductEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.param.YxStoreProductQueryParam; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.product.service.YxStoreProductReplyService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.vo.ProductVo; +import co.yixiang.modules.product.vo.ReplyCountVo; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import co.yixiang.modules.shop.domain.YxSystemAttachment; +import co.yixiang.modules.shop.service.YxSystemAttachmentService; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.user.domain.YxUser; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.awt.FontFormatException; +import java.io.File; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 商品控制器 + *

+ * + * @author hupeng + * @since 2019-10-19 + */ +@Slf4j +@RestController +@Api(value = "产品模块", tags = "商城:产品模块") +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class AppStoreProductController { + + private final YxStoreProductService storeProductService; + private final YxStoreProductRelationService productRelationService; + private final YxStoreProductReplyService replyService; + private final YxSystemConfigService systemConfigService; + private final YxSystemAttachmentService systemAttachmentService; + private final CreatShareProductService creatShareProductService; + private String path = ""; + + + /** + * 获取首页更多产品 + */ + @GetMapping("/groom/list/{type}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "类型:1精品推荐,2热门榜单,3首发新品,4促销单品", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "获取首页更多产品",notes = "获取首页更多产品") + public ApiResult> moreGoodsList(@PathVariable Integer type){ + Map map = new LinkedHashMap<>(); + // 精品推荐 + if(ProductEnum.TYPE_1.getValue().equals(type)){ + map.put("list",storeProductService.getList(1,20,ProductEnum.TYPE_1.getValue())); + // 热门榜单 + }else if(type.equals(ProductEnum.TYPE_2.getValue())){ + map.put("list",storeProductService.getList(1,20,ProductEnum.TYPE_2.getValue())); + // 首发新品 + }else if(type.equals(ProductEnum.TYPE_3.getValue())){ + map.put("list",storeProductService.getList(1,20,ProductEnum.TYPE_3.getValue())); + // 促销单品 + }else if(type.equals(ProductEnum.TYPE_4.getValue())){ + map.put("list",storeProductService.getList(1,20,ProductEnum.TYPE_4.getValue())); + } + + return ApiResult.ok(map); + } + + /** + * 获取产品列表 + */ + @GetMapping("/products") + @ApiOperation(value = "商品列表",notes = "商品列表") + public ApiResult> goodsList(YxStoreProductQueryParam productQueryParam){ + return ApiResult.ok(storeProductService.getGoodsList(productQueryParam)); + } + + /** + * 为你推荐 + */ + @GetMapping("/product/hot") + @ApiOperation(value = "为你推荐",notes = "为你推荐") + public ApiResult> productRecommend(YxStoreProductQueryParam queryParam){ + return ApiResult.ok(storeProductService.getList(queryParam.getPage(), queryParam.getLimit(), + ShopCommonEnum.IS_STATUS_1.getValue())); + } + + /** + * 商品详情海报 + */ + @AppLog(value = "商品详情海报", type = 1) + @AuthCheck + @GetMapping("/product/poster/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品ID", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "商品详情海报",notes = "商品详情海报") + public ApiResult prodoctPoster(@PathVariable Integer id,@RequestParam(value = "from",defaultValue = "h5") String from) throws IOException, FontFormatException { + YxUser userInfo = LocalUser.getUser(); + + long uid = userInfo.getUid(); + + YxStoreProduct storeProduct = storeProductService.getById(id); + // 海报 + String siteUrl = systemConfigService.getData(SystemConfigConstants.SITE_URL); + if(StrUtil.isEmpty(siteUrl)){ + return ApiResult.fail("未配置h5地址"); + } + String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL); + if(StrUtil.isEmpty(apiUrl)){ + return ApiResult.fail("未配置api地址"); + } + String name = id+"_"+uid + "_"+from+"_product_detail_wap.jpg"; + YxSystemAttachment attachment = systemAttachmentService.getInfo(name); + String sepa = File.separator; + String fileDir = path+"qrcode"+ sepa; + String qrcodeUrl = ""; + if(ObjectUtil.isNull(attachment)){ + File file = FileUtil.mkdir(new File(fileDir)); + //如果类型是小程序 + if(AppFromEnum.ROUNTINE.getValue().equals(from)){ + siteUrl = siteUrl+"/product/"; + //生成二维码 + QrCodeUtil.generate(siteUrl+"?id="+id+"&spread="+uid+"&pageType=good&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180, + FileUtil.file(fileDir+name)); + } + else if(AppFromEnum.APP.getValue().equals(from)){ + siteUrl = siteUrl+"/product/"; + //生成二维码 + QrCodeUtil.generate(siteUrl+"?id="+id+"&spread="+uid+"&pageType=good&codeType="+AppFromEnum.APP.getValue(), 180, 180, + FileUtil.file(fileDir+name)); + //如果类型是h5 + }else if(AppFromEnum.H5.getValue().equals(from)){ + //生成二维码 + QrCodeUtil.generate(siteUrl+"/detail/"+id+"?spread="+uid, 180, 180, + FileUtil.file(fileDir+name)); + }else { + //生成二维码 + String uniUrl = systemConfigService.getData(SystemConfigConstants.UNI_SITE_URL); + siteUrl = StrUtil.isNotBlank(uniUrl) ? uniUrl : ShopConstants.DEFAULT_UNI_H5_URL; + QrCodeUtil.generate(siteUrl+"/pages/shop/GoodsCon/index?id="+id+"&spread="+uid, 180, 180, + FileUtil.file(fileDir+name)); + } + systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)), + fileDir+name,"qrcode/"+name); + + qrcodeUrl = apiUrl + "/api/file/qrcode/"+name; + }else{ + qrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir(); + } + String spreadPicName = id+"_"+uid + "_"+from+"_product_user_spread.jpg"; + String spreadPicPath = fileDir+spreadPicName; + String rr = creatShareProductService.creatProductPic(storeProduct,qrcodeUrl, + spreadPicName,spreadPicPath,apiUrl); + return ApiResult.ok(rr); + } + + + + /** + * 普通商品详情 + */ + //@AppLog(value = "普通商品详情", type = 1) + //@AuthCheck + @GetMapping("/product/detail/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品ID", paramType = "query", dataType = "long",required = true), + @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "longitude", value = "经度", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "from", value = "来自:", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "普通商品详情",notes = "普通商品详情") + public ApiResult detail(@PathVariable long id, + @RequestParam(value = "",required=false) String latitude, + @RequestParam(value = "",required=false) String longitude, + @RequestParam(value = "",required=false) String from) { + long uid = LocalUser.getUidByToken(); + storeProductService.incBrowseNum(id); + ProductVo productDTO = storeProductService.goodsDetail(id,uid,latitude,longitude); + return ApiResult.ok(productDTO); + } + + /** + * 添加收藏 + */ + @AppLog(value = "添加收藏", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/collect/add") + @ApiOperation(value = "添加收藏",notes = "添加收藏") + public ApiResult collectAdd(@Validated @RequestBody YxStoreProductRelationQueryParam param){ + long uid = LocalUser.getUser().getUid(); + if(!NumberUtil.isNumber(param.getId())) { + throw new YshopException("参数非法"); + } + productRelationService.addRroductRelation(Long.valueOf(param.getId()),uid,param.getCategory()); + return ApiResult.ok(); + } + + /** + * 取消收藏 + */ + @AppLog(value = "取消收藏", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/collect/del") + @ApiOperation(value = "取消收藏",notes = "取消收藏") + public ApiResult collectDel(@Validated @RequestBody YxStoreProductRelationQueryParam param){ + long uid = LocalUser.getUser().getUid(); + if(!NumberUtil.isNumber(param.getId())) { + throw new YshopException("参数非法"); + } + productRelationService.delRroductRelation(Long.valueOf(param.getId()), + uid,param.getCategory()); + return ApiResult.ok(); + } + + /** + * 取消收藏/足跡 + */ + @AppLog(value = "删除足跡", type = 1) + @NoRepeatSubmit + @AuthCheck + @DeleteMapping("/collect/delFoot") + @ApiOperation(value = "删除足跡",notes = "删除足跡") + public ApiResult collectDelFoot(@Validated @RequestBody CollectDelFootParam param){ + if (CollectionUtil.isEmpty(param.getIds())){ + throw new YshopException("参数非法"); + } + productRelationService.collectDelFoot(param.getIds()); + return ApiResult.ok(); + } + + /** + * 获取产品评论 + */ + @GetMapping("/reply/list/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品ID", paramType = "query", dataType = "long",required = true), + @ApiImplicitParam(name = "type", value = "评论分数类型", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "获取产品评论",notes = "获取产品评论") + public ApiResult> replyList(@PathVariable Long id, + @RequestParam(value = "type",defaultValue = "0") int type, + @RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + return ApiResult.ok(replyService.getReplyList(id,type, page,limit)); + } + + /** + * 获取产品评论数据 + */ + @GetMapping("/reply/config/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品ID", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "获取产品评论数据",notes = "获取产品评论数据") + public ApiResult replyCount(@PathVariable Integer id){ + return ApiResult.ok(replyService.getReplyCount(id)); + } + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java new file mode 100644 index 00000000..b3522a11 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java @@ -0,0 +1,417 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.services; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; +import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; +import cn.binarywang.wx.miniapp.bean.WxMaUserInfo; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.SecureUtil; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.util.IpUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.AppFromEnum; +import co.yixiang.app.modules.auth.param.LoginParam; +import co.yixiang.app.modules.auth.param.RegParam; +import co.yixiang.modules.mp.config.WxMaConfiguration; +import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.modules.shop.domain.YxSystemAttachment; +import co.yixiang.modules.shop.service.YxSystemAttachmentService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.dto.WechatUserDto; +import co.yixiang.modules.user.vo.OnlineUser; +import co.yixiang.utils.*; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.WxOAuth2UserInfo; +import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @ClassName 登陆认证服务类 + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/14 + **/ +@Slf4j +@Service +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class AppAuthService { + + private final YxUserService userService; + private final RedisUtils redisUtils; + private static Integer expiredTimeIn; + private final YxSystemAttachmentService systemAttachmentService; + + @Value("${yshop.security.token-expired-in}") + public void setExpiredTimeIn(Integer expiredTimeIn) { + AppAuthService.expiredTimeIn = expiredTimeIn; + } + + + /** + * 小程序登陆 + * + * @param loginParam loginParam + * @param uid + * @param sessionKey + * @return long + */ + @Transactional(rollbackFor = Exception.class) + public YxUser loginAuth(LoginParam loginParam,Long uid,String sessionKey) { +// String code = loginParam.getCode(); + String encryptedData = loginParam.getEncryptedData(); + String iv = loginParam.getIv(); + String spread = loginParam.getSpread(); + //读取redis配置 + String appId = redisUtils.getY(ShopKeyUtils.getWxAppAppId()); + String secret = redisUtils.getY(ShopKeyUtils.getWxAppSecret()); + if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) { + throw new YshopException("请先配置小程序"); + } + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + //WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code); + + WxMaUserInfo wxMpUser = wxMaService.getUserService() + .getUserInfo(sessionKey, encryptedData, iv); + + YxUser yxUser = userService.getById(uid); + //过滤掉表情 + String ip = co.yixiang.app.common.util.IpUtil.getRequestIp(); + + if(!StringUtils.isNotBlank(yxUser.getNickname())){ + yxUser.setNickname(wxMpUser.getNickName()); + yxUser.setAvatar(wxMpUser.getAvatarUrl()); + } + yxUser.setLastIp(ip); + //构建微信用户 + WechatUserDto wechatUserDTO = yxUser.getWxProfile(); + wechatUserDTO.setNickname(wxMpUser.getNickName()); + wechatUserDTO.setSex(Integer.valueOf(wxMpUser.getGender())); + wechatUserDTO.setLanguage(wxMpUser.getLanguage()); + wechatUserDTO.setCity(wxMpUser.getCity()); + wechatUserDTO.setProvince(wxMpUser.getProvince()); + wechatUserDTO.setCountry(wxMpUser.getCountry()); + wechatUserDTO.setHeadimgurl(wxMpUser.getAvatarUrl()); + yxUser.setWxProfile(wechatUserDTO); + userService.updateById(yxUser); + userService.setSpread(spread, yxUser.getUid()); + return yxUser; + } + + + /** + * 小程序登陆 + * + * @param loginParam loginParam + * @return long + */ + @Transactional(rollbackFor = Exception.class) + public YxUser wxappLogin(LoginParam loginParam) { + String code = loginParam.getCode(); + String encryptedData = loginParam.getEncryptedData(); + String iv = loginParam.getIv(); + String spread = loginParam.getSpread(); + try { + //读取redis配置 + String appId = redisUtils.getY(ShopKeyUtils.getWxAppAppId()); + String secret = redisUtils.getY(ShopKeyUtils.getWxAppSecret()); + if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) { + throw new YshopException("请先配置小程序"); + } + log.info("appId:{},secret:{}",appId,secret); + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code); + + WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService() + .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); + + YxUser yxUser = this.userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getPhone, phoneNoInfo.getPhoneNumber()), false); + + if (ObjectUtil.isNull(yxUser)) { + + //兼容旧系统 + yxUser = this.userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getUsername, session.getOpenid()), false); + + if (ObjectUtil.isNull(yxUser)) { + //过滤掉表情 + String ip = co.yixiang.app.common.util.IpUtil.getRequestIp(); + yxUser = YxUser.builder() + .username(phoneNoInfo.getPhoneNumber()) + .phone(phoneNoInfo.getPhoneNumber()) + .addIp(ip) + .lastIp(ip) + .userType(AppFromEnum.ROUNTINE.getValue()) + .build(); + + //构建微信用户 + WechatUserDto wechatUserDTO = WechatUserDto.builder() + .routineOpenid(session.getOpenid()) + .unionId(session.getUnionid()) + .build(); + + yxUser.setWxProfile(wechatUserDTO); + + this.userService.save(yxUser); + }else { + yxUser.setUsername(phoneNoInfo.getPhoneNumber()); + yxUser.setPhone(phoneNoInfo.getPhoneNumber()); + this.userService.updateById(yxUser); + } + + } else { + WechatUserDto wechatUser = yxUser.getWxProfile(); + if (null != wechatUser &&(StrUtil.isBlank(wechatUser.getRoutineOpenid()) && StrUtil.isNotBlank(session.getOpenid()))) { + wechatUser.setRoutineOpenid(session.getOpenid()); + yxUser.setWxProfile(wechatUser); + } + yxUser.setUserType(AppFromEnum.ROUNTINE.getValue()); + this.userService.updateById(yxUser); + } + this.userService.setSpread(spread, yxUser.getUid()); + redisUtils.set(ShopConstants.YSHOP_MINI_SESSION_KET + yxUser.getUid(), session.getSessionKey()); + return yxUser; + } catch (WxErrorException e) { + e.printStackTrace(); + log.error(e.getMessage()); + throw new YshopException(e.toString()); + } + } + + /** + * 公众号登陆 + * + * @param code code码 + * @param spread 上级用户 + * @return uid + */ + @Transactional(rollbackFor = Exception.class) + public YxUser wechatLogin(String code, String spread) { + try { + WxMpService wxService = WxMpConfiguration.getWxMpService(); + WxOAuth2AccessToken wxMpOAuth2AccessToken = wxService.getOAuth2Service().getAccessToken(code); + WxOAuth2UserInfo wxMpUser = wxService.getOAuth2Service().getUserInfo(wxMpOAuth2AccessToken, null); + String openid = wxMpUser.getOpenid(); + + //如果开启了UnionId + if (StrUtil.isNotBlank(wxMpUser.getUnionId())) { + openid = wxMpUser.getUnionId(); + } + + YxUser yxUser = userService.getOne(Wrappers.lambdaQuery() + .eq(YxUser::getUsername, openid), false); + + //long uid = 0; + YxUser returnUser = null; + if (yxUser == null) { + //过滤掉表情 + String nickname = wxMpUser.getNickname(); + log.info("昵称:{}", nickname); + //用户保存 + String ip = co.yixiang.app.common.util.IpUtil.getRequestIp(); + YxUser user = YxUser.builder() + .username(openid) + .nickname(nickname) + .avatar(wxMpUser.getHeadImgUrl()) + .addIp(ip) + .lastIp(ip) + .userType(AppFromEnum.WECHAT.getValue()) + .build(); + + //构建微信用户 + WechatUserDto wechatUserDTO = WechatUserDto.builder() + .nickname(nickname) + .openid(wxMpUser.getOpenid()) + .unionId(wxMpUser.getUnionId()) + .language("") + .headimgurl(wxMpUser.getHeadImgUrl()) + .subscribe(false) + .subscribeTime(0L) + .build(); + + user.setWxProfile(wechatUserDTO); + userService.save(user); + + returnUser = user; + } else { + returnUser = yxUser; + WechatUserDto wechatUser = yxUser.getWxProfile(); + if ((StrUtil.isBlank(wechatUser.getOpenid()) && StrUtil.isNotBlank(wxMpUser.getOpenid())) + || (StrUtil.isBlank(wechatUser.getUnionId()) && StrUtil.isNotBlank(wxMpUser.getUnionId()))) { + wechatUser.setOpenid(wxMpUser.getOpenid()); + wechatUser.setUnionId(wxMpUser.getUnionId()); + + yxUser.setWxProfile(wechatUser); + } + + yxUser.setUserType(AppFromEnum.WECHAT.getValue()); + userService.updateById(yxUser); + + } + + userService.setSpread(spread, returnUser.getUid()); + + log.error("spread:{}", spread); + + return returnUser; + + } catch (WxErrorException e) { + e.printStackTrace(); + log.error(e.getMessage()); + throw new YshopException(e.toString()); + } + } + + + /** + * 注册 + * + * @param param RegDTO + */ + @Transactional(rollbackFor = Exception.class) + public void register(RegParam param) { + + String account = param.getAccount(); + String ip = IpUtil.getRequestIp(); + YxUser user = YxUser.builder() + .username(account) + .nickname(account) + .password(SecureUtil.md5(param.getPassword())) + .phone(account) + .avatar(ShopConstants.YSHOP_DEFAULT_AVATAR) + .addIp(ip) + .lastIp(ip) + .userType(AppFromEnum.H5.getValue()) + .build(); + + userService.save(user); + + //设置推广关系 + if (StrUtil.isNotBlank(param.getInviteCode())) { + YxSystemAttachment systemAttachment = systemAttachmentService.getByCode(param.getInviteCode()); + if (systemAttachment != null) { + userService.setSpread(String.valueOf(systemAttachment.getUid()), + user.getUid()); + } + } + + } + + + /** + * 保存在线用户信息 + * + * @param yxUser / + * @param token / + * @param request / + */ + public void save(YxUser yxUser, String token, HttpServletRequest request) { + String job = "yshop开发工程师"; + String ip = StringUtils.getIp(request); + String browser = StringUtils.getBrowser(request); + String address = StringUtils.getCityInfo(ip); + OnlineUser onlineUser = null; + try { + onlineUser = new OnlineUser(yxUser.getUsername(), yxUser.getNickname(), job, browser, + ip, address, EncryptUtils.desEncrypt(token), new Date()); + } catch (Exception e) { + e.printStackTrace(); + } + redisUtils.set(ShopConstants.YSHOP_APP_LOGIN_USER +onlineUser.getUserName() + ":" + token, onlineUser, AppAuthService.expiredTimeIn); + } + + /** + * 检测用户是否在之前已经登录,已经登录踢下线 + * + * @param userName 用户名 + */ + public void checkLoginOnUser(String userName, String igoreToken) { + List onlineUsers = this.getAll(userName); + if (onlineUsers == null || onlineUsers.isEmpty()) { + return; + } + for (OnlineUser onlineUser : onlineUsers) { + try { + String token = EncryptUtils.desDecrypt(onlineUser.getKey()); + if (StringUtils.isNotBlank(igoreToken) && !igoreToken.equals(token)) { + this.kickOut(userName, onlineUser.getKey()); + } else if (StringUtils.isBlank(igoreToken)) { + this.kickOut(userName, onlineUser.getKey()); + } + } catch (Exception e) { + log.error("checkUser is error", e); + } + } + } + + /** + * 踢出用户 + * + * @param key / + */ + public void kickOut(String userName, String key) throws Exception { + key = ShopConstants.YSHOP_APP_LOGIN_USER + userName + ":" + EncryptUtils.desDecrypt(key); + redisUtils.del(key); + } + + /** + * 退出登录 + * + * @param token / + */ + public void logout(String userName, String token) { + String key = ShopConstants.YSHOP_APP_LOGIN_USER + userName + ":" + token; + redisUtils.del(key); + } + + /** + * 查询全部数据,不分页 + * + * @param uName / + * @return / + */ + private List getAll(String uName) { + List keys = null; + keys = redisUtils.scan(ShopConstants.YSHOP_APP_LOGIN_USER + uName + ":" + "*"); + + Collections.reverse(keys); + List onlineUsers = new ArrayList<>(); + for (String key : keys) { + OnlineUser onlineUser = (OnlineUser) redisUtils.get(key); + onlineUsers.add(onlineUser); + } + onlineUsers.sort((o1, o2) -> o2.getLoginTime().compareTo(o1.getLoginTime())); + return onlineUsers; + } + + /** + * 根据手机号查询用户注册状态 + * @param phone 手机号 + * @return / + */ + public YxUser authPhone(String phone) { + return userService.getOne(Wrappers.lambdaQuery().eq(YxUser::getPhone, phone)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java new file mode 100644 index 00000000..2d55ffc2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java @@ -0,0 +1,874 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.services; + +import cn.hutool.core.img.ImgUtil; +import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.qrcode.QrCodeUtil; +import cn.hutool.http.HttpUtil; +import co.yixiang.api.YshopException; +import co.yixiang.constant.ShopConstants; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.AppFromEnum; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.domain.YxStoreCombination; +import co.yixiang.modules.activity.domain.YxStorePink; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.service.YxStoreCombinationService; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.shop.domain.YxSystemAttachment; +import co.yixiang.modules.shop.service.YxSystemAttachmentService; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.utils.OrderUtil; + +import co.yixiang.utils.RedisUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageInputStream; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontFormatException; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import static co.yixiang.utils.FileUtil.transformStyle; + +/** + * @ClassName 二维码相关服务 + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/22 + **/ +@Slf4j +@Service +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +public class CreatShareProductService { + + private final YxSystemAttachmentService systemAttachmentService; + private final YxStoreBargainService storeBargainService; + private final YxStoreBargainUserService storeBargainUserService; + private final YxStorePinkService storePinkService; + private final YxStoreCombinationService storeCombinationService; + private final YxSystemStoreService systemStoreService; + private final YxSystemConfigService systemConfigService; + private final RedisUtils redisUtils; + + /** + * 返回门店信息与二维码 + * @param storeOrder 订单 + * @return YxStoreOrderQueryVo + */ + public YxStoreOrderQueryVo handleQrcode(YxStoreOrderQueryVo storeOrder,String path){ + //门店 + if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(storeOrder.getShippingType())){ + String mapKey = redisUtils.get(SystemConfigConstants.TENGXUN_MAP_KEY).toString(); + if(StrUtil.isBlank(mapKey)) { + throw new YshopException("请配置腾讯地图key"); + } + String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL); + if(StrUtil.isEmpty(apiUrl)){ + throw new YshopException("未配置api地址"); + } + //生成二维码 + String name = storeOrder.getVerifyCode()+"_yshop.jpg"; + YxSystemAttachment attachment = systemAttachmentService.getInfo(name); + String fileDir = path+"qrcode"+ File.separator; + String qrcodeUrl = ""; + if(ObjectUtil.isNull(attachment)){ + //生成二维码 + File file = FileUtil.mkdir(new File(fileDir)); + QrCodeUtil.generate(storeOrder.getVerifyCode(), 180, 180, + FileUtil.file(fileDir+name)); + systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)), + fileDir+name,"qrcode/"+name); + qrcodeUrl = apiUrl + "/api/file/qrcode/"+name; + }else{ + qrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir(); + } + storeOrder.setCode(qrcodeUrl); + storeOrder.setMapKey(mapKey); + storeOrder.setSystemStore(systemStoreService.getYxSystemStoreById(storeOrder.getStoreId())); + } + + return storeOrder; + } + + /** + * 获取分销二维码url + * @param from 来源 + * @param userInfo 用户 + * @param siteUrl h5地址 + * @param apiUrl api地址 + * @param path 本地图片路径 + * @return url + */ + public String getSpreadUrl(String from,YxUser userInfo,String siteUrl, + String apiUrl,String path){ + String spreadUrl = ""; + Long uid = userInfo.getUid(); + + File newFile = new File("fx.jpg"); + File newFileT = new File("simsunb.ttf"); + try { + if(!newFile.exists()){ + InputStream stream = getClass().getClassLoader().getResourceAsStream("fx.jpg"); + FileUtils.copyInputStreamToFile(stream, newFile); + } + if(!newFileT.exists()){ + InputStream streamT = getClass().getClassLoader() + .getResourceAsStream("simsunb.ttf"); + FileUtils.copyInputStreamToFile(streamT, newFileT); + } + } catch (IOException e) { + log.error(e.getMessage()); + throw new YshopException(e.getMessage()); + } + + if(StrUtil.isNotBlank(from) && AppFromEnum.APP.getValue().equals(from)){ + String spreadPicName = uid + "_"+from+"_user_spread.jpg"; + String fileDir = path+"qrcode"+File.separator; + String spreadPicPath = fileDir+spreadPicName; + + YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); + if(ObjectUtil.isNull(attachmentT)){ + try { + Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT); + Font f= font.deriveFont(Font.PLAIN,20); + ImgUtil.pressText(// + newFile, + FileUtil.file(spreadPicPath), + userInfo.getNickname()+"邀您加入", + Color.BLACK, + f, //字体 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + String inviteCode = OrderUtil.createShareCode(); + ImgUtil.pressText( + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + "邀您码:"+ inviteCode, + Color.RED, + f, //字体 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f + ); + + systemAttachmentService.newAttachmentAdd(spreadPicName, + String.valueOf(FileUtil.size(new File(spreadPicPath))), + spreadPicPath,"qrcode/"+spreadPicName,uid,inviteCode); + + spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName; + } catch (Exception e) { + e.printStackTrace(); + } + }else{ + spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir(); + } + } + else{//其他 + if(StrUtil.isBlank(from)) { + from = AppFromEnum.H5.getValue(); + } + + String name = uid + "_"+from+"_user_wap.jpg"; + + YxSystemAttachment attachment = systemAttachmentService.getInfo(name); + String fileDir = path+"qrcode"+File.separator; + String qrcodeUrl = ""; + if(ObjectUtil.isNull(attachment)){ + //生成二维码 + //判断用户是否小程序,注意小程序二维码生成路径要与H5不一样 不然会导致都跳转到小程序问题 + if(from.equals(AppFromEnum.ROUNTINE.getValue())){ + siteUrl = siteUrl+"/distribution/"; + }else if(AppFromEnum.UNIAPPH5.getValue().equals(from)){ + String uniUrl = systemConfigService.getData(SystemConfigConstants.UNI_SITE_URL); + siteUrl = StrUtil.isNotBlank(uniUrl) ? uniUrl : ShopConstants.DEFAULT_UNI_H5_URL; + siteUrl = siteUrl+"/pages/Loading/index"; + } + File file = FileUtil.mkdir(new File(fileDir)); + QrCodeUtil.generate(siteUrl+"?spread="+uid, 180, 180, + FileUtil.file(fileDir+name)); + + systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)), + fileDir+name,"qrcode/"+name); + + qrcodeUrl = fileDir+name; + }else{ + qrcodeUrl = attachment.getAttDir(); + } + + String spreadPicName = uid + "_"+from+"_user_spread.jpg"; + String spreadPicPath = fileDir+spreadPicName; + + YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); + if(ObjectUtil.isNull(attachmentT)){ + try { + + Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT); + Font f= font.deriveFont(Font.PLAIN,20); + //font. + ImgUtil.pressText(// + newFile, + FileUtil.file(spreadPicPath), + userInfo.getNickname()+"邀您加入", + Color.BLACK, + f, //字体 + 50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + ImgUtil.pressImage( + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片 + -150, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f + ); + + systemAttachmentService.attachmentAdd(spreadPicName, + String.valueOf(FileUtil.size(new File(spreadPicPath))), + spreadPicPath,"qrcode/"+spreadPicName); + + spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName; + + } catch (Exception e) { + e.printStackTrace(); + } + }else{ + spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir(); + } + + } + + return spreadUrl; + } + + + /** + * 获取砍价海报 + * @param bargainId 砍价商品id + * @param userInfo 用户 + * @param siteUrl h5地址 + * @param apiUrl api地址 + * @param path 本地图片路径 + * @return url + */ + public String getBargainPosterUrl(Long bargainId, YxUser userInfo,String siteUrl, + String apiUrl,String path,String from){ + Long uid = userInfo.getUid(); + YxStoreBargain storeBargainQueryVo = storeBargainService + .getById(bargainId); + YxStoreBargainUser storeBargainUser = storeBargainUserService + .getBargainUserInfo(bargainId,uid); + + if(ObjectUtil.isNull(storeBargainQueryVo) || ObjectUtil.isNull(storeBargainUser)) { + throw new YshopException("数据不存在"); + } + //用户可以砍掉的金额 好友砍价之前获取可以砍价金额 + double coverPrice = NumberUtil.sub(storeBargainUser.getBargainPrice() + ,storeBargainUser.getBargainPriceMin()).doubleValue(); + //用户剩余要砍掉的价格 + double surplusPrice = NumberUtil.sub(coverPrice, + storeBargainUser.getPrice()).doubleValue(); + + + String name = bargainId+"_"+uid + "_"+from+"_bargain_share_wap.jpg"; + YxSystemAttachment attachment = systemAttachmentService.getInfo(name); + //删除已经存在的砍价海报图片 + if (ObjectUtil.isNotNull(attachment)) { + storeBargainService.deleteBargainImg(name); + } + String fileDir = path+"qrcode"+ File.separator; + String qrcodeUrl = ""; + if(ObjectUtil.isNull(attachment)){ + //生成二维码 + //判断用户是否小程序,注意小程序二维码生成路径要与H5不一样 不然会导致都跳转到小程序问题 + File file = FileUtil.mkdir(new File(fileDir)); + if(AppFromEnum.ROUNTINE.getValue().equals(from)){ + siteUrl = siteUrl+"/bargain/"; + QrCodeUtil.generate(siteUrl+"?bargainId="+bargainId+"&uid="+uid+"&partake="+uid+"&pageType=dargain&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180, + FileUtil.file(fileDir+name)); + } + else if(AppFromEnum.APP.getValue().equals(from)){ + siteUrl = siteUrl+"/bargain/"; + QrCodeUtil.generate(siteUrl+"?bargainId="+bargainId+"&uid="+uid+"&partake="+uid+"&pageType=dargain&codeType="+AppFromEnum.APP.getValue(), 180, 180, + FileUtil.file(fileDir+name)); + }else if(AppFromEnum.H5.getValue().equals(from)){ + QrCodeUtil.generate(siteUrl+"/activity/dargain_detail/"+bargainId+"/"+uid+"?spread="+uid, 180, 180, + FileUtil.file(fileDir+name)); + }else { + String uniUrl = systemConfigService.getData(SystemConfigConstants.UNI_SITE_URL); + siteUrl = StrUtil.isNotBlank(uniUrl) ? uniUrl : ShopConstants.DEFAULT_UNI_H5_URL; + QrCodeUtil.generate(siteUrl+"/pages/activity/DargainDetails/index?id="+bargainId+"&uid="+uid+"&partake="+uid, 180, 180, + FileUtil.file(fileDir+name)); + } + systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)), + fileDir+name,"qrcode/"+name); + qrcodeUrl = fileDir+name; + }else{ + qrcodeUrl = attachment.getAttDir(); + } + + String spreadPicName = bargainId+"_"+uid + "_"+from+"_bargain_user_spread.jpg"; + String spreadPicPath = fileDir+spreadPicName; + + YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); + //删除已经存在的砍价海报图片 + if (ObjectUtil.isNotNull(attachmentT)) { + storeBargainService.deleteBargainImg(spreadPicName); + } + String spreadUrl = ""; + File newFile = new File("poster.jpg"); + File newFileT = new File("simsunb.ttf"); + try { + if(!newFile.exists()){ + InputStream stream = getClass().getClassLoader().getResourceAsStream("poster.jpg"); + FileUtils.copyInputStreamToFile(stream, newFile); + } + if(!newFileT.exists()){ + InputStream streamT = getClass().getClassLoader() + .getResourceAsStream("simsunb.ttf"); + FileUtils.copyInputStreamToFile(streamT, newFileT); + } + } catch (IOException e) { + log.error(e.getMessage()); + throw new YshopException(e.getMessage()); + } + if(ObjectUtil.isNull(attachmentT)){ + try { + + //第一步标题 + Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT); + Font f= font.deriveFont(Font.PLAIN,30); + //font. + ImgUtil.pressText(// + newFile, + FileUtil.file(spreadPicPath), + storeBargainQueryVo.getTitle(), + Color.BLACK, + f, //字体 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -480, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + Font f2= font.deriveFont(Font.PLAIN,45); + //第2步价格 + ImgUtil.pressText(// + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + NumberUtil.sub(storeBargainQueryVo.getPrice(), + storeBargainUser.getPrice()).toString(), + Color.RED, + f2, //字体 + -160, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -380, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + Font f3= font.deriveFont(Font.PLAIN,30); + + ImgUtil.pressText(// + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + "已砍至", + Color.WHITE, + f3, //字体 + 90, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -385, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + //第4步介绍 + String pro = "还差还差" + surplusPrice + "即可砍价成功"; + ImgUtil.pressText(// + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + pro, + Color.BLACK, + f3, //字体 + -50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + //第5步商品图片 + //下载图片 + String image = storeBargainQueryVo.getImage(); + String ext = image.substring(image.lastIndexOf(".")); + String picImage = fileDir + "bargain_product_" + bargainId + ext; + if(!new File(picImage).exists()){ + //下载商品图 + HttpUtil.downloadFile(image, FileUtil.file(picImage)); + //只缩放一次防止图片持续缩放导致图片没了 + ImgUtil.scale( + FileUtil.file(picImage), + FileUtil.file(picImage), + 0.4f//缩放比例 + ); + } + + ImgUtil.pressImage( + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + ImgUtil.read(FileUtil.file(picImage)), //水印图片 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -80, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.7f + ); + + ImgUtil.pressImage( + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 390, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f + ); + + systemAttachmentService.attachmentAdd(spreadPicName, + String.valueOf(FileUtil.size(new File(spreadPicPath))), + spreadPicPath,"qrcode/"+spreadPicName); + + spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName; + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getMessage()); + throw new YshopException("生成失败"); + } + }else{ + spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir(); + } + + return spreadUrl; + } + + + /** + * 获取拼团海报 + * @param pinkId 拼团id + * @param userInfo 用户 + * @param siteUrl h5地址 + * @param apiUrl api地址 + * @param path 本地图片路径 + * @return url + */ + public String getPinkPosterUrl(Long pinkId, YxUser userInfo,String siteUrl, + String apiUrl,String path,String from){ + Long uid = userInfo.getUid(); + YxStorePink storePink = storePinkService.getById(pinkId); + if(ObjectUtil.isNull(storePink)) { + throw new YshopException("拼团不存在"); + } + YxStoreCombination storeCombination = storeCombinationService.getById(storePink.getCid()); + if(ObjectUtil.isNull(storeCombination)) { + throw new YshopException("拼团产品不存在"); + } + + + String name = pinkId+"_"+uid + "_"+from+"_pink_share_wap.jpg"; + YxSystemAttachment attachment = systemAttachmentService.getInfo(name); + String fileDir = path+"qrcode"+ File.separator; + String qrcodeUrl = ""; + if(ObjectUtil.isNull(attachment)){ + //生成二维码 + File file = FileUtil.mkdir(new File(fileDir)); + if(AppFromEnum.ROUNTINE.getValue().equals(from)){ + siteUrl = siteUrl+"/pink/"; + QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid+"&pageType=group&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180, + FileUtil.file(fileDir+name)); + } + else if(AppFromEnum.APP.getValue().equals(from)){ + siteUrl = siteUrl+"/pink/"; + QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid+"&pageType=group&codeType="+AppFromEnum.ROUNTINE.getValue(), 180, 180, + FileUtil.file(fileDir+name)); + } + else if(AppFromEnum.H5.getValue().equals(from)){ + QrCodeUtil.generate(siteUrl+"/activity/group_rule/"+pinkId+"?spread="+uid, 180, 180, + FileUtil.file(fileDir+name)); + }else { + String uniUrl = systemConfigService.getData(SystemConfigConstants.UNI_SITE_URL); + siteUrl = StrUtil.isNotBlank(uniUrl) ? uniUrl : ShopConstants.DEFAULT_UNI_H5_URL; + QrCodeUtil.generate(siteUrl+"/pages/activity/GroupRule/index?id="+pinkId+"&spread="+uid, 180, 180, + FileUtil.file(fileDir+name)); + } + + + systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)), + fileDir+name,"qrcode/"+name); + + qrcodeUrl = fileDir+name; + }else{ + qrcodeUrl = attachment.getAttDir(); + } + + String spreadPicName = pinkId+"_"+uid + "_"+from+"_pink_user_spread.jpg"; + String spreadPicPath = fileDir+spreadPicName; + + YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); + String spreadUrl = ""; +// InputStream stream = getClass().getClassLoader().getResourceAsStream("poster.jpg"); +// InputStream streamT = getClass().getClassLoader() +// .getResourceAsStream("simsunb.ttf"); + File newFile = new File("poster.jpg"); + File newFileT = new File("simsunb.ttf"); + try { + if(!newFileT.exists()){ + InputStream streamT = getClass().getClassLoader() + .getResourceAsStream("simsunb.ttf"); + FileUtils.copyInputStreamToFile(streamT, newFileT); + } + if(!newFile.exists()){ + InputStream stream = getClass().getClassLoader().getResourceAsStream("poster.jpg"); + FileUtils.copyInputStreamToFile(stream, newFile); + } + + } catch (IOException e) { + log.error(e.getMessage()); + throw new YshopException(e.getMessage()); + } + if(ObjectUtil.isNull(attachmentT)){ + try { + + //第一步标题 + Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT); + Font f= font.deriveFont(Font.PLAIN,40); + //font. + ImgUtil.pressText(// + newFile, + FileUtil.file(spreadPicPath), + storeCombination.getTitle(), + Color.BLACK, + f, //字体 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -480, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + Font f2= font.deriveFont(Font.PLAIN,45); + //第2步价格 + ImgUtil.pressText(// + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + storePink.getTotalPrice().toString(), + Color.RED, + f2, //字体 + -160, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -350, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + Font f3= font.deriveFont(Font.PLAIN,30); + //第3步几人团 + ImgUtil.pressText(// + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + storePink.getPeople()+"人团", + Color.WHITE, + f3, //字体 + 90, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -370, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + //第4步介绍 + String pro = "原价¥"+storeCombination.getProductPrice()+" 还差" + +storePinkService.surplusPeople(storePink)+"人拼团成功"; + ImgUtil.pressText(// + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + pro, + Color.BLACK, + f3, //字体 + -50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + -300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.7f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + ); + + //第5步商品图片 + //下载图片 +// String picImage = fileDir+pinkId+"_pink_image.jpg"; +// HttpUtil.downloadFile(storeCombination.getImage(), +// FileUtil.file(picImage)); + + String image = storeCombination.getImage(); + String ext = image.substring(image.lastIndexOf(".")); + String picImage = fileDir + "pink_product_" + pinkId + ext; + if(!new File(picImage).exists()){ + //下载商品图 + HttpUtil.downloadFile(image, FileUtil.file(picImage)); + //只缩放一次防止图片持续缩放导致图片没了 + ImgUtil.scale( + FileUtil.file(picImage), + FileUtil.file(picImage), + 0.5f//缩放比例 + ); + } + + + ImgUtil.pressImage( + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + ImgUtil.read(FileUtil.file(picImage)), //水印图片 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f + ); + + ImgUtil.pressImage( + FileUtil.file(spreadPicPath), + FileUtil.file(spreadPicPath), + ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片 + 0, //x坐标修正值。 默认在中间,偏移量相对于中间偏移 + 390, //y坐标修正值。 默认在中间,偏移量相对于中间偏移 + 0.8f + ); + + systemAttachmentService.attachmentAdd(spreadPicName, + String.valueOf(FileUtil.size(new File(spreadPicPath))), + spreadPicPath,"qrcode/"+spreadPicName); + + spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName; + + } catch (Exception e) { + log.error(e.getMessage()); + throw new YshopException(e.getMessage()); + } + }else{ + spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir(); + } + + return spreadUrl; + } + + + /** + * 普通组合海报 + * @param productDTO 商品 + * @param shareCode 二维码 + * @param spreadPicName 海报图片名称 + * @param spreadPicPath 路径 + * @param apiUrl api地址 + * @return String + * @throws IOException + * @throws FontFormatException + */ + public String creatProductPic(YxStoreProduct productDTO, String shareCode, String spreadPicName, String spreadPicPath, String apiUrl) throws IOException, FontFormatException { + YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); + String spreadUrl = ""; + if(ObjectUtil.isNull(attachmentT)){ + //创建图片 + BufferedImage img = new BufferedImage(750, 1334, BufferedImage.TYPE_INT_RGB); + //开启画图 + Graphics g = img.getGraphics(); + //背景 -- 读取互联网图片 + InputStream stream = getClass().getClassLoader().getResourceAsStream("background.png"); + ImageInputStream background = ImageIO.createImageInputStream(stream); + BufferedImage back = ImageIO.read(background); + + g.drawImage(back.getScaledInstance(750, 1334, Image.SCALE_DEFAULT), 0, 0, null); // 绘制缩小后的图 + //商品 banner图 + //读取互联网图片 + BufferedImage priductUrl = null; + try { + priductUrl = ImageIO.read(new URL(transformStyle(productDTO.getImage()))); + } catch (IOException e) { + e.printStackTrace(); + } + g.drawImage(priductUrl.getScaledInstance(750,590,Image.SCALE_DEFAULT),0,0,null); + + File newFileT = new File("simsunb.ttf"); + if(!newFileT.exists()){ + InputStream streamT = getClass().getClassLoader() + .getResourceAsStream("simsunb.ttf"); + FileUtils.copyInputStreamToFile(streamT, newFileT); + } + Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT); + //文案标题 + g.setFont(font.deriveFont(Font.BOLD,34)); + g.setColor(new Color(29,29,29)); + int fontlenb = getWatermarkLength(productDTO.getStoreName(), g); + //文字长度相对于图片宽度应该有多少行 + int lineb = fontlenb / (back.getWidth() +200); + //高度 + int yb = back.getHeight() - (lineb + 1) * 30 + 100; + //文字叠加,自动换行叠加 + int tempXb = 32; + int tempYb = yb; + //单字符长度 + int tempCharLenb = 0; + //单行字符总长度临时计算 + int tempLineLenb = 0; + StringBuffer sbb =new StringBuffer(); + for(int i=0; i < productDTO.getStoreName().length(); i++) { + char tempChar = productDTO.getStoreName().charAt(i); + tempCharLenb = getCharLen(tempChar, g); + tempLineLenb += tempCharLenb; + if(tempLineLenb >= (back.getWidth()+220)) { + //长度已经满一行,进行文字叠加 + g.drawString(sbb.toString(), tempXb, tempYb + 50); + //清空内容,重新追加 + sbb.delete(0, sbb.length()); + //每行文字间距50 + tempYb += 50; + tempLineLenb =0; + } + //追加字符 + sbb.append(tempChar); + } + g.drawString(sbb.toString(), tempXb, tempYb + 50); + + //------------------------------------------------文案----------------------- + //文案 + g.setFont(font.deriveFont(Font.PLAIN,30)); + g.setColor(new Color(47,47,47)); + int fontlen = getWatermarkLength(productDTO.getStoreInfo(), g); + //文字长度相对于图片宽度应该有多少行 + int line = fontlen / (back.getWidth() - 90); + //高度 + int y = tempYb + 50 - (line + 1) * 30 + 100; + //文字叠加,自动换行叠加 + int tempX = 32; + int tempY = y; + //单字符长度 + int tempCharLen = 0; + //单行字符总长度临时计算 + int tempLineLen = 0; + StringBuffer sb =new StringBuffer(); + + for(int i=0; i < productDTO.getStoreInfo().length(); i++) { + char tempChar = productDTO.getStoreInfo().charAt(i); + tempCharLen = getCharLen(tempChar, g); + tempLineLen += tempCharLen; + if(tempLineLen >= (back.getWidth()-90)) { + //长度已经满一行,进行文字叠加 + g.drawString(sb.toString(), tempX, tempY + 50); + //清空内容,重新追加 + sb.delete(0, sb.length()); + //每行文字间距50 + tempY += 50; + tempLineLen =0; + } + //追加字符 + sb.append(tempChar); + } + //最后叠加余下的文字 + g.drawString(sb.toString(), tempX, tempY + 50); + + //价格背景 + //读取互联网图片 + BufferedImage bground = null; + InputStream redStream = getClass().getClassLoader().getResourceAsStream("red.jpg"); + try { + ImageInputStream red = ImageIO.createImageInputStream(redStream); + bground = ImageIO.read(red); + } catch (IOException e) { + e.printStackTrace(); + } + // 绘制缩小后的图 + g.drawImage(bground.getScaledInstance(160, 40, Image.SCALE_DEFAULT), 30, 1053, null); + + //限时促销价 + g.setFont(font.deriveFont(Font.PLAIN,24)); + g.setColor(new Color(255,255,255)); + g.drawString("限时促销价", 50, 1080); + + //价格 + g.setFont(font.deriveFont(Font.PLAIN,50)); + g.setColor(new Color(249,64,64)); + g.drawString("¥" +productDTO.getPrice(), 29, 1162); + + //原价 + g.setFont(font.deriveFont(Font.PLAIN,36)); + g.setColor(new Color(171,171,171)); + String price = "¥" + productDTO.getOtPrice(); + g.drawString(price, 260, 1160); + g.drawLine(250,1148,260+150,1148); + +// //商品名称 +// g.setFont(font.deriveFont(Font.PLAIN,32)); +// g.setColor(new Color(29,29,29)); +// g.drawString(productDTO.getStoreName(), 30, 1229); + + //生成二维码返回链接 + String url = shareCode; + //读取互联网图片 + BufferedImage qrCode = null; + try { + qrCode = ImageIO.read(new URL(url)); + } catch (IOException e) { + e.printStackTrace(); + } + // 绘制缩小后的图 + g.drawImage(qrCode.getScaledInstance(174, 174, Image.SCALE_DEFAULT), 536, 1057, null); + + //二维码字体 + g.setFont(font.deriveFont(Font.PLAIN,25)); + g.setColor(new Color(171,171,171)); + //绘制文字 + g.drawString("扫描或长按小程序码", 515, 1260); + + g.dispose(); + //先将画好的海报写到本地 + File file = new File(spreadPicPath); + try { + ImageIO.write(img, "jpg",file); + } catch (IOException e) { + e.printStackTrace(); + } + systemAttachmentService.attachmentAdd(spreadPicName, + String.valueOf(FileUtil.size(new File(spreadPicPath))), + spreadPicPath,"qrcode/"+spreadPicName); + spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName; + //保存到本地 生成文件名字 + }else { + spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir(); + } + + return spreadUrl; + } + + + /** + * 获取水印文字总长度 + *@paramwaterMarkContent水印的文字 + *@paramg + *@return水印文字总长度 + */ + public static int getWatermarkLength(String waterMarkContent, Graphics g) { + return g.getFontMetrics(g.getFont()).charsWidth(waterMarkContent.toCharArray(),0, waterMarkContent.length()); + } + public static int getCharLen(char c, Graphics g) { + return g.getFontMetrics(g.getFont()).charWidth(c); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java new file mode 100644 index 00000000..a0e52440 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java @@ -0,0 +1,268 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.services; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.enums.AppFromEnum; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.OrderLogEnum; +import co.yixiang.enums.PayTypeEnum; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.app.modules.order.dto.OrderExtendDto; +import co.yixiang.app.modules.order.param.ComputeOrderParam; +import co.yixiang.modules.order.service.YxStoreOrderCartInfoService; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.dto.ProductAttrDto; +import co.yixiang.modules.order.service.dto.ProductDto; +import co.yixiang.modules.order.vo.OrderCartInfoVo; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.mp.service.WeixinPayService; +import com.alibaba.fastjson.JSONObject; +import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayNativeOrderResult; +import com.google.common.collect.Maps; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * @ClassName 订单提供者服务 + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/22 + **/ +@Slf4j +@Service +@AllArgsConstructor +public class OrderSupplyService { + + private final YxStoreOrderService storeOrderService; + private final YxStoreBargainUserService storeBargainUserService; + private final YxStorePinkService storePinkService; + private final YxStoreOrderCartInfoService orderCartInfoService; + private final WeixinPayService weixinPayService; + + + /** + * 返回订单产品信息 + * @param unique 订单唯一值 + * @return OrderCartInfoVo + */ + public OrderCartInfoVo getProductOrder(String unique){ + YxStoreOrderCartInfo orderCartInfo = orderCartInfoService.findByUni(unique); + + YxStoreCartQueryVo cartInfo = JSONObject.parseObject(orderCartInfo.getCartInfo(), + YxStoreCartQueryVo.class); + + ProductDto productDTO = new ProductDto(); + productDTO.setImage(cartInfo.getProductInfo().getImage()); + productDTO.setPrice(cartInfo.getProductInfo().getPrice().doubleValue()); + productDTO.setStoreName(cartInfo.getProductInfo().getStoreName()); + if(ObjectUtil.isNotEmpty(cartInfo.getProductInfo().getAttrInfo())){ + ProductAttrDto productAttrDTO = new ProductAttrDto(); + productAttrDTO.setImage(cartInfo.getProductInfo().getAttrInfo().getImage()); + productAttrDTO.setPrice(cartInfo.getProductInfo().getAttrInfo().getPrice().doubleValue()); + productAttrDTO.setProductId(cartInfo.getProductInfo().getAttrInfo().getProductId()); + productAttrDTO.setSku(cartInfo.getProductInfo().getAttrInfo().getSku()); + productDTO.setAttrInfo(productAttrDTO); + } + + + return OrderCartInfoVo.builder() + .bargainId(cartInfo.getBargainId()) + .cartNum(cartInfo.getCartNum()) + .combinationId(cartInfo.getCombinationId()) + .orderId(storeOrderService.getById(orderCartInfo.getOid()).getOrderId()) + .seckillId(cartInfo.getSeckillId()) + .productInfo(productDTO) + .build(); + } + + /** + * 订单检测 + * @param uid uid + * @param key 缓存值 + * @param param ComputeOrderParam + * @return map + */ + public Map check(Long uid,String key, ComputeOrderParam param){ + Map map = Maps.newHashMap(); + if(StrUtil.isBlank(key)) { + throw new YshopException("参数错误"); + } + YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,uid); + if(ObjectUtil.isNotNull(storeOrder)){ + + OrderExtendDto orderExtendDTO = OrderExtendDto.builder() + .key(key) + .orderId(storeOrder.getOrderId()) + .build(); + map.put("status", OrderLogEnum.EXTEND_ORDER.getValue()); + map.put("result", orderExtendDTO); + map.put("msg",OrderLogEnum.EXTEND_ORDER.getDesc()); + } + + // 砍价 + if(StrUtil.isNotBlank(param.getBargainId()) && NumberUtil.isNumber(param.getBargainId())){ + Long bargainId = Long.valueOf(param.getBargainId()); + if(bargainId > 0){ + YxStoreBargainUser storeBargainUser = storeBargainUserService + .getBargainUserInfo(bargainId,uid); + if(storeBargainUser == null) { + throw new YshopException("砍价失败"); + } + if(OrderInfoEnum.BARGAIN_STATUS_3.getValue().equals(storeBargainUser.getStatus())) { + throw new YshopException("砍价已支付"); + } + } + + } + // 拼团 + if(StrUtil.isNotBlank(param.getPinkId()) && NumberUtil.isNumber(param.getPinkId())){ + Long pinkId = Long.valueOf(param.getPinkId()); + if(pinkId > 0){ + YxStoreOrder yxStoreOrder = storeOrderService.getOrderPink(pinkId,uid); + if(yxStoreOrder != null){ + map.put("status",OrderLogEnum.PINK_ORDER_FAIL_1.getValue()); + OrderExtendDto orderExtendDTO = new OrderExtendDto(); + orderExtendDTO.setOrderId(yxStoreOrder.getOrderId()); + map.put("result",orderExtendDTO); + map.put("msg",OrderLogEnum.PINK_ORDER_FAIL_1.getDesc()); + } + if(yxStoreOrder != null && storePinkService.getIsPinkUid(pinkId,uid)){ + map.put("status",OrderLogEnum.PINK_ORDER_FAIL_2.getValue()); + OrderExtendDto orderExtendDTO = new OrderExtendDto(); + orderExtendDTO.setOrderId(yxStoreOrder.getOrderId()); + map.put("result",orderExtendDTO); + map.put("msg",OrderLogEnum.PINK_ORDER_FAIL_2.getDesc()); + } + } + + } + + + return map; + } + + /** + * 支付 + * @param map map + * @param orderId 订单号 + * @param uid uid + * @param payType 支付方式 + * @param from 来源 + * @param orderDTO orderDTO + * @return map + */ + public Map goPay(Map map, String orderId, Long uid, String payType, + String from, OrderExtendDto orderDTO){ + switch (PayTypeEnum.toType(payType)){ + case WEIXIN: + Map jsConfig = new HashMap<>(); + if(AppFromEnum.WEIXIN_H5.getValue().equals(from)){ + WxPayMwebOrderResult wxPayMwebOrderResult = (WxPayMwebOrderResult)weixinPayService + .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"H5商品购买"); + + log.info("wxPayMwebOrderResult:{}",wxPayMwebOrderResult); + jsConfig.put("mweb_url",wxPayMwebOrderResult.getMwebUrl()); + orderDTO.setJsConfig(jsConfig); + map.put("result",orderDTO); + map.put("status","WECHAT_H5_PAY"); + map.put("payMsg","订单创建成功"); + return map; + } else if(AppFromEnum.ROUNTINE.getValue().equals(from)){ + map.put("status","WECHAT_PAY"); + WxPayMpOrderResult wxPayMpOrderResult = (WxPayMpOrderResult)weixinPayService + .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"小程序商品购买"); + jsConfig.put("appId",wxPayMpOrderResult.getAppId()); + jsConfig.put("timeStamp",wxPayMpOrderResult.getTimeStamp()); + jsConfig.put("paySign",wxPayMpOrderResult.getPaySign()); + jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr()); + jsConfig.put("package",wxPayMpOrderResult.getPackageValue()); + jsConfig.put("signType",wxPayMpOrderResult.getSignType()); + orderDTO.setJsConfig(jsConfig); + map.put("payMsg","订单创建成功"); + map.put("result",orderDTO); + return map; + }else if(AppFromEnum.APP.getValue().equals(from)){//app支付 + map.put("status","WECHAT_APP_PAY"); + WxPayAppOrderResult wxPayAppOrderResult = (WxPayAppOrderResult)weixinPayService + .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"APP商品购买"); + jsConfig.put("appid",wxPayAppOrderResult.getAppId()); + jsConfig.put("partnerid",wxPayAppOrderResult.getPartnerId()); + jsConfig.put("prepayid",wxPayAppOrderResult.getPrepayId()); + jsConfig.put("package",wxPayAppOrderResult.getPackageValue()); + jsConfig.put("noncestr",wxPayAppOrderResult.getNonceStr()); + jsConfig.put("timestamp",wxPayAppOrderResult.getTimeStamp()); + jsConfig.put("sign",wxPayAppOrderResult.getSign()); + orderDTO.setJsConfig(jsConfig); + map.put("result",orderDTO); + map.put("payMsg","订单创建成功"); + return map; + }else if(AppFromEnum.PC.getValue().equals(from)){ //扫码支付 + map.put("status","WECHAT_PC_PAY"); + WxPayNativeOrderResult wxPayNativeOrderResult = (WxPayNativeOrderResult)weixinPayService + .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"pc商品购买"); + jsConfig.put("codeUrl",wxPayNativeOrderResult.getCodeUrl()); + orderDTO.setJsConfig(jsConfig); + map.put("result",orderDTO); + map.put("payMsg","订单创建成功"); + return map; + } + else{//公众号 + map.put("status","WECHAT_PAY"); + WxPayMpOrderResult wxPayMpOrderResult = (WxPayMpOrderResult)weixinPayService + .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"公众号商品购买"); + + log.info("WxPayMpOrderResult:{}",wxPayMpOrderResult); + + jsConfig.put("appId",wxPayMpOrderResult.getAppId()); + jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp()); + jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr()); + jsConfig.put("package",wxPayMpOrderResult.getPackageValue()); + jsConfig.put("signType",wxPayMpOrderResult.getSignType()); + jsConfig.put("paySign",wxPayMpOrderResult.getPaySign()); + orderDTO.setJsConfig(jsConfig); + map.put("result",orderDTO); + map.put("payMsg","订单创建成功"); + + return map; + } + case YUE: + storeOrderService.yuePay(orderId,uid); + map.put("payMsg","余额支付成功"); + return map; + case INTEGRAL: + storeOrderService.integralPay(orderId,uid); + map.put("payMsg","积分兑换成功"); + return map; + default: + } + + map.put("payMsg","订单生成失败"); + return map; + } + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxArticleQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxArticleQueryParam.java new file mode 100644 index 00000000..0b1b7b53 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxArticleQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.shop.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 文章管理表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxArticleQueryParam对象", description="文章管理表查询参数") +public class YxArticleQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemConfigQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemConfigQueryParam.java new file mode 100644 index 00000000..44cade73 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemConfigQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.shop.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 配置表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-19 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxSystemConfigQueryParam对象", description="配置表查询参数") +public class YxSystemConfigQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemGroupDataQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemGroupDataQueryParam.java new file mode 100644 index 00000000..cb647630 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemGroupDataQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.shop.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 组合数据详情表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-19 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxSystemGroupDataQueryParam对象", description="组合数据详情表查询参数") +public class YxSystemGroupDataQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemStoreQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemStoreQueryParam.java new file mode 100644 index 00000000..9ebe6875 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemStoreQueryParam.java @@ -0,0 +1,28 @@ +package co.yixiang.app.modules.shop.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +/** + *

+ * 门店自提 查询参数对象 + *

+ * + * @author hupeng + * @date 2020-03-04 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="门店自提", description="门店自提查询参数") +public class YxSystemStoreQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "纬度") + private String latitude; + + @ApiModelProperty(value = "经度") + private String longitude; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemStoreStaffQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemStoreStaffQueryParam.java new file mode 100644 index 00000000..7f6d6e85 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/param/YxSystemStoreStaffQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.shop.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 门店店员表 查询参数对象 + *

+ * + * @author hupeng + * @date 2020-03-23 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxSystemStoreStaffQueryParam对象", description="门店店员表查询参数") +public class YxSystemStoreStaffQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/ArticleController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/ArticleController.java new file mode 100644 index 00000000..7d514352 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/ArticleController.java @@ -0,0 +1,68 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.shop.rest; + +import co.yixiang.api.ApiResult; +import co.yixiang.modules.mp.service.YxArticleService; +import co.yixiang.modules.mp.vo.YxArticleQueryVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Collections; +import java.util.List; + +/** + *

+ * 文章 前端控制器 + *

+ * + * @author hupeng + * @since 2019-10-02 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@RequestMapping("/article") +@Api(value = "文章模块", tags = "商城:文章模块") +public class ArticleController { + + private final YxArticleService articleService; + + + /** + * 获取文章文章详情 + */ + @GetMapping("/details/{id}") + @ApiOperation(value = "文章详情",notes = "文章详情") + public ApiResult getYxArticle(@PathVariable Integer id){ + YxArticleQueryVo yxArticleQueryVo = articleService.getDetail(id); + articleService.incVisitNum(id); + return ApiResult.ok(yxArticleQueryVo); + } + + /** + * 文章列表 + */ + @GetMapping("/list") + @ApiOperation(value = "文章列表",notes = "文章列表") + public ApiResult> getYxArticlePageList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + return ApiResult.resultPage(articleService.getList(page,limit),limit); + } + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/IndexController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/IndexController.java new file mode 100644 index 00000000..89c04226 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/IndexController.java @@ -0,0 +1,175 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.shop.rest; + +import cn.hutool.core.io.file.FileReader; +import cn.hutool.core.io.resource.ClassPathResource; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.ProductEnum; +import co.yixiang.modules.activity.service.YxStoreCombinationService; +import co.yixiang.modules.activity.service.YxStoreSeckillService; +import co.yixiang.modules.canvas.domain.StoreCanvas; +import co.yixiang.modules.canvas.service.StoreCanvasService; +import co.yixiang.modules.mp.service.YxWechatLiveService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; +import co.yixiang.modules.shop.domain.YxAppVersion; +import co.yixiang.app.modules.shop.param.YxSystemStoreQueryParam; +import co.yixiang.modules.shop.service.YxAppVersionService; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.shop.vo.AppCheckVersion; +import co.yixiang.app.modules.shop.vo.IndexVo; +import co.yixiang.modules.shop.vo.YxAppVersionVo; +import co.yixiang.utils.FileUtil; + +import co.yixiang.utils.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName IndexController + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/19 + **/ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "首页模块", tags = "商城:首页模块") +public class IndexController { + private final YxAppVersionService appVersionService; + private final YxSystemGroupDataService systemGroupDataService; + private final YxStoreProductService storeProductService; + private final YxSystemStoreService systemStoreService; + private final YxStoreCombinationService storeCombinationService; + private final YxStoreSeckillService storeSeckillService; + private final YxWechatLiveService wechatLiveService; + private final RedisUtils redisUtils; + + private final StoreCanvasService storeCanvasService; + + @GetMapping("/getCanvas") + @ApiOperation(value = "读取画布数据") + public ResponseEntity getCanvas(StoreCanvas storeCanvas){ + StoreCanvas canvas = storeCanvasService.getOne(new LambdaQueryWrapper() + .eq(StoreCanvas::getTerminal, storeCanvas.getTerminal()) + .orderByDesc(StoreCanvas::getCanvasId).last("limit 1")); + return new ResponseEntity<>(canvas, HttpStatus.OK); + } + + @Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY) + @GetMapping("/index") + @ApiOperation(value = "首页数据",notes = "首页数据") + public ApiResult index(){ + IndexVo indexVo = IndexVo.builder() + .banner(systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_BANNER)) + .bastList(storeProductService.getList(1,6, ProductEnum.TYPE_1.getValue())) + .benefit(storeProductService.getList(1,100,ProductEnum.TYPE_4.getValue())) + .combinationList(storeCombinationService.getList(1,8).getStoreCombinationQueryVos()) + .firstList(storeProductService.getList(1,6,ProductEnum.TYPE_3.getValue())) + .likeInfo(storeProductService.getList(1,80,ProductEnum.TYPE_2.getValue())) + .mapKey(redisUtils.get(ShopKeyUtils.getTengXunMapKey()).toString()) + .menus(systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_MENUS)) + .roll(systemGroupDataService.getDatas(ShopConstants.YSHOP_HOME_ROLL_NEWS)) + .seckillList(storeSeckillService.getList(1, 4)) + .liveList(wechatLiveService.getList(1,4,0)) + .build(); + return ApiResult.ok(indexVo); + } + + @GetMapping("/search/keyword") + @ApiOperation(value = "热门搜索关键字获取",notes = "热门搜索关键字获取") + public ApiResult> search(){ + List list = systemGroupDataService.getDatas(ShopConstants.YSHOP_HOT_SEARCH); + List stringList = new ArrayList<>(); + for (JSONObject object : list) { + stringList.add(object.getString("title")); + } + return ApiResult.ok(stringList); + } + + + @PostMapping("/image_base64") + @ApiOperation(value = "获取图片base64",notes = "获取图片base64") + @Deprecated + public ApiResult> imageBase64(){ + return ApiResult.ok(null); + } + + + @GetMapping("/citys") + @ApiOperation(value = "获取城市json",notes = "获取城市json") + public ApiResult cityJson(){ + String path = "city.json"; + String name = "city.json"; + try { + File file = FileUtil.inputStreamToFile(new ClassPathResource(path).getStream(), name); + FileReader fileReader = new FileReader(file,"UTF-8"); + String string = fileReader.readString(); + JSONObject jsonObject = JSON.parseObject(string); + return ApiResult.ok(jsonObject); + } catch (Exception e) { + log.error(e.getMessage()); + throw new YshopException("无数据"); + } + + } + + + @GetMapping("/store_list") + @ApiOperation(value = "获取门店列表",notes = "获取门店列表") + public ApiResult> storeList( YxSystemStoreQueryParam param){ + Map map = new LinkedHashMap<>(); + List lists = systemStoreService.getStoreList( + param.getLatitude(), + param.getLongitude(), + param.getPage(),param.getLimit()); + map.put("list",lists); + return ApiResult.ok(map); + } + + + @GetMapping("/version") + @ApiOperation(value = "获取app版本信息",notes = "获取app版本信息") + public ApiResult storeList(AppCheckVersion param){ + YxAppVersion appVersion= appVersionService.lambdaQuery().orderByDesc(YxAppVersion::getCreateTime).one(); + YxAppVersionVo appVersionVo=new YxAppVersionVo(); + appVersionVo.setVersionCode(appVersion.getVersionCode()); + appVersionVo.setVersionInfo(appVersion.getVersionInfo()); + appVersionVo.setVersionName(appVersion.getVersionName()); + appVersionVo.setDownloadUrl("1101".equals(param.getType())?appVersion.getAndroidUrl():appVersion.getIosUrl()); + appVersionVo.setForceUpdate(appVersion.getForceUpdate()==0); + if (!param.getVersionName().equals(appVersion.getVersionName())){ + return ApiResult.ok(appVersionVo); + } + return ApiResult.ok(new YxAppVersionVo()); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/vo/IndexVo.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/vo/IndexVo.java new file mode 100644 index 00000000..23931ea7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/vo/IndexVo.java @@ -0,0 +1,57 @@ +package co.yixiang.app.modules.shop.vo; + +import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo; +import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo; +import co.yixiang.modules.mp.service.dto.YxWechatLiveDto; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ApiModel("首页数据") +public class IndexVo { + + @ApiModelProperty("banner") + private List banner; + //首页按钮 + @ApiModelProperty("首页按钮") + private List menus; + //精品推荐->拼团 + @ApiModelProperty("精品推荐") + private List bastList; + //首发新品->秒杀 + @ApiModelProperty("首发新品") + private List firstList; + //猜你喜欢 + @ApiModelProperty("猜你喜欢") + private List benefit; + //热门榜单 + @ApiModelProperty("热门榜单") + private List likeInfo; + //滚动 + @ApiModelProperty("滚动") + private List roll; + //地图key + @ApiModelProperty("地图key") + private String mapKey; + //精品推荐->拼团 + @ApiModelProperty("精品推荐->拼团") + private List combinationList; + //首发新品->秒杀 + @ApiModelProperty("首发新品->秒杀") + private List seckillList; + //直播间信息 + @ApiModelProperty("直播间") + private List liveList; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/test/LimitController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/test/LimitController.java new file mode 100644 index 00000000..709c5bd2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/test/LimitController.java @@ -0,0 +1,34 @@ +package co.yixiang.app.modules.test; + +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.annotation.Limit; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @author / + * 接口限流测试类 + */ +@RestController +@RequestMapping("/test") +@Api(tags = "系统:限流测试管理") +public class LimitController { + + private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger(); + + /** + * 测试限流注解,下面配置说明该接口 60秒内最多只能访问 10次,保存到redis的键名为 limit_test, + */ + @GetMapping("/limit") + @AnonymousAccess + @ApiOperation("测试") + @Limit(key = "test", period = 60, count = 10, name = "testLimit", prefix = "limit") + public int testLimit() { + return ATOMIC_INTEGER.incrementAndGet(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/TaskFinishDTO.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/TaskFinishDTO.java new file mode 100644 index 00000000..c69c82c8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/TaskFinishDTO.java @@ -0,0 +1,19 @@ +package co.yixiang.app.modules.user.dto; + + +import lombok.Data; + +import java.io.Serializable; + + +/** + * @ClassName TaskFinishDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/6 + **/ +@Data +public class TaskFinishDTO implements Serializable { + private String addTime; + private String title; + private Integer number; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/UserBillDTO.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/UserBillDTO.java new file mode 100644 index 00000000..1cfe898d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/UserBillDTO.java @@ -0,0 +1,16 @@ +package co.yixiang.app.modules.user.dto; + +import lombok.Data; + +/** + * @ClassName UserBillDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class UserBillDTO { + private String addTime; + private String title; + private Double number; + private Integer pm; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/UserRankDTO.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/UserRankDTO.java new file mode 100644 index 00000000..b30b4321 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/dto/UserRankDTO.java @@ -0,0 +1,16 @@ +package co.yixiang.app.modules.user.dto; + +import lombok.Data; + +/** + * @ClassName UserRankDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/13 + **/ +@Data +public class UserRankDTO { + private Integer uid; + private Integer count; + private String nickname; + private String avatar; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/PromParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/PromParam.java new file mode 100644 index 00000000..82e72c3d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/PromParam.java @@ -0,0 +1,30 @@ +package co.yixiang.app.modules.user.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName PromParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class PromParam implements Serializable { + + @ApiModelProperty(value = "推荐人级别 0一级推荐人 1二级推荐人") + private Integer grade; + + @ApiModelProperty(value = "关键字搜索") + private String keyword; + + @ApiModelProperty(value = "页码") + private Integer limit; + + @ApiModelProperty(value = "页大小") + private Integer page; + + @ApiModelProperty(value = "排序") + private String sort; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/RechargeParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/RechargeParam.java new file mode 100644 index 00000000..11c6b44f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/RechargeParam.java @@ -0,0 +1,37 @@ +package co.yixiang.app.modules.user.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName RechargeParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/8 + **/ +@Data +public class RechargeParam implements Serializable { + + @NotBlank(message = "充值参数有误") + @JsonProperty(value = "rechar_id") + @ApiModelProperty(value = "用户充值ID") + private String recharId; + + @ApiModelProperty(value = "来源") + private String from; + + //@NotNull(message = "金额必填") + // @Min(value = 1,message = "充值金额不能低于1") + @ApiModelProperty(value = "充值金额") + private Double price; + + @JsonProperty(value = "paid_price") + @ApiModelProperty(value = "赠送金额") + private Double paidPrice; + + @ApiModelProperty(value = "充值单号") + private String orderSn; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/UserEditParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/UserEditParam.java new file mode 100644 index 00000000..674b38f5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/UserEditParam.java @@ -0,0 +1,28 @@ +package co.yixiang.app.modules.user.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * @ClassName UserEditParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/02/07 + **/ +@Data +public class UserEditParam implements Serializable { + + @NotBlank(message = "请上传头像") + @ApiModelProperty(value = "用户头像") + private String avatar; + + @NotBlank(message = "请填写昵称") + @Size(min = 1, max = 60,message = "长度超过了限制") + @ApiModelProperty(value = "用户昵称") + private String nickname; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemAttachmentQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemAttachmentQueryParam.java new file mode 100644 index 00000000..24931aee --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemAttachmentQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 附件管理表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-11-11 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxSystemAttachmentQueryParam对象", description="附件管理表查询参数") +public class YxSystemAttachmentQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemUserLevelQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemUserLevelQueryParam.java new file mode 100644 index 00000000..7ec00664 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemUserLevelQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 设置用户等级表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-06 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxSystemUserLevelQueryParam对象", description="设置用户等级表查询参数") +public class YxSystemUserLevelQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemUserTaskQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemUserTaskQueryParam.java new file mode 100644 index 00000000..9c9a4120 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxSystemUserTaskQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 等级任务设置 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-06 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxSystemUserTaskQueryParam对象", description="等级任务设置查询参数") +public class YxSystemUserTaskQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserAddressQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserAddressQueryParam.java new file mode 100644 index 00000000..9d85ca78 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserAddressQueryParam.java @@ -0,0 +1,23 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户地址表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-28 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserAddressQueryParam对象", description="用户地址表查询参数") +public class YxUserAddressQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + private Integer uid; + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserBillQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserBillQueryParam.java new file mode 100644 index 00000000..a382b655 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserBillQueryParam.java @@ -0,0 +1,22 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户账单表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserBillQueryParam对象", description="用户账单表查询参数") +public class YxUserBillQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserExtractQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserExtractQueryParam.java new file mode 100644 index 00000000..59e6470b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserExtractQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户提现表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-11-11 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserExtractQueryParam对象", description="用户提现表查询参数") +public class YxUserExtractQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserLevelQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserLevelQueryParam.java new file mode 100644 index 00000000..5d61c815 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserLevelQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户等级记录表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-06 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserLevelQueryParam对象", description="用户等级记录表查询参数") +public class YxUserLevelQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserQueryParam.java new file mode 100644 index 00000000..ce16ed2d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-16 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserQueryParam对象", description="用户表查询参数") +public class YxUserQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserRechargeQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserRechargeQueryParam.java new file mode 100644 index 00000000..398fa39f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserRechargeQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户充值表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-08 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserRechargeQueryParam对象", description="用户充值表查询参数") +public class YxUserRechargeQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserSignQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserSignQueryParam.java new file mode 100644 index 00000000..7129c133 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserSignQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 签到记录表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-05 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserSignQueryParam对象", description="签到记录表查询参数") +public class YxUserSignQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserTaskFinishQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserTaskFinishQueryParam.java new file mode 100644 index 00000000..0739d8f1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxUserTaskFinishQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户任务完成记录表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-07 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxUserTaskFinishQueryParam对象", description="用户任务完成记录表查询参数") +public class YxUserTaskFinishQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxWechatUserQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxWechatUserQueryParam.java new file mode 100644 index 00000000..f3aa36c8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/param/YxWechatUserQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.user.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 微信用户表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxWechatUserQueryParam对象", description="微信用户表查询参数") +public class YxWechatUserQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserBillController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserBillController.java new file mode 100644 index 00000000..827878d1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserBillController.java @@ -0,0 +1,208 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.user.rest; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.app.modules.services.CreatShareProductService; +import co.yixiang.app.modules.user.param.PromParam; +import co.yixiang.app.modules.user.param.YxUserBillQueryParam; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.modules.activity.service.YxUserExtractService; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.vo.YxUserBillQueryVo; +import com.google.common.collect.Maps; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.*; + +/** + * @ClassName UserBillController + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/10 + **/ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户分销", tags = "用户:用户分销") +public class AppUserBillController { + + private final YxUserBillService userBillService; + private final YxUserExtractService extractService; + private final YxSystemConfigService systemConfigService; + private final YxUserService yxUserService; + private final CreatShareProductService creatShareProductService; + + private String path = ""; + + /** + * 推广数据 昨天的佣金 累计提现金额 当前佣金 + */ + @AppLog(value = "查看推广数据", type = 1) + @AuthCheck + @GetMapping("/commission") + @ApiOperation(value = "推广数据",notes = "推广数据") + public ApiResult> commission(){ + YxUser yxUser = LocalUser.getUser(); + + //昨天的佣金 + double lastDayCount = userBillService.yesterdayCommissionSum(yxUser.getUid()); + //累计提现金额 + double extractCount = extractService.extractSum(yxUser.getUid()); + + Map map = Maps.newHashMap(); + map.put("lastDayCount",lastDayCount); + map.put("extractCount",extractCount); + map.put("commissionCount",yxUser.getBrokeragePrice()); + + return ApiResult.ok(map); + } + + /** + * 积分记录 + */ + @AppLog(value = "查看积分记录", type = 1) + @AuthCheck + @GetMapping("/integral/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "积分记录",notes = "积分记录") + public ApiResult> userInfo(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(userBillService.userBillList(uid, BillDetailEnum.CATEGORY_2.getValue() + ,page, limit)); + } + + + /** + * 分销二维码海报生成 + */ + @AppLog(value = "分销二维码海报生成", type = 1) + @AuthCheck + @GetMapping("/spread/banner") + @ApiImplicitParams({ + @ApiImplicitParam(name = "form", value = "来源", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "分销二维码海报生成",notes = "分销二维码海报生成") + public ApiResult>> spreadBanner(@RequestParam(value = "",required=false) String from){ + YxUser yxUser = LocalUser.getUser(); + String siteUrl = systemConfigService.getData(SystemConfigConstants.SITE_URL); + if(StrUtil.isEmpty(siteUrl)){ + throw new YshopException("未配置h5地址!"); + } + String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL); + if(StrUtil.isEmpty(apiUrl)){ + throw new YshopException("未配置api地址!"); + } + + String spreadUrl = creatShareProductService.getSpreadUrl(from,yxUser,siteUrl,apiUrl,path); + + List> list = new ArrayList<>(); + + Map map = Maps.newHashMap(); + map.put("id",1); + map.put("pic",""); + map.put("title","分享海报"); + map.put("wap_poster",spreadUrl); + list.add(map); + return ApiResult.ok(list); + } + + + /** + * 推广人统计 + */ + @AppLog(value = "查看推广人统计", type = 1) + @AuthCheck + @PostMapping("/spread/people") + @ApiOperation(value = "推广人统计",notes = "推广人统计") + public ApiResult> spreadPeople(@Valid @RequestBody PromParam param){ + Long uid = LocalUser.getUser().getUid(); + Map map = new LinkedHashMap<>(); + map.put("list",yxUserService.getUserSpreadGrade(uid,param.getPage(),param.getLimit() + ,param.getGrade(),param.getKeyword(),param.getSort())); + + Map countMap = yxUserService.getSpreadCount(uid); + map.put("total",countMap.get("first")); + map.put("totalLevel",countMap.get("second")); + return ApiResult.ok(map); + } + + /** + * 推广佣金明细 + * type 0 全部 1 消费 2 充值 3 返佣 4 提现 + * @return mixed + */ + @AppLog(value = "查看推广佣金明细", type = 1) + @AuthCheck + @GetMapping("/spread/commission/{type}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "type", value = "类型 0所有 1消费 2充值 3返佣 4提现 5签到积分 6退款 7系统增加 8系统减少", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "推广佣金明细",notes = "推广佣金明细") + public ApiResult spreadCommission(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit, + @PathVariable String type){ + int newType = 0; + if(NumberUtil.isNumber(type)) { + newType = Integer.valueOf(type); + } + Long uid = LocalUser.getUser().getUid(); + Map map = userBillService.getUserBillList(page,limit,uid,newType); + Long total = (Long)map.get("total"); + Long totalPage = (Long)map.get("totalPage"); + return ApiResult.resultPage(total.intValue(),totalPage.intValue(),map.get("list")); + // return ApiResult.resultPage(Collections.singletonList(userBillService.getUserBillList(page,limit,uid,newType)),limit); + } + + + /** + * 推广订单 + */ + @AppLog(value = "查看推广订单", type = 1) + @AuthCheck + @PostMapping("/spread/order") + @ApiOperation(value = "推广订单",notes = "推广订单") + public ApiResult spreadOrder(@RequestBody YxUserBillQueryParam param){ + Long uid = LocalUser.getUser().getUid(); + Map map = userBillService.spreadOrder(uid,param.getPage(),param.getLimit()); + return ApiResult.ok(map); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserExtractController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserExtractController.java new file mode 100644 index 00000000..c1ddec90 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserExtractController.java @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.user.rest; + + +import co.yixiang.api.ApiResult; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.modules.activity.param.UserExtParam; +import co.yixiang.modules.activity.service.YxUserExtractService; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.user.domain.YxUser; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + *

+ * 用户提现 前端控制器 + *

+ * + * @author hupeng + * @since 2019-11-11 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户提现", tags = "用户:用户提现") +public class AppUserExtractController { + + private final YxUserExtractService userExtractService; + private final YxSystemConfigService systemConfigService; + + /** + * 提现参数 + */ + @AuthCheck + @GetMapping("/extract/bank") + @ApiOperation(value = "提现参数",notes = "提现参数") + public ApiResult bank(){ + YxUser yxUser = LocalUser.getUser(); + Map map = new LinkedHashMap<>(); + map.put("commissionCount",yxUser.getBrokeragePrice()); + map.put("minPrice",systemConfigService.getData(SystemConfigConstants.USER_EXTRACT_MIN_PRICE)); + return ApiResult.ok(map); + } + + + /** + * 用户提现 + */ + @AppLog(value = "用户提现", type = 1) + @AuthCheck + @PostMapping("/extract/cash") + @ApiOperation(value = "用户提现",notes = "用户提现") + public ApiResult addYxUserExtract(@Valid @RequestBody UserExtParam param){ + YxUser yxUser = LocalUser.getUser(); + userExtractService.userExtract(yxUser,param); + return ApiResult.ok("申请提现成功"); + } + + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserRechargeController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserRechargeController.java new file mode 100644 index 00000000..0293cfc8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/AppUserRechargeController.java @@ -0,0 +1,164 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.user.rest; + +import cn.hutool.core.bean.BeanUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.user.param.RechargeParam; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.AppFromEnum; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.modules.shop.domain.YxSystemGroupData; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria; +import co.yixiang.modules.shop.vo.YxSystemGroupDataVo; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.mp.service.WeixinPayService; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.github.binarywang.wxpay.bean.order.WxPayAppOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; +import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + *

+ * 用户充值 前端控制器 + *

+ * + * @author hupeng + * @since 2020-03-01 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户充值", tags = "用户:用户充值") +public class AppUserRechargeController { + + private final YxUserRechargeService userRechargeService; + private final WeixinPayService weixinPayService; + private final YxSystemGroupDataService systemGroupDataService; + + /** + * 充值方案 + */ + @GetMapping("/recharge/index") + @ApiOperation(value = "充值方案",notes = "充值方案",response = ApiResult.class) + public ApiResult getWays(){ + YxSystemGroupDataQueryCriteria queryCriteria = new YxSystemGroupDataQueryCriteria(); + queryCriteria.setGroupName(ShopConstants.YSHOP_RECHARGE_PRICE_WAYS); + queryCriteria.setStatus(ShopCommonEnum.IS_STATUS_1.getValue()); + List yxSystemGroupDataList = systemGroupDataService.queryAll(queryCriteria); + + List systemGroupDataVoList = yxSystemGroupDataList.stream().map(s->{ + YxSystemGroupDataVo systemGroupDataVo = new YxSystemGroupDataVo(); + BeanUtil.copyProperties(s,systemGroupDataVo,"value"); + systemGroupDataVo.setValue(JSON.parseObject(s.getValue())); + return systemGroupDataVo; + }).collect(Collectors.toList()); + + Map map = new LinkedHashMap<>(); + map.put("recharge_price_ways",systemGroupDataVoList); + return ApiResult.ok(map); + } + + /** + * 公众号充值/H5充值 + */ + @AppLog(value = "公众号充值", type = 1) + @AuthCheck + @PostMapping("/recharge/wechat") + @ApiOperation(value = "公众号充值/H5充值",notes = "公众号充值/H5充值",response = ApiResult.class) + public ApiResult> add(@Valid @RequestBody RechargeParam param){ + YxUser user = LocalUser.getUser(); + + Map map = new LinkedHashMap<>(); + map.put("type",param.getFrom()); + YxSystemGroupData systemGroupData = systemGroupDataService.getById(param.getRecharId()); + if(systemGroupData == null) { + throw new YshopException("充值方案不存在"); + } + + JSONObject jsonObject = JSON.parseObject(systemGroupData.getValue()); + String price = jsonObject.getString("price"); + String giveMoney =jsonObject.getString("give_price"); + String orderSn = userRechargeService.addRecharge(user,price,giveMoney); + + if(AppFromEnum.WEIXIN_H5.getValue().equals(param.getFrom())){ + WxPayMwebOrderResult result = (WxPayMwebOrderResult)weixinPayService + .unifyPay(orderSn,param.getFrom(), BillDetailEnum.TYPE_1.getValue(),"H5充值"); + map.put("data",result.getMwebUrl()); + }else if(AppFromEnum.ROUNTINE.getValue().equals(param.getFrom())){ + WxPayMpOrderResult wxPayMpOrderResult = (WxPayMpOrderResult)weixinPayService + .unifyPay(orderSn,param.getFrom(), BillDetailEnum.TYPE_1.getValue(),"小程序充值"); + Map jsConfig = new HashMap<>(); + jsConfig.put("timeStamp",wxPayMpOrderResult.getTimeStamp()); + jsConfig.put("appId",wxPayMpOrderResult.getAppId()); + jsConfig.put("paySign",wxPayMpOrderResult.getPaySign()); + jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr()); + jsConfig.put("package",wxPayMpOrderResult.getPackageValue()); + jsConfig.put("signType",wxPayMpOrderResult.getSignType()); + map.put("data",jsConfig); + }else if(AppFromEnum.APP.getValue().equals(param.getFrom())){ + WxPayAppOrderResult wxPayAppOrderResult = (WxPayAppOrderResult)weixinPayService + .unifyPay(orderSn,param.getFrom(), BillDetailEnum.TYPE_1.getValue(),"app充值"); + Map jsConfig = new HashMap<>(); + jsConfig.put("partnerid",wxPayAppOrderResult.getPartnerId()); + jsConfig.put("appid",wxPayAppOrderResult.getAppId()); + jsConfig.put("prepayid",wxPayAppOrderResult.getPrepayId()); + jsConfig.put("package",wxPayAppOrderResult.getPackageValue()); + jsConfig.put("noncestr",wxPayAppOrderResult.getNonceStr()); + jsConfig.put("timestamp",wxPayAppOrderResult.getTimeStamp()); + jsConfig.put("sign",wxPayAppOrderResult.getSign()); + map.put("data",jsConfig); + }else{ + WxPayMpOrderResult result = (WxPayMpOrderResult)weixinPayService + .unifyPay(orderSn,param.getFrom(), BillDetailEnum.TYPE_1.getValue(),"公众号充值"); + Map config = new HashMap<>(); + config.put("timestamp",result.getTimeStamp()); + config.put("appId",result.getAppId()); + config.put("nonceStr",result.getNonceStr()); + config.put("package",result.getPackageValue()); + config.put("signType",result.getSignType()); + config.put("paySign",result.getPaySign()); + map.put("data",config); + } + + + + + return ApiResult.ok(map); + } + + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java new file mode 100644 index 00000000..9a5e4b26 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/LetterAppUserController.java @@ -0,0 +1,239 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.user.rest; + + +import co.yixiang.api.ApiResult; +import co.yixiang.app.common.aop.NoRepeatSubmit; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.app.modules.user.param.UserEditParam; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.BillInfoEnum; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.vo.UserOrderCountVo; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.YxUserSignService; +import co.yixiang.modules.user.vo.SignVo; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import com.google.common.collect.Maps; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static co.yixiang.constant.SystemConfigConstants.YSHOP_SHOW_RECHARGE; + +/** + *

+ * 用户控制器 + *

+ * + * @author hupeng + * @since 2019-10-16 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户中心", tags = "用户:用户中心") +public class LetterAppUserController { + + private final YxUserService yxUserService; + private final YxSystemGroupDataService systemGroupDataService; + private final YxStoreOrderService orderService; + private final YxStoreProductRelationService relationService; + private final YxUserSignService userSignService; + private final YxUserBillService userBillService; + private final YxSystemConfigService systemConfigService; + + + /** + * 用户资料 + */ + @AuthCheck + @GetMapping("/userinfo") + @ApiOperation(value = "获取用户信息",notes = "获取用户信息",response = YxUserQueryVo.class) + public ApiResult userInfo(){ + YxUser yxUser = LocalUser.getUser(); + return ApiResult.ok(yxUserService.getNewYxUserById(yxUser)); + } + + /** + * 获取个人中心菜单 + */ + @GetMapping("/menu/user") + @ApiOperation(value = "获取个人中心菜单",notes = "获取个人中心菜单") + public ApiResult> userMenu(){ + Map map = new LinkedHashMap<>(); + map.put("routine_my_menus",systemGroupDataService.getDatas(ShopConstants.YSHOP_MY_MENUES)); + return ApiResult.ok(map); + } + + + + /** + * 订单统计数据 + */ + @AppLog(value = "查看订单统计数据", type = 1) + @AuthCheck + @GetMapping("/order/data") + @ApiOperation(value = "订单统计数据",notes = "订单统计数据") + public ApiResult orderData(){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(orderService.orderData(uid)); + } + + /** + * 获取收藏产品 + */ + @AuthCheck + @GetMapping("/collect/user") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "type", value = "foot为足迹,collect为收藏", paramType = "query", dataType = "String") + }) + @ApiOperation(value = "获取收藏产品,或足迹",notes = "获取收藏产品,或足迹") + public ApiResult> collectUser(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit, + @RequestParam(value = "type") String type){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(relationService.userCollectProduct(page,limit,uid,type)); + } + + /** + * 用户资金统计 + */ + @AppLog(value = "查看用户资金统计", type = 1) + @AuthCheck + @GetMapping("/user/balance") + @ApiOperation(value = "用户资金统计",notes = "用户资金统计") + public ApiResult userBalance(){ + YxUser yxUser = LocalUser.getUser(); + Map map = Maps.newHashMap(); + Double[] userMoneys = yxUserService.getUserMoney(yxUser.getUid()); + map.put("now_money",yxUser.getNowMoney()); + map.put("orderStatusSum",userMoneys[0]); + map.put("recharge",userMoneys[1]); + map.put("is_hide",systemConfigService.getData(YSHOP_SHOW_RECHARGE)); + return ApiResult.ok(map); + } + + + /** + * 签到用户信息 + */ + @AppLog(value = "签到用户信息", type = 1) + @AuthCheck + @PostMapping("/sign/user") + @ApiOperation(value = "签到用户信息",notes = "签到用户信息") + public ApiResult sign(){ + YxUser yxUser = LocalUser.getUser(); + return ApiResult.ok(userSignService.userSignInfo(yxUser)); + } + + /** + * 签到配置 + */ + @GetMapping("/sign/config") + @ApiOperation(value = "签到配置",notes = "签到配置") + public ApiResult signConfig(){ + return ApiResult.ok(systemGroupDataService.getDatas(ShopConstants.YSHOP_SIGN_DAY_NUM)); + } + + /** + * 签到列表 + */ + @AppLog(value = "查看签到列表", type = 1) + @AuthCheck + @GetMapping("/sign/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "签到列表",notes = "签到列表") + public ApiResult> signList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(userSignService.getSignList(uid,page,limit)); + } + + /** + * 签到列表(年月) + */ + + @AuthCheck + @GetMapping("/sign/month") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), + @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") + }) + @ApiOperation(value = "签到列表(年月)",notes = "签到列表(年月)") + public ApiResult signMonthList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(userBillService.getUserBillList(page, limit,uid, BillInfoEnum.SIGN_INTEGRAL.getValue())); + } + + /** + * 开始签到 + */ + @AppLog(value = "开始签到", type = 1) + @NoRepeatSubmit + @AuthCheck + @PostMapping("/sign/integral") + @ApiOperation(value = "开始签到",notes = "开始签到") + public ApiResult signIntegral(){ + YxUser yxUser = LocalUser.getUser(); + int integral = userSignService.sign(yxUser);; + + Map map = new LinkedHashMap<>(); + map.put("integral",integral); + return ApiResult.ok(map,"签到获得" + integral + "积分"); + } + + @AppLog(value = "用户修改信息", type = 1) + @AuthCheck + @PostMapping("/user/edit") + @ApiOperation(value = "用户修改信息",notes = "用修改信息") + public ApiResult edit(@Validated @RequestBody UserEditParam param){ + YxUser yxUser = LocalUser.getUser(); + yxUser.setAvatar(param.getAvatar()); + yxUser.setNickname(param.getNickname()); + + yxUserService.updateById(yxUser); + + return ApiResult.ok("修改成功"); + } + + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/UserAddressController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/UserAddressController.java new file mode 100644 index 00000000..413ec689 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/UserAddressController.java @@ -0,0 +1,156 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.user.rest; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.app.common.util.CityTreeUtil; +import co.yixiang.app.common.web.param.IdParam; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.constant.ShopConstants; +import co.yixiang.modules.template.domain.YxSystemCity; +import co.yixiang.modules.template.service.YxSystemCityService; +import co.yixiang.modules.user.param.AddressParam; +import co.yixiang.modules.user.service.YxUserAddressService; +import co.yixiang.modules.user.vo.CityVo; +import co.yixiang.modules.user.vo.YxUserAddressQueryVo; +import com.google.common.collect.Lists; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 用户地前端控制器 + *

+ * + * @author hupeng + * @since 2019-10-28 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户地址", tags = "用户:用户地址") +public class UserAddressController { + + private final YxUserAddressService userAddressService; + private final YxSystemCityService systemCityService; + + + @Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_CITY_KEY) + @GetMapping("/city_list") + @ApiOperation(value = "城市列表",notes = "城市列表") + public ApiResult> getTest() { + List yxSystemCities = systemCityService.list(); + + List cityVOS = Lists.newArrayList(); + + for (YxSystemCity systemCity : yxSystemCities){ + CityVo cityVO = new CityVo(); + + cityVO.setV(systemCity.getCityId()); + cityVO.setN(systemCity.getName()); + cityVO.setPid(systemCity.getParentId()); + + cityVOS.add(cityVO); + } + + + return ApiResult.ok(CityTreeUtil.list2TreeConverter(cityVOS, 0)); + + } + + /** + * 添加或修改地址 + */ + @AppLog(value = "添加或修改地址", type = 1) + @AuthCheck + @PostMapping("/address/edit") + @ApiOperation(value = "添加或修改地址",notes = "添加或修改地址") + public ApiResult> addYxUserAddress(@Valid @RequestBody AddressParam param){ + Long uid = LocalUser.getUser().getUid(); + Long id = userAddressService.addAndEdit(uid,param); + Map map = new LinkedHashMap<>(); + map.put("id",id); + return ApiResult.ok(map); + } + + /** + * 设置默认地址 + */ + @AppLog(value = "设置默认地址", type = 1) + @AuthCheck + @PostMapping("/address/default/set") + @ApiOperation(value = "设置默认地址",notes = "设置默认地址") + public ApiResult setDefault(@Valid @RequestBody IdParam idParam){ + Long uid = LocalUser.getUser().getUid(); + userAddressService.setDefault(uid,Long.valueOf(idParam.getId())); + return ApiResult.ok(); + } + + + + /** + * 删除用户地址 + */ + @AuthCheck + @PostMapping("/address/del") + @ApiOperation(value = "删除用户地址",notes = "删除用户地址") + public ApiResult deleteYxUserAddress(@Valid @RequestBody IdParam idParam){ + userAddressService.removeById(idParam.getId()); + return ApiResult.ok(); + } + + + /** + * 用户地址列表 + */ + @AuthCheck + @GetMapping("/address/list") + @ApiOperation(value = "用户地址列表",notes = "用户地址列表") + public ApiResult> getYxUserAddressPageList(@RequestParam(value = "page",defaultValue = "1") int page, + @RequestParam(value = "limit",defaultValue = "10") int limit){ + Long uid = LocalUser.getUser().getUid(); + List addressQueryVos = userAddressService.getList(uid,page,limit); + return ApiResult.ok(addressQueryVos); + } + + /** + * 地址详情 + */ + @AuthCheck + @GetMapping("/address/detail/{id}") + @ApiOperation(value = "地址详情",notes = "地址详情") + public ApiResult addressDetail(@PathVariable String id){ + if(StrUtil.isBlank(id) || !NumberUtil.isNumber(id)){ + throw new YshopException("参数非法"); + } + return ApiResult.ok(userAddressService.getDetail(Long.valueOf(id))); + } + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/UserLevelController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/UserLevelController.java new file mode 100644 index 00000000..738d78cc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/user/rest/UserLevelController.java @@ -0,0 +1,93 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.user.rest; + + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.modules.user.service.YxSystemUserLevelService; +import co.yixiang.modules.user.service.YxSystemUserTaskService; +import co.yixiang.modules.user.service.YxUserLevelService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 用户等级 前端控制器 + *

+ * + * @author hupeng + * @since 2019-12-06 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "用户等级", tags = "用户:用户等级") +public class UserLevelController { + + private final YxUserLevelService userLevelService; + private final YxSystemUserLevelService systemUserLevelService; + private final YxSystemUserTaskService systemUserTaskService; + + /** + * 会员等级列表 + */ + @AuthCheck + @GetMapping("/user/level/grade") + @ApiOperation(value = "会员等级列表",notes = "会员等级列表") + public ApiResult getLevelInfo(){ + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(systemUserLevelService.getLevelInfo(uid)); + } + + /** + * 获取等级任务 + */ + @AuthCheck + @GetMapping("/user/level/task/{id}") + @ApiOperation(value = "获取等级任务",notes = "获取等级任务") + public ApiResult getTask(@PathVariable String id){ + if(StrUtil.isBlank(id) || !NumberUtil.isNumber(id)){ + throw new YshopException("参数非法"); + } + Long uid = LocalUser.getUser().getUid(); + return ApiResult.ok(systemUserTaskService.getTaskList(Integer.valueOf(id),uid)); + } + + /** + * 检测用户是否可以成为会员 + */ + @AuthCheck + @GetMapping("/user/level/detection") + @ApiOperation(value = "检测用户是否可以成为会员",notes = "检测用户是否可以成为会员") + public ApiResult detection(){ + Long uid = LocalUser.getUser().getUid(); + boolean res = userLevelService.setLevelComplete(uid); + if(res){ + return ApiResult.ok("升级成功!"); + }else{ + throw new YshopException("还不符合升级条件哦!"); + } + + } + + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WechatController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WechatController.java new file mode 100644 index 00000000..b7d102b2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WechatController.java @@ -0,0 +1,308 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.wechat.rest.controller; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.api.ApiResult; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.AfterSalesStatusEnum; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.PayMethodEnum; +import co.yixiang.enums.PayTypeEnum; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.user.domain.YxUserRecharge; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.modules.mp.config.WxPayConfiguration; +import co.yixiang.modules.mp.config.WxMaConfiguration; +import co.yixiang.utils.BigNum; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; +import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; +import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; +import com.github.binarywang.wxpay.exception.WxPayException; +import com.github.binarywang.wxpay.service.WxPayService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.bean.WxJsapiSignature; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.math.BigDecimal; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; + +/** + * @ClassName WechatController + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/5 + **/ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "微信模块", tags = "微信:微信模块") +public class WechatController { + + private final YxStoreOrderService orderService; + private final YxSystemConfigService systemConfigService; + private final YxUserRechargeService userRechargeService; + private final StoreAfterSalesService storeAfterSalesService; + + + /** + * 微信分享配置 + */ + @GetMapping("/share") + @ApiOperation(value = "微信分享配置",notes = "微信分享配置") + public ApiResult> share() { + Map map = new LinkedHashMap<>(); + map.put("img",systemConfigService.getData(SystemConfigConstants.WECHAT_SHARE_IMG)); + map.put("title",systemConfigService.getData(SystemConfigConstants.WECHAT_SHARE_TITLE)); + map.put("synopsis",systemConfigService.getData(SystemConfigConstants.WECHAT_SHARE_SYNOPSIS)); + Map mapt = new LinkedHashMap<>(); + mapt.put("data",map); + return ApiResult.ok(mapt); + } + + /** + * jssdk配置 + */ + @GetMapping("/wechat/config") + @ApiOperation(value = "jssdk配置",notes = "jssdk配置") + public ApiResult> jsConfig(HttpServletRequest request) throws WxErrorException { + WxMpService wxService = WxMpConfiguration.getWxMpService(); + String url = request.getParameter("url"); + log.info("url:"+url); + WxJsapiSignature jsapiSignature = wxService.createJsapiSignature(url); + Map map = new LinkedHashMap<>(); + map.put("appId",jsapiSignature.getAppId()); + map.put("jsApiList",new String[]{"updateAppMessageShareData","openLocation","scanQRCode", + "chooseWXPay","updateAppMessageShareData","updateTimelineShareData", + "openAddress","editAddress","getLocation"}); + map.put("nonceStr",jsapiSignature.getNonceStr()); + map.put("signature",jsapiSignature.getSignature()); + map.put("timestamp",jsapiSignature.getTimestamp()); + map.put("url",jsapiSignature.getUrl()); + return ApiResult.ok(map); + } + + + /** + * 微信小程序接口能力配置 + */ + @GetMapping("/wxapp/config") + @ApiOperation(value = "微信小程序接口能力配置",notes = "微信小程序接口能力配置",produces = "text/plain;charset=utf-8") + public String wxAppConfig(@RequestParam(value = "signature") String signature, + @RequestParam(value = "timestamp") String timestamp, + @RequestParam(value = "nonce") String nonce, + @RequestParam(name = "echostr", required = false) String echostr) throws WxErrorException { + WxMaService wxService = WxMaConfiguration.getWxMaService(); + + if( wxService.checkSignature(timestamp,nonce,signature)){ + return echostr; + } + return "false"; + } + + /** + * 微信支付/充值回调 + */ + @AnonymousAccess + @PostMapping("/wechat/notify") + @ApiOperation(value = "微信支付充值回调",notes = "微信支付充值回调") + public String renotify(@RequestBody String xmlData) { + try { + WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT); + if(wxPayService == null) { + wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP); + } + if(wxPayService == null) { + wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP); + } + WxPayOrderNotifyResult notifyResult = wxPayService.parseOrderNotifyResult(xmlData); + String orderId = notifyResult.getOutTradeNo(); + String attach = notifyResult.getAttach(); + if(BillDetailEnum.TYPE_3.getValue().equals(attach)){ + YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,null); + if(orderInfo == null) { + return WxPayNotifyResponse.success("处理成功!"); + } + if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())){ + return WxPayNotifyResponse.success("处理成功!"); + } + orderService.paySuccess(orderInfo.getOrderId(),PayTypeEnum.WEIXIN.getValue()); + }else if(BillDetailEnum.TYPE_1.getValue().equals(attach)){ + //处理充值 + YxUserRecharge userRecharge = userRechargeService.getInfoByOrderId(orderId); + if(userRecharge == null) { + return WxPayNotifyResponse.success("处理成功!"); + } + if(OrderInfoEnum.PAY_STATUS_1.getValue().equals(userRecharge.getPaid())){ + return WxPayNotifyResponse.success("处理成功!"); + } + + userRechargeService.updateRecharge(userRecharge); + } + + return WxPayNotifyResponse.success("处理成功!"); + } catch (WxPayException e) { + log.error(e.getMessage()); + return WxPayNotifyResponse.fail(e.getMessage()); + } + + } + + /** + * 微信退款回调 + */ + @ApiOperation(value = "退款回调通知处理",notes = "退款回调通知处理") + @PostMapping("/notify/refund") + public String parseRefundNotifyResult(@RequestBody String xmlData) { + try { + WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT); + if(wxPayService == null) { + wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP); + } + if(wxPayService == null) { + wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP); + } + WxPayRefundNotifyResult result = wxPayService.parseRefundNotifyResult(xmlData); + String orderId = result.getReqInfo().getOutTradeNo(); + BigDecimal refundFee = BigNum.div(result.getReqInfo().getRefundFee(), 100); + YxStoreOrderQueryVo orderInfo = orderService.getOrderInfo(orderId,null); + if(OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderInfo.getRefundStatus())){ + return WxPayNotifyResponse.success("处理成功!"); + } + YxStoreOrder storeOrder = new YxStoreOrder(); + //修改状态 + storeOrder.setId(orderInfo.getId()); + storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue()); + storeOrder.setRefundPrice(refundFee); + orderService.updateById(storeOrder); + orderService.retrunStock(orderId); + //售后状态修改 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StoreAfterSales::getOrderCode, orderId); + StoreAfterSales storeAfterSales = storeAfterSalesService.getOne(wrapper); + if (Objects.nonNull(storeAfterSales)) { + storeAfterSales.setState(AfterSalesStatusEnum.STATUS_3.getValue()); + storeAfterSalesService.updateById(storeAfterSales); + } + return WxPayNotifyResponse.success("处理成功!"); + } catch (WxPayException | IllegalAccessException e) { + log.error(e.getMessage()); + return WxPayNotifyResponse.fail(e.getMessage()); + } + } + /** + * 微信验证消息 + */ + @GetMapping( value = "/wechat/serve",produces = "text/plain;charset=utf-8") + @ApiOperation(value = "微信验证消息",notes = "微信验证消息") + public String authGet(@RequestParam(name = "signature", required = false) String signature, + @RequestParam(name = "timestamp", required = false) String timestamp, + @RequestParam(name = "nonce", required = false) String nonce, + @RequestParam(name = "echostr", required = false) String echostr){ + + final WxMpService wxService = WxMpConfiguration.getWxMpService(); + if (wxService == null) { + throw new IllegalArgumentException("未找到对应配置的服务,请核实!"); + } + + if (wxService.checkSignature(timestamp, nonce, signature)) { + return echostr; + } + + return "fail"; + } + + /** + *微信获取消息 + */ + @PostMapping("/wechat/serve") + @ApiOperation(value = "微信获取消息",notes = "微信获取消息") + public void post(@RequestBody String requestBody, + @RequestParam("signature") String signature, + @RequestParam("timestamp") String timestamp, + @RequestParam("nonce") String nonce, + @RequestParam("openid") String openid, + @RequestParam(name = "encrypt_type", required = false) String encType, + @RequestParam(name = "msg_signature", required = false) String msgSignature, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + WxMpService wxService = WxMpConfiguration.getWxMpService(); + + if (!wxService.checkSignature(timestamp, nonce, signature)) { + throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); + } + + String out = null; + if (encType == null) { + // 明文传输的消息 + WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody); + WxMpXmlOutMessage outMessage = this.route(inMessage); + if(outMessage == null) { + return; + } + out = outMessage.toXml();; + } else if ("aes".equalsIgnoreCase(encType)) { + // aes加密的消息 + WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(), + timestamp, nonce, msgSignature); + WxMpXmlOutMessage outMessage = this.route(inMessage); + if(outMessage == null) { + return; + } + + out = outMessage.toEncryptedXml(wxService.getWxMpConfigStorage()); + } + + response.setCharacterEncoding("UTF-8"); + PrintWriter writer = response.getWriter(); + writer.print(out); + writer.close(); + } + + private WxMpXmlOutMessage route(WxMpXmlMessage message) { + try { + return WxMpConfiguration.getWxMpMessageRouter().route(message); + } catch (Exception e) { + log.error("路由消息时出现异常!", e); + } + + return null; + } + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WechatLiveController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WechatLiveController.java new file mode 100644 index 00000000..161f8c28 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WechatLiveController.java @@ -0,0 +1,47 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.app.modules.wechat.rest.controller; + +import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult; +import co.yixiang.api.ApiResult; +import co.yixiang.modules.mp.service.YxWechatLiveService; +import co.yixiang.modules.mp.service.dto.YxWechatLiveQueryCriteria; +import co.yixiang.modules.mp.vo.WechatLiveVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@AllArgsConstructor +@Api(tags = "wxlive管理") +@RestController +@RequestMapping +public class WechatLiveController { + + private final YxWechatLiveService yxWechatLiveService; + + + @GetMapping("yxWechatLive") + @ApiOperation("查询所有直播间") + public ApiResult getYxWechatLives(YxWechatLiveQueryCriteria criteria, Pageable pageable){ + return ApiResult.ok(yxWechatLiveService.queryAll(criteria,pageable)); + } + @GetMapping("yxWechatLive/getLiveReplay/{id}") + @ApiOperation("获取直播回放") + public ApiResult> getLiveReplay(@PathVariable Integer id){ + return ApiResult.ok(yxWechatLiveService.getLiveReplay(id)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java new file mode 100644 index 00000000..a754f3b5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.app.modules.wechat.rest.controller; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.modules.wechat.rest.param.BindPhoneParam; +import co.yixiang.app.modules.wechat.rest.param.WxPhoneParam; +import co.yixiang.constant.ShopConstants; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.mp.config.WxMaConfiguration; + +import co.yixiang.utils.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author hupeng + * @date 2020/02/07 + */ +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "微信其他", tags = "微信:微信其他") +public class WxMaUserController { + + private final YxUserService userService; + private final RedisUtils redisUtils; + + @AppLog(value = "公众号绑定手机号", type = 1) + @AuthCheck + @PostMapping("/binding") + @ApiOperation(value = "公众号绑定手机号", notes = "公众号绑定手机号") + public ApiResult verify(@Validated @RequestBody BindPhoneParam param) { + Object codeObj = redisUtils.get("code_" + param.getPhone()); + if(codeObj == null){ + return ApiResult.fail("请先获取验证码"); + } + String code = codeObj.toString(); + + if (!StrUtil.equals(code, param.getCaptcha())) { + return ApiResult.fail("验证码错误"); + } + YxUser user = LocalUser.getUser(); + if(StrUtil.isNotBlank(user.getPhone())){ + return ApiResult.fail("您的账号已经绑定过手机号码"); + } + + user.setPhone(param.getPhone()); + userService.updateById(user); + + return ApiResult.ok("绑定成功"); + + } + + @AppLog(value = "小程序绑定手机号", type = 1) + @AuthCheck + @PostMapping("/wxapp/binding") + @ApiOperation(value = "小程序绑定手机号", notes = "小程序绑定手机号") + public ApiResult> phone(@Validated @RequestBody WxPhoneParam param) { + YxUser user = LocalUser.getUser(); + if(StrUtil.isNotBlank(user.getPhone())){ + throw new YshopException("您的账号已经绑定过手机号码"); + } + + //读取redis配置 + String appId = redisUtils.getY(ShopKeyUtils.getWxAppAppId()); + String secret = redisUtils.getY(ShopKeyUtils.getWxAppSecret()); + if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) { + throw new YshopException("请先配置小程序"); + } + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + String phone = ""; + try { + String sessionKey = redisUtils.get(ShopConstants.YSHOP_MINI_SESSION_KET+ user.getUid()).toString(); + WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService() + .getPhoneNoInfo(sessionKey, param.getEncryptedData(), param.getIv()); + phone = phoneNoInfo.getPhoneNumber(); + user.setPhone(phone); + userService.updateById(user); + } catch (Exception e) { + e.printStackTrace(); + throw new YshopException("绑定失败"); + } + Map map = new LinkedHashMap<>(); + map.put("phone",phone); + + return ApiResult.ok(map,"绑定成功"); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/BindPhoneParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/BindPhoneParam.java new file mode 100644 index 00000000..abb862b0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/BindPhoneParam.java @@ -0,0 +1,25 @@ +package co.yixiang.app.modules.wechat.rest.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName BindPhoneParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/2/7 + **/ +@Getter +@Setter +public class BindPhoneParam { + + @NotBlank(message = "验证码必填") + @ApiModelProperty(value = "验证码") + private String captcha; + + @NotBlank(message = "手机号必填") + @ApiModelProperty(value = "手机号码") + private String phone; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/WxPhoneParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/WxPhoneParam.java new file mode 100644 index 00000000..730fb18c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/WxPhoneParam.java @@ -0,0 +1,23 @@ +package co.yixiang.app.modules.wechat.rest.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName WxPhoneParam + * @Author hupeng <610796224@qq.com> + * @Date 2020/02/07 + **/ +@Getter +@Setter +public class WxPhoneParam { + + @ApiModelProperty(value = "小程序完整用户信息的加密数据") + private String encryptedData; + + @ApiModelProperty(value = "小程序加密算法的初始向量") + private String iv; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/YxWechatTemplateQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/YxWechatTemplateQueryParam.java new file mode 100644 index 00000000..367cb801 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/param/YxWechatTemplateQueryParam.java @@ -0,0 +1,21 @@ +package co.yixiang.app.modules.wechat.rest.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 微信模板 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-12-10 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxWechatTemplateQueryParam对象", description="微信模板查询参数") +public class YxWechatTemplateQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/vo/YxWechatTemplateQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/vo/YxWechatTemplateQueryVo.java new file mode 100644 index 00000000..22b2e0c3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/vo/YxWechatTemplateQueryVo.java @@ -0,0 +1,43 @@ +package co.yixiang.app.modules.wechat.rest.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 微信模板 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-10 + */ +@Data +@ApiModel(value = "YxWechatTemplateQueryVo对象", description = "微信模板查询参数") +public class YxWechatTemplateQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "模板id") + private Integer id; + + @ApiModelProperty(value = "模板编号") + private String tempkey; + + @ApiModelProperty(value = "模板名") + private String name; + + @ApiModelProperty(value = "回复内容") + private String content; + + @ApiModelProperty(value = "模板ID") + private String tempid; + + @ApiModelProperty(value = "添加时间") + private String addTime; + + @ApiModelProperty(value = "状态") + private Integer status; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/app/rest/AppStoreAfterSalesController.java b/zsw-bxg/src/main/java/co/yixiang/app/rest/AppStoreAfterSalesController.java new file mode 100644 index 00000000..fd1d9df8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/app/rest/AppStoreAfterSalesController.java @@ -0,0 +1,175 @@ +package co.yixiang.app.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.app.common.bean.LocalUser; +import co.yixiang.app.common.interceptor.AuthCheck; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.modules.order.domain.YxExpress; +import co.yixiang.modules.order.service.YxExpressService; +import co.yixiang.modules.order.service.dto.YxExpressQueryCriteria; +import co.yixiang.modules.sales.param.StoreAfterSalesParam; +import co.yixiang.modules.sales.service.StoreAfterSalesItemService; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.sales.service.StoreAfterSalesStatusService; +import co.yixiang.modules.sales.service.vo.StoreAfterSalesVo; +import co.yixiang.modules.sales.service.vo.YxStoreOrderCartInfoVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author : gzlv 2021/6/27 16:00 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "售后记录", tags = "用户:售后记录") +public class AppStoreAfterSalesController { + + @Autowired + private StoreAfterSalesService storeAfterSalesService; + @Autowired + private StoreAfterSalesItemService storeAfterSalesItemService; + @Autowired + private StoreAfterSalesStatusService storeAfterSalesStatusService; + @Autowired + private YxExpressService yxExpressService; + + @AuthCheck + @PostMapping("/applyForAfterSales") + @ApiOperation(value = "申请售后", notes = "申请售后") + public ApiResult applyForAfterSales(@RequestBody StoreAfterSalesParam storeAfterSalesParam) { + storeAfterSalesService.applyForAfterSales(LocalUser.getUser().getUid(), LocalUser.getUser().getNickname(), storeAfterSalesParam); + return ApiResult.ok(); + } + + @AuthCheck + @GetMapping("/applyForAfterSales/{key}") + @ApiOperation(value = "查询订单详情", notes = "查询订单详情") + public ApiResult> checkOrderDetails(@PathVariable String key) { + return ApiResult.ok(storeAfterSalesService.checkOrderDetails(key)); + } + + @AppLog(value = "查看售后列表", type = 1) + @AuthCheck + @GetMapping("/storeAfterSales/list") + @ApiOperation(value = "售后列表", notes = "售后列表") + public ApiResult salesList(@RequestParam(value = "type", defaultValue = "0") int type, + @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit) { + Map map = storeAfterSalesService.salesList(LocalUser.getUser().getUid(), type, + page, null, limit); + Long total = (Long) map.get("total"); + Long totalPage = (Long) map.get("totalPage"); + return ApiResult.resultPage(total.intValue(), totalPage.intValue(), map.get("list")); + } + + @AppLog(value = "查看售後详情", type = 1) + @AuthCheck + @GetMapping("/store/detail/{key}/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "订单详情", notes = "订单详情") + public ApiResult detail(@PathVariable String key, @PathVariable Long id) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + StoreAfterSalesVo storeInfo = storeAfterSalesService.getStoreInfoByOrderCodeAndAfterIdAndUid(key, id, uid); + storeAfterSalesService.handleSales(storeInfo); + return ApiResult.ok(storeInfo); + } + + @AppLog(value = "通过订单号搜索", type = 1) + @AuthCheck + @GetMapping("/store/detail/{key}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "订单详情", notes = "订单详情") + public ApiResult> detail(@PathVariable String key) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + List storeInfo = storeAfterSalesService.getStoreInfoByOrderCodeAndUid(key, uid); + storeInfo.forEach(item -> + storeAfterSalesService.handleSales(item) + ); + if (ObjectUtil.isNull(storeInfo)) { + throw new YshopException("售后订单不存在"); + } + return ApiResult.ok(storeInfo); + } + + @AppLog(value = "撤销申请", type = 1) + @AuthCheck + @GetMapping("/revoke/{key}/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "订单号", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "撤销申请", notes = "撤销申请") + public ApiResult revoke(@PathVariable String key, @PathVariable Long id) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + Boolean revoke = storeAfterSalesService.revoke(key, uid, id); + return ApiResult.ok(revoke); + } + + @ApiOperation(value = "查询快递") + @GetMapping(value = "/yxExpress") + public ApiResult> getYxExpresss(YxExpressQueryCriteria criteria) { + return ApiResult.ok(yxExpressService.queryAll(criteria)); + } + + @AppLog(value = "添加物流信息", type = 1) + @AuthCheck + @PostMapping("/addLogisticsInformation") + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "快递公司编码", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "name", value = "快递公司名称", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "postalCode", value = "快递编号", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "orderCode", value = "订单编号", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "添加物流信息", notes = "添加物流信息") + public ApiResult addLogisticsInformation(@RequestParam String code, @RequestParam String name, @RequestParam String postalCode, @RequestParam String orderCode) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(code) || StrUtil.isEmpty(name) || StrUtil.isEmpty(postalCode)) { + throw new YshopException("参数错误"); + } + Boolean revoke = storeAfterSalesService.addLogisticsInformation(code, name, postalCode, orderCode); + return ApiResult.ok(revoke); + } + + @AppLog(value = "删除售后订单", type = 1) + @AuthCheck + @DeleteMapping("/deleteAfterSalesOrder") + @ApiImplicitParams({ + @ApiImplicitParam(name = "orderCode", value = "订单编码", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "删除售后订单", notes = "删除售后订单") + public ApiResult deleteAfterSalesOrder(@RequestParam String orderCode, @RequestParam Long id) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(orderCode) || ObjectUtil.isEmpty(id)) { + throw new YshopException("参数错误"); + } + Boolean revoke = storeAfterSalesService.deleteAfterSalesOrder(orderCode, id); + return ApiResult.ok(revoke); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/aspect/LimitAspect.java b/zsw-bxg/src/main/java/co/yixiang/aspect/LimitAspect.java new file mode 100644 index 00000000..ad545120 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/aspect/LimitAspect.java @@ -0,0 +1,91 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.aspect; +// +//import co.yixiang.annotation.Limit; +//import co.yixiang.exception.BadLimitRequestException; +//import co.yixiang.exception.BadRequestException; +//import co.yixiang.utils.RequestHolder; +//import co.yixiang.utils.StringUtils; +//import com.google.common.collect.ImmutableList; +//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.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.data.redis.core.RedisTemplate; +//import org.springframework.data.redis.core.script.DefaultRedisScript; +//import org.springframework.data.redis.core.script.RedisScript; +//import org.springframework.stereotype.Component; +// +//import javax.servlet.http.HttpServletRequest; +//import java.lang.reflect.Method; +// +///** +// * @author / +// */ +//@Aspect +//@Component +//public class LimitAspect { +// +// private final RedisTemplate redisTemplate; +// private static final Logger logger = LoggerFactory.getLogger(LimitAspect.class); +// +// public LimitAspect(RedisTemplate redisTemplate) { +// this.redisTemplate = redisTemplate; +// } +// +// @Pointcut("@annotation(co.yixiang.annotation.Limit)") +// public void pointcut() { +// } +// +// @Around("pointcut()") +// public Object around(ProceedingJoinPoint joinPoint) throws Throwable { +// HttpServletRequest request = RequestHolder.getHttpServletRequest(); +// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); +// Method signatureMethod = signature.getMethod(); +// Limit limit = signatureMethod.getAnnotation(Limit.class); +// LimitType limitType = limit.limitType(); +// String key = limit.key(); +// if (StringUtils.isEmpty(key)) { +// if (limitType == LimitType.IP) { +// key = StringUtils.getIp(request); +// } else { +// key = signatureMethod.getName(); +// } +// } +// +// ImmutableList keys = ImmutableList.of(StringUtils.join(limit.prefix(), "_", key, "_", request.getRequestURI().replaceAll("/","_"))); +// +// String luaScript = buildLuaScript(); +// RedisScript redisScript = new DefaultRedisScript<>(luaScript, Number.class); +// Number count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period()); +// if (null != count && count.intValue() <= limit.count()) { +// logger.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name()); +// return joinPoint.proceed(); +// } else { +// throw new BadLimitRequestException("访问次数受限制"); +// } +// } +// +// /** +// * 限流脚本 +// */ +// private String buildLuaScript() { +// return "local c" + +// "\nc = redis.call('get',KEYS[1])" + +// "\nif c and tonumber(c) > tonumber(ARGV[1]) then" + +// "\nreturn c;" + +// "\nend" + +// "\nc = redis.call('incr',KEYS[1])" + +// "\nif tonumber(c) == 1 then" + +// "\nredis.call('expire',KEYS[1],ARGV[2])" + +// "\nend" + +// "\nreturn c;"; +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/aspect/LimitType.java b/zsw-bxg/src/main/java/co/yixiang/aspect/LimitType.java new file mode 100644 index 00000000..c9e0f5ca --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/aspect/LimitType.java @@ -0,0 +1,17 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.aspect; + +/** + * 限流枚举 + * @author / + */ +public enum LimitType { + // 默认 + CUSTOMER, + // by ip addr + IP +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/entity/BaseEntity.java b/zsw-bxg/src/main/java/co/yixiang/common/entity/BaseEntity.java new file mode 100644 index 00000000..2ad67ca4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/entity/BaseEntity.java @@ -0,0 +1,15 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.entity; + +import io.swagger.annotations.ApiModel; + +import java.io.Serializable; + + +@ApiModel("BaseEntity") +public abstract class BaseEntity implements Serializable{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/mapper/CoreMapper.java b/zsw-bxg/src/main/java/co/yixiang/common/mapper/CoreMapper.java new file mode 100644 index 00000000..e96bad8b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/mapper/CoreMapper.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.mapper; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @param + * @author LionCity + */ +public interface CoreMapper extends BaseMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/service/BaseService.java b/zsw-bxg/src/main/java/co/yixiang/common/service/BaseService.java new file mode 100644 index 00000000..3f413e5c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/service/BaseService.java @@ -0,0 +1,14 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.service; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.extension.service.IService; + + +public interface BaseService extends IService { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/service/impl/BaseServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/common/service/impl/BaseServiceImpl.java new file mode 100644 index 00000000..8b8f7800 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/service/impl/BaseServiceImpl.java @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import co.yixiang.common.service.BaseService; +import co.yixiang.common.web.param.OrderQueryParam; +import co.yixiang.common.web.param.QueryParam; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; + +import java.util.Arrays; +import java.util.List; + +/** + * @author hupeng + * @since 2019-10-16 + */ +@Slf4j +@SuppressWarnings("unchecked") +public abstract class BaseServiceImpl, T> extends ServiceImpl implements BaseService { + + protected Page setPageParam(QueryParam queryParam) { + return setPageParam(queryParam,null); + } + + protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) { + Page page = new Page(); + // 设置当前页码 + page.setCurrent(queryParam.getPage()); + // 设置页大小 + page.setSize(queryParam.getLimit()); + /** + * 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序 + * 否则使用默认排序 + */ + if (queryParam instanceof OrderQueryParam){ + OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam; + List orderItems = orderQueryParam.getOrders(); + if (CollectionUtil.isEmpty(orderItems)){ + page.setOrders(Arrays.asList(defaultOrder)); + }else{ + page.setOrders(orderItems); + } + }else{ + page.setOrders(Arrays.asList(defaultOrder)); + } + + return page; + } + + protected void getPage(Pageable pageable) { + String order=null; + if(pageable.getSort()!=null){ + order= pageable.getSort().toString(); + order=order.replace(":",""); + if("UNSORTED".equals(order)){ + order="id desc"; + } + } + PageHelper.startPage(pageable.getPageNumber()+1, pageable.getPageSize(),order); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/utils/QueryHelpPlus.java b/zsw-bxg/src/main/java/co/yixiang/common/utils/QueryHelpPlus.java new file mode 100644 index 00000000..7cd4af35 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/utils/QueryHelpPlus.java @@ -0,0 +1,186 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.utils; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.annotation.Query; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import lombok.extern.slf4j.Slf4j; + +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * @author Zheng Jie + * @date 2019-6-4 14:59:48 + */ +@Slf4j +@SuppressWarnings({"unchecked", "all"}) +public class QueryHelpPlus { + + public static QueryWrapper getPredicate(R obj, Q query) { + QueryWrapper queryWrapper = new QueryWrapper(); + if (query == null) { + return queryWrapper; + } + try { + List fields = getAllFields(query.getClass(), new ArrayList<>()); + for (Field field : fields) { + boolean accessible = field.isAccessible(); + field.setAccessible(true); + Query q = field.getAnnotation(Query.class); + if (q != null) { + String propName = q.propName(); + String blurry = q.blurry(); + String attributeName = isBlank(propName) ? field.getName() : propName; + attributeName = humpToUnderline(attributeName); + Class fieldType = field.getType(); + Object val = field.get(query); + if (ObjectUtil.isNull(val) || "".equals(val)) { + continue; + } + // 模糊多字段 + if (ObjectUtil.isNotEmpty(blurry)) { + String[] blurrys = blurry.split(","); + //queryWrapper.or(); + queryWrapper.and(wrapper -> { + for (int i=0;i< blurrys.length;i++) { + String column = humpToUnderline(blurrys[i]); + //if(i!=0){ + wrapper.or(); + //} + wrapper.like(column, val.toString()); + } + }); + continue; + } + String finalAttributeName = attributeName; + switch (q.type()) { + case EQUAL: + //queryWrapper.and(wrapper -> wrapper.eq(finalAttributeName, val)); + queryWrapper.eq(attributeName, val); + break; + case GREATER_THAN: + queryWrapper.ge(finalAttributeName, val); + break; + case GREATER_THAN_NQ: + queryWrapper.gt(finalAttributeName, val); + break; + case LESS_THAN: + queryWrapper.le(finalAttributeName, val); + break; + case LESS_THAN_NQ: + queryWrapper.lt(finalAttributeName, val); + break; + case INNER_LIKE: + queryWrapper.like(finalAttributeName, val); + break; + case LEFT_LIKE: + queryWrapper.likeLeft(finalAttributeName, val); + break; + case RIGHT_LIKE: + queryWrapper.likeRight(finalAttributeName, val); + break; + case IN: + if (CollUtil.isNotEmpty((Collection) val)) { + queryWrapper.in(finalAttributeName, (Collection) val); + } + break; + case NOT_EQUAL: + queryWrapper.ne(finalAttributeName, val); + break; + case NOT_NULL: + queryWrapper.isNotNull(finalAttributeName); + break; + case BETWEEN: + List between = new ArrayList<>((List) val); + queryWrapper.between(finalAttributeName, between.get(0), between.get(1)); + break; + case UNIX_TIMESTAMP: + List UNIX_TIMESTAMP = new ArrayList<>((List)val); + if(!UNIX_TIMESTAMP.isEmpty()){ + SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date time1 = fm.parse(UNIX_TIMESTAMP.get(0).toString()); + Date time2 = fm.parse(UNIX_TIMESTAMP.get(1).toString()); + queryWrapper.between(finalAttributeName, time1, time2); + } + break; + default: + break; + } + } + field.setAccessible(accessible); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return queryWrapper; + } + + + + private static boolean isBlank(final CharSequence cs) { + int strLen; + if (cs == null || (strLen = cs.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (!Character.isWhitespace(cs.charAt(i))) { + return false; + } + } + return true; + } + + private static List getAllFields(Class clazz, List fields) { + if (clazz != null) { + fields.addAll(Arrays.asList(clazz.getDeclaredFields())); + getAllFields(clazz.getSuperclass(), fields); + } + return fields; + } + + /*** + * 驼峰命名转为下划线命名 + * + * @param para + * 驼峰命名的字符串 + */ + + public static String humpToUnderline(String para) { + StringBuilder sb = new StringBuilder(para); + int temp = 0;//定位 + if (!para.contains("_")) { + for (int i = 0; i < para.length(); i++) { + if (Character.isUpperCase(para.charAt(i))) { + sb.insert(i + temp, "_"); + temp += 1; + } + } + } + return sb.toString(); + } + +// public static void main(String[] args) { +// QueryWrapper query = new QueryWrapper(); +// //query.or(); +// query.or(wrapper -> wrapper.eq("store_id", 1).or().eq("store_id", 2)); +// //query.like("a",1); +// //query.or(); +// //query.like("b",2); +// //query.and(wrapper->wrapper.eq("c",1)); +// query.eq("1", 1); +// +// System.out.println(query.getSqlSegment()); +// } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/web/param/OrderQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/common/web/param/OrderQueryParam.java new file mode 100644 index 00000000..d593b9ae --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/web/param/OrderQueryParam.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.web.param; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Arrays; +import java.util.List; + + +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("可排序查询参数对象") +public abstract class OrderQueryParam extends QueryParam{ + private static final long serialVersionUID = 57714391204790143L; + + @ApiModelProperty(value = "排序") + private List orders; + + public void defaultOrder(OrderItem orderItem){ + this.defaultOrders(Arrays.asList(orderItem)); + } + + public void defaultOrders(List orderItems){ + if (CollectionUtil.isEmpty(orderItems)){ + return; + } + this.orders = orderItems; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/web/param/QueryParam.java b/zsw-bxg/src/main/java/co/yixiang/common/web/param/QueryParam.java new file mode 100644 index 00000000..a4913995 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/web/param/QueryParam.java @@ -0,0 +1,44 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.web.param; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + + +@Data +@ApiModel("查询参数对象") +public abstract class QueryParam implements Serializable{ + private static final long serialVersionUID = -3263921252635611410L; + + @ApiModelProperty(value = "页码,默认为1") + private Integer page =1; + @ApiModelProperty(value = "页大小,默认为10") + private Integer limit = 10; + @ApiModelProperty(value = "搜索字符串") + private String keyword; + + @ApiModelProperty(value = "当前第几页") + public void setCurrent(Integer current) { + if (current == null || current <= 0){ + this.page = 1; + }else{ + this.page = current; + } + } + + public void setSize(Integer size) { + if (size == null || size <= 0){ + this.limit = 10; + }else{ + this.limit = size; + } + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/common/web/vo/Paging.java b/zsw-bxg/src/main/java/co/yixiang/common/web/vo/Paging.java new file mode 100644 index 00000000..30fa65f8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/common/web/vo/Paging.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.common.web.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; + + +@ApiModel("分页") +@SuppressWarnings("unchecked") +public class Paging implements Serializable { + private static final long serialVersionUID = -1683800405530086022L; + + @ApiModelProperty("总行数") + @JSONField(name = "total") + @JsonProperty("total") + private long total = 0; + + @ApiModelProperty("数据列表") + @JSONField(name = "records") + @JsonProperty("records") + private List records = Collections.emptyList(); + + public Paging() { + } + + public Paging(IPage page) { + this.total = page.getTotal(); + this.records = page.getRecords(); + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public List getRecords() { + return records; + } + + public void setRecords(List records) { + this.records = records; + } + + @Override + public String toString() { + return "Paging{" + + "total=" + total + + ", records=" + records + + '}'; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/MvcConfigure.java b/zsw-bxg/src/main/java/co/yixiang/config/MvcConfigure.java new file mode 100644 index 00000000..3f74db5e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/MvcConfigure.java @@ -0,0 +1,34 @@ +package co.yixiang.config; + +import co.yixiang.app.common.interceptor.PermissionInterceptor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@Slf4j +public class MvcConfigure implements WebMvcConfigurer { + + public HandlerInterceptor getPermissionInterceptor() { + return new PermissionInterceptor(); + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(this.getPermissionInterceptor()) + .addPathPatterns("/bxgApp/**"); + } + + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + // 给电商的全部接口增加前缀 + + configurer.addPathPrefix("/bxgApp",aClass -> aClass.getPackage().getName().startsWith("co.yixiang.app.modules")); + configurer.addPathPrefix("/admin-api/bxg",aClass -> aClass.getPackage().getName().startsWith("co.yixiang")); + + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/MybatisConfig.java b/zsw-bxg/src/main/java/co/yixiang/config/MybatisConfig.java new file mode 100644 index 00000000..b0fe6d72 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/MybatisConfig.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.config; + +/** + * @author :LionCity + * @date :Created in 2020-04-10 15:11 + * @description:MybatisConfig + * @modified By: + * @version: + */ + +import com.github.pagehelper.PageHelper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +@Configuration(proxyBeanMethods = false) +public class MybatisConfig { + /** + * 配置mybatis的分页插件pageHelper + * @return + */ + @Bean + public PageHelper pageHelper(){ + PageHelper pageHelper = new PageHelper(); + Properties properties = new Properties(); + properties.setProperty("offsetAsPageNum","true"); + properties.setProperty("rowBoundsWithCount","true"); + properties.setProperty("reasonable","true"); + //配置mysql数据库的方言 + properties.setProperty("dialect","mysql"); + pageHelper.setProperties(properties); + return pageHelper; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/RedisConfig.java b/zsw-bxg/src/main/java/co/yixiang/config/RedisConfig.java new file mode 100644 index 00000000..6bf5e3c6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/RedisConfig.java @@ -0,0 +1,205 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.config; +// +//import cn.hutool.core.lang.Assert; +//import co.yixiang.utils.StringUtils; +//import com.alibaba.fastjson.JSON; +//import com.alibaba.fastjson.parser.ParserConfig; +//import com.alibaba.fastjson.serializer.SerializerFeature; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.commons.codec.digest.DigestUtils; +//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +//import org.springframework.boot.autoconfigure.data.redis.RedisProperties; +//import org.springframework.boot.context.properties.EnableConfigurationProperties; +//import org.springframework.cache.Cache; +//import org.springframework.cache.annotation.CachingConfigurerSupport; +//import org.springframework.cache.annotation.EnableCaching; +//import org.springframework.cache.interceptor.CacheErrorHandler; +//import org.springframework.cache.interceptor.KeyGenerator; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.data.redis.cache.RedisCacheConfiguration; +//import org.springframework.data.redis.connection.RedisConnectionFactory; +//import org.springframework.data.redis.core.RedisOperations; +//import org.springframework.data.redis.core.RedisTemplate; +//import org.springframework.data.redis.serializer.RedisSerializationContext; +//import org.springframework.data.redis.serializer.RedisSerializer; +// +//import java.nio.charset.Charset; +//import java.nio.charset.StandardCharsets; +//import java.time.Duration; +//import java.util.HashMap; +//import java.util.Map; +// +///** +// * @author Zheng Jie +// * @date 2018-11-24 +// */ +//@Slf4j +//@Configuration(proxyBeanMethods = false) +//@EnableCaching +//@ConditionalOnClass(RedisOperations.class) +//@EnableConfigurationProperties(RedisProperties.class) +//public class RedisConfig extends CachingConfigurerSupport { +// +// /** +// * 设置 redis 数据默认过期时间,默认2小时 +// * 设置@cacheable 序列化方式 +// */ +// @Bean +// public RedisCacheConfiguration redisCacheConfiguration(){ +// FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class); +// RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig(); +// configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)).entryTtl(Duration.ofHours(2)); +// return configuration; +// } +// +// @SuppressWarnings("all") +// @Bean(name = "redisTemplate") +// @ConditionalOnMissingBean(name = "redisTemplate") +// public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { +// RedisTemplate template = new RedisTemplate<>(); +// //序列化 +// FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class); +// // value值的序列化采用fastJsonRedisSerializer +// template.setValueSerializer(fastJsonRedisSerializer); +// template.setHashValueSerializer(fastJsonRedisSerializer); +// // 全局开启AutoType,这里方便开发,使用全局的方式 +// ParserConfig.getGlobalInstance().setAutoTypeSupport(true); +// // 建议使用这种方式,小范围指定白名单 +// // ParserConfig.getGlobalInstance().addAccept("me.zhengjie.domain"); +// // key的序列化采用StringRedisSerializer +// template.setKeySerializer(new StringRedisSerializer()); +// template.setHashKeySerializer(new StringRedisSerializer()); +// template.setConnectionFactory(redisConnectionFactory); +// return template; +// } +// +// /** +// * 自定义缓存key生成策略,默认将使用该策略 +// */ +// @Bean +// @Override +// public KeyGenerator keyGenerator() { +// return (target, method, params) -> { +// Map container = new HashMap<>(3); +// Class targetClassClass = target.getClass(); +// // 类地址 +// container.put("class",targetClassClass.toGenericString()); +// // 方法名称 +// container.put("methodName",method.getName()); +// // 包名称 +// container.put("package",targetClassClass.getPackage()); +// // 参数列表 +// for (int i = 0; i < params.length; i++) { +// container.put(String.valueOf(i),params[i]); +// } +// // 转为JSON字符串 +// String jsonString = JSON.toJSONString(container); +// // 做SHA256 Hash计算,得到一个SHA256摘要作为Key +// return DigestUtils.sha256Hex(jsonString); +// }; +// } +// +// @Bean +// @Override +// public CacheErrorHandler errorHandler() { +// // 异常处理,当Redis发生异常时,打印日志,但是程序正常走 +// log.info("初始化 -> [{}]", "Redis CacheErrorHandler"); +// return new CacheErrorHandler() { +// @Override +// public void handleCacheGetError(RuntimeException e, Cache cache, Object key) { +// log.error("Redis occur handleCacheGetError:key -> [{}]", key, e); +// } +// +// @Override +// public void handleCachePutError(RuntimeException e, Cache cache, Object key, Object value) { +// log.error("Redis occur handleCachePutError:key -> [{}];value -> [{}]", key, value, e); +// } +// +// @Override +// public void handleCacheEvictError(RuntimeException e, Cache cache, Object key) { +// log.error("Redis occur handleCacheEvictError:key -> [{}]", key, e); +// } +// +// @Override +// public void handleCacheClearError(RuntimeException e, Cache cache) { +// log.error("Redis occur handleCacheClearError:", e); +// } +// }; +// } +// +//} +// +///** +// * Value 序列化 +// * +// * @author / +// * @param +// */ +// class FastJsonRedisSerializer implements RedisSerializer { +// +// private final Class clazz; +// +// FastJsonRedisSerializer(Class clazz) { +// super(); +// this.clazz = clazz; +// } +// +// @Override +// public byte[] serialize(T t) { +// if (t == null) { +// return new byte[0]; +// } +// return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(StandardCharsets.UTF_8); +// } +// +// @Override +// public T deserialize(byte[] bytes) { +// if (bytes == null || bytes.length <= 0) { +// return null; +// } +// String str = new String(bytes, StandardCharsets.UTF_8); +// return JSON.parseObject(str, clazz); +// } +// +//} +// +///** +// * 重写序列化器 +// * +// * @author / +// */ +//class StringRedisSerializer implements RedisSerializer { +// +// private final Charset charset; +// +// StringRedisSerializer() { +// this(StandardCharsets.UTF_8); +// } +// +// private StringRedisSerializer(Charset charset) { +// Assert.notNull(charset, "Charset must not be null!"); +// this.charset = charset; +// } +// +// @Override +// public String deserialize(byte[] bytes) { +// return (bytes == null ? null : new String(bytes, charset)); +// } +// +// @Override +// public byte[] serialize(Object object) { +// String string = JSON.toJSONString(object); +// if (StringUtils.isBlank(string)) { +// return null; +// } +// string = string.replace("\"", ""); +// return string.getBytes(charset); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/WebSocketConfig.java b/zsw-bxg/src/main/java/co/yixiang/config/WebSocketConfig.java new file mode 100644 index 00000000..87b66ae5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/WebSocketConfig.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.server.standard.ServerEndpointExporter; + +/** + * @author: ZhangHouYing + * @date: 2019-08-24 15:44 + */ +@Configuration(proxyBeanMethods = false) +public class WebSocketConfig { + + @Bean + public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/thread/AsyncTaskExecutePool.java b/zsw-bxg/src/main/java/co/yixiang/config/thread/AsyncTaskExecutePool.java new file mode 100644 index 00000000..aab9b663 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/thread/AsyncTaskExecutePool.java @@ -0,0 +1,60 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.config.thread; +// +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.scheduling.annotation.AsyncConfigurer; +//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +// +//import java.util.concurrent.Executor; +//import java.util.concurrent.ThreadPoolExecutor; +// +///** +// * 异步任务线程池装配类 +// * @author https://juejin.im/entry/5abb8f6951882555677e9da2 +// * @date 2019年10月31日15:06:18 +// */ +//@Slf4j +//@Configuration(proxyBeanMethods = false) +//public class AsyncTaskExecutePool implements AsyncConfigurer { +// +// /** 注入配置类 */ +// private final AsyncTaskProperties config; +// +// public AsyncTaskExecutePool(AsyncTaskProperties config) { +// this.config = config; +// } +// +// @Override +// public Executor getAsyncExecutor() { +// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); +// //核心线程池大小 +// executor.setCorePoolSize(config.getCorePoolSize()); +// //最大线程数 +// executor.setMaxPoolSize(config.getMaxPoolSize()); +// //队列容量 +// executor.setQueueCapacity(config.getQueueCapacity()); +// //活跃时间 +// executor.setKeepAliveSeconds(config.getKeepAliveSeconds()); +// //线程名字前缀 +// executor.setThreadNamePrefix("el-async-"); +// // setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务 +// // CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行 +// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); +// executor.initialize(); +// return executor; +// } +// +// @Override +// public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { +// return (throwable, method, objects) -> { +// log.error("===="+throwable.getMessage()+"====", throwable); +// log.error("exception method:"+method.getName()); +// }; +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/thread/AsyncTaskProperties.java b/zsw-bxg/src/main/java/co/yixiang/config/thread/AsyncTaskProperties.java new file mode 100644 index 00000000..1873e986 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/thread/AsyncTaskProperties.java @@ -0,0 +1,29 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.config.thread; +// +//import lombok.Data; +//import org.springframework.boot.context.properties.ConfigurationProperties; +//import org.springframework.stereotype.Component; +// +///** +// * 线程池配置属性类 +// * @author https://juejin.im/entry/5abb8f6951882555677e9da2 +// * @date 2019年10月31日14:58:18 +// */ +//@Data +//@Component +//@ConfigurationProperties(prefix = "task.pool") +//public class AsyncTaskProperties { +// +// private int corePoolSize; +// +// private int maxPoolSize; +// +// private int keepAliveSeconds; +// +// private int queueCapacity; +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/thread/TheadFactoryName.java b/zsw-bxg/src/main/java/co/yixiang/config/thread/TheadFactoryName.java new file mode 100644 index 00000000..158e2658 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/thread/TheadFactoryName.java @@ -0,0 +1,53 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.config.thread; +// +//import org.springframework.stereotype.Component; +// +//import java.util.concurrent.ThreadFactory; +//import java.util.concurrent.atomic.AtomicInteger; +// +///** +// * 自定义线程名称 +// * @author hupeng +// * @date 2019年10月31日17:49:55 +// */ +//@Component +//public class TheadFactoryName implements ThreadFactory { +// +// private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1); +// private final ThreadGroup group; +// private final AtomicInteger threadNumber = new AtomicInteger(1); +// private final String namePrefix; +// +// public TheadFactoryName() { +// this("el-pool"); +// } +// +// private TheadFactoryName(String name){ +// SecurityManager s = System.getSecurityManager(); +// group = (s != null) ? s.getThreadGroup() : +// Thread.currentThread().getThreadGroup(); +// //此时namePrefix就是 name + 第几个用这个工厂创建线程池的 +// this.namePrefix = name + +// POOL_NUMBER.getAndIncrement(); +// } +// +// @Override +// public Thread newThread(Runnable r) { +// //此时线程的名字 就是 namePrefix + -thread- + 这个线程池中第几个执行的线程 +// Thread t = new Thread(group, r, +// namePrefix + "-thread-"+threadNumber.getAndIncrement(), +// 0); +// if (t.isDaemon()) { +// t.setDaemon(false); +// } +// if (t.getPriority() != Thread.NORM_PRIORITY) { +// t.setPriority(Thread.NORM_PRIORITY); +// } +// return t; +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/config/thread/ThreadPoolExecutorUtil.java b/zsw-bxg/src/main/java/co/yixiang/config/thread/ThreadPoolExecutorUtil.java new file mode 100644 index 00000000..b4ff52fa --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/config/thread/ThreadPoolExecutorUtil.java @@ -0,0 +1,32 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.config.thread; +// +//import co.yixiang.utils.SpringContextHolder; +// +//import java.util.concurrent.ArrayBlockingQueue; +//import java.util.concurrent.ThreadPoolExecutor; +//import java.util.concurrent.TimeUnit; +// +///** +// * 用于获取自定义线程池 +// * @author hupeng +// * @date 2019年10月31日18:16:47 +// */ +//public class ThreadPoolExecutorUtil { +// +// public static ThreadPoolExecutor getPoll(){ +// AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class); +// return new ThreadPoolExecutor( +// properties.getCorePoolSize(), +// properties.getMaxPoolSize(), +// properties.getKeepAliveSeconds(), +// TimeUnit.SECONDS, +// new ArrayBlockingQueue<>(properties.getQueueCapacity()), +// new TheadFactoryName() +// ); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java new file mode 100644 index 00000000..bb0c3556 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java @@ -0,0 +1,182 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.constant; + +/** + * 商城统一常量 + * @author hupeng + * @since 2020-02-27 + */ +public interface ShopConstants { + + /** + * 订单自动取消时间(分钟) + */ + long ORDER_OUTTIME_UNPAY = 30; + /** + * 订单自动收货时间(天) + */ + long ORDER_OUTTIME_UNCONFIRM = 7; + /** + * redis订单未付款key + */ + String REDIS_ORDER_OUTTIME_UNPAY = "order:unpay:"; + /** + * redis订单收货key + */ + String REDIS_ORDER_OUTTIME_UNCONFIRM = "order:unconfirm:"; + + /** + * redis拼团key + */ + String REDIS_PINK_CANCEL_KEY = "pink:cancel:"; + + /** + * 微信支付service + */ + String YSHOP_WEIXIN_PAY_SERVICE = "yshop_weixin_pay_service"; + + /** + * 微信支付小程序service + */ + String YSHOP_WEIXIN_MINI_PAY_SERVICE = "yshop_weixin_mini_pay_service"; + + /** + * 微信支付app service + */ + String YSHOP_WEIXIN_APP_PAY_SERVICE = "yshop_weixin_app_pay_service"; + + /** + * 微信公众号service + */ + String YSHOP_WEIXIN_MP_SERVICE = "yshop_weixin_mp_service"; + /** + * 微信小程序service + */ + String YSHOP_WEIXIN_MA_SERVICE = "yshop_weixin_ma_service"; + + /** + * 商城默认密码 + */ + String YSHOP_DEFAULT_PWD = "123456"; + + /** + * 商城默认注册图片 + */ + String YSHOP_DEFAULT_AVATAR = "https://image.dayouqiantu.cn/5e79f6cfd33b6.png"; + + /** + * 腾讯地图地址解析 + */ + String QQ_MAP_URL = "https://apis.map.qq.com/ws/geocoder/v1/"; + + /** + * redis首页键 + */ + String YSHOP_REDIS_INDEX_KEY = "yshop:index_data"; + + /** + * 配置列表缓存 + */ + String YSHOP_REDIS_CONFIG_DATAS = "yshop:config_datas"; + + /** + * 充值方案 + */ + String YSHOP_RECHARGE_PRICE_WAYS = "yshop_recharge_price_ways"; + /** + * 首页banner + */ + String YSHOP_HOME_BANNER = "yshop_home_banner"; + /** + * 首页菜单 + */ + String YSHOP_HOME_MENUS = "yshop_home_menus"; + /** + * 首页滚动新闻 + */ + String YSHOP_HOME_ROLL_NEWS = "yshop_home_roll_news"; + /** + * 热门搜索 + */ + String YSHOP_HOT_SEARCH = "yshop_hot_search"; + /** + * 个人中心菜单 + */ + String YSHOP_MY_MENUES = "yshop_my_menus"; + /** + * 秒杀时间段 + */ + String YSHOP_SECKILL_TIME = "yshop_seckill_time"; + /** + * 签到天数 + */ + String YSHOP_SIGN_DAY_NUM = "yshop_sign_day_num"; + + /** + * 打印机配置 + */ + String YSHOP_ORDER_PRINT_COUNT = "order_print_count"; + /** + * 飞蛾用户信息 + */ + String YSHOP_FEI_E_USER = "fei_e_user"; + /** + * 飞蛾用户密钥 + */ + String YSHOP_FEI_E_UKEY= "fei_e_ukey"; + + /** + * 打印机配置 + */ + String YSHOP_ORDER_PRINT_COUNT_DETAIL = "order_print_count_detail"; + + /** + * 短信验证码长度 + */ + int YSHOP_SMS_SIZE = 6; + + /** + * 短信缓存时间 + */ + long YSHOP_SMS_REDIS_TIME = 600L; + + //零标识 + String YSHOP_ZERO = "0"; + + //业务标识标识 + String YSHOP_ONE = "1"; + + //目前完成任务数量是3 + Long TASK_FINISH_COUNT = 3L; + + int YSHOP_ONE_NUM = 1; + + String YSHOP_ORDER_CACHE_KEY = "yshop:order"; + + long YSHOP_ORDER_CACHE_TIME = 600L; + + String WECHAT_MENUS = "wechat_menus"; + + String YSHOP_EXPRESS_SERVICE = "yshop_express_service"; + + String YSHOP_REDIS_SYS_CITY_KEY = "yshop:city_list"; + + String YSHOP_REDIS_CITY_KEY = "yshop:city"; + + String YSHOP_APP_LOGIN_USER = "app-online-token:"; + + String YSHOP_WECHAT_PUSH_REMARK = "yshop为您服务!"; + + String DEFAULT_UNI_H5_URL = "https://h5.yixiang.co"; + + String YSHOP_MINI_SESSION_KET = "yshop:session_key:"; + + /**公众号二维码*/ + String WECHAT_FOLLOW_IMG="wechat_follow_img"; + /**后台api地址*/ + String ADMIN_API_URL="admin_api_url"; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/constant/SystemConfigConstants.java b/zsw-bxg/src/main/java/co/yixiang/constant/SystemConfigConstants.java new file mode 100644 index 00000000..be39605e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/constant/SystemConfigConstants.java @@ -0,0 +1,57 @@ +package co.yixiang.constant; + +public class SystemConfigConstants { + //地址配置 + public final static String API="api"; + public final static String API_URL="api_url"; + public final static String SITE_URL="site_url"; + public final static String UNI_SITE_URL="uni_site_url"; + public final static String TENGXUN_MAP_KEY="tengxun_map_key"; + public final static String FILE_STORE_MODE="file_store_mode"; + //业务相关配置 + public final static String IMAGEARR="imageArr"; + public final static String INTERGRAL_FULL="integral_full"; + public final static String INTERGRAL_MAX="integral_max"; + public final static String INTERGRAL_RATIO="integral_ratio"; + public final static String ORDER_CANCEL_JOB_TIME="order_cancel_job_time"; + public final static String STORE_BROKERAGE_OPEN="store_brokerage_open"; + public final static String STORE_BROKERAGE_RATIO="store_brokerage_ratio"; + public final static String STORE_BROKERAGE_STATU="store_brokerage_statu"; + public final static String STORE_BROKERAGE_TWO="store_brokerage_two"; + public final static String STORE_FREE_POSTAGE="store_free_postage"; + public final static String STORE_POSTAGE="store_postage"; + public final static String STORE_SEFL_MENTION="store_self_mention"; + public final static String STORE_USER_MIN_RECHARGE="store_user_min_recharge"; + public final static String USER_EXTRACT_MIN_PRICE="user_extract_min_price"; + public final static String YSHOP_SHOW_RECHARGE = "yshop_show_recharge"; + //微信相关配置 + public final static String WECHAT_APPID="wechat_appid"; + public final static String WECHAT_APPSECRET="wechat_appsecret"; + public final static String WECHAT_AVATAR="wechat_avatar"; + public final static String WECHAT_ENCODE="wechat_encode"; + public final static String WECHAT_ENCODINGAESKEY="wechat_encodingaeskey"; + public final static String WECHAT_ID="wechat_id"; + public final static String WECHAT_NAME="wechat_name"; + public final static String WECHAT_QRCODE="wechat_qrcode"; + public final static String WECHAT_SHARE_IMG="wechat_share_img"; + public final static String WECHAT_SHARE_SYNOPSIS="wechat_share_synopsis"; + public final static String WECHAT_SHARE_TITLE="wechat_share_title"; + public final static String WECHAT_SOURCEID="wechat_sourceid"; + public final static String WECHAT_TOKEN="wechat_token"; + public final static String WECHAT_MA_TOKEN="wechat_ma_token"; + public final static String WECHAT_MA_ENCODINGAESKEY="wechat_ma_encodingaeskey"; + public final static String WECHAT_TYPE="wechat_type"; + public final static String WXAPP_APPID="wxapp_appId"; + public final static String WXAPP_SECRET="wxapp_secret"; + public final static String WXPAY_APPID="wxpay_appId"; + public final static String WXPAY_KEYPATH="wxpay_keyPath"; + public final static String WXPAY_MCHID="wxpay_mchId"; + public final static String WXPAY_MCHKEY="wxpay_mchKey"; + 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"; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/domain/BaseDomain.java b/zsw-bxg/src/main/java/co/yixiang/domain/BaseDomain.java new file mode 100644 index 00000000..cb3ec4a3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/domain/BaseDomain.java @@ -0,0 +1,39 @@ +package co.yixiang.domain; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + + +/** + * @ClassName 公共模型 + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/13 + **/ +@Getter +@Setter +public class BaseDomain implements Serializable { + + private static final long serialVersionUID = 1L; + + + @TableField(fill= FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + @TableField(fill= FieldFill.UPDATE) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date updateTime; + + @TableLogic + @JsonIgnore + @TableField(fill= FieldFill.INSERT) + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/domain/PageResult.java b/zsw-bxg/src/main/java/co/yixiang/domain/PageResult.java new file mode 100644 index 00000000..4e36c7ac --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/domain/PageResult.java @@ -0,0 +1,37 @@ +package co.yixiang.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * @author :LionCity + * @date :Created in 2020-08-04 16:55 + * @description:分页参数返回 + * @modified By: + * @version: V1.0 + */ +@Data +@Accessors(chain = true) +@Builder +public class PageResult implements Serializable { + + + @ApiModelProperty("总数量") + private long totalElements; + + @ApiModelProperty("内容") + private List content; + + public PageResult(long totalElements, List content) { + this.totalElements = totalElements; + this.content = content; + } + + public PageResult() { + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/dozer/config/DozerMapperConfig.java b/zsw-bxg/src/main/java/co/yixiang/dozer/config/DozerMapperConfig.java new file mode 100644 index 00000000..7d017dea --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/dozer/config/DozerMapperConfig.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.dozer.config; + +import org.dozer.spring.DozerBeanMapperFactoryBean; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; + +/** + * @author :LionCity + * @date :Created in 2019/10/9 10:40 + * @description:Dozer转换 + * @modified By: + * @version: 1.0 + */ +@Configuration(proxyBeanMethods = false) +public class DozerMapperConfig { + @Bean + public DozerBeanMapperFactoryBean dozerBeanMapperFactoryBean(@Value("classpath*:dozer/*.xml" ) Resource[] resources) throws Exception { + final DozerBeanMapperFactoryBean dozerBeanMapperFactoryBean = new DozerBeanMapperFactoryBean(); + dozerBeanMapperFactoryBean.setMappingFiles(resources); + return dozerBeanMapperFactoryBean; + } + + /* @Bean + public IGenerator ejbGenerator() { + return new EJBGenerator(); + }*/ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/dozer/service/EJBGenerator.java b/zsw-bxg/src/main/java/co/yixiang/dozer/service/EJBGenerator.java new file mode 100644 index 00000000..07fbbc60 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/dozer/service/EJBGenerator.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.dozer.service; + +import co.yixiang.common.web.vo.Paging; +import co.yixiang.domain.PageResult; +import com.github.pagehelper.PageInfo; +import org.dozer.Mapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Array; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author :LionCity + * @date :Created in 2019/10/9 10:43 + * @description:dozer实现类 + * @modified By: + * @version: 1.0 + */ +@Component +@Lazy(true) +public class EJBGenerator implements IGenerator { + + @Autowired + protected Mapper dozerMapper; + + @Override + public T convert(final S s, Class clz) { + return s == null ? null : this.dozerMapper.map(s, clz); + } + + @Override + public List convert(List s, Class clz) { + return s == null ? null : s.stream().map(vs -> this.dozerMapper.map(vs, clz)).collect(Collectors.toList()); + } + + @Override + public Paging convertPaging(Paging paging, Class clz) { + Paging pagingVo=new Paging(); + pagingVo.setRecords(convert(paging.getRecords(),clz)); + pagingVo.setTotal(paging.getTotal()); + return pagingVo; + } + + @Override + public Set convert(Set s, Class clz) { + return s == null ? null : s.stream().map(vs -> this.dozerMapper.map(vs, clz)).collect(Collectors.toSet()); + } + + @Override + public T[] convert(S[] s, Class clz) { + if (s == null) { + return null; + } + @SuppressWarnings("unchecked") + T[] arr = (T[]) Array.newInstance(clz, s.length); + for (int i = 0; i < s.length; i++) { + arr[i] = this.dozerMapper.map(s[i], clz); + } + return arr; + } + + @Override + public PageResult convertPageInfo(PageInfo s, Class clz) { + return new PageResult(s.getTotal(), convert(s.getList(), clz)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/dozer/service/IGenerator.java b/zsw-bxg/src/main/java/co/yixiang/dozer/service/IGenerator.java new file mode 100644 index 00000000..ca2639f3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/dozer/service/IGenerator.java @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.dozer.service; + +import co.yixiang.common.web.vo.Paging; +import co.yixiang.domain.PageResult; +import com.github.pagehelper.PageInfo; + +import java.util.List; +import java.util.Set; + +/** + * @author :LionCity + * @date :Created in 2019/10/9 10:42 + * @description:doczer转换接口 + * @modified By: + * @version: 1.0 + */ +public interface IGenerator { + + /** + * 转换 + * + * @param s 数据对象 + * @param clz 复制目标类型 + * @return {@link T} + * @Description: 单个对象的深度复制及类型转换,vo/domain , po + * @author banjuer@outlook.com + * @Time 2018年5月9日 下午3:53:24 + */ + T convert(S s, Class clz); + + /** + * @Description: 深度复制结果集(ResultSet为自定义的分页结果集) + * @param s 数据对象 + * @param clz 复制目标类型 + * @return + * @author banjuer@outlook.com + * @Time 2018年5月9日 下午3:53:24 + */ + // Result convert(Result s, Class clz); + + /** + * 转换 + * @param s 数据对象 + * @param clz 复制目标类型 + * @return {@link List} + * @Description: list深度复制 + * @author banjuer@outlook.com + * @Time 2018年5月9日 下午3:54:08 + */ + List convert(List s, Class clz); + + /** + * + * @param s + * @param clz + * @param + * @param + * @return + */ + Paging convertPaging(Paging s, Class clz); + /** + * @param s 数据对象 + * @param clz 复制目标类型 + * @return + * @Description: set深度复制 + * @author banjuer@outlook.com + * @Time 2018年5月9日 下午3:54:39 + */ + Set convert(Set s, Class clz); + + /** + * @param s 数据对象 + * @param clz 复制目标类型 + * @return + * @Description: 数组深度复制 + * @author banjuer@outlook.com + * @Time 2018年5月9日 下午3:54:57 + */ + T[] convert(S[] s, Class clz); + + /** + * 分页信息转换 + * @return {@link PageResult} + */ + PageResult convertPageInfo(PageInfo s, Class clz); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/AfterSalesStatusEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/AfterSalesStatusEnum.java new file mode 100644 index 00000000..5ff32dfd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/AfterSalesStatusEnum.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * 售后状态枚举 + * + * @author hupeng + * @date 2021/12/21 + */ +@Getter +@AllArgsConstructor +public enum AfterSalesStatusEnum { + + STATUS_0(0,"已提交等待平台审核"), + STATUS_1(1,"平台已审核,等待用户发货/退款"), + STATUS_2(2,"用户已发货"), + STATUS_3(3,"已完成"); + + private Integer value; + private String desc; + + public static AfterSalesStatusEnum toType(int value) { + return Stream.of(AfterSalesStatusEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/AppFromEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/AppFromEnum.java new file mode 100644 index 00000000..46b5165d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/AppFromEnum.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 应用来源相关枚举 + */ +@Getter +@AllArgsConstructor +public enum AppFromEnum { + + WEIXIN_H5("weixinh5","weixinh5"), + H5("h5","H5"), + WECHAT("wechat","公众号"), + APP("app","APP"), + PC("pc","PC"), + ROUNTINE("routine","小程序"), + UNIAPPH5("uniappH5","uniappH5"); + + + private String value; + private String desc; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/BillDetailEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/BillDetailEnum.java new file mode 100644 index 00000000..d4521f2a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/BillDetailEnum.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 账单明细相关枚举 + */ +@Getter +@AllArgsConstructor +public enum BillDetailEnum { + + TYPE_1("recharge","充值"), + TYPE_2("brokerage","返佣"), + TYPE_3("pay_product","消费"), + TYPE_4("extract","提现"), + TYPE_5("pay_product_refund","退款"), + TYPE_6("system_add","系统添加"), + TYPE_7("system_sub","系统减少"), + TYPE_8("deduction","减去"), + TYPE_9("gain","奖励"), + TYPE_10("sign","签到"), + + + CATEGORY_1("now_money","金额"), + CATEGORY_2("integral","积分"); + + + + private String value; + private String desc; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/BillEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/BillEnum.java new file mode 100644 index 00000000..007a4fc9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/BillEnum.java @@ -0,0 +1,44 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 账单相关枚举 + */ +@Getter +@AllArgsConstructor +public enum BillEnum { + + PM_0(0,"支出"), + PM_1(1,"获得"), + + STATUS_0(0,"默认"), + STATUS_1(1,"有效"), + STATUS_2(2,"无效"); + + + + + + private Integer value; + private String desc; + + public static BillEnum toType(int value) { + return Stream.of(BillEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/BillInfoEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/BillInfoEnum.java new file mode 100644 index 00000000..a34af24a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/BillInfoEnum.java @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 账单相关枚举 + */ +@Getter +@AllArgsConstructor +public enum BillInfoEnum { + + DEAFUL_ALL(0,"所有"), + PAY_PRODUCT(1,"消费"), + RECHAREGE(2,"充值"), + BROKERAGE(3,"返佣"), + EXTRACT(4,"提现"), + SIGN_INTEGRAL(5,"签到积分"), + PAY_PRODUCT_REFUND(6,"退款"), + SYSTEM_ADD(7,"系统添加"), + SYSTEM_SUB(8,"系统减少"); + + + + private Integer value; + private String desc; + + public static BillInfoEnum toType(int value) { + return Stream.of(BillInfoEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/Brokerage.java b/zsw-bxg/src/main/java/co/yixiang/enums/Brokerage.java new file mode 100644 index 00000000..f7b883ed --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/Brokerage.java @@ -0,0 +1,20 @@ +package co.yixiang.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 分销级别 + */ +@Getter +@AllArgsConstructor +public enum Brokerage { + + LEVEL_1(1,"一级"), + LEVEL_2(2,"二级"); + + private Integer value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/CartTypeEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/CartTypeEnum.java new file mode 100644 index 00000000..b1f23373 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/CartTypeEnum.java @@ -0,0 +1,18 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 优惠券类型枚举 + */ +@Getter +@AllArgsConstructor +public enum CartTypeEnum { + NEW_0(0,"加入购物车"), + NEW_1(1,"加入购物车直接购买"); + + private Integer value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/CommonEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/CommonEnum.java new file mode 100644 index 00000000..23c2de5d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/CommonEnum.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 通用枚举 + */ +@Getter +@AllArgsConstructor +public enum CommonEnum { + + DEL_STATUS_0(0,"未删除"), + DEL_STATUS_1(1,"已删除"), + + SHOW_STATUS_0(0,"未显示"), + SHOW_STATUS_1(1,"显示"); + + + private Integer value; + private String desc; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/CouponEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/CouponEnum.java new file mode 100644 index 00000000..35f2e06e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/CouponEnum.java @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 优惠券相关枚举 + */ +@Getter +@AllArgsConstructor +public enum CouponEnum { + + FALI_0(0,"有效"), + FALI_1(1,"无效"), + + USE_0(0,"不可用"), + USE_1(1,"可用"), + + STATUS_0(0,"未使用"), + STATUS_1(1,"已使用"), + STATUS_2(2,"已过期"), + + TYPE_0(0,"通用券"), + TYPE_1(1,"商品券"), + TYPE_2(2,"内部券"), + + PERMANENT_0(0,"限量"), + PERMANENT_1(1,"不限量"); + + + + + private Integer value; + private String desc; + + public static CouponEnum toType(int value) { + return Stream.of(CouponEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/CouponGetEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/CouponGetEnum.java new file mode 100644 index 00000000..06d3681b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/CouponGetEnum.java @@ -0,0 +1,18 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 优惠券获取类型枚举 + */ +@Getter +@AllArgsConstructor +public enum CouponGetEnum { + GET("get","领取"), + SEND("send","派送"); + + private String value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/DataSourceType.java b/zsw-bxg/src/main/java/co/yixiang/enums/DataSourceType.java new file mode 100644 index 00000000..c8ebe031 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/DataSourceType.java @@ -0,0 +1,18 @@ +package co.yixiang.enums; + +/** + * 数据源 + * @author hupeng + */ +public enum DataSourceType +{ + /** + * 主库 + */ + MASTER, + + /** + * 从库 + */ + SLAVE +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/LiveGoodsEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/LiveGoodsEnum.java new file mode 100644 index 00000000..d4973a80 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/LiveGoodsEnum.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 直播商品相关枚举 + */ +@Getter +@AllArgsConstructor +public enum LiveGoodsEnum { + + IS_Audit_0(0,"未审核"), + IS_Audit_1(1,"审核中"), + IS_Audit_2(2,"审核通过"), + IS_Audit_3(3,"审核失败"); + + private Integer value; + private String desc; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/OrderCountEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/OrderCountEnum.java new file mode 100644 index 00000000..085999e0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/OrderCountEnum.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 订单相关枚举 + */ +@Getter +@AllArgsConstructor +public enum OrderCountEnum { + + TODAY(1,"今天"), + YESTERDAY(2,"昨天"), + WEEK(3,"上周"), + MONTH(4,"本月"); + + + + private Integer value; + private String desc; + + public static OrderCountEnum toType(int value) { + return Stream.of(OrderCountEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/OrderInfoEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/OrderInfoEnum.java new file mode 100644 index 00000000..d9d4e586 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/OrderInfoEnum.java @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 订单相关枚举 + */ +@Getter +@AllArgsConstructor +public enum OrderInfoEnum { + + STATUS_NE1(-1,"申请退款"), + STATUS_NE2(-2,"退款成功"), + STATUS_0(0,"默认"), + STATUS_1(1,"待收货"), + STATUS_2(2,"已收货"), + STATUS_3(3,"已完成"), + + PAY_STATUS_0(0,"未支付"), + PAY_STATUS_1(1,"已支付"), + + REFUND_STATUS_0(0,"正常"), + REFUND_STATUS_1(1,"退款中"), + REFUND_STATUS_2(2,"已退款"), + + BARGAIN_STATUS_1(1,"参与中"), + BARGAIN_STATUS_2(2,"参与失败"), + BARGAIN_STATUS_3(3,"参与成功"), + + PINK_STATUS_1(1,"进行中"), + PINK_STATUS_2(2,"已完成"), + PINK_STATUS_3(3,"未完成"), + + PINK_REFUND_STATUS_0(0,"拼团正常"), + PINK_REFUND_STATUS_1(1,"拼团已退款"), + + CANCEL_STATUS_0(0,"正常"), + CANCEL_STATUS_1(1,"已取消"), + + CONFIRM_STATUS_0(0,"正常"), + CONFIRM_STATUS_1(1,"确认"), + + PAY_CHANNEL_0(0,"公众号/H5支付渠道"), + PAY_CHANNEL_1(1,"小程序支付渠道"), + + + SHIPPIING_TYPE_1(1,"快递"), + SHIPPIING_TYPE_2(2,"门店自提"); + + + + private Integer value; + private String desc; + + public static OrderInfoEnum toType(int value) { + return Stream.of(OrderInfoEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/OrderLogEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/OrderLogEnum.java new file mode 100644 index 00000000..0db3ad9c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/OrderLogEnum.java @@ -0,0 +1,49 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 订单操作相关枚举 + */ +@Getter +@AllArgsConstructor +public enum OrderLogEnum { + + PINK_ORDER_FAIL_1("ORDER_EXIST","订单生成失败,你已经参加该团了,请先支付订单"), + PINK_ORDER_FAIL_2("ORDER_EXIST","订单生成失败,你已经在该团内不能再参加了"), + REFUND_ORDER_SUCCESS("refund_price_success","退款成功"), + ORDER_EDIT("order_edit","订单改价"), + REMOVE_ORDER("remove_order","删除订单"), + EVAL_ORDER("order_eval","用户评价"), + REFUND_ORDER_APPLY("apply_refund","用户申请退款"), + TAKE_ORDER_DELIVERY("user_take_delivery","用户已收货"), + PAY_ORDER_FAIL("PAY_DEFICIENCY","余额不足"), + PAY_ORDER_SUCCESS("pay_success","用户付款成功"), + CREATE_ORDER_SUCCESS("SUCCESS","订单创建成功"), + CREATE_ORDER("yshop_create_order","订单生成"), + NONE_ORDER("NONE","订单OK"), + DELIVERY_GOODS("delivery_goods", "订单发货"), + EXTEND_ORDER("EXTEND_ORDER","订单已生成"); + + + private String value; + private String desc; + + + + public static OrderLogEnum toType(String value) { + return Stream.of(OrderLogEnum.values()) + .filter(p -> p.value.equals(value)) + .findAny() + .orElse(null); + } + + public static String getDesc(String value) { + return toType(value) == null ? null : toType(value).desc; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/OrderStatusEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/OrderStatusEnum.java new file mode 100644 index 00000000..6fc04fd9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/OrderStatusEnum.java @@ -0,0 +1,44 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 订单相关枚举 + */ +@Getter +@AllArgsConstructor +public enum OrderStatusEnum { + + STATUS__1(-1,"全部订单"), + STATUS_0(0,"未支付"), + STATUS_1(1,"待发货"), + STATUS_2(2,"待收货"), + STATUS_3(3,"待评价"), + STATUS_4(4,"已完成"), + STATUS_MINUS_1(-1,"退款中"), + STATUS_MINUS_2(-2,"已退款"), + STATUS_MINUS_3(-3,"退款"); + + + + private Integer value; + private String desc; + + public static OrderStatusEnum toType(int value) { + return Stream.of(OrderStatusEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/PayMethodEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/PayMethodEnum.java new file mode 100644 index 00000000..4ab54d24 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/PayMethodEnum.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 支付相关枚举 + */ +@Getter +@AllArgsConstructor +public enum PayMethodEnum { + + WECHAT("wechat","公众号支付"), + WXAPP("wxapp","小程序支付"), + APP("app","app支付"); + + + private String value; + private String desc; + + public static PayMethodEnum toType(String value) { + return Stream.of(PayMethodEnum.values()) + .filter(p -> p.value.equals(value)) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/PayTypeEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/PayTypeEnum.java new file mode 100644 index 00000000..046117df --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/PayTypeEnum.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 支付相关枚举 + */ +@Getter +@AllArgsConstructor +public enum PayTypeEnum { + + ALI("alipay","支付宝支付"), + WEIXIN("weixin","微信支付"), + YUE("yue","余额支付"), + INTEGRAL("integral","积分兑换"); + + + private String value; + private String desc; + + public static PayTypeEnum toType(String value) { + return Stream.of(PayTypeEnum.values()) + .filter(p -> p.value.equals(value)) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/PinkEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/PinkEnum.java new file mode 100644 index 00000000..78d1ed8f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/PinkEnum.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 拼团相关枚举 + */ +@Getter +@AllArgsConstructor +public enum PinkEnum { + + IS_OK_0(0,"未完成"), + IS_OK_1(1,"已完成"), + + PINK_BOOL_0(0,"未成功,进行中"), + PINK_BOOL_1(1,"已成功"), + PINK_BOOL_MINUS_1(-1,"拼团失败"), + + USER_BOOL_0(0,"不在团内"), + USER_BOOL_1(1,"在团内"); + + private Integer value; + private String desc; + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/ProductEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/ProductEnum.java new file mode 100644 index 00000000..010804b0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/ProductEnum.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * 产品相关枚举 + */ +@Getter +@AllArgsConstructor +public enum ProductEnum { + + TYPE_1(1,"精品推荐"), + TYPE_2(2,"热门榜单"), + TYPE_3(3,"首发新品"), + TYPE_4(4,"猜你喜欢"); + + + private Integer value; + private String desc; + + public static ProductEnum toType(int value) { + return Stream.of(ProductEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/ProductTypeEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/ProductTypeEnum.java new file mode 100644 index 00000000..7526ee99 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/ProductTypeEnum.java @@ -0,0 +1,24 @@ +package co.yixiang.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 产品类型枚举 + */ + +@Getter +@AllArgsConstructor +public enum ProductTypeEnum { + + PINK("pink","拼团"), + + SECKILL("seckill","秒杀"), + + COMBINATION("combination","拼团产品"); + + private String value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/RedisKeyEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/RedisKeyEnum.java new file mode 100644 index 00000000..bc3caa7e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/RedisKeyEnum.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * rediskey 相关枚举 + */ +@Getter +@AllArgsConstructor +public enum RedisKeyEnum { + + WXAPP_APPID("wxapp_appId","微信小程序id"), + WXAPP_SECRET("wxapp_secret","微信小程序秘钥"), + WX_NATIVE_APP_APPID("wx_native_app_appId","支付appId"), + WXPAY_MCHID("wxpay_mchId","商户号"), + WXPAY_MCHKEY("wxpay_mchKey","商户秘钥"), + WXPAY_KEYPATH("wxpay_keyPath","商户证书路径"), + WECHAT_APPID("wechat_appid","微信公众号id"), + WECHAT_APPSECRET("wechat_appsecret","微信公众号secret"), + WECHAT_TOKEN("wechat_token","微信公众号验证token"), + WECHAT_ENCODINGAESKEY("wechat_encodingaeskey","EncodingAESKey"), + TENGXUN_MAP_KEY("tengxun_map_key","腾讯mapkey"); + + private String value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/ShipperCodeEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/ShipperCodeEnum.java new file mode 100644 index 00000000..3ad3631f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/ShipperCodeEnum.java @@ -0,0 +1,18 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 快递公司编码相关枚举 + */ +@Getter +@AllArgsConstructor +public enum ShipperCodeEnum { + + SF("SF","顺丰速运"); + + private String value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/ShippingTempEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/ShippingTempEnum.java new file mode 100644 index 00000000..bfd87b65 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/ShippingTempEnum.java @@ -0,0 +1,20 @@ +package co.yixiang.enums; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 运费模板类型枚举 + */ +@Getter +@AllArgsConstructor +public enum ShippingTempEnum { + TYPE_1(1,"按件数"), + TYPE_2(2,"按重量"), + TYPE_3(3,"按体积"); + + private Integer value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/ShopCommonEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/ShopCommonEnum.java new file mode 100644 index 00000000..6d109250 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/ShopCommonEnum.java @@ -0,0 +1,73 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 商城常用枚举 + */ +@Getter +@AllArgsConstructor +public enum ShopCommonEnum { + + STORE_MODE_1(1,"本地存储"), + STORE_MODE_2(2,"云存储"), + + ENABLE_1(1,"开启"), + ENABLE_2(2,"关闭"), + + EXTRACT_MINUS_1(-1,"提现未通过"), + EXTRACT_0(0,"提现审核中"), + EXTRACT_1(1,"提现已完成"), + + IS_FINISH_0(0,"未完成"), + IS_FINISH_1(1,"已完成"), + + IS_FOREVER_0(0,"不是永久"), + IS_FOREVER_1(1,"永久"), + + AGREE_1(1,"同意"), + AGREE_2(2,"拒绝"), + + IS_PERMANENT_0(0,"限制"), + IS_PERMANENT_1(1,"不限制"), + + IS_STATUS_0(0,"否"), + IS_STATUS_1(1,"是"), + + + IS_PROMOTER_0(0,"默认"), + IS_PROMOTER_1(1,"是客服"), + + IS_NEW_0(0,"默认"), + IS_NEW_1(1,"新品"), + + IS_SUB_0(0,"不单独分佣"), + IS_SUB_1(1,"单独分佣"), + + + GRADE_0(0,"一级推荐人"), + GRADE_1(1,"二级推荐人"), + + REPLY_0(0,"未回复"), + REPLY_1(1,"已回复"), + + ADD_1(1,"增加"), + ADD_2(2,"减少"), + + DELETE_0(0,"未删除"), + DELETE_1(1,"已删除"), + + SHOW_0(0,"不显示"), + SHOW_1(1,"显示"), + + DEFAULT_0(0,"不是默认"), + DEFAULT_1(1,"默认"); + + + + + private Integer value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/SortEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/SortEnum.java new file mode 100644 index 00000000..6ed8fa94 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/SortEnum.java @@ -0,0 +1,31 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + +/** + * @author hupeng + * sort关枚举 + */ +@Getter +@AllArgsConstructor +public enum SortEnum { + + DESC("desc","降序"), + ASC("asc","升序"); + + + private String value; + private String desc; + + public static SortEnum toType(String value) { + return Stream.of(SortEnum.values()) + .filter(p -> p.value == value) + .findAny() + .orElse(null); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/enums/SpecTypeEnum.java b/zsw-bxg/src/main/java/co/yixiang/enums/SpecTypeEnum.java new file mode 100644 index 00000000..5a0240ba --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/enums/SpecTypeEnum.java @@ -0,0 +1,18 @@ +package co.yixiang.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 产品相关规格类型枚举 + */ +@Getter +@AllArgsConstructor +public enum SpecTypeEnum { + TYPE_0(0,"单规格"), + TYPE_1(1,"多规格"); + + private Integer value; + private String desc; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java b/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java new file mode 100644 index 00000000..f08e4fa2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/event/TemplateBean.java @@ -0,0 +1,33 @@ +package co.yixiang.event; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * @ClassName TemplateBean + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/6 + **/ +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TemplateBean { + private String templateType; + private String orderId; + private String time; + private String price; + private String deliveryName; + private String deliveryId; + private String payType; + private Long uid; + /** + * 提现申请ID + */ + private Long extractId; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/event/TemplateEvent.java b/zsw-bxg/src/main/java/co/yixiang/event/TemplateEvent.java new file mode 100644 index 00000000..d89cca92 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/event/TemplateEvent.java @@ -0,0 +1,23 @@ +package co.yixiang.event; + +import lombok.Getter; +import org.springframework.context.ApplicationEvent; + +/** + * @author hupeng + * 微信模板事件 + */ +@Getter +public class TemplateEvent extends ApplicationEvent { + + private TemplateBean templateBean; + /** + * 重写构造函数 + * @param source 发生事件的对象 + * @param templateBean 自定义 + */ + public TemplateEvent(Object source,TemplateBean templateBean) { + super(source); + this.templateBean = templateBean; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java b/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java new file mode 100644 index 00000000..9dc68b5d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/event/TemplateListenEnum.java @@ -0,0 +1,35 @@ +package co.yixiang.event; + + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.stream.Stream; + + +/** + * @author hupeng + * 模板监听枚举 + */ +@Getter +@AllArgsConstructor +public enum TemplateListenEnum { + TYPE_1("1","支付成功模板通知"), + TYPE_2("2","退款成功通知"), + TYPE_3("3","发货成功通知"), + TYPE_4("4","充值成功通知"), + TYPE_5("5","在线买单/收款成功通知"), + TYPE_6("6","商家收款通知"), + TYPE_7("7","用户下单未支付通知"), + TYPE_8("8","用户提现通知"), + TYPE_9("9","退款申请通知"); + private String value; + private String desc; + + public static TemplateListenEnum toType(String value) { + return Stream.of(TemplateListenEnum.values()) + .filter(p -> p.value.equals(value)) + .findAny() + .orElse(null); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/exception/BadLimitRequestException.java b/zsw-bxg/src/main/java/co/yixiang/exception/BadLimitRequestException.java new file mode 100644 index 00000000..b15d36f5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/exception/BadLimitRequestException.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.exception; + +import co.yixiang.api.ApiCode; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +/** + * @author Zheng Jie + * @date 2018-11-23 + * 统一异常处理 + */ +@Getter +public class BadLimitRequestException extends RuntimeException{ + + private Integer status = ApiCode.BAD_LIMIT_EXCEPTION.getCode(); + + public BadLimitRequestException(String msg){ + super(msg); + } + + public BadLimitRequestException(HttpStatus status, String msg){ + super(msg); + this.status = status.value(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/exception/BadRequestException.java b/zsw-bxg/src/main/java/co/yixiang/exception/BadRequestException.java new file mode 100644 index 00000000..df2f728c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/exception/BadRequestException.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.exception; + +import lombok.Getter; +import org.springframework.http.HttpStatus; + +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +/** + * @author Zheng Jie + * @date 2018-11-23 + * 统一异常处理 + */ +@Getter +public class BadRequestException extends RuntimeException{ + + private Integer status = BAD_REQUEST.value(); + + public BadRequestException(String msg){ + super(msg); + } + + public BadRequestException(HttpStatus status,String msg){ + super(msg); + this.status = status.value(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/exception/EntityExistException.java b/zsw-bxg/src/main/java/co/yixiang/exception/EntityExistException.java new file mode 100644 index 00000000..7ea01a9f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/exception/EntityExistException.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.exception; + +import org.springframework.util.StringUtils; + +/** + * @author Zheng Jie + * @date 2018-11-23 + */ +public class EntityExistException extends RuntimeException { + + public EntityExistException(Class clazz, String field, String val) { + super(EntityExistException.generateMessage(clazz.getSimpleName(), field, val)); + } + + private static String generateMessage(String entity, String field, String val) { + return StringUtils.capitalize(entity) + + " with " + field + " "+ val + " existed"; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/exception/EntityNotFoundException.java b/zsw-bxg/src/main/java/co/yixiang/exception/EntityNotFoundException.java new file mode 100644 index 00000000..cde4d3f1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/exception/EntityNotFoundException.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.exception; + +import org.springframework.util.StringUtils; + +/** + * @author Zheng Jie + * @date 2018-11-23 + */ +public class EntityNotFoundException extends RuntimeException { + + public EntityNotFoundException(Class clazz, String field, String val) { + super(EntityNotFoundException.generateMessage(clazz.getSimpleName(), field, val)); + } + + private static String generateMessage(String entity, String field, String val) { + return StringUtils.capitalize(entity) + + " with " + field + " "+ val + " does not exist"; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/exception/ErrorRequestException.java b/zsw-bxg/src/main/java/co/yixiang/exception/ErrorRequestException.java new file mode 100644 index 00000000..b8146456 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/exception/ErrorRequestException.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.exception; + +import lombok.Getter; +import org.springframework.http.HttpStatus; + +import static org.springframework.http.HttpStatus.BAD_REQUEST; + +/** + * @author hupeng + * @date 2019-11-11 + * 统一异常处理 + */ +@Getter +public class ErrorRequestException extends RuntimeException{ + + private Integer status = BAD_REQUEST.value(); + + public ErrorRequestException(String msg){ + super(msg); + } + + public ErrorRequestException(HttpStatus status, String msg){ + super(msg); + this.status = status.value(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/handler/ApiErr.java b/zsw-bxg/src/main/java/co/yixiang/handler/ApiErr.java new file mode 100644 index 00000000..494247ba --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/handler/ApiErr.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.handler; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author hupeng + * @since 2019-10-02 + */ +@Data +class ApiErr { + + private Integer status; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime timestamp; + private String msg; + + private ApiErr() { + timestamp = LocalDateTime.now(); + } + + public ApiErr(Integer status, String message) { + this(); + this.status = status; + this.msg = message; + } +} + + diff --git a/zsw-bxg/src/main/java/co/yixiang/handler/ApiError.java b/zsw-bxg/src/main/java/co/yixiang/handler/ApiError.java new file mode 100644 index 00000000..9c5dbef3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/handler/ApiError.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.handler; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author Zheng Jie + * @date 2018-11-23 + */ +@Data +class ApiError { + + private Integer status = 400; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime timestamp; + private String message; + + private ApiError() { + timestamp = LocalDateTime.now(); + } + + public static ApiError error(String message){ + ApiError apiError = new ApiError(); + apiError.setMessage(message); + return apiError; + } + + public static ApiError error(Integer status, String message){ + ApiError apiError = new ApiError(); + apiError.setStatus(status); + apiError.setMessage(message); + return apiError; + } +} + + diff --git a/zsw-bxg/src/main/java/co/yixiang/handler/GlobalExceptionHandler.java b/zsw-bxg/src/main/java/co/yixiang/handler/GlobalExceptionHandler.java new file mode 100644 index 00000000..b53761f4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/handler/GlobalExceptionHandler.java @@ -0,0 +1,130 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.handler; +// +//import co.yixiang.exception.BadRequestException; +//import co.yixiang.exception.EntityExistException; +//import co.yixiang.exception.EntityNotFoundException; +//import co.yixiang.exception.ErrorRequestException; +//import co.yixiang.utils.ThrowableUtil; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.http.HttpStatus; +//import org.springframework.http.ResponseEntity; +//import org.springframework.security.authentication.BadCredentialsException; +//import org.springframework.web.bind.MethodArgumentNotValidException; +//import org.springframework.web.bind.annotation.ExceptionHandler; +//import org.springframework.web.bind.annotation.RestControllerAdvice; +// +//import java.util.Objects; +// +//import static org.springframework.http.HttpStatus.NOT_FOUND; +//import static org.springframework.http.HttpStatus.valueOf; +// +///** +// * @author Zheng Jie +// * @date 2018-11-23 +// */ +//@Slf4j +//@RestControllerAdvice +//@SuppressWarnings("unchecked") +//public class GlobalExceptionHandler { +// +// /** +// * 处理所有不可知的异常 +// */ +// @ExceptionHandler(Throwable.class) +// public ResponseEntity handleException(Throwable e){ +// // 打印堆栈信息 +// log.error(ThrowableUtil.getStackTrace(e)); +// return buildResponseEntity(ApiError.error(e.getMessage())); +// } +// +// /** +// * BadCredentialsException +// */ +// @ExceptionHandler(BadCredentialsException.class) +// public ResponseEntity badCredentialsException(BadCredentialsException e){ +// // 打印堆栈信息 +// String message = "坏的凭证".equals(e.getMessage()) ? "用户名或密码不正确" : e.getMessage(); +// log.error(message); +// return buildResponseEntity(ApiError.error(message)); +// } +// +// /** +// * 处理自定义异常 +// */ +// @ExceptionHandler(value = BadRequestException.class) +// public ResponseEntity badRequestException(BadRequestException e) { +// // 打印堆栈信息 +// log.error(ThrowableUtil.getStackTrace(e)); +// return buildResponseEntity(ApiError.error(e.getStatus(),e.getMessage())); +// } +// +// /** +// * 处理自定义异常 +// * @param e +// * @return +// */ +// @ExceptionHandler(value = ErrorRequestException.class) +// public ResponseEntity errorRequestException(ErrorRequestException e) { +// // 打印堆栈信息 +// log.error(ThrowableUtil.getStackTrace(e)); +// ApiErr apiError = new ApiErr(e.getStatus(),e.getMessage()); +// return buildResponseEntity2(apiError); +// } +// +// /** +// * 处理 EntityExist +// */ +// @ExceptionHandler(value = EntityExistException.class) +// public ResponseEntity entityExistException(EntityExistException e) { +// // 打印堆栈信息 +// log.error(ThrowableUtil.getStackTrace(e)); +// return buildResponseEntity(ApiError.error(e.getMessage())); +// } +// +// /** +// * 处理 EntityNotFound +// */ +// @ExceptionHandler(value = EntityNotFoundException.class) +// public ResponseEntity entityNotFoundException(EntityNotFoundException e) { +// // 打印堆栈信息 +// log.error(ThrowableUtil.getStackTrace(e)); +// return buildResponseEntity(ApiError.error(NOT_FOUND.value(),e.getMessage())); +// } +// +// /** +// * 处理所有接口数据验证异常 +// */ +// @ExceptionHandler(MethodArgumentNotValidException.class) +// public ResponseEntity handleMethodArgumentNotValidException(MethodArgumentNotValidException e){ +// // 打印堆栈信息 +// log.error(ThrowableUtil.getStackTrace(e)); +// String[] str = Objects.requireNonNull(e.getBindingResult().getAllErrors().get(0).getCodes())[1].split("\\."); +// String message = e.getBindingResult().getAllErrors().get(0).getDefaultMessage(); +// String msg = "不能为空"; +// if(msg.equals(message)){ +// message = str[1] + ":" + message; +// } +// return buildResponseEntity(ApiError.error(message)); +// } +// +// /** +// * 统一返回 +// */ +// private ResponseEntity buildResponseEntity(ApiError apiError) { +// return new ResponseEntity<>(apiError, valueOf(apiError.getStatus())); +// } +// +// /** +// * 统一返回 +// * @param apiError +// * @return +// */ +// private ResponseEntity buildResponseEntity2(ApiErr apiError) { +// return new ResponseEntity(apiError, HttpStatus.valueOf(apiError.getStatus())); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/aop/log/AppLog.java b/zsw-bxg/src/main/java/co/yixiang/logging/aop/log/AppLog.java new file mode 100644 index 00000000..9f80dc45 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/aop/log/AppLog.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.aop.log; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author hupeng + * @date 2018-11-24 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface AppLog { + String value() default ""; + int type() default 0; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/aop/log/Log.java b/zsw-bxg/src/main/java/co/yixiang/logging/aop/log/Log.java new file mode 100644 index 00000000..1e1ae507 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/aop/log/Log.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.aop.log; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author hupeng + * @date 2018-11-24 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Log { + String value() default ""; + int type() default 0; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/domain/Log.java b/zsw-bxg/src/main/java/co/yixiang/logging/domain/Log.java new file mode 100644 index 00000000..536cba5e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/domain/Log.java @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.domain; + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * @author hupeng + * @date 2018-11-24 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("log") +@NoArgsConstructor +public class Log extends BaseDomain { + + @TableId + private Long id; + + /** 操作用户 */ + private String username; + + @TableField(exist = false) + private String nickname; + + /** 描述 */ + private String description; + + /** 方法名 */ + private String method; + + private Long uid; + + private Integer type; + + /** 参数 */ + private String params; + + /** 日志类型 */ + private String logType; + + /** 请求ip */ + private String requestIp; + + /** 地址 */ + private String address; + + /** 浏览器 */ + private String browser; + + /** 请求耗时 */ + private Long time; + + /** 异常详细 */ + private byte[] exceptionDetail; + + + public Log(String logType, Long time) { + this.logType = logType; + this.time = time; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/service/LogService.java b/zsw-bxg/src/main/java/co/yixiang/logging/service/LogService.java new file mode 100644 index 00000000..fbded299 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/service/LogService.java @@ -0,0 +1,94 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.logging.domain.Log; +import co.yixiang.logging.service.dto.LogQueryCriteria; +import org.aspectj.lang.ProceedingJoinPoint; +import org.springframework.data.domain.Pageable; +import org.springframework.scheduling.annotation.Async; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * @author hupeng + * @date 2018-11-24 + */ +public interface LogService extends BaseService { + + + + Object findAllByPageable(String nickname, Pageable pageable); + /** + * 分页查询 + * @param criteria 查询条件 + * @param pageable 分页参数 + * @return / + */ + Object queryAll(LogQueryCriteria criteria, Pageable pageable); + + /** + * 查询全部数据 + * @param criteria 查询条件 + * @return / + */ + List queryAll(LogQueryCriteria criteria); + + /** + * 查询用户日志 + * @param criteria 查询条件 + * @param pageable 分页参数 + * @return - + */ + Object queryAllByUser(LogQueryCriteria criteria, Pageable pageable); + + /** + * 保存日志数据 + * @param username 用户 + * @param ip 请求IP + * @param joinPoint / + * @param log 日志实体 + */ + @Async + void save(String username, String ip, ProceedingJoinPoint joinPoint, Log log,Long uid); + + /** + * 保存app日志数据 + * @param username 用户 + * @param ip 请求IP + * @param joinPoint / + * @param log 日志实体 + */ + @Async + void saveApp(String username, String ip, ProceedingJoinPoint joinPoint, Log log,Long uid); + /** + * 查询异常详情 + * @param id 日志ID + * @return Object + */ + Object findByErrDetail(Long id); + + /** + * 导出日志 + * @param logs 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List logs, HttpServletResponse response) throws IOException; + + /** + * 删除所有错误日志 + */ + void delAllByError(); + + /** + * 删除所有INFO日志 + */ + void delAllByInfo(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogErrorDTO.java b/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogErrorDTO.java new file mode 100644 index 00000000..8ac20a32 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogErrorDTO.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2019-5-22 +*/ +@Data +public class LogErrorDTO implements Serializable { + + private Long id; + + private String username; + + private String description; + + private String method; + + private String params; + + private String browser; + + private String requestIp; + + private String address; + + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogQueryCriteria.java new file mode 100644 index 00000000..be0045d8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogQueryCriteria.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** + * 日志查询类 + * @author hupeng + * @date 2019-6-4 09:23:07 + */ +@Data +public class LogQueryCriteria { + + @Query(blurry = "username,description,address,requestIp,method,params") + private String blurry; + + @Query + private String logType; + + @Query(type = Query.Type.BETWEEN) + private List createTime; + + + @Query + private Integer type; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogSmallDTO.java b/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogSmallDTO.java new file mode 100644 index 00000000..fe93bb93 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/service/dto/LogSmallDTO.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * @author hupeng + * @date 2019-5-22 + */ +@Data +public class LogSmallDTO implements Serializable { + + private String description; + + private String requestIp; + + private Long time; + + private String address; + + private String browser; + + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/service/impl/LogServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/logging/service/impl/LogServiceImpl.java new file mode 100644 index 00000000..ccb3f1da --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/service/impl/LogServiceImpl.java @@ -0,0 +1,238 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.service.impl; + +import cn.hutool.core.lang.Dict; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONObject; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.logging.service.LogService; +import co.yixiang.logging.service.dto.LogErrorDTO; +import co.yixiang.logging.service.dto.LogQueryCriteria; +import co.yixiang.logging.service.dto.LogSmallDTO; +import co.yixiang.logging.service.mapper.LogMapper; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.StringUtils; +import co.yixiang.utils.ValidationUtil; +import com.github.pagehelper.PageInfo; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author hupeng + * @date 2018-11-24 + */ +@SuppressWarnings("unchecked") +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class LogServiceImpl extends BaseServiceImpl implements LogService { + + + private final LogMapper logMapper; + + private final IGenerator generator; + + public LogServiceImpl(LogMapper logMapper, IGenerator generator) { + this.logMapper = logMapper; + this.generator = generator; + } + + @Override + public Object findAllByPageable(String nickname, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(logMapper.findAllByPageable(nickname)); + Map map = new LinkedHashMap<>(2); + map.put("content",page.getList()); + map.put("totalElements",page.getTotal()); + return map; + } + + + @Override + public Object queryAll(LogQueryCriteria criteria, Pageable pageable){ + + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + String status = "ERROR"; + if(status.equals(criteria.getLogType())){ + map.put("content", generator.convert(page.getList(), LogErrorDTO.class)); + map.put("totalElements", page.getTotal()); + } + map.put("content", page.getList()); + map.put("totalElements", page.getTotal()); + return map; + } + + @Override + public List queryAll(LogQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(co.yixiang.logging.domain.Log.class, criteria)); + } + + @Override + public Object queryAllByUser(LogQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), LogSmallDTO.class)); + map.put("totalElements", page.getTotal()); + return map; + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(String username, String ip, ProceedingJoinPoint joinPoint, + co.yixiang.logging.domain.Log log, Long uid){ + + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + Log aopLog = method.getAnnotation(Log.class); + + // 方法路径 + String methodName = joinPoint.getTarget().getClass().getName()+"."+signature.getName()+"()"; + + StringBuilder params = new StringBuilder("{"); + //参数值 + Object[] argValues = joinPoint.getArgs(); + //参数名称 + String[] argNames = ((MethodSignature)joinPoint.getSignature()).getParameterNames(); + if(argValues != null){ + for (int i = 0; i < argValues.length; i++) { + params.append(" ").append(argNames[i]).append(": ").append(argValues[i]); + } + } + // 描述 + if (log != null) { + log.setDescription(aopLog.value()); + } + //类型 0-后台 1-前台 + log.setType(aopLog.type()); + if(uid != null) { + log.setUid(uid); + } + assert log != null; + log.setRequestIp(ip); + + String loginPath = "login"; + if(loginPath.equals(signature.getName())){ + try { + assert argValues != null; + username = new JSONObject(argValues[0]).get("username").toString(); + }catch (Exception e){ + e.printStackTrace(); + } + } + log.setAddress(StringUtils.getCityInfo(log.getRequestIp())); + log.setMethod(methodName); + log.setUsername(username); + log.setParams(params.toString() + " }"); + this.save(log); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveApp(String username, String ip, ProceedingJoinPoint joinPoint, + co.yixiang.logging.domain.Log log, Long uid){ + + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + AppLog aopLog = method.getAnnotation(AppLog.class); + + // 方法路径 + String methodName = joinPoint.getTarget().getClass().getName()+"."+signature.getName()+"()"; + + StringBuilder params = new StringBuilder("{"); + //参数值 + Object[] argValues = joinPoint.getArgs(); + //参数名称 + String[] argNames = ((MethodSignature)joinPoint.getSignature()).getParameterNames(); + if(argValues != null){ + for (int i = 0; i < argValues.length; i++) { + params.append(" ").append(argNames[i]).append(": ").append(argValues[i]); + } + } + // 描述 + if (log != null) { + log.setDescription(aopLog.value()); + } + //类型 0-后台 1-前台 + log.setType(aopLog.type()); + if(uid != null) { + log.setUid(uid); + } + assert log != null; + log.setRequestIp(ip); + + String loginPath = "login"; + if(loginPath.equals(signature.getName())){ + try { + assert argValues != null; + username = new JSONObject(argValues[0]).get("username").toString(); + }catch (Exception e){ + e.printStackTrace(); + } + } + log.setAddress(StringUtils.getCityInfo(log.getRequestIp())); + log.setMethod(methodName); + log.setUsername(username); + log.setParams(params.toString() + " }"); + this.save(log); + } + @Override + public Object findByErrDetail(Long id) { + co.yixiang.logging.domain.Log log = this.getById(id); + ValidationUtil.isNull( log.getId(),"Log","id", id); + byte[] details = log.getExceptionDetail(); + return Dict.create().set("exception",new String(ObjectUtil.isNotNull(details) ? details : "".getBytes())); + } + + @Override + public void download(List logs, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (co.yixiang.logging.domain.Log log : logs) { + Map map = new LinkedHashMap<>(); + map.put("用户名", log.getUsername()); + map.put("IP", log.getRequestIp()); + map.put("IP来源", log.getAddress()); + map.put("描述", log.getDescription()); + map.put("浏览器", log.getBrowser()); + map.put("请求耗时/毫秒", log.getTime()); + map.put("异常详情", new String(ObjectUtil.isNotNull(log.getExceptionDetail()) ? log.getExceptionDetail() : "".getBytes())); + map.put("创建日期", log.getCreateTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delAllByError() { + logMapper.deleteByLogType("ERROR"); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delAllByInfo() { + logMapper.deleteByLogType("INFO"); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/logging/service/mapper/LogMapper.java b/zsw-bxg/src/main/java/co/yixiang/logging/service/mapper/LogMapper.java new file mode 100644 index 00000000..cd9533ac --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/logging/service/mapper/LogMapper.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.logging.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.logging.domain.Log; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author hupeng + * @date 2019-5-22 + */ +@Repository +@Mapper +public interface LogMapper extends CoreMapper { + + @Delete("delete from log where log_type = #{logType}") + void deleteByLogType(@Param("logType") String logType); + @Select("") + List findAllByPageable(@Param("nickname") String nickname); + @Select( "select count(*) FROM (select request_ip FROM log where create_time between #{date1} and #{date2} GROUP BY request_ip) as s") + long findIp(@Param("date1") String date1, @Param("date2")String date2); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/mapper/EntityMapper.java b/zsw-bxg/src/main/java/co/yixiang/mapper/EntityMapper.java new file mode 100644 index 00000000..62eaec23 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/mapper/EntityMapper.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.mapper; + +import java.util.List; + +/** + * @author Zheng Jie + * @date 2018-11-23 + */ +public interface EntityMapper { + + /** + * DTO转Entity + * @param dto + * @return + */ + E toEntity(D dto); + + /** + * Entity转DTO + * @param entity + * @return + */ + D toDto(E entity); + + /** + * DTO集合转Entity集合 + * @param dtoList + * @return + */ + List toEntity(List dtoList); + + /** + * Entity集合转DTO集合 + * @param entityList + * @return + */ + List toDto(List entityList); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisConfigProperties.java b/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisConfigProperties.java new file mode 100644 index 00000000..9f3071c7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisConfigProperties.java @@ -0,0 +1,32 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.message.redis.config; +// +// +//import lombok.Data; +//import org.springframework.boot.context.properties.ConfigurationProperties; +//import org.springframework.context.annotation.Configuration; +// +// +///** +// * reids相关配置 +// * @author hupeng +// * @since 2020-02-27 +// */ +//@Data +//@Configuration(proxyBeanMethods = false) +//@ConfigurationProperties(prefix = "spring.redis") +//public class RedisConfigProperties { +// +// private String host = "host"; +// private String port = "port"; +// private String password = "password"; +// private String database = "database"; +// +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisKeyInitialization.java b/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisKeyInitialization.java new file mode 100644 index 00000000..a8601098 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisKeyInitialization.java @@ -0,0 +1,59 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.message.redis.config; +// +//import co.yixiang.modules.shop.domain.YxSystemConfig; +//import co.yixiang.modules.shop.service.YxSystemConfigService; +//import co.yixiang.utils.RedisUtils; +//import lombok.RequiredArgsConstructor; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.boot.CommandLineRunner; +//import org.springframework.stereotype.Component; +// +//import java.util.List; +// +// +///** +// * api服务启动初始化reids +// */ +//@Slf4j +//@Component +//@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +//public class RedisKeyInitialization implements CommandLineRunner { +// +// +// private final YxSystemConfigService systemConfigService; +// +// +// private final RedisUtils redisUtils; +// +// +// /** +// * 初始化redis +// */ +// private void redisKeyInitialization(){ +// try { +// List systemConfigs = systemConfigService.list(); +// for (YxSystemConfig systemConfig : systemConfigs) { +// redisUtils.set(systemConfig.getMenuName(),systemConfig.getValue()); +// } +// +// log.info("---------------redisKey初始化成功---------------"); +// }catch (Exception e){ +// log.error("redisKey初始化失败: {}",e.getMessage()); +// } +// +// } +// +// @Override +// public void run(String... args) throws Exception { +// this.redisKeyInitialization(); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisListenerConfig.java b/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisListenerConfig.java new file mode 100644 index 00000000..1ea10bdb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/message/redis/config/RedisListenerConfig.java @@ -0,0 +1,49 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.message.redis.config; +// +// +//import cn.hutool.core.util.StrUtil; +//import co.yixiang.message.redis.listener.RedisKeyExpirationListener; +//import co.yixiang.modules.activity.service.YxStorePinkService; +//import co.yixiang.modules.order.service.YxStoreOrderService; +//import lombok.AllArgsConstructor; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.data.redis.connection.RedisConnectionFactory; +//import org.springframework.data.redis.core.RedisTemplate; +//import org.springframework.data.redis.listener.PatternTopic; +//import org.springframework.data.redis.listener.RedisMessageListenerContainer; +// +///** +// * redis监听配置 +// * @author hupeng +// * @since 2020-02-27 +// */ +// +//@Configuration(proxyBeanMethods = false) +//@AllArgsConstructor +//public class RedisListenerConfig { +// +// private final RedisTemplate stringRedisTemplate; +// private final RedisConfigProperties redisConfigProperties; +// private final YxStoreOrderService storeOrderService; +// private final YxStorePinkService storePinkService; +// +// @Bean +// RedisMessageListenerContainer container(RedisConnectionFactory factory) { +// String topic =StrUtil.format("__keyevent@{}__:expired", redisConfigProperties.getDatabase()); +// RedisMessageListenerContainer container = new RedisMessageListenerContainer(); +// container.setConnectionFactory(factory); +// container.addMessageListener(new RedisKeyExpirationListener(stringRedisTemplate,redisConfigProperties +// ,storeOrderService,storePinkService), new PatternTopic(topic)); +// return container; +// } +//} +// diff --git a/zsw-bxg/src/main/java/co/yixiang/message/redis/listener/RedisKeyExpirationListener.java b/zsw-bxg/src/main/java/co/yixiang/message/redis/listener/RedisKeyExpirationListener.java new file mode 100644 index 00000000..66ceafac --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/message/redis/listener/RedisKeyExpirationListener.java @@ -0,0 +1,109 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// * 注意: +// * 本软件为www.yixiang.co开发研制,未经购买不得使用 +// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +// * 一经发现盗用、分享等行为,将追究法律责任,后果自负 +// */ +//package co.yixiang.message.redis.listener; +// +// +//import cn.hutool.core.util.StrUtil; +//import co.yixiang.constant.ShopConstants; +//import co.yixiang.enums.OrderInfoEnum; +//import co.yixiang.message.redis.config.RedisConfigProperties; +//import co.yixiang.modules.activity.domain.YxStorePink; +//import co.yixiang.modules.activity.service.YxStorePinkService; +//import co.yixiang.modules.order.domain.YxStoreOrder; +//import co.yixiang.modules.order.service.YxStoreOrderService; +//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +//import com.baomidou.mybatisplus.core.toolkit.Wrappers; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.data.redis.connection.Message; +//import org.springframework.data.redis.connection.MessageListener; +//import org.springframework.data.redis.core.RedisTemplate; +//import org.springframework.data.redis.serializer.RedisSerializer; +//import org.springframework.stereotype.Component; +// +///** +// * redis过期监听 +// * @author hupeng +// * @since 2020-02-27 +// */ +//@Component +//@Slf4j +//public class RedisKeyExpirationListener implements MessageListener { +// +// private RedisTemplate redisTemplate; +// private RedisConfigProperties redisConfigProperties; +// private YxStoreOrderService storeOrderService; +// private YxStorePinkService storePinkService; +// +// public RedisKeyExpirationListener(RedisTemplate redisTemplate, +// RedisConfigProperties redisConfigProperties, +// YxStoreOrderService storeOrderService, +// YxStorePinkService storePinkService){ +// this.redisTemplate = redisTemplate; +// this.redisConfigProperties = redisConfigProperties; +// this.storeOrderService = storeOrderService; +// this.storePinkService = storePinkService; +// } +// @Override +// public void onMessage(Message message, byte[] bytes) { +// RedisSerializer serializer = redisTemplate.getValueSerializer(); +// String channel = String.valueOf(serializer.deserialize(message.getChannel())); +// String body = String.valueOf(serializer.deserialize(message.getBody())); +// //key过期监听 +// if(StrUtil.format("__keyevent@{}__:expired", redisConfigProperties.getDatabase()).equals(channel)){ +// //订单自动取消 +// if(body.contains(ShopConstants.REDIS_ORDER_OUTTIME_UNPAY)) { +// body = body.replace(ShopConstants.REDIS_ORDER_OUTTIME_UNPAY, ""); +// log.info("body:{}",body); +// String orderId = body; +// YxStoreOrder order = storeOrderService.getOne(new LambdaQueryWrapper() +// .eq(YxStoreOrder::getId, orderId) +// .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue())); +// //只有待支付的订单能取消 +// if(order != null){ +// storeOrderService.cancelOrder(order.getOrderId(),null); +// log.info("订单id:{},未在规定时间支付取消成功",body); +// } +// } +// //订单自动收货 +// if(body.contains(ShopConstants.REDIS_ORDER_OUTTIME_UNCONFIRM)) { +// body = body.replace(ShopConstants.REDIS_ORDER_OUTTIME_UNCONFIRM, ""); +// log.info("body:{}",body); +// String orderId = body; +// YxStoreOrder order = storeOrderService.getOne(new LambdaQueryWrapper() +// .eq(YxStoreOrder::getId, orderId) +// .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) +// .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_1.getValue())); +// +// //只有待收货的订单能收货 +// if(order != null){ +// storeOrderService.takeOrder(order.getOrderId(),null); +// log.info("订单id:{},自动收货成功",body); +// } +// } +// +// //拼团过期取消 +// if(body.contains(ShopConstants.REDIS_PINK_CANCEL_KEY)) { +// body = body.replace(ShopConstants.REDIS_PINK_CANCEL_KEY, ""); +// log.info("body:{}",body); +// String pinkId = body; +// YxStorePink storePink = storePinkService.getOne(Wrappers.lambdaQuery() +// .eq(YxStorePink::getId,pinkId) +// .eq(YxStorePink::getStatus,OrderInfoEnum.PINK_STATUS_1.getValue()) +// .eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_0.getValue())); +// +// //取消拼团 +// if(storePink != null){ +// storePinkService.removePink(storePink.getUid(),storePink.getCid(),storePink.getId()); +// log.info("拼团订单id:{},未在规定时间完成取消成功",body); +// } +// } +// } +// +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java new file mode 100644 index 00000000..8997939e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargain.java @@ -0,0 +1,210 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName(value="yx_store_bargain") +public class YxStoreBargain extends BaseDomain { + + /** 砍价产品ID */ + @TableId + @ApiModelProperty(value = "砍价产品ID") + private Long id; + + + /** 关联产品ID */ + @ApiModelProperty(value = "关联产品ID") + private Long productId; + + + /** 砍价活动名称 */ + @NotBlank(message = "请填写砍价名称") + @ApiModelProperty(value = "砍价产品名称") + private String title; + + + /** 砍价活动图片 */ + @NotBlank(message = "请上传商品图片") + @ApiModelProperty(value = "砍价产品图片") + private String image; + + + /** 单位名称 */ + @ApiModelProperty(value = "砍价产品单位名称") + private String unitName; + + + /** 库存 */ + @NotNull(message = "请输入库存") + @Min(message = "库存不能小于0",value = 1) + @ApiModelProperty(value = "砍价产品库存") + private Integer stock; + + + /** 销量 */ + @ApiModelProperty(value = "砍价产品销量") + private Integer sales; + + + /** 砍价产品轮播图 */ + @NotBlank(message = "请上传商品轮播图") + @ApiModelProperty(value = "砍价产品轮播图") + private String images; + + + /** 砍价开启时间 */ + @NotNull(message = "请选择开始时间") + @ApiModelProperty(value = "砍价产品开始时间") + private Date startTime; + + + /** 砍价结束时间 */ + @NotNull(message = "请选择结束时间") + @ApiModelProperty(value = "砍价产品结束时间") + private Date stopTime; + + + /** 砍价产品名称 */ + @ApiModelProperty(value = "砍价产品名称") + private String storeName; + + + /** 砍价金额 */ + @NotNull(message = "请输入砍价金额") + @DecimalMin(value="0.00", message = "砍价金额不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "砍价金额不在合法范围内") + @ApiModelProperty(value = "砍价产品砍价金额") + private BigDecimal price; + + + /** 砍价商品最低价 */ + @NotNull(message = "请输入砍到最低价") + @DecimalMin(value="0.00", message = "砍到最低价不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "砍到最低价不在合法范围内") + @ApiModelProperty(value = "砍价商品最低价") + private BigDecimal minPrice; + + + /** 每次购买的砍价产品数量 */ + @NotNull(message = "请输入限购数量") + @Min(message = "限购不能小于0",value = 1) + @ApiModelProperty(value = "每次购买的砍价产品数量") + private Integer num; + + + /** 用户每次砍价的最大金额 */ + @NotNull(message = "请输入单次砍最高价") + @DecimalMin(value="0.00", message = "单次砍最高价不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "单次砍最高价不在合法范围内") + @ApiModelProperty(value = "用户每次砍价的最大金额") + private BigDecimal bargainMaxPrice; + + + /** 用户每次砍价的最小金额 */ + @NotNull(message = "请输入单次砍最低价") + @DecimalMin(value="0.00", message = "单次砍最低价不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "单次砍最低价小金额不在合法范围内") + @ApiModelProperty(value = "用户每次砍价的最小金额") + private BigDecimal bargainMinPrice; + + + /** 用户每次砍价的次数 */ + @NotNull(message = "请输入砍价的次数") + @Min(message = "砍价的次数不能小于0",value = 1) + @ApiModelProperty(value = "用户每次砍价的次数") + private Integer bargainNum; + + + /** 砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间) */ + @ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)") + private Integer status; + + + /** 砍价详情 */ + @NotBlank(message = "请填写详情") + @ApiModelProperty(value = "砍价详情") + private String description; + + + /** 返多少积分 */ + @ApiModelProperty(value = "返多少积分") + private BigDecimal giveIntegral; + + + /** 砍价活动简介 */ + @ApiModelProperty(value = "砍价产品简介") + private String info; + + + /** 成本价 */ + @ApiModelProperty(value = "成本价") + private BigDecimal cost; + + + /** 排序 */ + @ApiModelProperty(value = "排序") + private Integer sort; + + + /** 是否推荐0不推荐1推荐 */ + @ApiModelProperty(value = "是否推荐0不推荐1推荐") + private Integer isHot; + + + + /** 是否包邮 0不包邮 1包邮 */ + @ApiModelProperty(value = "是否包邮 0不包邮 1包邮") + private Integer isPostage; + + + /** 邮费 */ + @ApiModelProperty(value = "邮费") + private BigDecimal postage; + + + /** 砍价规则 */ + @NotBlank(message = "请填写砍价规则") + @ApiModelProperty(value = "砍价规则描述") + private String rule; + + + /** 砍价产品浏览量 */ + @ApiModelProperty(value = "砍价产品浏览量") + private Integer look; + + + /** 砍价产品分享量 */ + @ApiModelProperty(value = "砍价产品分享量") + private Integer share; + + + + public void copy(YxStoreBargain source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargainUser.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargainUser.java new file mode 100644 index 00000000..fa537d39 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargainUser.java @@ -0,0 +1,58 @@ +package co.yixiang.modules.activity.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + *

+ * 用户参与砍价表 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "YxStoreBargainUser对象", description = "用户参与砍价表") +public class YxStoreBargainUser extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户参与砍价表ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "砍价产品id") + private Long bargainId; + + @ApiModelProperty(value = "砍价的最低价") + private BigDecimal bargainPriceMin; + + @ApiModelProperty(value = "砍价金额") + private BigDecimal bargainPrice; + + @ApiModelProperty(value = "砍掉的价格") + private BigDecimal price; + + @ApiModelProperty(value = "状态 1参与中 2 活动结束参与失败 3活动结束参与成功") + private Integer status; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargainUserHelp.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargainUserHelp.java new file mode 100644 index 00000000..19b4123b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreBargainUserHelp.java @@ -0,0 +1,51 @@ +package co.yixiang.modules.activity.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + *

+ * 砍价用户帮助表 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel(value = "YxStoreBargainUserHelp对象", description = "砍价用户帮助表") +public class YxStoreBargainUserHelp extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "砍价用户帮助表ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "帮助的用户id") + private Long uid; + + @ApiModelProperty(value = "砍价产品ID") + private Long bargainId; + + @ApiModelProperty(value = "用户参与砍价表id") + private Long bargainUserId; + + @ApiModelProperty(value = "帮助砍价多少金额") + private BigDecimal price; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCombination.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCombination.java new file mode 100644 index 00000000..199c5fc4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCombination.java @@ -0,0 +1,195 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_combination") +public class YxStoreCombination extends BaseDomain { + + @TableId + @ApiModelProperty(value = "拼团产品ID") + private Long id; + + + /** 商品id */ + @ApiModelProperty(value = "关联产品ID") + private Long productId; + + + /** 商户id */ + @ApiModelProperty(value = "商户id 预留字段") + private Integer merId; + + + /** 推荐图 */ + @NotBlank(message = "请上传商品图片") + @ApiModelProperty(value = "推荐图") + private String image; + + + /** 轮播图 */ + @NotBlank(message = "请上传商品轮播") + @ApiModelProperty(value = "轮播图") + private String images; + + + /** 活动标题 */ + @NotBlank(message = "请填写拼团名称") + @ApiModelProperty(value = "拼团产品名称") + private String title; + + + + /** 参团人数 */ + @NotNull(message = "请输入拼团人数") + @Min(message = "拼团人数小于0",value = 1) + @ApiModelProperty(value = "拼团产品拼团人数") + private Integer people; + + + /** 简介 */ + @ApiModelProperty(value = "拼团产品简介") + private String info; + + + /** 价格 */ + @NotNull(message = "请输入拼团价") + @DecimalMin(value="0.00", message = "拼团价不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "拼团价不在合法范围内") + @ApiModelProperty(value = "拼团产品拼团价") + private BigDecimal price; + + private BigDecimal productPrice; + + + /** 排序 */ + @ApiModelProperty(value = "排序") + private Integer sort; + + + /** 销量 */ + @ApiModelProperty(value = "销量") + private Integer sales; + + + /** 库存 */ + @NotNull(message = "请输入库存") + @Min(message = "库存不能小于0",value = 1) + private Integer stock; + + + /** 推荐 */ + @ApiModelProperty(value = "是否推荐0不推荐1推荐") + private Integer isHost; + + + /** 产品状态 */ + @ApiModelProperty(value = "拼团产品状态0不显示 1显示") + private Integer isShow; + + + private Integer combination; + + + /** 商户是否可用1可用0不可用 */ + @ApiModelProperty(value = "商户是否可用1可用0不可用 预留字段") + private Integer merUse; + + + /** 拼团内容 */ + @NotBlank(message = "请填写详情") + @ApiModelProperty(value = "拼团产品详情") + private String description; + + + /** 拼团开始时间 */ + @NotNull(message = "请选择结束时间") + @ApiModelProperty(value = "拼团产品结束时间") + private Date startTime; + + + /** 拼团结束时间 */ + @NotNull(message = "请选择开始时间") + @ApiModelProperty(value = "拼团产品开始时间") + private Date stopTime; + + + /** 拼团订单有效时间 */ + @NotNull(message = "请输入拼团时效") + @Min(message = "拼团时效不能小于0",value = 1) + @ApiModelProperty(value = "拼团订单有效时间") + private Integer effectiveTime; + + + /** 拼团产品成本价 */ + @ApiModelProperty(value = "拼团产品成本价") + private Integer cost; + + + /** 浏览量 */ + @ApiModelProperty(value = "拼团产品浏览量") + private Integer browse; + + + /** 单位名 */ + @ApiModelProperty(value = "拼团产品单位名") + private String unitName; + + /** + * 规格 0单 1多 + */ + @ApiModelProperty(value = "拼团产品规格 0单规格 1多规格") + private Integer specType; + + /** 运费模板ID */ + @JsonProperty("temp_id") + @ApiModelProperty(value = "运费模板ID") + private Long tempId; + + + /** 属性项目 */ + @TableField(exist = false) + @ApiModelProperty(value = "属性项目") + private List items; + + /** sku结果集 */ + @TableField(exist = false) + private List> attrs; + + + + public void copy(YxStoreCombination source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java new file mode 100644 index 00000000..9ca64556 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCoupon.java @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_coupon") +public class YxStoreCoupon extends BaseDomain { + + /** 优惠券表ID */ + @TableId + @ApiModelProperty(value = "优惠券ID") + private Integer id; + + + /** 优惠券名称 */ + @NotBlank(message = "请填写优惠券名称") + @ApiModelProperty(value = "优惠券名称") + private String title; + + + /** 兑换消耗积分值 */ + @ApiModelProperty(value = "兑换消耗积分值") + private Integer integral; + + + /** 兑换的优惠券面值 */ + @DecimalMin(value="0.00", message = "优惠券面值不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "优惠券面值不在合法范围内") + @ApiModelProperty(value = "兑换的优惠券面值") + private BigDecimal couponPrice; + + + /** 最低消费多少金额可用优惠券 */ + @DecimalMin(value="0.00", message = "最低消费不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "最低消费不在合法范围内") + @ApiModelProperty(value = "最低消费多少金额可用优惠券") + private BigDecimal useMinPrice; + + + /** 优惠券有效期限(单位:天) */ + @NotNull(message = "请输入有效期限") + @ApiModelProperty(value = "优惠券有效期限(单位:天)") + private Integer couponTime; + + + /** 排序 */ + @ApiModelProperty(value = "排序") + private Integer sort; + + + /** 状态(0:关闭,1:开启) */ + @ApiModelProperty(value = "优惠券状态(0:关闭,1:开启) ") + private Integer status; + + /** 优惠券类型(0:通用券,1:商品券,2:内部券) */ + @ApiModelProperty(value = "优惠券类型(0:通用券,1:商品券,2:内部券) ") + private Integer type; + + /** 优惠券绑定产品ID */ + @ApiModelProperty(value = "优惠券绑定产品ID ") + private String productId; + + + + public void copy(YxStoreCoupon source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponIssue.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponIssue.java new file mode 100644 index 00000000..5b3af8cd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponIssue.java @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_coupon_issue") +public class YxStoreCouponIssue extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @TableId + @ApiModelProperty(value = "优惠券前台领取ID") + private Integer id; + + @ApiModelProperty(value = "前台显示优惠券名称") + private String cname; + + + /** 优惠券ID */ + @ApiModelProperty(value = "优惠券ID") + private Integer cid; + + @ApiModelProperty(value = "优惠券类型 0-通用 1-商品券") + private Integer ctype; + + + /** 优惠券领取开启时间 */ + @NotNull(message = "请选择开启时间") + @ApiModelProperty(value = "优惠券领取开启时间") + private Date startTime; + + + /** 优惠券领取结束时间 */ + @NotNull(message = "请选择结束时间") + @ApiModelProperty(value = "优惠券领取结束时间") + private Date endTime; + + + /** 优惠券领取数量 */ + @ApiModelProperty(value = "优惠券领取数量") + private Integer totalCount; + + + /** 优惠券剩余领取数量 */ + @ApiModelProperty(value = "优惠券剩余领取数量") + private Integer remainCount; + + + /** 是否无限张数 */ + @ApiModelProperty(value = "是否无限张数1:是 0:否") + private Integer isPermanent; + + + /** 1 正常 0 未开启 -1 已无效 */ + @ApiModelProperty(value = "前台领取优惠券状态1 正常 0 未开启 -1 已无效") + private Integer status; + + + + public void copy(YxStoreCouponIssue source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponIssueUser.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponIssueUser.java new file mode 100644 index 00000000..55e91b26 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponIssueUser.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_coupon_issue_user") +public class YxStoreCouponIssueUser extends BaseDomain { + + @TableId + @ApiModelProperty(value = "优惠券前台用户领取记录ID") + private Long id; + + + /** 领取优惠券用户ID */ + @ApiModelProperty(value = "领取优惠券用户ID") + private Long uid; + + + /** 优惠券前台领取ID */ + @ApiModelProperty(value = "优惠券前台领取ID") + private Integer issueCouponId; + + + + + public void copy(YxStoreCouponIssueUser source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java new file mode 100644 index 00000000..1f6160f3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreCouponUser.java @@ -0,0 +1,94 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("yx_store_coupon_user") +public class YxStoreCouponUser extends BaseDomain { + + /** 优惠券发放记录id */ + @TableId + @ApiModelProperty(value = "优惠券发放记录id") + private Long id; + + + /** 兑换的项目id */ + @ApiModelProperty(value = "兑换的项目id") + private Integer cid; + + + /** 优惠券所属用户 */ + @ApiModelProperty(value = "优惠券所属用户") + private Long uid; + + + /** 优惠券名称 */ + @ApiModelProperty(value = "优惠券名称") + private String couponTitle; + + + /** 优惠券的面值 */ + @ApiModelProperty(value = "优惠券的面值") + private BigDecimal couponPrice; + + + /** 最低消费多少金额可用优惠券 */ + @ApiModelProperty(value = "最低消费多少金额可用优惠券") + private BigDecimal useMinPrice; + + + /** 优惠券结束时间 */ + @ApiModelProperty(value = "优惠券结束时间") + private Date endTime; + + + /** 使用时间 */ + @ApiModelProperty(value = "使用时间") + private Date useTime; + + + /** 获取方式 */ + @ApiModelProperty(value = "获取方式:get领取 send派送") + private String type; + + + /** 状态(0:未使用,1:已使用, 2:已过期) */ + @ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已过期)") + private Integer status; + + + /** 是否有效 */ + @ApiModelProperty(value = "是否有效1是 0否") + private Integer isFail; + + + public void copy(YxStoreCouponUser source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStorePink.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStorePink.java new file mode 100644 index 00000000..060b79c4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStorePink.java @@ -0,0 +1,114 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("yx_store_pink") +public class YxStorePink extends BaseDomain { + + @TableId + @ApiModelProperty(value = "拼团产品ID") + private Long id; + + + /** 用户id */ + @ApiModelProperty(value = "拼团产品用户ID") + private Long uid; + + + /** 订单id 生成 */ + @ApiModelProperty(value = "拼团产品订单ID 生成") + private String orderId; + + + /** 订单id 数据库 */ + @ApiModelProperty(value = "拼团产品订单id 数据库") + private Long orderIdKey; + + + /** 购买商品个数 */ + @ApiModelProperty(value = "购买商品个数") + private Integer totalNum; + + + /** 购买总金额 */ + @ApiModelProperty(value = "购买总金额") + private BigDecimal totalPrice; + + + /** 拼团产品id */ + @ApiModelProperty(value = "拼团产品id") + private Long cid; + + + /** 产品id */ + @ApiModelProperty(value = "产品id") + private Long pid; + + + /** 拼团总人数 */ + @ApiModelProperty(value = "拼团总人数") + private Integer people; + + + /** 拼团产品单价 */ + @ApiModelProperty(value = "拼团产品单价") + private BigDecimal price; + + /** 拼团产品停止时间 */ + @ApiModelProperty(value = "拼团产品停止时间") + private Date stopTime; + + + /** 团长id 0为团长 */ + @ApiModelProperty(value = "拼团产品团长id 0为团长") + private Long kId; + + + /** 是否发送模板消息0未发送1已发送 */ + @ApiModelProperty(value = "是否发送模板消息0未发送1已发送") + private Integer isTpl; + + + /** 是否退款 0未退款 1已退款 */ + @ApiModelProperty(value = "是否退款 0未退款 1已退款") + private Integer isRefund; + + + /** 状态1进行中2已完成3未完成 */ + @ApiModelProperty(value = "状态1进行中2已完成3未完成") + private Integer status; + + @ApiModelProperty(value = "库存唯一值") + private String uniqueId; + + public void copy(YxStorePink source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreSeckill.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreSeckill.java new file mode 100644 index 00000000..21d4fdde --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreSeckill.java @@ -0,0 +1,193 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 商品秒杀产品表 +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_seckill") +public class YxStoreSeckill extends BaseDomain { + + /** 商品秒杀产品表id */ + @TableId + @ApiModelProperty(value = "商品秒杀产品表id") + private Long id; + + + /** 商品id */ + @ApiModelProperty(value = "商品id") + private Long productId; + + + /** 推荐图 */ + @NotBlank(message = "请上传商品图片") + @ApiModelProperty(value = "推荐图") + private String image; + + + /** 轮播图 */ + @NotBlank(message = "请上传商品轮播") + @ApiModelProperty(value = "轮播图") + private String images; + + + /** 活动标题 */ + @NotBlank(message = "请填写秒杀名称") + @ApiModelProperty(value = "秒杀名称") + private String title; + + + /** 简介 */ + @ApiModelProperty(value = "简介") + private String info; + + + /** 返多少积分 */ + @ApiModelProperty(value = "返多少积分") + private BigDecimal giveIntegral; + + + /** 排序 */ + @ApiModelProperty(value = "排序") + private Integer sort; + + + /** 库存 */ + @ApiModelProperty(value = "秒杀库存") + private Integer stock; + + /** 秒杀价 */ + @ApiModelProperty(value = "秒杀价") + private BigDecimal price; + + /** 原价 */ + @ApiModelProperty(value = "原价") + private BigDecimal otPrice; + + /** 成本 */ + @ApiModelProperty(value = "成本") + private BigDecimal cost; + /** 销量 */ + @ApiModelProperty(value = "秒杀销量") + private Integer sales; + + + /** 单位名 */ + @ApiModelProperty(value = "单位名") + private String unitName; + + + /** 邮费 */ + @ApiModelProperty(value = "邮费") + private BigDecimal postage; + + + + + /** 内容 */ + @NotBlank(message = "请填写详情") + @ApiModelProperty(value = "详细内容") + private String description; + + + /** 开始时间 */ + @NotNull(message = "请选择秒杀开始时间") + @ApiModelProperty(value = "秒杀开始时间") + private Date startTime; + + + /** 结束时间 */ + @NotNull(message = "请选择秒杀结束时间") + @ApiModelProperty(value = "秒杀结束时间") + private Date stopTime; + + + + /** 产品状态 */ + @ApiModelProperty(value = "产品状态") + private Integer status; + + + /** 是否包邮 */ + @ApiModelProperty(value = "是否包邮") + private Integer isPostage; + + + /** 热门推荐 */ + @ApiModelProperty(value = "是否热门推荐") + private Integer isHot; + + + + /** 最多秒杀几个 */ + @NotNull(message = "请输入限购") + @Min(message = "限购不能小于0",value = 1) + @ApiModelProperty(value = "最多秒杀几个商品") + private Integer num; + + + /** 显示 */ + @ApiModelProperty(value = "是否显示 0否 1显示") + private Integer isShow; + + + /** 时间段id */ + @NotNull(message = "请选择开始时间") + @ApiModelProperty(value = "时间段id") + private Integer timeId; + + /** + * 规格 0单规格 1多规格 + */ + @ApiModelProperty(value = "规格 0单规格 1多规格") + private Integer specType; + + /** 运费模板ID */ + @JsonProperty("temp_id") + @ApiModelProperty(value = "运费模板ID") + private Long tempId; + + + /** 属性项目 */ + @TableField(exist = false) + @ApiModelProperty(value = "属性项目") + private List items; + + /** sku结果集 */ + @TableField(exist = false) + @ApiModelProperty(value = "sku结果集") + private List> attrs; + + public void copy(YxStoreSeckill source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreVisit.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreVisit.java new file mode 100644 index 00000000..233c267e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxStoreVisit.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("yx_store_visit") +public class YxStoreVisit implements Serializable { + + @TableId + private Long id; + + + /** 产品ID */ + private Long productId; + + + /** 产品类型 */ + private String productType; + + + /** 产品分类ID */ + private Integer cateId; + + + /** 产品类型 */ + private String type; + + + /** 用户ID */ + private Long uid; + + + /** 访问次数 */ + private Integer count; + + + /** 备注描述 */ + private String content; + + + /** 添加时间 */ + @TableField(fill= FieldFill.INSERT) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Integer addTime; + + + public void copy(YxStoreVisit source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxUserExtract.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxUserExtract.java new file mode 100644 index 00000000..158645ef --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/domain/YxUserExtract.java @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_user_extract") +public class YxUserExtract extends BaseDomain { + + @TableId + private Long id; + + + private Long uid; + + + /** 名称 */ + private String realName; + + + /** bank = 银行卡 alipay = 支付宝wx=微信 */ + private String extractType; + + + /** 银行卡 */ + private String bankCode; + + + /** 开户地址 */ + private String bankAddress; + + + /** 支付宝账号 */ + private String alipayCode; + + + /** 提现金额 */ + private BigDecimal extractPrice; + + + private String mark; + + + private BigDecimal balance; + + + /** 无效原因 */ + private String failMsg; + + + private Date failTime; + + + /** -1 未通过 0 审核中 1 已提现 */ + private Integer status; + + + /** 微信号 */ + private String wechat; + + + public void copy(YxUserExtract source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/param/UserExtParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/param/UserExtParam.java new file mode 100644 index 00000000..9dd5a0c8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/param/UserExtParam.java @@ -0,0 +1,33 @@ +package co.yixiang.modules.activity.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @ClassName UserExtParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/13 + **/ +@Data +public class UserExtParam implements Serializable { + + @ApiModelProperty(value = "提现支付宝用户名") + private String alipayCode; + + @NotBlank(message = "体现类型不能为空") + @ApiModelProperty(value = "提现类型 weixin alipay") + private String extractType; + + @NotBlank(message = "金额不能为空") + @ApiModelProperty(value = "提现金额") + private String money; + + @ApiModelProperty(value = "微信号") + private String weixin; + + @ApiModelProperty(value = "支付宝账号") + private String name; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreBargainController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreBargainController.java new file mode 100644 index 00000000..9d91a777 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreBargainController.java @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.rest; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.api.YshopException; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria; +import co.yixiang.modules.aop.ForbidSubmit; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-12-22 +*/ +@Api(tags = "商城:砍价管理") +@RestController +@RequestMapping("api") +public class StoreBargainController { + + private final YxStoreBargainService yxStoreBargainService; + + public StoreBargainController(YxStoreBargainService yxStoreBargainService) { + this.yxStoreBargainService = yxStoreBargainService; + } + + @Log("查询砍价") + @ApiOperation(value = "查询砍价") + @GetMapping(value = "/yxStoreBargain") + @PreAuthorize("hasAnyRole('admin','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_SELECT')") + public ResponseEntity getYxStoreBargains(YxStoreBargainQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreBargainService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + + @Log("修改砍价") + @ApiOperation(value = "修改砍价") + @PutMapping(value = "/yxStoreBargain") + @PreAuthorize("hasAnyRole('admin','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreBargain resources){ + if(resources.getBargainMinPrice().compareTo(resources.getBargainMaxPrice()) >= 0){ + throw new YshopException("单次砍最低价不能高于单次砍最高价"); + } + if(resources.getMinPrice().compareTo(resources.getPrice()) >= 0){ + throw new YshopException("允许砍到最低价不能高于砍价金额"); + } + if(ObjectUtil.isNull(resources.getId())){ + return new ResponseEntity<>(yxStoreBargainService.save(resources),HttpStatus.CREATED); + }else{ + yxStoreBargainService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + } + + @ForbidSubmit + @Log("删除砍价") + @ApiOperation(value = "删除砍价") + @DeleteMapping(value = "/yxStoreBargain/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxStoreBargainService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCombinationController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCombinationController.java new file mode 100644 index 00000000..0d8fdec8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCombinationController.java @@ -0,0 +1,204 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.rest; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +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.modules.product.domain.YxStoreProductAttrResult; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrResultService; +import co.yixiang.modules.product.service.YxStoreProductAttrValueService; +import co.yixiang.modules.product.service.YxStoreProductRuleService; +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.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** +* @author hupeng +* @date 2019-11-18 +*/ +@Api(tags = "商城:拼团管理") +@RestController +@RequestMapping("api") +public class StoreCombinationController { + + private final YxStoreCombinationService yxStoreCombinationService; + private final YxShippingTemplatesService yxShippingTemplatesService; + private final YxStoreProductRuleService yxStoreProductRuleService; + private final YxStoreProductAttrResultService yxStoreProductAttrResultService; + private final YxStoreProductAttrValueService storeProductAttrValueService; + private final IGenerator generator; + public StoreCombinationController(YxStoreCombinationService yxStoreCombinationService, YxShippingTemplatesService yxShippingTemplatesService, YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrResultService yxStoreProductAttrResultService, YxStoreProductAttrValueService storeProductAttrValueService, IGenerator generator) { + this.yxStoreCombinationService = yxStoreCombinationService; + this.yxShippingTemplatesService = yxShippingTemplatesService; + this.yxStoreProductRuleService = yxStoreProductRuleService; + this.yxStoreProductAttrResultService = yxStoreProductAttrResultService; + this.storeProductAttrValueService = storeProductAttrValueService; + this.generator = generator; + } + + @Log("查询拼团") + @ApiOperation(value = "查询拼团") + @GetMapping(value = "/yxStoreCombination") + @PreAuthorize("hasAnyRole('admin','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_SELECT')") + public ResponseEntity getYxStoreCombinations(YxStoreCombinationQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreCombinationService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @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 map = new LinkedHashMap<>(3); + + //运费模板 + List shippingTemplatesList = yxShippingTemplatesService.list(); + map.put("tempList", shippingTemplatesList); + + //商品规格 + 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.lambdaQuery() + .eq(YxStoreProductAttrResult::getProductId,yxStoreCombination.getProductId()).last("limit 1")); + JSONObject result = JSON.parseObject(storeProductAttrResult.getResult()); + List attrValues = storeProductAttrValueService.list(new LambdaQueryWrapper().eq(YxStoreProductAttrValue::getProductId, yxStoreCombination.getProductId())); + List productFormatDtos =attrValues.stream().map(i ->{ + ProductFormatDto productFormatDto = new ProductFormatDto(); + BeanUtils.copyProperties(i,productFormatDto); + productFormatDto.setPic(i.getImage()); + return productFormatDto; + }).collect(Collectors.toList()); + if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreCombination.getSpecType())){ + productDto.setAttr(new ProductFormatDto()); + productDto.setAttrs(productFormatDtos); + productDto.setItems(result.getObject("attr",ArrayList.class)); + }else{ + productFormat(productDto, result); + } + + map.put("productInfo",productDto); + + return new ResponseEntity<>(map,HttpStatus.OK); + } + + /** + * 获取商品属性 + * @param productDto + * @param result + */ + private void productFormat(YxStoreCombinationDto productDto, JSONObject result) { + Map mapAttr = (Map) result.getObject("value",ArrayList.class).get(0); + ProductFormatDto productFormatDto = ProductFormatDto.builder() + .pic(mapAttr.get("pic").toString()) + .price(Double.valueOf(mapAttr.get("price").toString())) + .cost(Double.valueOf(mapAttr.get("cost").toString())) + .otPrice(Double.valueOf(mapAttr.get("otPrice").toString())) + .stock(Integer.valueOf(mapAttr.get("stock").toString())) + .barCode(mapAttr.get("barCode").toString()) + .weight(Double.valueOf(mapAttr.get("weight").toString())) + .volume(Double.valueOf(mapAttr.get("volume").toString())) + .value1(mapAttr.get("value1").toString()) + .brokerage(Double.valueOf(mapAttr.get("brokerage").toString())) + .brokerageTwo(Double.valueOf(mapAttr.get("brokerageTwo").toString())) + .pinkPrice(Double.valueOf(mapAttr.get("pinkPrice").toString())) + .pinkStock(Integer.valueOf(mapAttr.get("pinkStock").toString())) + .seckillPrice(Double.valueOf(mapAttr.get("seckillPrice").toString())) + .seckillStock(Integer.valueOf(mapAttr.get("seckillStock").toString())) + .build(); + productDto.setAttr(productFormatDto); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @Log("修改拼团") + @ApiOperation(value = "新增/修改拼团") + @PutMapping(value = "/yxStoreCombination") + @PreAuthorize("hasAnyRole('admin','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreCombination resources){ + if(ObjectUtil.isNull(resources.getId())){ + return new ResponseEntity<>(yxStoreCombinationService.save(resources),HttpStatus.CREATED); + }else{ + yxStoreCombinationService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + } + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @ForbidSubmit + @ApiOperation(value = "开启关闭") + @PostMapping(value = "/yxStoreCombination/onsale/{id}") + public ResponseEntity onSale(@PathVariable Long id,@RequestBody String jsonStr){ + JSONObject jsonObject = JSON.parseObject(jsonStr); + Integer status = jsonObject.getInteger("status"); + yxStoreCombinationService.onSale(id,status); + return new ResponseEntity(HttpStatus.OK); + } + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @ForbidSubmit + @Log("删除拼团") + @ApiOperation(value = "删除拼团") + @DeleteMapping(value = "/yxStoreCombination/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTORECOMBINATION_ALL','YXSTORECOMBINATION_DELETE')") + public ResponseEntity delete(@PathVariable Long id){ + yxStoreCombinationService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java new file mode 100644 index 00000000..f032013c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponController.java @@ -0,0 +1,95 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.rest; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.enums.CouponEnum; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import co.yixiang.modules.activity.service.YxStoreCouponService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponQueryCriteria; +import co.yixiang.modules.aop.ForbidSubmit; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-09 +*/ +@Api(tags = "商城:优惠券管理") +@RestController +@RequestMapping("api") +public class StoreCouponController { + + private final YxStoreCouponService yxStoreCouponService; + + public StoreCouponController(YxStoreCouponService yxStoreCouponService) { + this.yxStoreCouponService = yxStoreCouponService; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxStoreCoupon") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_SELECT')") + public ResponseEntity getYxStoreCoupons(YxStoreCouponQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreCouponService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @Log("新增") + @ApiOperation(value = "新增") + @PostMapping(value = "/yxStoreCoupon") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxStoreCoupon resources){ + if(CouponEnum.TYPE_1.getValue().equals(resources.getType()) + && StrUtil.isEmpty(resources.getProductId())){ + throw new YshopException("请选择商品"); + } + if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { + throw new YshopException("优惠券金额不能高于最低消费金额"); + } + return new ResponseEntity<>(yxStoreCouponService.save(resources),HttpStatus.CREATED); + } + + @Log("修改") + @ApiOperation(value = "修改") + @PutMapping(value = "/yxStoreCoupon") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreCoupon resources){ + if(CouponEnum.TYPE_1.getValue().equals(resources.getType()) + && StrUtil.isEmpty(resources.getProductId())){ + throw new YshopException("请选择商品"); + } + if(resources.getCouponPrice().compareTo(resources.getUseMinPrice()) >= 0) { + throw new YshopException("优惠券金额不能高于最低消费金额"); + } + yxStoreCouponService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxStoreCoupon/{id}") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPON_ALL','YXSTORECOUPON_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxStoreCouponService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponIssueController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponIssueController.java new file mode 100644 index 00000000..6395e5fb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponIssueController.java @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.domain.YxStoreCouponIssue; +import co.yixiang.modules.activity.service.YxStoreCouponIssueService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueQueryCriteria; +import co.yixiang.modules.aop.ForbidSubmit; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-09 +*/ +@Api(tags = "商城:优惠券发布管理") +@RestController +@RequestMapping("api") +public class StoreCouponIssueController { + + private final YxStoreCouponIssueService yxStoreCouponIssueService; + + public StoreCouponIssueController(YxStoreCouponIssueService yxStoreCouponIssueService) { + this.yxStoreCouponIssueService = yxStoreCouponIssueService; + } + + @Log("查询已发布") + @ApiOperation(value = "查询已发布") + @GetMapping(value = "/yxStoreCouponIssue") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPONISSUE_ALL','YXSTORECOUPONISSUE_SELECT')") + public ResponseEntity getYxStoreCouponIssues(YxStoreCouponIssueQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreCouponIssueService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @Log("发布") + @ApiOperation(value = "发布") + @PostMapping(value = "/yxStoreCouponIssue") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPONISSUE_ALL','YXSTORECOUPONISSUE_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxStoreCouponIssue resources){ + if(resources.getTotalCount() > 0) { + resources.setRemainCount(resources.getTotalCount()); + } + return new ResponseEntity<>(yxStoreCouponIssueService.save(resources),HttpStatus.CREATED); + } + + @Log("修改状态") + @ApiOperation(value = "修改状态") + @PutMapping(value = "/yxStoreCouponIssue") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPONISSUE_ALL','YXSTORECOUPONISSUE_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreCouponIssue resources){ + yxStoreCouponIssueService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxStoreCouponIssue/{id}") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECOUPONISSUE_ALL','YXSTORECOUPONISSUE_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxStoreCouponIssueService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponIssueUserController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponIssueUserController.java new file mode 100644 index 00000000..eea77cdb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponIssueUserController.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.service.YxStoreCouponIssueUserService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserQueryCriteria; +import co.yixiang.modules.aop.ForbidSubmit; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-09 +*/ +@Api(tags = "商城:优惠券前台用户领取记录管理") +@RestController +@RequestMapping("api") +public class StoreCouponIssueUserController { + + private final YxStoreCouponIssueUserService yxStoreCouponIssueUserService; + + public StoreCouponIssueUserController(YxStoreCouponIssueUserService yxStoreCouponIssueUserService) { + this.yxStoreCouponIssueUserService = yxStoreCouponIssueUserService; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxStoreCouponIssueUser") + @PreAuthorize("hasAnyRole('admin','YXSTORECOUPONISSUEUSER_ALL','YXSTORECOUPONISSUEUSER_SELECT')") + public ResponseEntity getYxStoreCouponIssueUsers(YxStoreCouponIssueUserQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreCouponIssueUserService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxStoreCouponIssueUser/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTORECOUPONISSUEUSER_ALL','YXSTORECOUPONISSUEUSER_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxStoreCouponIssueUserService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponUserController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponUserController.java new file mode 100644 index 00000000..2813716c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreCouponUserController.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.service.YxStoreCouponUserService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponUserQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-10 +*/ +@Api(tags = "商城:优惠券发放记录管理") +@RestController +@RequestMapping("api") +public class StoreCouponUserController { + + private final YxStoreCouponUserService yxStoreCouponUserService; + + public StoreCouponUserController(YxStoreCouponUserService yxStoreCouponUserService) { + this.yxStoreCouponUserService = yxStoreCouponUserService; + } + + @Log("查询Y") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxStoreCouponUser") + @PreAuthorize("hasAnyRole('admin','YXSTORECOUPONUSER_ALL','YXSTORECOUPONUSER_SELECT')") + public ResponseEntity getYxStoreCouponUsers(YxStoreCouponUserQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity(yxStoreCouponUserService.queryAll(criteria,pageable),HttpStatus.OK); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StorePinkController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StorePinkController.java new file mode 100644 index 00000000..e6e74c09 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StorePinkController.java @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.activity.service.dto.YxStorePinkQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-18 +*/ +@Api(tags = "商城:拼团记录管理") +@RestController +@RequestMapping("api") +public class StorePinkController { + + private final YxStorePinkService yxStorePinkService; + + public StorePinkController(YxStorePinkService yxStorePinkService) { + this.yxStorePinkService = yxStorePinkService; + } + + @Log("查询记录") + @ApiOperation(value = "查询记录") + @GetMapping(value = "/yxStorePink") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTOREPINK_ALL','YXSTOREPINK_SELECT')") + public ResponseEntity getYxStorePinks(YxStorePinkQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStorePinkService.queryAll(criteria,pageable),HttpStatus.OK); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreSeckillController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreSeckillController.java new file mode 100644 index 00000000..423ea51f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/StoreSeckillController.java @@ -0,0 +1,188 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + */ +package co.yixiang.modules.activity.rest; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.SpecTypeEnum; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.domain.YxStoreSeckill; +import co.yixiang.modules.activity.service.YxStoreSeckillService; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.product.domain.YxStoreProductAttrResult; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrResultService; +import co.yixiang.modules.product.service.YxStoreProductAttrValueService; +import co.yixiang.modules.product.service.YxStoreProductRuleService; +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.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author hupeng + * @date 2019-12-14 + */ +@Api(tags = "商城:秒杀管理") +@RestController +@RequestMapping("api") +public class StoreSeckillController { + + private final IGenerator generator; + private final YxStoreSeckillService yxStoreSeckillService; + private final YxShippingTemplatesService yxShippingTemplatesService; + private final YxStoreProductRuleService yxStoreProductRuleService; + private final YxStoreProductAttrValueService storeProductAttrValueService; + private final YxStoreProductAttrResultService yxStoreProductAttrResultService; + + public StoreSeckillController(IGenerator generator, YxStoreSeckillService yxStoreSeckillService, YxShippingTemplatesService yxShippingTemplatesService, + YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrValueService storeProductAttrValueService, + YxStoreProductAttrResultService yxStoreProductAttrResultService) { + this.generator = generator; + this.yxStoreSeckillService = yxStoreSeckillService; + this.yxShippingTemplatesService = yxShippingTemplatesService; + this.yxStoreProductRuleService = yxStoreProductRuleService; + this.storeProductAttrValueService = storeProductAttrValueService; + this.yxStoreProductAttrResultService = yxStoreProductAttrResultService; + } + + @Log("列表") + @ApiOperation(value = "列表") + @GetMapping(value = "/yxStoreSeckill") + @PreAuthorize("hasAnyRole('admin','YXSTORESECKILL_ALL','YXSTORESECKILL_SELECT')") + public ResponseEntity getYxStoreSeckills(YxStoreSeckillQueryCriteria criteria, Pageable pageable) { + return new ResponseEntity<>(yxStoreSeckillService.queryAll(criteria, pageable), HttpStatus.OK); + } + + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + @Log("发布") + @ApiOperation(value = "发布") + @PutMapping(value = "/yxStoreSeckill") + @PreAuthorize("hasAnyRole('admin','YXSTORESECKILL_ALL','YXSTORESECKILL_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreSeckill resources){ + if(ObjectUtil.isNull(resources.getId())){ + return new ResponseEntity<>(yxStoreSeckillService.save(resources),HttpStatus.CREATED); + }else{ + yxStoreSeckillService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxStoreSeckill/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTORESECKILL_ALL','YXSTORESECKILL_DELETE')") + public ResponseEntity delete(@PathVariable Integer id) { + yxStoreSeckillService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + @Log("新增秒杀") + @ApiOperation(value = "新增秒杀") + @PostMapping(value = "/yxStoreSeckill") + @PreAuthorize("hasAnyRole('admin','YXSTORESECKILL_ALL','YXSTORESECKILL_EDIT')") + public ResponseEntity add(@Validated @RequestBody YxStoreSeckillDto resources) { + return new ResponseEntity<>(yxStoreSeckillService.saveSeckill(resources), HttpStatus.CREATED); + } + + @ApiOperation(value = "获取商品信息") + @GetMapping(value = "/yxStoreSecKill/info/{id}") + public ResponseEntity info(@PathVariable Long id) { + Map map = new LinkedHashMap<>(3); + + //运费模板 + List shippingTemplatesList = yxShippingTemplatesService.list(); + map.put("tempList", shippingTemplatesList); + + //商品规格 + map.put("ruleList", yxStoreProductRuleService.list()); + + + if (id == 0) { + return new ResponseEntity<>(map, HttpStatus.OK); + } + + //处理商品详情 + YxStoreSeckill yxStoreSeckill = yxStoreSeckillService.getById(id); + YxStoreSeckillDto productDto = new YxStoreSeckillDto(); + BeanUtil.copyProperties(yxStoreSeckill, productDto, "images"); + productDto.setSliderImage(Arrays.asList(yxStoreSeckill.getImages().split(","))); + YxStoreProductAttrResult storeProductAttrResult = yxStoreProductAttrResultService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrResult::getProductId, yxStoreSeckill.getProductId()).last("limit 1")); + JSONObject result = JSON.parseObject(storeProductAttrResult.getResult()); + + List attrValues = storeProductAttrValueService.list(new LambdaQueryWrapper().eq(YxStoreProductAttrValue::getProductId, yxStoreSeckill.getProductId())); + List productFormatDtos = attrValues.stream().map(i -> { + ProductFormatDto productFormatDto = new ProductFormatDto(); + BeanUtils.copyProperties(i, productFormatDto); + productFormatDto.setPic(i.getImage()); + return productFormatDto; + }).collect(Collectors.toList()); + if (SpecTypeEnum.TYPE_1.getValue().equals(yxStoreSeckill.getSpecType())) { + productDto.setAttr(new ProductFormatDto()); + productDto.setAttrs(productFormatDtos); + productDto.setItems(result.getObject("attr", ArrayList.class)); + } else { + productFormat(productDto, result); + } + + + map.put("productInfo", productDto); + + return new ResponseEntity<>(map, HttpStatus.OK); + } + + /** + * 获取商品属性 + * @param productDto + * @param result + */ + private void productFormat(YxStoreSeckillDto productDto, JSONObject result) { + Map mapAttr = (Map) result.getObject("value", ArrayList.class).get(0); + ProductFormatDto productFormatDto = ProductFormatDto.builder() + .pic(mapAttr.get("pic").toString()) + .price(Double.valueOf(mapAttr.get("price").toString())) + .cost(Double.valueOf(mapAttr.get("cost").toString())) + .otPrice(Double.valueOf(mapAttr.get("otPrice").toString())) + .stock(Integer.valueOf(mapAttr.get("stock").toString())) + .barCode(mapAttr.get("barCode").toString()) + .weight(Double.valueOf(mapAttr.get("weight").toString())) + .volume(Double.valueOf(mapAttr.get("volume").toString())) + .value1(mapAttr.get("value1").toString()) + .brokerage(Double.valueOf(mapAttr.get("brokerage").toString())) + .brokerageTwo(Double.valueOf(mapAttr.get("brokerageTwo").toString())) + .pinkPrice(Double.valueOf(mapAttr.get("pinkPrice").toString())) + .pinkStock(Integer.valueOf(mapAttr.get("pinkStock").toString())) + .seckillPrice(Double.valueOf(mapAttr.get("seckillPrice").toString())) + .seckillStock(Integer.valueOf(mapAttr.get("seckillStock").toString())) + .build(); + productDto.setAttr(productFormatDto); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/UserExtractController.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/UserExtractController.java new file mode 100644 index 00000000..58f20377 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/rest/UserExtractController.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.activity.domain.YxUserExtract; +import co.yixiang.modules.activity.service.YxUserExtractService; +import co.yixiang.modules.activity.service.dto.YxUserExtractQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-14 +*/ +@Api(tags = "商城:提现管理") +@RestController +@RequestMapping("api") +public class UserExtractController { + + private final YxUserExtractService yxUserExtractService; + + + public UserExtractController(YxUserExtractService yxUserExtractService) { + this.yxUserExtractService = yxUserExtractService; + + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxUserExtract") + @PreAuthorize("hasAnyRole('admin','YXUSEREXTRACT_ALL','YXUSEREXTRACT_SELECT')") + public ResponseEntity getYxUserExtracts(YxUserExtractQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxUserExtractService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + + @Log("修改审核") + @ApiOperation(value = "修改审核") + @PutMapping(value = "/yxUserExtract") + @PreAuthorize("hasAnyRole('admin','YXUSEREXTRACT_ALL','YXUSEREXTRACT_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxUserExtract resources){ + yxUserExtractService.doExtract(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java new file mode 100644 index 00000000..8e758146 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainService.java @@ -0,0 +1,125 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.activity.service.dto.YxStoreBargainDto; +import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria; +import co.yixiang.modules.activity.vo.BargainCountVo; +import co.yixiang.modules.activity.vo.BargainVo; +import co.yixiang.modules.activity.vo.TopCountVo; +import co.yixiang.modules.activity.vo.YxStoreBargainQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxStoreBargainService extends BaseService{ + + /** + * 退回库存销量 + * @param num 数量 + * @param bargainId 砍价产品id + */ + void incStockDecSales(int num,Long bargainId); + + /** + * 增加销量 减少库存 + * @param num 数量 + * @param bargainId 砍价id + */ + void decStockIncSales(int num,Long bargainId); + + //YxStoreBargain getBargain(int bargainId); + + /** + * 开始帮助好友砍价 + * @param bargainId 砍价产品id + * @param bargainUserUid 开启砍价用户id + * @param uid 当前用户id + */ + void doHelp(Long bargainId,Long bargainUserUid,Long uid); + + /** + * 顶部统计 + * @param bargainId 砍价商品id + * @return TopCountVo + */ + TopCountVo topCount(Long bargainId); + + /** + * 砍价 砍价帮总人数、剩余金额、进度条、已经砍掉的价格 + * @param bargainId 砍价商品id + * @param uid 砍价用户id + * @param myUid 当前用户id + * @return BargainCountVo + */ + BargainCountVo helpCount(Long bargainId, Long uid, Long myUid); + + //int getBargainPayCount(int bargainId); + + //void addBargainShare(int id); + + //void addBargainLook(int id); + + /** + * 砍价详情 + * @param id 砍价id + * @param yxUser 用户 + * @return BargainVo + */ + BargainVo getDetail(Long id, YxUser yxUser); + + + /** + * 获取砍价商品列表 + * @param page page + * @param limit limit + * @return List + */ + List getList(int page, int limit); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreBargainQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreBargainQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * 删除砍价海报 + * @param id + */ + void deleteBargainImg(String id); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserHelpService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserHelpService.java new file mode 100644 index 00000000..da4c27c4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserHelpService.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; +import co.yixiang.modules.activity.vo.YxStoreBargainUserHelpQueryVo; + +import java.util.List; + +/** + *

+ * 砍价用户帮助表 服务类 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +public interface YxStoreBargainUserHelpService extends BaseService { + + /** + * 获取砍价帮 + * @param bargainId 砍价商品id + * @param bargainUserUid 砍价用户id + * @param page page + * @param limit limit + * @return list + */ + List getList(Long bargainId, Long bargainUserUid, int page, int limit); + + /** + * 获取砍价帮总人数 + * @param bargainId 砍价产品ID + * @param bargainUserUid 用户参与砍价表id + * @return int + */ + Long getBargainUserHelpPeopleCount(Long bargainId,Long bargainUserUid); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java new file mode 100644 index 00000000..aa3be303 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreBargainUserService.java @@ -0,0 +1,89 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.vo.YxStoreBargainUserQueryVo; + +import java.util.List; + +/** + *

+ * 用户参与砍价表 服务类 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +public interface YxStoreBargainUserService extends BaseService { + + /** + * 修改用户砍价状态 + * @param bargainId 砍价产品id + * @param uid 用户id + */ + void setBargainUserStatus(Long bargainId, Long uid); + + /** + * 砍价取消 + * @param bargainId 砍价商品id + * @param uid uid + */ + void bargainCancel(Long bargainId,Long uid); + + /** + * 获取用户的砍价产品 + * @param bargainUserUid 用户id + * @param page page + * @param limit limit + * @return List + */ + List bargainUserList(Long bargainUserUid, int page, int limit); + + /** + * 判断用户是否还可以砍价 + * @param bargainId 砍价产品id + * @param bargainUserUid 开启砍价用户id + * @param uid 当前用户id + * @return false=NO true=YES + */ + boolean isBargainUserHelp(Long bargainId,Long bargainUserUid,Long uid); + + /** + * 添加砍价记录 + * @param bargainId 砍价商品id + * @param uid 用户id + */ + void setBargain(Long bargainId,Long uid); + + //double getBargainUserDiffPrice(int id); + + + /** + * 获取某个用户参与砍价信息 + * @param bargainId 砍价id + * @param uid 用户id + * @return YxStoreBargainUser + */ + YxStoreBargainUser getBargainUserInfo(Long bargainId, Long uid); + + //List getBargainUserList(int bargainId,int status); + + /** + * 获取参与砍价的用户数量 + * @param bargainId 砍价id + * @param status 状态 OrderInfoEnum 1 进行中 2 结束失败 3结束成功 + * @return int + */ + Long getBargainUserCount(Long bargainId,Integer status); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCombinationService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCombinationService.java new file mode 100644 index 00000000..ca5c18fd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCombinationService.java @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreCombination; +import co.yixiang.modules.activity.service.dto.YxStoreCombinationDto; +import co.yixiang.modules.activity.service.dto.YxStoreCombinationQueryCriteria; +import co.yixiang.modules.activity.vo.CombinationQueryVo; +import co.yixiang.modules.activity.vo.StoreCombinationVo; +import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxStoreCombinationService extends BaseService{ + + + + /** + * 拼团列表 + * @param page page + * @param limit limit + * @return list + */ + CombinationQueryVo getList(int page, int limit); + + /** + * 获取拼团详情 + * @param id 拼团产品id + * @param uid uid + * @return StoreCombinationVo + */ + StoreCombinationVo getDetail(Long id, Long uid); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCombinationQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCombinationQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * 修改状态 + * @param id 拼团产品id + * @param status ShopCommonEnum + */ + void onSale(Long id, Integer status); + + boolean saveCombination(YxStoreCombinationDto resources); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponIssueService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponIssueService.java new file mode 100644 index 00000000..e24c97c1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponIssueService.java @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreCouponIssue; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueQueryCriteria; +import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxStoreCouponIssueService extends BaseService{ + + /** + * 领取优惠券 + * @param id id 优惠券id + * @param uid uid + */ + void issueUserCoupon(Integer id, Long uid); + + /** + * 优惠券列表 + * @param page page + * @param limit limit + * @param uid 用户id + * @return list + */ + List getCouponList(int page, int limit, Long uid,Long productId,Integer type); + + //int couponCount(int id, int uid); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCouponIssueQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCouponIssueQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponIssueUserService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponIssueUserService.java new file mode 100644 index 00000000..92a91bba --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponIssueUserService.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreCouponIssueUser; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxStoreCouponIssueUserService extends BaseService{ + + /** + * 添加优惠券领取记录 + * @param uid 用户id + * @param id 前台优惠券id + */ + void addUserIssue(Long uid, Integer id); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCouponIssueUserQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCouponIssueUserQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponService.java new file mode 100644 index 00000000..d613b529 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponService.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import co.yixiang.modules.activity.service.dto.YxStoreCouponDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxStoreCouponService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCouponQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCouponQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java new file mode 100644 index 00000000..9db811a5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java @@ -0,0 +1,121 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.service.dto.YxStoreCouponUserDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponUserQueryCriteria; +import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import co.yixiang.modules.activity.vo.YxStoreCouponUserQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author hupeng + * @date 2020-05-13 + */ +public interface YxStoreCouponUserService extends BaseService { + + /** + * 获取当前用户优惠券数量 + * + * @param uid uid + * @return int + */ + Long getUserValidCouponCount(Long uid); + + void useCoupon(int id); + + /** + * 获取用户优惠券 + * + * @param id 优惠券id + * @param uid 用户id + * @return YxStoreCouponUser + */ + YxStoreCouponUser getCoupon(Integer id, Long uid); + + + /** + * 获取满足条件的可用优惠券 + * + * @param cartIds 购物车ids + * @return list + */ + List beUsableCouponList(Long uid, String cartIds); + + /** + * 获取下单时候满足的优惠券 + * + * @param uid uid + * @param price 总价格 + * @param productIds list + * @return list + */ + List getUsableCouponList(Long uid, double price, List productIds); + + + /** + * 获取用户优惠券 + * + * @param uid uid + * @return list + */ + List getUserCoupon(Long uid); + + /** + * 添加优惠券记录 + * + * @param uid 用户id + * @param cid 优惠券id + */ + void addUserCoupon(Long uid, Integer cid); + + /** + * 查询数据分页 + * + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCouponUserQueryCriteria criteria); + + /** + * 导出数据 + * + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * pc端查询优惠券 + * + * @param uid 用户id + * @param page 当前页码 + * @param limit 一页多少 + * @param type + * @return / + */ + Map getUserPCCoupon(Long uid, int page, int limit, Integer type); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStorePinkService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStorePinkService.java new file mode 100644 index 00000000..7b93331f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStorePinkService.java @@ -0,0 +1,121 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStorePink; +import co.yixiang.modules.activity.service.dto.PinkAllDto; +import co.yixiang.modules.activity.service.dto.YxStorePinkDto; +import co.yixiang.modules.activity.service.dto.YxStorePinkQueryCriteria; +import co.yixiang.modules.activity.vo.PinkInfoVo; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStorePinkService extends BaseService{ + + + /** + * 取消拼团 + * @param uid 用户id + * @param cid 团购产品id + * @param pinkId 拼团id + */ + void removePink(Long uid, Long cid, Long pinkId); + + /** + * 计算还差几人拼团 + * @param pink 拼团信息 + * @return int + */ + int surplusPeople(YxStorePink pink); + + + /** + * 拼团明细 + * @param id 拼团id + * @param uid 用户id + */ + PinkInfoVo pinkInfo(Long id, Long uid); + + + /** + * 返回正在拼团的人数 + * @param id 拼团id + * @return int + */ + Long pinkIngCount(Long id); + + /** + * 创建拼团 + * @param order 订单 + */ + void createPink(YxStoreOrderQueryVo order); + + /** + * 判断用户是否在团内 + * @param id 拼团id + * @param uid 用户id + * @return boolean true=在 + */ + boolean getIsPinkUid(Long id,Long uid); + + /** + * 获取拼团完成的商品总件数 + * @return int + */ + int getPinkOkSumTotalNum(); + + /** + * 获取拼团成功的用户 + * @param uid uid + * @return list + */ + List getPinkOkList(Long uid); + + + + /** + * 获取团长拼团数据 + * @param cid 拼团产品id + * @return PinkAllDto pindAll-参与的拼团的id 集合 list-团长参与的列表 + */ + PinkAllDto getPinkAll(Long cid); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStorePinkQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStorePinkQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreSeckillService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreSeckillService.java new file mode 100644 index 00000000..1b9ef323 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreSeckillService.java @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreSeckill; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria; +import co.yixiang.modules.activity.vo.StoreSeckillVo; +import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author hupeng + * @date 2020-05-13 + */ +public interface YxStoreSeckillService extends BaseService { + + + /** + * 产品详情 + * + * @param id 秒杀商品id + * @return StoreSeckillVo + */ + StoreSeckillVo getDetail(Long id); + + /** + * 秒杀产品列表 + * + * @param page page + * @param limit limit + * @return list + */ + List getList(int page, int limit, int time); + + /** + * 秒杀产品列表(首页用) + * + * @param page page + * @param limit limit + * @return list + */ + List getList(int page, int limit); + + /** + * 查询数据分页 + * + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreSeckillQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreSeckillQueryCriteria criteria); + + /** + * 导出数据 + * + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + boolean saveSeckill(YxStoreSeckillDto resources); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreVisitService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreVisitService.java new file mode 100644 index 00000000..0ed13f7a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxStoreVisitService.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxStoreVisit; +import co.yixiang.modules.activity.service.dto.YxStoreVisitDto; +import co.yixiang.modules.activity.service.dto.YxStoreVisitQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxStoreVisitService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreVisitQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreVisitQueryCriteria criteria); + + /** + * 添加用户访问拼团记录 + * @param uid 用户id + * @param productId 产品id + */ + void addStoreVisit(Long uid,Long productId); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxUserExtractService.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxUserExtractService.java new file mode 100644 index 00000000..3f4c1661 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/YxUserExtractService.java @@ -0,0 +1,74 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.activity.domain.YxUserExtract; +import co.yixiang.modules.activity.param.UserExtParam; +import co.yixiang.modules.activity.service.dto.YxUserExtractDto; +import co.yixiang.modules.activity.service.dto.YxUserExtractQueryCriteria; +import co.yixiang.modules.user.domain.YxUser; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface YxUserExtractService extends BaseService{ + + /** + * 开始提现 + * @param userInfo 用户 + * @param param UserExtParam + */ + void userExtract(YxUser userInfo, UserExtParam param); + + /** + * 累计提现金额 + * @param uid uid + * @return double + */ + double extractSum(Long uid); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxUserExtractQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxUserExtractQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + + /** + * 操作提现 + * @param resources YxUserExtract + */ + void doExtract(YxUserExtract resources); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkAllDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkAllDto.java new file mode 100644 index 00000000..9b26cf72 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkAllDto.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.activity.service.dto; + +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @ClassName 团长拼团数据PinkAllDto + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/20 + **/ +@Getter +@Setter +@Builder +public class PinkAllDto { + List list; // list-团长参与的列表 + List pindAll; //pindAll-参与的拼团的id 集合 +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkDto.java new file mode 100644 index 00000000..7dfd030f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkDto.java @@ -0,0 +1,51 @@ +package co.yixiang.modules.activity.service.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @ClassName PinkDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/19 + **/ +@Data +public class PinkDto implements Serializable { + + @ApiModelProperty(value = "拼团ID") + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "拼团总人数") + private Integer people; + + @ApiModelProperty(value = "拼团产品单价") + private Double price; + + @ApiModelProperty(value = "拼团结束时间") + private Date stopTime; + + @ApiModelProperty(value = "拼团用户昵称") + private String nickname; + + @ApiModelProperty(value = "拼团用户头像") + private String avatar; + + @ApiModelProperty(value = "参与的拼团的id集合") + private String count; + + @ApiModelProperty(value = "拼团时效:小时") + private String h; + + @ApiModelProperty(value = "拼团时效:分钟") + private String i; + + @ApiModelProperty(value = "拼团时效:秒") + private String s; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkUserDto.java new file mode 100644 index 00000000..ea50ef68 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/PinkUserDto.java @@ -0,0 +1,44 @@ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.modules.activity.domain.YxStorePink; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +/** + * @ClassName PinkUserDto + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/22 + **/ +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class PinkUserDto { + + /**拼团的团员*/ + @ApiModelProperty(value = "拼团的团员信息") + private List pinkAll; + + /**单个拼团信息*/ + @ApiModelProperty(value = "单个拼团信息") + private YxStorePink pinkT; + + /**拼团id集合*/ + @ApiModelProperty(value = "拼团id集合") + private List idAll; + + /**拼团用户id集合*/ + @ApiModelProperty(value = "拼团用户id集合") + private List uidAll; + + /**还差几人成团*/ + @ApiModelProperty(value = "还差几人成团") + private Integer count; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/SeckillTimeDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/SeckillTimeDto.java new file mode 100644 index 00000000..1999b249 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/SeckillTimeDto.java @@ -0,0 +1,27 @@ +package co.yixiang.modules.activity.service.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class SeckillTimeDto { + + private Integer id; + /** + * 00:00 + */ + @ApiModelProperty(value = "秒杀产品时间:00:00") + private String time; + + /** + *状态 + */ + @ApiModelProperty(value = "秒杀产品状态显示中文值") + private String state; + + @ApiModelProperty(value = "秒杀产品状态") + private Integer status; + + @ApiModelProperty(value = "秒杀产品停止时间") + private Integer stop; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java new file mode 100644 index 00000000..db1d7e6b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainDto.java @@ -0,0 +1,113 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreBargainDto implements Serializable { + + /** 砍价产品ID */ + private Long id; + + /** 关联产品ID */ + private Long productId; + + /** 砍价活动名称 */ + private String title; + + /** 砍价活动图片 */ + private String image; + + /** 单位名称 */ + private String unitName; + + /** 库存 */ + private Integer stock; + + /** 销量 */ + private Integer sales; + + /** 砍价产品轮播图 */ + private String images; + + /** 砍价开启时间 */ + private Date startTime; + + /** 砍价结束时间 */ + private Date stopTime; + + /** 砍价产品名称 */ + private String storeName; + + /** 砍价金额 */ + private BigDecimal price; + + /** 砍价商品最低价 */ + private BigDecimal minPrice; + + /** 每次购买的砍价产品数量 */ + private Integer num; + + /** 用户每次砍价的最大金额 */ + private BigDecimal bargainMaxPrice; + + /** 用户每次砍价的最小金额 */ + private BigDecimal bargainMinPrice; + + /** 用户每次砍价的次数 */ + private Integer bargainNum; + + /** 砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间) */ + private Integer status; + + /** 砍价详情 */ + private String description; + + /** 反多少积分 */ + private BigDecimal giveIntegral; + + /** 砍价活动简介 */ + private String info; + + /** 成本价 */ + private BigDecimal cost; + + /** 排序 */ + private Integer sort; + + /** 是否推荐0不推荐1推荐 */ + private Integer isHot; + + /** 添加时间 */ + private Date createTime; + + /** 是否包邮 0不包邮 1包邮 */ + private Integer isPostage; + + /** 邮费 */ + private BigDecimal postage; + + /** 砍价规则 */ + private String rule; + + /** 砍价产品浏览量 */ + private Integer look; + + /** 砍价产品分享量 */ + private Integer share; + + + private String statusStr; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainQueryCriteria.java new file mode 100644 index 00000000..732a5278 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreBargainQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreBargainQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCombinationDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCombinationDto.java new file mode 100644 index 00000000..e328a575 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCombinationDto.java @@ -0,0 +1,139 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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 com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +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 +*/ +@Getter +@Setter +@ToString +public class YxStoreCombinationDto implements Serializable { + + private Long id; + + // 商品id + private Long productId; + + // 商户id + private Integer merId; + + // 推荐图 + private String image; + + private String images; + + /** 轮播图 */ + @JsonProperty("slider_image") + private List sliderImage; + + //参与人数 + private Long countPeopleAll; + + //成团人数 + private Long countPeoplePink; + + //访问人数 + private Long countPeopleBrowse; + + // 活动标题 + private String title; + + // 参团人数 + private Long people; + + // 简介 + private String info; + + // 价格 + private BigDecimal price; + + // 排序 + private Integer sort; + + // 销量 + private Long sales; + + // 库存 + private Long stock; + + // 添加时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + // 推荐 + private Integer isHost; + + // 产品状态 + private Integer isShow; + + + private Integer combination; + + // 商户是否可用1可用0不可用 + private Integer merUse; + + // 是否包邮1是0否 + private Integer isPostage; + + // 邮费 + private BigDecimal postage; + + // 拼团内容 + private String description; + + // 拼团开始时间 + private Date startTime; + + // 拼团结束时间 + private Date stopTime; + + // 拼团订单有效时间 + private Integer effectiveTime; + + // 拼团产品成本 + private Integer cost; + + // 浏览量 + private Integer browse; + + // 单位名 + private String unitName; + + /** 规格 0单 1多 */ + @JsonProperty("spec_type") + private Integer specType; + // 模板id + @JsonProperty("temp_id") + private Integer tempId; + + /** 是否单独分佣 */ + @JsonProperty("is_sub") + private Integer isSub; + + private ProductFormatDto attr; + //属性项目 + private List items; + + //sku结果集 + private List attrs; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCombinationQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCombinationQueryCriteria.java new file mode 100644 index 00000000..4fc0d6be --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCombinationQueryCriteria.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCombinationQueryCriteria{ + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String title; + + @Query + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponDto.java new file mode 100644 index 00000000..7baebf0a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponDto.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.modules.product.domain.YxStoreProduct; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponDto implements Serializable { + + // 优惠券表ID + private Integer id; + + // 优惠券名称 + private String title; + + // 兑换消耗积分值 + private Integer integral; + + // 兑换的优惠券面值 + private BigDecimal couponPrice; + + // 最低消费多少金额可用优惠券 + private BigDecimal useMinPrice; + + // 优惠券有效期限(单位:天) + private Integer couponTime; + + // 排序 + private Integer sort; + + // 状态(0:关闭,1:开启) + private Integer status; + + private Integer type; + + private String productId; + + private List product; + + // 兑换项目添加时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueDto.java new file mode 100644 index 00000000..ad0f5287 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueDto.java @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponIssueDto implements Serializable { + + private Integer id; + + private String cname; + + /** 优惠券ID */ + private Integer cid; + + private Integer ctype; + + /** 优惠券领取开启时间 */ + private Date startTime; + + /** 优惠券领取结束时间 */ + private Date endTime; + + /** 优惠券领取数量 */ + private Integer totalCount; + + /** 优惠券剩余领取数量 */ + private Integer remainCount; + + /** 是否无限张数 */ + private Integer isPermanent; + + /** 1 正常 0 未开启 -1 已无效 */ + private Integer status; + + + /** 优惠券添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueQueryCriteria.java new file mode 100644 index 00000000..e07e5698 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueQueryCriteria.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponIssueQueryCriteria{ + + @Query + private Integer isDel; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueUserDto.java new file mode 100644 index 00000000..49fad1c9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueUserDto.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponIssueUserDto implements Serializable { + + private Integer id; + + /** 领取优惠券用户ID */ + private Integer uid; + + /** 优惠券前台领取ID */ + private Integer issueCouponId; + + /** 领取时间 */ + private Integer addTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueUserQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueUserQueryCriteria.java new file mode 100644 index 00000000..ee859e17 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponIssueUserQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponIssueUserQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponQueryCriteria.java new file mode 100644 index 00000000..d9686b22 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponQueryCriteria.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponQueryCriteria{ + + @Query + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponUserDto.java new file mode 100644 index 00000000..fb530966 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponUserDto.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponUserDto implements Serializable { + + // 优惠券发放记录id + private Long id; + + // 兑换的项目id + private Integer cid; + + // 优惠券所属用户 + private Long uid; + + private String nickname; + + // 优惠券名称 + private String couponTitle; + + // 优惠券的面值 + private BigDecimal couponPrice; + + // 最低消费多少金额可用优惠券 + private BigDecimal useMinPrice; + + // 优惠券创建时间 + private Date addTime; + + // 优惠券结束时间 + private Date endTime; + + // 使用时间 + private Date useTime; + + // 获取方式 + private String type; + + // 状态(0:未使用,1:已使用, 2:已过期) + private Integer status; + + // 是否有效 + private Integer isFail; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponUserQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponUserQueryCriteria.java new file mode 100644 index 00000000..4ea955a8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreCouponUserQueryCriteria.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreCouponUserQueryCriteria{ + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String couponTitle; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStorePinkDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStorePinkDto.java new file mode 100644 index 00000000..0679c2a7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStorePinkDto.java @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStorePinkDto implements Serializable { + + private Long id; + + /** 用户id */ + private Long uid; + + /** 订单id 生成 */ + private String orderId; + + /** 订单id 数据库 */ + private Long orderIdKey; + + /** 购买商品个数 */ + private Integer totalNum; + + /** 购买总金额 */ + private BigDecimal totalPrice; + + /** 拼团产品id */ + private Long cid; + + /** 产品id */ + private Long pid; + + /** 拼团总人数 */ + private Integer people; + + /** 拼团产品单价 */ + private BigDecimal price; + + /** 开始时间 */ + @JsonFormat( + pattern = "yyyy年MM月dd日HH时mm分", + timezone = "GMT+8" + ) + private Date createTime; + + private String stopTime; + + /** 团长id 0为团长 */ + private Long kId; + + /** 是否发送模板消息0未发送1已发送 */ + private Integer isTpl; + + /** 是否退款 0未退款 1已退款 */ + private Integer isRefund; + + /** 状态1进行中2已完成3未完成 */ + private Integer status; + + private String nickname; + + private String phone; + + private String userImg; + + private String product; + + private String image; + /** + * 参团人数 + */ + private Long countPeople; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStorePinkQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStorePinkQueryCriteria.java new file mode 100644 index 00000000..14445dad --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStorePinkQueryCriteria.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStorePinkQueryCriteria{ + @Query + private Integer cid; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreSeckillDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreSeckillDto.java new file mode 100644 index 00000000..e3014977 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreSeckillDto.java @@ -0,0 +1,136 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +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.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +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 +*/ +@Getter +@Setter +@ToString +public class YxStoreSeckillDto implements Serializable { + + + // 商品秒杀产品表id + private Long id; + + // 商品id + private Long productId; + + // 推荐图 + private String image; + + // 轮播图 + private String images; + + /** 轮播图 */ + @JsonProperty("slider_image") + private List sliderImage; + + // 活动标题 + private String title; + + // 简介 + private String info; + + // 返多少积分 + private BigDecimal giveIntegral; + + /** 秒杀价 */ + @ApiModelProperty(value = "秒杀价") + private BigDecimal price; + + /** 原价 */ + @ApiModelProperty(value = "原价") + private BigDecimal otPrice; + + /** 成本 */ + @ApiModelProperty(value = "成本") + private BigDecimal cost; + + /** 销量 */ + @ApiModelProperty(value = "秒杀销量") + private Integer sales; + + // 排序 + private Integer sort; + + // 库存 + private Integer stock; + + // 单位名 + private String unitName; + + // 邮费 + private BigDecimal postage; + + // 内容 + private String description; + + // 开始时间 + private Date startTime; + + // 结束时间 + private Date stopTime; + + // 添加时间 + private Date createTime; + + // 产品状态 + private Integer status; + + // 是否包邮 + private Integer isPostage; + + // 热门推荐 + private Integer isHot; + + + // 最多秒杀几个 + private Integer num; + + // 显示 + private Integer isShow; + + + private String statusStr; + + private Integer timeId; + // 模板id + @JsonProperty("temp_id") + private Integer tempId; + /** 规格 0单 1多 */ + @JsonProperty("spec_type") + private Integer specType; + + /** 是否单独分佣 */ + @JsonProperty("is_sub") + private Integer isSub; + + private ProductFormatDto attr; + //属性项目 + private List items; + + //sku结果集 + private List attrs; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreSeckillQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreSeckillQueryCriteria.java new file mode 100644 index 00000000..00293147 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreSeckillQueryCriteria.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreSeckillQueryCriteria{ + + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String title; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreVisitDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreVisitDto.java new file mode 100644 index 00000000..03408fa7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreVisitDto.java @@ -0,0 +1,44 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreVisitDto implements Serializable { + + private Integer id; + + /** 产品ID */ + private Integer productId; + + /** 产品类型 */ + private String productType; + + /** 产品分类ID */ + private Integer cateId; + + /** 产品类型 */ + private String type; + + /** 用户ID */ + private Integer uid; + + /** 访问次数 */ + private Integer count; + + /** 备注描述 */ + private String content; + + /** 添加时间 */ + private Integer addTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreVisitQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreVisitQueryCriteria.java new file mode 100644 index 00000000..e5762c1c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxStoreVisitQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxStoreVisitQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxUserExtractDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxUserExtractDto.java new file mode 100644 index 00000000..ca8064d2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxUserExtractDto.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxUserExtractDto implements Serializable { + + + private Long id; + + private Long uid; + + // 名称 + private String realName; + + // bank = 银行卡 alipay = 支付宝wx=微信 + private String extractType; + + // 银行卡 + private String bankCode; + + // 开户地址 + private String bankAddress; + + // 支付宝账号 + private String alipayCode; + + // 提现金额 + private BigDecimal extractPrice; + + private String mark; + + private BigDecimal balance; + + // 无效原因 + private String failMsg; + + private Date failTime; + + // 添加时间 + private Date createTime; + + // -1 未通过 0 审核中 1 已提现 + private Integer status; + + // 微信号 + private String wechat; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxUserExtractQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxUserExtractQueryCriteria.java new file mode 100644 index 00000000..d7391e99 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/dto/YxUserExtractQueryCriteria.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class YxUserExtractQueryCriteria{ + + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String realName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java new file mode 100644 index 00000000..85204e28 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainServiceImpl.java @@ -0,0 +1,431 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.NumberUtil; +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.OrderInfoEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.YxStoreBargainUserHelpService; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.service.dto.YxStoreBargainDto; +import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreBargainMapper; +import co.yixiang.modules.activity.vo.BargainCountVo; +import co.yixiang.modules.activity.vo.BargainVo; +import co.yixiang.modules.activity.vo.TopCountVo; +import co.yixiang.modules.activity.vo.YxStoreBargainQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.OrderUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** + * @author hupeng + * @date 2020-05-13 + */ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreBargainServiceImpl extends BaseServiceImpl implements YxStoreBargainService { + + @Autowired + private IGenerator generator; + + @Autowired + private YxStoreBargainMapper yxStoreBargainMapper; + + + @Autowired + private YxStoreBargainUserService storeBargainUserService; + @Autowired + private YxStoreOrderService storeOrderService; + @Autowired + private YxStoreBargainUserHelpService storeBargainUserHelpService; + + + + /** + * 退回库存销量 + * @param num 数量 + * @param bargainId 砍价产品id + */ + @Override + public void incStockDecSales(int num, Long bargainId) { + yxStoreBargainMapper.incStockDecSales(num,bargainId); + } + + /** + * 增加销量 减少库存 + * @param num 数量 + * @param bargainId 砍价id + */ + @Override + public void decStockIncSales(int num, Long bargainId) { + int res = yxStoreBargainMapper.decStockIncSales(num,bargainId); + if(res == 0) { + throw new YshopException("砍价产品库存不足"); + } + } + +// @Override +// public YxStoreBargain getBargain(int bargainId) { +// QueryWrapper wrapper = new QueryWrapper<>(); +// int nowTime = OrderUtil.getSecondTimestampTwo(); +// wrapper.eq("id",bargainId).eq("is_del",0).eq("status",1) +// .le("start_time",nowTime).ge("stop_time",nowTime); +// return yxStoreBargainMapper.selectOne(wrapper); +// } + + + + /** + * 开始帮助好友砍价 + * @param bargainId 砍价产品id + * @param bargainUserUid 开启砍价用户id + * @param uid 当前用户id + */ + @Override + public void doHelp(Long bargainId, Long bargainUserUid, Long uid) { + //开始真正的砍价 + YxStoreBargainUser storeBargainUser = storeBargainUserService + .getBargainUserInfo(bargainId,bargainUserUid); + + + YxStoreBargain storeBargain = this.getById(bargainId); + //用户可以砍掉的金额 好友砍价之前获取可以砍价金额 + double coverPrice = NumberUtil.sub(storeBargainUser.getBargainPrice() + ,storeBargainUser.getBargainPriceMin()).doubleValue(); + + double random = 0d; + if(coverPrice > 0 ){ + //用户剩余要砍掉的价格 + double surplusPrice = NumberUtil.sub(coverPrice, + storeBargainUser.getPrice()).doubleValue(); + if(surplusPrice == 0) { + return; + } + + + //生成一个区间随机数 + random = OrderUtil.randomNumber( + storeBargain.getBargainMinPrice().doubleValue(), + storeBargain.getBargainMaxPrice().doubleValue()); + if(random > surplusPrice) { + random = surplusPrice; + } + } + + + //添加砍价帮助表 + YxStoreBargainUserHelp storeBargainUserHelp = YxStoreBargainUserHelp + .builder() + .uid(uid) + .bargainId(bargainId) + .bargainUserId(storeBargainUser.getId()) + .price(BigDecimal.valueOf(random)) + .build(); + storeBargainUserHelpService.save(storeBargainUserHelp); + + //累计砍掉的金额 + double totalPrice = NumberUtil.add(storeBargainUser.getPrice().doubleValue(),random); + + //更新砍价参与表 + YxStoreBargainUser bargainUser = YxStoreBargainUser + .builder() + .id(storeBargainUser.getId()) + .price(BigDecimal.valueOf(totalPrice)) + .build(); + + storeBargainUserService.updateById(bargainUser); + } + + /** + * 顶部统计 + * @param bargainId 砍价商品id + * @return TopCountVo + */ + @Override + public TopCountVo topCount(Long bargainId) { + if(bargainId != null) { + this.addBargainShare(bargainId); + } + return TopCountVo.builder() + .lookCount(yxStoreBargainMapper.lookCount()) + .shareCount(yxStoreBargainMapper.shareCount()) + .userCount(storeBargainUserService.count()) + .build(); + } + + /** + * 砍价 砍价帮总人数、剩余金额、进度条、已经砍掉的价格 + * @param bargainId 砍价商品id + * @param uid 砍价用户id + * @param myUid 当前用户id + * @return BargainCountVo + */ + @Override + public BargainCountVo helpCount(Long bargainId, Long uid, Long myUid) { + YxStoreBargainUser storeBargainUser = storeBargainUserService + .getBargainUserInfo(bargainId,uid); + // 是否帮别人砍,没砍是true,砍了false + boolean userBargainStatus = true; + if(storeBargainUser == null) { + return BargainCountVo + .builder() + .count(0L) + .alreadyPrice(0d) + .status(0) + .pricePercent(0) + .price(0d) + .userBargainStatus(userBargainStatus) + .build(); + } + + + Long helpCount = storeBargainUserHelpService.lambdaQuery() + .eq(YxStoreBargainUserHelp::getBargainUserId,storeBargainUser.getId()) + .eq(YxStoreBargainUserHelp::getBargainId,bargainId) + .eq(YxStoreBargainUserHelp::getUid,myUid) + .count(); + + if(helpCount > 0) { + userBargainStatus = false; + } + + + Long count = storeBargainUserHelpService + .getBargainUserHelpPeopleCount(bargainId,storeBargainUser.getId()); + //用户可以砍掉的价格 + double diffPrice = NumberUtil.sub(storeBargainUser.getBargainPrice() + ,storeBargainUser.getBargainPriceMin()).doubleValue(); + //砍价进度条百分比 + int pricePercent = 0; + if(diffPrice <= 0) { + pricePercent = 100; + }else{ + pricePercent = NumberUtil.round(NumberUtil.mul(NumberUtil.div( + storeBargainUser.getPrice(),diffPrice),100) + ,0).intValue(); + } + + + + //剩余的砍价金额 + double surplusPrice = NumberUtil.sub(diffPrice,storeBargainUser.getPrice()).doubleValue(); + + return BargainCountVo + .builder() + .count(count) + .alreadyPrice(storeBargainUser.getPrice().doubleValue()) + .status(storeBargainUser.getStatus()) + .pricePercent(pricePercent) + .price(surplusPrice) + .userBargainStatus(userBargainStatus) + .build(); + } + + + + + + /** + * 砍价详情 + * @param id 砍价id + * @param yxUser 用户 + * @return BargainVo + */ + @Override + public BargainVo getDetail(Long id, YxUser yxUser) { + + Date now = new Date(); + YxStoreBargain storeBargain = this.lambdaQuery().eq(YxStoreBargain::getId,id) + .eq(YxStoreBargain::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .le(YxStoreBargain::getStartTime,now) + .ge(YxStoreBargain::getStopTime,now) + .one(); + + if(storeBargain == null) { + throw new YshopException("砍价已结束"); + } + + this.addBargainLook(id); + + YxStoreBargainQueryVo storeBargainQueryVo = generator.convert(storeBargain, + YxStoreBargainQueryVo.class); + + return BargainVo + .builder() + .bargain(storeBargainQueryVo) + .userInfo(generator.convert(yxUser, YxUserQueryVo.class)) + .bargainSumCount(this.getBargainPayCount(id)) + .build(); + } + + /** + * 获取砍价商品列表 + * @param page page + * @param limit limit + * @return List + */ + @Override + public List getList(int page, int limit) { + Page pageModel = new Page<>(page, limit); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + Date nowTime = new Date(); + wrapper.eq(YxStoreBargain::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .lt(YxStoreBargain::getStartTime,nowTime) + .gt(YxStoreBargain::getStopTime,nowTime); + + List yxStoreBargainQueryVos = generator.convert( + yxStoreBargainMapper.selectPage(pageModel,wrapper).getRecords(), + YxStoreBargainQueryVo.class); + + yxStoreBargainQueryVos.forEach(item->{ + item.setPeople(storeBargainUserService.getBargainUserCount(item.getId(), + OrderInfoEnum.BARGAIN_STATUS_1.getValue())); + }); + + return yxStoreBargainQueryVos; + } + + + /** + * 增加分享次数 + * @param id 砍价商品id + */ + private void addBargainShare(Long id) { + yxStoreBargainMapper.addBargainShare(id); + } + + /** + * 增加浏览次数 + * @param id 砍价商品id + */ + private void addBargainLook(Long id) { + yxStoreBargainMapper.addBargainLook(id); + } + + + /** + * 砍价支付成功订单数量 + * @param bargainId 砍价id + * @return int + */ + private Long getBargainPayCount(Long bargainId) { + return storeOrderService.lambdaQuery().eq(YxStoreOrder::getBargainId,bargainId) + .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) + .count(); + } + + + //===================================================================// + + @Override + //@Cacheable + public Map queryAll(YxStoreBargainQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + List storeBargainDtoList = generator.convert(page.getList(), YxStoreBargainDto.class); + for (YxStoreBargainDto storeBargainDto : storeBargainDtoList) { + + String statusStr = OrderUtil.checkActivityStatus(storeBargainDto.getStartTime(), + storeBargainDto.getStopTime(), storeBargainDto.getStatus()); + storeBargainDto.setStatusStr(statusStr); + } + map.put("content", storeBargainDtoList); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreBargainQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreBargain.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreBargainDto yxStoreBargain : all) { + Map map = new LinkedHashMap<>(); + map.put("关联产品ID", yxStoreBargain.getProductId()); + map.put("砍价活动名称", yxStoreBargain.getTitle()); + map.put("砍价活动图片", yxStoreBargain.getImage()); + map.put("单位名称", yxStoreBargain.getUnitName()); + map.put("库存", yxStoreBargain.getStock()); + map.put("销量", yxStoreBargain.getSales()); + map.put("砍价产品轮播图", yxStoreBargain.getImages()); + map.put("砍价开启时间", yxStoreBargain.getStartTime()); + map.put("砍价结束时间", yxStoreBargain.getStopTime()); + map.put("砍价产品名称", yxStoreBargain.getStoreName()); + map.put("砍价金额", yxStoreBargain.getPrice()); + map.put("砍价商品最低价", yxStoreBargain.getMinPrice()); + map.put("每次购买的砍价产品数量", yxStoreBargain.getNum()); + map.put("用户每次砍价的最大金额", yxStoreBargain.getBargainMaxPrice()); + map.put("用户每次砍价的最小金额", yxStoreBargain.getBargainMinPrice()); + map.put("用户每次砍价的次数", yxStoreBargain.getBargainNum()); + map.put("砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)", yxStoreBargain.getStatus()); + map.put("砍价详情", yxStoreBargain.getDescription()); + map.put("反多少积分", yxStoreBargain.getGiveIntegral()); + map.put("砍价活动简介", yxStoreBargain.getInfo()); + map.put("成本价", yxStoreBargain.getCost()); + map.put("排序", yxStoreBargain.getSort()); + map.put("是否推荐0不推荐1推荐", yxStoreBargain.getIsHot()); + map.put("是否包邮 0不包邮 1包邮", yxStoreBargain.getIsPostage()); + map.put("邮费", yxStoreBargain.getPostage()); + map.put("砍价规则", yxStoreBargain.getRule()); + map.put("砍价产品浏览量", yxStoreBargain.getLook()); + map.put("砍价产品分享量", yxStoreBargain.getShare()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 删除砍价海报 + * + * @param name + */ + @Override + public void deleteBargainImg(String name) { + baseMapper.deleteBargainImg(name); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserHelpServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserHelpServiceImpl.java new file mode 100644 index 00000000..d7232851 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserHelpServiceImpl.java @@ -0,0 +1,111 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; +import co.yixiang.modules.activity.service.YxStoreBargainUserHelpService; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.service.mapper.YxStoreBargainUserHelpMapper; +import co.yixiang.modules.activity.vo.YxStoreBargainUserHelpQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; + + +/** + *

+ * 砍价用户帮助表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +@Slf4j +@Service +@Transactional(rollbackFor = Exception.class) +public class YxStoreBargainUserHelpServiceImpl extends BaseServiceImpl implements YxStoreBargainUserHelpService { + + @Autowired + private IGenerator generator; + + @Autowired + private YxStoreBargainUserHelpMapper yxStoreBargainUserHelpMapper; + + @Autowired + private YxStoreBargainUserService storeBargainUserService; + @Autowired + private YxUserService userService; + + + + + /** + * 获取砍价帮 + * @param bargainId 砍价商品id + * @param bargainUserUid 砍价用户id + * @param page page + * @param limit limit + * @return list + */ + @Override + public List getList(Long bargainId, Long bargainUserUid, + int page, int limit) { + YxStoreBargainUser storeBargainUser = storeBargainUserService + .getBargainUserInfo(bargainId,bargainUserUid); + if(ObjectUtil.isNull(storeBargainUser)) { + return Collections.emptyList(); + } + Page pageModel = new Page<>(page, limit); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreBargainUserHelp::getBargainUserId,storeBargainUser.getId()) + .orderByDesc(YxStoreBargainUserHelp::getId); + List storeBargainUserHelpQueryVos = generator + .convert(yxStoreBargainUserHelpMapper.selectPage(pageModel,wrapper).getRecords(), + YxStoreBargainUserHelpQueryVo.class); + + storeBargainUserHelpQueryVos.forEach(item->{ + YxUser yxUser = userService.getById(item.getUid()); + item.setAvatar(yxUser.getAvatar()); + item.setNickname(yxUser.getNickname()); + }); + + return storeBargainUserHelpQueryVos; + } + + /** + * 获取砍价帮总人数 + * @param bargainId 砍价产品ID + * @param bargainUserUid 用户参与砍价表id + * @return int + */ + @Override + public Long getBargainUserHelpPeopleCount(Long bargainId, Long bargainUserUid) { + return this.lambdaQuery() + .eq(YxStoreBargainUserHelp::getBargainUserId,bargainUserUid) + .eq(YxStoreBargainUserHelp::getBargainId,bargainId) + .count(); + } + + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java new file mode 100644 index 00000000..8b0daef0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreBargainUserServiceImpl.java @@ -0,0 +1,229 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.YxStoreBargainUserHelpService; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.service.mapper.YxStoreBargainUserMapper; +import co.yixiang.modules.activity.vo.YxStoreBargainUserQueryVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; + + +/** + *

+ * 用户参与砍价表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +@Slf4j +@Service +public class YxStoreBargainUserServiceImpl extends BaseServiceImpl implements YxStoreBargainUserService { + + + @Autowired + private IGenerator generator; + + @Autowired + private YxStoreBargainUserMapper yxStoreBargainUserMapper; + + @Autowired + private YxStoreBargainService storeBargainService; + @Autowired + private YxStoreBargainUserHelpService storeBargainUserHelpService; + + + /** + * 修改用户砍价状态 + * @param bargainId 砍价产品id + * @param uid 用户id + */ + @Override + public void setBargainUserStatus(Long bargainId, Long uid) { + YxStoreBargainUser storeBargainUser = getBargainUserInfo(bargainId.longValue(),uid); + if(ObjectUtil.isNull(storeBargainUser)) { + return; + } + + if(storeBargainUser.getStatus() != 1) { + return; + } + double price = NumberUtil.sub(NumberUtil.sub(storeBargainUser.getBargainPrice(), + storeBargainUser.getBargainPriceMin()),storeBargainUser.getPrice()).doubleValue(); + if(price > 0) { + return; + } + + storeBargainUser.setStatus(3); + + yxStoreBargainUserMapper.updateById(storeBargainUser); + } + + /** + * 砍价取消 + * @param bargainId 砍价商品id + * @param uid uid + */ + @Override + public void bargainCancel(Long bargainId, Long uid) { + YxStoreBargainUser storeBargainUser = this.getBargainUserInfo(bargainId,uid); + if(ObjectUtil.isNull(storeBargainUser)) { + throw new YshopException("数据不存在"); + } + if(!OrderInfoEnum.BARGAIN_STATUS_1.getValue().equals(storeBargainUser.getStatus())){ + throw new YshopException("状态错误"); + } + yxStoreBargainUserMapper.deleteById(storeBargainUser.getId()); + } + + /** + * 获取用户的砍价产品 + * @param bargainUserUid 用户id + * @param page page + * @param limit limit + * @return List + */ + @Override + public List bargainUserList(Long bargainUserUid, int page, int limit) { + Page pageModel = new Page<>(page, limit); + return yxStoreBargainUserMapper.getBargainUserList(bargainUserUid,pageModel); + } + + /** + * 判断用户是否还可以砍价 + * @param bargainId 砍价产品id + * @param bargainUserUid 开启砍价用户id + * @param uid 当前用户id + * @return false=NO true=YES + */ + @Override + public boolean isBargainUserHelp(Long bargainId, Long bargainUserUid, Long uid) { + YxStoreBargainUser storeBargainUser = this.getBargainUserInfo(bargainId, bargainUserUid); + YxStoreBargain storeBargain = storeBargainService + .getById(bargainId); + if(ObjectUtil.isNull(storeBargainUser) || ObjectUtil.isNull(storeBargain)){ + return false; + } + Long count = storeBargainUserHelpService.lambdaQuery() + .eq(YxStoreBargainUserHelp::getBargainId,bargainId) + .eq(YxStoreBargainUserHelp::getBargainUserId,storeBargainUser.getId()) + .eq(YxStoreBargainUserHelp::getUid,uid) + .count(); + if(count == 0) { + return true; + } + return false; + } + + /** + * 添加砍价记录 + * @param bargainId 砍价商品id + * @param uid 用户id + */ + @Override + public void setBargain(Long bargainId, Long uid) { + YxStoreBargainUser storeBargainUser = this.getBargainUserInfo(bargainId,uid); + if(storeBargainUser != null) { + throw new YshopException("你已经参与了"); + } + YxStoreBargain storeBargain = storeBargainService.getById(bargainId); + if(storeBargain == null) { + throw new YshopException("砍价商品不存在"); + } + YxStoreBargainUser yxStoreBargainUser = YxStoreBargainUser + .builder() + .bargainId(bargainId) + .uid(uid) + .bargainPrice(storeBargain.getPrice()) + .bargainPriceMin(storeBargain.getMinPrice()) + .price(BigDecimal.ZERO) + .status(OrderInfoEnum.BARGAIN_STATUS_1.getValue()) + .build(); + yxStoreBargainUserMapper.insert(yxStoreBargainUser); + } + +// /** +// * 获取用户可以砍掉的价格 +// * @param id +// * @return +// */ +// @Override +// public double getBargainUserDiffPrice(int id) { +// YxStoreBargainUser storeBargainUserQueryVo = this.getById(id); +// return NumberUtil.sub(storeBargainUserQueryVo.getBargainPrice() +// ,storeBargainUserQueryVo.getBargainPriceMin()).doubleValue(); +// } + + + + /** + * 获取某个用户参与砍价信息 + * @param bargainId 砍价id + * @param uid 用户id + * @return YxStoreBargainUser + */ + @Override + public YxStoreBargainUser getBargainUserInfo(Long bargainId, Long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreBargainUser::getBargainId,bargainId) + .eq(YxStoreBargainUser::getUid,uid) + .last("limit 1"); + return yxStoreBargainUserMapper.selectOne(wrapper); + } + + /** + * 获取参与砍价的用户数量 + * @param bargainId 砍价id + * @param status 状态 OrderInfoEnum 1 进行中 2 结束失败 3结束成功 + * @return int + */ + @Override + public Long getBargainUserCount(Long bargainId, Integer status) { + return this.lambdaQuery().eq(YxStoreBargainUser::getBargainId,bargainId) + .eq(YxStoreBargainUser::getStatus,status).count(); + } + + +// +// /** +// * 获取参与砍价的用户列表 +// * @param bargainId 砍价id +// * @param status 状态 1 进行中 2 结束失败 3结束成功 +// * @return +// */ +// @Override +// public List getBargainUserList(int bargainId, int status) { +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq("bargain_id",bargainId).eq("status",status); +// return generator.convert(yxStoreBargainUserMapper.selectList(wrapper), +// YxStoreBargainUserQueryVo.class); +// } + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java new file mode 100644 index 00000000..0b49fad2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java @@ -0,0 +1,390 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +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 cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.ProductTypeEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.enums.SpecTypeEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.activity.domain.YxStoreCombination; +import co.yixiang.modules.activity.domain.YxStorePink; +import co.yixiang.modules.activity.domain.YxStoreSeckill; +import co.yixiang.modules.activity.domain.YxStoreVisit; +import co.yixiang.modules.activity.service.YxStoreCombinationService; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.activity.service.dto.PinkAllDto; +import co.yixiang.modules.activity.service.dto.YxStoreCombinationDto; +import co.yixiang.modules.activity.service.dto.YxStoreCombinationQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreCombinationMapper; +import co.yixiang.modules.activity.service.mapper.YxStorePinkMapper; +import co.yixiang.modules.activity.service.mapper.YxStoreVisitMapper; +import co.yixiang.modules.activity.vo.CombinationQueryVo; +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.domain.YxStoreProductAttrValue; +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.YxStoreProductService; +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.modules.product.vo.YxStoreProductAttrQueryVo; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.utils.FileUtil; + +import co.yixiang.utils.RedisUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class YxStoreCombinationServiceImpl extends BaseServiceImpl implements YxStoreCombinationService { + + @Autowired + private IGenerator generator; + + @Autowired + private YxStorePinkMapper yxStorePinkMapper; + @Autowired + private YxStoreVisitMapper yxStoreVisitMapper; + @Autowired + private RedisUtils redisUtils; + @Autowired + private YxStoreCombinationMapper yxStoreCombinationMapper; + @Autowired + private YxStoreProductReplyService replyService; + @Autowired + private YxStorePinkService storePinkService; + @Autowired + private YxStoreProductAttrService yxStoreProductAttrService; + @Autowired + private YxStoreProductAttrValueService yxStoreProductAttrValueService; + @Autowired + private YxShippingTemplatesService shippingTemplatesService; + + @Autowired + private YxStoreProductService storeProductService; + + + + /** + * 获取拼团详情 + * @param id 拼团产品id + * @param uid uid + * @return StoreCombinationVo + */ + @Override + public StoreCombinationVo getDetail(Long id, Long uid) { + Date now = new Date(); + YxStoreCombination storeCombination = this + .lambdaQuery().eq(YxStoreCombination::getId,id) + .eq(YxStoreCombination::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .le(YxStoreCombination::getStartTime,now) + .ge(YxStoreCombination::getStopTime,now) + .one(); + if(storeCombination == null){ + throw new YshopException("拼团不存在或已下架"); + } + //获取商品sku + Map returnMap = yxStoreProductAttrService.getProductAttrDetail(storeCombination.getProductId()); + + YxStoreCombinationQueryVo storeCombinationQueryVo = generator.convert(storeCombination, + YxStoreCombinationQueryVo.class); + + StoreCombinationVo storeCombinationVo = new StoreCombinationVo(); + + storeCombinationVo.setStoreInfo(storeCombinationQueryVo); + + //评价 + storeCombinationVo.setReply(replyService + .getReply(storeCombinationQueryVo.getProductId())); + Long replyCount = replyService.productReplyCount(storeCombinationQueryVo.getProductId()); + //总条数 + storeCombinationVo.setReplyCount(replyCount); + //好评比例 + storeCombinationVo.setReplyChance(replyService.replyPer(storeCombinationQueryVo.getProductId())); + + //获取运费模板名称 + String storeFreePostage = redisUtils.get("store_free_postage").toString(); + String tempName = ""; + if(StrUtil.isBlank(storeFreePostage) + || !NumberUtil.isNumber(storeFreePostage) + || Integer.valueOf(storeFreePostage) == 0){ + tempName = "全国包邮"; + }else{ + YxShippingTemplates shippingTemplates = shippingTemplatesService.getById(storeCombination.getTempId()); + if(ObjectUtil.isNotNull(shippingTemplates)){ + tempName = shippingTemplates.getName(); + }else { + throw new BadRequestException("请配置运费模板"); + } + + } + storeCombinationVo.setTempName(tempName); + + PinkAllDto pinkAllDto = storePinkService.getPinkAll(id); + storeCombinationVo.setPindAll(pinkAllDto.getPindAll()); + storeCombinationVo.setPink(pinkAllDto.getList()); + storeCombinationVo.setPinkOkList(storePinkService.getPinkOkList(uid)); + storeCombinationVo.setPinkOkSum(storePinkService.getPinkOkSumTotalNum()); + storeCombinationVo.setProductAttr((List)returnMap.get("productAttr")); + storeCombinationVo.setProductValue((Map)returnMap.get("productValue")); + return storeCombinationVo; + } + + /** + * 拼团列表 + * @param page page + * @param limit limit + * @return list + */ + @Override + public CombinationQueryVo getList(int page, int limit) { + CombinationQueryVo combinationQueryVo = new CombinationQueryVo(); + Date nowTime = new Date(); + Page pageModel = new Page<>(page, limit); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper + .eq(YxStoreCombination::getIsShow,1) + .le(YxStoreCombination::getStartTime,nowTime) + .ge(YxStoreCombination::getStopTime,nowTime) + .orderByDesc(YxStoreCombination::getSort); + IPage yxStoreCombinationIPage = yxStoreCombinationMapper.selectPage(pageModel, wrapper); + + List collect = yxStoreCombinationIPage.getRecords().stream().map(i -> { + YxStoreCombinationQueryVo yxStoreCombinationQueryVo = new YxStoreCombinationQueryVo(); + BeanUtils.copyProperties(i, yxStoreCombinationQueryVo); + return yxStoreCombinationQueryVo; + }).collect(Collectors.toList()); + combinationQueryVo.setStoreCombinationQueryVos(collect); + combinationQueryVo.setLastPage(yxStoreCombinationIPage.getPages()); + return combinationQueryVo; + } + + + //=======================================// + + @Override + //@Cacheable + public Map queryAll(YxStoreCombinationQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + + List combinationDTOS = generator.convert(page.getList(),YxStoreCombinationDto.class); + for (YxStoreCombinationDto combinationDTO : combinationDTOS) { + //参与人数 + combinationDTO.setCountPeopleAll(yxStorePinkMapper.selectCount(new LambdaQueryWrapper() + .eq(YxStorePink::getCid,combinationDTO.getId()))); + + //成团人数 + combinationDTO.setCountPeoplePink(yxStorePinkMapper.selectCount(new LambdaQueryWrapper() + .eq(YxStorePink::getCid,combinationDTO.getId()) + .eq(YxStorePink::getKId,0)));//团长 + //获取查看拼团产品人数 + combinationDTO.setCountPeopleBrowse(yxStoreVisitMapper.selectCount(new LambdaQueryWrapper() + .eq(YxStoreVisit::getProductId,combinationDTO.getId()) + .eq(YxStoreVisit::getProductType, ProductTypeEnum.COMBINATION.getValue()))); + } + Map map = new LinkedHashMap<>(2); + map.put("content",combinationDTOS); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCombinationQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCombination.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCombinationDto yxStoreCombination : all) { + Map map = new LinkedHashMap<>(); + map.put("商品id", yxStoreCombination.getProductId()); + map.put("推荐图", yxStoreCombination.getImage()); + map.put("轮播图", yxStoreCombination.getImages()); + map.put("活动标题", yxStoreCombination.getTitle()); + map.put("参团人数", yxStoreCombination.getPeople()); + map.put("简介", yxStoreCombination.getInfo()); + map.put("价格", yxStoreCombination.getPrice()); + map.put("排序", yxStoreCombination.getSort()); + map.put("销量", yxStoreCombination.getSales()); + map.put("库存", yxStoreCombination.getStock()); + map.put("推荐", yxStoreCombination.getIsHost()); + map.put("产品状态", yxStoreCombination.getIsShow()); + map.put(" combination", yxStoreCombination.getCombination()); + map.put("商户是否可用1可用0不可用", yxStoreCombination.getMerUse()); + map.put("是否包邮1是0否", yxStoreCombination.getIsPostage()); + map.put("邮费", yxStoreCombination.getPostage()); + map.put("拼团内容", yxStoreCombination.getDescription()); + map.put("拼团开始时间", yxStoreCombination.getStartTime()); + map.put("拼团结束时间", yxStoreCombination.getStopTime()); + map.put("拼团订单有效时间", yxStoreCombination.getEffectiveTime()); + map.put("拼团产品成本", yxStoreCombination.getCost()); + map.put("浏览量", yxStoreCombination.getBrowse()); + map.put("单位名", yxStoreCombination.getUnitName()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 修改状态 + * @param id 拼团产品id + * @param status ShopCommonEnum + */ + @Override + public void onSale(Long id, Integer status) { + if(ShopCommonEnum.SHOW_1.getValue().equals(status)){ + status = ShopCommonEnum.SHOW_0.getValue(); + }else{ + status = ShopCommonEnum.SHOW_1.getValue(); + } + YxStoreCombination yxStoreCombination = new YxStoreCombination(); + yxStoreCombination.setIsShow(status); + 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.setProductPrice(BigDecimal.valueOf(resultDTO.getMinOtPrice())); + 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 attrs = resources.getAttrs(); + ProductFormatDto productFormatDto = attrs.get(0); + productFormatDto.setValue1("规格"); + Map map = new HashMap<>(); + map.put("规格","默认"); + productFormatDto.setDetail(map); + yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto), + ListUtil.toList(productFormatDto),resources.getProductId()); + }else{ + yxStoreProductAttrService.insertYxStoreProductAttr(resources.getItems(), + resources.getAttrs(),resources.getProductId()); + } + return true; + } + + + /** + * 计算产品数据 + * @param attrs attrs + * @return ProductResultDto + */ + private ProductResultDto computedProduct(List attrs){ + //取最小价格 + Double minPrice = attrs + .stream() + .map(ProductFormatDto::getPinkPrice) + .min(Comparator.naturalOrder()) + .orElse(0d); + + Double minOtPrice = attrs + .stream() + .map(ProductFormatDto::getOtPrice) + .min(Comparator.naturalOrder()) + .orElse(0d); + + Double minCost = attrs + .stream() + .map(ProductFormatDto::getCost) + .min(Comparator.naturalOrder()) + .orElse(0d); + //计算库存 + Integer stock = attrs + .stream() + .map(ProductFormatDto::getPinkStock) + .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 ListMapToListBean(List> listMap){ + List list = new ArrayList<>(); + // 循环遍历出map对象 + for (Map m : listMap) { + list.add(BeanUtil.mapToBean(m,ProductFormatDto.class,true)); + } + return list; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueServiceImpl.java new file mode 100644 index 00000000..bbadbb61 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueServiceImpl.java @@ -0,0 +1,177 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.ObjectUtil; +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.CouponEnum; +import co.yixiang.modules.activity.domain.YxStoreCouponIssue; +import co.yixiang.modules.activity.domain.YxStoreCouponIssueUser; +import co.yixiang.modules.activity.service.YxStoreCouponIssueService; +import co.yixiang.modules.activity.service.YxStoreCouponIssueUserService; +import co.yixiang.modules.activity.service.YxStoreCouponUserService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponIssueMapper; +import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl implements YxStoreCouponIssueService { + + private final IGenerator generator; + + private final YxStoreCouponIssueMapper yxStoreCouponIssueMapper; + + + private final YxStoreCouponUserService storeCouponUserService; + private final YxStoreCouponIssueUserService storeCouponIssueUserService; + + + /** + * 领取优惠券 + * @param id id 优惠券id + * @param uid uid + */ + @Override + public void issueUserCoupon(Integer id, Long uid) { + YxStoreCouponIssueQueryVo couponIssueQueryVo = yxStoreCouponIssueMapper + .selectOne(id); + if(ObjectUtil.isNull(couponIssueQueryVo)) { + throw new YshopException("领取的优惠劵已领完或已过期"); + } + + Long count = this.couponCount(id,uid); + if(count > 0) { + throw new YshopException("已领取过该优惠劵"); + } + + if(couponIssueQueryVo.getRemainCount() <= 0 + && CouponEnum.PERMANENT_0.getValue().equals(couponIssueQueryVo.getIsPermanent())){ + throw new YshopException("抱歉优惠卷已经领取完了"); + } + + storeCouponUserService.addUserCoupon(uid,couponIssueQueryVo.getCid()); + + storeCouponIssueUserService.addUserIssue(uid,id); + + if(couponIssueQueryVo.getTotalCount() > 0){ + yxStoreCouponIssueMapper.decCount(id); + } + + } + + + /** + * 优惠券列表 + * @param page page + * @param limit limit + * @param uid 用户id + * @return list + */ + @Override + public List getCouponList(int page, int limit, Long uid,Long productId,Integer type) { + Page pageModel = new Page<>(page, limit); + + if(type == null) { + type = CouponEnum.TYPE_0.getValue(); + } + List list = yxStoreCouponIssueMapper + .selecCoupontList(pageModel,type,productId); + for (YxStoreCouponIssueQueryVo couponIssue : list) { + Long count = this.couponCount(couponIssue.getId(),uid); + if(count > 0){ + couponIssue.setIsUse(true); + }else{ + couponIssue.setIsUse(false); + } + + } + return list; + } + + + /** + * 获取用户领取优惠券数量 + * @param id 前台优惠券id + * @param uid 用户id + * @return int + */ + private Long couponCount(Integer id, Long uid) { + return storeCouponIssueUserService.lambdaQuery() + .eq(YxStoreCouponIssueUser::getUid,uid) + .eq(YxStoreCouponIssueUser::getIssueCouponId,id) + .count(); + } + + //============================================================// + + + @Override + //@Cacheable + public Map queryAll(YxStoreCouponIssueQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreCouponIssueDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCouponIssueQueryCriteria criteria){ + return this.list(QueryHelpPlus.getPredicate(YxStoreCouponIssue.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCouponIssueDto yxStoreCouponIssue : all) { + Map map = new LinkedHashMap<>(); + map.put(" cname", yxStoreCouponIssue.getCname()); + map.put("优惠券ID", yxStoreCouponIssue.getCid()); + map.put("优惠券领取开启时间", yxStoreCouponIssue.getStartTime()); + map.put("优惠券领取结束时间", yxStoreCouponIssue.getEndTime()); + map.put("优惠券领取数量", yxStoreCouponIssue.getTotalCount()); + map.put("优惠券剩余领取数量", yxStoreCouponIssue.getRemainCount()); + map.put("是否无限张数", yxStoreCouponIssue.getIsPermanent()); + map.put("1 正常 0 未开启 -1 已无效", yxStoreCouponIssue.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueUserServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueUserServiceImpl.java new file mode 100644 index 00000000..3fb13e65 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponIssueUserServiceImpl.java @@ -0,0 +1,94 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.activity.domain.YxStoreCouponIssueUser; +import co.yixiang.modules.activity.service.YxStoreCouponIssueUserService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponIssueUserQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponIssueUserMapper; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCouponIssueUserServiceImpl extends BaseServiceImpl implements YxStoreCouponIssueUserService { + + private final IGenerator generator; + + /** + * 添加优惠券领取记录 + * @param uid 用户id + * @param id 前台优惠券id + */ + @Override + public void addUserIssue(Long uid, Integer id) { + YxStoreCouponIssueUser couponIssueUser = new YxStoreCouponIssueUser(); + couponIssueUser.setIssueCouponId(id); + couponIssueUser.setUid(uid); + this.save(couponIssueUser); + } + + + @Override + //@Cacheable + public Map queryAll(YxStoreCouponIssueUserQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreCouponIssueUserDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCouponIssueUserQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCouponIssueUser.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCouponIssueUserDto yxStoreCouponIssueUser : all) { + Map map = new LinkedHashMap<>(); + map.put("领取优惠券用户ID", yxStoreCouponIssueUser.getUid()); + map.put("优惠券前台领取ID", yxStoreCouponIssueUser.getIssueCouponId()); + map.put("领取时间", yxStoreCouponIssueUser.getAddTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponServiceImpl.java new file mode 100644 index 00000000..75cc19bd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponServiceImpl.java @@ -0,0 +1,95 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import co.yixiang.modules.activity.service.YxStoreCouponService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponMapper; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCouponServiceImpl extends BaseServiceImpl implements YxStoreCouponService { + + private final IGenerator generator; + private final YxStoreProductService storeProductService; + + @Override + //@Cacheable + public Map queryAll(YxStoreCouponQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + List storeCouponDtos = generator.convert(page.getList(), YxStoreCouponDto.class); + for (YxStoreCouponDto storeCouponDto : storeCouponDtos) { + if(StrUtil.isNotBlank(storeCouponDto.getProductId())){ + List storeProducts = storeProductService.lambdaQuery() + .in(YxStoreProduct::getId, Arrays.asList(storeCouponDto.getProductId().split(","))) + .list(); + storeCouponDto.setProduct(storeProducts); + } + } + map.put("content", storeCouponDtos); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCouponQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCoupon.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCouponDto yxStoreCoupon : all) { + Map map = new LinkedHashMap<>(); + map.put("优惠券名称", yxStoreCoupon.getTitle()); + map.put("兑换消耗积分值", yxStoreCoupon.getIntegral()); + map.put("兑换的优惠券面值", yxStoreCoupon.getCouponPrice()); + map.put("最低消费多少金额可用优惠券", yxStoreCoupon.getUseMinPrice()); + map.put("优惠券有效期限(单位:天)", yxStoreCoupon.getCouponTime()); + map.put("排序", yxStoreCoupon.getSort()); + map.put("状态(0:关闭,1:开启)", yxStoreCoupon.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java new file mode 100644 index 00000000..55480697 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java @@ -0,0 +1,353 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.CouponEnum; +import co.yixiang.enums.CouponGetEnum; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.service.YxStoreCouponService; +import co.yixiang.modules.activity.service.YxStoreCouponUserService; +import co.yixiang.modules.activity.service.dto.YxStoreCouponUserDto; +import co.yixiang.modules.activity.service.dto.YxStoreCouponUserQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreCouponUserMapper; +import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import co.yixiang.modules.activity.vo.YxStoreCouponUserQueryVo; +import co.yixiang.modules.cart.service.YxStoreCartService; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCouponUserServiceImpl extends BaseServiceImpl implements YxStoreCouponUserService { + + @Autowired + private IGenerator generator; + + + @Autowired + private YxStoreCouponUserMapper yxStoreCouponUserMapper; + + @Autowired + private YxUserService userService; + @Autowired + private YxStoreCouponService storeCouponService; + @Autowired + private YxStoreCartService yxStoreCartService; + + /** + * 获取当前用户优惠券数量 + * @param uid uid + * @return int + */ + @Override + public Long getUserValidCouponCount(Long uid) { + this.checkInvalidCoupon(); + return this.lambdaQuery() + .eq(YxStoreCouponUser::getStatus, CouponEnum.STATUS_0.getValue()) + .eq(YxStoreCouponUser::getUid,uid) + .count(); + } + + /** + * 获取满足条件的可用优惠券 + * @param cartIds 购物车ids + * @return list + */ + @Override + public List beUsableCouponList(Long uid,String cartIds) { + + Map cartGroup = yxStoreCartService.getUserProductCartList(uid, + cartIds, ShopConstants.YSHOP_ONE_NUM); + + List cartInfo = (List)cartGroup.get("valid"); + + BigDecimal sumPrice = BigDecimal.ZERO; + for (YxStoreCartQueryVo storeCart : cartInfo) { + sumPrice = NumberUtil.add(sumPrice,NumberUtil.mul(storeCart.getCartNum(),storeCart.getTruePrice())); + } + + List productIds = cartInfo.stream() + .map(YxStoreCartQueryVo::getProductId) + .map(Object::toString) + .collect(Collectors.toList()); + + + return this.getUsableCouponList(uid, sumPrice.doubleValue(), productIds); + } + + /** + * 获取下单时候满足的优惠券 + * @param uid uid + * @param price 总价格 + * @param productIds list + * @return list + */ + @Override + public List getUsableCouponList(Long uid, double price, List productIds) { + Date now = new Date(); + List storeCouponUsers = yxStoreCouponUserMapper.selectCouponList(now, price, uid); + return storeCouponUsers.stream() + .filter(coupon -> + CouponEnum.TYPE_2.getValue().equals(coupon.getType()) || + CouponEnum.TYPE_0.getValue().equals(coupon.getType()) + || (CouponEnum.TYPE_1.getValue().equals(coupon.getType()) + && isSame(Arrays.asList(coupon.getProductId().split(",")),productIds))) + .collect(Collectors.toList()); + + } + + + + + /** + * 获取用户优惠券 + * @param id 优惠券id + * @param uid 用户id + * @return YxStoreCouponUser + */ + @Override + public YxStoreCouponUser getCoupon(Integer id,Long uid) { + return this.lambdaQuery() + .eq(YxStoreCouponUser::getIsFail, CouponEnum.FALI_0.getValue()) + .eq(YxStoreCouponUser::getStatus,CouponEnum.STATUS_0.getValue()) + .eq(YxStoreCouponUser::getUid,uid) + .eq(YxStoreCouponUser::getId,id) + .one(); + } + + @Override + public void useCoupon(int id) { + YxStoreCouponUser couponUser = new YxStoreCouponUser(); + couponUser.setId((long)id); + couponUser.setStatus(1); + couponUser.setUseTime(new Date()); + yxStoreCouponUserMapper.updateById(couponUser); + } + + + + /** + * 获取用户优惠券 + * @param uid uid + * @return list + */ + @Override + public List getUserCoupon(Long uid) { + //this.checkInvalidCoupon(); + List storeCouponUsers = yxStoreCouponUserMapper + .selectList(Wrappers.lambdaQuery() + .eq(YxStoreCouponUser::getUid,uid)); + List storeCouponUserQueryVoList = new ArrayList<>(); + long nowTime = System.currentTimeMillis(); + for (YxStoreCouponUser couponUser : storeCouponUsers) { + YxStoreCouponUserQueryVo queryVo = generator.convert(couponUser,YxStoreCouponUserQueryVo.class); + if(couponUser.getIsFail() == 1){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已失效"); + }else if (couponUser.getStatus() == 1){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已使用"); + }else if (couponUser.getStatus() == 2){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已过期"); + }else if(couponUser.getCreateTime().getTime() > nowTime || couponUser.getEndTime().getTime() < nowTime){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已过期"); + }else{ + queryVo.set_type(CouponEnum.USE_1.getValue()); + queryVo.set_msg("可使用"); + } + + storeCouponUserQueryVoList.add(queryVo); + } + return storeCouponUserQueryVoList; + } + + /** + * 添加优惠券记录 + * @param uid 用户id + * @param cid 优惠券id + */ + @Override + public void addUserCoupon(Long uid, Integer cid) { + YxStoreCoupon storeCoupon = storeCouponService.getById(cid); + if(storeCoupon == null) { + throw new YshopException("优惠劵不存在"); + } + + Date now = new Date(); + + Date endTime = DateUtil.offsetDay(now,storeCoupon.getCouponTime()); + + YxStoreCouponUser storeCouponUser = YxStoreCouponUser.builder() + .cid(storeCoupon.getId()) + .uid(uid) + .couponPrice(storeCoupon.getCouponPrice()) + .couponTitle(storeCoupon.getTitle()) + .useMinPrice(storeCoupon.getUseMinPrice()) + .endTime(endTime) + .type(CouponGetEnum.GET.getValue()) + .build(); + + this.save(storeCouponUser); + + } + + + /** + * 判断两个list是否有相同值 + * @param list1 list + * @param list2 list + * @return boolean + */ + private boolean isSame(List list1,List list2){ + if(list2.isEmpty()) { + return true; + } + list1 = new ArrayList<>(list1); + list2 = new ArrayList<>(list2); + list1.addAll(list2); + int total = list1.size(); + + List newList = new ArrayList<>(new HashSet<>(list1)); + + int newTotal = newList.size(); + + + return total > newTotal; + } + + + /** + * 检查优惠券状态 + */ + private void checkInvalidCoupon() { + Date nowTime = new Date(); + LambdaQueryWrapper wrapper= new LambdaQueryWrapper<>(); + wrapper.lt(YxStoreCouponUser::getEndTime,nowTime) + .eq(YxStoreCouponUser::getStatus,CouponEnum.STATUS_0.getValue()); + YxStoreCouponUser couponUser = new YxStoreCouponUser(); + couponUser.setStatus(CouponEnum.STATUS_2.getValue()); + yxStoreCouponUserMapper.update(couponUser,wrapper); + + } + + + + //=========================================================================================================// + + @Override + //@Cacheable + public Map queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + List storeOrderDTOS = generator.convert(page.getList(),YxStoreCouponUserDto.class); + for (YxStoreCouponUserDto couponUserDTO : storeOrderDTOS) { + couponUserDTO.setNickname(userService.getOne(new LambdaQueryWrapper() + .eq(YxUser::getUid,couponUserDTO.getUid())).getNickname()); + } + Map map = new LinkedHashMap<>(2); + map.put("content",storeOrderDTOS); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCouponUserQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCouponUser.class, criteria)); + } + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCouponUserDto yxStoreCouponUser : all) { + Map map = new LinkedHashMap<>(); + map.put("兑换的项目id", yxStoreCouponUser.getCid()); + map.put("优惠券所属用户", yxStoreCouponUser.getUid()); + map.put("优惠券名称", yxStoreCouponUser.getCouponTitle()); + map.put("优惠券的面值", yxStoreCouponUser.getCouponPrice()); + map.put("最低消费多少金额可用优惠券", yxStoreCouponUser.getUseMinPrice()); + map.put("优惠券创建时间", yxStoreCouponUser.getAddTime()); + map.put("优惠券结束时间", yxStoreCouponUser.getEndTime()); + map.put("使用时间", yxStoreCouponUser.getUseTime()); + map.put("获取方式", yxStoreCouponUser.getType()); + map.put("状态(0:未使用,1:已使用, 2:已过期)", yxStoreCouponUser.getStatus()); + map.put("是否有效", yxStoreCouponUser.getIsFail()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public Map getUserPCCoupon(Long uid, int page, int limit, Integer type) { + Page yxStoreCouponUserPage = new Page<>(page, limit); + yxStoreCouponUserMapper.selectPage(yxStoreCouponUserPage,Wrappers.lambdaQuery() + .eq(YxStoreCouponUser::getUid,uid).eq(YxStoreCouponUser::getStatus,type)); + + List storeCouponUserQueryVoList = new ArrayList<>(); + long nowTime = System.currentTimeMillis(); + for (YxStoreCouponUser couponUser : yxStoreCouponUserPage.getRecords()) { + YxStoreCouponUserQueryVo queryVo = generator.convert(couponUser,YxStoreCouponUserQueryVo.class); + if(couponUser.getIsFail() == 1){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已失效"); + }else if (couponUser.getStatus() == 1){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已使用"); + }else if (couponUser.getStatus() == 2){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已过期"); + }else if(couponUser.getCreateTime().getTime() > nowTime || couponUser.getEndTime().getTime() < nowTime){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已过期"); + }else{ + queryVo.set_type(CouponEnum.USE_1.getValue()); + queryVo.set_msg("可使用"); + } + + storeCouponUserQueryVoList.add(queryVo); + } + Map map = new HashMap<>(); + map.put("list",storeCouponUserQueryVoList); + map.put("total",yxStoreCouponUserPage.getTotal()); + map.put("totalPage",yxStoreCouponUserPage.getPages()); + return map; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStorePinkServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStorePinkServiceImpl.java new file mode 100644 index 00000000..2fdcd5ec --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStorePinkServiceImpl.java @@ -0,0 +1,695 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.PinkEnum; +import co.yixiang.modules.activity.domain.YxStoreCombination; +import co.yixiang.modules.activity.domain.YxStorePink; +import co.yixiang.modules.activity.service.YxStoreCombinationService; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.activity.service.YxStoreVisitService; +import co.yixiang.modules.activity.service.dto.PinkAllDto; +import co.yixiang.modules.activity.service.dto.PinkDto; +import co.yixiang.modules.activity.service.dto.PinkUserDto; +import co.yixiang.modules.activity.service.dto.YxStorePinkDto; +import co.yixiang.modules.activity.service.dto.YxStorePinkQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreCombinationMapper; +import co.yixiang.modules.activity.service.mapper.YxStorePinkMapper; +import co.yixiang.modules.activity.vo.PinkInfoVo; +import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo; +import co.yixiang.modules.activity.vo.YxStorePinkQueryVo; +import co.yixiang.modules.cart.domain.YxStoreCart; +import co.yixiang.modules.cart.service.YxStoreCartService; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStorePinkServiceImpl extends BaseServiceImpl implements YxStorePinkService { + + @Autowired + private IGenerator generator; + @Autowired + private YxStorePinkMapper yxStorePinkMapper; + @Autowired + private YxStoreCombinationMapper yxStoreCombinationMapper; + @Autowired + private YxStoreCombinationService combinationService; + @Autowired + private YxStoreOrderService storeOrderService; + @Autowired + private YxUserService userService; + @Autowired + private RedisTemplate stringRedisTemplate; + @Autowired + private YxUserService yxUserService; + + @Autowired + private YxStoreCartService yxStoreCartService; + + @Autowired + private YxStoreVisitService yxStoreVisitService; + + + /** + * 取消拼团 + * @param uid 用户id + * @param cid 团购产品id + * @param pinkId 拼团id + */ + @Override + public void removePink(Long uid, Long cid, Long pinkId) { + YxStorePink pink = this.lambdaQuery().eq(YxStorePink::getId,pinkId) + .eq(YxStorePink::getUid,uid) + .eq(YxStorePink::getCid,cid) + .eq(YxStorePink::getKId,0) //团长 + .eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_0.getValue()) + .eq(YxStorePink::getStatus,OrderInfoEnum.REFUND_STATUS_1.getValue()) + .gt(YxStorePink::getStopTime,new Date()) + .one(); + if(pink == null) { + throw new YshopException("拼团不存在或已经取消"); + } + + PinkUserDto pinkUserDto = this.getPinkMemberAndPinK(pink); + List pinkAll = pinkUserDto.getPinkAll(); + YxStorePink pinkT = pinkUserDto.getPinkT(); + List idAll = pinkUserDto.getIdAll(); + List uidAll = pinkUserDto.getUidAll(); + int count = pinkUserDto.getCount(); + if(count < 1){ + this.pinkComplete(uidAll,idAll,uid,pinkT); + throw new YshopException("拼团已完成,无法取消"); + } + //如果团长取消拼团,团队还有人,就把后面的人作为下一任团长 + YxStorePink nextPinkT = null; + if(pinkAll.size() > 0){ + nextPinkT = pinkAll.get(0); + } + + //先退团长的money + storeOrderService.orderApplyRefund("","","拼团取消开团",pinkT.getOrderId(),pinkT.getUid()); + this.orderPinkFailAfter(pinkT.getUid(),pinkT.getId()); + + //把团长下个人设置为团长 + if(ObjectUtil.isNotNull(nextPinkT)){ + LambdaQueryWrapper wrapperO = new LambdaQueryWrapper<>(); + YxStorePink storePinkO = new YxStorePink(); + storePinkO.setKId(0L); //设置团长 + storePinkO.setStatus(OrderInfoEnum.PINK_STATUS_1.getValue()); + storePinkO.setStopTime(pinkT.getStopTime()); + storePinkO.setId(nextPinkT.getId()); + yxStorePinkMapper.updateById(storePinkO); + + //原有团长的数据变更成新团长下面 + wrapperO.eq(YxStorePink::getKId,pinkT.getId()); + YxStorePink storePinkT = new YxStorePink(); + storePinkT.setKId(nextPinkT.getId()); + yxStorePinkMapper.update(storePinkT,wrapperO); + + //update order + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setPinkId(nextPinkT.getId()); + storeOrder.setId(nextPinkT.getId()); + storeOrderService.updateById(storeOrder); + + } + } + + /** + * 计算还差几人拼团 + * @param pink 拼团信息 + * @return int + */ + @Override + public int surplusPeople(YxStorePink pink) { + List listT = new ArrayList<>(); + if(pink.getKId() > 0){ //团长存在 + listT = this.getPinkMember(pink.getKId()); + }else{ + listT = this.getPinkMember(pink.getId()); + } + + return pink.getPeople() - (listT.size() + 1); + } + + + + + /** + * 拼团明细 + * @param id 拼团id + * @param uid 用户id + */ + @Override + public PinkInfoVo pinkInfo(Long id, Long uid) { + YxStorePink pink = this.getPinkUserOne(id); + if(ObjectUtil.isNull(pink)) { + throw new YshopException("拼团不存在"); + } + if( OrderInfoEnum.PINK_REFUND_STATUS_1.getValue().equals(pink.getIsRefund())){ + throw new YshopException("订单已退款"); + } + + int isOk = 0;//判断拼团是否完成 + int userBool = 0;//判断当前用户是否在团内 0未在 1在 + int pinkBool = 0;//判断拼团是否成功 0未 1是 -1结束 + + PinkUserDto pinkUserDto = this.getPinkMemberAndPinK(pink); + YxStorePink pinkT = pinkUserDto.getPinkT(); + List pinkAll = pinkUserDto.getPinkAll(); + List idAll = pinkUserDto.getIdAll(); + List uidAll = pinkUserDto.getUidAll(); + int count = pinkUserDto.getCount(); + + if(count < 0) { + count = 0; + } + if(OrderInfoEnum.PINK_STATUS_2.getValue().equals(pinkT.getStatus())){ + pinkBool = PinkEnum.PINK_BOOL_1.getValue(); + isOk = PinkEnum.IS_OK_1.getValue(); + }else if(pinkT.getStatus() == 3){ + pinkBool = PinkEnum.PINK_BOOL_MINUS_1.getValue(); + isOk = PinkEnum.IS_OK_0.getValue(); + }else{ + //组团完成 + if(count < 1){ + isOk = PinkEnum.IS_OK_1.getValue(); + pinkBool = this.pinkComplete(uidAll,idAll,uid,pinkT); + }else{ + pinkBool = this.pinkFail(pinkAll,pinkT,pinkBool); + } + } + + //团员是否在团 + if(ObjectUtil.isNotNull(pinkAll)){ + for (YxStorePink storePink : pinkAll) { + if(storePink.getUid().equals(uid)) { + userBool = PinkEnum.USER_BOOL_1.getValue(); + } + } + } + //团长 + if(pinkT.getUid().equals(uid)) { + userBool = PinkEnum.USER_BOOL_1.getValue(); + } + + YxStoreCombinationQueryVo storeCombinationQueryVo = yxStoreCombinationMapper.getCombDetail(pink.getCid()); + if(ObjectUtil.isNull(storeCombinationQueryVo)) { + throw new YshopException("拼团不存在或已下架"); + } + + YxUserQueryVo userInfo = userService.getYxUserById(uid); + YxStoreOrder yxStoreOrder = storeOrderService.getById(pink.getOrderIdKey()); + YxStoreCart yxStoreCart = yxStoreCartService.getById(yxStoreOrder.getCartId()); + //拼团访问量 + yxStoreCombinationMapper.incBrowseNum(pink.getPid()); + //拼团访客人数 + yxStoreVisitService.addStoreVisit(uid, pink.getPid()); + return PinkInfoVo.builder() + .count(count) + .currentPinkOrder(this.getCurrentPinkOrderId(id,uid)) + .isOk(isOk) + .pinkAll(this.handPinkAll(pinkAll)) + .pinkBool(pinkBool) + .pinkT(this.handPinkT(pinkT)) + .storeCombination(storeCombinationQueryVo) + .userBool(userBool) + .userInfo(userInfo) + .uniqueId(yxStoreCart.getProductAttrUnique()) + .build(); + + } + + + + /** + * 返回正在拼团的人数 + * @param id 拼团id + * @return int + */ + @Override + public Long pinkIngCount(Long id) { + return this.lambdaQuery() + .eq(YxStorePink::getId,id) + .eq(YxStorePink::getStatus,OrderInfoEnum.PINK_STATUS_1.getValue()) + .count(); + } + + + /** + * 创建拼团 + * @param order 订单 + */ + @Override + public void createPink(YxStoreOrderQueryVo order) { + YxStoreCombination storeCombination = combinationService.getById(order.getCombinationId()); + order = storeOrderService.handleOrder(order); + YxStoreCart storeCart = yxStoreCartService.getById(order.getCartId()); + Long pinkCount = yxStorePinkMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxStorePink::getOrderId,order.getOrderId())); + if(pinkCount > 0) { + return; + } + if(storeCombination != null){ + YxStorePink storePink = YxStorePink.builder() + .uid(order.getUid()) + .orderId(order.getOrderId()) + .orderIdKey(order.getId()) + .totalNum(order.getTotalNum()) + .totalPrice(order.getPayPrice()) + .build(); + List cartInfo = order.getCartInfo(); + for (YxStoreCartQueryVo queryVo : cartInfo) { + storePink.setCid(queryVo.getCombinationId()); + storePink.setPid(queryVo.getProductId()); + storePink.setPrice(queryVo.getProductInfo().getPrice()); + } + + Date stopTime = DateUtil.offsetHour(new Date(), storeCombination.getEffectiveTime()); + storePink.setPeople(storeCombination.getPeople()); + storePink.setStopTime(stopTime); + storePink.setUniqueId(storeCart.getProductAttrUnique()); + if(order.getPinkId() > 0){ //其他成员入团 + if(this.getIsPinkUid(order.getPinkId(),order.getUid())) { + return; + } + storePink.setKId(order.getPinkId()); + storePink.setStopTime(null); + this.save(storePink); + + //处理拼团完成 + PinkUserDto pinkUserDto = this.getPinkMemberAndPinK(storePink); + YxStorePink pinkT = pinkUserDto.getPinkT(); + if( OrderInfoEnum.PINK_STATUS_1.getValue().equals(pinkT.getStatus())){ + //int count = (int)map.get("count"); + if(pinkUserDto.getCount() == 0){//处理成功 + this.pinkComplete(pinkUserDto.getUidAll(),pinkUserDto.getIdAll(),order.getUid(), pinkT); + }else{ + this.pinkFail(pinkUserDto.getPinkAll(),pinkT,PinkEnum.PINK_BOOL_0.getValue()); + } + } + + }else{//开团 + this.save(storePink); + //pink_id更新到order表 + YxStoreOrder yxStoreOrder = new YxStoreOrder(); + yxStoreOrder.setPinkId(storePink.getId()); + yxStoreOrder.setId(order.getId()); + storeOrderService.updateById(yxStoreOrder); + + //开团加入队列 + String redisKey = String.valueOf(StrUtil.format("{}{}", + ShopConstants.REDIS_PINK_CANCEL_KEY, storePink.getId())); + long expireTime = storeCombination.getEffectiveTime().longValue() * 3600; + stringRedisTemplate.opsForValue().set(redisKey, "1" , expireTime, TimeUnit.SECONDS); + } + } + } + + /** + * 判断用户是否在团内 + * @param id 拼团id + * @param uid 用户id + * @return boolean true=在 + */ + @Override + public boolean getIsPinkUid(Long id, Long uid) { + Long count = this.lambdaQuery() + .eq(YxStorePink::getIsRefund, OrderInfoEnum.PINK_REFUND_STATUS_0.getValue()) + .eq(YxStorePink::getUid,uid) + .and(i->i.eq(YxStorePink::getKId,id).or().eq(YxStorePink::getId,id)) + .count(); + return count > 0; + } + + /** + * 获取拼团完成的商品总件数 + * @return int + */ + @Override + public int getPinkOkSumTotalNum() { + return yxStorePinkMapper.sumNum(); + } + + /** + * 获取拼团成功的用户 + * @param uid uid + * @return list + */ + @Override + public List getPinkOkList(Long uid) { + List list = new ArrayList<>(); + List pinkDTOList = yxStorePinkMapper.getPinkOkList(uid); + for (PinkDto pinkDTO : pinkDTOList) { + list.add(pinkDTO.getNickname()+"拼团成功"); + } + return list; + } + + + /** + * 获取团长拼团数据 + * @param cid 拼团产品id + * @return PinkAllDto pindAll-参与的拼团的id 集合 list-团长参与的列表 + */ + @Override + public PinkAllDto getPinkAll(Long cid) { + Map map = new LinkedHashMap<>(2); + List list = yxStorePinkMapper.getPinks(cid); + List pindAll = new ArrayList<>();//参与的拼团的id 集合 + for (PinkDto pinkDto : list) { + pinkDto.setCount(String.valueOf(this.getPinkPeople(pinkDto.getId() + ,pinkDto.getPeople()))); + Date date = pinkDto.getStopTime(); + pinkDto.setH(String.valueOf(DateUtil.hour(date,true))); + pinkDto.setI(String.valueOf(DateUtil.minute(date))); + pinkDto.setS(String.valueOf(DateUtil.second(date))); + pindAll.add(pinkDto.getId()); + } + + + return PinkAllDto.builder() + .list(list) + .pindAll(pindAll) + .build(); + } + + + /** + * 处理团员 + * @param pinkAll 拼团数据 + * @return list + */ + private List handPinkAll(List pinkAll) { + + List list = generator.convert(pinkAll,YxStorePinkQueryVo.class); + for (YxStorePinkQueryVo queryVo : list) { + YxUserQueryVo userQueryVo = userService.getYxUserById(queryVo.getUid().longValue()); + queryVo.setAvatar(userQueryVo.getAvatar()); + queryVo.setNickname(userQueryVo.getNickname()); + } + return list; + } + + /** + * 处理团长 + * @param pinkT 拼团 + * @return YxStorePinkQueryVo + */ + private YxStorePinkQueryVo handPinkT(YxStorePink pinkT) { + YxStorePinkQueryVo pinkQueryVo = generator.convert(pinkT,YxStorePinkQueryVo.class); + YxUserQueryVo userQueryVo = userService.getYxUserById(pinkQueryVo.getUid().longValue()); + pinkQueryVo.setAvatar(userQueryVo.getAvatar()); + pinkQueryVo.setNickname(userQueryVo.getNickname()); + + return pinkQueryVo; + } + + + /** + * 获取当前拼团数据返回订单编号 + * @param id 拼团id + * @param uid uid + * @return string + */ + private String getCurrentPinkOrderId(Long id, Long uid) { + YxStorePink pink = yxStorePinkMapper.selectOne(Wrappers.lambdaQuery() + .eq(YxStorePink::getId,id).eq(YxStorePink::getUid,uid)); + if(pink == null){ + pink = yxStorePinkMapper.selectOne(Wrappers.lambdaQuery() + .eq(YxStorePink::getKId,id).eq(YxStorePink::getUid,uid)); + if(pink == null) { + return ""; + } + } + return pink.getOrderId(); + } + + + /** + * 获取拼团的团员 + * @param kid 团长id + * @return list + */ + private List getPinkMember(Long kid) { + return this.lambdaQuery().eq(YxStorePink::getKId,kid) + .eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_0.getValue()) + .orderByAsc(YxStorePink::getId) + .list(); + } + + + + /** + * 获取一条拼团数据 + * @param id 拼团id + * @return YxStorePink + */ + private YxStorePink getPinkUserOne(Long id) { + return this.lambdaQuery().eq(YxStorePink::getId,id).one(); + } + + /** + * 拼团人数完成时,判断全部人都是未退款状态 + * @return boolean + */ + private boolean getPinkStatus(List idAll) { + Long count = this.lambdaQuery().in(YxStorePink::getId,idAll) + .eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_1.getValue()) + .count(); + if(count == 0) { + return true; + } + return false; + } + + + /** + * 拼团完成更改数据写入内容 + * @param uidAll 用户id集合 + * @param idAll 拼团id集合 + * @param uid uid + * @param pinkT 团长 + */ + private int pinkComplete(List uidAll,List idAll,Long uid, + YxStorePink pinkT) { + boolean pinkStatus = this.getPinkStatus(idAll);//判断是否有退款的 + int pinkBool = PinkEnum.PINK_BOOL_0.getValue(); + if(pinkStatus){ + //更改状态 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(YxStorePink::getId,idAll); + + YxStorePink storePink = new YxStorePink(); + storePink.setStopTime(new Date()); + storePink.setStatus(OrderInfoEnum.PINK_STATUS_2.getValue()); + + this.update(storePink,wrapper); + + if(uidAll.contains(uid)){ + pinkBool = PinkEnum.PINK_BOOL_1.getValue(); + } + + //todo 模板消息 + } + + return pinkBool; + + } + + /** + * 拼团失败退款之后 + * @param uid 用户id + * @param pid 团长id + */ + private void orderPinkFailAfter(Long uid, Long pid) { + YxStorePink yxStorePink = new YxStorePink(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStorePink::getId,pid); + yxStorePink.setStatus(OrderInfoEnum.PINK_STATUS_3.getValue()); + yxStorePink.setStopTime(new Date()); + yxStorePinkMapper.update(yxStorePink,wrapper); + + LambdaQueryWrapper wrapperT = new LambdaQueryWrapper<>(); + wrapperT.eq(YxStorePink::getKId,pid); + yxStorePinkMapper.update(yxStorePink,wrapperT); + //todo 模板消息 + } + + + /** + * 拼团失败 退款 + * @param pinkAll 拼团数据,不包括团长 + * @param pinkT 团长数据 + * @param pinkBool PinkEnum + */ + private int pinkFail(List pinkAll, YxStorePink pinkT,int pinkBool) { + Date now = new Date(); + //拼团时间超时 退款 + if(DateUtil.compare(pinkT.getStopTime(),now) < 0){ + pinkBool = PinkEnum.PINK_BOOL_MINUS_1.getValue(); + pinkAll.add(pinkT); + //处理退款 + for (YxStorePink storePink : pinkAll) { + storeOrderService.orderApplyRefund("","","拼团时间超时",storePink.getOrderId(),storePink.getUid()); + this.orderPinkFailAfter(pinkT.getUid(),storePink.getId()); + } + } + + return pinkBool; + } + + /** + * 获取参团人和团长和拼团总人数 + * @param pink 拼团 + * @return PinkUserDto + */ + private PinkUserDto getPinkMemberAndPinK(YxStorePink pink) { + //查找拼团团员和团长 + List pinkAll = null; + YxStorePink pinkT = null; + //查找拼团团员和团长 + if(pink.getKId() > 0){ //团长存在 + pinkAll = this.getPinkMember(pink.getKId()); + pinkT = this.getPinkUserOne(pink.getKId()); + }else{ + pinkAll = this.getPinkMember(pink.getId()); + pinkT = pink; + } + //收集拼团用户id和拼团id + List idAll = pinkAll.stream().map(YxStorePink::getId).collect(Collectors.toList()); + List uidAll = pinkAll.stream().map(YxStorePink::getUid).collect(Collectors.toList()); + + idAll.add(pinkT.getId()); + uidAll.add(pinkT.getUid()); + //还差几人 + int count = pinkT.getPeople() - (pinkAll.size() + 1); + + + return PinkUserDto.builder() + .pinkAll(pinkAll) + .pinkT(pinkT) + .idAll(idAll) + .uidAll(uidAll) + .count(count) + .build(); + } + + + /** + * 计算获取团长还差多少人拼团成功 + * @param kid 团长参与拼团id + * @param people 当前满足拼团的人数 + * @return int + */ + private Long getPinkPeople(Long kid, int people) { + LambdaQueryWrapper wrapper= new LambdaQueryWrapper<>(); + wrapper.eq(YxStorePink::getKId,kid) + .eq(YxStorePink::getIsRefund, OrderInfoEnum.PINK_REFUND_STATUS_0.getValue()); + //加上团长自己 + Long count = yxStorePinkMapper.selectCount(wrapper) + 1; + return people - count; + } + + //=================================================// + + @Override + //@Cacheable + public Map queryAll(YxStorePinkQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + List yxStorePinkDtos = generator.convert(page.getList(), YxStorePinkDto.class); + yxStorePinkDtos.forEach(i ->{ + YxUser yxUser = yxUserService.getById(i.getUid()); + YxStoreCombination storeCombination = combinationService.getById(i.getCid()); + i.setNickname(yxUser.getNickname()); + i.setPhone(yxUser.getPhone()); + i.setUserImg(yxUser.getAvatar()); + i.setProduct(storeCombination.getTitle()); + i.setImage(storeCombination.getImage()); + i.setCountPeople( this.count(new LambdaQueryWrapper().eq(YxStorePink::getCid,i.getCid()))); + }); + map.put("content", yxStorePinkDtos); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStorePinkQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStorePink.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStorePinkDto yxStorePink : all) { + Map map = new LinkedHashMap<>(); + map.put("用户id", yxStorePink.getUid()); + map.put("订单id 生成", yxStorePink.getOrderId()); + map.put("订单id 数据库", yxStorePink.getOrderIdKey()); + map.put("购买商品个数", yxStorePink.getTotalNum()); + map.put("购买总金额", yxStorePink.getTotalPrice()); + map.put("拼团产品id", yxStorePink.getCid()); + map.put("产品id", yxStorePink.getPid()); + map.put("拼团总人数", yxStorePink.getPeople()); + map.put("拼团产品单价", yxStorePink.getPrice()); + map.put(" stopTime", yxStorePink.getStopTime()); + map.put("团长id 0为团长", yxStorePink.getKId()); + map.put("是否发送模板消息0未发送1已发送", yxStorePink.getIsTpl()); + map.put("是否退款 0未退款 1已退款", yxStorePink.getIsRefund()); + map.put("状态1进行中2已完成3未完成", yxStorePink.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreSeckillServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreSeckillServiceImpl.java new file mode 100644 index 00000000..7af4cd8c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreSeckillServiceImpl.java @@ -0,0 +1,323 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +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 cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.exception.BadRequestException; +import co.yixiang.modules.activity.domain.YxStoreSeckill; +import co.yixiang.modules.activity.domain.YxStoreSeckill; +import co.yixiang.modules.activity.service.YxStoreSeckillService; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto; +import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper; +import co.yixiang.modules.activity.vo.StoreSeckillVo; +import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrService; +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.modules.product.vo.YxStoreProductAttrQueryVo; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.OrderUtil; + +import co.yixiang.utils.RedisUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreSeckillServiceImpl extends BaseServiceImpl implements YxStoreSeckillService { + + @Autowired + private IGenerator generator; + + @Autowired + private YxStoreSeckillMapper yxStoreSeckillMapper; + + @Autowired + private RedisUtils redisUtils; + @Autowired + private YxStoreProductReplyService replyService; + + @Autowired + private YxStoreProductAttrService yxStoreProductAttrService; + + @Autowired + private YxShippingTemplatesService shippingTemplatesService; + + /** + * 产品详情 + * @param id 砍价商品id + * @return StoreSeckillVo + */ + @Override + public StoreSeckillVo getDetail(Long id){ + Date now = new Date(); + YxStoreSeckill storeSeckill = this.lambdaQuery().eq(YxStoreSeckill::getId,id) + .eq(YxStoreSeckill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxStoreSeckill::getIsShow,ShopCommonEnum.SHOW_1.getValue()) + .le(YxStoreSeckill::getStartTime,now) + .ge(YxStoreSeckill::getStopTime,now) + .one(); + + if(storeSeckill == null){ + throw new YshopException("秒杀产品不存在或已下架"); + } + //获取商品sku + Map returnMap = yxStoreProductAttrService.getProductAttrDetail(storeSeckill.getProductId()); + //获取运费模板名称 + String storeFreePostage = redisUtils.get("store_free_postage").toString(); + String tempName = ""; + if(StrUtil.isBlank(storeFreePostage) + || !NumberUtil.isNumber(storeFreePostage) + || Integer.parseInt(storeFreePostage) == 0){ + tempName = "全国包邮"; + }else{ + YxShippingTemplates shippingTemplates = shippingTemplatesService.getById(storeSeckill.getTempId()); + if(ObjectUtil.isNotNull(shippingTemplates)){ + tempName = shippingTemplates.getName(); + }else { + throw new BadRequestException("请配置运费模板"); + } + + } + return StoreSeckillVo.builder() + .productAttr((List)returnMap.get("productAttr")) + .productValue((Map)returnMap.get("productValue")) + .storeInfo(generator.convert(storeSeckill, YxStoreSeckillQueryVo.class)) + .reply(replyService.getReply(storeSeckill.getProductId())) + .replyCount(replyService.productReplyCount(storeSeckill.getProductId())) + .tempName(tempName) + .build(); + } + + /** + * 秒杀产品列表 + * @param page page + * @param limit limit + * @return list + */ + @Override + public List getList(int page, int limit, int time) { + Date nowTime = new Date(); + Page pageModel = new Page<>(page, limit); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreSeckill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxStoreSeckill::getTimeId,time) + .le(YxStoreSeckill::getStartTime,nowTime) + .ge(YxStoreSeckill::getStopTime,nowTime) + .orderByDesc(YxStoreSeckill::getSort); + List yxStoreSeckillQueryVos = generator.convert + (yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords(), + YxStoreSeckillQueryVo.class); + yxStoreSeckillQueryVos.forEach(item->{ + Integer sum = item.getSales() + item.getStock(); + item.setPercent(NumberUtil.round(NumberUtil.mul(NumberUtil.div(item.getSales(),sum), + 100),0).intValue()); + }); + return yxStoreSeckillQueryVos; + } + /** + * 秒杀产品列表(首页用) + * @param page page + * @param limit limit + * @return list + */ + @Override + public List getList(int page, int limit) { + Date nowTime = new Date(); + Page pageModel = new Page<>(page, limit); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreSeckill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxStoreSeckill::getIsHot,1) + .le(YxStoreSeckill::getStartTime,nowTime) + .ge(YxStoreSeckill::getStopTime,nowTime) + .orderByDesc(YxStoreSeckill::getSort); + List yxStoreSeckillQueryVos = generator.convert + (yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords(), + YxStoreSeckillQueryVo.class); + yxStoreSeckillQueryVos.forEach(item->{ + Integer sum = item.getSales() + item.getStock(); + item.setPercent(NumberUtil.round(NumberUtil.mul(NumberUtil.div(item.getSales(),sum), + 100),0).intValue()); + }); + return yxStoreSeckillQueryVos; + } + @Override + //@Cacheable + public Map queryAll(YxStoreSeckillQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + List storeSeckillDTOS = generator.convert(page.getList(),YxStoreSeckillDto.class); + for (YxStoreSeckillDto storeSeckillDTO : storeSeckillDTOS){ + String statusStr = OrderUtil.checkActivityStatus(storeSeckillDTO.getStartTime(), + storeSeckillDTO.getStopTime(), storeSeckillDTO.getStatus()); + storeSeckillDTO.setStatusStr(statusStr); + } + Map map = new LinkedHashMap<>(2); + map.put("content",storeSeckillDTOS); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreSeckillQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreSeckill.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreSeckillDto yxStoreSeckill : all) { + Map map = new LinkedHashMap<>(); + map.put("推荐图", yxStoreSeckill.getImage()); + map.put("轮播图", yxStoreSeckill.getImages()); + map.put("活动标题", yxStoreSeckill.getTitle()); + map.put("简介", yxStoreSeckill.getInfo()); + map.put("返多少积分", yxStoreSeckill.getGiveIntegral()); + map.put("排序", yxStoreSeckill.getSort()); + map.put("库存", yxStoreSeckill.getStock()); + map.put("销量", yxStoreSeckill.getSales()); + map.put("单位名", yxStoreSeckill.getUnitName()); + map.put("邮费", yxStoreSeckill.getPostage()); + map.put("内容", yxStoreSeckill.getDescription()); + map.put("开始时间", yxStoreSeckill.getStartTime()); + map.put("结束时间", yxStoreSeckill.getStopTime()); + map.put("产品状态", yxStoreSeckill.getStatus()); + map.put("是否包邮", yxStoreSeckill.getIsPostage()); + map.put("热门推荐", yxStoreSeckill.getIsHot()); + map.put("最多秒杀几个", yxStoreSeckill.getNum()); + map.put("显示", yxStoreSeckill.getIsShow()); + map.put("时间段id", yxStoreSeckill.getTimeId()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public boolean saveSeckill(YxStoreSeckillDto resources) { + ProductResultDto resultDTO = this.computedProduct(resources.getAttrs()); + + //添加商品 + YxStoreSeckill yxStoreSeckill = new YxStoreSeckill(); + BeanUtil.copyProperties(resources,yxStoreSeckill,"images"); + if(resources.getImages().isEmpty()) { + throw new YshopException("请上传轮播图"); + } + + yxStoreSeckill.setStock(resultDTO.getStock()); + yxStoreSeckill.setOtPrice(BigDecimal.valueOf(resultDTO.getMinOtPrice())); + yxStoreSeckill.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice())); + yxStoreSeckill.setCost(BigDecimal.valueOf(resultDTO.getMinCost())); + yxStoreSeckill.setStock(resultDTO.getStock()); + yxStoreSeckill.setImages(String.join(",", resources.getImages())); + this.saveOrUpdate(yxStoreSeckill); + + //属性处理 + //处理单sKu + if(SpecTypeEnum.TYPE_0.getValue().equals(resources.getSpecType())){ + FromatDetailDto fromatDetailDto = FromatDetailDto.builder() + .value("规格") + .detailValue("") + .attrHidden("") + .detail(ListUtil.toList("默认")) + .build(); + List attrs = resources.getAttrs(); + ProductFormatDto productFormatDto = attrs.get(0); + productFormatDto.setValue1("规格"); + Map map = new HashMap<>(); + map.put("规格","默认"); + productFormatDto.setDetail(map); + yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto), + ListUtil.toList(productFormatDto),resources.getProductId()); + }else{ + yxStoreProductAttrService.insertYxStoreProductAttr(resources.getItems(), + resources.getAttrs(),resources.getProductId()); + } + return true; + } + + /** + * 计算产品数据 + * @param attrs attrs + * @return ProductResultDto + */ + private ProductResultDto computedProduct(List attrs){ + //取最小价格 + Double minPrice = attrs + .stream() + .map(ProductFormatDto::getSeckillPrice) + .min(Comparator.naturalOrder()) + .orElse(0d); + + Double minOtPrice = attrs + .stream() + .map(ProductFormatDto::getOtPrice) + .min(Comparator.naturalOrder()) + .orElse(0d); + + Double minCost = attrs + .stream() + .map(ProductFormatDto::getCost) + .min(Comparator.naturalOrder()) + .orElse(0d); + //计算库存 + Integer stock = attrs + .stream() + .map(ProductFormatDto::getSeckillStock) + .reduce(Integer::sum) + .orElse(0); + + if(stock <= 0) { + throw new YshopException("库存不能低于0"); + } + + return ProductResultDto.builder() + .minPrice(minPrice) + .minOtPrice(minOtPrice) + .minCost(minCost) + .stock(stock) + .build(); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreVisitServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreVisitServiceImpl.java new file mode 100644 index 00000000..dc3f31e9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreVisitServiceImpl.java @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.ProductTypeEnum; +import co.yixiang.modules.activity.domain.YxStoreVisit; +import co.yixiang.modules.activity.service.YxStoreVisitService; +import co.yixiang.modules.activity.service.dto.YxStoreVisitDto; +import co.yixiang.modules.activity.service.dto.YxStoreVisitQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxStoreVisitMapper; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreVisitServiceImpl extends BaseServiceImpl implements YxStoreVisitService { + + private final IGenerator generator; + private final YxStoreProductService yxStoreProductService; + private final YxStoreVisitMapper yxStoreVisitMapper; + + @Override + //@Cacheable + public Map queryAll(YxStoreVisitQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreVisitDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreVisitQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreVisit.class, criteria)); + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreVisitDto yxStoreVisit : all) { + Map map = new LinkedHashMap<>(); + map.put("产品ID", yxStoreVisit.getProductId()); + map.put("产品类型", yxStoreVisit.getProductType()); + map.put("产品分类ID", yxStoreVisit.getCateId()); + map.put("产品类型", yxStoreVisit.getType()); + map.put("用户ID", yxStoreVisit.getUid()); + map.put("访问次数", yxStoreVisit.getCount()); + map.put("备注描述", yxStoreVisit.getContent()); + map.put("添加时间", yxStoreVisit.getAddTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 添加用户访问拼团记录 + * @param uid 用户id + * @param productId 产品id + */ + @Override + public void addStoreVisit(Long uid, Long productId) { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreVisit::getUid, uid).eq(YxStoreVisit::getProductId, productId); + YxStoreVisit storeVisit = this.baseMapper.selectOne(wrapper); + + if (ObjectUtil.isNull(storeVisit)) { + //查询产品分类 + YxStoreProduct yxStoreProduct = yxStoreProductService.getProductInfo(productId); + + YxStoreVisit yxStoreVisit = YxStoreVisit.builder() + .productId(productId) + .productType(ProductTypeEnum.COMBINATION.getValue()) + .cateId(Integer.valueOf(yxStoreProduct.getCateId())) + .type(ProductTypeEnum.COMBINATION.getValue()) + .uid(uid) + .count(1) + .build(); + this.save(yxStoreVisit); + } + + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxUserExtractServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxUserExtractServiceImpl.java new file mode 100644 index 00000000..32348801 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxUserExtractServiceImpl.java @@ -0,0 +1,246 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.impl; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.BillDetailEnum; +import co.yixiang.enums.PayTypeEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.activity.domain.YxUserExtract; +import co.yixiang.modules.activity.param.UserExtParam; +import co.yixiang.modules.activity.service.YxUserExtractService; +import co.yixiang.modules.activity.service.dto.YxUserExtractDto; +import co.yixiang.modules.activity.service.dto.YxUserExtractQueryCriteria; +import co.yixiang.modules.activity.service.mapper.YxUserExtractMapper; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxUserExtractServiceImpl extends BaseServiceImpl implements YxUserExtractService { + + private final IGenerator generator; + private final YxUserExtractMapper yxUserExtractMapper; + private final YxUserService userService; + private final YxUserBillService billService; + private final ApplicationEventPublisher publisher; + + /** + * 开始提现 + * @param userInfo 用户 + * @param param UserExtParam + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void userExtract(YxUser userInfo, UserExtParam param) { + BigDecimal extractPrice = userInfo.getBrokeragePrice(); + if(extractPrice.compareTo(BigDecimal.ZERO) <= 0) { + throw new YshopException("提现佣金不足"); + } + + double money = Double.valueOf(param.getMoney()); + if( extractPrice.compareTo(BigDecimal.valueOf(money)) < 0) { + throw new YshopException("提现佣金不足"); + } + + if(money <= 0) { + throw new YshopException("提现佣金大于0"); + } + + double balance = NumberUtil.sub(extractPrice.doubleValue(),money); + if(balance < 0) { + balance = 0; + } + + YxUserExtract userExtract = new YxUserExtract(); + userExtract.setUid(userInfo.getUid()); + userExtract.setExtractType(param.getExtractType()); + userExtract.setExtractPrice(new BigDecimal(param.getMoney())); + userExtract.setBalance(BigDecimal.valueOf(balance)); + + if(StrUtil.isNotEmpty(param.getName())){ + userExtract.setRealName(param.getName()); + }else { + userExtract.setRealName(userInfo.getNickname()); + } + + if(StrUtil.isNotEmpty(param.getWeixin())){ + userExtract.setWechat(param.getWeixin()); + }else { + userExtract.setWechat(userInfo.getNickname()); + } + + String mark = ""; + + if(PayTypeEnum.ALI.getValue().equals(param.getExtractType())){ + if(StrUtil.isEmpty(param.getAlipayCode())){ + throw new YshopException("请输入支付宝账号"); + } + userExtract.setAlipayCode(param.getAlipayCode()); + mark = "使用支付宝提现"+param.getMoney()+"元"; + }else if(PayTypeEnum.WEIXIN.getValue().equals(param.getExtractType())){ + if(StrUtil.isEmpty(param.getWeixin())){ + throw new YshopException("请输入微信账号"); + } + mark = "使用微信提现"+param.getMoney()+"元"; + } + + yxUserExtractMapper.insert(userExtract); + + //更新佣金 + YxUser yxUser = new YxUser(); + yxUser.setBrokeragePrice(BigDecimal.valueOf(balance)); + yxUser.setUid(userInfo.getUid()); + userService.updateById(yxUser); + + //插入流水 + billService.expend(userInfo.getUid(),"佣金提现", BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_4.getValue(),money,balance, mark); + + } + + /** + * 累计提现金额 + * @param uid uid + * @return double + */ + @Override + public double extractSum(Long uid) { + return yxUserExtractMapper.sumPrice(uid); + } + + + //==============================================================// + + @Override + //@Cacheable + public Map queryAll(YxUserExtractQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxUserExtractDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxUserExtractQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxUserExtract.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxUserExtractDto yxUserExtract : all) { + Map map = new LinkedHashMap<>(); + map.put(" uid", yxUserExtract.getUid()); + map.put("名称", yxUserExtract.getRealName()); + map.put("bank = 银行卡 alipay = 支付宝wx=微信", yxUserExtract.getExtractType()); + map.put("银行卡", yxUserExtract.getBankCode()); + map.put("开户地址", yxUserExtract.getBankAddress()); + map.put("支付宝账号", yxUserExtract.getAlipayCode()); + map.put("提现金额", yxUserExtract.getExtractPrice()); + map.put(" mark", yxUserExtract.getMark()); + map.put(" balance", yxUserExtract.getBalance()); + map.put("无效原因", yxUserExtract.getFailMsg()); + map.put(" failTime", yxUserExtract.getFailTime()); + map.put("-1 未通过 0 审核中 1 已提现", yxUserExtract.getStatus()); + map.put("微信号", yxUserExtract.getWechat()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 操作提现 + * @param resources YxUserExtract + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void doExtract(YxUserExtract resources){ + if(resources.getStatus() == null){ + throw new BadRequestException("请选择审核状态"); + } + + if(ShopCommonEnum.EXTRACT_0.getValue().equals(resources.getStatus())){ + throw new BadRequestException("请选择审核状态"); + } + YxUserExtract userExtract = this.getById(resources.getId()); + if(!ShopCommonEnum.EXTRACT_0.getValue().equals(userExtract.getStatus())){ + throw new BadRequestException("该申请已经处理过啦!"); + } + if(ShopCommonEnum.EXTRACT_MINUS_1.getValue().equals(resources.getStatus())){ + if(StrUtil.isEmpty(resources.getFailMsg())){ + throw new BadRequestException("请填写失败原因"); + } + //防止无限添加佣金 + if (ObjectUtil.isNull(userExtract.getFailTime())) { + String mark = "提现失败,退回佣金"+resources.getExtractPrice()+"元"; + YxUser yxUser = userService.getById(resources.getUid()); + + double balance = NumberUtil.add(yxUser.getBrokeragePrice(),resources.getExtractPrice()).doubleValue(); + //插入流水 + billService.income(resources.getUid(),"提现失败", BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_4.getValue(),resources.getExtractPrice().doubleValue(),balance, + mark,resources.getId().toString()); + + //返回提现金额 + userService.incBrokeragePrice(resources.getExtractPrice(),resources.getUid()); + + resources.setFailTime(new Date()); + } + + }else{ + //模板消息支付成功发布事件 + TemplateBean templateBean = TemplateBean.builder() + .extractId( resources.getId()) + .templateType(TemplateListenEnum.TYPE_8.getValue()) + .build(); + publisher.publishEvent(new TemplateEvent(this,templateBean)); + } + this.saveOrUpdate(resources); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainMapper.java new file mode 100644 index 00000000..ad53f906 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainMapper.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreBargainMapper extends CoreMapper { + @Update("update yx_store_bargain set stock=stock+#{num}, sales=sales-#{num}" + + " where id=#{bargainId}") + int incStockDecSales(@Param("num") int num, @Param("bargainId") Long bargainId); + + @Update("update yx_store_bargain set stock=stock-#{num}, sales=sales+#{num}" + + " where id=#{bargainId} and stock >= #{num}") + int decStockIncSales(@Param("num") int num,@Param("bargainId") Long bargainId); + + @Select("SELECT c.id,c.image,c.min_price as price,c.price as otPrice," + + "c.title as storeName,c.status as isShow,c.cost," + + "c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" + + " FROM yx_store_bargain c " + + " WHERE c.id = #{id} and c.is_del = 0") + YxStoreProductQueryVo bargainInfo(Long id); + + @Select("select IFNULL(sum(look),0)" + + "from yx_store_bargain") + int lookCount(); + + @Select("select IFNULL(sum(share),0) as shareCount " + + "from yx_store_bargain") + int shareCount(); + + @Update("update yx_store_bargain set share=share+1" + + " where id=#{id}") + void addBargainShare(@Param("id") Long id); + + @Update("update yx_store_bargain set look=look+1" + + " where id=#{id}") + void addBargainLook(@Param("id") Long id); + + @Delete("delete from yx_system_attachment where name = #{name}") + void deleteBargainImg(@Param("name") String name); + + @Select("SELECT table_name FROM information_schema.tables WHERE table_schema='xiaohui'") + List listAllTable(); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainUserHelpMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainUserHelpMapper.java new file mode 100644 index 00000000..329f3033 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainUserHelpMapper.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreBargainUserHelp; +import org.springframework.stereotype.Repository; + +/** + *

+ * 砍价用户帮助表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +@Repository +public interface YxStoreBargainUserHelpMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainUserMapper.java new file mode 100644 index 00000000..d134f7fd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreBargainUserMapper.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreBargainUser; +import co.yixiang.modules.activity.vo.YxStoreBargainUserQueryVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + *

+ * 用户参与砍价表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-12-21 + */ +@Repository +public interface YxStoreBargainUserMapper extends CoreMapper { + + + @Select("SELECT u.uid,u.is_del as isDel,u.bargain_price - u.price as residuePrice,u.id," + + "u.bargain_id as bargainId,u.bargain_price as bargainPrice," + + "u.bargain_price_min as bargainPriceMin,u.price,u.status,b.title," + + "b.image,b.stop_time as datatime FROM yx_store_bargain_user u INNER JOIN " + + "yx_store_bargain b ON b.id=u.bargain_id WHERE u.uid = #{uid} AND u.is_del = 0 " + + "ORDER BY u.id DESC ") + List getBargainUserList(@Param("uid") Long uid, Page page); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCombinationMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCombinationMapper.java new file mode 100644 index 00000000..9d08a96b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCombinationMapper.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreCombination; +import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreCombinationMapper extends CoreMapper { + + @Select("SELECT c.id,c.effective_time as effectiveTime,c.info,c.image,c.people,c.price, s.sales as sales," + + "c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " + + "INNER JOIN yx_store_product s ON s.id=c.product_id " + + " WHERE c.is_show = 1 AND c.is_del = 0 AND c.start_time < now() " + + " AND c.stop_time > now() ORDER BY c.sort desc,c.id desc") + List getCombList(Page page); + + @Override + > E selectPage(E page, @Param(Constants.WRAPPER) Wrapper queryWrapper); + + @Select("SELECT c.id,c.effective_time as effectiveTime,c.image,c.people,c.price,c.browse," + + "c.description,c.image,c.images,c.info," + + "c.product_id as productId,c.sales,c.start_time as startTime" + + ",c.stock,c.stop_time stopTime," + + "c.title,c.unit_name as unitName,s.price as productPrice FROM yx_store_combination c " + + "INNER JOIN yx_store_product s ON s.id=c.product_id " + + " WHERE c.is_show = 1 AND c.is_del = 0 AND c.id = #{id} ") + YxStoreCombinationQueryVo getCombDetail(Long id); + + @Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," + + "c.sales,c.stock,c.is_del as isDel" + + " FROM yx_store_combination c " + + " WHERE c.id = #{id} and c.is_del = 0 ") + YxStoreProductQueryVo combinatiionInfo(Long id); + + /** + * 商品浏览量 + * @param productId + * @return + */ + @Update("update yx_store_combination set browse=browse+1 " + + "where id=#{productId}") + int incBrowseNum(@Param("productId") Long productId); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponIssueMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponIssueMapper.java new file mode 100644 index 00000000..cfc69148 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponIssueMapper.java @@ -0,0 +1,55 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreCouponIssue; +import co.yixiang.modules.activity.vo.YxStoreCouponIssueQueryVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreCouponIssueMapper extends CoreMapper { + @Select("") + List selecCoupontList(Page page,@Param("type") Integer type, + @Param("productId") Long productId); + + @Select("select A.cid,A.end_time as endTime,A.start_time as startTime," + + "A.is_permanent as isPermanent,A.remain_count as remainCount," + + "A.total_count as totalCount,A.id" + + " from yx_store_coupon_issue A" + + " where A.status =1 and A.id=#{id}" + + " AND ( A.start_time < now() AND A.end_time > now() ) " + + " AND A.is_del = 0 AND " + + "( A.remain_count > 0 OR A.is_permanent = 1 )") + YxStoreCouponIssueQueryVo selectOne(Integer id); + + @Update("update yx_store_coupon_issue set remain_count=remain_count-1" + + " where id=#{id}") + int decCount(@Param("id") int id); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponIssueUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponIssueUserMapper.java new file mode 100644 index 00000000..a6354571 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponIssueUserMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreCouponIssueUser; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreCouponIssueUserMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponMapper.java new file mode 100644 index 00000000..ff42925e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreCoupon; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreCouponMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java new file mode 100644 index 00000000..caa316c4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreCouponUserMapper.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreCouponUserMapper extends CoreMapper { + @Select("select A.id,A.coupon_title as couponTitle,A.coupon_price as couponPrice," + + "A.end_time as endTime,B.use_min_price as useMinPrice,B.type," + + "B.product_id as productId" + + " from yx_store_coupon_user A left join yx_store_coupon B " + + "on A.cid = B.id " + + "where A.status = 0" + + " AND A.end_time > #{now} " + + " AND A.uid = #{uid} AND A.use_min_price <= #{price} " + + " ORDER BY B.id DESC") + List selectCouponList(@Param("now") Date now, @Param("price") double price, + @Param("uid") Long uid); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStorePinkMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStorePinkMapper.java new file mode 100644 index 00000000..b08145ff --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStorePinkMapper.java @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStorePink; +import co.yixiang.modules.activity.service.dto.PinkDto; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface YxStorePinkMapper extends CoreMapper { + @Select("SELECT p.id,p.uid,p.people,p.price,p.stop_time as stopTime,u.nickname,u.avatar" + + " FROM yx_store_pink p INNER JOIN yx_user u ON u.uid=p.uid" + + " WHERE stop_time > now() AND p.cid = #{cid} AND p.k_id = 0 " + + "AND p.is_refund = 0 ORDER BY p.create_time DESC") + List getPinks(Long cid); + + //= ]]> + @Select("SELECT p.id,u.nickname,u.avatar" + + " FROM yx_store_pink p RIGHT JOIN yx_user u ON u.uid=p.uid" + + " where p.status= 2 AND p.uid <> ${uid} " + + "AND p.is_refund = 0") + List getPinkOkList(Long uid); + + @Select("SELECT p.id,p.uid,p.people,p.price,p.stop_time as stopTime,u.nickname,u.avatar" + + " FROM yx_store_pink p LEFT JOIN yx_user u ON u.uid=p.uid" + + " where p.k_id= ${kid} " + + "AND p.is_refund = 0") + List getPinkMember(int kid); + + @Select("SELECT p.id,p.uid,p.people,p.price,p.stop_time as stopTime,u.nickname,u.avatar" + + " FROM yx_store_pink p LEFT JOIN yx_user u ON u.uid=p.uid" + + " where p.id= ${id} ") + PinkDto getPinkUserOne(int id); + + @Select("select IFNULL(sum(total_num),0) from yx_store_pink " + + "where status=2 and is_refund=0") + int sumNum(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreSeckillMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreSeckillMapper.java new file mode 100644 index 00000000..d7666872 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreSeckillMapper.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreSeckill; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreSeckillMapper extends CoreMapper { + + @Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," + + "c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" + + " FROM yx_store_seckill c " + + " WHERE c.id = #{id} and c.is_del = 0 ") + YxStoreProductQueryVo seckillInfo(Long id); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreVisitMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreVisitMapper.java new file mode 100644 index 00000000..4dd38b1f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxStoreVisitMapper.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxStoreVisit; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxStoreVisitMapper extends CoreMapper { + + /** + * 拼团浏览量 + * @param productId + * @return + */ + @Update("update yx_store_visit set count=count+1 " + + "where uid=#{uid} AND id=#{productId}") + int incBrowseNum(@Param("uid") Long uid,@Param("productId") Long productId); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxUserExtractMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxUserExtractMapper.java new file mode 100644 index 00000000..37044e8f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/mapper/YxUserExtractMapper.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.activity.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.activity.domain.YxUserExtract; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +public interface YxUserExtractMapper extends CoreMapper { + @Select("select IFNULL(sum(extract_price),0) from yx_user_extract " + + "where status=1 " + + "and uid=#{uid}") + double sumPrice(@Param("uid") Long uid); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainCountVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainCountVo.java new file mode 100644 index 00000000..57b73061 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainCountVo.java @@ -0,0 +1,24 @@ +package co.yixiang.modules.activity.vo; + +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName BargainCountVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/21 + **/ +@Data +@Builder +public class BargainCountVo implements Serializable { + private Double alreadyPrice; + private Long count; + private Integer pricePercent; + private Integer status; + private Double price; //剩余的砍价金额 + private Boolean userBargainStatus; // 是否帮别人砍,没砍是true,砍了false + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java new file mode 100644 index 00000000..5c37b2d0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/BargainVo.java @@ -0,0 +1,21 @@ +package co.yixiang.modules.activity.vo; + + +import co.yixiang.modules.user.vo.YxUserQueryVo; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName BargainVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/21 + **/ +@Data +@Builder +public class BargainVo implements Serializable { + private YxStoreBargainQueryVo bargain; + private YxUserQueryVo userInfo; + private Long bargainSumCount;//砍价支付成功订单数量 +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/CombinationQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/CombinationQueryVo.java new file mode 100644 index 00000000..5202a3c3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/CombinationQueryVo.java @@ -0,0 +1,14 @@ +package co.yixiang.modules.activity.vo; + +import lombok.Data; + +import java.util.List; + +@Data +public class CombinationQueryVo { + + private List storeCombinationQueryVos; + + private Long lastPage; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/PinkInfoVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/PinkInfoVo.java new file mode 100644 index 00000000..ebfa6f4f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/PinkInfoVo.java @@ -0,0 +1,53 @@ +package co.yixiang.modules.activity.vo; + + +import co.yixiang.modules.user.vo.YxUserQueryVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName PinkInfoVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/20 + **/ +@Data +@Builder +public class PinkInfoVo implements Serializable { + + @ApiModelProperty(value = "还差几人成团") + private Integer count; + + @ApiModelProperty(value = "当前拼团数据返回订单编号") + private String currentPinkOrder; + + @ApiModelProperty(value = "是否完成 0未完成 1完成") + private Integer isOk = 0; + + @ApiModelProperty(value = "拼团信息列表") + private List pinkAll; + + @ApiModelProperty(value = "拼团状态 0未成功,进行中 1已成功 -1拼团失败") + private Integer pinkBool = 0; + + @ApiModelProperty(value = "拼团信息") + private YxStorePinkQueryVo pinkT; + + @ApiModelProperty(value = "拼团内容信息") + private YxStoreCombinationQueryVo storeCombination; + + @ApiModelProperty(value = "拼团内容") + private String storeCombinationHost; + + @ApiModelProperty(value = "是否在团内 0不在 1在") + private Integer userBool = 0; + + @ApiModelProperty(value = "拼团用户信息") + private YxUserQueryVo userInfo; + + @ApiModelProperty(value = "库存唯一值") + private String uniqueId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/SeckillConfigVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/SeckillConfigVo.java new file mode 100644 index 00000000..34b2071f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/SeckillConfigVo.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.activity.vo; + + +import co.yixiang.modules.activity.service.dto.SeckillTimeDto; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class SeckillConfigVo { + + @ApiModelProperty(value = "秒杀产品时间信息") + private List seckillTime; + + private String lovely; + + @ApiModelProperty(value = "秒杀产品时间索引") + private Integer seckillTimeIndex; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCombinationVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCombinationVo.java new file mode 100644 index 00000000..81ed4541 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCombinationVo.java @@ -0,0 +1,64 @@ +package co.yixiang.modules.activity.vo; + +import co.yixiang.modules.activity.service.dto.PinkDto; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 拼团产品表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-11-19 + */ +@Data +public class StoreCombinationVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "拼团详情") + private List pink; + + @ApiModelProperty(value = "参与的拼团的id 集合") + private List pindAll; + + @ApiModelProperty(value = "拼团成功的用户信息") + private List pinkOkList; + + @ApiModelProperty(value = "拼团完成的商品总件数") + private Integer pinkOkSum; + + @ApiModelProperty(value = "拼团评论信息") + private YxStoreProductReplyQueryVo reply; + + @ApiModelProperty(value = "拼团评论总条数") + private Long replyCount = 0L; + + @ApiModelProperty(value = "拼团好评比例") + private String replyChance; + + @ApiModelProperty(value = "拼团产品表信息") + private YxStoreCombinationQueryVo storeInfo; + + @ApiModelProperty(value = "拼团产品用户是否收藏") + private Boolean userCollect = false; + + @ApiModelProperty(value = "拼团产品运费模板名称") + private String tempName; + + @ApiModelProperty(value = "拼团产品属性信息") + private List productAttr = new ArrayList(); + + @ApiModelProperty(value = "拼团产品属性值") + private Map productValue = new LinkedHashMap<>(); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java new file mode 100644 index 00000000..a3c7da30 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreCouponUserVo.java @@ -0,0 +1,54 @@ +package co.yixiang.modules.activity.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.util.Date; + +/** + * 优惠券发放记录对象StoreCouponUserVO + * + * @author hupeng + * @date 2020-05-06 + */ +@Getter +@Setter +public class StoreCouponUserVo implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 优惠券发放记录id */ + @ApiModelProperty(value = "优惠券发放记录ID") + private Long id; + + /** 优惠券名称 */ + @ApiModelProperty(value = "优惠券名称") + private String couponTitle; + + /** 优惠券的面值 */ + @ApiModelProperty(value = "优惠券的面值") + private Double couponPrice; + + /** 最低消费多少金额可用优惠券 */ + @ApiModelProperty(value = "最低消费多少金额可用优惠券") + private Double useMinPrice; + + /** 优惠券结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") + @ApiModelProperty(value = "优惠券结束时间") + private Date endTime; + + /** 优惠券类型 0通用券 1商品券 2内部券*/ + @ApiModelProperty(value = "优惠券类型 0通用券 1商品券 2内部券") + private Integer type; + + /**优惠产品ID*/ + @ApiModelProperty(value = "优惠产品ID") + private String productId; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreSeckillVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreSeckillVo.java new file mode 100644 index 00000000..d4196fec --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/StoreSeckillVo.java @@ -0,0 +1,50 @@ +package co.yixiang.modules.activity.vo; + + +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 秒杀产品表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-17 + */ +@Data +@Builder +public class StoreSeckillVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "秒杀产品评论信息") + private YxStoreProductReplyQueryVo reply; + + @ApiModelProperty(value = "秒杀产品评论数量") + private Long replyCount; + + @ApiModelProperty(value = "秒杀产品信息") + private YxStoreSeckillQueryVo storeInfo; + + @Builder.Default + @ApiModelProperty(value = "秒杀产品用户是否收藏") + private Boolean userCollect = false; + + @ApiModelProperty(value = "模板名称") + private String tempName; + + private List productAttr = new ArrayList(); + + private Map productValue = new LinkedHashMap<>(); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/TopCountVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/TopCountVo.java new file mode 100644 index 00000000..0c98c19c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/TopCountVo.java @@ -0,0 +1,21 @@ +package co.yixiang.modules.activity.vo; + +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName TopCountVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/21 + **/ +@Data +@Builder +public class TopCountVo implements Serializable { + private Integer lookCount; + private Integer shareCount; + private Long userCount; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java new file mode 100644 index 00000000..f1ee7703 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainQueryVo.java @@ -0,0 +1,117 @@ +package co.yixiang.modules.activity.vo; + +import co.yixiang.serializer.BigDecimalSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 砍价表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-21 + */ +@Data +@ApiModel(value = "YxStoreBargainQueryVo对象", description = "砍价表查询参数") +public class YxStoreBargainQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "砍价产品ID") + private Long id; + + @ApiModelProperty(value = "关联产品ID") + private Long productId; + + @ApiModelProperty(value = "砍价活动名称") + private String title; + + @ApiModelProperty(value = "砍价活动图片") + private String image; + + @ApiModelProperty(value = "单位名称") + private String unitName; + + @ApiModelProperty(value = "库存") + private Integer stock; + + @ApiModelProperty(value = "销量") + private Integer sales; + + @ApiModelProperty(value = "砍价产品轮播图") + private String images; + + @ApiModelProperty(value = "砍价开启时间") + private Date startTime; + + @ApiModelProperty(value = "砍价结束时间") + private Date stopTime; + + @ApiModelProperty(value = "砍价产品名称") + private String storeName; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "砍价金额") + private BigDecimal price; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "砍价商品最低价") + private BigDecimal minPrice; + + @ApiModelProperty(value = "每次购买的砍价产品数量") + private Integer num; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "用户每次砍价的最大金额") + private BigDecimal bargainMaxPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "用户每次砍价的最小金额") + private BigDecimal bargainMinPrice; + + @ApiModelProperty(value = "用户每次砍价的次数") + private Integer bargainNum; + + @ApiModelProperty(value = "砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)") + private Integer status; + + @ApiModelProperty(value = "砍价详情") + private String description; + + @ApiModelProperty(value = "反多少积分") + private BigDecimal giveIntegral; + + @ApiModelProperty(value = "砍价活动简介") + private String info; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "成本价") + private BigDecimal cost; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "邮费") + private BigDecimal postage; + + @ApiModelProperty(value = "砍价规则") + private String rule; + + @ApiModelProperty(value = "砍价产品浏览量") + private Long look; + + @ApiModelProperty(value = "砍价产品分享量") + private Long share; + + @ApiModelProperty(value = "砍价产品参与人数") + private Long people; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainUserHelpQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainUserHelpQueryVo.java new file mode 100644 index 00000000..b76b58d2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainUserHelpQueryVo.java @@ -0,0 +1,42 @@ +package co.yixiang.modules.activity.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + *

+ * 砍价用户帮助表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-21 + */ +@Data +@ApiModel(value = "YxStoreBargainUserHelpQueryVo对象", description = "砍价用户帮助表查询参数") +public class YxStoreBargainUserHelpQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "砍价用户帮助表ID") + private Long id; + + @ApiModelProperty(value = "帮助的用户id") + private Long uid; + + @ApiModelProperty(value = "砍价产品ID") + private Long bargainId; + + @ApiModelProperty(value = "用户参与砍价表id") + private Long bargainUserId; + + @ApiModelProperty(value = "帮助砍价多少金额") + private BigDecimal price; + + private String nickname; + + private String avatar; + +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainUserQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainUserQueryVo.java new file mode 100644 index 00000000..16a49c7c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreBargainUserQueryVo.java @@ -0,0 +1,54 @@ +package co.yixiang.modules.activity.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 用户参与砍价表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-21 + */ +@Data +@ApiModel(value = "YxStoreBargainUserQueryVo对象", description = "用户参与砍价表查询参数") +public class YxStoreBargainUserQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户参与砍价表ID") + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "砍价产品id") + private Long bargainId; + + @ApiModelProperty(value = "砍价的最低价") + private BigDecimal bargainPriceMin; + + @ApiModelProperty(value = "砍价金额") + private BigDecimal bargainPrice; + + @ApiModelProperty(value = "砍掉的价格") + private BigDecimal price; + + @ApiModelProperty(value = "状态 1参与中 2 活动结束参与失败 3活动结束参与成功") + private Integer status; + + + private Double residuePrice; + + private String title; + + private String image; + + private Date datatime; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java new file mode 100644 index 00000000..17a60aa2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCombinationQueryVo.java @@ -0,0 +1,106 @@ +package co.yixiang.modules.activity.vo; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.serializer.BigDecimalSerializer; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + *

+ * 拼团产品表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-11-19 + */ +@Data +@ApiModel(value = "YxStoreCombinationQueryVo对象", description = "拼团产品表查询参数") +public class YxStoreCombinationQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + + @ApiModelProperty(value = "商品id") + private Long productId; + + @ApiModelProperty(value = "商户id") + private Integer merId; + + @ApiModelProperty(value = "推荐图") + private String image; + + @ApiModelProperty(value = "轮播图") + private String images; + + private List sliderImageArr; + + public List getSliderImageArr() { + if(StrUtil.isNotEmpty(images)){ + return Arrays.asList(images.split(",")); + }else { + return new ArrayList<>(); + } + + } + + @ApiModelProperty(value = "活动标题") + private String title; + + + @ApiModelProperty(value = "参团人数") + private Integer people; + + @ApiModelProperty(value = "简介") + private String info; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "价格") + private BigDecimal price; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "商品价格") + private BigDecimal productPrice; + + + @ApiModelProperty(value = "销量") + private Integer sales; + + @ApiModelProperty(value = "库存") + private Integer stock; + + private Integer combination; + + @ApiModelProperty(value = "是否包邮1是0否") + private Integer isPostage; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "邮费") + private BigDecimal postage; + + @ApiModelProperty(value = "拼团内容") + private String description; + + @ApiModelProperty(value = "拼团订单有效时间") + private Integer effectiveTime; + + @ApiModelProperty(value = "浏览量") + private Integer browse; + + @ApiModelProperty(value = "单位名") + private String unitName; + + /** 是否单独分佣 */ + @JsonProperty("is_sub") + private Integer isSub; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponIssueQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponIssueQueryVo.java new file mode 100644 index 00000000..54313ff8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponIssueQueryVo.java @@ -0,0 +1,64 @@ +package co.yixiang.modules.activity.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 优惠券前台领取表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxStoreCouponIssueQueryVo对象", description = "优惠券前台领取表查询参数") +public class YxStoreCouponIssueQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "优惠券ID") + private Integer cid; + + @ApiModelProperty(value = "优惠券名称") + private String cname; + + @ApiModelProperty(value = "优惠券类别") + private Integer ctype; + + @ApiModelProperty(value = "优惠券领取开启时间") + @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") + private Date startTime; + + @ApiModelProperty(value = "优惠券领取结束时间") + @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") + private Date endTime; + + @ApiModelProperty(value = "优惠券领取数量") + private Integer totalCount; + + @ApiModelProperty(value = "优惠券剩余领取数量") + private Integer remainCount; + + @ApiModelProperty(value = "是否无限张数") + private Integer isPermanent; + + @ApiModelProperty(value = "1 正常 0 未开启 -1 已无效") + private Integer status; + + @ApiModelProperty(value = "优惠券价格") + private Double couponPrice; + + @ApiModelProperty(value = "优惠券最低满多少能使用") + private Double useMinPrice; + + @ApiModelProperty(value = "优惠券是否使用") + private Boolean isUse; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponQueryVo.java new file mode 100644 index 00000000..8d799692 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponQueryVo.java @@ -0,0 +1,53 @@ +package co.yixiang.modules.activity.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + *

+ * 优惠券表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxStoreCouponQueryVo对象", description = "优惠券表查询参数") +public class YxStoreCouponQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "优惠券表ID") + private Integer id; + + @ApiModelProperty(value = "优惠券名称") + private String title; + + @ApiModelProperty(value = "兑换消耗积分值") + private Integer integral; + + @ApiModelProperty(value = "兑换的优惠券面值") + private BigDecimal couponPrice; + + @ApiModelProperty(value = "最低消费多少金额可用优惠券") + private BigDecimal useMinPrice; + + @ApiModelProperty(value = "优惠券有效期限(单位:天)") + private Integer couponTime; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "状态(0:关闭,1:开启)") + private Boolean status; + + @ApiModelProperty(value = "兑换项目添加时间") + private Integer addTime; + + @ApiModelProperty(value = "是否删除") + private Boolean isDel; + +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponUserQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponUserQueryVo.java new file mode 100644 index 00000000..366bf8f3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreCouponUserQueryVo.java @@ -0,0 +1,69 @@ +package co.yixiang.modules.activity.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 优惠券发放记录表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxStoreCouponUserQueryVo对象", description = "优惠券发放记录表查询参数") +public class YxStoreCouponUserQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "优惠券发放记录id") + private Long id; + + @ApiModelProperty(value = "兑换的项目id") + private Integer cid; + + @ApiModelProperty(value = "优惠券所属用户") + private Long uid; + + @ApiModelProperty(value = "优惠券名称") + private String couponTitle; + + @ApiModelProperty(value = "优惠券的面值") + private BigDecimal couponPrice; + + @ApiModelProperty(value = "最低消费多少金额可用优惠券") + private BigDecimal useMinPrice; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") + @ApiModelProperty(value = "优惠券创建时间") + private Date createTime; + + @ApiModelProperty(value = "优惠券结束时间") + @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") + private Date endTime; + + @ApiModelProperty(value = "使用时间") + private Date useTime; + + @ApiModelProperty(value = "获取方式") + private String type; + + @ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已过期)") + private Integer status; + + @ApiModelProperty(value = "是否有效") + private Integer isFail; + + @ApiModelProperty(value = "优惠券发放类型 0可用 1不可用") + private Integer _type; + + @ApiModelProperty(value = "优惠券发放显示文字") + private String _msg; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStorePinkQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStorePinkQueryVo.java new file mode 100644 index 00000000..5c82a337 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStorePinkQueryVo.java @@ -0,0 +1,72 @@ +package co.yixiang.modules.activity.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 拼团表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-11-19 + */ +@Data +@ApiModel(value = "YxStorePinkQueryVo对象", description = "拼团表查询参数") +public class YxStorePinkQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + + @ApiModelProperty(value = "用户id") + private Long uid; + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "用户头像") + private String avatar; + + @ApiModelProperty(value = "订单id 生成") + private String orderId; + + @ApiModelProperty(value = "订单id 数据库") + private Integer orderIdKey; + + @ApiModelProperty(value = "购买商品个数") + private Integer totalNum; + + @ApiModelProperty(value = "购买总金额") + private BigDecimal totalPrice; + + @ApiModelProperty(value = "拼团产品id") + private Long cid; + + @ApiModelProperty(value = "产品id") + private Long pid; + + @ApiModelProperty(value = "拼团总人数") + private Integer people; + + @ApiModelProperty(value = "拼团产品单价") + private BigDecimal price; + + @ApiModelProperty(value = "开始时间") + private Date createTime; + + @ApiModelProperty(value = "结束时间") + private Date stopTime; + + @ApiModelProperty(value = "团长id 0为团长") + private Long kId; + + + @ApiModelProperty(value = "状态1进行中2已完成3未完成") + private Integer status; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java new file mode 100644 index 00000000..50102cd1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/vo/YxStoreSeckillQueryVo.java @@ -0,0 +1,119 @@ +package co.yixiang.modules.activity.vo; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.serializer.BigDecimalSerializer; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +/** + *

+ * 商品秒杀产品表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-14 + */ +@Data +@ApiModel(value="YxStoreSeckillQueryVo对象", description="商品秒杀产品表查询参数") +public class YxStoreSeckillQueryVo implements Serializable{ + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "商品秒杀产品表id") + private Long id; + + @ApiModelProperty(value = "商品id") + private Long productId; + + @ApiModelProperty(value = "推荐图") + private String image; + + @ApiModelProperty(value = "轮播图") + private String images; + + private List sliderImageArr; + + public List getSliderImageArr() { + if(StrUtil.isNotEmpty(images)){ + return Arrays.asList(images.split(",")); + }else { + return new ArrayList<>(); + } + + } + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "价格") + private BigDecimal price; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "成本") + private BigDecimal cost; + + @JsonSerialize(using = BigDecimalSerializer.class) + @ApiModelProperty(value = "原价") + private BigDecimal otPrice; + + @ApiModelProperty(value = "轮播图") + private String[] pics; + @ApiModelProperty(value = "活动标题") + private String title; + + @ApiModelProperty(value = "简介") + private String info; + + @ApiModelProperty(value = "返多少积分") + private BigDecimal giveIntegral; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "库存") + private Integer stock; + + @ApiModelProperty(value = "销量") + private Integer sales; + + @ApiModelProperty(value = "单位名") + private String unitName; + + @ApiModelProperty(value = "邮费") + private BigDecimal postage; + + @ApiModelProperty(value = "内容") + private String description; + + @ApiModelProperty(value = "开始时间") + private Date startTime; + + @ApiModelProperty(value = "结束时间") + private Date stopTime; + + @ApiModelProperty(value = "产品状态") + private Integer status; + + @ApiModelProperty(value = "最多秒杀几个") + private Integer num; + + @ApiModelProperty(value = "显示") + private Integer isShow; + + @ApiModelProperty(value = "百分比") + private Integer percent; + + /** 是否单独分佣 */ + @JsonProperty("is_sub") + private Integer isSub; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/aop/ForbidSubmit.java b/zsw-bxg/src/main/java/co/yixiang/modules/aop/ForbidSubmit.java new file mode 100644 index 00000000..802d8d0e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/aop/ForbidSubmit.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ForbidSubmit { + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/aop/ForbidSubmitAspect.java b/zsw-bxg/src/main/java/co/yixiang/modules/aop/ForbidSubmitAspect.java new file mode 100644 index 00000000..7282a017 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/aop/ForbidSubmitAspect.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.aop; + + +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.springframework.stereotype.Component; + +/** + * 重复提交aop + * @author hupeng + * @since 2020-06-02 + */ +@Aspect +@Component +@Slf4j +public class ForbidSubmitAspect { + + + + + @Pointcut("@annotation(forbidSubmit)") + public void pointCut(ForbidSubmit forbidSubmit) { + } + + @Around("pointCut(forbidSubmit)") + public Object around(ProceedingJoinPoint pjp, ForbidSubmit forbidSubmit) throws Throwable { + + //用于拦截演示环境一些禁止操作 + //throw new YshopException("演示环境禁止操作"); + return pjp.proceed(); + + + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/domain/StoreCanvas.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/domain/StoreCanvas.java new file mode 100644 index 00000000..98434099 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/domain/StoreCanvas.java @@ -0,0 +1,52 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.domain; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.validation.constraints.*; +import co.yixiang.domain.BaseDomain; + +/** +* @author yshop +* @date 2021-02-01 +*/ +@Data +@TableName("yx_store_canvas") +public class StoreCanvas extends BaseDomain { + /** 画布id */ + @TableId + private Long canvasId; + + /** 终端 1-小程序 2-H5 3-APP 4-PC */ + @NotNull + private Integer terminal; + + /** 画布json数据 */ + private String json; + + /** 类型 1-系统画布 2-自定义页面 3-商家店铺装修 */ + private Integer type; + + /** 名称 */ + @NotBlank + private String name; + + /** 店铺id,当type=3的时候,值为具体的店铺id,其它情况为0 */ + private Long shopId; + + + + + public void copy(StoreCanvas source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java new file mode 100644 index 00000000..a824109f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java @@ -0,0 +1,113 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.rest; +import java.util.Arrays; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.constant.ShopConstants; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.LocalStorageService; +import co.yixiang.tools.service.QiNiuService; +import co.yixiang.tools.service.dto.LocalStorageDto; +import co.yixiang.utils.RedisUtils; +import lombok.AllArgsConstructor; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.canvas.domain.StoreCanvas; +import co.yixiang.modules.canvas.service.StoreCanvasService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.util.HashMap; +import java.util.Map; +import org.springframework.web.multipart.MultipartFile; + +/** +* @author yshop +* @date 2021-02-01 +*/ +@AllArgsConstructor +@Api(tags = "画布管理") +@RestController +@RequestMapping("/api/canvas") +public class StoreCanvasController { + + private final StoreCanvasService storeCanvasService; + private final LocalStorageService localStorageService; + private final QiNiuService qiNiuService; + private final RedisUtils redisUtils; + + + @PostMapping("/saveCanvas") + @Log("新增或修改画布") + @ApiOperation("新增或修改画布") + public ResponseEntity create(@Validated @RequestBody StoreCanvas resources){ + return new ResponseEntity<>(storeCanvasService.saveOrUpdate(resources),HttpStatus.CREATED); + } + + + @ApiOperation("上传文件") + @PostMapping("/upload") + public ResponseEntity create(@RequestParam(defaultValue = "") String name, + @RequestParam(defaultValue = "") String type, + @RequestParam("file") MultipartFile file) { + + String localUrl = redisUtils.getY(ShopConstants.ADMIN_API_URL); + if(StrUtil.isBlank(type)){ + localUrl = redisUtils.getY(SystemConfigConstants.API_URL) + "/api"; + } + String mode = redisUtils.getY(SystemConfigConstants.FILE_STORE_MODE); + StringBuilder url = new StringBuilder(); + if (ShopCommonEnum.STORE_MODE_1.getValue().toString().equals(mode)) { //存在走本地 + if(StrUtil.isBlank(localUrl)){ + throw new YshopException("本地上传,请先登陆系统配置后台/移动端API地址"); + } + LocalStorageDto localStorageDTO = localStorageService.create(name, file); + if ("".equals(url.toString())) { + url = url.append(localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName()); + } else { + url = url.append(","+localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName()); + } + } else {//走七牛云 + QiniuContent qiniuContent = qiNiuService.upload(file, qiNiuService.find()); + if ("".equals(url.toString())) { + url = url.append(qiniuContent.getUrl()); + }else{ + url = url.append(","+qiniuContent.getUrl()); + } + } + + Map map = new HashMap<>(2); + map.put("errno", 0); + map.put("link", url); + return new ResponseEntity(map, HttpStatus.CREATED); + } + + + @GetMapping("/getCanvas") + @ApiOperation(value = "读取画布数据") + public ResponseEntity getCanvas(StoreCanvas storeCanvas){ + StoreCanvas canvas = storeCanvasService.lambdaQuery().eq(StoreCanvas::getTerminal, storeCanvas.getTerminal()).one(); + return new ResponseEntity<>(canvas,HttpStatus.OK); + } + + @Log("删除画布") + @ApiOperation("删除画布") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + storeCanvasService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/StoreCanvasService.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/StoreCanvasService.java new file mode 100644 index 00000000..d4705bea --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/StoreCanvasService.java @@ -0,0 +1,49 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.service; +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.canvas.domain.StoreCanvas; +import co.yixiang.modules.canvas.service.dto.StoreCanvasDto; +import co.yixiang.modules.canvas.service.dto.StoreCanvasQueryCriteria; +import com.baomidou.dynamic.datasource.annotation.DS; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** +* @author yshop +* @date 2021-02-01 +*/ +public interface StoreCanvasService extends BaseService{ + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(StoreCanvasQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(StoreCanvasQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/dto/StoreCanvasDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/dto/StoreCanvasDto.java new file mode 100644 index 00000000..51e90ad4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/dto/StoreCanvasDto.java @@ -0,0 +1,44 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @author yshop +* @date 2021-02-01 +*/ +@Data +public class StoreCanvasDto implements Serializable { + + /** 画布id */ + private Long canvasId; + + /** 终端 1-小程序 2-H5 3-APP 4-PC */ + private Integer terminal; + + /** 画布json数据 */ + private String json; + + /** 类型 1-系统画布 2-自定义页面 3-商家店铺装修 */ + private Integer type; + + /** 名称 */ + private String name; + + /** 店铺id,当type=3的时候,值为具体的店铺id,其它情况为0 */ + private Long shopId; + + /** 创建时间 */ + private String createTime; + + /** 修改时间 */ + private String updateTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/dto/StoreCanvasQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/dto/StoreCanvasQueryCriteria.java new file mode 100644 index 00000000..6a771313 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/dto/StoreCanvasQueryCriteria.java @@ -0,0 +1,21 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.service.dto; + +import lombok.Data; +import java.util.List; +import co.yixiang.annotation.Query; + +/** +* @author yshop +* @date 2021-02-01 +*/ +@Data +public class StoreCanvasQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/impl/StoreCanvasServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/impl/StoreCanvasServiceImpl.java new file mode 100644 index 00000000..250131aa --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/impl/StoreCanvasServiceImpl.java @@ -0,0 +1,84 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.service.impl; + +import co.yixiang.modules.canvas.domain.StoreCanvas; +import co.yixiang.common.service.impl.BaseServiceImpl; +import lombok.AllArgsConstructor; +import co.yixiang.dozer.service.IGenerator; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.utils.ValidationUtil; +import co.yixiang.utils.FileUtil; +import co.yixiang.modules.canvas.service.StoreCanvasService; +import co.yixiang.modules.canvas.service.dto.StoreCanvasDto; +import co.yixiang.modules.canvas.service.dto.StoreCanvasQueryCriteria; +import co.yixiang.modules.canvas.service.mapper.StoreCanvasMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import co.yixiang.domain.PageResult; +/** +* @author yshop +* @date 2021-02-01 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "storeCanvas") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreCanvasServiceImpl extends BaseServiceImpl implements StoreCanvasService { + + private final IGenerator generator; + + @Override + //@Cacheable + public PageResult queryAll(StoreCanvasQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + return generator.convertPageInfo(page,StoreCanvasDto.class); + } + + + @Override + //@Cacheable + public List queryAll(StoreCanvasQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(StoreCanvas.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (StoreCanvasDto storeCanvas : all) { + Map map = new LinkedHashMap<>(); + map.put("终端 1-小程序 2-H5 3-APP 4-PC", storeCanvas.getTerminal()); + map.put("画布json数据", storeCanvas.getJson()); + map.put("类型 1-系统画布 2-自定义页面 3-商家店铺装修", storeCanvas.getType()); + map.put("名称", storeCanvas.getName()); + map.put("店铺id,当type=3的时候,值为具体的店铺id,其它情况为0", storeCanvas.getShopId()); + map.put("创建时间", storeCanvas.getCreateTime()); + map.put("修改时间", storeCanvas.getUpdateTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/mapper/StoreCanvasMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/mapper/StoreCanvasMapper.java new file mode 100644 index 00000000..d7ccdbe9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/service/mapper/StoreCanvasMapper.java @@ -0,0 +1,25 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.canvas.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.canvas.domain.StoreCanvas; +import com.baomidou.dynamic.datasource.annotation.DS; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author yshop +* @date 2021-02-01 +*/ +@Repository + +public interface StoreCanvasMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/domain/YxStoreCart.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/domain/YxStoreCart.java new file mode 100644 index 00000000..34dbea8a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/domain/YxStoreCart.java @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.cart.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("yx_store_cart") +public class YxStoreCart extends BaseDomain { + + /** 购物车表ID */ + @TableId + private Long id; + + + /** 用户ID */ + private Long uid; + + + /** 类型 */ + private String type; + + + /** 商品ID */ + private Long productId; + + + /** 商品属性 */ + private String productAttrUnique; + + + /** 商品数量 */ + private Integer cartNum; + + + + + /** 0 = 未购买 1 = 已购买 */ + private Integer isPay; + + + + /** 是否为立即购买 */ + private Integer isNew; + + + /** 拼团id */ + //@Column(name = "combination_id") + private Long combinationId; + + + /** 秒杀产品ID */ + private Long seckillId; + + + /** 砍价id */ + private Long bargainId; + + + public void copy(YxStoreCart source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/YxStoreCartService.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/YxStoreCartService.java new file mode 100644 index 00000000..856c3bb0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/YxStoreCartService.java @@ -0,0 +1,112 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.cart.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.cart.domain.YxStoreCart; +import co.yixiang.modules.cart.service.dto.YxStoreCartDto; +import co.yixiang.modules.cart.service.dto.YxStoreCartQueryCriteria; +import co.yixiang.modules.order.service.dto.CountDto; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreCartService extends BaseService{ + + /** + * 删除购物车 + * @param uid uid + * @param ids 购物车id集合 + */ + void removeUserCart(Long uid, List ids); + + /** + * 改购物车数量 + * @param cartId 购物车id + * @param cartNum 数量 + * @param uid uid + */ + void changeUserCartNum(Long cartId,int cartNum,Long uid); + + /** + * 购物车列表 + * @param uid 用户id + * @param cartIds 购物车id,多个逗号隔开 + * @param status 0-购购物车列表 + * @return map valid-有效购物车 invalid-失效购物车 + */ + Map getUserProductCartList(Long uid,String cartIds,Integer status); + + /** + * 返回当前用户购物车总数量 + * @param uid 用户id + * @return int + */ + int getUserCartNum(Long uid); + + /** + * 添加购物车 + * @param uid 用户id + * @param productId 普通产品编号 + * @param cartNum 购物车数量 + * @param productAttrUnique 属性唯一值 + * @param isNew 1 加入购物车直接购买 0 加入购物车 + * @param combinationId 拼团id + * @param seckillId 秒杀id + * @param bargainId 砍价id + * @return 购物车id + */ + long addCart(Long uid,Long productId,Integer cartNum, String productAttrUnique, + Integer isNew,Long combinationId,Long seckillId,Long bargainId); + + /** + * 检测商品/秒杀/砍价/拼团库存 + * @param uid 用户ID + * @param productId 产品ID + * @param cartNum 购买数量 + * @param productAttrUnique 商品属性Unique + * @param combinationId 拼团产品ID + * @param seckillId 秒杀产品ID + * @param bargainId 砍价产品ID + */ + void checkProductStock(Long uid, Long productId, Integer cartNum, String productAttrUnique, + Long combinationId, Long seckillId, Long bargainId); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCartQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCartQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + List findCateName(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/dto/YxStoreCartDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/dto/YxStoreCartDto.java new file mode 100644 index 00000000..ae021960 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/dto/YxStoreCartDto.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.cart.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreCartDto implements Serializable { + + /** 购物车表ID */ + private Long id; + + /** 用户ID */ + private Integer uid; + + /** 类型 */ + private String type; + + /** 商品ID */ + private Integer productId; + + /** 商品属性 */ + private String productAttrUnique; + + /** 商品数量 */ + private Integer cartNum; + + /** 添加时间 */ + private Integer addTime; + + /** 0 = 未购买 1 = 已购买 */ + private Integer isPay; + + /** 是否删除 */ + private Integer isDel; + + /** 是否为立即购买 */ + private Integer isNew; + + /** 拼团id */ + private Integer combinationId; + + /** 秒杀产品ID */ + private Integer seckillId; + + /** 砍价id */ + private Integer bargainId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/dto/YxStoreCartQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/dto/YxStoreCartQueryCriteria.java new file mode 100644 index 00000000..607b4c79 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/dto/YxStoreCartQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.cart.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreCartQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/impl/YxStoreCartServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/impl/YxStoreCartServiceImpl.java new file mode 100644 index 00000000..dcd00d30 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/impl/YxStoreCartServiceImpl.java @@ -0,0 +1,452 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.cart.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.CartTypeEnum; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.ProductTypeEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.activity.domain.YxStoreBargain; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.mapper.YxStoreBargainMapper; +import co.yixiang.modules.activity.service.mapper.YxStoreCombinationMapper; +import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper; +import co.yixiang.modules.cart.domain.YxStoreCart; +import co.yixiang.modules.cart.service.YxStoreCartService; +import co.yixiang.modules.cart.service.dto.YxStoreCartDto; +import co.yixiang.modules.cart.service.dto.YxStoreCartQueryCriteria; +import co.yixiang.modules.cart.service.mapper.StoreCartMapper; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.service.dto.CountDto; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * @author hupeng + * @date 2020-05-12 + */ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCartServiceImpl extends BaseServiceImpl implements YxStoreCartService { + + @Autowired + private IGenerator generator; + + @Autowired + private StoreCartMapper yxStoreCartMapper; + @Autowired + private YxStoreSeckillMapper storeSeckillMapper; + @Autowired + private YxStoreBargainMapper yxStoreBargainMapper; + @Autowired + private YxStoreCombinationMapper storeCombinationMapper; + @Autowired + private YxStoreProductService productService; + @Autowired + private YxStoreProductAttrService productAttrService; + @Autowired + private YxStoreBargainService storeBargainService; + @Autowired + private YxUserService userService; + + + /** + * 删除购物车 + * + * @param uid uid + * @param ids 购物车id集合 + */ + @Override + public void removeUserCart(Long uid, List ids) { + List newids = ids.stream().map(Long::new).collect(Collectors.toList()); + yxStoreCartMapper.delete(Wrappers.lambdaQuery() + .eq(YxStoreCart::getUid, uid) + .in(YxStoreCart::getId, newids)); + } + + /** + * 改购物车数量 + * + * @param cartId 购物车id + * @param cartNum 数量 + * @param uid uid + */ + @Override + public void changeUserCartNum(Long cartId, int cartNum, Long uid) { + YxStoreCart cart = this.lambdaQuery() + .eq(YxStoreCart::getUid, uid) + .eq(YxStoreCart::getId, cartId) + .one(); + if (cart == null) { + throw new YshopException("购物车不存在"); + } + + if (cartNum <= 0) { + throw new YshopException("库存错误"); + } + + //普通商品库存 + int stock = productService.getProductStock(cart.getProductId() + , cart.getProductAttrUnique(), ""); + if (stock < cartNum) { + throw new YshopException("该产品库存不足" + cartNum); + } + + if (cartNum == cart.getCartNum()) { + return; + } + + YxStoreCart storeCart = new YxStoreCart(); + storeCart.setCartNum(cartNum); + storeCart.setId(cartId); + + yxStoreCartMapper.updateById(storeCart); + + + } + + /** + * 购物车列表 + * + * @param uid 用户id + * @param cartIds 购物车id,多个逗号隔开 + * @param status 0-购购物车列表 + * @return map valid-有效购物车 invalid-失效购物车 + */ + @Override + public Map getUserProductCartList(Long uid, String cartIds, Integer status) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreCart::getUid, uid) + .eq(YxStoreCart::getIsPay, OrderInfoEnum.PAY_STATUS_0.getValue()) + .orderByDesc(YxStoreCart::getId); + if (status == null) { + wrapper.eq(YxStoreCart::getIsNew, CartTypeEnum.NEW_0.getValue()); + } + if (StrUtil.isNotEmpty(cartIds)) { + wrapper.in(YxStoreCart::getId, Arrays.asList(cartIds.split(","))); + } + List carts = yxStoreCartMapper.selectList(wrapper); + + List valid = new ArrayList<>(); + List invalid = new ArrayList<>(); + + for (YxStoreCart storeCart : carts) { + YxStoreProductQueryVo storeProduct = null; + if (storeCart.getCombinationId() != null && storeCart.getCombinationId() > 0) { + storeProduct = ObjectUtil.clone(storeCombinationMapper.combinatiionInfo(storeCart.getCombinationId())); + } else if (storeCart.getSeckillId() != null && storeCart.getSeckillId() > 0) { + storeProduct = ObjectUtil.clone(storeSeckillMapper.seckillInfo(storeCart.getSeckillId())); + } else if (storeCart.getBargainId() != null && storeCart.getBargainId() > 0) { + storeProduct = ObjectUtil.clone(yxStoreBargainMapper.bargainInfo(storeCart.getBargainId())); + } else { + //必须得重新克隆创建一个新对象 + storeProduct = ObjectUtil.clone(productService + .getStoreProductById(storeCart.getProductId())); + } + + YxStoreCartQueryVo storeCartQueryVo = generator.convert(storeCart, YxStoreCartQueryVo.class); + + if (ObjectUtil.isNull(storeProduct)) { + this.removeById(storeCart.getId()); + } else if (ShopCommonEnum.SHOW_0.getValue().equals(storeProduct.getIsShow()) || (storeProduct.getStock() == 0 && StrUtil.isEmpty(storeCart.getProductAttrUnique()))) { + storeCartQueryVo.setProductInfo(storeProduct); + invalid.add(storeCartQueryVo); + } else { + if (StrUtil.isNotEmpty(storeCart.getProductAttrUnique())) { + YxStoreProductAttrValue productAttrValue = productAttrService + .uniqueByAttrInfo(storeCart.getProductAttrUnique()); + if (ObjectUtil.isNull(productAttrValue) || productAttrValue.getStock() == 0) { + storeCartQueryVo.setProductInfo(storeProduct); + invalid.add(storeCartQueryVo); + } else { + storeProduct.setAttrInfo(productAttrValue); + storeCartQueryVo.setProductInfo(storeProduct); + + //设置真实价格 + //设置VIP价格 + double vipPrice = userService.setLevelPrice( + productAttrValue.getPrice().doubleValue(), uid); + //砍价金额 + if ( storeCart.getBargainId() > 0 + ) { + vipPrice = storeProduct.getPrice().doubleValue(); + } + //设置拼团价格 + if(storeCart.getCombinationId() > 0 ){ + vipPrice = productAttrValue.getPinkPrice().doubleValue(); + } + //设置秒杀价格 + if( storeCart.getSeckillId() > 0){ + vipPrice = productAttrValue.getSeckillPrice().doubleValue(); + } + storeCartQueryVo.setTruePrice(vipPrice); + //设置会员价 + storeCartQueryVo.setVipTruePrice(productAttrValue.getPrice() + .doubleValue()); + storeCartQueryVo.setCostPrice(productAttrValue.getCost() + .doubleValue()); + storeCartQueryVo.setTrueStock(productAttrValue.getStock()); + + valid.add(storeCartQueryVo); + + } + } else { + //设置VIP价格,营销商品不参与 + double vipPrice = userService.setLevelPrice( + storeProduct.getPrice().doubleValue(), uid); + if (storeCart.getCombinationId() > 0 || storeCart.getSeckillId() > 0 + || storeCart.getBargainId() > 0) { + vipPrice = storeProduct.getPrice().doubleValue(); + } + + storeCartQueryVo.setTruePrice(vipPrice); + // 设置会员价 + storeCartQueryVo.setVipTruePrice(0d); + storeCartQueryVo.setCostPrice(storeProduct.getCost() + .doubleValue()); + storeCartQueryVo.setTrueStock(storeProduct.getStock()); + storeCartQueryVo.setProductInfo(storeProduct); + + valid.add(storeCartQueryVo); + } + } + + } + + Map map = new LinkedHashMap<>(); + map.put("valid", valid); + map.put("invalid", invalid); + return map; + } + + /** + * 添加购物车 + * @param uid 用户id + * @param productId 普通产品编号 + * @param cartNum 购物车数量 + * @param productAttrUnique 属性唯一值 + * @param isNew 1 加入购物车直接购买 0 加入购物车 + * @param combinationId 拼团id + * @param seckillId 秒杀id + * @param bargainId 砍价id + * @return 购物车id + */ + @Override + public long addCart(Long uid, Long productId, Integer cartNum, String productAttrUnique, + Integer isNew, Long combinationId, Long seckillId, Long bargainId) { + + this.checkProductStock(uid, productId, cartNum, productAttrUnique, combinationId, seckillId, bargainId); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreCart::getUid, uid) + .eq(YxStoreCart::getIsPay, OrderInfoEnum.PAY_STATUS_0.getValue()) + .eq(YxStoreCart::getProductId, productId) + .eq(YxStoreCart::getIsNew, isNew) + .eq(YxStoreCart::getProductAttrUnique, productAttrUnique) + .eq(YxStoreCart::getBargainId, bargainId) + .eq(YxStoreCart::getCombinationId, combinationId) + .eq(YxStoreCart::getSeckillId, seckillId) + .orderByDesc(YxStoreCart::getId) + .last("limit 1"); + + YxStoreCart cart = yxStoreCartMapper.selectOne(wrapper); + + YxStoreCart storeCart = YxStoreCart.builder() + .cartNum(cartNum) + .productAttrUnique(productAttrUnique) + .productId(productId) + .bargainId(bargainId) + .combinationId(combinationId) + .seckillId(seckillId) + .isNew(isNew) + .uid(uid) + .build(); + if (cart != null) { + if (CartTypeEnum.NEW_0.getValue().equals(isNew)) { + storeCart.setCartNum(cartNum + cart.getCartNum()); + } + storeCart.setId(cart.getId()); + yxStoreCartMapper.updateById(storeCart); + } else { + yxStoreCartMapper.insert(storeCart); + } + + return storeCart.getId(); + } + + /** + * 返回当前用户购物车总数量 + * + * @param uid 用户id + * @return int + */ + @Override + public int getUserCartNum(Long uid) { + return yxStoreCartMapper.cartSum(uid); + } + +// @Override +// public YxStoreCartQueryVo getYxStoreCartById(Serializable id){ +// return yxStoreCartMapper.getYxStoreCartById(id); +// } + + /** + * 检测商品/秒杀/砍价/拼团库存 + * + * @param uid 用户ID + * @param productId 产品ID + * @param cartNum 购买数量 + * @param productAttrUnique 商品属性Unique + * @param combinationId 拼团产品ID + * @param seckillId 秒杀产品ID + * @param bargainId 砍价产品ID + */ + @Override + public void checkProductStock(Long uid, Long productId, Integer cartNum, String productAttrUnique, + Long combinationId, Long seckillId, Long bargainId) { + Date now = new Date(); + //拼团 + if (combinationId != null && combinationId > 0) { + YxStoreProduct product = productService + .lambdaQuery().eq(YxStoreProduct::getId, productId) + .eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .one(); + if (product == null) { + throw new YshopException("该产品已下架或删除"); + } + + int stock = productService.getProductStock(productId, productAttrUnique, ProductTypeEnum.PINK.getValue()); + if (stock < cartNum) { + throw new YshopException(product.getStoreName() + "库存不足" + cartNum); + } + //秒杀 + } else if (seckillId != null && seckillId > 0) { + YxStoreProduct product = productService + .lambdaQuery().eq(YxStoreProduct::getId, productId) + .eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .one(); + if (product == null) { + throw new YshopException("该产品已下架或删除"); + } + + int stock = productService.getProductStock(productId, productAttrUnique, ProductTypeEnum.SECKILL.getValue()); + if (stock < cartNum) { + throw new YshopException(product.getStoreName() + "库存不足" + cartNum); + } + //砍价 + } else if (bargainId != null && bargainId > 0) { + YxStoreBargain yxStoreBargain = storeBargainService + .lambdaQuery().eq(YxStoreBargain::getId, bargainId) + .eq(YxStoreBargain::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .le(YxStoreBargain::getStartTime, now) + .ge(YxStoreBargain::getStopTime, now) + .one(); + if (yxStoreBargain == null) { + throw new YshopException("该产品已下架或删除"); + } + if (yxStoreBargain.getStock() < cartNum) { + throw new YshopException("该产品库存不足"); + } + + } else { + YxStoreProduct product = productService + .lambdaQuery().eq(YxStoreProduct::getId, productId) + .eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .one(); + if (product == null) { + throw new YshopException("该产品已下架或删除"); + } + + int stock = productService.getProductStock(productId, productAttrUnique, ""); + if (stock < cartNum) { + throw new YshopException(product.getStoreName() + "库存不足" + cartNum); + } + } + + } + + + //====================================================================// + + + @Override + //@Cacheable + public Map queryAll(YxStoreCartQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreCartDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCartQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCart.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCartDto yxStoreCart : all) { + Map map = new LinkedHashMap<>(); + map.put("用户ID", yxStoreCart.getUid()); + map.put("类型", yxStoreCart.getType()); + map.put("商品ID", yxStoreCart.getProductId()); + map.put("商品属性", yxStoreCart.getProductAttrUnique()); + map.put("商品数量", yxStoreCart.getCartNum()); + map.put("添加时间", yxStoreCart.getAddTime()); + map.put("0 = 未购买 1 = 已购买", yxStoreCart.getIsPay()); + map.put("是否删除", yxStoreCart.getIsDel()); + map.put("是否为立即购买", yxStoreCart.getIsNew()); + map.put("拼团id", yxStoreCart.getCombinationId()); + map.put("秒杀产品ID", yxStoreCart.getSeckillId()); + map.put("砍价id", yxStoreCart.getBargainId()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public List findCateName() { + return yxStoreCartMapper.findCateName(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/mapper/StoreCartMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/mapper/StoreCartMapper.java new file mode 100644 index 00000000..88383a72 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/service/mapper/StoreCartMapper.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.cart.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.cart.domain.YxStoreCart; +import co.yixiang.modules.order.service.dto.CountDto; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreCartMapper extends CoreMapper { + + @Select("select IFNULL(sum(cart_num),0) from yx_store_cart " + + "where is_pay=0 and is_del=0 and is_new=0 and uid=#{uid}") + int cartSum(@Param("uid") Long uid); + + + @Select("SELECT t.cate_name as catename from yx_store_cart c " + + "LEFT JOIN yx_store_product p on c.product_id = p.id " + + "LEFT JOIN yx_store_category t on p.cate_id = t.id " + + "WHERE c.is_pay = 1") + List findCateName(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/cart/vo/YxStoreCartQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/cart/vo/YxStoreCartQueryVo.java new file mode 100644 index 00000000..a45009fc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/cart/vo/YxStoreCartQueryVo.java @@ -0,0 +1,77 @@ +package co.yixiang.modules.cart.vo; + +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.serializer.DoubleSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 购物车表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-25 + */ +@Data +@ApiModel(value = "YxStoreCartQueryVo对象", description = "购物车表查询参数") +public class YxStoreCartQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "购物车表ID") + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "类型") + private String type; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "商品属性") + private String productAttrUnique; + + @ApiModelProperty(value = "商品数量") + private Integer cartNum; + + + @ApiModelProperty(value = "拼团id") + private Long combinationId; + + @ApiModelProperty(value = "秒杀产品ID") + private Long seckillId; + + @ApiModelProperty(value = "砍价id") + private Long bargainId; + + @ApiModelProperty(value = "商品信息") + private YxStoreProductQueryVo productInfo; + + @ApiModelProperty(value = "成本价") + @JsonSerialize(using = DoubleSerializer.class) + private Double costPrice; + + @ApiModelProperty(value = "真实价格") + @JsonSerialize(using = DoubleSerializer.class) + private Double truePrice; + + @ApiModelProperty(value = "真实库存") + private Integer trueStock; + + @JsonSerialize(using = DoubleSerializer.class) + @ApiModelProperty(value = "vip真实价格") + private Double vipTruePrice; + + @ApiModelProperty(value = "唯一id") + private String unique; + + @ApiModelProperty(value = "是否评价") + private Long isReply; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/domain/YxStoreCategory.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/domain/YxStoreCategory.java new file mode 100644 index 00000000..6ce984c9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/domain/YxStoreCategory.java @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.category.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_category") +public class YxStoreCategory extends BaseDomain { + + /** 商品分类表ID */ + @TableId + private Integer id; + + + /** 父id */ + private Integer pid; + + + /** 分类名称 */ + @NotBlank(message = "分类名称必填") + private String cateName; + + + /** 排序 */ + private Integer sort; + + + /** 图标 */ + private String pic; + + + /** 是否推荐 */ + private Integer isShow; + + + + + public void copy(YxStoreCategory source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java new file mode 100644 index 00000000..94aad122 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/rest/StoreCategoryController.java @@ -0,0 +1,161 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.category.rest; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.constant.ShopConstants; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.category.domain.YxStoreCategory; +import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.modules.category.service.dto.YxStoreCategoryDto; +import co.yixiang.modules.category.service.dto.YxStoreCategoryQueryCriteria; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** +* @author hupeng +* @date 2019-10-03 +*/ +@Api(tags = "商城:商品分类管理") +@RestController +@RequestMapping("api") +public class StoreCategoryController { + + + private final YxStoreCategoryService yxStoreCategoryService; + private final YxStoreProductService yxStoreProductService; + + + public StoreCategoryController(YxStoreCategoryService yxStoreCategoryService, + YxStoreProductService yxStoreProductService) { + this.yxStoreCategoryService = yxStoreCategoryService; + this.yxStoreProductService = yxStoreProductService; + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/yxStoreCategory/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXSTORECATEGORY_SELECT')") + public void download(HttpServletResponse response, YxStoreCategoryQueryCriteria criteria) throws IOException { + yxStoreCategoryService.download(yxStoreCategoryService.queryAll(criteria), response); + } + + + @Log("查询商品分类") + @ApiOperation(value = "查询商品分类") + @GetMapping(value = "/yxStoreCategory") + @PreAuthorize("hasAnyRole('admin','YXSTORECATEGORY_ALL','YXSTORECATEGORY_SELECT')") + public ResponseEntity getYxStoreCategorys(YxStoreCategoryQueryCriteria criteria, Pageable pageable){ + List categoryDTOList = yxStoreCategoryService.queryAll(criteria); + return new ResponseEntity<>(yxStoreCategoryService.buildTree(categoryDTOList),HttpStatus.OK); + } + + @ForbidSubmit + @Log("新增商品分类") + @ApiOperation(value = "新增商品分类") + @PostMapping(value = "/yxStoreCategory") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @PreAuthorize("hasAnyRole('admin','YXSTORECATEGORY_ALL','YXSTORECATEGORY_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxStoreCategory resources){ + if(resources.getPid() != null && resources.getPid() > 0 && StrUtil.isBlank(resources.getPic())) { + throw new YshopException("子分类图片必传"); + } + + boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid()); + if(!checkResult) { + throw new YshopException("分类最多能添加2级哦"); + } + + return new ResponseEntity<>(yxStoreCategoryService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @Log("修改商品分类") + @ApiOperation(value = "修改商品分类") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @PutMapping(value = "/yxStoreCategory") + @PreAuthorize("hasAnyRole('admin','YXSTORECATEGORY_ALL','YXSTORECATEGORY_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreCategory resources){ + if(resources.getPid() != null && resources.getPid() > 0 && StrUtil.isBlank(resources.getPic())) { + throw new YshopException("子分类图片必传"); + } + + if(resources.getId().equals(resources.getPid())){ + throw new YshopException("自己不能选择自己哦"); + } + + boolean checkResult = yxStoreCategoryService.checkCategory(resources.getPid()); + + if(!checkResult) { + throw new YshopException("分类最多能添加2级哦"); + } + + yxStoreCategoryService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除商品分类") + @ApiOperation(value = "删除商品分类") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @DeleteMapping(value = "/yxStoreCategory/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTORECATEGORY_ALL','YXSTORECATEGORY_DELETE')") + public ResponseEntity delete(@PathVariable String id){ + String[] ids = id.split(","); + for (String newId: ids) { + this.delCheck(Integer.valueOf(newId)); + yxStoreCategoryService.removeById(Integer.valueOf(newId)); + } + return new ResponseEntity(HttpStatus.OK); + } + + + /** + * 检测删除分类 + * @param id 分类id + */ + private void delCheck(Integer id){ + Long count = yxStoreCategoryService.lambdaQuery() + .eq(YxStoreCategory::getPid,id) + .count(); + if(count > 0) { + throw new YshopException("请先删除子分类"); + } + + Long countP = yxStoreProductService.lambdaQuery() + .eq(YxStoreProduct::getCateId,id) + .count(); + + if(countP > 0) { + throw new YshopException("当前分类下有商品不可删除"); + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/service/YxStoreCategoryService.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/YxStoreCategoryService.java new file mode 100644 index 00000000..29a53a90 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/YxStoreCategoryService.java @@ -0,0 +1,74 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.category.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.category.domain.YxStoreCategory; +import co.yixiang.modules.category.service.dto.YxStoreCategoryDto; +import co.yixiang.modules.category.service.dto.YxStoreCategoryQueryCriteria; +import co.yixiang.utils.CateDTO; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreCategoryService extends BaseService{ + + List getList(); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCategoryQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCategoryQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * 构建树形 + * @param categoryDTOS 分类列表 + * @return map + */ + Map buildTree(List categoryDTOS); + + /** + * 检测分类是否操过二级 + * @param pid 父级id + * @return boolean + */ + boolean checkCategory(int pid); + + /** + * 检测商品分类必选选择二级 + * @param id 分类id + * @return boolean + */ + boolean checkProductCategory(int id); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategoryDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategoryDto.java new file mode 100644 index 00000000..396b10c2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategoryDto.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.category.service.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreCategoryDto implements Serializable { + + /** 商品分类表ID */ + private Integer id; + + /** 父id */ + private Integer pid; + + /** 分类名称 */ + private String cateName; + + /** 排序 */ + private Integer sort; + + /** 图标 */ + private String pic; + + /** 是否推荐 */ + private Integer isShow; + + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public String getLabel() { + return cateName; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategoryQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategoryQueryCriteria.java new file mode 100644 index 00000000..ac9566a5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategoryQueryCriteria.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.category.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreCategoryQueryCriteria{ + @Query + private String cateName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategorySmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategorySmallDto.java new file mode 100644 index 00000000..23d9ca9c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/dto/YxStoreCategorySmallDto.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.category.service.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** +* @author hupeng +* @date 2019-10-03 +*/ +@Data +public class YxStoreCategorySmallDto implements Serializable { + + // 商品分类表ID + private Integer id; + + + // 分类名称 + private String cateName; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/service/impl/YxStoreCategoryServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/impl/YxStoreCategoryServiceImpl.java new file mode 100644 index 00000000..04768c4f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/impl/YxStoreCategoryServiceImpl.java @@ -0,0 +1,185 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.category.service.impl; + +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.modules.category.domain.YxStoreCategory; +import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.modules.category.service.dto.YxStoreCategoryDto; +import co.yixiang.modules.category.service.dto.YxStoreCategoryQueryCriteria; +import co.yixiang.modules.category.service.mapper.StoreCategoryMapper; +import co.yixiang.utils.CateDTO; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.TreeUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import com.google.common.collect.Maps; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCategoryServiceImpl extends BaseServiceImpl implements YxStoreCategoryService { + + private final IGenerator generator; + + /** + * 获取分类列表树形列表 + * @return List + */ + @Override + public List getList() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxStoreCategory::getSort); + List list = generator.convert(baseMapper.selectList(wrapper),CateDTO.class); + return TreeUtil.list2TreeConverter(list,0); + } + + //===============================// + + @Override + public Map queryAll(YxStoreCategoryQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", page.getList()); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + public List queryAll(YxStoreCategoryQueryCriteria criteria){ + return generator.convert(this.baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCategory.class, criteria)), + YxStoreCategoryDto.class); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCategoryDto yxStoreCategory : all) { + Map map = new LinkedHashMap<>(); + map.put("父id", yxStoreCategory.getPid()); + map.put("分类名称", yxStoreCategory.getCateName()); + map.put("排序", yxStoreCategory.getSort()); + map.put("图标", yxStoreCategory.getPic()); + map.put("是否推荐", yxStoreCategory.getIsShow()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 构建树形 + * @param categoryDTOS 分类列表 + * @return map + */ + @Override + public Map buildTree(List categoryDTOS) { + Set trees = new LinkedHashSet<>(); + Set cates = new LinkedHashSet<>(); + List deptNames = categoryDTOS.stream().map(YxStoreCategoryDto::getCateName) + .collect(Collectors.toList()); + + //YxStoreCategoryDto categoryDTO = new YxStoreCategoryDto(); + Boolean isChild; + List categories = this.list(); + for (YxStoreCategoryDto deptDTO : categoryDTOS) { + isChild = false; + if ("0".equals(deptDTO.getPid().toString())) { + trees.add(deptDTO); + } + for (YxStoreCategoryDto it : categoryDTOS) { + if (it.getPid().equals(deptDTO.getId())) { + isChild = true; + if (deptDTO.getChildren() == null) { + deptDTO.setChildren(new ArrayList()); + } + deptDTO.getChildren().add(it); + } + } + if (isChild) { + cates.add(deptDTO); + } + for (YxStoreCategory category : categories) { + if (category.getId().equals(deptDTO.getPid()) && !deptNames.contains(category.getCateName())) { + cates.add(deptDTO); + } + } + } + + + if (CollectionUtils.isEmpty(trees)) { + trees = cates; + } + + + Integer totalElements = categoryDTOS != null ? categoryDTOS.size() : 0; + + Map map = Maps.newHashMap(); + map.put("totalElements", totalElements); + map.put("content", CollectionUtils.isEmpty(trees) ? categoryDTOS : trees); + return map; + } + + + /** + * 检测分类是否操过二级 + * @param pid 父级id + * @return boolean + */ + @Override + public boolean checkCategory(int pid){ + if(pid == 0) { + return true; + } + YxStoreCategory yxStoreCategory = this.getOne(Wrappers.lambdaQuery() + .eq(YxStoreCategory::getId,pid)); + return yxStoreCategory.getPid() <= 0; + } + + /** + * 检测商品分类必选选择二级 + * @param id 分类id + * @return boolean + */ + @Override + public boolean checkProductCategory(int id){ + YxStoreCategory yxStoreCategory = this.getOne(Wrappers.lambdaQuery() + .eq(YxStoreCategory::getId,id)); + return yxStoreCategory.getPid() != 0; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/category/service/mapper/StoreCategoryMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/mapper/StoreCategoryMapper.java new file mode 100644 index 00000000..668d1925 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/category/service/mapper/StoreCategoryMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.category.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.category.domain.YxStoreCategory; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreCategoryMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/domain/YxStoreCustomer.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/domain/YxStoreCustomer.java new file mode 100644 index 00000000..aa8d83b9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/domain/YxStoreCustomer.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.domain; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.validation.constraints.*; +import java.util.Date; +import co.yixiang.domain.BaseDomain; + +/** +* @author Bug +* @date 2020-12-10 +*/ +@Data +@TableName("yx_store_customer") +public class YxStoreCustomer extends BaseDomain { + /** id */ + @TableId + private Long id; + + /** 用户昵称 */ + private String nickName; + + /** openId */ + @NotBlank(message = "请用户扫码后提交") + private String openId; + + /** 备注 */ + private String remark; + + + + + /** 是否启用 */ + private Integer isEnable; + + + public void copy(YxStoreCustomer source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java new file mode 100644 index 00000000..7b1110d1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java @@ -0,0 +1,116 @@ +package co.yixiang.modules.customer.rest; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.constant.ShopConstants; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.utils.RecodeUtil; + +import co.yixiang.utils.RedisUtils; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.Api; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.bean.WxOAuth2UserInfo; +import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; + +/** + * @author lioncity + * @date 2020-03-21 + */ +@Slf4j +@Api(tags = "微信") +@Controller +@RequestMapping("/api/wxmp") +@AllArgsConstructor +public class QrCodeController { + + private final RedisUtils redisUtils; + /** + * 生成微信图片二维码 + * + * @param request + * @param response + * @ + */ + @AnonymousAccess + @GetMapping("/qrcode") + public void qrcode(HttpServletRequest request, HttpServletResponse response, @RequestParam("key") String key) { + String adminApiUrl = redisUtils.getY(ShopConstants.ADMIN_API_URL); + if(StrUtil.isBlank(adminApiUrl)){ + throw new BadRequestException("请配置后台-->商城配置-->商城系统配置-->后台Api地址"); + } + final WxMpService wxService = WxMpConfiguration.getWxMpService(); + if (wxService == null) { + throw new IllegalArgumentException("未找到对应配置的服务,请核实!"); + } + String state = key; + String url = adminApiUrl + "/api/wxmp/userInfo"; + String redirectURL = wxService.getOAuth2Service().buildAuthorizationUrl(url, WxConsts.OAuth2Scope.SNSAPI_USERINFO, URLEncoder.encode(state)); + log.info("【微信网页授权】获取code,redirectURL={}", redirectURL); + //调用工具类,生成二维码 + //180为图片高度和宽度 + RecodeUtil.creatRrCode(redirectURL, 180, 180, response); + } + + @AnonymousAccess + @GetMapping("/wechatCode") + public ResponseEntity wechatCode() { + String wechatFollowImg = redisUtils.getY(ShopConstants.WECHAT_FOLLOW_IMG); + if(StrUtil.isBlank(wechatFollowImg)){ + throw new BadRequestException("请配置后台-->微信管理-->公众号配置->关注二维码"); + } + return ResponseEntity.ok(wechatFollowImg); + } + + @AnonymousAccess + @ResponseBody + @GetMapping("/userInfo") + public void userInfo(HttpServletRequest request, @RequestParam("code") String code, + @RequestParam("state") String key) throws Exception { + log.info("【微信网页授权】code={}", code); + log.info("【微信网页授权】state={}", key); + final WxMpService wxService = WxMpConfiguration.getWxMpService(); + if (wxService == null) { + throw new IllegalArgumentException("未找到对应配置的服务,请核实!"); + } + try { + WxOAuth2AccessToken wxOAuth2AccessToken = wxService.getOAuth2Service().getAccessToken(code); + WxOAuth2UserInfo wxOAuth2UserInfo = wxService.getOAuth2Service().getUserInfo(wxOAuth2AccessToken, "zh_CN"); + redisUtils.set("qrCode:" + key, wxOAuth2UserInfo.getOpenid() + ":" + wxOAuth2UserInfo.getNickname()); + log.info("【微信网页授权】wxMpUser={}", wxOAuth2UserInfo); + } catch (WxErrorException e) { + log.info("【微信网页授权】{}", e); + throw new Exception(e.getError().getErrorMsg()); + } + } + + @ResponseBody + @GetMapping("/getOpenId") + public ResponseEntity userInfo(HttpServletRequest request, @RequestParam("key") String key) { + String openId = redisUtils.get("qrCode:" + key).toString(); + if (openId != null) { + String[] str = openId.split(":"); + JSONObject json = new JSONObject(); + json.put("openId", str[0]); + json.put("nickName", str[1]); + return new ResponseEntity(json, HttpStatus.OK); + } + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/YxStoreCustomerController.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/YxStoreCustomerController.java new file mode 100644 index 00000000..dae6f939 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/YxStoreCustomerController.java @@ -0,0 +1,95 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.rest; +import java.util.Arrays; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.aop.ForbidSubmit; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.AllArgsConstructor; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.customer.domain.YxStoreCustomer; +import co.yixiang.modules.customer.service.YxStoreCustomerService; +import co.yixiang.modules.customer.service.dto.YxStoreCustomerQueryCriteria; +import co.yixiang.modules.customer.service.dto.YxStoreCustomerDto; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** +* @author Bug +* @date 2020-12-10 +*/ +@AllArgsConstructor +@Api(tags = "customer管理") +@RestController +@RequestMapping("/api/yxStoreCustomer") +public class YxStoreCustomerController { + + private final YxStoreCustomerService yxStoreCustomerService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreCustomer:list')") + public void download(HttpServletResponse response, YxStoreCustomerQueryCriteria criteria) throws IOException { + yxStoreCustomerService.download(generator.convert(yxStoreCustomerService.queryAll(criteria), YxStoreCustomerDto.class), response); + } + + @GetMapping + @Log("查询customer") + @ApiOperation("查询customer") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreCustomer:list')") + public ResponseEntity> getYxStoreCustomers(YxStoreCustomerQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreCustomerService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @PostMapping + @Log("新增customer") + @ApiOperation("新增customer") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreCustomer:add')") + public ResponseEntity create(@Validated @RequestBody YxStoreCustomer resources){ + Long count = yxStoreCustomerService.count(new LambdaQueryWrapper().eq(YxStoreCustomer::getOpenId, resources.getOpenId())); + if (count > 0) { + throw new BadRequestException("当前用户已存在,请勿重复提交"); + } + return new ResponseEntity<>(yxStoreCustomerService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @PutMapping + @Log("修改customer") + @ApiOperation("修改customer") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreCustomer:edit')") + public ResponseEntity update(@Validated @RequestBody YxStoreCustomer resources){ + yxStoreCustomerService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除customer") + @ApiOperation("删除customer") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreCustomer:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + yxStoreCustomerService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/YxStoreCustomerService.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/YxStoreCustomerService.java new file mode 100644 index 00000000..1f3110c3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/YxStoreCustomerService.java @@ -0,0 +1,48 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.service; +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.customer.domain.YxStoreCustomer; +import co.yixiang.modules.customer.service.dto.YxStoreCustomerDto; +import co.yixiang.modules.customer.service.dto.YxStoreCustomerQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** +* @author Bug +* @date 2020-12-10 +*/ +public interface YxStoreCustomerService extends BaseService{ + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxStoreCustomerQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreCustomerQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/dto/YxStoreCustomerDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/dto/YxStoreCustomerDto.java new file mode 100644 index 00000000..82fb9da6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/dto/YxStoreCustomerDto.java @@ -0,0 +1,44 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.service.dto; + +import lombok.Data; +import java.util.Date; +import java.io.Serializable; + +/** +* @author Bug +* @date 2020-12-10 +*/ +@Data +public class YxStoreCustomerDto implements Serializable { + + /** id */ + private Long id; + + /** 用户昵称 */ + private String nickName; + + /** openId */ + private String openId; + + /** 备注 */ + private String remark; + + /** 添加时间 */ + private Date createTime; + + /** 修改时间 */ + private Date updateTime; + + private Integer isDel; + + /** 是否启用 */ + private Integer isEnable; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/dto/YxStoreCustomerQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/dto/YxStoreCustomerQueryCriteria.java new file mode 100644 index 00000000..ab692a49 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/dto/YxStoreCustomerQueryCriteria.java @@ -0,0 +1,21 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.service.dto; + +import lombok.Data; +import java.util.List; +import co.yixiang.annotation.Query; + +/** +* @author Bug +* @date 2020-12-10 +*/ +@Data +public class YxStoreCustomerQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/impl/YxStoreCustomerServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/impl/YxStoreCustomerServiceImpl.java new file mode 100644 index 00000000..1b2b9b65 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/impl/YxStoreCustomerServiceImpl.java @@ -0,0 +1,84 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.service.impl; + +import co.yixiang.modules.customer.domain.YxStoreCustomer; +import co.yixiang.common.service.impl.BaseServiceImpl; +import lombok.AllArgsConstructor; +import co.yixiang.dozer.service.IGenerator; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.utils.ValidationUtil; +import co.yixiang.utils.FileUtil; +import co.yixiang.modules.customer.service.YxStoreCustomerService; +import co.yixiang.modules.customer.service.dto.YxStoreCustomerDto; +import co.yixiang.modules.customer.service.dto.YxStoreCustomerQueryCriteria; +import co.yixiang.modules.customer.service.mapper.YxStoreCustomerMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import co.yixiang.domain.PageResult; +/** +* @author Bug +* @date 2020-12-10 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxStoreCustomer") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreCustomerServiceImpl extends BaseServiceImpl implements YxStoreCustomerService { + + private final IGenerator generator; + + @Override + //@Cacheable + public PageResult queryAll(YxStoreCustomerQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + return generator.convertPageInfo(page,YxStoreCustomerDto.class); + } + + + @Override + //@Cacheable + public List queryAll(YxStoreCustomerQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreCustomer.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreCustomerDto yxStoreCustomer : all) { + Map map = new LinkedHashMap<>(); + map.put("用户昵称", yxStoreCustomer.getNickName()); + map.put("openId", yxStoreCustomer.getOpenId()); + map.put("备注", yxStoreCustomer.getRemark()); + map.put("添加时间", yxStoreCustomer.getCreateTime()); + map.put("修改时间", yxStoreCustomer.getUpdateTime()); + map.put(" isDel", yxStoreCustomer.getIsDel()); + map.put("是否启用", yxStoreCustomer.getIsEnable()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/mapper/YxStoreCustomerMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/mapper/YxStoreCustomerMapper.java new file mode 100644 index 00000000..ca96028d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/service/mapper/YxStoreCustomerMapper.java @@ -0,0 +1,23 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.customer.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.customer.domain.YxStoreCustomer; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author Bug +* @date 2020-12-10 +*/ +@Repository +public interface YxStoreCustomerMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/vo/YzCustomerVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/vo/YzCustomerVo.java new file mode 100644 index 00000000..6a254bfc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/vo/YzCustomerVo.java @@ -0,0 +1,43 @@ +package co.yixiang.modules.customer.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 订单通知用户表 接收订单通知的用户 查询结果对象 + *

+ * + * @author LionCity + * @date 2020-04-02 + */ +@Data +@ApiModel(description = "订单通知用户表") +public class YzCustomerVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "用户昵称") + private String nickName; + + @ApiModelProperty(value = "openId") + private String openId; + + @ApiModelProperty(value = "备注") + private String remark; + + + @ApiModelProperty(value = "创建时间 创建时间") + private Date createTime; + + @ApiModelProperty(value = "更新时间 最后更新时间") + private Date updateTime; + +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/config/VisitsInitialization.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/config/VisitsInitialization.java new file mode 100644 index 00000000..9abe0e0f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/config/VisitsInitialization.java @@ -0,0 +1,26 @@ +package co.yixiang.modules.monitor.config; + +import co.yixiang.modules.monitor.service.VisitsService; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; + +/** + * 初始化站点统计 + * @author Zheng Jie + */ +//@Component +public class VisitsInitialization implements ApplicationRunner { + + private final VisitsService visitsService; + + public VisitsInitialization(VisitsService visitsService) { + this.visitsService = visitsService; + } + + @Override + public void run(ApplicationArguments args){ + System.out.println("--------------- 初始化站点统计,如果存在今日统计则跳过 ---------------"); + visitsService.save(); + System.out.println("--------------- 初始化站点统计完成 ---------------"); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/domain/Visits.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/domain/Visits.java new file mode 100644 index 00000000..f1f6d567 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/domain/Visits.java @@ -0,0 +1,35 @@ +package co.yixiang.modules.monitor.domain; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * pv 与 ip 统计 + * + * @author Zheng Jie + * @date 2018-12-13 + */ +@Data +@TableName( "yx_visits") +public class Visits implements Serializable { + + @TableId + private Long id; + + private String date; + + private Long pvCounts; + + private Long ipCounts; + + @TableField(fill = FieldFill.INSERT) + private Timestamp createTime; + + private String weekDay; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/domain/vo/RedisVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/domain/vo/RedisVo.java new file mode 100644 index 00000000..02cd0caf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/domain/vo/RedisVo.java @@ -0,0 +1,24 @@ +package co.yixiang.modules.monitor.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author Zheng Jie + * @date 2018-12-10 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class RedisVo implements Serializable { + + @NotBlank + private String key; + + @NotBlank + private String value; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/rest/BxgRedisController.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/rest/BxgRedisController.java new file mode 100644 index 00000000..14ef0838 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/rest/BxgRedisController.java @@ -0,0 +1,55 @@ +package co.yixiang.modules.monitor.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.monitor.domain.vo.RedisVo; +import co.yixiang.modules.monitor.service.RedisService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Zheng Jie + * @date 2018-12-10 + */ +@Api(tags = "redis缓存管理") +@RestController +@RequestMapping("api") +public class BxgRedisController { + + @Autowired + private RedisService redisService; + + @Log("查询Redis缓存") + @GetMapping(value = "/redis") + @PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_SELECT')") + public ResponseEntity getRedis(String key, Pageable pageable){ + return new ResponseEntity(redisService.findByKey(key,pageable), HttpStatus.OK); + } + + @ForbidSubmit + @Log("删除Redis缓存") + @DeleteMapping(value = "/redis") + @PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')") + public ResponseEntity delete(@RequestBody RedisVo resources){ + redisService.delete(resources.getKey()); + return new ResponseEntity(HttpStatus.OK); + } + + @ForbidSubmit + @Log("清空Redis缓存") + @DeleteMapping(value = "/redis/all") + @PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')") + public ResponseEntity deleteAll(){ + redisService.flushdb(); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/rest/VisitsController.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/rest/VisitsController.java new file mode 100644 index 00000000..6ce3a612 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/rest/VisitsController.java @@ -0,0 +1,47 @@ +package co.yixiang.modules.monitor.rest; + +import co.yixiang.modules.monitor.service.VisitsService; +import co.yixiang.utils.RequestHolder; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Zheng Jie + * @date 2018-12-13 + */ +@RestController +@RequestMapping("/api/visits") +@Api(tags = "系统:访问记录管理") +public class VisitsController { + + private final VisitsService visitsService; + + public VisitsController(VisitsService visitsService) { + this.visitsService = visitsService; + } + + @PostMapping + @ApiOperation("创建访问记录") + public ResponseEntity create(){ + visitsService.count(RequestHolder.getHttpServletRequest()); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @GetMapping + @ApiOperation("查询") + public ResponseEntity get(){ + return new ResponseEntity<>(visitsService.get(),HttpStatus.OK); + } + + @GetMapping(value = "/chartData") + @ApiOperation("查询图表数据") + public ResponseEntity getChartData(){ + return new ResponseEntity<>(visitsService.getChartData(),HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/RedisService.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/RedisService.java new file mode 100644 index 00000000..0838343f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/RedisService.java @@ -0,0 +1,44 @@ +package co.yixiang.modules.monitor.service; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * 可自行扩展 + * @author Zheng Jie + * @date 2018-12-10 + */ +public interface RedisService { + + /** + * findById + * @param key + * @return + */ + Page findByKey(String key, Pageable pageable); + + /** + * 查询验证码的值 + * @param key + * @return + */ + String getCodeVal(String key); + + /** + * 保存验证码 + * @param key + * @param val + */ + void saveCode(String key, Object val); + + /** + * delete + * @param key + */ + void delete(String key); + + /** + * 清空所有缓存 + */ + void flushdb(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/VisitsService.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/VisitsService.java new file mode 100644 index 00000000..74ebb415 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/VisitsService.java @@ -0,0 +1,38 @@ +package co.yixiang.modules.monitor.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.monitor.domain.Visits; +import org.springframework.scheduling.annotation.Async; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author Zheng Jie + * @date 2018-12-13 + */ +public interface VisitsService extends BaseService { + + /** + * 提供给定时任务,每天0点执行 + */ + void save(); + + /** + * 新增记录 + * @param request / + */ + @Async + void count(HttpServletRequest request); + + /** + * 获取数据 + * @return / + */ + Object get(); + + /** + * getChartData + * @return / + */ + Object getChartData(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java new file mode 100644 index 00000000..632fd967 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java @@ -0,0 +1,86 @@ +package co.yixiang.modules.monitor.service.impl; + +import co.yixiang.modules.monitor.domain.vo.RedisVo; +import co.yixiang.modules.monitor.service.RedisService; +import co.yixiang.utils.PageUtil; +import co.yixiang.utils.ShopKeyUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.data.redis.connection.DataType; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author Zheng Jie + * @date 2018-12-10 + */ +@Service +public class RedisServiceImpl implements RedisService { + + @Autowired + RedisTemplate redisTemplate; + + private Long expiration = 5L; + + @Override + public Page findByKey(String key, Pageable pageable){ + List redisVos = new ArrayList<>(); + if(!"*".equals(key)){ + key = "*" + key + "*"; + } + for (Object s : redisTemplate.keys(key)) { + // 过滤掉权限的缓存 + if (s.toString().indexOf("role::loadPermissionByUser") != -1 + || s.toString().indexOf("user::loadUserByUsername") != -1 + || s.toString().indexOf("wechat") != -1 + || s.toString().indexOf("wxpay") != -1 + || s.toString().indexOf(ShopKeyUtils.getSiteUrl()) != -1) { + continue; + } + DataType dataType = redisTemplate.type(s.toString()); + if(!"string".equals(dataType.code())) { + continue; + } + RedisVo redisVo = new RedisVo(s.toString(),redisTemplate.opsForValue().get(s.toString()).toString()); + redisVos.add(redisVo); + } + Page page = new PageImpl( + PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(),redisVos), + pageable, + redisVos.size()); + return page; + } + + @Override + public void delete(String key) { + redisTemplate.delete(key); + } + + @Override + public void flushdb() { + redisTemplate.getConnectionFactory().getConnection().flushDb(); + } + + @Override + public String getCodeVal(String key) { + try { + String value = redisTemplate.opsForValue().get(key).toString(); + return value; + }catch (Exception e){ + return ""; + } + } + + @Override + public void saveCode(String key, Object val) { + redisTemplate.opsForValue().set(key,val); + redisTemplate.expire(key,expiration, TimeUnit.MINUTES); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/VisitsServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/VisitsServiceImpl.java new file mode 100644 index 00000000..4d076dfd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/VisitsServiceImpl.java @@ -0,0 +1,102 @@ +package co.yixiang.modules.monitor.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.logging.service.mapper.LogMapper; +import co.yixiang.modules.monitor.domain.Visits; +import co.yixiang.modules.monitor.service.VisitsService; +import co.yixiang.modules.monitor.service.mapper.VisitsMapper; +import co.yixiang.utils.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletRequest; +import java.time.LocalDate; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author hupeng + * @date 2018-12-13 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class VisitsServiceImpl extends BaseServiceImpl implements VisitsService { + + + private final LogMapper logMapper; + + private final VisitsMapper visitsMapper; + + public VisitsServiceImpl(LogMapper logMapper, VisitsMapper visitsMapper) { + this.logMapper = logMapper; + this.visitsMapper = visitsMapper; + } + + + @Override + public void save() { + LocalDate localDate = LocalDate.now(); + Visits visits = this.getOne(new LambdaQueryWrapper() + .eq(Visits::getDate,localDate.toString())); + if(visits == null){ + visits = new Visits(); + visits.setWeekDay(StringUtils.getWeekDay()); + visits.setPvCounts(1L); + visits.setIpCounts(1L); + visits.setDate(localDate.toString()); + this.save(visits); + } + } + + @Override + public void count(HttpServletRequest request) { + LocalDate localDate = LocalDate.now(); + Visits visits = this.getOne(new LambdaQueryWrapper() + .eq(Visits::getDate,localDate.toString())); + if (visits == null) { + visits = new Visits(); + visits.setPvCounts(1L); + } else { + visits.setPvCounts(visits.getPvCounts()+1); + } + long ipCounts = logMapper.findIp(localDate.toString(), localDate.plusDays(1).toString()); + visits.setIpCounts(ipCounts); + this.saveOrUpdate(visits); + } + + @Override + public Object get() { + Map map = new HashMap<>(4); + LocalDate localDate = LocalDate.now(); + Visits visits = this.getOne(new LambdaQueryWrapper() + .eq(Visits::getDate,localDate.toString())); + List list = visitsMapper.findAllVisits(localDate.minusDays(6).toString(),localDate.plusDays(1).toString()); + + long recentVisits = 0, recentIp = 0; + for (Visits data : list) { + recentVisits += data.getPvCounts(); + recentIp += data.getIpCounts(); + } + map.put("newVisits",visits.getPvCounts()); + map.put("newIp",visits.getIpCounts()); + map.put("recentVisits",recentVisits); + map.put("recentIp",recentIp); + return map; + } + + @Override + public Object getChartData() { + Map map = new HashMap<>(3); +// LocalDate localDate = LocalDate.now(); +// List list = visitsRepository.findAllVisits(localDate.minusDays(6).toString(),localDate.plusDays(1).toString()); +// map.put("weekDays",list.stream().map(Visits::getWeekDay).collect(Collectors.toList())); +// map.put("visitsData",list.stream().map(Visits::getPvCounts).collect(Collectors.toList())); +// map.put("ipData",list.stream().map(Visits::getIpCounts).collect(Collectors.toList())); + return map; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/mapper/VisitsMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/mapper/VisitsMapper.java new file mode 100644 index 00000000..6a0b5b37 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/mapper/VisitsMapper.java @@ -0,0 +1,15 @@ +package co.yixiang.modules.monitor.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.monitor.domain.Visits; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface VisitsMapper extends CoreMapper { + @Select("select * FROM visits where create_time between #{time1} and #{time2}") + List findAllVisits(@Param("time1") String time1, @Param("time2")String time2); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/AbstractBuilder.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/AbstractBuilder.java new file mode 100644 index 00000000..e99bf7ee --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/AbstractBuilder.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.builder; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public abstract class AbstractBuilder { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + public abstract WxMpXmlOutMessage build(String content, + WxMpXmlMessage wxMessage, WxMpService service); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/ImageBuilder.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/ImageBuilder.java new file mode 100644 index 00000000..d129b3fa --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/ImageBuilder.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.builder; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public class ImageBuilder extends AbstractBuilder { + + @Override + public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, + WxMpService service) { + + WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) + .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) + .build(); + + return m; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/TextBuilder.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/TextBuilder.java new file mode 100644 index 00000000..0391be76 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/builder/TextBuilder.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.builder; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public class TextBuilder extends AbstractBuilder { + + @Override + public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, + WxMpService service) { + WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) + .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) + .build(); + return m; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java new file mode 100644 index 00000000..053a0092 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java @@ -0,0 +1,78 @@ +package co.yixiang.modules.mp.config; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +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.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import com.google.common.collect.Maps; +import me.chanjar.weixin.common.api.WxConsts; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +/** + * @author Binary Wang + */ +@Configuration(proxyBeanMethods = false) +public class WxMaConfiguration { + private static Map maServices = Maps.newHashMap(); + private static Map routers = Maps.newHashMap(); + private static RedisUtils redisUtils; + private static WxMaMessageHandler wxMaMessageHandler; + + public static WxMaMessageRouter getRouter(String appid) { + return routers.get(appid); + } + @Autowired + public WxMaConfiguration(RedisUtils redisUtils) { + WxMaConfiguration.redisUtils = redisUtils; + } + + public static WxMaService getWxMaService() { + WxMaService wxMaService = maServices.get(ShopKeyUtils.getYshopWeiXinMaSevice()); + //增加一个redis标识 + if(wxMaService == null || redisUtils.get(ShopKeyUtils.getYshopWeiXinMaSevice()) == null){ + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setMsgDataFormat("JSON"); + config.setAppid(redisUtils.get(ShopKeyUtils.getWxAppAppId()).toString()); + config.setSecret(redisUtils.get(ShopKeyUtils.getWxAppSecret()).toString()); + config.setToken(redisUtils.get(ShopKeyUtils.getWechatMaToken()).toString()); + config.setAesKey(redisUtils.get(ShopKeyUtils.getWechatMaEncodingAESKey()).toString()); + wxMaService = new WxMaServiceImpl(); + wxMaService.setWxMaConfig(config); + maServices.put(ShopKeyUtils.getYshopWeiXinMaSevice(), wxMaService); + routers.put(ShopKeyUtils.getYshopWeiXinMaSevice(), newRouter(wxMaService)); + //增加标识 + redisUtils.set(ShopKeyUtils.getYshopWeiXinMaSevice(),"yshop"); + + } + return wxMaService; + } + /** + * 移除WxMpService + */ + public static void removeWxMaService(){ + redisUtils.del(ShopKeyUtils.getYshopWeiXinMaSevice()); + maServices.remove(ShopKeyUtils.getYshopWeiXinMaSevice()); + routers.remove(ShopKeyUtils.getYshopWeiXinMaSevice()); + } + private static WxMaMessageRouter newRouter(WxMaService service) { + final WxMaMessageRouter router = new WxMaMessageRouter(service); + router + .rule().handler(wxMaMessageHandler).next() + .rule().async(false).msgType(WxConsts.XmlMsgType.EVENT).event(SystemConfigConstants.BINDSTATECHANGE).handler(BINDSTATECHANGE_HANDLER).end(); + return router; + } + private static final WxMaMessageHandler BINDSTATECHANGE_HANDLER = (wxMessage, context, service, sessionManager) -> { + wxMessage.getFromUser(); + wxMessage.getContent(); + return null; + }; +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMpConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMpConfiguration.java new file mode 100644 index 00000000..739b94e3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMpConfiguration.java @@ -0,0 +1,178 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.config; + +import co.yixiang.modules.mp.handler.KfSessionHandler; +import co.yixiang.modules.mp.handler.LocationHandler; +import co.yixiang.modules.mp.handler.LogHandler; +import co.yixiang.modules.mp.handler.MenuHandler; +import co.yixiang.modules.mp.handler.MsgHandler; +import co.yixiang.modules.mp.handler.NullHandler; +import co.yixiang.modules.mp.handler.ScanHandler; +import co.yixiang.modules.mp.handler.StoreCheckNotifyHandler; +import co.yixiang.modules.mp.handler.SubscribeHandler; +import co.yixiang.modules.mp.handler.UnsubscribeHandler; + +import co.yixiang.utils.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import com.google.common.collect.Maps; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.mp.api.WxMpMessageRouter; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; +import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; +import me.chanjar.weixin.mp.constant.WxMpEventConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +import static me.chanjar.weixin.common.api.WxConsts.EventType; +import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType; + +/** + * 公众号配置 + * @author hupeng + * @date 2020/01/20 + */ +@Configuration(proxyBeanMethods = false) +public class WxMpConfiguration { + + private static Map mpServices = Maps.newHashMap(); + private static Map routers = Maps.newHashMap(); + + private static LogHandler logHandler; + private static NullHandler nullHandler; + private static KfSessionHandler kfSessionHandler; + private static StoreCheckNotifyHandler storeCheckNotifyHandler; + private static LocationHandler locationHandler; + private static MenuHandler menuHandler; + private static MsgHandler msgHandler; + private static UnsubscribeHandler unsubscribeHandler; + private static SubscribeHandler subscribeHandler; + private static ScanHandler scanHandler; + private static RedisUtils redisUtils; + + @Autowired + public WxMpConfiguration(LogHandler logHandler,NullHandler nullHandler,KfSessionHandler kfSessionHandler, + StoreCheckNotifyHandler storeCheckNotifyHandler,LocationHandler locationHandler, + MenuHandler menuHandler,MsgHandler msgHandler,UnsubscribeHandler unsubscribeHandler, + SubscribeHandler subscribeHandler,ScanHandler scanHandler, + RedisUtils redisUtils){ + WxMpConfiguration.logHandler = logHandler; + WxMpConfiguration.nullHandler = nullHandler; + WxMpConfiguration.kfSessionHandler = kfSessionHandler; + WxMpConfiguration.storeCheckNotifyHandler = storeCheckNotifyHandler; + WxMpConfiguration.locationHandler = locationHandler; + WxMpConfiguration.menuHandler = menuHandler; + WxMpConfiguration.msgHandler = msgHandler; + WxMpConfiguration.unsubscribeHandler = unsubscribeHandler; + WxMpConfiguration.subscribeHandler = subscribeHandler; + WxMpConfiguration.scanHandler = scanHandler; + WxMpConfiguration.redisUtils = redisUtils; + } + + + /** + * 获取WxMpService + * @return + */ + public static WxMpService getWxMpService() { + + WxMpService wxMpService = mpServices.get(ShopKeyUtils.getYshopWeiXinMpSevice()); + //增加一个redis标识 + if(wxMpService == null || redisUtils.get(ShopKeyUtils.getYshopWeiXinMpSevice()) == null) { + WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl(); + configStorage.setAppId(redisUtils.get(ShopKeyUtils.getWechatAppId()).toString()); + configStorage.setSecret(redisUtils.get(ShopKeyUtils.getWechatAppSecret()).toString()); + configStorage.setToken(redisUtils.get(ShopKeyUtils.getWechatToken()).toString()); + configStorage.setAesKey(redisUtils.get(ShopKeyUtils.getWechatEncodingAESKey()).toString()); + wxMpService = new WxMpServiceImpl(); + wxMpService.setWxMpConfigStorage(configStorage); + mpServices.put(ShopKeyUtils.getYshopWeiXinMpSevice(), wxMpService); + routers.put(ShopKeyUtils.getYshopWeiXinMpSevice(), newRouter(wxMpService)); + + //增加标识 + redisUtils.set(ShopKeyUtils.getYshopWeiXinMpSevice(),"yshop"); + } + return wxMpService; + } + + /** + * 移除WxMpService + */ + public static void removeWxMpService(){ + redisUtils.del(ShopKeyUtils.getYshopWeiXinMpSevice()); + mpServices.remove(ShopKeyUtils.getYshopWeiXinMpSevice()); + routers.remove(ShopKeyUtils.getYshopWeiXinMpSevice()); + } + + /** + * 获取WxMpMessageRouter + */ + public static WxMpMessageRouter getWxMpMessageRouter() { + WxMpMessageRouter wxMpMessageRouter = routers.get(ShopKeyUtils.getYshopWeiXinMpSevice()); + return wxMpMessageRouter; + } + + private static WxMpMessageRouter newRouter(WxMpService wxMpService) { + final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService); + + // 记录所有事件的日志 (异步执行) + newRouter.rule().handler(logHandler).next(); + + // 接收客服会话管理事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(WxMpEventConstants.CustomerService.KF_CREATE_SESSION) + .handler(kfSessionHandler).end(); + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(WxMpEventConstants.CustomerService.KF_CLOSE_SESSION) + .handler(kfSessionHandler) + .end(); + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(WxMpEventConstants.CustomerService.KF_SWITCH_SESSION) + .handler(kfSessionHandler).end(); + + // 门店审核事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(WxMpEventConstants.POI_CHECK_NOTIFY) + .handler(storeCheckNotifyHandler).end(); + + // 自定义菜单事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(WxConsts.MenuButtonType.CLICK).handler(menuHandler).end(); + + // 点击菜单连接事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(WxConsts.MenuButtonType.VIEW).handler(menuHandler).end(); + + // 扫码事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(EventType.SCANCODE_WAITMSG).handler(menuHandler).end(); + + // 关注事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(EventType.SUBSCRIBE).handler(subscribeHandler) + .end(); + + // 取消关注事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(EventType.UNSUBSCRIBE) + .handler(unsubscribeHandler).end(); + + // 上报地理位置事件 + newRouter.rule().async(false).msgType(XmlMsgType.EVENT) + .event(EventType.LOCATION).handler(locationHandler) + .end(); + + + // 默认 + newRouter.rule().async(false).handler(msgHandler).end(); + + return newRouter; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java new file mode 100644 index 00000000..4e86e438 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java @@ -0,0 +1,133 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.config; + +import co.yixiang.enums.PayMethodEnum; + +import co.yixiang.utils.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import com.github.binarywang.wxpay.config.WxPayConfig; +import com.github.binarywang.wxpay.service.WxPayService; +import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; +import com.google.common.collect.Maps; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +/** + * 支付配置 + * @author hupeng + * @date 2020/03/01 + */ +@Slf4j +@Configuration(proxyBeanMethods = false) +public class WxPayConfiguration { + + private static Map payServices = Maps.newHashMap(); + + private static RedisUtils redisUtils; + + @Autowired + public WxPayConfiguration(RedisUtils redisUtils) { + WxPayConfiguration.redisUtils = redisUtils; + } + + /** + * 获取WxPayService + * @return + */ + public static WxPayService getPayService(PayMethodEnum payMethodEnum) { + WxPayService wxPayService = payServices.get(ShopKeyUtils.getYshopWeiXinPayService()+payMethodEnum.getValue()); + if(wxPayService == null || redisUtils.get(ShopKeyUtils.getYshopWeiXinPayService()) == null) { + WxPayConfig payConfig = new WxPayConfig(); + switch (payMethodEnum){ + case WECHAT: + payConfig.setAppId(redisUtils.getY(ShopKeyUtils.getWechatAppId())); + break; + case WXAPP: + payConfig.setAppId(redisUtils.get(ShopKeyUtils.getWxAppAppId()).toString()); + break; + case APP: + payConfig.setAppId(redisUtils.get(ShopKeyUtils.getWxNativeAppAppId()).toString()); + break; + default: + } + payConfig.setMchId(redisUtils.getY(ShopKeyUtils.getWxPayMchId())); + payConfig.setMchKey(redisUtils.getY(ShopKeyUtils.getWxPayMchKey())); + payConfig.setKeyPath(redisUtils.getY(ShopKeyUtils.getWxPayKeyPath())); + // 可以指定是否使用沙箱环境 + payConfig.setUseSandboxEnv(false); + wxPayService = new WxPayServiceImpl(); + wxPayService.setConfig(payConfig); + payServices.put(ShopKeyUtils.getYshopWeiXinPayService()+payMethodEnum.getValue(), wxPayService); + + //增加标识 + redisUtils.set(ShopKeyUtils.getYshopWeiXinPayService(),"yshop"); + } + return wxPayService; + } + +// /** +// * 获取小程序WxAppPayService +// * @return +// */ +// public static WxPayService getWxAppPayService() { +// WxPayService wxPayService = payServices.get(ShopKeyUtils.getYshopWeiXinMiniPayService()); +// if(wxPayService == null || RedisUtil.get(ShopKeyUtils.getYshopWeiXinPayService()) == null) { +// WxPayConfig payConfig = new WxPayConfig(); +// payConfig.setAppId(RedisUtil.get(ShopKeyUtils.getWxAppAppId())); +// payConfig.setMchId(RedisUtil.get(ShopKeyUtils.getWxPayMchId())); +// payConfig.setMchKey(RedisUtil.get(ShopKeyUtils.getWxPayMchKey())); +// payConfig.setKeyPath(RedisUtil.get(ShopKeyUtils.getWxPayKeyPath())); +// // 可以指定是否使用沙箱环境 +// payConfig.setUseSandboxEnv(false); +// wxPayService = new WxPayServiceImpl(); +// wxPayService.setConfig(payConfig); +// payServices.put(ShopKeyUtils.getYshopWeiXinMiniPayService(), wxPayService); +// +// //增加标识 +// RedisUtil.set(ShopKeyUtils.getYshopWeiXinPayService(),"yshop"); +// } +// return wxPayService; +// } + +// /** +// * 获取APPPayService +// * @return +// */ +// public static WxPayService getAppPayService() { +// WxPayService wxPayService = payServices.get(ShopKeyUtils.getYshopWeiXinAppPayService()); +// if(wxPayService == null || RedisUtil.get(ShopKeyUtils.getYshopWeiXinPayService()) == null) { +// WxPayConfig payConfig = new WxPayConfig(); +// payConfig.setAppId(RedisUtil.get(ShopKeyUtils.getWxNativeAppAppId())); +// payConfig.setMchId(RedisUtil.get(ShopKeyUtils.getWxPayMchId())); +// payConfig.setMchKey(RedisUtil.get(ShopKeyUtils.getWxPayMchKey())); +// payConfig.setKeyPath(RedisUtil.get(ShopKeyUtils.getWxPayKeyPath())); +// // 可以指定是否使用沙箱环境 +// payConfig.setUseSandboxEnv(false); +// wxPayService = new WxPayServiceImpl(); +// wxPayService.setConfig(payConfig); +// payServices.put(ShopKeyUtils.getYshopWeiXinAppPayService(), wxPayService); +// +// //增加标识 +// RedisUtil.set(ShopKeyUtils.getYshopWeiXinPayService(),"yshop"); +// } +// return wxPayService; +// } + + /** + * 移除WxPayService + */ + public static void removeWxPayService(){ + redisUtils.del(ShopKeyUtils.getYshopWeiXinPayService()); + payServices.remove(ShopKeyUtils.getYshopWeiXinPayService()); + //payServices.remove(ShopKeyUtils.getYshopWeiXinMiniPayService()); + //payServices.remove(ShopKeyUtils.getYshopWeiXinAppPayService()); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxArticle.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxArticle.java new file mode 100644 index 00000000..afa1a5ca --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxArticle.java @@ -0,0 +1,112 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_article") +public class YxArticle extends BaseDomain { + + /** 文章管理ID */ + @TableId + private Integer id; + + + /** 分类id */ + private String cid; + + + /** 文章标题 */ + @NotBlank(message = "请输入文章标题") + private String title; + + + /** 文章作者 */ + @NotBlank(message = "请输入文章作者") + private String author; + + + /** 文章图片 */ + @NotBlank(message = "请上传文章图片") + private String imageInput; + + + /** 文章简介 */ + @NotBlank(message = "请填写文章简介") + private String synopsis; + + + @NotBlank(message = "请填写文章详情") + private String content; + + + /** 文章分享标题 */ + private String shareTitle; + + + /** 文章分享简介 */ + private String shareSynopsis; + + + /** 浏览次数 */ + private String visit; + + + /** 排序 */ + private Integer sort; + + + /** 原文链接 */ + private String url; + + + /** 状态 */ + private Integer status; + + + + /** 是否隐藏 */ + private Integer hide; + + + /** 管理员id */ + private Integer adminId; + + + /** 商户id */ + private Integer merId; + + + /** 产品关联id */ + private Integer productId; + + + /** 是否热门(小程序) */ + private Integer isHot; + + + /** 是否轮播图(小程序) */ + private Integer isBanner; + + + public void copy(YxArticle source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatLive.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatLive.java new file mode 100644 index 00000000..849eef14 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatLive.java @@ -0,0 +1,143 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@Data +@TableName("yx_wechat_live") +public class YxWechatLive implements Serializable { + + /** 直播间id */ + @TableId(type = IdType.INPUT) + private Long roomId; + + + /** 直播间标题 */ + @NotBlank + private String name; + + + /** 背景图 */ + @TableField(exist = false) + private String coverImg; + + + /** 分享图片 */ + @TableField(exist = false) + private String shareImg; + + /** 背景图 */ + @NotBlank + private String coverImge; + + + /** 分享图片 */ + @NotBlank + private String shareImge; + + /** 主播头像 */ + private String anchorImge; + + /** + * 101:直播中,102:未开始,103已结束,104禁播,105:暂停,106:异常,107:已过期 + */ + /** 直播间状态 */ + private Integer liveStatus; + + + /** 开始时间 */ + private Long startTime; + + + /** 预计结束时间 */ + private Long endTime; + + + /** 开始时间 */ + @NotNull + @TableField(exist = false) + private Date startDate; + + + /** 预计结束时间 */ + @NotNull + @TableField(exist = false) + private Date endDate; + /** 主播昵称 */ + @NotBlank + private String anchorName; + + + /** 主播微信号 */ + @NotBlank + private String anchorWechat; + + + /** 主播头像 */ + @TableField(exist = false) + private String anchorImg; + + + /** 直播间类型 1:推流 0:手机直播 */ + @NotNull + private Integer type; + + + /** 横屏、竖屏 【1:横屏,0:竖屏】 */ + @NotNull + private Integer screenType; + + + /** 是否关闭点赞 【0:开启,1:关闭】 */ + @NotNull + private Integer closeLike; + + + /** 是否关闭货架 【0:开启,1:关闭】 */ + @NotNull + private Integer closeGoods; + + /** 是否关闭评论 【0:开启,1:关闭】 */ + @NotNull + private Integer closeComment; + @NotNull + private Integer closeReplay ; // 是否关闭回放 1 关闭 + @NotNull + private Integer closeShare ; // 是否关闭分享 1 关闭 + @NotNull + private Integer closeKf ; // 是否关闭客服,1 关闭 + + private String productId; + + /** + * 购物直播封面图 ,建议尺寸800*800 + */ + @TableField(exist = false) + private String feedsImg; + + public void copy(YxWechatLive source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatLiveGoods.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatLiveGoods.java new file mode 100644 index 00000000..ec910f31 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatLiveGoods.java @@ -0,0 +1,85 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-08-11 +*/ +@Data +@TableName("yx_wechat_live_goods") +public class YxWechatLiveGoods implements Serializable { + + /** 直播商品id */ + @TableId(type = IdType.INPUT) + private Long goodsId; + + + /** 关联商品id */ + private Long productId; + + + /** 商品图片 */ + @TableField(exist = false) + private String coverImgUrl; + + + /** 商品图片 */ + @NotBlank + private String coverImgeUrl; + + /** 商品小程序路径 */ + @NotBlank + private String url; + + + /** 价格类型 1:一口价(只需要传入price,price2不传) 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传) 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传) */ + @NotBlank + private String priceType; + + + @NotBlank + private String price; + + + private String price2; + + + /** 商品名称 */ + @NotBlank + private String name; + + + /** 1, 2:表示是为api添加商品,否则是直播控制台添加的商品 */ + private String thirdPartyTag; + + + /** 审核单id */ + private Long auditId; + + + /** 审核状态 0:未审核,1:审核中,2:审核通过,3审核失败 */ + private Integer auditStatus; + + + public void copy(YxWechatLiveGoods source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatMenu.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatMenu.java new file mode 100644 index 00000000..21404e27 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatMenu.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +@TableName("yx_wechat_menu") +public class YxWechatMenu implements Serializable { + + @TableId(value = "`key`") + private String key; + + + /** 缓存数据 */ + private String result; + + + /** 缓存时间 */ + @TableField(fill= FieldFill.INSERT) + private Integer addTime; + + + public void copy(YxWechatMenu source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatReply.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatReply.java new file mode 100644 index 00000000..cf3719f9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatReply.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +@TableName("yx_wechat_reply") +public class YxWechatReply implements Serializable { + + /** 微信关键字回复id */ + @TableId + private Integer id; + + + /** 关键字 */ + @TableField(value = "`key`") + private String key; + + + /** 回复类型 */ + private String type; + + + /** 回复数据 */ + private String data; + + + /** 0=不可用 1 =可用 */ + private Integer status; + + + /** 是否隐藏 */ + private Integer hide; + + + public void copy(YxWechatReply source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatTemplate.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatTemplate.java new file mode 100644 index 00000000..70668c00 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/domain/YxWechatTemplate.java @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_wechat_template") +public class YxWechatTemplate extends BaseDomain { + + /** 模板id */ + @TableId + private Integer id; + + + /** 模板编号 */ + private String tempkey; + + + /** 模板名 */ + private String name; + + + /** 回复内容 */ + private String content; + + + /** 模板ID */ + private String tempid; + + + + /** 状态 */ + private Integer status; + + /** 类型:template:模板消息 subscribe:订阅消息 */ + private String type; + + public void copy(YxWechatTemplate source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java new file mode 100644 index 00000000..e478e632 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/enums/WechatTempateEnum.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.mp.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author hupeng + * 微信公众号模板枚举 + */ +@Getter +@AllArgsConstructor +public enum WechatTempateEnum { + PAY_SUCCESS("pay_success","支付成功通知"), + DELIVERY_SUCCESS("delivery_success","发货成功通知"), + REFUND_SUCCESS("refund_success","退款成功通知"), + RECHARGE_SUCCESS("recharge_success","充值成功通知"); + + private String value; //模板编号 + private String desc; //模板id +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/error/ErrorController.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/error/ErrorController.java new file mode 100644 index 00000000..df164151 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/error/ErrorController.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.error; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + *
+ * 出错页面控制器
+ * 
+ * + */ +@Controller +@RequestMapping("/error") +public class ErrorController { + + @GetMapping(value = "/404") + public String error404() { + return "error"; + } + + @GetMapping(value = "/500") + public String error500() { + return "error"; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/error/ErrorPageConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/error/ErrorPageConfiguration.java new file mode 100644 index 00000000..a505751e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/error/ErrorPageConfiguration.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.error; + +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.ErrorPageRegistrar; +import org.springframework.boot.web.server.ErrorPageRegistry; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; + +/** + *
+ * Created by Binary Wang on 2018/8/25.
+ *
+ */
+@Component
+public class ErrorPageConfiguration implements ErrorPageRegistrar {
+  @Override
+  public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
+    errorPageRegistry.addErrorPages(
+        new ErrorPage(HttpStatus.NOT_FOUND, "/error/404"),
+        new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500")
+    );
+  }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/AbstractHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/AbstractHandler.java
new file mode 100644
index 00000000..2da1f460
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/AbstractHandler.java
@@ -0,0 +1,15 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.mp.api.WxMpMessageHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class AbstractHandler implements WxMpMessageHandler {
+    protected Logger logger = LoggerFactory.getLogger(getClass());
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/KfSessionHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/KfSessionHandler.java
new file mode 100644
index 00000000..53324504
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/KfSessionHandler.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+
+@Component
+public class KfSessionHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService wxMpService,
+                                    WxSessionManager sessionManager) {
+        //TODO 对会话做处理
+        return null;
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/LocationHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/LocationHandler.java
new file mode 100644
index 00000000..a9e5f248
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/LocationHandler.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import co.yixiang.modules.mp.builder.TextBuilder;
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
+
+
+@Component
+public class LocationHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService wxMpService,
+                                    WxSessionManager sessionManager) {
+        if (wxMessage.getMsgType().equals(XmlMsgType.LOCATION)) {
+            //TODO 接收处理用户发送的地理位置消息
+            try {
+                String content = "感谢反馈,您的的地理位置已收到!";
+                return new TextBuilder().build(content, wxMessage, null);
+            } catch (Exception e) {
+                this.logger.error("位置消息接收处理失败", e);
+                return null;
+            }
+        }
+
+        //上报地理位置事件
+        this.logger.info("上报地理位置,纬度 : {},经度 : {},精度 : {}",
+            wxMessage.getLatitude(), wxMessage.getLongitude(), String.valueOf(wxMessage.getPrecision()));
+
+        //TODO  可以将用户地理位置信息保存到本地数据库,以便以后使用
+
+        return null;
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/LogHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/LogHandler.java
new file mode 100644
index 00000000..52da0072
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/LogHandler.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class LogHandler extends AbstractHandler {
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService wxMpService,
+                                    WxSessionManager sessionManager) {
+        //this.logger.info("\n接收到请求消息,内容:{}", JsonUtils.toJson(wxMessage));
+        return null;
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/MenuHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/MenuHandler.java
new file mode 100644
index 00000000..3bbe8479
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/MenuHandler.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType;
+
+
+@Component
+public class MenuHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService weixinService,
+                                    WxSessionManager sessionManager) {
+
+        String msg = String.format("type:%s, event:%s, key:%s",
+            wxMessage.getMsgType(), wxMessage.getEvent(),
+            wxMessage.getEventKey());
+        if (MenuButtonType.VIEW.equals(wxMessage.getEvent())) {
+            return null;
+        }
+
+        return WxMpXmlOutMessage.TEXT().content(msg)
+            .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
+            .build();
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/MsgHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/MsgHandler.java
new file mode 100644
index 00000000..328a18fa
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/MsgHandler.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import co.yixiang.modules.mp.builder.TextBuilder;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
+
+@Component
+public class MsgHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService weixinService,
+                                    WxSessionManager sessionManager) {
+
+        if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
+            //TODO 可以选择将消息保存到本地
+        }
+
+        //当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
+        try {
+            if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
+                && weixinService.getKefuService().kfOnlineList()
+                .getKfOnlineList().size() > 0) {
+                return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
+                    .fromUser(wxMessage.getToUser())
+                    .toUser(wxMessage.getFromUser()).build();
+            }
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+        }
+
+        //TODO 组装回复消息
+        String content = "yshop收到信息内容:" + wxMessage.getContent();
+
+        return new TextBuilder().build(content, wxMessage, weixinService);
+
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/NullHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/NullHandler.java
new file mode 100644
index 00000000..f2132fef
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/NullHandler.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class NullHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService wxMpService,
+                                    WxSessionManager sessionManager) {
+        return null;
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/RedisHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/RedisHandler.java
new file mode 100644
index 00000000..738840d6
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/RedisHandler.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class RedisHandler{
+
+    @Autowired
+    RedisTemplate redisTemplate;
+
+
+    public String getVal(String key) {
+        try {
+            String value = redisTemplate.opsForValue().get(key).toString();
+            return value;
+        }catch (Exception e){
+            return "";
+        }
+    }
+
+
+    public Object getObj(String key) {
+        return redisTemplate.opsForValue().get(key);
+    }
+
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/ScanHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/ScanHandler.java
new file mode 100644
index 00000000..d074c1e8
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/ScanHandler.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class ScanHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map map,
+                                    WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
+        // 扫码事件处理
+        return null;
+    }
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/StoreCheckNotifyHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/StoreCheckNotifyHandler.java
new file mode 100644
index 00000000..c7f1297f
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/StoreCheckNotifyHandler.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * 门店审核事件处理
+ *
+ */
+@Component
+public class StoreCheckNotifyHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService wxMpService,
+                                    WxSessionManager sessionManager) {
+        // TODO 处理门店审核事件
+        return null;
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/SubscribeHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/SubscribeHandler.java
new file mode 100644
index 00000000..37054209
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/SubscribeHandler.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import cn.hutool.core.util.ObjectUtil;
+import co.yixiang.modules.mp.domain.YxWechatReply;
+import co.yixiang.modules.mp.service.YxWechatReplyService;
+import com.alibaba.fastjson.JSONObject;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+
+@Component
+public class SubscribeHandler extends AbstractHandler {
+
+    @Autowired
+    private YxWechatReplyService yxWechatReplyService;
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService weixinService,
+                                    WxSessionManager sessionManager) throws WxErrorException {
+
+
+        String str = "你好,欢迎关注yshop!";
+        YxWechatReply wechatReply = yxWechatReplyService.isExist("subscribe");
+        if(!ObjectUtil.isNull(wechatReply)){
+            str = JSONObject.parseObject(wechatReply.getData()).getString("content");
+        }
+
+        try {
+            WxMpXmlOutMessage msg= WxMpXmlOutMessage.TEXT()
+                    .content(str)
+                    .fromUser(wxMessage.getToUser())
+                    .toUser(wxMessage.getFromUser())
+                    .build();
+            return msg;
+        } catch (Exception e) {
+            this.logger.error(e.getMessage(), e);
+        }
+
+
+
+        return null;
+    }
+
+
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/UnsubscribeHandler.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/UnsubscribeHandler.java
new file mode 100644
index 00000000..53c2c910
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/handler/UnsubscribeHandler.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+
+ */
+package co.yixiang.modules.mp.handler;
+
+import me.chanjar.weixin.common.session.WxSessionManager;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+
+@Component
+public class UnsubscribeHandler extends AbstractHandler {
+
+    @Override
+    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
+                                    Map context, WxMpService wxMpService,
+                                    WxSessionManager sessionManager) {
+        String openId = wxMessage.getFromUser();
+        this.logger.info("取消关注用户 OPENID: " + openId);
+        // TODO 可以更新本地数据库为取消关注状态
+        return null;
+    }
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java
new file mode 100644
index 00000000..1edc6570
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/listener/TemplateListener.java
@@ -0,0 +1,186 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+ * 注意:
+ * 本软件为www.yixiang.co开发研制,未经购买不得使用
+ * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
+ * 一经发现盗用、分享等行为,将追究法律责任,后果自负
+ */
+package co.yixiang.modules.mp.listener;
+
+
+import cn.hutool.core.util.NumberUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import co.yixiang.constant.ShopConstants;
+import co.yixiang.enums.BillDetailEnum;
+import co.yixiang.enums.PayTypeEnum;
+import co.yixiang.event.TemplateBean;
+import co.yixiang.event.TemplateEvent;
+import co.yixiang.event.TemplateListenEnum;
+import co.yixiang.modules.activity.domain.YxUserExtract;
+import co.yixiang.modules.activity.service.YxUserExtractService;
+import co.yixiang.modules.customer.domain.YxStoreCustomer;
+import co.yixiang.modules.customer.service.YxStoreCustomerService;
+import co.yixiang.modules.mp.service.WeiXinSubscribeService;
+import co.yixiang.modules.mp.service.WeixinPayService;
+import co.yixiang.modules.mp.service.WeixinTemplateService;
+import co.yixiang.modules.user.domain.YxUser;
+import co.yixiang.modules.user.service.YxUserBillService;
+import co.yixiang.modules.user.service.YxUserService;
+import co.yixiang.modules.user.service.dto.WechatUserDto;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.event.SmartApplicationListener;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author hupeng
+ * 异步监听模板通知事件
+ */
+@Slf4j
+@Component
+public class TemplateListener implements SmartApplicationListener {
+    @Autowired
+    private YxUserService userService;
+    @Autowired
+    private WeixinTemplateService weixinTemplateService;
+    @Autowired
+    private WeixinPayService weixinPayService;
+    @Autowired
+    private WeiXinSubscribeService weiXinSubscribeService;
+    @Autowired
+    private YxUserExtractService yxUserExtractService;
+    @Autowired
+    private WeixinPayService payService;
+    @Autowired
+    private YxUserBillService billService;
+    @Autowired
+    private YxStoreCustomerService yxStoreCustomerService;
+    //@Autowired
+    //private MqProducer mqProducer;
+
+    @Override
+    public boolean supportsEventType(Class aClass) {
+        return aClass == TemplateEvent.class;
+    }
+
+    @Async
+    @Override
+    public void onApplicationEvent(ApplicationEvent applicationEvent) {
+        //转换事件类型
+        TemplateEvent templateEvent = (TemplateEvent) applicationEvent;
+        //获取注册用户对象信息
+        TemplateBean templateBean = templateEvent.getTemplateBean();
+        log.info("模板事件类型:{}", templateBean.getTemplateType());
+        switch (TemplateListenEnum.toType(templateBean.getTemplateType())) {
+            case TYPE_1:
+                weixinTemplateService.paySuccessNotice(templateBean.getOrderId()
+                        , templateBean.getPrice(), templateBean.getUid());
+                weiXinSubscribeService.paySuccessNotice(templateBean.getOrderId()
+                        , templateBean.getPrice(), templateBean.getUid());
+                /**************给客服发送消息**************/
+                try {
+                    List yxStoreCustomers = yxStoreCustomerService.lambdaQuery().eq(YxStoreCustomer::getIsEnable, ShopConstants.YSHOP_ONE_NUM).list();
+                    yxStoreCustomers.forEach(msg -> {
+                        if (StrUtil.isNotBlank(msg.getOpenId())) {
+                         weixinTemplateService.paySuccessNoticeToKefu(templateBean.getOrderId()
+                                 , templateBean.getPrice(), msg.getOpenId());
+                        }
+                    });
+                } catch (Exception e) {
+                    log.error("消息发送失败:{}", e);
+                }
+                break;
+            case TYPE_2:
+                //处理退款与消息
+                if (PayTypeEnum.WEIXIN.getValue().equals(templateBean.getPayType())) {
+                    BigDecimal bigDecimal = new BigDecimal("100");
+                    int payPrice = bigDecimal.multiply(new BigDecimal(templateBean.getPrice())).intValue();
+                    weixinPayService.refundOrder(templateBean.getOrderId(), payPrice);
+                }
+
+                weixinTemplateService.refundSuccessNotice("您的订单退款申请被通过,钱款将很快还至您的支付账户。",templateBean.getOrderId(), templateBean.getPrice(),
+                        templateBean.getUid(), templateBean.getTime());
+                break;
+            case TYPE_3:
+                weixinTemplateService.deliverySuccessNotice(templateBean.getOrderId(), templateBean.getDeliveryName(),
+                        templateBean.getDeliveryId(), templateBean.getUid());
+                break;
+            case TYPE_4:
+                weixinTemplateService.rechargeSuccessNotice(templateBean.getTime(), templateBean.getPrice(),
+                        templateBean.getUid());
+                break;
+            case TYPE_7:
+                //使用MQ延时消息
+                //mqProducer.sendMsg("yshop-topic", templateBean.getOrderId());
+                log.info("投递延时订单id: [{}]:", templateBean.getOrderId());
+                break;
+            case TYPE_8:
+                YxUserExtract resources = yxUserExtractService.getById(templateBean.getExtractId());
+                Boolean success = false;
+                YxUser user = userService.getById(resources.getUid());
+                if (user != null) {
+                    WechatUserDto wechatUser = user.getWxProfile();
+                    if (ObjectUtil.isNotNull(wechatUser) && ObjectUtil.isNotNull(wechatUser.getRoutineOpenid())) {
+                        try {
+                            String nonce_str = UUID.randomUUID().toString().replace("-", "");
+                            payService.entPay(wechatUser.getRoutineOpenid(), nonce_str,
+                                    resources.getRealName(),
+                                    resources.getExtractPrice().multiply(new BigDecimal(100)).intValue());
+                            success = true;
+                        } catch (WxPayException e) {
+                            log.error("退款失败,原因:{}", e.getMessage());
+                        }
+                    }
+                }
+                if (!success) {
+                    //防止无限添加佣金
+                    if (ObjectUtil.isNull(resources.getFailTime())) {
+                        String mark = "提现失败,退回佣金" + resources.getExtractPrice() + "元";
+                        double balance = NumberUtil.add(user.getBrokeragePrice(), resources.getExtractPrice()).doubleValue();
+                        //插入流水
+                        billService.income(resources.getUid(), "提现失败", BillDetailEnum.CATEGORY_1.getValue(),
+                                BillDetailEnum.TYPE_4.getValue(), resources.getExtractPrice().doubleValue(), balance,
+                                mark, resources.getId().toString());
+                        //返回提现金额
+                        userService.incBrokeragePrice(resources.getExtractPrice(), resources.getUid());
+                        resources.setFailMsg("提现失败");
+                        resources.setFailTime(new Date());
+                    }
+                    yxUserExtractService.updateById(resources);
+                }
+
+
+                break;
+            case TYPE_9:
+                weixinTemplateService.refundSuccessNotice("您的订单退款申请已提交,等待审核。",templateBean.getOrderId(), templateBean.getPrice(),
+                        templateBean.getUid(), templateBean.getTime());
+                /**************给客服发送消息**************/
+                try {
+                    List yxStoreCustomers = yxStoreCustomerService.lambdaQuery().eq(YxStoreCustomer::getIsEnable, ShopConstants.YSHOP_ONE_NUM).list();
+                    yxStoreCustomers.forEach(msg -> {
+                        if (StrUtil.isNotBlank(msg.getOpenId())) {
+                            weixinTemplateService.refundSuccessNoticeToKefu("尊敬的客服,您有新的退款申请待处理!",templateBean.getOrderId()
+                                    , templateBean.getPrice(), msg.getOpenId(), templateBean.getTime());
+                        }
+                    });
+                } catch (Exception e) {
+                    log.error("消息发送失败:{}", e);
+                }
+                break;
+            default:
+                //todo
+        }
+
+
+    }
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java
new file mode 100644
index 00000000..c5a360bd
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeiXinSubscribeService.java
@@ -0,0 +1,206 @@
+package co.yixiang.modules.mp.service;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
+import cn.hutool.core.util.StrUtil;
+import co.yixiang.api.YshopException;
+import co.yixiang.constant.ShopConstants;
+import co.yixiang.enums.ShopCommonEnum;
+import co.yixiang.modules.mp.domain.YxWechatTemplate;
+import co.yixiang.modules.user.domain.YxUser;
+import co.yixiang.modules.user.service.YxUserService;
+import co.yixiang.modules.user.service.dto.WechatUserDto;
+import co.yixiang.modules.mp.enums.WechatTempateEnum;
+import co.yixiang.modules.mp.config.WxMaConfiguration;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 小程序订阅消息通知
+ */
+@Service
+public class WeiXinSubscribeService {
+
+    @Autowired
+    private YxUserService userService;
+    @Autowired
+    private YxWechatTemplateService yxWechatTemplateService;
+    /**
+     * 充值成功通知
+     * @param time 时间
+     * @param price 金额
+     * @param uid uid
+     */
+    public void rechargeSuccessNotice(String time,String price,Long uid){
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isBlank(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first","您的账户金币发生变动,详情如下:");
+        map.put("keyword1","充值");
+        map.put("keyword2",time);
+        map.put("keyword3",price);
+        map.put("remark", ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendSubscribeMsg( openid, tempId, "/user/account",map);
+        }
+    }
+
+
+    /**
+     * 支付成功通知
+     * @param orderId 订单号
+     * @param price 金额
+     * @param uid uid
+     */
+    public void paySuccessNotice(String orderId,String price,Long uid){
+
+        String openid = this.getUserOpenid(uid);
+        if(StrUtil.isBlank(openid)) {
+            return;
+        }
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
+        Map map = new HashMap<>();
+        map.put("amount1",price);
+        map.put("date2", simpleDateFormat.format(new Date()));
+        map.put("character_string3",orderId);
+        map.put("time4",simpleDateFormat.format(new Date()));
+        map.put("thing5","yshop购买商品");
+        String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
+        }
+    }
+
+    /**
+     * 退款成功通知
+     * @param orderId 订单号
+     * @param price 金额
+     * @param uid uid
+     * @param time 时间
+     */
+    public void refundSuccessNotice(String orderId,String price,Long uid,String time){
+
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isBlank(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first","您的订单退款申请被通过,钱款将很快还至您的支付账户。");
+        //订单号
+        map.put("keyword1",orderId);
+        map.put("keyword2",price);
+        map.put("keyword3", time);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
+        }
+    }
+
+    /**
+     * 发货成功通知
+     * @param orderId 单号
+     * @param deliveryName 快递公司
+     * @param deliveryId 快递单号
+     * @param uid uid
+     */
+    public void deliverySuccessNotice(String orderId,String deliveryName,
+                                      String deliveryId,Long uid){
+
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isEmpty(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
+        map.put("keyword2",deliveryName);
+        map.put("keyword1",orderId);
+        map.put("keyword3",deliveryId);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendSubscribeMsg( openid,tempId, "/order/detail/"+orderId,map);
+        }
+    }
+
+
+    /**
+     * 构建小程序一次性订阅消息
+     * @param openId 单号
+     * @param templateId 模板id
+     * @param page 跳转页面
+     * @param map map内容
+     * @return String
+     */
+    private void sendSubscribeMsg(String openId, String templateId, String page, Map map){
+        WxMaSubscribeMessage wxMaSubscribeMessage = WxMaSubscribeMessage.builder()
+                .toUser(openId)
+                .templateId(templateId)
+                .page(page)
+                .build();
+        map.forEach( (k,v)-> { wxMaSubscribeMessage.addData(new WxMaSubscribeMessage.MsgData(k, v));} );
+        WxMaService wxMaService = WxMaConfiguration.getWxMaService();
+        try {
+            wxMaService.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage);
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 获取模板消息id
+     * @param key 模板key
+     * @return string
+     */
+    private String getTempId(String key){
+        YxWechatTemplate yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
+                .eq(YxWechatTemplate::getType,"subscribe")
+                .eq(YxWechatTemplate::getTempkey,key)
+                .one();
+        if (yxWechatTemplate == null) {
+            throw new YshopException("请后台配置key:" + key + "订阅消息id");
+        }
+        if(ShopCommonEnum.IS_STATUS_0.getValue().equals(yxWechatTemplate.getStatus())){
+            return "";
+        }
+        return yxWechatTemplate.getTempid();
+    }
+
+
+    /**
+     * 获取openid
+     * @param uid uid
+     * @return String
+     */
+    private String getUserOpenid(Long uid){
+        YxUser yxUser = userService.getById(uid);
+        if(yxUser == null) {
+            return "";
+        }
+
+        WechatUserDto wechatUserDto = yxUser.getWxProfile();
+        if(wechatUserDto == null) {
+            return "";
+        }
+        if(StrUtil.isBlank(wechatUserDto.getRoutineOpenid())) {
+            return "";
+        }
+        return wechatUserDto.getRoutineOpenid();
+
+    }
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java
new file mode 100644
index 00000000..740d7d6d
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java
@@ -0,0 +1,233 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+ * 注意:
+ * 本软件为www.yixiang.co开发研制,未经购买不得使用
+ * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
+ * 一经发现盗用、分享等行为,将追究法律责任,后果自负
+ */
+package co.yixiang.modules.mp.service;
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import co.yixiang.api.BusinessException;
+import co.yixiang.api.YshopException;
+import co.yixiang.enums.AppFromEnum;
+import co.yixiang.enums.BillDetailEnum;
+import co.yixiang.enums.OrderInfoEnum;
+import co.yixiang.enums.PayMethodEnum;
+import co.yixiang.enums.PayTypeEnum;
+import co.yixiang.modules.order.service.YxStoreOrderService;
+import co.yixiang.modules.order.vo.YxStoreOrderQueryVo;
+import co.yixiang.modules.user.domain.YxUser;
+import co.yixiang.modules.user.domain.YxUserRecharge;
+import co.yixiang.modules.user.service.YxUserRechargeService;
+import co.yixiang.modules.user.service.YxUserService;
+import co.yixiang.modules.user.service.dto.WechatUserDto;
+import co.yixiang.modules.mp.config.WxPayConfiguration;
+import co.yixiang.utils.IpUtil;
+import co.yixiang.utils.RedisUtils;
+import co.yixiang.utils.ShopKeyUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
+import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
+import com.github.binarywang.wxpay.exception.WxPayException;
+import com.github.binarywang.wxpay.service.WxPayService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+
+/**
+ * @ClassName 微信支付WeixinPayService
+ * @Author hupeng <610796224@qq.com>
+ * @Date 2020/6/27
+ **/
+@Service
+@Slf4j
+public class WeixinPayService {
+
+    @Autowired
+    private RedisUtils redisUtils;
+
+    @Autowired
+    private YxUserService userService;
+    @Autowired
+    private YxStoreOrderService storeOrderService;
+    @Autowired
+    private YxUserRechargeService userRechargeService;
+
+
+    /**
+     * 统一支付入口
+     * @param orderId 单号
+     * @param from 来源
+     * @param attach 备注 普通支付还是充值
+     * @param body 内容
+     * @return Object
+     */
+    public Object unifyPay(String orderId, String from, String attach, String body) {
+        long uid = 0;
+        int payPrice = 0;
+        BigDecimal bigDecimal = new BigDecimal(100);
+        //普通支付
+        if(BillDetailEnum.TYPE_3.getValue().equals(attach)){
+            YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderId,null);
+            if(ObjectUtil.isNull(orderInfo)) {
+                throw new YshopException("订单不存在");
+            }
+            if(orderInfo.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) {
+                throw new YshopException("该订单已支付");
+            }
+
+            if(orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) {
+                throw new YshopException("该支付无需支付");
+            }
+
+            uid = orderInfo.getUid().intValue();
+            //计算分
+            payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();
+        }else{ //充值
+            YxUserRecharge userRecharge = userRechargeService.getOne(Wrappers.lambdaQuery()
+                    .eq(YxUserRecharge::getOrderId,orderId));
+            if(userRecharge == null) {
+                throw new BusinessException("充值订单不存在");
+            }
+
+            if(userRecharge.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue())) {
+                throw new YshopException("该订单已支付");
+            }
+            uid = userRecharge.getUid();
+            payPrice = bigDecimal.multiply(userRecharge.getPrice()).intValue();
+        }
+
+
+        YxUser yxUser = userService.getById(uid);
+        if(yxUser == null) {
+            throw new YshopException("用户错误");
+        }
+
+
+        WechatUserDto wechatUserDto = yxUser.getWxProfile();
+
+        WxPayService wxPayService = null;
+        if(AppFromEnum.ROUNTINE.getValue().equals(from)){
+            wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WXAPP);
+        }else if(AppFromEnum.APP.getValue().equals(from) || AppFromEnum.PC.getValue().equals(from)){
+            wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.APP);
+        }else{
+            wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
+        }
+        WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
+        orderRequest.setOutTradeNo(orderId);
+        orderRequest.setTotalFee(payPrice);
+        orderRequest.setSpbillCreateIp(IpUtil.getLocalIP());
+        orderRequest.setNotifyUrl(this.getApiUrl() + "/xiaohuiapp/wechat/notify");
+        orderRequest.setBody(body);
+        orderRequest.setAttach(attach);
+
+        if(AppFromEnum.WEIXIN_H5.getValue().equals(from)){
+            orderRequest.setTradeType("MWEB");
+        }else if(AppFromEnum.APP.getValue().equals(from)){
+            orderRequest.setTradeType("APP");
+        }else if(AppFromEnum.PC.getValue().equals(from)){
+            orderRequest.setTradeType("NATIVE");
+            orderRequest.setProductId( UUID.fastUUID().toString());
+        } else{
+            orderRequest.setTradeType("JSAPI");
+            if(AppFromEnum.ROUNTINE.getValue().equals(from)){
+                orderRequest.setOpenid(wechatUserDto.getRoutineOpenid());
+            }else {
+                orderRequest.setOpenid(wechatUserDto.getOpenid());
+            }
+        }
+        try {
+            return wxPayService.createOrder(orderRequest);
+        }catch (WxPayException e) {
+            log.info("支付错误信息:{}",e.getMessage());
+            throw new BusinessException(e.getMessage());
+        }
+
+
+    }
+
+
+
+
+    /**
+     * 退款
+     * @param orderId orderId
+     * @param refundFee totalFee 单位分
+     */
+    public void refundOrder(String orderId, Integer refundFee) {
+
+        YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(orderId,null);
+        if(PayTypeEnum.YUE.getValue().equals(orderInfo.getPayType())) {
+            return;
+        }
+        if(orderInfo.getExtendOrderId()!=null){
+            orderId=orderInfo.getExtendOrderId();
+        }
+        WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
+        WxPayRefundRequest wxPayRefundRequest = new WxPayRefundRequest();
+        BigDecimal bigDecimal = new BigDecimal("100");
+        int totalFee = bigDecimal.multiply(orderInfo.getPayPrice()).intValue();
+        //订单总金额
+        wxPayRefundRequest.setTotalFee(totalFee);
+        wxPayRefundRequest.setOutTradeNo(orderId);
+        //生成退款单号
+        String orderSn = IdUtil.getSnowflake(0,0).nextIdStr();
+        wxPayRefundRequest.setOutRefundNo(orderSn);
+        //退款金额
+        wxPayRefundRequest.setRefundFee(refundFee);
+        wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/xiaohuiapp/notify/refund");
+        try {
+            wxPayService.refundV2(wxPayRefundRequest);
+        } catch (WxPayException e) {
+            log.info("退款错误信息:{}",e.getMessage());
+            throw new BusinessException(e.getMessage());
+        }
+    }
+
+
+    /**
+     * 企业打款
+     * @param openid 微信openid
+     * @param no 单号
+     * @param userName 用户姓名
+     * @param amount 金额
+     * @throws WxPayException
+     */
+    public void entPay(String openid,String no,String userName,Integer amount) throws WxPayException {
+        WxPayService wxPayService = WxPayConfiguration.getPayService(PayMethodEnum.WECHAT);
+        EntPayRequest entPayRequest = new EntPayRequest();
+
+        entPayRequest.setOpenid(openid);
+        entPayRequest.setPartnerTradeNo(no);
+        entPayRequest.setCheckName("FORCE_CHECK");
+        entPayRequest.setReUserName(userName);
+        entPayRequest.setAmount(amount);
+        entPayRequest.setDescription("提现");
+        entPayRequest.setSpbillCreateIp(IpUtil.getLocalIP());
+        wxPayService.getEntPayService().entPay(entPayRequest);
+
+    }
+
+
+    /**
+     * 返回H5 url
+     * @return url
+     */
+    private String getApiUrl(){
+        String apiUrl = redisUtils.getY(ShopKeyUtils.getApiUrl());
+        if(StrUtil.isBlank(apiUrl)){
+            throw new YshopException("请配置移动端api地址");
+        }
+        return apiUrl;
+    }
+
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java
new file mode 100644
index 00000000..5f107ecf
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java
@@ -0,0 +1,330 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+ * 注意:
+ * 本软件为www.yixiang.co开发研制,未经购买不得使用
+ * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
+ * 一经发现盗用、分享等行为,将追究法律责任,后果自负
+ */
+package co.yixiang.modules.mp.service;
+
+import cn.hutool.core.util.StrUtil;
+import co.yixiang.api.YshopException;
+import co.yixiang.constant.ShopConstants;
+import co.yixiang.enums.ShopCommonEnum;
+import co.yixiang.modules.mp.config.WxMpConfiguration;
+import co.yixiang.modules.mp.domain.YxWechatTemplate;
+import co.yixiang.modules.user.domain.YxUser;
+import co.yixiang.modules.user.service.YxUserService;
+import co.yixiang.modules.user.service.dto.WechatUserDto;
+import co.yixiang.modules.mp.enums.WechatTempateEnum;
+
+import co.yixiang.utils.RedisUtils;
+import co.yixiang.utils.ShopKeyUtils;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.mp.api.WxMpService;
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @ClassName 微信公众号模板通知
+ * @Author hupeng <610796224@qq.com>
+ * @Date 2020/6/27
+ **/
+@Slf4j
+@Service
+public class WeixinTemplateService {
+
+    @Autowired
+    private RedisUtils redisUtils;
+
+    @Autowired
+    private YxUserService userService;
+    @Autowired
+    private YxWechatTemplateService yxWechatTemplateService;
+
+
+
+
+    /**
+     * 充值成功通知
+     * @param time 时间
+     * @param price 金额
+     * @param uid uid
+     */
+    public void rechargeSuccessNotice(String time,String price,Long uid){
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isBlank(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first","您的账户金币发生变动,详情如下:");
+        map.put("keyword1","充值");
+        map.put("keyword2",time);
+        map.put("keyword3",price);
+        map.put("remark", ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendWxMpTemplateMessage( openid, tempId, this.getSiteUrl()+"/user/account",map);
+        }
+    }
+
+
+    /**
+     * 支付成功通知
+     * @param orderId 订单号
+     * @param price 金额
+     * @param uid uid
+     */
+    public void paySuccessNotice(String orderId,String price,Long uid){
+
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isBlank(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first","您的订单已支付成功,我们会尽快为您发货。");
+        //订单号
+        map.put("keyword1",orderId);
+        map.put("keyword2",price);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
+        }
+    }
+
+
+    /**
+     * 支付成功通知给客服
+     *
+     * @param orderId
+     * @param price
+     * @param openId
+     */
+    public void paySuccessNoticeToKefu(String orderId,String price,String openId) {
+        Map map = new HashMap<>();
+        map.put("first", "尊敬的客服,您有新订单了");
+        map.put("keyword1",orderId);
+        map.put("keyword2",price);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue());
+        String appId=redisUtils.getY(ShopKeyUtils.getWxAppAppId());
+        if(StrUtil.isNotBlank(tempId)) {
+            if(StrUtil.isBlank(appId)){
+                this.sendWxMpTemplateMessage( openId,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
+            }else{
+                WxMpTemplateMessage.MiniProgram miniProgram = new WxMpTemplateMessage.MiniProgram();
+                miniProgram.setAppid(redisUtils.getY(ShopKeyUtils.getWxAppAppId()));
+                miniProgram.setPagePath("pages/orderAdmin/AdminOrder/index?oid=" + orderId);
+                this.sendWxMpTemplateMessageToWx(openId, tempId, miniProgram, map);
+            }
+        }
+
+
+
+    }
+
+
+    /**
+     * 退款成功通知
+     * @param orderId 订单号
+     * @param price 金额
+     * @param uid uid
+     * @param time 时间
+     */
+    public void refundSuccessNotice(String title,String orderId,String price,Long uid,String time){
+
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isBlank(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first",title);
+        //订单号
+        map.put("keyword1",orderId);
+        map.put("keyword2",price);
+        map.put("keyword3", time);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
+        }
+    }
+
+    /**
+     * 发送退款申请给客服
+     * @param orderId 订单号
+     * @param price 金额
+     * @param openId openId
+     * @param time 时间
+     */
+    public void refundSuccessNoticeToKefu(String title,String orderId,String price,String openId,String time){
+
+        Map map = new HashMap<>();
+        map.put("first",title);
+        //订单号
+        map.put("keyword1",orderId);
+        map.put("keyword2",price);
+        map.put("keyword3", time);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue());
+        String appId=redisUtils.getY(ShopKeyUtils.getWxAppAppId());
+        if(StrUtil.isNotBlank(tempId)) {
+            if(StrUtil.isBlank(appId)){
+                this.sendWxMpTemplateMessage( openId,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
+            }else{
+                WxMpTemplateMessage.MiniProgram miniProgram = new WxMpTemplateMessage.MiniProgram();
+                miniProgram.setAppid(redisUtils.getY(ShopKeyUtils.getWxAppAppId()));
+                miniProgram.setPagePath("pages/orderAdmin/AdminOrder/index?oid=" + orderId);
+                this.sendWxMpTemplateMessageToWx(openId, tempId, miniProgram, map);
+            }
+        }
+    }
+
+    /**
+     * 发货成功通知
+     * @param orderId 单号
+     * @param deliveryName 快递公司
+     * @param deliveryId 快递单号
+     * @param uid uid
+     */
+    public void deliverySuccessNotice(String orderId,String deliveryName,
+                                      String deliveryId,Long uid){
+
+        String openid = this.getUserOpenid(uid);
+
+        if(StrUtil.isEmpty(openid)) {
+            return;
+        }
+
+        Map map = new HashMap<>();
+        map.put("first","亲,宝贝已经启程了,好想快点来到你身边。");
+        map.put("keyword2",deliveryName);
+        map.put("keyword1",orderId);
+        map.put("keyword3",deliveryId);
+        map.put("remark",ShopConstants.YSHOP_WECHAT_PUSH_REMARK);
+        String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue());
+        if(StrUtil.isNotBlank(tempId)) {
+            this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map);
+        }
+    }
+
+
+    /**
+     * 构建微信模板通知
+     * @param openId 单号
+     * @param templateId 模板id
+     * @param url 跳转url
+     * @param map map内容
+     * @return String
+     */
+    private String sendWxMpTemplateMessage(String openId, String templateId, String url, Map map){
+        WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
+                .toUser(openId)
+                .templateId(templateId)
+                .url(url)
+                .build();
+        map.forEach( (k,v)-> { templateMessage.addData(new WxMpTemplateData(k, v, "#000000"));} );
+        String msgId = null;
+        WxMpService wxService = WxMpConfiguration.getWxMpService();
+        try {
+            msgId =   wxService.getTemplateMsgService().sendTemplateMsg(templateMessage);
+        } catch (WxErrorException e) {
+            e.printStackTrace();
+        }
+        return msgId;
+    }
+
+
+
+
+    public String sendWxMpTemplateMessageToWx(String openId, String templateId, WxMpTemplateMessage.MiniProgram miniProgram, Map map) {
+        WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
+                .toUser(openId)
+                .templateId(templateId)
+                .miniProgram(miniProgram)
+                .build();
+        map.forEach((k, v) -> {
+            templateMessage.addData(new WxMpTemplateData(k, v, "#000000"));
+        });
+        String msgId = null;
+        WxMpService wxService = WxMpConfiguration.getWxMpService();
+        try {
+            msgId = wxService.getTemplateMsgService().sendTemplateMsg(templateMessage);
+        } catch (WxErrorException e) {
+            log.error(e.getMessage(), e);
+        }
+        return msgId;
+    }
+
+
+    /**
+     * 获取模板消息id
+     * @param key 模板key
+     * @return string
+     */
+    private String getTempId(String key){
+        YxWechatTemplate yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
+                .eq(YxWechatTemplate::getType,"template")
+                .eq(YxWechatTemplate::getTempkey,key)
+                .one();
+        if (yxWechatTemplate == null) {
+            throw new YshopException("请后台配置key:" + key + "模板消息id");
+        }
+
+        if(ShopCommonEnum.IS_STATUS_0.getValue().equals(yxWechatTemplate.getStatus())){
+            return "";
+        }
+
+        return yxWechatTemplate.getTempid();
+    }
+
+    /**
+     * 返回H5 url
+     * @return url
+     */
+    private String getSiteUrl(){
+        String apiUrl = redisUtils.getY(ShopKeyUtils.getSiteUrl());
+        if(StrUtil.isBlank(apiUrl)){
+            return "";
+        }
+        return apiUrl;
+    }
+
+    /**
+     * 获取openid
+     * @param uid uid
+     * @return String
+     */
+    private String getUserOpenid(Long uid){
+        YxUser yxUser = userService.getById(uid);
+        if(yxUser == null) {
+            return "";
+        }
+
+        WechatUserDto wechatUserDto = yxUser.getWxProfile();
+        if(wechatUserDto == null) {
+            return "";
+        }
+        if(StrUtil.isBlank(wechatUserDto.getOpenid())) {
+            return "";
+        }
+        return wechatUserDto.getOpenid();
+
+    }
+
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxArticleService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxArticleService.java
new file mode 100644
index 00000000..13227ef2
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxArticleService.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright (C) 2018-2022
+ * All rights reserved, Designed By www.yixiang.co
+ * 注意:
+ * 本软件为www.yixiang.co开发研制,未经购买不得使用
+ * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
+ * 一经发现盗用、分享等行为,将追究法律责任,后果自负
+ */
+package co.yixiang.modules.mp.service;
+
+import co.yixiang.common.service.BaseService;
+import co.yixiang.modules.mp.service.dto.YxArticleDto;
+import co.yixiang.modules.mp.service.dto.YxArticleQueryCriteria;
+import co.yixiang.modules.mp.domain.YxArticle;
+import co.yixiang.modules.mp.vo.YxArticleQueryVo;
+import org.springframework.data.domain.Pageable;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author hupeng
+* @date 2020-05-12
+*/
+public interface YxArticleService  extends BaseService{
+
+    /**
+     * 获取文章列表
+     * @param page 页码
+     * @param limit 条数
+     * @return List
+     */
+    List getList(int page, int limit);
+
+    /**
+     * 获取文章详情
+     * @param id id
+     * @return YxArticleQueryVo
+     */
+    YxArticleQueryVo getDetail(int id);
+
+    void incVisitNum(int id);
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map
+    */
+    Map queryAll(YxArticleQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List
+    */
+    List queryAll(YxArticleQueryCriteria criteria);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List all, HttpServletResponse response) throws IOException;
+
+
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatLiveGoodsService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatLiveGoodsService.java
new file mode 100644
index 00000000..d2a5b9a8
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatLiveGoodsService.java
@@ -0,0 +1,76 @@
+/**
+* Copyright (C) 2018-2022
+* All rights reserved, Designed By www.yixiang.co
+* 注意:
+* 本软件为www.yixiang.co开发研制,未经购买不得使用
+* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
+* 一经发现盗用、分享等行为,将追究法律责任,后果自负
+*/
+package co.yixiang.modules.mp.service;
+
+import co.yixiang.common.service.BaseService;
+import co.yixiang.modules.mp.service.dto.YxWechatLiveGoodsDto;
+import co.yixiang.modules.mp.service.dto.YxWechatLiveGoodsQueryCriteria;
+import co.yixiang.modules.mp.domain.YxWechatLiveGoods;
+import org.springframework.data.domain.Pageable;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+* @author hupeng
+* @date 2020-08-11
+*/
+public interface YxWechatLiveGoodsService  extends BaseService{
+
+/**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map
+    */
+    Map queryAll(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List
+    */
+    List queryAll(YxWechatLiveGoodsQueryCriteria criteria);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List all, HttpServletResponse response) throws IOException;
+
+    /**
+     * 保存直播商品信息
+     * @param resources
+     * @return
+     */
+    boolean saveGoods(YxWechatLiveGoods resources);
+
+    /**
+     * 同步商品更新审核状态
+     * @param goodsIds
+     * @return
+     */
+    boolean synchroWxOlLive(List goodsIds);
+
+    /**
+     * 根据id删除直播商品信息
+     * @param id
+     */
+    void removeGoods(Long id);
+
+    /**
+     * 更新直播商品信息
+     * @param resources
+     */
+    void updateGoods(YxWechatLiveGoods resources);
+}
diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatLiveService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatLiveService.java
new file mode 100644
index 00000000..99a38d7e
--- /dev/null
+++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatLiveService.java
@@ -0,0 +1,100 @@
+/**
+* Copyright (C) 2018-2022
+* All rights reserved, Designed By www.yixiang.co
+* 注意:
+* 本软件为www.yixiang.co开发研制,未经购买不得使用
+* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
+* 一经发现盗用、分享等行为,将追究法律责任,后果自负
+*/
+package co.yixiang.modules.mp.service;
+
+import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
+import co.yixiang.common.service.BaseService;
+import co.yixiang.modules.mp.service.dto.UpdateGoodsDto;
+import co.yixiang.modules.mp.service.dto.WxMaLiveInfo;
+import co.yixiang.modules.mp.service.dto.YxWechatLiveDto;
+import co.yixiang.modules.mp.service.dto.YxWechatLiveQueryCriteria;
+import co.yixiang.modules.mp.vo.WechatLiveVo;
+import co.yixiang.modules.mp.domain.YxWechatLive;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.springframework.data.domain.Pageable;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+* @author hupeng
+* @date 2020-08-10
+*/
+public interface YxWechatLiveService  extends BaseService{
+
+
+
+
+    /**
+     * 同步直播间
+     * @return
+     */
+    boolean synchroWxOlLive();
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map
+    */
+    WechatLiveVo queryAll(YxWechatLiveQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List
+    */
+    List queryAll(YxWechatLiveQueryCriteria criteria);
+
+
+    boolean saveLive(YxWechatLive resources);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List all, HttpServletResponse response) throws IOException;
+
+
+    /**
+     * 创建直播间
+     * 
+     * 调用此接口创建直播间,创建成功后将在直播间列表展示,调用额度:10000次/一天
+     * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#1
+     * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=ACCESS_TOKEN
+     * 
+ * + * @param roomInfo 直播间信息 + * @return . + * @throws WxErrorException . + */ + Integer createRoom(WxMaLiveInfo.RoomInfo roomInfo) throws WxErrorException; + + /** + * 获取直播回放 + * @param roomId + * @return + */ + List getLiveReplay(Integer roomId); + + + /** + * 商品列表 + * @param page 页码 + * @param limit 条数 + * @param order ProductEnum + * @return List + */ + List getList(int page, int limit, int order); + + boolean addGoods(UpdateGoodsDto resources); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatMenuService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatMenuService.java new file mode 100644 index 00000000..58989502 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatMenuService.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.mp.service.dto.YxWechatMenuDto; +import co.yixiang.modules.mp.service.dto.YxWechatMenuQueryCriteria; +import co.yixiang.modules.mp.domain.YxWechatMenu; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxWechatMenuService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxWechatMenuQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxWechatMenuQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + Boolean isExist(String wechat_menus); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatReplyService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatReplyService.java new file mode 100644 index 00000000..23ac8df4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatReplyService.java @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.mp.service.dto.YxWechatReplyDto; +import co.yixiang.modules.mp.service.dto.YxWechatReplyQueryCriteria; +import co.yixiang.modules.mp.domain.YxWechatReply; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxWechatReplyService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxWechatReplyQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxWechatReplyQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + YxWechatReply isExist(String subscribe); + + void create(YxWechatReply yxWechatReply); + + void upDate(YxWechatReply yxWechatReply); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatTemplateService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatTemplateService.java new file mode 100644 index 00000000..b69b91ea --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/YxWechatTemplateService.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.mp.service.dto.YxWechatTemplateQueryCriteria; +import co.yixiang.modules.mp.domain.YxWechatTemplate; +import co.yixiang.modules.mp.service.dto.YxWechatTemplateDto; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxWechatTemplateService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxWechatTemplateQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxWechatTemplateQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + YxWechatTemplate findByTempkey(String recharge_success_key); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/UpdateGoodsDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/UpdateGoodsDto.java new file mode 100644 index 00000000..5d645fde --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/UpdateGoodsDto.java @@ -0,0 +1,11 @@ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +@Data +public class UpdateGoodsDto { + + private Integer roomId; + + private String productId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/WxMaLiveInfo.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/WxMaLiveInfo.java new file mode 100644 index 00000000..941cd515 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/WxMaLiveInfo.java @@ -0,0 +1,59 @@ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class WxMaLiveInfo { + + private static final long serialVersionUID = 7285263767524755887L; + + /** + * 直播列表 + */ + @Data + public static class RoomInfo implements Serializable { + private static final long serialVersionUID = 7745775280267417154L; + private String name; + private Integer roomid; + private String coverImg; + private String shareImg; + private String feedsImg; + private Integer liveStatus; + private Long startTime; + private Long endTime; + private String anchorName; + private String anchorWechat; + private String anchorImg; + private Integer type; + private Integer screenType; + private Integer closeLike; + private Integer closeGoods; + private Integer closeComment; + private Integer closeReplay ; // 是否关闭回放 1 关闭 + private Integer closeShare ; // 是否关闭分享 1 关闭 + private Integer closeKf ; // 是否关闭客服,1 关闭 + private List goods; + } + + /** + * 商品列表 + */ + @Data + public static class Goods implements Serializable { + private static final long serialVersionUID = 5769245932149287574L; + private Integer goodsId; + private String coverImgUrl; + private String url; + private Integer priceType; + private String price; + private String price2; + private String name; + /** + * 1, 2:表示是为api添加商品,否则是在MP添加商品 + */ + private String thirdPartyTag; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/WxMaLiveResult.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/WxMaLiveResult.java new file mode 100644 index 00000000..c4d6b713 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/WxMaLiveResult.java @@ -0,0 +1,131 @@ +package co.yixiang.modules.mp.service.dto; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + *
+ * 直播间操作返回结果
+ * Created by lipengjun on 2020/6/29.
+ * 
+ * + * @author lipengjun (939961241@qq.com) + */ +@Data +public class WxMaLiveResult implements Serializable { + private static final long serialVersionUID = 1L; + private Integer errcode; + private String errmsg; + private Integer total; + private Integer auditId; + private Integer goodsId; + private List goods; + + /** + * 直播间列表 + */ + @SerializedName("room_info") + private List roomInfos; + + /** + * 获取回放源视频列表 + */ + @SerializedName("live_replay") + private List liveReplay; + + public static cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult fromJson(String json) { + return WxMaGsonBuilder.create().fromJson(json, cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult.class); + } + + /** + * 商品列表 + */ + @Data + public static class Goods implements Serializable { + private static final long serialVersionUID = 5769245932149287574L; + @SerializedName("goods_id") + private Integer goodsId; + /** + * 获取商品列表返回的商品图片 + */ + @SerializedName("cover_img_url") + private String coverImgUrl; + /** + * 获取直播间列表返回的商品图片 + */ + @SerializedName("cover_img") + private String coverImg; + private String name; + private String url; + @SerializedName("price_type") + private Integer priceType; + /** + * 0:未审核,1:审核中,2:审核通过,3审核失败 + */ + @SerializedName("audit_status") + private Integer auditStatus; + private String price; + private String price2; + /** + * 1, 2:表示是为api添加商品,否则是在MP添加商品 + */ + @SerializedName("third_party_tag") + private String thirdPartyTag; + } + + /** + * 直播列表 + */ + @Data + public static class RoomInfo implements Serializable { + private static final long serialVersionUID = 7745775280267417154L; + private String name; + @SerializedName("roomid") + private Integer roomId; + @SerializedName("cover_img") + private String coverImg; + @SerializedName("share_img") + private String shareImg; + @SerializedName("live_status") + private Integer liveStatus; + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + @SerializedName("anchor_name") + private String anchorName; + @SerializedName("anchor_wechat") + private String anchorWechat; + @SerializedName("anchor_img") + private String anchorImg; + private Integer type; + @SerializedName("screen_type") + private Integer screenType; + @SerializedName("close_like") + private Integer closeLike; + @SerializedName("closeGoods") + private Integer closeGoods; + @SerializedName("close_comment") + private Integer closeComment; + private List goods; + } + + /** + * 回放数据列表 + */ + @Data + public static class LiveReplay implements Serializable { + private static final long serialVersionUID = 7683927205627536320L; + @SerializedName("expire_time") + private String expireTime; + @SerializedName("create_time") + private String createTime; + @SerializedName("media_url") + private String mediaUrl; + } +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxArticleDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxArticleDto.java new file mode 100644 index 00000000..adb00a80 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxArticleDto.java @@ -0,0 +1,82 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxArticleDto implements Serializable { + + /** 文章管理ID */ + private Integer id; + + /** 分类id */ + private String cid; + + /** 文章标题 */ + private String title; + + /** 文章作者 */ + private String author; + + /** 文章图片 */ + private String imageInput; + + /** 文章简介 */ + private String synopsis; + + private String content; + + /** 文章分享标题 */ + private String shareTitle; + + /** 文章分享简介 */ + private String shareSynopsis; + + /** 浏览次数 */ + private String visit; + + /** 排序 */ + private Integer sort; + + /** 原文链接 */ + private String url; + + /** 状态 */ + private Integer status; + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + /** 是否隐藏 */ + private Integer hide; + + /** 管理员id */ + private Integer adminId; + + /** 商户id */ + private Integer merId; + + /** 产品关联id */ + private Integer productId; + + /** 是否热门(小程序) */ + private Integer isHot; + + /** 是否轮播图(小程序) */ + private Integer isBanner; + + private String thumbMediaId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxArticleQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxArticleQueryCriteria.java new file mode 100644 index 00000000..79abd820 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxArticleQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxArticleQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveDto.java new file mode 100644 index 00000000..5ac1e20c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveDto.java @@ -0,0 +1,105 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@Data +public class YxWechatLiveDto implements Serializable { + + + + /** 直播间id */ + /** 防止精度丢失 */ + @JsonSerialize(using= ToStringSerializer.class) + @ApiModelProperty(value = "直播间id") + private Long roomId; + + private Long id; + + /** 直播间标题 */ + @ApiModelProperty(value = "直播间标题") + private String name; + + /** 背景图 */ + @ApiModelProperty(value = "背景图") + private String coverImge; + + /** 分享图片 */ + @ApiModelProperty(value = "分享图片") + private String shareImge; + + /** 直播间状态 */ + @ApiModelProperty(value = "直播间状态 101:直播中,102:未开始,103 已结束,104 禁播,105:暂停,106:异常,107:已过期") + private Integer liveStatus; + + /** 开始时间 */ + @ApiModelProperty(value = "开始时间") + private Long startTime; + + /** 预计结束时间 */ + @ApiModelProperty(value = "预计结束时间") + private Long endTime; + + /** 主播昵称 */ + @ApiModelProperty(value = "主播昵称") + private String anchorName; + + /** 主播微信号 */ + @ApiModelProperty(value = "主播微信号") + private String anchorWechat; + + /** 主播头像 */ + @ApiModelProperty(value = "主播头像") + private String anchorImge; + + /** 直播间类型 1:推流 0:手机直播 */ + @ApiModelProperty(value = "直播间类型 1:推流 0:手机直播") + private Integer type; + + /** 横屏、竖屏 【1:横屏,0:竖屏】 */ + @ApiModelProperty(value = "横屏、竖屏 【1:横屏,0:竖屏】") + private Integer screenType; + + /** 是否关闭点赞 【0:开启,1:关闭】 */ + @ApiModelProperty(value = "是否关闭点赞 【0:开启,1:关闭】") + private Integer closeLike; + + /** 是否关闭评论 【0:开启,1:关闭】 */ + @ApiModelProperty(value = "是否关闭评论 【0:开启,1:关闭】") + private Integer closeComment; + + /** 是否关闭货架 【0:开启,1:关闭】 */ + @ApiModelProperty(value = "是否关闭货架 【0:开启,1:关闭】") + private Integer closeGoods; + + private Integer closeReplay ; // 是否关闭回放 1 关闭 + + private Integer closeShare ; // 是否关闭分享 1 关闭 + + private Integer closeKf ; // 是否关闭客服,1 关闭 + /** + * 关联商品id多个,隔开 + */ + + private String productId; + + @ApiModelProperty(value = "商品信息") + private List product; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveGoodsDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveGoodsDto.java new file mode 100644 index 00000000..49955682 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveGoodsDto.java @@ -0,0 +1,59 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-08-11 +*/ +@Data +public class YxWechatLiveGoodsDto implements Serializable { + + + private Long id; + + /** 直播商品id */ + /** 防止精度丢失 */ + @JsonSerialize(using= ToStringSerializer.class) + private Long goodsId; + + /** 关联商品id */ + private Long productId; + + /** 商品图片 */ + private String coverImgeUrl; + + /** 商品小程序路径 */ + private String url; + + /** 价格类型 1:一口价(只需要传入price,price2不传) 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传) 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传) */ + private String priceType; + + private String price; + + private String price2; + + /** 商品名称 */ + private String name; + + /** 1, 2:表示是为api添加商品,否则是直播控制台添加的商品 */ + private String thirdPartyTag; + + /** 审核单id */ + private Long auditId; + + /** 审核状态 0:未审核,1:审核中,2:审核通过,3审核失败 */ + private Integer auditStatus; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveGoodsQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveGoodsQueryCriteria.java new file mode 100644 index 00000000..03569901 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveGoodsQueryCriteria.java @@ -0,0 +1,24 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-08-11 +*/ +@Data +public class YxWechatLiveGoodsQueryCriteria{ + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String name; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveQueryCriteria.java new file mode 100644 index 00000000..06dec017 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatLiveQueryCriteria.java @@ -0,0 +1,24 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.dto; + +import co.yixiang.annotation.Query; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@Data +public class YxWechatLiveQueryCriteria{ + @ApiModelProperty(value = "直播间状态 101:直播中,102:未开始,103 已结束,104 禁播,105:暂停,106:异常,107:已过期") + @Query + private Integer liveStatus; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatMenuDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatMenuDto.java new file mode 100644 index 00000000..49fb24ec --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatMenuDto.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatMenuDto implements Serializable { + + private String key; + + /** 缓存数据 */ + private String result; + + /** 缓存时间 */ + private Integer addTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatMenuQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatMenuQueryCriteria.java new file mode 100644 index 00000000..cde34691 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatMenuQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatMenuQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatReplyDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatReplyDto.java new file mode 100644 index 00000000..f02752bf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatReplyDto.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatReplyDto implements Serializable { + + /** 微信关键字回复id */ + private Integer id; + + /** 关键字 */ + private String key; + + /** 回复类型 */ + private String type; + + /** 回复数据 */ + private String data; + + /** 0=不可用 1 =可用 */ + private Integer status; + + /** 是否隐藏 */ + private Integer hide; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatReplyQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatReplyQueryCriteria.java new file mode 100644 index 00000000..ff6c8dfb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatReplyQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatReplyQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatTemplateDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatTemplateDto.java new file mode 100644 index 00000000..c427b20e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatTemplateDto.java @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatTemplateDto implements Serializable { + + /** 模板id */ + private Integer id; + + /** 模板编号 */ + private String tempkey; + + /** 模板名 */ + private String name; + + /** 回复内容 */ + private String content; + + /** 模板ID */ + private String tempid; + + /** 添加时间 */ + private String addTime; + + /** 状态 */ + private Integer status; + /** 类型:template:模板消息 subscribe:订阅消息 */ + private String type; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatTemplateQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatTemplateQueryCriteria.java new file mode 100644 index 00000000..8bc40075 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/dto/YxWechatTemplateQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatTemplateQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxArticleServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxArticleServiceImpl.java new file mode 100644 index 00000000..1485f6f6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxArticleServiceImpl.java @@ -0,0 +1,141 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.mp.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.mp.service.mapper.ArticleMapper; +import co.yixiang.modules.mp.domain.YxArticle; +import co.yixiang.modules.mp.service.YxArticleService; +import co.yixiang.modules.mp.service.dto.YxArticleDto; +import co.yixiang.modules.mp.service.dto.YxArticleQueryCriteria; +import co.yixiang.modules.mp.vo.YxArticleQueryVo; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Slf4j +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxArticleServiceImpl extends BaseServiceImpl implements YxArticleService { + + private final IGenerator generator; + private final ArticleMapper articleMapper; + + + public YxArticleServiceImpl(IGenerator generator,ArticleMapper articleMapper) { + this.generator = generator; + this.articleMapper = articleMapper; + } + + /** + * 获取文章列表 + * @param page 页码 + * @param limit 条数 + * @return List + */ + @Override + public List getList(int page, int limit){ + Page pageModel = new Page<>(page, limit); + + IPage pageList = articleMapper.selectPage(pageModel, Wrappers.lambdaQuery() + .orderByDesc(YxArticle::getId)); + + return generator.convert(pageList.getRecords(),YxArticleQueryVo.class); + } + + /** + * 获取文章详情 + * @param id id + * @return YxArticleQueryVo + */ + @Override + public YxArticleQueryVo getDetail(int id){ + return generator.convert(this.getById(id),YxArticleQueryVo.class); + } + + + @Override + public void incVisitNum(int id) { + articleMapper.incVisitNum(id); + } + + @Override + //@Cacheable + public Map queryAll(YxArticleQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxArticleDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxArticleQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxArticle.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxArticleDto yxArticle : all) { + Map map = new LinkedHashMap<>(); + map.put("分类id", yxArticle.getCid()); + map.put("文章标题", yxArticle.getTitle()); + map.put("文章作者", yxArticle.getAuthor()); + map.put("文章图片", yxArticle.getImageInput()); + map.put("文章简介", yxArticle.getSynopsis()); + map.put(" content", yxArticle.getContent()); + map.put("文章分享标题", yxArticle.getShareTitle()); + map.put("文章分享简介", yxArticle.getShareSynopsis()); + map.put("浏览次数", yxArticle.getVisit()); + map.put("排序", yxArticle.getSort()); + map.put("原文链接", yxArticle.getUrl()); + map.put("状态", yxArticle.getStatus()); + map.put("是否隐藏", yxArticle.getHide()); + map.put("管理员id", yxArticle.getAdminId()); + map.put("商户id", yxArticle.getMerId()); + map.put("产品关联id", yxArticle.getProductId()); + map.put("是否热门(小程序)", yxArticle.getIsHot()); + map.put("是否轮播图(小程序)", yxArticle.getIsBanner()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveGoodsServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveGoodsServiceImpl.java new file mode 100644 index 00000000..07e2ec7a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveGoodsServiceImpl.java @@ -0,0 +1,225 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.live.WxMaLiveGoodInfo; +import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.LiveGoodsEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.mp.service.dto.WxMaLiveInfo; +import co.yixiang.modules.mp.service.mapper.YxWechatLiveGoodsMapper; +import co.yixiang.modules.mp.domain.YxWechatLiveGoods; +import co.yixiang.modules.mp.service.YxWechatLiveGoodsService; +import co.yixiang.modules.mp.service.dto.YxWechatLiveGoodsDto; +import co.yixiang.modules.mp.service.dto.YxWechatLiveGoodsQueryCriteria; +import co.yixiang.modules.mp.config.WxMaConfiguration; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.common.error.WxErrorException; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-08-11 +*/ +@Slf4j +@Service +//@CacheConfig(cacheNames = "yxWechatLiveGoods") +@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class) +public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl implements YxWechatLiveGoodsService { + + private final IGenerator generator; + private String uploadDirStr = ""; + public YxWechatLiveGoodsServiceImpl(IGenerator generator) { + this.generator = generator; + } + + + /** + * 同步商品更新审核状态 + * @return + */ + //@Cacheable + @Override + public boolean synchroWxOlLive(List goodsIds) { + try { + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + WxMaLiveResult liveInfos = wxMaService.getLiveGoodsService().getGoodsWareHouse(goodsIds); + List convert = generator.convert(liveInfos.getGoods(), YxWechatLiveGoods.class); + this.saveOrUpdateBatch(convert); + } catch (WxErrorException e) { + e.printStackTrace(); + } + return true; + } + + @Override + public void removeGoods(Long id) { + this.removeById(id); + try { + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + wxMaService.getLiveGoodsService().deleteGoods(id.intValue()); + } catch (WxErrorException e) { + e.printStackTrace(); + } + } + + + /** + * 更新直播商品信息 + * @param resources + */ + @Override + public void updateGoods(YxWechatLiveGoods resources) { + YxWechatLiveGoods wechatLiveGoods = this.getById(resources.getGoodsId()); + try { + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + WxMaLiveGoodInfo goods = generator.convert(resources, WxMaLiveGoodInfo.class); + if(ObjectUtil.isNotEmpty(wechatLiveGoods)){ + /** 审核状态 0:未审核,1:审核中,2:审核通过,3审核失败 */ + if(LiveGoodsEnum.IS_Audit_2.getValue().equals(wechatLiveGoods.getAuditStatus())){ + }else if(LiveGoodsEnum.IS_Audit_0.getValue().equals(wechatLiveGoods.getAuditStatus())){ + resources.setCoverImgUrl(uploadPhotoToWx(wxMaService,resources.getCoverImgeUrl()).getMediaId()); + }else if(LiveGoodsEnum.IS_Audit_1.getValue().equals(wechatLiveGoods.getAuditStatus())){ + throw new BadRequestException("商品审核中不允许修改"); + }else if(LiveGoodsEnum.IS_Audit_3.getValue().equals(wechatLiveGoods.getAuditStatus())){ + resources.setCoverImgUrl(uploadPhotoToWx(wxMaService,resources.getCoverImgeUrl()).getMediaId()); + wxMaService.getLiveGoodsService().updateGoods(goods); + wxMaService.getLiveGoodsService().auditGoods(goods.getGoodsId()); + return; + } + } + + boolean wxMaLiveResult = wxMaService.getLiveGoodsService().updateGoods(goods); + this.saveOrUpdate(resources); + } catch (WxErrorException e) { + throw new BadRequestException(e.toString()); + } + } + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + @Override + //@Cacheable + public Map queryAll(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + List goodsDtos = generator.convert(page.getList(), YxWechatLiveGoodsDto.class); + goodsDtos.forEach(i ->{ + i.setId(i.getGoodsId()); + }); + map.put("content",goodsDtos); + map.put("totalElements", page.getTotal()); + return map; + } + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + @Override + //@Cacheable + public List queryAll(YxWechatLiveGoodsQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatLiveGoods.class, criteria)); + } + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxWechatLiveGoodsDto yxWechatLiveGoods : all) { + Map map = new LinkedHashMap<>(); + map.put("关联商品id", yxWechatLiveGoods.getProductId()); + map.put("商品图片", yxWechatLiveGoods.getCoverImgeUrl()); + map.put("商品小程序路径", yxWechatLiveGoods.getUrl()); + map.put("价格类型 1:一口价(只需要传入price,price2不传) 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传) 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传)", yxWechatLiveGoods.getPriceType()); + map.put(" price", yxWechatLiveGoods.getPrice()); + map.put(" price2", yxWechatLiveGoods.getPrice2()); + map.put("商品名称", yxWechatLiveGoods.getName()); + map.put("1, 2:表示是为api添加商品,否则是直播控制台添加的商品", yxWechatLiveGoods.getThirdPartyTag()); + map.put("审核单id", yxWechatLiveGoods.getAuditId()); + map.put("审核状态 0:未审核,1:审核中,2:审核通过,3审核失败", yxWechatLiveGoods.getAuditStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 保存直播商品信息 + * @param resources + * @return + */ + @Override + public boolean saveGoods(YxWechatLiveGoods resources) { + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + try { + resources.setCoverImgUrl(uploadPhotoToWx(wxMaService,resources.getCoverImgeUrl()).getMediaId()); + WxMaLiveGoodInfo goods = generator.convert(resources, WxMaLiveGoodInfo.class); + WxMaLiveResult wxMaLiveResult = wxMaService.getLiveGoodsService().addGoods(goods); + resources.setGoodsId(Long.valueOf(wxMaLiveResult.getGoodsId())); + resources.setAuditId(Long.valueOf(wxMaLiveResult.getAuditId())); + this.save(resources); + } catch (WxErrorException e) { + throw new BadRequestException(e.toString()); + } + return true; + } + + /** + * 上传临时素材 + * @param wxMaService WxMaService + * @param picPath 图片路径 + * @return WxMpMaterialUploadResult + * @throws WxErrorException + */ + private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException { + String filename = (int) System.currentTimeMillis() + ".png"; + String downloadPath = uploadDirStr + filename; + long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath)); + picPath = downloadPath; + File picFile = new File( picPath ); + log.info( "picFile name : {}", picFile.getName() ); + WxMediaUploadResult wxMediaUploadResult = wxMaService.getMediaService().uploadMedia( WxConsts.MediaFileType.IMAGE, picFile ); + log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMediaUploadResult ) ); + return wxMediaUploadResult; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveServiceImpl.java new file mode 100644 index 00000000..e1b8f69a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatLiveServiceImpl.java @@ -0,0 +1,285 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +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.exception.BadRequestException; +import co.yixiang.modules.mp.domain.YxWechatLiveGoods; +import co.yixiang.modules.mp.service.YxWechatLiveGoodsService; +import co.yixiang.modules.mp.service.YxWechatLiveService; +import co.yixiang.modules.mp.service.dto.*; +import co.yixiang.modules.mp.service.mapper.YxWechatLiveMapper; +import co.yixiang.modules.mp.vo.WechatLiveVo; +import co.yixiang.modules.mp.domain.YxWechatLive; +import co.yixiang.modules.mp.config.WxMaConfiguration; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.OrderUtil; +import co.yixiang.utils.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.google.gson.JsonObject; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room.CREATE_ROOM; + + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@Service +//@CacheConfig(cacheNames = "yxWechatLive") +@Slf4j +@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class) +public class YxWechatLiveServiceImpl extends BaseServiceImpl implements YxWechatLiveService { + + private final IGenerator generator; + + private String uploadDirStr = ""; + private final YxWechatLiveGoodsService wechatLiveGoodsService; + + private final YxWechatLiveMapper wechatLiveMapper; + + public YxWechatLiveServiceImpl(IGenerator generator, YxWechatLiveGoodsService wechatLiveGoodsService, YxWechatLiveMapper wechatLiveMapper) { + this.generator = generator; + this.wechatLiveGoodsService = wechatLiveGoodsService; + this.wechatLiveMapper = wechatLiveMapper; + } + + /** + * 同步直播间 + * @return + */ + //@Cacheable + @Override + public boolean synchroWxOlLive() { + try { + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + List liveInfos = wxMaService.getLiveService().getLiveInfos(); + List convert = generator.convert(liveInfos, YxWechatLive.class); + this.saveOrUpdateBatch(convert); + } catch (WxErrorException e) { + e.printStackTrace(); + } + return true; + } + @Override + //@Cacheable + public WechatLiveVo queryAll(YxWechatLiveQueryCriteria criteria, Pageable pageable) { + String order=null; + if(pageable.getSort()!=null){ + order= pageable.getSort().toString(); + order=order.replace(":",""); + if("UNSORTED".equals(order)){ + order="start_time desc"; + } + } + PageHelper.startPage(pageable.getPageNumber()+1, pageable.getPageSize(),order); + PageInfo page = new PageInfo<>(queryAll(criteria)); + WechatLiveVo wechatLiveVo = new WechatLiveVo(); +// List liveInfos = wxMaLiveService.getLiveInfos(); + List liveDtos = generator.convert(page.getList(), YxWechatLiveDto.class); + //获取所有商品 + liveDtos.forEach(i ->{ + if(StringUtils.isNotBlank(i.getProductId())){ + List wechatLiveGoodsDtos = generator.convert( + wechatLiveGoodsService.list(new LambdaQueryWrapper().in(YxWechatLiveGoods::getGoodsId,i.getProductId().split(","))) + ,YxWechatLiveGoodsDto.class); + i.setProduct(wechatLiveGoodsDtos); + } + i.setId(i.getRoomId()); + }); + wechatLiveVo.setContent(liveDtos); + wechatLiveVo.setTotalElements(page.getTotal()); + wechatLiveVo.setPageNumber(page.getPageNum()); + wechatLiveVo.setLastPage(page.getPages()); + return wechatLiveVo; + } + + @Override + public boolean addGoods(UpdateGoodsDto resources) { + YxWechatLive wechatLive = new YxWechatLive(); + + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + if(StringUtils.isNotBlank(resources.getProductId())){ + wechatLive.setRoomId(Long.valueOf(resources.getRoomId())); + wechatLive.setProductId(resources.getProductId()); + String[] productIds = resources.getProductId().split(","); + List pids = new ArrayList<>(); + for (String productId : productIds) { + pids.add(Integer.valueOf(productId)); + } + //添加商品 + try { + wxMaService.getLiveService().addGoodsToRoom(resources.getRoomId().intValue(), pids); + this.saveOrUpdate(wechatLive); + } catch (WxErrorException e) { + e.printStackTrace(); + } + } + return true; + } + @Override + public boolean saveLive(YxWechatLive resources){ + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + try { + resources.setFeedsImg(uploadPhotoToWx(wxMaService,resources.getFeedsImg()).getMediaId()); + resources.setStartTime(Long.valueOf(OrderUtil.dateToTimestamp(resources.getStartDate()))); + resources.setEndTime(Long.valueOf(OrderUtil.dateToTimestamp(resources.getEndDate()))); + resources.setAnchorImg(uploadPhotoToWx(wxMaService,resources.getAnchorImge()).getMediaId()); + resources.setCoverImg(uploadPhotoToWx(wxMaService,resources.getCoverImge()).getMediaId()); + resources.setShareImg(uploadPhotoToWx(wxMaService,resources.getShareImge()).getMediaId()); + WxMaLiveInfo.RoomInfo roomInfo = generator.convert(resources, WxMaLiveInfo.RoomInfo.class); + Integer status = this.createRoom(roomInfo); + resources.setRoomId(Long.valueOf(status)); + if(StringUtils.isNotBlank(resources.getProductId())){ + String[] productIds = resources.getProductId().split(","); + List pids = new ArrayList<>(); + for (String productId : productIds) { + pids.add(Integer.valueOf(productId)); + } + //添加商品 + wxMaService.getLiveService().addGoodsToRoom(status, pids); + } + this.save(resources); + } catch (WxErrorException e) { + e.printStackTrace(); + throw new BadRequestException(e.toString()); + } + return false; + } + + @Override + //@Cacheable + public List queryAll(YxWechatLiveQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatLive.class, criteria)); + } + + @Override + //@Cacheable + public List getLiveReplay(Integer roomId){ + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + WxMaLiveResult get_replay = new WxMaLiveResult(); + try { + get_replay = wxMaService.getLiveService().getLiveReplay("get_replay", roomId, 0, 100); + } catch (WxErrorException e) { + e.printStackTrace(); + } + return get_replay.getLiveReplay(); + } + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxWechatLiveDto yxWechatLive : all) { + Map map = new LinkedHashMap<>(); + map.put("直播间标题", yxWechatLive.getName()); + map.put("背景图", yxWechatLive.getCoverImge()); + map.put("分享图片", yxWechatLive.getShareImge()); + map.put("直播间状态", yxWechatLive.getLiveStatus()); + map.put("开始时间", yxWechatLive.getStartTime()); + map.put("预计结束时间", yxWechatLive.getEndTime()); + map.put("主播昵称", yxWechatLive.getAnchorName()); + map.put("主播微信号", yxWechatLive.getAnchorWechat()); + map.put("主播头像", yxWechatLive.getAnchorImge()); + map.put("直播间类型 1:推流 0:手机直播", yxWechatLive.getType()); + map.put("横屏、竖屏 【1:横屏,0:竖屏】", yxWechatLive.getScreenType()); + map.put("是否关闭货架 【0:开启,1:关闭】", yxWechatLive.getCloseLike()); + map.put("是否关闭评论 【0:开启,1:关闭】", yxWechatLive.getCloseComment()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + + @Override + public Integer createRoom(WxMaLiveInfo.RoomInfo roomInfo) throws WxErrorException { + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); + String responseContent = wxMaService.post(CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo)); + JsonObject jsonObject = GsonParser.parse(responseContent); + if (jsonObject.get("errcode").getAsInt() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return jsonObject.get("roomId").getAsInt(); + } + /** + * 上传临时素材 + * @param wxMaService WxMaService + * @param picPath 图片路径 + * @return WxMpMaterialUploadResult + * @throws WxErrorException + */ + private WxMediaUploadResult uploadPhotoToWx(WxMaService wxMaService, String picPath) throws WxErrorException { + String filename = (int) System.currentTimeMillis() + ".png"; + String downloadPath = uploadDirStr + filename; + long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath)); + picPath = downloadPath; + File picFile = new File( picPath ); + log.info( "picFile name : {}", picFile.getName() ); + WxMediaUploadResult wxMediaUploadResult = wxMaService.getMediaService().uploadMedia( WxConsts.MediaFileType.IMAGE, picFile ); + log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMediaUploadResult ) ); + return wxMediaUploadResult; + } + + + /** + * 直播间列表 + * @param page 页码 + * @param limit 条数 + * @param order ProductEnum + * @return List + */ + @Override + public List getList(int page, int limit, int order) { + //todo 添加状态判断 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.orderByDesc(YxWechatLive::getStartTime); + + + Page pageModel = new Page<>(page, limit); + + IPage pageList = wechatLiveMapper.selectPage(pageModel,wrapper); + + + return generator.convert(pageList.getRecords(),YxWechatLiveDto.class); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatMenuServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatMenuServiceImpl.java new file mode 100644 index 00000000..bf8ce1a3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatMenuServiceImpl.java @@ -0,0 +1,89 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.mp.service.mapper.WechatMenuMapper; +import co.yixiang.modules.mp.domain.YxWechatMenu; +import co.yixiang.modules.mp.service.YxWechatMenuService; +import co.yixiang.modules.mp.service.dto.YxWechatMenuDto; +import co.yixiang.modules.mp.service.dto.YxWechatMenuQueryCriteria; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxWechatMenu") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxWechatMenuServiceImpl extends BaseServiceImpl implements YxWechatMenuService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxWechatMenuQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxWechatMenuDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxWechatMenuQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatMenu.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxWechatMenuDto yxWechatMenu : all) { + Map map = new LinkedHashMap<>(); + map.put("缓存数据", yxWechatMenu.getResult()); + map.put("缓存时间", yxWechatMenu.getAddTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public Boolean isExist(String wechat_menus) { + YxWechatMenu yxWechatMenu = this.getOne(new LambdaQueryWrapper() + .eq(YxWechatMenu::getKey,wechat_menus)); + if(yxWechatMenu == null){ + return false; + } + return true; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatReplyServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatReplyServiceImpl.java new file mode 100644 index 00000000..0b407d1f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatReplyServiceImpl.java @@ -0,0 +1,110 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.EntityExistException; +import co.yixiang.modules.mp.service.mapper.WechatReplyMapper; +import co.yixiang.modules.mp.domain.YxWechatReply; +import co.yixiang.modules.mp.service.YxWechatReplyService; +import co.yixiang.modules.mp.service.dto.YxWechatReplyDto; +import co.yixiang.modules.mp.service.dto.YxWechatReplyQueryCriteria; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxWechatReply") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxWechatReplyServiceImpl extends BaseServiceImpl implements YxWechatReplyService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxWechatReplyQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxWechatReplyDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxWechatReplyQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatReply.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxWechatReplyDto yxWechatReply : all) { + Map map = new LinkedHashMap<>(); + map.put("关键字", yxWechatReply.getKey()); + map.put("回复类型", yxWechatReply.getType()); + map.put("回复数据", yxWechatReply.getData()); + map.put("0=不可用 1 =可用", yxWechatReply.getStatus()); + map.put("是否隐藏", yxWechatReply.getHide()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public YxWechatReply isExist(String key) { + YxWechatReply yxWechatReply = this.getOne(new LambdaQueryWrapper() + .eq(YxWechatReply::getKey,key)); + return yxWechatReply; + } + + @Override + public void create(YxWechatReply yxWechatReply) { + if(this.isExist(yxWechatReply.getKey()) != null){ + throw new EntityExistException(YxWechatReply.class,"key",yxWechatReply.getKey()); + } + this.save(yxWechatReply); + } + + @Override + public void upDate(YxWechatReply resources) { + YxWechatReply yxWechatReply = this.getById(resources.getId()); + YxWechatReply yxWechatReply1; + yxWechatReply1 = this.isExist(resources.getKey()); + if(yxWechatReply1 != null && !yxWechatReply1.getId().equals(yxWechatReply.getId())){ + throw new EntityExistException(YxWechatReply.class,"key",resources.getKey()); + } + yxWechatReply.copy(resources); + this.saveOrUpdate(yxWechatReply); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatTemplateServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatTemplateServiceImpl.java new file mode 100644 index 00000000..4ff0b5a9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/impl/YxWechatTemplateServiceImpl.java @@ -0,0 +1,89 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.mp.domain.YxWechatTemplate; +import co.yixiang.modules.mp.service.YxWechatTemplateService; +import co.yixiang.modules.mp.service.dto.YxWechatTemplateQueryCriteria; +import co.yixiang.modules.mp.service.dto.YxWechatTemplateDto; +import co.yixiang.modules.mp.service.mapper.WechatTemplateMapper; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxWechatTemplate") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxWechatTemplateServiceImpl extends BaseServiceImpl implements YxWechatTemplateService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxWechatTemplateQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxWechatTemplateDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxWechatTemplateQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxWechatTemplate.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxWechatTemplateDto yxWechatTemplate : all) { + Map map = new LinkedHashMap<>(); + map.put("模板编号", yxWechatTemplate.getTempkey()); + map.put("模板名", yxWechatTemplate.getName()); + map.put("回复内容", yxWechatTemplate.getContent()); + map.put("模板ID", yxWechatTemplate.getTempid()); + map.put("添加时间", yxWechatTemplate.getAddTime()); + map.put("状态", yxWechatTemplate.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public YxWechatTemplate findByTempkey(String recharge_success_key) { + return this.getOne(new LambdaQueryWrapper() + .eq(YxWechatTemplate::getTempkey,recharge_success_key)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/ArticleMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/ArticleMapper.java new file mode 100644 index 00000000..2e74acaa --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/ArticleMapper.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.mp.domain.YxArticle; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface ArticleMapper extends CoreMapper { + @Update("update yx_article set visit=visit+1 " + + "where id=#{id}") + int incVisitNum(@Param("id") int id); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatMenuMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatMenuMapper.java new file mode 100644 index 00000000..c10f665e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatMenuMapper.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.mp.domain.YxWechatMenu; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface WechatMenuMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatReplyMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatReplyMapper.java new file mode 100644 index 00000000..fe840482 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatReplyMapper.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.mp.domain.YxWechatReply; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface WechatReplyMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatTemplateMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatTemplateMapper.java new file mode 100644 index 00000000..e9ac0079 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/WechatTemplateMapper.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.mp.domain.YxWechatTemplate; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface WechatTemplateMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/YxWechatLiveGoodsMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/YxWechatLiveGoodsMapper.java new file mode 100644 index 00000000..398c4717 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/YxWechatLiveGoodsMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.mp.domain.YxWechatLiveGoods; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-08-11 +*/ +@Repository +public interface YxWechatLiveGoodsMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/YxWechatLiveMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/YxWechatLiveMapper.java new file mode 100644 index 00000000..3726e1c7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/mapper/YxWechatLiveMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.mp.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.mp.domain.YxWechatLive; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@Repository +public interface YxWechatLiveMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/JsonUtils.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/JsonUtils.java new file mode 100644 index 00000000..09d1670d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/JsonUtils.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.utils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public class JsonUtils { + public static String toJson(Object obj) { + Gson gson = new GsonBuilder() + .setPrettyPrinting() + .create(); + return gson.toJson(obj); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/URLUtils.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/URLUtils.java new file mode 100644 index 00000000..57a387fe --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/URLUtils.java @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.mp.utils; + +import java.util.HashMap; +import java.util.Map; + +/** + * URLUtils + * @author Kevin + * @date 2019-03-20 13:39 + */ +public class URLUtils { + + /** + * 获取URL中的某个参数 + * @param url + * @param name + * @return + */ + public static String getParam(String url, String name) { + return urlSplit(url).get( name ); + } + + /** + * 去掉url中的路径,留下请求参数部分 + * @param strURL url地址 + * @return url请求参数部分 + */ + private static String truncateUrlPage(String strURL){ + String strAllParam=null; + String[] arrSplit=null; + strURL=strURL.trim().toLowerCase(); + arrSplit=strURL.split("[?]"); + if(strURL.length()>1){ + if(arrSplit.length>1){ + for (int i=1;i urlSplit(String URL){ + Map mapRequest = new HashMap(); + String[] arrSplit=null; + String strUrlParam= truncateUrlPage(URL); + if(strUrlParam==null){ + return mapRequest; + } + arrSplit=strUrlParam.split("[&]"); + for(String strSplit:arrSplit){ + String[] arrSplitEqual=null; + arrSplitEqual= strSplit.split("[=]"); + //解析出键值 + if(arrSplitEqual.length>1){ + //正确解析 + mapRequest.put(arrSplitEqual[0], arrSplitEqual[1]); + }else{ + if(arrSplitEqual[0]!=""){ + //只有参数没有值,不加入 + mapRequest.put(arrSplitEqual[0], ""); + } + } + } + return mapRequest; + } + + +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/YshopUtils.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/YshopUtils.java new file mode 100644 index 00000000..d2b08186 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/utils/YshopUtils.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.mp.utils; + + +import co.yixiang.modules.user.service.dto.WechatUserDto; +import com.alibaba.fastjson.JSONObject; + +/** + * @ClassName YshopUtils + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/27 + **/ +public class YshopUtils { + public static WechatUserDto getWechtUser(String str) { + return JSONObject.parseObject(str,WechatUserDto.class); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/vo/WechatLiveVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/vo/WechatLiveVo.java new file mode 100644 index 00000000..a06901e0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/vo/WechatLiveVo.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.mp.vo; + +import co.yixiang.modules.mp.service.dto.YxWechatLiveDto; +import lombok.Data; + +import java.util.List; + +@Data +public class WechatLiveVo { + + private List content; + + private Long totalElements; + + private Integer pageNumber; + + private Integer lastPage; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/vo/YxArticleQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/vo/YxArticleQueryVo.java new file mode 100644 index 00000000..1d459621 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/vo/YxArticleQueryVo.java @@ -0,0 +1,65 @@ +package co.yixiang.modules.mp.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 文章管理表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-02 + */ +@Data +@ApiModel(value = "YxArticleQueryVo对象", description = "文章管理表查询参数") +public class YxArticleQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "文章管理ID") + private Integer id; + + @ApiModelProperty(value = "文章标题") + private String title; + + @ApiModelProperty(value = "文章作者") + private String author; + + @ApiModelProperty(value = "文章图片") + private String imageInput; + + @ApiModelProperty(value = "文章简介") + private String synopsis; + + @ApiModelProperty(value = "文章分享标题") + private String shareTitle; + + @ApiModelProperty(value = "文章分享简介") + private String shareSynopsis; + + @ApiModelProperty(value = "浏览次数") + private String visit; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "原文链接") + private String url; + + @ApiModelProperty(value = "状态") + private Boolean status; + + @ApiModelProperty(value = "添加时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + @JsonProperty(value = "addTime") + private String createTime; + + @ApiModelProperty(value = "文章内容") + private String content; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxExpress.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxExpress.java new file mode 100644 index 00000000..04befbe0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxExpress.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_express") +public class YxExpress extends BaseDomain { + + /** 快递公司id */ + @TableId + private Integer id; + + + /** 快递公司简称 */ + @NotBlank(message = "请输入快递公司编号") + private String code; + + + /** 快递公司全称 */ + @NotBlank(message = "请输入快递公司名称") + private String name; + + + /** 排序 */ + private Integer sort; + + + /** 是否显示 */ + private Integer isShow; + + + public void copy(YxExpress source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrder.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrder.java new file mode 100644 index 00000000..357b9c54 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrder.java @@ -0,0 +1,246 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName("yx_store_order") +public class YxStoreOrder extends BaseDomain { + + /** 订单ID */ + @TableId + private Long id; + + + /** 订单号 */ + private String orderId; + + + /** 额外订单号 */ + private String extendOrderId; + + + /** 用户id */ + private Long uid; + + + /** 用户姓名 */ + private String realName; + + + /** 用户电话 */ + private String userPhone; + + + /** 详细地址 */ + private String userAddress; + + + /** 购物车id */ + private String cartId; + + + /** 运费金额 */ + private BigDecimal freightPrice; + + + /** 订单商品总数 */ + private Integer totalNum; + + + /** 订单总价 */ + private BigDecimal totalPrice; + + + /** 邮费 */ + private BigDecimal totalPostage; + + + /** 实际支付金额 */ + private BigDecimal payPrice; + + + /** 支付邮费 */ + private BigDecimal payPostage; + + + /** 抵扣金额 */ + private BigDecimal deductionPrice; + + + /** 优惠券id */ + private Integer couponId; + + + /** 优惠券金额 */ + private BigDecimal couponPrice; + + + /** 支付状态 */ + private Integer paid; + + + /** 支付时间 */ + private Date payTime; + + + /** 支付方式 */ + private String payType; + + + /** 订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款) */ + private Integer status; + + + /** 0 未退款 1 申请中 2 已退款 */ + private Integer refundStatus; + + + /** 退款图片 */ + private String refundReasonWapImg; + + + /** 退款用户说明 */ + private String refundReasonWapExplain; + + + /** 退款时间 */ + private Date refundReasonTime; + + + /** 前台退款原因 */ + private String refundReasonWap; + + + /** 不退款的理由 */ + private String refundReason; + + + /** 退款金额 */ + private BigDecimal refundPrice; + + + /** 快递公司编号 */ + private String deliverySn; + + + /** 快递名称/送货人姓名 */ + private String deliveryName; + + + /** 发货类型 */ + private String deliveryType; + + + /** 快递单号/手机号 */ + private String deliveryId; + + + /** 消费赚取积分 */ + private BigDecimal gainIntegral; + + + /** 使用积分 */ + private BigDecimal useIntegral; + + + /** 给用户退了多少积分 */ + private BigDecimal backIntegral; + + + /** 备注 */ + private String mark; + + + + /** 唯一id(md5加密)类似id */ + @TableField(value = "`unique`") + private String unique; + + + /** 管理员备注 */ + private String remark; + + + /** 商户ID */ + private Integer merId; + + + private Integer isMerCheck; + + + /** 拼团产品id0一般产品 */ + private Long combinationId; + + + /** 拼团id 0没有拼团 */ + private Long pinkId; + + + /** 成本价 */ + private BigDecimal cost; + + + /** 秒杀产品ID */ + private Long seckillId; + + + /** 砍价id */ + private Long bargainId; + + + /** 核销码 */ + private String verifyCode; + + + /** 门店id */ + private Integer storeId; + + + /** 配送方式 1=快递 ,2=门店自提 */ + private Integer shippingType; + + + /** 支付渠道(0微信公众号1微信小程序) */ + private Integer isChannel; + + + private Integer isRemind; + + + private Integer isSystemDel; + + @ApiModelProperty(value = "实际支付积分") + private BigDecimal payIntegral; + + public void copy(YxStoreOrder source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java new file mode 100644 index 00000000..0ea9ea74 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@TableName("yx_store_order_cart_info") +public class YxStoreOrderCartInfo implements Serializable { + + @TableId + private Long id; + + + /** 订单id */ + private Long oid; + + /** + * 订单号 + */ + private String orderId; + + + /** 购物车id */ + private Long cartId; + + + /** 商品ID */ + private Long productId; + + + /** 购买东西的详细信息 */ + private String cartInfo; + + + /** 唯一id */ + @TableField(value = "`unique`") + private String unique; + + /** 是否能售后0不能1能 */ + private Integer isAfterSales; + + + public void copy(YxStoreOrderCartInfo source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderStatus.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderStatus.java new file mode 100644 index 00000000..34b3fae0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderStatus.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@TableName("yx_store_order_status") +public class YxStoreOrderStatus implements Serializable { + + @TableId + private Long id; + + + /** 订单id */ + private Long oid; + + + /** 操作类型 */ + private String changeType; + + + /** 操作备注 */ + private String changeMessage; + + + /** 操作时间 */ + private Date changeTime; + + + public void copy(YxStoreOrderStatus source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/param/ExpressParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/param/ExpressParam.java new file mode 100644 index 00000000..5b3ee5dc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/param/ExpressParam.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName ExpressParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/9 + **/ +@Data +public class ExpressParam implements Serializable { + + @ApiModelProperty(value = "订单编号") + private String orderCode; + + @ApiModelProperty(value = "快递公司编码") + private String shipperCode; + + @ApiModelProperty(value = "物流单号") + private String logisticCode; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/param/OrderParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/param/OrderParam.java new file mode 100644 index 00000000..64aa34cb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/param/OrderParam.java @@ -0,0 +1,65 @@ +package co.yixiang.modules.order.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * @ClassName OrderParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/28 + **/ +@Data +public class OrderParam implements Serializable { + + @ApiModelProperty(value = "地址ID") + private String addressId; + + @ApiModelProperty(value = "砍价产品ID") + private String bargainId; + + @ApiModelProperty(value = "拼团ID") + private String combinationId; + + @ApiModelProperty(value = "优惠券ID") + private String couponId; + + @ApiModelProperty(value = "来源") + private String from; + + @Size(max = 200,message = "长度超过了限制") + @ApiModelProperty(value = "备注") + private String mark; + + @NotBlank(message="请选择支付方式") + @ApiModelProperty(value = "支付方式") + private String payType; + + @ApiModelProperty(value = "门店电话") + private String phone; + + @ApiModelProperty(value = "拼团id 0没有拼团") + private String pinkId; + + @ApiModelProperty(value = "门店联系人") + private String realName; + + @ApiModelProperty(value = "秒杀产品ID") + private String seckillId; + + @ApiModelProperty(value = "配送方式 1=快递 ,2=门店自提") + private String shippingType; + + @ApiModelProperty(value = "使用积分 1-表示使用") + private String useIntegral; + + @ApiModelProperty(value = "支付渠道(0微信公众号1微信小程序) ") + private String isChannel; + + @ApiModelProperty(value = "门店ID") + private String storeId; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java new file mode 100644 index 00000000..b3c3fe43 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java @@ -0,0 +1,465 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.rest; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.OrderLogEnum; +import co.yixiang.enums.ShipperCodeEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderStatus; +import co.yixiang.modules.order.param.ExpressParam; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.YxStoreOrderStatusService; +import co.yixiang.modules.order.service.dto.*; +import co.yixiang.tools.express.ExpressService; +import co.yixiang.tools.express.config.ExpressAutoConfiguration; +import co.yixiang.tools.express.dao.ExpressInfo; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author hupeng + * @date 2019-10-14 + */ +@Api(tags = "商城:订单管理") +@RestController +@RequestMapping("api") +@Slf4j +@SuppressWarnings("unchecked") +public class StoreOrderController { + + @Value("${yshop.apiUrl}") + private String apiUrl; + + private final IGenerator generator; + private final YxStoreOrderService yxStoreOrderService; + private final YxStoreOrderStatusService yxStoreOrderStatusService; + + + public StoreOrderController(IGenerator generator, YxStoreOrderService yxStoreOrderService, + YxStoreOrderStatusService yxStoreOrderStatusService) { + this.generator = generator; + this.yxStoreOrderService = yxStoreOrderService; + this.yxStoreOrderStatusService = yxStoreOrderStatusService; + } + + /**@Valid + * 根据商品分类统计订单占比 + */ + @GetMapping("/yxStoreOrder/orderCount") + @ApiOperation(value = "根据商品分类统计订单占比",notes = "根据商品分类统计订单占比",response = ExpressParam.class) + public ResponseEntity orderCount(){ + OrderCountDto orderCountDto = yxStoreOrderService.getOrderCount(); + return new ResponseEntity<>(orderCountDto, HttpStatus.OK); + } + + /** + * 首页订单/用户等统计 + * @return OrderTimeDataDto + */ + @GetMapping(value = "/data/count") + @AnonymousAccess + public ResponseEntity getCount() { + return new ResponseEntity<>(yxStoreOrderService.getOrderTimeData(), HttpStatus.OK); + } + + /** + * 返回本月订单金额与数量chart + * @return map + */ + @GetMapping(value = "/data/chart") + @AnonymousAccess + public ResponseEntity getChart() { + return new ResponseEntity<>(yxStoreOrderService.chartCount(), HttpStatus.OK); + } + + + @ApiOperation(value = "查询订单") + @GetMapping(value = "/yxStoreOrder") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_SELECT','YXEXPRESS_SELECT')") + public ResponseEntity getYxStoreOrders(YxStoreOrderQueryCriteria criteria, + Pageable pageable, + @RequestParam(name = "orderStatus") String orderStatus, + @RequestParam(name = "orderType") String orderType) { + + YxStoreOrderQueryCriteria newCriteria = this.handleQuery(criteria,orderStatus,orderType); + + return new ResponseEntity<>(yxStoreOrderService.queryAll(newCriteria, pageable), HttpStatus.OK); + } + + @ApiOperation(value = "根据订单id获取订单详情") + @GetMapping(value = "/getStoreOrderDetail/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_SELECT','YXEXPRESS_SELECT')") + public ResponseEntity getYxStoreOrders(@PathVariable Long id) { + return new ResponseEntity<>(yxStoreOrderService.getOrderDetail(id), HttpStatus.OK); + } + @ApiOperation(value = "查询订单当前状态流程") + @GetMapping(value = "/getNowOrderStatus/{id}") + public ResponseEntity getNowOrderStatus(@PathVariable Long id) { + List statusList = new ArrayList<>(); + statusList.add(OrderLogEnum.CREATE_ORDER.getValue()); + statusList.add(OrderLogEnum.PAY_ORDER_SUCCESS.getValue()); + statusList.add(OrderLogEnum.DELIVERY_GOODS.getValue()); + statusList.add(OrderLogEnum.TAKE_ORDER_DELIVERY.getValue()); + statusList.add(OrderLogEnum.EVAL_ORDER.getValue()); + List orderStatusLogList = yxStoreOrderStatusService.list(new LambdaQueryWrapper().eq(YxStoreOrderStatus::getOid, id).in(YxStoreOrderStatus::getChangeType, statusList).orderByDesc(YxStoreOrderStatus::getChangeTime)); + List dtoList = getOrderStatusDto(orderStatusLogList); + YxOrderNowOrderStatusDto yxOrderNowOrderStatusDto = new YxOrderNowOrderStatusDto(); + yxOrderNowOrderStatusDto.setSize(dtoList.size()); + dtoList.forEach(dto -> { + if (OrderLogEnum.CREATE_ORDER.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setCacheKeyCreateOrder(dto.getChangeTime()); + } + if (OrderLogEnum.PAY_ORDER_SUCCESS.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setPaySuccess(dto.getChangeTime()); + } + if (OrderLogEnum.DELIVERY_GOODS.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setDeliveryGoods(dto.getChangeTime()); + } + if (OrderLogEnum.TAKE_ORDER_DELIVERY.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setUserTakeDelivery(dto.getChangeTime()); + yxOrderNowOrderStatusDto.setOrderVerific(dto.getChangeTime()); + } + if (OrderLogEnum.EVAL_ORDER.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setCheckOrderOver(dto.getChangeTime()); + } + }); + + + statusList = new ArrayList<>(); + statusList.add(OrderLogEnum.REFUND_ORDER_APPLY.getValue()); + statusList.add(OrderLogEnum.REFUND_ORDER_SUCCESS.getValue()); + orderStatusLogList = yxStoreOrderStatusService.list(new LambdaQueryWrapper().eq(YxStoreOrderStatus::getOid, id).in(YxStoreOrderStatus::getChangeType, statusList).orderByDesc(YxStoreOrderStatus::getChangeTime)); + dtoList = getOrderStatusDto(orderStatusLogList); + dtoList.forEach(dto -> { + if (OrderLogEnum.REFUND_ORDER_APPLY.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setApplyRefund(dto.getChangeTime()); + } + if (OrderLogEnum.REFUND_ORDER_SUCCESS.getDesc().equals(dto.getChangeType())) { + yxOrderNowOrderStatusDto.setRefundOrderSuccess(dto.getChangeTime()); + } + + }); + + return new ResponseEntity(yxOrderNowOrderStatusDto, HttpStatus.OK); + } + public List getOrderStatusDto(List orderStatusLogList) { + List dtoList = orderStatusLogList.stream().map(log -> { + YxStoreOrderStatusDto dto = generator.convert(log, YxStoreOrderStatusDto.class); + dto.setChangeType(OrderLogEnum.getDesc(dto.getChangeType())); + dto.setChangeTime(log.getChangeTime()); + return dto; + }).collect(Collectors.toList()); + return dtoList; + } + @ApiOperation(value = "发货") + @PutMapping(value = "/yxStoreOrder") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreOrder resources) { + if (StrUtil.isBlank(resources.getDeliveryName())) { + throw new BadRequestException("请选择快递公司"); + } + if (StrUtil.isBlank(resources.getDeliveryId())) { + throw new BadRequestException("快递单号不能为空"); + } + + yxStoreOrderService.orderDelivery(resources.getOrderId(),resources.getDeliveryId(), + resources.getDeliveryName(),resources.getDeliveryType()); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ApiOperation(value = "修改快递单号") + @PutMapping(value = "/yxStoreOrder/updateDelivery") + @PreAuthorize("hasAnyAuthority('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')") + public ResponseEntity updateDelivery(@Validated @RequestBody YxStoreOrder resources) { + if (StrUtil.isBlank(resources.getDeliveryName())) { + throw new BadRequestException("请选择快递公司"); + } + if (StrUtil.isBlank(resources.getDeliveryId())) { + throw new BadRequestException("快递单号不能为空"); + } + + yxStoreOrderService.updateDelivery(resources.getOrderId(),resources.getDeliveryId(), + resources.getDeliveryName(),resources.getDeliveryType()); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + + + @ApiOperation(value = "订单核销") + @PutMapping(value = "/yxStoreOrder/check") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')") + public ResponseEntity check(@Validated @RequestBody YxStoreOrder resources) { + if (StrUtil.isBlank(resources.getVerifyCode())) { + throw new BadRequestException("核销码不能为空"); + } + YxStoreOrderDto storeOrderDTO = generator.convert(yxStoreOrderService.getById(resources.getId()),YxStoreOrderDto.class); + if(!resources.getVerifyCode().equals(storeOrderDTO.getVerifyCode())){ + throw new BadRequestException("核销码不对"); + } + if(OrderInfoEnum.PAY_STATUS_0.getValue().equals(storeOrderDTO.getPaid())){ + throw new BadRequestException("订单未支付"); + } + + yxStoreOrderService.verifyOrder(resources.getVerifyCode(), + OrderInfoEnum.CONFIRM_STATUS_1.getValue(),null); + + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + + @ApiOperation(value = "退款") + @PostMapping(value = "/yxStoreOrder/refund") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')") + public ResponseEntity refund(@Validated @RequestBody YxStoreOrder resources) { + yxStoreOrderService.orderRefund(resources.getOrderId(),resources.getPayPrice(), + ShopCommonEnum.AGREE_1.getValue()); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxStoreOrder/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_DELETE')") + public ResponseEntity delete(@PathVariable Integer id) { + yxStoreOrderService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } + + + @Log("修改订单") + @ApiOperation(value = "修改订单") + @PostMapping(value = "/yxStoreOrder/edit") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')") + public ResponseEntity editOrder(@RequestBody YxStoreOrder resources) { + if (ObjectUtil.isNull(resources.getPayPrice())) { + throw new BadRequestException("请输入支付金额"); + } + if (resources.getPayPrice().doubleValue() < 0) { + throw new BadRequestException("金额不能低于0"); + } + YxStoreOrderDto storeOrder = generator.convert(yxStoreOrderService.getById(resources.getId()),YxStoreOrderDto.class); + //判断金额是否有变动,生成一个额外订单号去支付 + int res = NumberUtil.compare(storeOrder.getPayPrice().doubleValue(), resources.getPayPrice().doubleValue()); + if (res != 0) { + String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr(); + resources.setExtendOrderId(orderSn); + } + + yxStoreOrderService.saveOrUpdate(resources); + + yxStoreOrderStatusService.create(resources.getId(),OrderLogEnum.ORDER_EDIT.getValue(), + "修改订单价格为:" + resources.getPayPrice()); + return new ResponseEntity(HttpStatus.OK); + } + + + @Log("修改订单备注") + @ApiOperation(value = "修改订单备注") + @PostMapping(value = "/yxStoreOrder/remark") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_ALL','YXSTOREORDER_EDIT')") + public ResponseEntity editOrderRemark(@RequestBody YxStoreOrder resources) { + if (StrUtil.isBlank(resources.getRemark())) { + throw new BadRequestException("请输入备注"); + } + yxStoreOrderService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.OK); + } + + + /** + * 快递查询 + */ + @PostMapping("/yxStoreOrder/express") + @ApiOperation(value = "获取物流信息",notes = "获取物流信息",response = ExpressParam.class) + public ResponseEntity express( @RequestBody ExpressParam expressInfoDo){ + + //顺丰轨迹查询处理 + String lastFourNumber = ""; + if (expressInfoDo.getShipperCode().equals(ShipperCodeEnum.SF.getValue())) { + YxStoreOrderDto yxStoreOrderDto; + yxStoreOrderDto = yxStoreOrderService.getOrderDetail(Long.valueOf(expressInfoDo.getOrderCode())); + lastFourNumber = yxStoreOrderDto.getUserPhone(); + if (lastFourNumber.length()==11) { + lastFourNumber = StrUtil.sub(lastFourNumber,lastFourNumber.length(),-4); + } + } + + ExpressService expressService = ExpressAutoConfiguration.expressService(); + ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(), + expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode(),lastFourNumber); + if(!expressInfo.isSuccess()) { + throw new BadRequestException(expressInfo.getReason()); + } + return new ResponseEntity<>(expressInfo, HttpStatus.OK); + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/yxStoreOrder/download") + @PreAuthorize("hasAnyRole('admin','YXSTOREORDER_SELECT')") + public void download(HttpServletResponse response, + YxStoreOrderQueryCriteria criteria, + Pageable pageable, + @RequestParam(name = "orderStatus") String orderStatus, + @RequestParam(name = "orderType") String orderType, + @RequestParam(name = "listContent") String listContent) throws IOException, ParseException { + List list; + if(StringUtils.isEmpty(listContent)){ + list = (List)getYxStoreList(criteria, pageable, orderStatus, orderType).get("content"); + }else { + List idList = JSONArray.parseArray(listContent).toJavaList(String.class); + list = (List)yxStoreOrderService.queryAll(idList).get("content"); + } + yxStoreOrderService.download(list, response); + } + + /** + * 下载数据 + * @param criteria criteria + * @param pageable pageable + * @param orderStatus orderStatus + * @param orderType orderType + * @return Map + */ + private Map getYxStoreList(YxStoreOrderQueryCriteria criteria, + Pageable pageable, + String orderStatus, + String orderType){ + + YxStoreOrderQueryCriteria newCriteria = this.handleQuery(criteria,orderStatus,orderType); + return yxStoreOrderService.queryAll(newCriteria, pageable); + } + + + + /** + * 处理订单查询 + * @param criteria YxStoreOrderQueryCriteria + * @param orderStatus 订单状态 + * @param orderType 订单类型 + * @return YxStoreOrderQueryCriteria + */ + private YxStoreOrderQueryCriteria handleQuery(YxStoreOrderQueryCriteria criteria,String orderStatus, + String orderType){ + + //默认查询所有快递订单 + criteria.setShippingType(OrderInfoEnum.SHIPPIING_TYPE_1.getValue()); + //订单状态查询 + if (StrUtil.isNotEmpty(orderStatus)) { + switch (orderStatus) { + case "0": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_0.getValue()); + criteria.setStatus(OrderInfoEnum.STATUS_0.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + break; + case "1": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + criteria.setStatus(OrderInfoEnum.STATUS_0.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + break; + case "2": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + criteria.setStatus(OrderInfoEnum.STATUS_1.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + break; + case "3": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + criteria.setStatus(OrderInfoEnum.STATUS_2.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + break; + case "4": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + criteria.setStatus(OrderInfoEnum.STATUS_3.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + break; + case "-1": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_1.getValue()); + break; + case "-2": + criteria.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + criteria.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue()); + break; + default: + } + } + //订单类型查询 + if (StrUtil.isNotEmpty(orderType)) { + switch (orderType) { + case "1": + criteria.setBargainId(0); + criteria.setCombinationId(0); + criteria.setSeckillId(0); + break; + case "2": + criteria.setNewCombinationId(0); + break; + case "3": + criteria.setNewSeckillId(0); + break; + case "4": + criteria.setNewBargainId(0); + break; + case "5": + criteria.setShippingType(2); + break; + case "6": + criteria.setPayIntegral(new BigDecimal("0.00")); + break; + default: + } + } + + return criteria; + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxExpressService.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxExpressService.java new file mode 100644 index 00000000..64b4635a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxExpressService.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.order.domain.YxExpress; +import co.yixiang.modules.order.service.dto.YxExpressDto; +import co.yixiang.modules.order.service.dto.YxExpressQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxExpressService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxExpressQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxExpressQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderCartInfoService.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderCartInfoService.java new file mode 100644 index 00000000..9ecc8c44 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderCartInfoService.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.service.dto.YxStoreOrderCartInfoDto; +import co.yixiang.modules.order.service.dto.YxStoreOrderCartInfoQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreOrderCartInfoService extends BaseService{ + + /** + * 添加购物车商品信息 + * @param oid 订单id + * @param orderId 订单号 + * @param cartInfo 购物车信息 + */ + void saveCartInfo(Long oid, String orderId,List cartInfo); + + YxStoreOrderCartInfo findByUni(String unique); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreOrderCartInfoQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreOrderCartInfoQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java new file mode 100644 index 00000000..965b59ea --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java @@ -0,0 +1,302 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.param.OrderParam; +import co.yixiang.modules.order.service.dto.OrderCountDto; +import co.yixiang.modules.order.service.dto.OrderTimeDataDto; +import co.yixiang.modules.order.service.dto.YxStoreOrderDto; +import co.yixiang.modules.order.service.dto.YxStoreOrderQueryCriteria; +import co.yixiang.modules.order.vo.ComputeVo; +import co.yixiang.modules.order.vo.ConfirmOrderVo; +import co.yixiang.modules.order.vo.OrderDataVo; +import co.yixiang.modules.order.vo.ShoperOrderTimeDataVo; +import co.yixiang.modules.order.vo.UserOrderCountVo; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreOrderService extends BaseService{ + + /** + * 订单评价 + * @param orderCartInfo + * @param user user + * @param unique 订单orderCart唯一值 + * @param comment 评论内容 + * @param pics 图片 + * @param productScore 评分 + * @param serviceScore 评分 + */ + void orderComment(YxStoreOrderCartInfo orderCartInfo, YxUser user, String unique, String comment, String pics, String productScore, + String serviceScore); + + /** + * 返回订单确认数据 + * @param yxUser yxUser + * @param cartIds 购物车id + * @return ConfirmOrderVO + */ + ConfirmOrderVo confirmOrder(YxUser yxUser, String cartIds); + + + + /** + * 确认订单退款 + * @param orderId 单号 + * @param price 金额 + * @param type ShopCommonEnum + */ + void orderRefund(String orderId, BigDecimal price, Integer type); + + /** + * 订单发货 + * @param orderId 单号 + * @param deliveryId 快递单号 + * @param deliveryName 快递公司code + * @param deliveryType 快递方式 + */ + void orderDelivery(String orderId,String deliveryId,String deliveryName,String deliveryType); + + /** + * 修改快递单号 + * @param orderId 单号 + * @param deliveryId 快递单号 + * @param deliveryName 快递公司code + * @param deliveryType 快递方式 + */ + void updateDelivery(String orderId,String deliveryId,String deliveryName,String deliveryType); + /** + * 修改订单价格 + * @param orderId 单号 + * @param price 价格 + */ + void editOrderPrice(String orderId,String price); + + /** + * 订单每月统计数据 + * @param page page + * @param limit list + * @return List + */ + List getOrderDataPriceCount(int page, int limit); + + /** + * 获取 今日 昨日 本月 订单金额 + * @return ShoperOrderTimeDataVo + */ + ShoperOrderTimeDataVo getShoperOrderTimeData(); + + /** + * 获取拼团订单 + * @param pid 拼团id + * @param uid 用户id + * @return YxStoreOrder + */ + YxStoreOrder getOrderPink(Long pid,Long uid); + + + /** + * 未付款取消订单 + * @param orderId 订单号 + * @param uid 用户id + */ + void cancelOrder(String orderId,Long uid); + + + /** + * 申请退款 + * @param explain 退款备注 + * @param Img 图片 + * @param text 理由 + * @param orderId 订单号 + * @param uid uid + */ + void orderApplyRefund(String explain,String Img,String text,String orderId, Long uid); + + /** + * 删除订单 + * @param orderId 单号 + * @param uid uid + */ + void removeOrder(String orderId,Long uid); + + + + /** + * 订单确认收货 + * @param orderId 单号 + * @param uid uid + */ + void takeOrder(String orderId,Long uid); + + /** + * 核销订单 + * @param verifyCode 核销码 + * @param isConfirm OrderInfoEnum + * @param uid uid + * @return YxStoreOrderQueryVo + */ + YxStoreOrderQueryVo verifyOrder(String verifyCode, Integer isConfirm , Long uid); + + /** + * 订单列表 + * @param uid 用户id + * @param type OrderStatusEnum + * @param page page + * @param limit limit + * @return list + */ + Map orderList(Long uid,int type,int page,int limit); + + /** + * 获取某个用户的订单统计数据 + * @param uid uid>0 取用户 否则取所有 + * @return UserOrderCountVo + */ + UserOrderCountVo orderData(Long uid); + + /** + * 处理订单返回的状态 + * @param order order + * @return YxStoreOrderQueryVo + */ + YxStoreOrderQueryVo handleOrder(YxStoreOrderQueryVo order); + + /** + * 支付成功后操作 + * @param orderId 订单号 + * @param payType 支付方式 + */ + void paySuccess(String orderId,String payType); + + /** + * 余额支付 + * @param orderId 订单号 + * @param uid 用户id + */ + void yuePay(String orderId,Long uid); + + /** + * 积分兑换 + * @param orderId 订单号 + * @param uid 用户id + */ + void integralPay(String orderId,Long uid); + + + String aliPay(String orderId) throws Exception; + + + /** + * 创建订单 + * @param userInfo 用户信息 + * @param key key + * @param param param + * @return YxStoreOrder + */ + YxStoreOrder createOrder(YxUser userInfo, String key, OrderParam param); + + /** + *计算订单价格 + * @param userInfo 用户 + * @param key 订单缓存key + * @param couponId 优惠券id + * @param useIntegral 使用积分 1-表示使用 + * @param shippingType 发货类型 OrderInfoEnum + * @return ComputeVo + */ + ComputeVo computedOrder(YxUser userInfo, String key, String couponId, + String useIntegral, String shippingType,String addressId); + + /** + * 订单信息 + * @param unique 唯一值或者单号 + * @param uid 用户id + * @return YxStoreOrderQueryVo + */ + YxStoreOrderQueryVo getOrderInfo(String unique, Long uid); + + + + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreOrderQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreOrderQueryCriteria criteria); + + + //YxStoreOrderDto create(YxStoreOrder resources); + + void update(YxStoreOrder resources); + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * 获取订单详情 + * @param orderId + * @return + */ + YxStoreOrderDto getOrderDetail(Long orderId); + + Map queryAll(List ids); + + + + + /** + * 根据商品分类统计订单占比 + * @return OrderCountDto + */ + OrderCountDto getOrderCount(); + + /** + * 首页订单/用户等统计 + * @return OrderTimeDataDto + */ + OrderTimeDataDto getOrderTimeData(); + + /** + * 返回本月订单金额与数量 + * @return map + */ + Map chartCount(); + + + void retrunStock(String orderId); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderStatusService.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderStatusService.java new file mode 100644 index 00000000..d42e2369 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderStatusService.java @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.order.domain.YxStoreOrderStatus; +import co.yixiang.modules.order.service.dto.YxStoreOrderStatusDto; +import co.yixiang.modules.order.service.dto.YxStoreOrderStatusQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreOrderStatusService extends BaseService{ + + /** + * 添加订单操作记录 + * @param oid 订单id + * @param changetype 操作状态 + * @param changeMessage 操作内容 + */ + void create(Long oid,String changetype,String changeMessage); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreOrderStatusQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreOrderStatusQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/CacheDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/CacheDto.java new file mode 100644 index 00000000..ac9a505c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/CacheDto.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.order.service.dto; + +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName CacheDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/27 + **/ +@Data +public class CacheDto implements Serializable { + private List cartInfo; + private PriceGroupDto priceGroup; + private OtherDto other; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ChartDataDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ChartDataDto.java new file mode 100644 index 00000000..a13d0555 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ChartDataDto.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +/** + * @ClassName ChartDataDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/25 + **/ +@Data +public class ChartDataDto { + + // @Value("#{target.adminCount}") + private Double num; + private String time; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/CountDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/CountDto.java new file mode 100644 index 00000000..6cd9d4f8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/CountDto.java @@ -0,0 +1,14 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +@Data +public class CountDto { + + private String catename; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OrderCountDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OrderCountDto.java new file mode 100644 index 00000000..32c60afe --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OrderCountDto.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + + +import lombok.Data; + +import java.util.List; + +@Data +public class OrderCountDto { + + private List column; + + private List orderCountDatas; + + @Data + public static class OrderCountData{ + private String name; + + private Integer value; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OrderTimeDataDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OrderTimeDataDto.java new file mode 100644 index 00000000..7e597ca3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OrderTimeDataDto.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName OrderTimeDataDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/25 + **/ +@Data +public class OrderTimeDataDto implements Serializable { + private Double todayPrice; //今日成交额 + private Long todayCount; //今日订单数 + private Double proPrice; //昨日成交额 + private Long proCount;//昨日订单数 + private Double monthPrice;//本月成交额 + private Long monthCount;//本月订单数 + + private Long lastWeekCount;//上周 + private Double lastWeekPrice; //上周 + + private Long userCount; + private Long orderCount; + private Double priceCount; + private Long goodsCount; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OtherDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OtherDto.java new file mode 100644 index 00000000..d6cbe5b4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/OtherDto.java @@ -0,0 +1,25 @@ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName OtherDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/27 + **/ +@Data +public class OtherDto implements Serializable { + //线下包邮 + private String offlinePostage; + //积分抵扣 + private String integralRatio; + + //最大 + private String integralMax; + + //满多少 + private String integralFull; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/PriceGroupDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/PriceGroupDto.java new file mode 100644 index 00000000..bbce372b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/PriceGroupDto.java @@ -0,0 +1,34 @@ +package co.yixiang.modules.order.service.dto; + +import co.yixiang.serializer.BigDecimalSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @ClassName PriceGroup + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/27 + **/ +@Data +public class PriceGroupDto { + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal costPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal storeFreePostage; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal storePostage; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal totalPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal vipPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal payIntegral; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ProductAttrDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ProductAttrDto.java new file mode 100644 index 00000000..a6820d71 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ProductAttrDto.java @@ -0,0 +1,27 @@ +package co.yixiang.modules.order.service.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName ProductAttrDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/3 + **/ +@Data +public class ProductAttrDto implements Serializable { + + @ApiModelProperty(value = "产品属性ID") + private Long productId; + + @ApiModelProperty(value = "产品属性sku") + private String sku; + + @ApiModelProperty(value = "产品属性价格") + private Double price; + + @ApiModelProperty(value = "产品属性图片") + private String image; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ProductDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ProductDto.java new file mode 100644 index 00000000..2aadda91 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/ProductDto.java @@ -0,0 +1,28 @@ +package co.yixiang.modules.order.service.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName ProductVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/3 + **/ +@Data +public class ProductDto implements Serializable { + + @ApiModelProperty(value = "产品图片") + private String image; + + @ApiModelProperty(value = "产品价格") + private Double price; + + @ApiModelProperty(value = "产品名称") + private String storeName; + + @ApiModelProperty(value = "产品属性信息") + private ProductAttrDto attrInfo; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/StatusDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/StatusDto.java new file mode 100644 index 00000000..0c00316b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/StatusDto.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName StatusDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/30 + **/ +@Data +public class StatusDto implements Serializable { + private String _class; + private String _msg; + private String _payType; + private String _title; + private String _type; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/StoreOrderCartInfoDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/StoreOrderCartInfoDto.java new file mode 100644 index 00000000..cfc9de1e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/StoreOrderCartInfoDto.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +import java.util.Map; + +/** + * @ClassName StoreOrderCartInfo + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/14 + **/ + + +@Data +public class StoreOrderCartInfoDto { + + + private Integer id; + + + private Integer oid; + + + private Integer cartId; + + + private String cartInfo; + + + private String unique; + + private Map cartInfoMap; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/TemplateDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/TemplateDto.java new file mode 100644 index 00000000..6e699f23 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/TemplateDto.java @@ -0,0 +1,30 @@ +package co.yixiang.modules.order.service.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.math.BigDecimal; + +/** + * @ClassName TemplateDTO + * @Author hupeng <610796224@qq.com> + * @Date 2020/5/28 + **/ +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TemplateDto { + private Double number; + private BigDecimal price; + private Double first; + private BigDecimal firstPrice; + private Double _continue; + private BigDecimal continuePrice; + private Integer tempId; + private Integer cityId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxExpressDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxExpressDto.java new file mode 100644 index 00000000..824fee3e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxExpressDto.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxExpressDto implements Serializable { + + /** 快递公司id */ + private Integer id; + + /** 快递公司简称 */ + private String code; + + /** 快递公司全称 */ + private String name; + + /** 排序 */ + private Integer sort; + + /** 是否显示 */ + private Integer isShow; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxExpressQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxExpressQueryCriteria.java new file mode 100644 index 00000000..beb1d4e9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxExpressQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxExpressQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxOrderNowOrderStatusDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxOrderNowOrderStatusDto.java new file mode 100644 index 00000000..5ea67460 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxOrderNowOrderStatusDto.java @@ -0,0 +1,36 @@ +package co.yixiang.modules.order.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author :LionCity + * @date :Created in 2020-05-29 11:16 + * @description: + * @modified By: + * @version: + */ +@Data +public class YxOrderNowOrderStatusDto implements Serializable { + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date cacheKeyCreateOrder; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date paySuccess; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date deliveryGoods; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date orderVerific; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date userTakeDelivery; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date checkOrderOver; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date applyRefund; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date refundOrderSuccess; + private int size; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderCartInfoDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderCartInfoDto.java new file mode 100644 index 00000000..80e1613d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderCartInfoDto.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreOrderCartInfoDto implements Serializable { + + private Integer id; + + /** 订单id */ + private Integer oid; + + /** + * 订单号 + */ + private String orderId; + + /** 购物车id */ + private Integer cartId; + + /** 商品ID */ + private Integer productId; + + /** 购买东西的详细信息 */ + private String cartInfo; + + /** 唯一id */ + private String unique; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderCartInfoQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderCartInfoQueryCriteria.java new file mode 100644 index 00000000..2c07169e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderCartInfoQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreOrderCartInfoQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderDto.java new file mode 100644 index 00000000..90dfb439 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderDto.java @@ -0,0 +1,197 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import co.yixiang.modules.user.service.dto.YxUserDto; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreOrderDto implements Serializable { + // 订单ID + private Long id; + + //支付类型 + private String payTypeName; + + //状态名称 + private String statusName; + + private Integer _status; + + //订单类型 + private String pinkName; + + private List cartInfoList; + + /** + * 订单状态列表 + */ + private List storeOrderStatusList; + + // 订单号 + private String orderId; + + // 用户id + private Long uid; + + private YxUserDto userDTO; + + // 用户姓名 + private String realName; + + // 用户电话 + private String userPhone; + + // 详细地址 + private String userAddress; + + // 购物车id + private String cartId; + + // 运费金额 + private BigDecimal freightPrice; + + // 订单商品总数 + private Integer totalNum; + + // 订单总价 + private BigDecimal totalPrice; + + // 邮费 + private BigDecimal totalPostage; + + // 实际支付金额 + private BigDecimal payPrice; + + // 支付邮费 + private BigDecimal payPostage; + + // 抵扣金额 + private BigDecimal deductionPrice; + + // 优惠券id + private Integer couponId; + + // 优惠券金额 + private BigDecimal couponPrice; + + // 支付状态 + private Integer paid; + + // 支付时间 + private Date payTime; + + // 支付方式 + private String payType; + + // 创建时间 + private Date createTime; + + // 订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款) + private Integer status; + + // 0 未退款 1 申请中 2 已退款 + private Integer refundStatus; + + // 退款图片 + private String refundReasonWapImg; + + // 退款用户说明 + private String refundReasonWapExplain; + + // 退款时间 + private Date refundReasonTime; + + // 前台退款原因 + private String refundReasonWap; + + // 不退款的理由 + private String refundReason; + + // 退款金额 + private BigDecimal refundPrice; + + // 快递名称/送货人姓名 + private String deliveryName; + + private String deliverySn; + + // 发货类型 + private String deliveryType; + + // 快递单号/手机号 + private String deliveryId; + + // 消费赚取积分 + private BigDecimal gainIntegral; + + // 使用积分 + private BigDecimal useIntegral; + + // 给用户退了多少积分 + private BigDecimal backIntegral; + + // 备注 + private String mark; + + + // 唯一id(md5加密)类似id + private String unique; + + // 管理员备注 + private String remark; + + // 商户ID + private Integer merId; + + private Integer isMerCheck; + + // 拼团产品id0一般产品 + private Long combinationId; + + // 拼团id 0没有拼团 + private Long pinkId; + + // 成本价 + private BigDecimal cost; + + // 秒杀产品ID + private Long seckillId; + + // 砍价id + private Long bargainId; + + // 核销码 + private String verifyCode; + + // 门店id + private Integer storeId; + + private String storeName; + + // 配送方式 1=快递 ,2=门店自提 + private Integer shippingType; + + // 支付渠道(0微信公众号1微信小程序) + private Integer isChannel; + + private Integer isRemind; + + @ApiModelProperty(value = "实际支付积分") + private BigDecimal payIntegral; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderQueryCriteria.java new file mode 100644 index 00000000..5158323d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderQueryCriteria.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreOrderQueryCriteria{ + + // 模糊 + @Query(type = Query.Type.UNIX_TIMESTAMP) + private List createTime; + + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String orderId; + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String realName; + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String userPhone; + + @Query + private Integer paid; + + @Query + private Integer status; + + @Query + private Integer refundStatus; + + @Query + private Integer isDel; + + @Query + private Integer combinationId; + + @Query + private Integer seckillId; + + @Query + private Integer bargainId; + + @Query(propName="combinationId",type = Query.Type.NOT_EQUAL) + private Integer newCombinationId; + + @Query(propName="seckillId",type = Query.Type.NOT_EQUAL) + private Integer newSeckillId; + + @Query(propName="bargainId",type = Query.Type.NOT_EQUAL) + private Integer newBargainId; + + @Query + private Integer shippingType; + + @Query(type = Query.Type.GREATER_THAN_NQ) + private BigDecimal payIntegral; + + @Query + private Integer storeId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderStatusDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderStatusDto.java new file mode 100644 index 00000000..0ea6d25d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderStatusDto.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreOrderStatusDto implements Serializable { + + private Integer id; + + /** 订单id */ + private Integer oid; + + /** 操作类型 */ + private String changeType; + + /** 操作备注 */ + private String changeMessage; + + /** 操作时间 */ + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date changeTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderStatusQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderStatusQueryCriteria.java new file mode 100644 index 00000000..f8b36894 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/dto/YxStoreOrderStatusQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreOrderStatusQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxExpressServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxExpressServiceImpl.java new file mode 100644 index 00000000..91b45c39 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxExpressServiceImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.order.domain.YxExpress; +import co.yixiang.modules.order.service.YxExpressService; +import co.yixiang.modules.order.service.dto.YxExpressDto; +import co.yixiang.modules.order.service.dto.YxExpressQueryCriteria; +import co.yixiang.modules.order.service.mapper.ExpressMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxExpressServiceImpl extends BaseServiceImpl implements YxExpressService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxExpressQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxExpressDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxExpressQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxExpress.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxExpressDto yxExpress : all) { + Map map = new LinkedHashMap<>(); + map.put("快递公司简称", yxExpress.getCode()); + map.put("快递公司全称", yxExpress.getName()); + map.put("排序", yxExpress.getSort()); + map.put("是否显示", yxExpress.getIsShow()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java new file mode 100644 index 00000000..178babee --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java @@ -0,0 +1,114 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.impl; + +import cn.hutool.core.util.IdUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.service.YxStoreOrderCartInfoService; +import co.yixiang.modules.order.service.dto.YxStoreOrderCartInfoDto; +import co.yixiang.modules.order.service.dto.YxStoreOrderCartInfoQueryCriteria; +import co.yixiang.modules.order.service.mapper.StoreOrderCartInfoMapper; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreOrderCartInfoServiceImpl extends BaseServiceImpl implements YxStoreOrderCartInfoService { + + private final IGenerator generator; + + @Override + public YxStoreOrderCartInfo findByUni(String unique) { + LambdaQueryWrapper wrapper= new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreOrderCartInfo::getUnique,unique); + return this.baseMapper.selectOne(wrapper); + } + + /** + * 添加购物车商品信息 + * @param oid 订单id + * @param orderId + * @param cartInfo 购物车信息 + */ + @Override + public void saveCartInfo(Long oid, String orderId, List cartInfo) { + + List list = new ArrayList<>(); + for (YxStoreCartQueryVo cart : cartInfo) { + YxStoreOrderCartInfo info = new YxStoreOrderCartInfo(); + info.setOid(oid); + info.setOrderId(orderId); + info.setCartId(cart.getId()); + info.setProductId(cart.getProductId()); + info.setCartInfo(JSONObject.toJSON(cart).toString()); + info.setUnique(IdUtil.simpleUUID()); + info.setIsAfterSales(1); + list.add(info); + } + + this.saveBatch(list); + } + + + @Override + //@Cacheable + public Map queryAll(YxStoreOrderCartInfoQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreOrderCartInfoDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreOrderCartInfoQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreOrderCartInfo.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreOrderCartInfoDto yxStoreOrderCartInfo : all) { + Map map = new LinkedHashMap<>(); + map.put("订单id", yxStoreOrderCartInfo.getOid()); + map.put("购物车id", yxStoreOrderCartInfo.getCartId()); + map.put("商品ID", yxStoreOrderCartInfo.getProductId()); + map.put("购买东西的详细信息", yxStoreOrderCartInfo.getCartInfo()); + map.put("唯一id", yxStoreOrderCartInfo.getUnique()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java new file mode 100644 index 00000000..5a1961b8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java @@ -0,0 +1,2561 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.BusinessException; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.constant.ShopConstants; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.*; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.exception.EntityExistException; +import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.activity.domain.YxStoreCouponUser; +import co.yixiang.modules.activity.domain.YxStorePink; +import co.yixiang.modules.activity.service.YxStoreBargainService; +import co.yixiang.modules.activity.service.YxStoreBargainUserService; +import co.yixiang.modules.activity.service.YxStoreCouponUserService; +import co.yixiang.modules.activity.service.YxStorePinkService; +import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import co.yixiang.modules.cart.domain.YxStoreCart; +import co.yixiang.modules.cart.service.YxStoreCartService; +import co.yixiang.modules.cart.service.mapper.StoreCartMapper; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxExpress; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.domain.YxStoreOrderStatus; +import co.yixiang.modules.order.param.OrderParam; +import co.yixiang.modules.order.service.YxExpressService; +import co.yixiang.modules.order.service.YxStoreOrderCartInfoService; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.YxStoreOrderStatusService; +import co.yixiang.modules.order.service.dto.*; +import co.yixiang.modules.order.service.mapper.StoreOrderMapper; +import co.yixiang.modules.order.vo.*; +import co.yixiang.modules.product.domain.YxStoreProductReply; +import co.yixiang.modules.product.service.YxStoreProductReplyService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.shop.service.YxSystemStoreStaffService; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.domain.YxShippingTemplatesFree; +import co.yixiang.modules.template.domain.YxShippingTemplatesRegion; +import co.yixiang.modules.template.service.YxShippingTemplatesFreeService; +import co.yixiang.modules.template.service.YxShippingTemplatesRegionService; +import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserAddress; +import co.yixiang.modules.user.service.YxUserAddressService; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserLevelService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.dto.YxUserDto; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import co.yixiang.tools.domain.AlipayConfig; +import co.yixiang.tools.domain.vo.TradeVo; +import co.yixiang.tools.service.AlipayConfigService; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.OrderUtil; +import co.yixiang.utils.RedisUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.domain.Pageable; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + + +/** + * @author hupeng + * @date 2020-05-12 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class YxStoreOrderServiceImpl extends BaseServiceImpl implements YxStoreOrderService { + + @Autowired + private IGenerator generator; + + + @Autowired + private YxStorePinkService storePinkService; + @Autowired + private YxStoreOrderCartInfoService storeOrderCartInfoService; + @Autowired + private YxStoreCartService storeCartService; + @Autowired + private YxUserAddressService userAddressService; + @Autowired + private YxStoreOrderCartInfoService orderCartInfoService; + @Autowired + private YxStoreOrderStatusService orderStatusService; + @Autowired + private YxUserBillService billService; + @Autowired + private YxStoreCouponUserService couponUserService; + @Autowired + private YxUserService userService; + @Autowired + private YxStoreProductService productService; + @Autowired + private YxStorePinkService pinkService; + @Autowired + private YxStoreBargainUserService storeBargainUserService; + @Autowired + private YxStoreBargainService storeBargainService; + @Autowired + private YxExpressService expressService; + @Autowired + private AlipayConfigService alipayService; + @Autowired + private YxSystemStoreService systemStoreService; + @Autowired + private YxStoreProductReplyService productReplyService; + @Autowired + private YxStoreCartService yxStoreCartService; + @Autowired + private YxSystemStoreStaffService systemStoreStaffService; + @Autowired + private YxShippingTemplatesService shippingTemplatesService; + @Autowired + private YxShippingTemplatesRegionService shippingTemplatesRegionService; + @Autowired + private YxShippingTemplatesFreeService shippingTemplatesFreeService; + @Autowired + private YxSystemConfigService systemConfigService; + @Autowired + private YxUserLevelService userLevelService; + + + @Autowired + private StoreOrderMapper yxStoreOrderMapper; + @Autowired + private StoreCartMapper storeCartMapper; + + + @Autowired + private RedisUtils redisUtils; + + + @Autowired + private RedisTemplate stringRedisTemplate; + + @Autowired + private ApplicationEventPublisher publisher; + + @Autowired + private StoreAfterSalesService storeAfterSalesService; + + + /** + * 返回订单确认数据 + * + * @param yxUser yxUser + * @param cartIds 购物车id + * @return ConfirmOrderVO + */ + @Override + public ConfirmOrderVo confirmOrder(YxUser yxUser, String cartIds) { + Long uid = yxUser.getUid(); + Map cartGroup = yxStoreCartService.getUserProductCartList(uid, + cartIds, ShopConstants.YSHOP_ONE_NUM); + if (ObjectUtil.isNotEmpty(cartGroup.get("invalid"))) { + throw new YshopException("有失效的商品请重新提交"); + } + if (ObjectUtil.isEmpty(cartGroup.get("valid"))) { + throw new YshopException("请提交购买的商品"); + } + + OtherDto other = new OtherDto(); + other.setIntegralRatio(systemConfigService.getData(SystemConfigConstants.INTERGRAL_RATIO)); + other.setIntegralFull(systemConfigService.getData(SystemConfigConstants.INTERGRAL_FULL)); + other.setIntegralMax(systemConfigService.getData(SystemConfigConstants.INTERGRAL_MAX)); + + //拼团 砍价 秒杀 + Long combinationId = null; + Long secKillId = null; + Long bargainId = null; + if (cartIds.split(",").length == 1) { + YxStoreCart cartQueryVo = yxStoreCartService.getById(cartIds); + combinationId = cartQueryVo.getCombinationId(); + secKillId = cartQueryVo.getSeckillId(); + bargainId = cartQueryVo.getBargainId(); + } + + boolean deduction = false; + boolean enableIntegral = true; + + //拼团砍价秒杀类产品不参与抵扣 + if ((combinationId != null && combinationId > 0) || (secKillId != null && secKillId > 0) + || (bargainId != null && bargainId > 0)) { + deduction = true; + } + + //获取默认地址 + YxUserAddress userAddress = userAddressService.getOne(Wrappers.lambdaQuery() + .eq(YxUserAddress::getUid, uid) + .eq(YxUserAddress::getIsDefault, ShopCommonEnum.DEFAULT_1.getValue()), false); + + List cartInfo = (List) cartGroup.get("valid"); + PriceGroupDto priceGroup = this.getOrderPriceGroup(cartInfo, userAddress); + + //判断积分是否满足订单额度 + if (priceGroup.getTotalPrice().compareTo(new BigDecimal(other.getIntegralFull())) < 0) { + enableIntegral = false; + } + + String cacheKey = this.cacheOrderInfo(uid, cartInfo, priceGroup, other); + + + //获取可用优惠券 + List productIds = cartInfo.stream() + .map(YxStoreCartQueryVo::getProductId) + .map(Object::toString) + .collect(Collectors.toList()); + List storeCouponUsers = couponUserService + .getUsableCouponList(uid, priceGroup.getTotalPrice().doubleValue(), productIds); + + StoreCouponUserVo storeCouponUser = null; + if (storeCouponUsers != null && !storeCouponUsers.isEmpty()) { + storeCouponUser = storeCouponUsers.get(0); + } + + return ConfirmOrderVo.builder() + .addressInfo(userAddress) + .cartInfo(cartInfo) + .priceGroup(priceGroup) + .userInfo(generator.convert(yxUser, YxUserQueryVo.class)) + .orderKey(cacheKey) + .deduction(deduction) + .enableIntegral(enableIntegral) + .enableIntegralNum(Double.valueOf(other.getIntegralMax())) + //.integralRatio(d) + .usableCoupon(storeCouponUser) + .systemStore(systemStoreService.getStoreInfo("", "")) + .build(); + + } + + + /** + * 计算订单价格 + * + * @param userInfo 用户 + * @param key 订单缓存key + * @param couponId 优惠券id + * @param useIntegral 使用积分 1-表示使用 + * @param shippingType 发货类型 OrderInfoEnum + * @return ComputeVo + */ + @Override + public ComputeVo computedOrder(YxUser userInfo, String key, String couponId, + String useIntegral, String shippingType, String addressId) { + Long uid = userInfo.getUid(); + CacheDto cacheDTO = this.getCacheOrderInfo(uid, key); + if (ObjectUtil.isNull(cacheDTO)) { + throw new YshopException("订单已过期,请刷新当前页面"); + } + BigDecimal payPrice = cacheDTO.getPriceGroup().getTotalPrice(); + + + //处理运费模板 + YxUserAddress userAddress = null; + if (StrUtil.isNotBlank(addressId)) { + userAddress = userAddressService.getById(addressId); + } + PriceGroupDto priceGroup = this.getOrderPriceGroup(cacheDTO.getCartInfo(), userAddress); + BigDecimal payPostage = priceGroup.getStorePostage(); + + Integer shippingTypeI = Integer.valueOf(shippingType); + //1-配送 2-到店 + if (OrderInfoEnum.SHIPPIING_TYPE_1.getValue().equals(shippingTypeI)) { + payPrice = NumberUtil.add(payPrice, payPostage); + } else { + payPostage = BigDecimal.ZERO; + } + + Long combinationId = null; + Long seckillId = null; + Long bargainId = null; + List cartInfo = cacheDTO.getCartInfo(); + for (YxStoreCartQueryVo cart : cartInfo) { + combinationId = cart.getCombinationId(); + seckillId = cart.getSeckillId(); + bargainId = cart.getBargainId(); + } + + //拼团等不参与抵扣 + if ((combinationId != null && combinationId > 0) || (seckillId != null && seckillId > 0) + || (bargainId != null && bargainId > 0)) { + couponId = ""; + useIntegral = ""; + } + + BigDecimal couponPrice = BigDecimal.ZERO; + if (StrUtil.isNotBlank(couponId) && !ShopConstants.YSHOP_ZERO.equals(couponId)) {//使用优惠券 + YxStoreCouponUser couponUser = couponUserService.getCoupon(Integer.valueOf(couponId), uid); + if (couponUser == null) { + throw new YshopException("使用优惠劵失败"); + } + + if (couponUser.getUseMinPrice().compareTo(payPrice) > 0) { + throw new YshopException("不满足优惠劵的使用条件"); + } + payPrice = NumberUtil.sub(payPrice, couponUser.getCouponPrice()); + couponPrice = couponUser.getCouponPrice(); + } + + // 积分抵扣 + BigDecimal deductionPrice = BigDecimal.ZERO; //积分抵扣金额 + double usedIntegral = 0; //使用了多少积分 + if (StrUtil.isNotBlank(useIntegral) && ShopConstants.YSHOP_ONE.equals(useIntegral) + && userInfo.getIntegral().intValue() > 0) { + Double integralMax = Double.valueOf(cacheDTO.getOther().getIntegralMax()); + BigDecimal integralFull = new BigDecimal(cacheDTO.getOther().getIntegralFull()); + Double integralRatio = Double.valueOf(cacheDTO.getOther().getIntegralRatio()); + + if (cacheDTO.getPriceGroup().getTotalPrice().compareTo(integralFull) >= 0) { + Double userIntegral = userInfo.getIntegral().doubleValue(); + if (integralMax.intValue() > 0 && Double.compare(userIntegral, integralMax) >= 0) { + userIntegral = integralMax; + } + deductionPrice = BigDecimal.valueOf(NumberUtil.mul(userIntegral, integralRatio)); + if (deductionPrice.compareTo(payPrice) < 0) { + payPrice = NumberUtil.sub(payPrice, deductionPrice); + usedIntegral = userIntegral; + } else { + deductionPrice = payPrice; + payPrice = BigDecimal.ZERO; + usedIntegral = NumberUtil.round(NumberUtil.div(deductionPrice, + BigDecimal.valueOf(integralRatio)), 2).doubleValue(); + } + } + } + + if (payPrice.compareTo(BigDecimal.ZERO) <= 0) { + payPrice = BigDecimal.ZERO; + } + + return ComputeVo.builder() + .totalPrice(cacheDTO.getPriceGroup().getTotalPrice()) + .payPrice(payPrice) + .payPostage(payPostage) + .couponPrice(couponPrice) + .deductionPrice(deductionPrice) + .usedIntegral(usedIntegral) + .payIntegral(cacheDTO.getPriceGroup().getPayIntegral()) + .build(); + } + + + /** + * 创建订单 + * + * @param userInfo 用户信息 + * @param key key + * @param param param + * @return YxStoreOrder + */ + @Override + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + public YxStoreOrder createOrder(YxUser userInfo, String key, OrderParam param) { + + ComputeVo computeVo = this.computedOrder(userInfo, key, param.getCouponId(), + param.getUseIntegral(), param.getShippingType(), param.getAddressId()); + + Long uid = userInfo.getUid(); + + //处理选择门店与正常选择地址下单 + YxUserAddress userAddress = null; + if (OrderInfoEnum.SHIPPIING_TYPE_1.getValue().equals(Integer.valueOf(param.getShippingType()))) { + if (StrUtil.isEmpty(param.getAddressId())) { + throw new YshopException("请选择收货地址"); + } + userAddress = userAddressService.getById(param.getAddressId()); + if (ObjectUtil.isNull(userAddress)) { + throw new YshopException("地址选择有误"); + } + } else { //门店 + if (StrUtil.isBlank(param.getRealName()) || StrUtil.isBlank(param.getPhone())) { + throw new YshopException("请填写姓名和电话"); + } + userAddress = new YxUserAddress(); + userAddress.setRealName(param.getRealName()); + userAddress.setPhone(param.getPhone()); + userAddress.setProvince(""); + userAddress.setCity(""); + userAddress.setDistrict(""); + userAddress.setDetail(""); + } + + Integer totalNum = 0; + //Integer gainIntegral = 0; + List cartIds = new ArrayList<>(); + Long combinationId = 0L; + Long seckillId = 0L; + Long bargainId = 0L; + + Boolean isIntegral = false; + BigDecimal integral = BigDecimal.ZERO; + + CacheDto cacheDTO = this.getCacheOrderInfo(uid, key); + List cartInfo = cacheDTO.getCartInfo(); + + for (YxStoreCartQueryVo cart : cartInfo) { + //检测库存 + yxStoreCartService.checkProductStock(uid, cart.getProductId(), cart.getCartNum(), + cart.getProductAttrUnique(), cart.getCombinationId(), + cart.getSeckillId(), cart.getBargainId()); + + combinationId = cart.getCombinationId(); + seckillId = cart.getSeckillId(); + bargainId = cart.getBargainId(); + + cartIds.add(cart.getId().toString()); + totalNum += cart.getCartNum(); + if (cart.getProductInfo().getIsIntegral() != null + && cart.getProductInfo().getIsIntegral() == 1) { + integral = NumberUtil.add(integral, + NumberUtil.mul(cart.getCartNum(), cart.getProductInfo().getAttrInfo().getIntegral())); + } + } + + + //计算奖励积分 + BigDecimal gainIntegral = this.getGainIntegral(cartInfo); + if (PayTypeEnum.INTEGRAL.getValue().equals(param.getPayType())) { + gainIntegral = BigDecimal.ZERO; + isIntegral = true; + } + //生成分布式唯一值 + String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr(); + //组合数据 + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setUid(Long.valueOf(String.valueOf(uid))); + storeOrder.setOrderId(orderSn); + storeOrder.setRealName(userAddress.getRealName()); + storeOrder.setUserPhone(userAddress.getPhone()); + storeOrder.setUserAddress(userAddress.getProvince() + " " + userAddress.getCity() + + " " + userAddress.getDistrict() + " " + userAddress.getDetail()); + storeOrder.setCartId(StrUtil.join(",", cartIds)); + storeOrder.setTotalNum(totalNum); + storeOrder.setTotalPrice(computeVo.getTotalPrice()); + storeOrder.setTotalPostage(computeVo.getPayPostage()); + + storeOrder.setCouponId(param.getCouponId() == null ? null : Integer.valueOf(param.getCouponId())); + storeOrder.setCouponPrice(computeVo.getCouponPrice()); + storeOrder.setPayPrice(computeVo.getPayPrice()); + storeOrder.setPayPostage(computeVo.getPayPostage()); + storeOrder.setDeductionPrice(computeVo.getDeductionPrice()); + storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_0.getValue()); + storeOrder.setPayType(param.getPayType()); + if (isIntegral) { + storeOrder.setPayIntegral(integral); + } + storeOrder.setUseIntegral(BigDecimal.valueOf(computeVo.getUsedIntegral())); + storeOrder.setBackIntegral(BigDecimal.ZERO); + storeOrder.setGainIntegral(gainIntegral); + storeOrder.setMark(param.getMark()); + storeOrder.setCombinationId(combinationId); + storeOrder.setPinkId(Long.valueOf(param.getPinkId())); + storeOrder.setSeckillId(seckillId); + storeOrder.setBargainId(bargainId); + storeOrder.setCost(cacheDTO.getPriceGroup().getCostPrice()); + if (AppFromEnum.ROUNTINE.getValue().equals(param.getFrom())) { + storeOrder.setIsChannel(OrderInfoEnum.PAY_CHANNEL_1.getValue()); + } else { + storeOrder.setIsChannel(OrderInfoEnum.PAY_CHANNEL_0.getValue()); + } + storeOrder.setUnique(key); + storeOrder.setShippingType(Integer.valueOf(param.getShippingType())); + //处理门店 + if (OrderInfoEnum.SHIPPIING_TYPE_2.getValue().toString().equals(param.getShippingType())) { + YxSystemStore systemStoreQueryVo = systemStoreService.getById(param.getStoreId()); + if (systemStoreQueryVo == null) { + throw new ErrorRequestException("暂无门店无法选择门店自提"); + } + storeOrder.setVerifyCode(StrUtil.sub(orderSn, orderSn.length(), -12)); + storeOrder.setStoreId(systemStoreQueryVo.getId()); + } + + boolean res = this.save(storeOrder); + if (!res) { + throw new YshopException("订单生成失败"); + } + + //使用了积分扣积分 + if (computeVo.getUsedIntegral() > 0) { + this.decIntegral(userInfo, computeVo.getUsedIntegral(), computeVo.getDeductionPrice().doubleValue()); + } + + //使用了优惠券扣优惠券 + if (computeVo.getCouponPrice().compareTo(BigDecimal.ZERO) > 0) { + couponUserService.useCoupon(Integer.valueOf(param.getCouponId())); + } + + + // 减库存加销量 + this.deStockIncSale(cartInfo); + + + //保存购物车商品信息 + orderCartInfoService.saveCartInfo(storeOrder.getId(), storeOrder.getOrderId(),cartInfo); + + + //购物车状态修改 + YxStoreCart cartObj = new YxStoreCart(); + cartObj.setIsPay(OrderInfoEnum.PAY_STATUS_1.getValue()); + storeCartMapper.update(cartObj, Wrappers.lambdaQuery() + .in(YxStoreCart::getId, cartIds)); + + //删除缓存 + this.delCacheOrderInfo(uid, key); + + //增加状态 + orderStatusService.create(storeOrder.getId(), OrderLogEnum.CREATE_ORDER.getValue(), + OrderLogEnum.CREATE_ORDER.getDesc()); + + + //加入redis,30分钟自动取消 + String redisKey = String.valueOf(StrUtil.format("{}{}", + ShopConstants.REDIS_ORDER_OUTTIME_UNPAY, storeOrder.getId())); + stringRedisTemplate.opsForValue().set(redisKey, storeOrder.getOrderId(), + ShopConstants.ORDER_OUTTIME_UNPAY, TimeUnit.MINUTES); + + //使用MQ延时消息 +// TemplateBean templateBean = TemplateBean.builder() +// .orderId(storeOrder.getId()+"") +// .uid(storeOrder.getUid()) +// .templateType(TemplateListenEnum.TYPE_7.getValue()) +// .time(DateUtil.formatTime(new Date())) +// .build(); +// publisher.publishEvent(new TemplateEvent(this,templateBean)); + + + return storeOrder; + } + + + /** + * 订单评价 + * + * @param orderCartInfo + * @param user user + * @param unique 订单orderCart唯一值 + * @param comment 评论内容 + * @param pics 图片 + * @param productScore 评分 + * @param serviceScore 评分 + */ + @Override + public void orderComment(YxStoreOrderCartInfo orderCartInfo, YxUser user, String unique, String comment, String pics, String productScore, + String serviceScore) { + + if (ObjectUtil.isEmpty(orderCartInfo)) { + throw new YshopException("评价产品不存在"); + } + + Long count = productReplyService.count(Wrappers.lambdaQuery() + .eq(YxStoreProductReply::getOid, orderCartInfo.getOid()) + .eq(YxStoreProductReply::getProductId, orderCartInfo.getProductId())); + if (count > 0) { + throw new YshopException("该产品已评价"); + } + + + YxStoreProductReply storeProductReply = YxStoreProductReply.builder() + .uid(user.getUid()) + .oid(orderCartInfo.getOid()) + .productId(orderCartInfo.getProductId()) + .productScore(Integer.valueOf(productScore)) + .serviceScore(Integer.valueOf(serviceScore)) + .comment(comment) + .pics(pics) + .unique(unique) + .build(); + + productReplyService.save(storeProductReply); + //获取评价商品数量 + Long replyCount = productReplyService.count(new LambdaQueryWrapper().eq(YxStoreProductReply::getOid, orderCartInfo.getOid())); + //购买商品数量 + Long cartCount = storeOrderCartInfoService.count(new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid, orderCartInfo.getOid())); + if (replyCount == cartCount) { + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setStatus(OrderInfoEnum.STATUS_3.getValue()); + storeOrder.setId(orderCartInfo.getOid()); + yxStoreOrderMapper.updateById(storeOrder); + + } + } + + /** + * 确认订单退款 + * + * @param orderId 单号 + * @param price 金额 + * @param type ShopCommonEnum + */ + @Override + public void orderRefund(String orderId, BigDecimal price, Integer type) { + + YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId, null); + if (ObjectUtil.isNull(orderQueryVo)) { + throw new YshopException("订单不存在"); + } + + YxUserQueryVo userQueryVo = userService.getYxUserById(orderQueryVo.getUid()); + if (ObjectUtil.isNull(userQueryVo)) { + throw new YshopException("用户不存在"); + } + + if (OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderQueryVo.getRefundStatus())) { + throw new YshopException("订单已经退款了哦!"); + } + + if (orderQueryVo.getPayPrice().compareTo(price) < 0) { + throw new YshopException("退款金额不正确"); + } + + YxStoreOrder storeOrder = new YxStoreOrder(); + //修改状态 + storeOrder.setId(orderQueryVo.getId()); + if (ShopCommonEnum.AGREE_2.getValue().equals(type)) { + storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + yxStoreOrderMapper.updateById(storeOrder); + StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery() + .eq(StoreAfterSales::getUserId, orderQueryVo.getUid()) + .eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId()).one(); + if (ObjectUtil.isNotNull(storeAfterSales)) { + storeAfterSalesService.lambdaUpdate() + .eq(StoreAfterSales::getId, storeAfterSales.getId()) + .set(StoreAfterSales::getSalesState, ShopCommonEnum.AGREE_2.getValue()) + .update(); + } + return; + } + + //根据支付类型不同退款不同 + if (PayTypeEnum.YUE.getValue().equals(orderQueryVo.getPayType())) { + storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue()); + storeOrder.setRefundPrice(price); + yxStoreOrderMapper.updateById(storeOrder); + //退款到余额 + userService.incMoney(orderQueryVo.getUid(), price); + + //增加流水 + billService.income(orderQueryVo.getUid(), "商品退款", BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_5.getValue(), + price.doubleValue(), + NumberUtil.add(price, userQueryVo.getNowMoney()).doubleValue(), + "订单退款到余额" + price + "元", orderQueryVo.getId().toString()); + this.retrunStock(orderQueryVo.getOrderId()); + StoreAfterSales storeAfterSales = storeAfterSalesService.lambdaQuery() + .eq(StoreAfterSales::getUserId, orderQueryVo.getUid()) + .eq(StoreAfterSales::getOrderCode, orderQueryVo.getOrderId()).one(); + if (ObjectUtil.isNotNull(storeAfterSales)) { + storeAfterSalesService.lambdaUpdate() + .eq(StoreAfterSales::getId, storeAfterSales.getId()) + .set(StoreAfterSales::getState, AfterSalesStatusEnum.STATUS_3.getValue()) + .update(); + } + + } else if (PayTypeEnum.INTEGRAL.getValue().equals(orderQueryVo.getPayType())) { + storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue()); + storeOrder.setRefundPrice(price); + yxStoreOrderMapper.updateById(storeOrder); + + orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.ORDER_EDIT.getValue(), "退款给用户:" + orderQueryVo.getPayIntegral() + "分"); + this.retrunStock(orderQueryVo.getOrderId()); + } + + orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(), "退款给用户:" + price + "元"); + + TemplateBean templateBean = TemplateBean.builder() + .orderId(orderQueryVo.getOrderId()) + .price(orderQueryVo.getPayPrice().toString()) + .uid(orderQueryVo.getUid()) + .templateType(TemplateListenEnum.TYPE_2.getValue()) + .time(DateUtil.formatTime(new Date())) + .payType(orderQueryVo.getPayType()) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + + + } + + + /** + * 订单发货 + * + * @param orderId 单号 + * @param deliveryId 快递单号 + * @param deliveryName 快递公司code + * @param deliveryType 快递方式 + */ + @Override + public void orderDelivery(String orderId, String deliveryId, String deliveryName, String deliveryType) { + YxStoreOrderQueryVo orderQueryVo = this.getOrderInfo(orderId, null); + if (ObjectUtil.isNull(orderQueryVo)) { + throw new YshopException("订单不存在"); + } + + if (!OrderInfoEnum.STATUS_0.getValue().equals(orderQueryVo.getStatus()) || + OrderInfoEnum.PAY_STATUS_0.getValue().equals(orderQueryVo.getPaid())) { + throw new YshopException("订单状态错误"); + } + + if (!OrderInfoEnum.REFUND_STATUS_0.getValue().equals(orderQueryVo.getRefundStatus())) { + throw new YshopException("订单退款中或已退款"); + } + + YxExpress expressQueryVo = expressService.getOne(new LambdaQueryWrapper().eq(YxExpress::getName, deliveryName)); + if (ObjectUtil.isNull(expressQueryVo)) { + throw new YshopException("请后台先添加快递公司"); + } + + //判断拼团产品 + if (orderQueryVo.getPinkId() != null && orderQueryVo.getPinkId() > 0) { + YxStorePink pink = pinkService.getById(orderQueryVo.getPinkId()); + if (!OrderInfoEnum.PINK_STATUS_2.getValue().equals(pink.getStatus())) { + throw new YshopException("拼团未成功不能发货"); + } + } + + YxStoreOrder storeOrder = YxStoreOrder.builder() + .id(orderQueryVo.getId()) + .status(OrderInfoEnum.STATUS_1.getValue()) + .deliveryId(deliveryId) + .deliveryName(expressQueryVo.getName()) + .deliveryType(deliveryType) + .deliverySn(expressQueryVo.getCode()) + .build(); + + yxStoreOrderMapper.updateById(storeOrder); + + //增加状态 + orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.DELIVERY_GOODS.getValue(), + "已发货 快递公司:" + expressQueryVo.getName() + "快递单号:" + deliveryId); + + //模板消息发布事件 + TemplateBean templateBean = TemplateBean.builder() + .orderId(orderQueryVo.getOrderId()) + .deliveryId(deliveryId) + .deliveryName(expressQueryVo.getName()) + .uid(orderQueryVo.getUid()) + .templateType(TemplateListenEnum.TYPE_3.getValue()) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + + + //加入redis,7天后自动确认收货 + String redisKey = String.valueOf(StrUtil.format("{}{}", + ShopConstants.REDIS_ORDER_OUTTIME_UNCONFIRM, orderQueryVo.getId())); + stringRedisTemplate.opsForValue().set(redisKey, orderQueryVo.getOrderId(), + ShopConstants.ORDER_OUTTIME_UNCONFIRM, TimeUnit.DAYS); + + } + + /** + * 修改快递单号 + * + * @param orderId 单号 + * @param deliveryId 快递单号 + * @param deliveryName 快递公司code + * @param deliveryType 快递方式 + */ + @Override + public void updateDelivery(String orderId, String deliveryId, String deliveryName, String deliveryType) { + YxStoreOrderQueryVo orderQueryVo = this.getOrderInfo(orderId, null); + if (ObjectUtil.isNull(orderQueryVo)) { + throw new YshopException("订单不存在"); + } + + if (!OrderInfoEnum.STATUS_1.getValue().equals(orderQueryVo.getStatus()) || + OrderInfoEnum.PAY_STATUS_0.getValue().equals(orderQueryVo.getPaid())) { + throw new YshopException("订单状态错误"); + } + + YxExpress expressQueryVo = expressService.getOne(new LambdaQueryWrapper().eq(YxExpress::getName, deliveryName)); + if (ObjectUtil.isNull(expressQueryVo)) { + throw new YshopException("请后台先添加快递公司"); + } + + + YxStoreOrder storeOrder = YxStoreOrder.builder() + .id(orderQueryVo.getId()) + .deliveryId(deliveryId) + .deliveryName(expressQueryVo.getName()) + .deliveryType(deliveryType) + .deliverySn(expressQueryVo.getCode()) + .build(); + + yxStoreOrderMapper.updateById(storeOrder); + } + + + /** + * 修改订单价格 + * + * @param orderId 单号 + * @param price 价格 + */ + @Override + public void editOrderPrice(String orderId, String price) { + YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId, null); + if (ObjectUtil.isNull(orderQueryVo)) { + throw new YshopException("订单不存在"); + } + + + if (orderQueryVo.getPayPrice().compareTo(new BigDecimal(price)) == 0) { + return; + } + + + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderQueryVo.getPaid())) { + throw new YshopException("订单状态错误"); + } + + + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setId(orderQueryVo.getId()); + storeOrder.setPayPrice(new BigDecimal(price)); + + //判断金额是否有变动,生成一个额外订单号去支付 + if (orderQueryVo.getPayPrice().compareTo(new BigDecimal(price)) != 0) { + String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr(); + storeOrder.setExtendOrderId(orderSn); + } + + yxStoreOrderMapper.updateById(storeOrder); + + //增加状态 + orderStatusService.create(storeOrder.getId(), OrderLogEnum.ORDER_EDIT.getValue(), "修改实际支付金额"); + + } + + /** + * 获取拼团订单 + * + * @param pid 拼团id + * @param uid 用户id + * @return YxStoreOrder + */ + @Override + public YxStoreOrder getOrderPink(Long pid, Long uid) { + return this.lambdaQuery().eq(YxStoreOrder::getUid, uid) + .eq(YxStoreOrder::getPinkId, pid) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .one(); + } + + + /** + * 未付款取消订单 + * + * @param orderId 订单号 + * @param uid 用户id + */ + @Override + public void cancelOrder(String orderId, Long uid) { + YxStoreOrderQueryVo order = this.getOrderInfo(orderId, uid); + if (ObjectUtil.isNull(order)) { + throw new YshopException("订单不存在"); + } + + this.regressionIntegral(order, 0); + + this.regressionStock(order, 0); + + this.regressionCoupon(order, 0); + + yxStoreOrderMapper.deleteById(order.getId()); + } + + + /** + * 删除订单 + * + * @param orderId 单号 + * @param uid uid + */ + @Override + public void removeOrder(String orderId, Long uid) { + YxStoreOrderQueryVo order = getOrderInfo(orderId, (long) uid); + if (order == null) { + throw new YshopException("订单不存在"); + } + order = handleOrder(order); + if (!OrderInfoEnum.STATUS_3.getValue().equals(order.getStatus())) { + throw new YshopException("该订单无法删除"); + } + + yxStoreOrderMapper.deleteById(order.getId()); + + //增加状态 + orderStatusService.create(order.getId(), + OrderLogEnum.REMOVE_ORDER.getValue(), + OrderLogEnum.REMOVE_ORDER.getDesc()); + } + + /** + * 订单确认收货 + * + * @param orderId 单号 + * @param uid uid + */ + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + @Override + public void takeOrder(String orderId, Long uid) { + YxStoreOrderQueryVo order = this.getOrderInfo(orderId, uid); + if (ObjectUtil.isNull(order)) { + throw new YshopException("订单不存在"); + } + order = handleOrder(order); + if (!OrderStatusEnum.STATUS_2.getValue().toString().equals(order.get_status().get_type())) { + throw new BusinessException("订单状态错误"); + } + + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setStatus(OrderInfoEnum.STATUS_2.getValue()); + storeOrder.setId(order.getId()); + yxStoreOrderMapper.updateById(storeOrder); + + //增加状态 + orderStatusService.create(order.getId(), OrderLogEnum.TAKE_ORDER_DELIVERY.getValue(), OrderLogEnum.TAKE_ORDER_DELIVERY.getDesc()); + + //奖励积分 + this.gainUserIntegral(order); + + //分销计算 + userService.backOrderBrokerage(order); + + //检查是否符合会员升级条件 + // userLevelService.setLevelComplete(uid); + } + + + /** + * 核销订单 + * + * @param verifyCode 核销码 + * @param isConfirm OrderInfoEnum + * @param uid uid + * @return YxStoreOrderQueryVo + */ + @Override + public YxStoreOrderQueryVo verifyOrder(String verifyCode, Integer isConfirm, Long uid) { + + YxStoreOrder order = this.getOne(Wrappers.lambdaQuery() + .eq(YxStoreOrder::getVerifyCode, verifyCode) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue())); + if (order == null) { + throw new YshopException("核销的订单不存在或未支付或已退款"); + } + + if (uid != null) { + boolean checkStatus = systemStoreStaffService.checkStatus(uid, order.getStoreId()); + if (!checkStatus) { + throw new YshopException("您没有当前店铺核销权限"); + } + } + + if (!OrderInfoEnum.STATUS_0.getValue().equals(order.getStatus())) { + throw new YshopException("订单已经核销"); + } + + if (order.getCombinationId() != null && order.getCombinationId() > 0 + && order.getPinkId() != null && order.getPinkId() > 0) { + YxStorePink storePink = storePinkService.getById(order.getPinkId()); + if (!OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())) { + throw new YshopException("拼团订单暂未成功无法核销"); + } + } + + YxStoreOrderQueryVo orderQueryVo = generator.convert(order, YxStoreOrderQueryVo.class); + if (OrderInfoEnum.CONFIRM_STATUS_0.getValue().equals(isConfirm)) { + return orderQueryVo; + } + + + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setStatus(OrderInfoEnum.STATUS_2.getValue()); + storeOrder.setId(order.getId()); + yxStoreOrderMapper.updateById(storeOrder); + + //增加状态 + orderStatusService.create(order.getId(), OrderLogEnum.TAKE_ORDER_DELIVERY.getValue(), "已核销"); + + //奖励积分 + this.gainUserIntegral(orderQueryVo); + + //分销计算 + userService.backOrderBrokerage(orderQueryVo); + + //检查是否符合会员升级条件 + userLevelService.setLevelComplete(order.getUid()); + + return null; + } + + /** + * 申请退款 + * + * @param explain 退款备注 + * @param Img 图片 + * @param text 理由 + * @param orderId 订单号 + * @param uid uid + */ + @Override + public void orderApplyRefund(String explain, String Img, String text, String orderId, Long uid) { + YxStoreOrderQueryVo order = getOrderInfo(orderId, uid); + if (order == null) { + throw new YshopException("订单不存在"); + } + + if (OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus())) { + throw new YshopException("订单已退款"); + } + if (OrderInfoEnum.REFUND_STATUS_1.getValue().equals(order.getRefundStatus())) { + throw new YshopException("正在申请退款中"); + } + if (OrderInfoEnum.STATUS_1.getValue().equals(order.getStatus())) { + throw new YshopException("订单当前无法退款"); + } + + + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_1.getValue()); + storeOrder.setRefundReasonTime(new Date()); + storeOrder.setRefundReasonWapExplain(explain); + storeOrder.setRefundReasonWapImg(Img); + storeOrder.setRefundReasonWap(text); + storeOrder.setId(order.getId()); + yxStoreOrderMapper.updateById(storeOrder); + + //增加状态 + orderStatusService.create(order.getId(), + OrderLogEnum.REFUND_ORDER_APPLY.getValue(), + "用户申请退款,原因:" + text); + + //模板消息发布事件 + TemplateBean templateBean = TemplateBean.builder() + .orderId(order.getOrderId()) + .price(order.getPayPrice().toString()) + .uid(order.getUid()) + .templateType(TemplateListenEnum.TYPE_9.getValue()) + .time(DateUtil.formatTime(new Date())) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + + } + + /** + * 订单列表 + * + * @param uid 用户id + * @param type OrderStatusEnum + * @param page page + * @param limit limit + * @return list + */ + @Override + public Map orderList(Long uid, int type, int page, int limit) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapper.eq(YxStoreOrder::getUid, uid); + } + wrapper.orderByDesc(YxStoreOrder::getId); + + switch (OrderStatusEnum.toType(type)) { + case STATUS__1: + break; + //未支付 + case STATUS_0: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); + break; + //待发货 + case STATUS_1: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); + break; + //待收货 + case STATUS_2: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_1.getValue()); + break; + //待评价 + case STATUS_3: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_2.getValue()); + break; + //已完成 + case STATUS_4: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_3.getValue()); + break; + //退款中 + case STATUS_MINUS_1: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_1.getValue()); + break; + //已退款 + case STATUS_MINUS_2: + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_2.getValue()); + break; + //退款 + case STATUS_MINUS_3: + String[] strs = {"1", "2"}; + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .in(YxStoreOrder::getRefundStatus, Arrays.asList(strs)); + break; + default: + } + + Page pageModel = new Page<>(page, limit); + IPage pageList = yxStoreOrderMapper.selectPage(pageModel, wrapper); + List list = generator.convert(pageList.getRecords(), YxStoreOrderQueryVo.class); + Map map = new HashMap<>(); + map.put("list", list.stream() + .map(this::handleOrder) + .collect(Collectors.toList())); + map.put("total", pageList.getTotal()); + map.put("totalPage", pageList.getPages()); + return map; + + } + + /** + * chart图标统计 + * + * @param cate + * @param type + * @return + */ + // @Override + @Deprecated + /** + public Map chartCount(int cate,int type) { + int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date())); + int yesterday = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil. + yesterday())); + int lastWeek = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.lastWeek())); + int nowMonth = OrderUtil.dateToTimestampT(DateUtil + .beginOfMonth(new Date())); + double price = 0d; + List list = null; + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq("paid",1).eq("refund_status",0).eq("is_del",0); + + switch (OrderCountEnum.toType(cate)){ + case TODAY: //今天 + wrapper.ge("pay_time",today); + break; + case YESTERDAY: //昨天 + wrapper.lt("pay_time",today).ge("pay_time",yesterday); + break; + case WEEK: //上周 + wrapper.ge("pay_time",lastWeek); + break; + case MONTH: //本月 + wrapper.ge("pay_time",nowMonth); + break; + } + if(type == 1){ + list = yxStoreOrderMapper.chartList(wrapper); + price = yxStoreOrderMapper.todayPrice(wrapper); + }else{ + list = yxStoreOrderMapper.chartListT(wrapper); + price = yxStoreOrderMapper.selectCount(wrapper).doubleValue(); + } + + Map map = new LinkedHashMap<>(); + map.put("chart",list); + map.put("time",price); + return map; + } + **/ + + /** + * 获取 今日 昨日 本月 订单金额 + * @return ShoperOrderTimeDataVo + */ + @Override + public ShoperOrderTimeDataVo getShoperOrderTimeData() { + + Date today = DateUtil.beginOfDay(new Date()); + Date yesterday = DateUtil.beginOfDay(DateUtil.yesterday()); + Date nowMonth = DateUtil.beginOfMonth(new Date()); + Date lastWeek = DateUtil.beginOfDay(DateUtil.lastWeek()); + + ShoperOrderTimeDataVo orderTimeDataVo = new ShoperOrderTimeDataVo(); + + //今日成交额 + LambdaQueryWrapper wrapperOne = new LambdaQueryWrapper<>(); + wrapperOne + .ge(YxStoreOrder::getPayTime, today) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); + orderTimeDataVo.setTodayPrice(yxStoreOrderMapper.todayPrice(wrapperOne)); + //今日订单数 + orderTimeDataVo.setTodayCount(yxStoreOrderMapper.selectCount(wrapperOne)); + + //昨日成交额 + LambdaQueryWrapper wrapperTwo = new LambdaQueryWrapper<>(); + wrapperTwo + .lt(YxStoreOrder::getPayTime, today) + .ge(YxStoreOrder::getPayTime, yesterday) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); + orderTimeDataVo.setProPrice(yxStoreOrderMapper.todayPrice(wrapperTwo)); + //昨日订单数 + orderTimeDataVo.setProCount(yxStoreOrderMapper.selectCount(wrapperTwo)); + + //本月成交额 + LambdaQueryWrapper wrapperThree = new LambdaQueryWrapper<>(); + wrapperThree + .ge(YxStoreOrder::getPayTime, nowMonth) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); + orderTimeDataVo.setMonthPrice(yxStoreOrderMapper.todayPrice(wrapperThree)); + //本月订单数 + orderTimeDataVo.setMonthCount(yxStoreOrderMapper.selectCount(wrapperThree)); + + //上周成交额 + LambdaQueryWrapper wrapperLastWeek = new LambdaQueryWrapper<>(); + wrapperLastWeek + .lt(YxStoreOrder::getPayTime, today) + .ge(YxStoreOrder::getPayTime, lastWeek) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); + orderTimeDataVo.setLastWeekPrice(yxStoreOrderMapper.todayPrice(wrapperLastWeek)); + //上周订单数 + orderTimeDataVo.setLastWeekCount(yxStoreOrderMapper.selectCount(wrapperLastWeek)); + + + return orderTimeDataVo; + } + + /** + * 订单每月统计数据 + * + * @param page page + * @param limit list + * @return List + */ + @Override + public List getOrderDataPriceCount(int page, int limit) { + Page pageModel = new Page<>(page, limit); + return yxStoreOrderMapper.getOrderDataPriceList(pageModel); + } + + /** + * 获取某个用户的订单统计数据 + * + * @param uid uid>0 取用户 否则取所有 + * @return UserOrderCountVo + */ + @Override + public UserOrderCountVo orderData(Long uid) { + + //订单支付没有退款 数量 + LambdaQueryWrapper wrapperOne = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperOne.eq(YxStoreOrder::getUid, uid); + } + wrapperOne.eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()); + Long orderCount = yxStoreOrderMapper.selectCount(wrapperOne); + + //订单支付没有退款 支付总金额 + double sumPrice = yxStoreOrderMapper.sumPrice(uid); + + //订单待支付 数量 + LambdaQueryWrapper wrapperTwo = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperTwo.eq(YxStoreOrder::getUid, uid); + } + wrapperTwo.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); + Long unpaidCount = yxStoreOrderMapper.selectCount(wrapperTwo); + + //订单待发货 数量 + LambdaQueryWrapper wrapperThree = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperThree.eq(YxStoreOrder::getUid, uid); + } + wrapperThree.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); + Long unshippedCount = yxStoreOrderMapper.selectCount(wrapperThree); + + //订单待收货 数量 + LambdaQueryWrapper wrapperFour = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperFour.eq(YxStoreOrder::getUid, uid); + } + wrapperFour.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_1.getValue()); + Long receivedCount = yxStoreOrderMapper.selectCount(wrapperFour); + + //订单待评价 数量 + LambdaQueryWrapper wrapperFive = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperFive.eq(YxStoreOrder::getUid, uid); + } + wrapperFive.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_2.getValue()); + Long evaluatedCount = yxStoreOrderMapper.selectCount(wrapperFive); + + //订单已完成 数量 + LambdaQueryWrapper wrapperSix = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperSix.eq(YxStoreOrder::getUid, uid); + } + wrapperSix.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_3.getValue()); + Long completeCount = yxStoreOrderMapper.selectCount(wrapperSix); + + //订单退款 + LambdaQueryWrapper wrapperSeven = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperSeven.eq(YxStoreOrder::getUid, uid); + } + String[] strArr = {"1", "2"}; + wrapperSeven.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .in(YxStoreOrder::getRefundStatus, Arrays.asList(strArr)); + Long refundCount = yxStoreOrderMapper.selectCount(wrapperSeven); + + + return UserOrderCountVo.builder() + .orderCount(orderCount) + .sumPrice(sumPrice) + .unpaidCount(unpaidCount) + .unshippedCount(unshippedCount) + .receivedCount(receivedCount) + .evaluatedCount(evaluatedCount) + .completeCount(completeCount) + .refundCount(refundCount) + .build(); + } + + /** + * 处理订单返回的状态 + * + * @param order order + * @return YxStoreOrderQueryVo + */ + @Override + public YxStoreOrderQueryVo handleOrder(YxStoreOrderQueryVo order) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreOrderCartInfo::getOid, order.getId()); + List cartInfos = orderCartInfoService.list(wrapper); + + List cartInfo = cartInfos.stream() + .map(cart -> { + YxStoreCartQueryVo cartQueryVo = JSON.parseObject(cart.getCartInfo(), YxStoreCartQueryVo.class); + cartQueryVo.setUnique(cart.getUnique()); + cartQueryVo.setIsReply(productReplyService.replyCount(cart.getUnique())); + return cartQueryVo; + }) + .collect(Collectors.toList()); + order.setCartInfo(cartInfo); + + StatusDto statusDTO = new StatusDto(); + if (OrderStatusEnum.STATUS_0.getValue().equals(order.getPaid())) { + //计算未支付到自动取消订 时间 + int offset = Integer.valueOf(String.valueOf(ShopConstants.ORDER_OUTTIME_UNPAY)); + Date time = DateUtil.offsetMinute(order.getCreateTime(), offset); + statusDTO.set_class("nobuy"); + statusDTO.set_msg(StrUtil.format("请在{}前完成支付", DateUtil.formatDateTime(time))); + statusDTO.set_type("0"); + statusDTO.set_title("未支付"); + } else if (OrderInfoEnum.REFUND_STATUS_1.getValue().equals(order.getRefundStatus())) { + statusDTO.set_class("state-sqtk"); + statusDTO.set_msg("商家审核中,请耐心等待"); + statusDTO.set_type("-1"); + statusDTO.set_title("申请退款中"); + } else if (OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus())) { + statusDTO.set_class("state-sqtk"); + statusDTO.set_msg("已为您退款,感谢您的支持"); + statusDTO.set_type("-2"); + statusDTO.set_title("已退款"); + } else if (OrderInfoEnum.STATUS_0.getValue().equals(order.getStatus())) { + // 拼团 + if (order.getPinkId() > 0) { + if (pinkService.pinkIngCount(order.getPinkId()) > 0) { + statusDTO.set_class("state-nfh"); + statusDTO.set_msg("待其他人参加拼团"); + statusDTO.set_type("1"); + statusDTO.set_title("拼团中"); + } else { + statusDTO.set_class("state-nfh"); + statusDTO.set_msg("商家未发货,请耐心等待"); + statusDTO.set_type("1"); + statusDTO.set_title("未发货"); + } + } else { + if (OrderInfoEnum.SHIPPIING_TYPE_1.getValue().equals(order.getShippingType())) { + statusDTO.set_class("state-nfh"); + statusDTO.set_msg("商家未发货,请耐心等待"); + statusDTO.set_type("1"); + statusDTO.set_title("未发货"); + } else { + statusDTO.set_class("state-nfh"); + statusDTO.set_msg("待核销,请到核销点进行核销"); + statusDTO.set_type("1"); + statusDTO.set_title("待核销"); + } + } + + } else if (OrderInfoEnum.STATUS_1.getValue().equals(order.getStatus())) { + statusDTO.set_class("state-ysh"); + statusDTO.set_msg("服务商已发货"); + statusDTO.set_type("2"); + statusDTO.set_title("待收货"); + } else if (OrderInfoEnum.STATUS_2.getValue().equals(order.getStatus())) { + statusDTO.set_class("state-ypj"); + statusDTO.set_msg("已收货,快去评价一下吧"); + statusDTO.set_type("3"); + statusDTO.set_title("待评价"); + } else if (OrderInfoEnum.STATUS_3.getValue().equals(order.getStatus())) { + statusDTO.set_class("state-ytk"); + statusDTO.set_msg("交易完成,感谢您的支持"); + statusDTO.set_type("4"); + statusDTO.set_title("交易完成"); + } + + if (PayTypeEnum.WEIXIN.getValue().equals(order.getPayType())) { + statusDTO.set_payType("微信支付"); + } else if (PayTypeEnum.YUE.getValue().equals(order.getPayType())) { + statusDTO.set_payType("余额支付"); + } else { + statusDTO.set_payType("积分支付"); + } + + order.set_status(statusDTO); + + + return order; + } + + /** + * 支付成功后操作 + * + * @param orderId 订单号 + * @param payType 支付方式 + */ + @Override + public void paySuccess(String orderId, String payType) { + YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId, null); + + //更新订单状态 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreOrder::getOrderId, orderId); + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + storeOrder.setPayType(payType); + storeOrder.setPayTime(new Date()); + yxStoreOrderMapper.update(storeOrder, wrapper); + + //增加用户购买次数 + userService.incPayCount(orderInfo.getUid()); + //增加状态 + orderStatusService.create(orderInfo.getId(), OrderLogEnum.PAY_ORDER_SUCCESS.getValue(), + OrderLogEnum.PAY_ORDER_SUCCESS.getDesc()); + //拼团 + if (orderInfo.getCombinationId() > 0) { + pinkService.createPink(orderInfo); + } + + //砍价 + if (orderInfo.getBargainId() > 0) { + storeBargainUserService.setBargainUserStatus(orderInfo.getBargainId(), orderInfo.getUid()); + } + + YxUser userInfo = userService.getById(orderInfo.getUid()); + //增加流水 + String payTypeMsg = PayTypeEnum.WEIXIN.getDesc(); + if (PayTypeEnum.YUE.getValue().equals(payType)) { + payTypeMsg = PayTypeEnum.YUE.getDesc(); + } + billService.expend(userInfo.getUid(), "购买商品", + BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_3.getValue(), + orderInfo.getPayPrice().doubleValue(), userInfo.getNowMoney().doubleValue(), + payTypeMsg + orderInfo.getPayPrice() + "元购买商品"); + + + //模板消息支付成功发布事件 + TemplateBean templateBean = TemplateBean.builder() + .orderId(orderInfo.getOrderId()) + .price(orderInfo.getPayPrice().toString()) + .uid(orderInfo.getUid()) + .templateType(TemplateListenEnum.TYPE_1.getValue()) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + + } + + + /** + * 支付宝支付 + * + * @param orderId,支付宝支付 本系统已经集成,请自行根据下面找到代码整合下即可 + * @return + */ + @Override + public String aliPay(String orderId) throws Exception { + AlipayConfig alipay = alipayService.find(); + if (ObjectUtil.isNull(alipay)) { + throw new YshopException("请先配置支付宝"); + } + YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId, null); + if (ObjectUtil.isNull(orderInfo)) { + throw new YshopException("订单不存在"); + } + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) { + throw new YshopException("该订单已支付"); + } + + if (orderInfo.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) { + throw new YshopException("该支付无需支付"); + } + TradeVo trade = new TradeVo(); + trade.setOutTradeNo(orderId); + String payUrl = alipayService.toPayAsWeb(alipay, trade); + return payUrl; + } + + + /** + * 余额支付 + * + * @param orderId 订单号 + * @param uid 用户id + */ + @Override + public void yuePay(String orderId, Long uid) { + YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId, uid); + if (ObjectUtil.isNull(orderInfo)) { + throw new YshopException("订单不存在"); + } + + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) { + throw new YshopException("该订单已支付"); + } + + YxUserQueryVo userInfo = userService.getYxUserById(uid); + + if (userInfo.getNowMoney().compareTo(orderInfo.getPayPrice()) < 0) { + throw new YshopException("余额不足"); + } + + userService.decPrice(uid, orderInfo.getPayPrice()); + + //支付成功后处理 + this.paySuccess(orderInfo.getOrderId(), PayTypeEnum.YUE.getValue()); + } + + + /** + * 积分兑换 + * + * @param orderId 订单号 + * @param uid 用户id + */ + @Override + public void integralPay(String orderId, Long uid) { + YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId, uid); + if (ObjectUtil.isNull(orderInfo)) { + throw new YshopException("订单不存在"); + } + + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(orderInfo.getPaid())) { + throw new YshopException("该订单已支付"); + } + orderInfo = handleOrder(orderInfo); + orderInfo.getCartInfo().forEach(cart -> { + if (cart.getProductInfo().getIsIntegral() == 0) { + throw new YshopException("该商品不为积分商品"); + } + }); + YxUser userInfo = userService.getById(uid); + + if (userInfo.getIntegral().compareTo(orderInfo.getPayIntegral()) < 0) { + throw new YshopException("积分不足"); + } + + //扣除积分 + //userService.decIntegral(uid,orderInfo.getPayIntegral().doubleValue()); + BigDecimal newIntegral = NumberUtil.sub(userInfo.getIntegral(), orderInfo.getPayIntegral()); + userInfo.setIntegral(newIntegral); + userService.updateById(userInfo); + //增加流水 + billService.expend(userInfo.getUid(), "兑换商品", BillDetailEnum.CATEGORY_2.getValue(), + BillDetailEnum.TYPE_8.getValue(), + orderInfo.getPayIntegral().doubleValue(), + newIntegral.doubleValue(), + "兑换商品扣除" + orderInfo.getPayIntegral().doubleValue() + "积分"); + //支付成功后处理 + this.paySuccess(orderInfo.getOrderId(), PayTypeEnum.INTEGRAL.getValue()); + } + + + /** + * 订单信息 + * + * @param unique 唯一值或者单号 + * @param uid 用户id + * @return YxStoreOrderQueryVo + */ + @Override + public YxStoreOrderQueryVo getOrderInfo(String unique, Long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and( + i -> i.eq(YxStoreOrder::getOrderId, unique).or().eq(YxStoreOrder::getUnique, unique).or() + .eq(YxStoreOrder::getExtendOrderId, unique)); + if (uid != null) { + wrapper.eq(YxStoreOrder::getUid, uid); + } + + return generator.convert(yxStoreOrderMapper.selectOne(wrapper), YxStoreOrderQueryVo.class); + } + + + /** + * 奖励积分 + * + * @param order 订单 + */ + private void gainUserIntegral(YxStoreOrderQueryVo order) { + if (order.getGainIntegral().compareTo(BigDecimal.ZERO) > 0) { + YxUser user = userService.getById(order.getUid()); + + BigDecimal newIntegral = NumberUtil.add(user.getIntegral(), order.getGainIntegral()); + user.setIntegral(newIntegral); + user.setUid(order.getUid()); + userService.updateById(user); + + //增加流水 + billService.income(user.getUid(), "购买商品赠送积分", BillDetailEnum.CATEGORY_2.getValue(), + BillDetailEnum.TYPE_9.getValue(), + order.getGainIntegral().doubleValue(), + newIntegral.doubleValue(), + "购买商品赠送" + order.getGainIntegral() + "积分", order.getId().toString()); + } + } + + /** + * 减库存增加销量 + * + * @param cartInfo 购物车 + */ + public void deStockIncSale(List cartInfo) { + for (YxStoreCartQueryVo storeCartVO : cartInfo) { + Long combinationId = storeCartVO.getCombinationId(); + Long seckillId = storeCartVO.getSeckillId(); + Long bargainId = storeCartVO.getBargainId(); + if (combinationId != null && combinationId > 0) { + productService.decProductStock(storeCartVO.getCartNum(), storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(), combinationId, ProductTypeEnum.COMBINATION.getValue()); + } else if (seckillId != null && seckillId > 0) { + productService.decProductStock(storeCartVO.getCartNum(), storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(), seckillId, ProductTypeEnum.SECKILL.getValue()); + } else if (bargainId != null && bargainId > 0) { + storeBargainService.decStockIncSales(storeCartVO.getCartNum(), bargainId); + } else { + productService.decProductStock(storeCartVO.getCartNum(), storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(), 0L, ""); + } + } + } + + + /** + * 积分抵扣 + * + * @param userInfo 用户信息 + * @param usedIntegral 使用得积分 + * @param deductionPrice 抵扣的金额 + */ + private void decIntegral(YxUser userInfo, double usedIntegral, double deductionPrice) { + userService.decIntegral(userInfo.getUid(), usedIntegral); + billService.expend(userInfo.getUid(), "积分抵扣", BillDetailEnum.CATEGORY_2.getValue(), + BillDetailEnum.TYPE_8.getValue(), usedIntegral, userInfo.getIntegral().doubleValue(), + "购买商品使用" + usedIntegral + "积分抵扣" + deductionPrice + "元"); + } + + /** + * 计算奖励的积分 + * + * @param cartInfo cartInfo + * @return double + */ + private BigDecimal getGainIntegral(List cartInfo) { + BigDecimal gainIntegral = BigDecimal.ZERO; + for (YxStoreCartQueryVo cart : cartInfo) { + if (cart.getCombinationId() > 0 || cart.getSeckillId() > 0 || cart.getBargainId() > 0) { + continue; + } + BigDecimal cartInfoGainIntegral = BigDecimal.ZERO; + Double gain = cart.getProductInfo().getGiveIntegral().doubleValue(); + if (gain > 0) { + cartInfoGainIntegral = NumberUtil.round(NumberUtil.mul(cart.getCartNum(), gain), 2); + } + gainIntegral = NumberUtil.add(gainIntegral, cartInfoGainIntegral); + } + return gainIntegral; + } + + + /** + * 退回优惠券 + * + * @param order 订单 + */ + private void regressionCoupon(YxStoreOrderQueryVo order, Integer type) { + if (type == 0) { + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getPaid()) + || OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus())) { + return; + } + } else { + if (!(OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getPaid()) + && OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus()))) { + return; + } + } + + if (order.getCouponId() != null && order.getCouponId() > 0) { + YxStoreCouponUser couponUser = couponUserService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreCouponUser::getId, order.getCouponId()) + .eq(YxStoreCouponUser::getStatus, CouponEnum.STATUS_1.getValue()) + .eq(YxStoreCouponUser::getUid, order.getUid())); + + if (ObjectUtil.isNotNull(couponUser)) { + YxStoreCouponUser storeCouponUser = new YxStoreCouponUser(); + storeCouponUser.setStatus(CouponEnum.STATUS_0.getValue()); + storeCouponUser.setUseTime(null); + couponUserService.update(storeCouponUser, Wrappers.lambdaQuery() + .eq(YxStoreCouponUser::getId, order.getCouponId()) + .eq(YxStoreCouponUser::getUid, order.getUid())); + } + } + + } + + /** + * 退回库存 + * + * @param order 订单 + */ + private void regressionStock(YxStoreOrderQueryVo order, Integer type) { + if (type == 0) { + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getPaid()) + || OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus())) { + return; + } + } else { + if (!(OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getPaid()) + && OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus()))) { + return; + } + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(YxStoreOrderCartInfo::getCartId, Arrays.asList(order.getCartId().split(","))); + + List cartInfoList = orderCartInfoService.list(wrapper); + for (YxStoreOrderCartInfo cartInfo : cartInfoList) { + YxStoreCartQueryVo cart = JSONObject.parseObject(cartInfo.getCartInfo() + , YxStoreCartQueryVo.class); + if (order.getCombinationId() != null && order.getCombinationId() > 0) {//拼团 + productService.incProductStock(cart.getCartNum(), cart.getProductId(), cart.getProductAttrUnique(), order.getCombinationId(), ProductTypeEnum.COMBINATION.getValue()); + } else if (order.getSeckillId() != null && order.getSeckillId() > 0) {//秒杀 + productService.incProductStock(cart.getCartNum(), cart.getProductId(), cart.getProductAttrUnique(), order.getSeckillId(), ProductTypeEnum.SECKILL.getValue()); + } else if (order.getBargainId() != null && order.getBargainId() > 0) {//砍价 + storeBargainService.incStockDecSales(cart.getCartNum(), order.getBargainId()); + } else { + productService.incProductStock(cart.getCartNum(), cart.getProductId() + , cart.getProductAttrUnique(), 0L, null); + } + + } + } + + /** + * 退回积分 + * + * @param order 订单 + */ + private void regressionIntegral(YxStoreOrderQueryVo order, Integer type) { + if (type == 0) { + if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getPaid()) + || OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus())) { + return; + } + } else { + if (!(OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getPaid()) + && OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus()))) { + return; + } + } + + if (order.getPayIntegral().compareTo(BigDecimal.ZERO) > 0) { + order.setUseIntegral(order.getPayIntegral()); + } + if (order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) { + return; + } + + if (!OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus()) + && !OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus()) + && order.getBackIntegral().compareTo(BigDecimal.ZERO) > 0) { + return; + } + + YxUser yxUser = userService.getById(order.getUid()); + + //增加积分 + BigDecimal newIntegral = NumberUtil.add(order.getUseIntegral(), yxUser.getIntegral()); + yxUser.setIntegral(newIntegral); + userService.updateById(yxUser); + + //增加流水 + billService.income(yxUser.getUid(), "积分回退", BillDetailEnum.CATEGORY_2.getValue(), + BillDetailEnum.TYPE_8.getValue(), + order.getUseIntegral().doubleValue(), + newIntegral.doubleValue(), + "购买商品失败,回退积分" + order.getUseIntegral(), order.getId().toString()); + + //更新回退积分 + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setBackIntegral(order.getUseIntegral()); + storeOrder.setId(order.getId()); + yxStoreOrderMapper.updateById(storeOrder); + } + + /** + * 获取订单缓存 + * + * @param uid uid + * @param key key + * @return CacheDto + */ + private CacheDto getCacheOrderInfo(Long uid, String key) { + Object obj = redisUtils.get(ShopConstants.YSHOP_ORDER_CACHE_KEY + uid + key); + if (obj == null) { + return null; + } + return JSON.parseObject(obj.toString(), CacheDto.class); + } + + + /** + * 删除订单缓存 + * + * @param uid uid + * @param key key + */ + private void delCacheOrderInfo(Long uid, String key) { + redisUtils.del(ShopConstants.YSHOP_ORDER_CACHE_KEY + uid + key); + } + + /** + * 缓存订单 + * + * @param uid uid + * @param cartInfo cartInfo + * @param priceGroup priceGroup + * @param other other + * @return string + */ + private String cacheOrderInfo(Long uid, List cartInfo, PriceGroupDto priceGroup, OtherDto other) { + String key = IdUtil.simpleUUID(); + CacheDto cacheDTO = new CacheDto(); + cacheDTO.setCartInfo(cartInfo); + cacheDTO.setPriceGroup(priceGroup); + cacheDTO.setOther(other); + redisUtils.set(ShopConstants.YSHOP_ORDER_CACHE_KEY + uid + key, + JSON.toJSONString(cacheDTO), + ShopConstants.YSHOP_ORDER_CACHE_TIME); + return key; + } + + /** + * 获取订单价格 + * + * @param cartInfo 购物车列表 + * @return PriceGroupDto + */ + private PriceGroupDto getOrderPriceGroup(List cartInfo, YxUserAddress userAddress) { + + BigDecimal storePostage = BigDecimal.ZERO; + + + String storeFreePostageStr = systemConfigService.getData(SystemConfigConstants.STORE_FREE_POSTAGE);//满额包邮 + BigDecimal storeFreePostage = BigDecimal.ZERO; + if (NumberUtil.isNumber(storeFreePostageStr) && StrUtil.isNotBlank(storeFreePostageStr)) { + storeFreePostage = new BigDecimal(storeFreePostageStr); + } + + + BigDecimal totalPrice = this.getOrderSumPrice(cartInfo, "truePrice");//获取订单总金额 + BigDecimal costPrice = this.getOrderSumPrice(cartInfo, "costPrice");//获取订单成本价 + BigDecimal vipPrice = this.getOrderSumPrice(cartInfo, "vipTruePrice");//获取订单会员优惠金额 + BigDecimal payIntegral = this.getOrderSumPrice(cartInfo, "payIntegral");//获取订单需要的积分 + + //如果设置满包邮0 表示全局包邮,如果设置大于0表示满这价格包邮,否则走运费模板算法 + if (storeFreePostage.compareTo(BigDecimal.ZERO) != 0 && totalPrice.compareTo(storeFreePostage) <= 0) { + storePostage = this.handlePostage(cartInfo, userAddress); + } + if (cartInfo.size() == 1 && cartInfo.get(0).getProductInfo().getIsIntegral() != null + && cartInfo.get(0).getProductInfo().getIsIntegral() == 1) { + totalPrice = BigDecimal.ZERO; + } + + PriceGroupDto priceGroupDTO = new PriceGroupDto(); + priceGroupDTO.setStorePostage(storePostage); + priceGroupDTO.setStoreFreePostage(storeFreePostage); + priceGroupDTO.setTotalPrice(totalPrice); + priceGroupDTO.setCostPrice(costPrice); + priceGroupDTO.setVipPrice(vipPrice); + priceGroupDTO.setPayIntegral(payIntegral); + return priceGroupDTO; + } + + + /** + * 根据运费模板算法返回邮费 + * + * @param cartInfo 购物车 + * @param userAddress 地址 + * @return double + */ + private BigDecimal handlePostage(List cartInfo, YxUserAddress userAddress) { + BigDecimal storePostage = BigDecimal.ZERO; + if (userAddress != null) { + if (userAddress.getCityId() == null) { + return storePostage; + } + //城市包括默认 + int cityId = userAddress.getCityId(); + List citys = new ArrayList<>(); + citys.add(cityId); + citys.add(0); + + List storeProductVOList = cartInfo + .stream() + .map(YxStoreCartQueryVo::getProductInfo) + .collect(Collectors.toList()); + List tempIdS = storeProductVOList + .stream() + .map(YxStoreProductQueryVo::getTempId) + .collect(Collectors.toList()); + + + //获取商品用到的运费模板 + List shippingTemplatesList = shippingTemplatesService + .list(Wrappers.lambdaQuery() + .in(YxShippingTemplates::getId, tempIdS)); + //获取运费模板区域列表按照城市排序 + List shippingTemplatesRegionList = shippingTemplatesRegionService + .list(Wrappers.lambdaQuery() + .in(YxShippingTemplatesRegion::getTempId, tempIdS) + .in(YxShippingTemplatesRegion::getCityId, citys) + .orderByAsc(YxShippingTemplatesRegion::getCityId)); + //提取运费模板类型 + Map shippingTemplatesMap = shippingTemplatesList + .stream() + .collect(Collectors.toMap(YxShippingTemplates::getId, + YxShippingTemplates::getType)); + //提取运费模板有相同值覆盖 + Map shippingTemplatesRegionMap = + shippingTemplatesRegionList.stream() + .collect(Collectors.toMap(YxShippingTemplatesRegion::getTempId, + YxShippingTemplatesRegion -> YxShippingTemplatesRegion, + (key1, key2) -> key2)); + + + Map templateDTOMap = new HashMap<>(); + for (YxStoreCartQueryVo storeCartVO : cartInfo) { + Integer tempId = storeCartVO.getProductInfo().getTempId(); + + //处理拼团等营销商品没有设置运费模板 + if (tempId == null) { + return storePostage; + } + + //根据模板类型获取相应的数量 + double num = 0d; + if (ShippingTempEnum.TYPE_1.getValue().equals(shippingTemplatesMap.get(tempId))) { + num = storeCartVO.getCartNum().doubleValue(); + } else if (ShippingTempEnum.TYPE_2.getValue().equals(shippingTemplatesMap.get(tempId))) { + num = NumberUtil.mul(storeCartVO.getCartNum(), + storeCartVO.getProductInfo().getAttrInfo().getWeight()).doubleValue(); + } else if (ShippingTempEnum.TYPE_3.getValue().equals(shippingTemplatesMap.get(tempId))) { + num = NumberUtil.mul(storeCartVO.getCartNum(), + storeCartVO.getProductInfo().getAttrInfo().getVolume()).doubleValue(); + } + + YxShippingTemplatesRegion shippingTemplatesRegion = shippingTemplatesRegionMap.get(tempId); + BigDecimal price = NumberUtil.round(NumberUtil.mul(storeCartVO.getCartNum(), + storeCartVO.getTruePrice()), 2); + if (!templateDTOMap.containsKey(tempId)) { + TemplateDto templateDTO = TemplateDto.builder() + .number(num) + .price(price) + .first(shippingTemplatesRegion.getFirst().doubleValue()) + .firstPrice(shippingTemplatesRegion.getFirstPrice()) + ._continue(shippingTemplatesRegion.getContinues().doubleValue()) + .continuePrice(shippingTemplatesRegion.getContinuePrice()) + .tempId(tempId) + .cityId(cityId) + .build(); + templateDTOMap.put(tempId, templateDTO); + } else { + TemplateDto templateDTO = templateDTOMap.get(tempId); + templateDTO.setNumber(templateDTO.getNumber() + num); + templateDTO.setPrice(NumberUtil.add(templateDTO.getPrice().doubleValue(), price)); + } + + + } + + //处理包邮情况 + jj: for (Map.Entry entry : templateDTOMap.entrySet()) { + Integer mapKey = entry.getKey(); + TemplateDto mapValue = entry.getValue(); + + Long count = shippingTemplatesFreeService.count(Wrappers.lambdaQuery() + .eq(YxShippingTemplatesFree::getTempId, mapValue.getTempId()) + .eq(YxShippingTemplatesFree::getCityId, mapValue.getCityId()) + .le(YxShippingTemplatesFree::getNumber, mapValue.getNumber()) + .le(YxShippingTemplatesFree::getPrice, mapValue.getPrice())); + //满足包邮条件剔除 + if (count > 0) { + templateDTOMap.remove(mapKey); + break jj; + } + } + + //处理区域邮费 + boolean isFirst = true; //用来是否多个产品的标识 false表示数量大于1 + for (TemplateDto templateDTO : templateDTOMap.values()) { + if (isFirst) {//首件 + //只满足首件 + if (Double.compare(templateDTO.getNumber(), templateDTO.getFirst()) <= 0) { + storePostage = NumberUtil.round(NumberUtil.add(storePostage, + templateDTO.getFirstPrice()), 2); + } else { + BigDecimal firstPrice = NumberUtil.add(storePostage, templateDTO.getFirstPrice()); + + if (templateDTO.get_continue() <= 0) { + storePostage = firstPrice; + } else { + //续件平均值且向上取整数 + double average = Math.ceil(NumberUtil.div(NumberUtil.sub(templateDTO.getNumber(), + templateDTO.getFirst()), + templateDTO.get_continue().doubleValue())); + //最终邮费 + storePostage = NumberUtil.add(firstPrice, NumberUtil.mul(average, + templateDTO.getContinuePrice())); + } + + } + + isFirst = false; + } else { + //多件直接在以前的基数继续续建 + if (templateDTO.get_continue() > 0) { + //续件平均值且向上取整数 + double average = Math.ceil( + NumberUtil.div( + templateDTO.getNumber(), + templateDTO.get_continue() + ) + ); + //最终邮费 + storePostage = NumberUtil.add(storePostage.doubleValue(), NumberUtil.mul(average, + templateDTO.getContinuePrice())); + } + } + } + } + + + return storePostage; + } + + /** + * 获取某字段价格 + * + * @param cartInfo 购物车 + * @param key key值 + * @return Double + */ + private BigDecimal getOrderSumPrice(List cartInfo, String key) { + BigDecimal sumPrice = BigDecimal.ZERO; + + if ("truePrice".equals(key)) { + for (YxStoreCartQueryVo storeCart : cartInfo) { + sumPrice = NumberUtil.add(sumPrice, NumberUtil.mul(storeCart.getCartNum(), storeCart.getTruePrice())); + } + } else if ("costPrice".equals(key)) { + for (YxStoreCartQueryVo storeCart : cartInfo) { + sumPrice = NumberUtil.add(sumPrice, + NumberUtil.mul(storeCart.getCartNum(), storeCart.getCostPrice())); + } + } else if ("vipTruePrice".equals(key)) { + for (YxStoreCartQueryVo storeCart : cartInfo) { + sumPrice = NumberUtil.add(sumPrice, + NumberUtil.mul(storeCart.getCartNum(), storeCart.getVipTruePrice())); + } + } else if ("payIntegral".equals(key)) { + for (YxStoreCartQueryVo storeCart : cartInfo) { + if (storeCart.getProductInfo().getAttrInfo() != null && storeCart.getProductInfo().getAttrInfo().getIntegral() != null) { + sumPrice = NumberUtil.add(sumPrice, + NumberUtil.mul(storeCart.getCartNum(), storeCart.getProductInfo().getAttrInfo().getIntegral())); + } + + } + } + + return sumPrice; + } + + + //=======================================================// + + + /** + * 根据商品分类统计订单占比 + * + * @return OrderCountDto + */ + @Override + public OrderCountDto getOrderCount() { + //获取所有订单转态为已支付的 + List nameList = storeCartService.findCateName(); + Map childrenMap = new HashMap<>(); + nameList.forEach(i -> { + if (i != null) { + if (childrenMap.containsKey(i.getCatename())) { + childrenMap.put(i.getCatename(), childrenMap.get(i.getCatename()) + 1); + } else { + childrenMap.put(i.getCatename(), 1); + } + } + + }); + List list = new ArrayList<>(); + List columns = new ArrayList<>(); + childrenMap.forEach((k, v) -> { + OrderCountDto.OrderCountData orderCountData = new OrderCountDto.OrderCountData(); + orderCountData.setName(k); + orderCountData.setValue(v); + columns.add(k); + list.add(orderCountData); + }); + OrderCountDto orderCountDto = new OrderCountDto(); + orderCountDto.setColumn(columns); + orderCountDto.setOrderCountDatas(list); + return orderCountDto; + } + + /** + * 首页订单/用户等统计 + * + * @return OrderTimeDataDto + */ + @Override + public OrderTimeDataDto getOrderTimeData() { + OrderTimeDataDto orderTimeDataDto = new OrderTimeDataDto(); + + ShoperOrderTimeDataVo shoperOrderTimeData = this.getShoperOrderTimeData(); + + BeanUtil.copyProperties(shoperOrderTimeData, orderTimeDataDto); + + + orderTimeDataDto.setUserCount(userService.count()); + orderTimeDataDto.setOrderCount(this.count()); + orderTimeDataDto.setPriceCount(yxStoreOrderMapper.sumTotalPrice()); + orderTimeDataDto.setGoodsCount(productService.count()); + + return orderTimeDataDto; + } + + /** + * 返回本月订单金额与数量 + * + * @return map + */ + @Override + public Map chartCount() { + Map map = new LinkedHashMap<>(); + Date nowMonth = DateUtil.beginOfMonth(new Date()); + + map.put("chart", yxStoreOrderMapper.chartList(nowMonth)); + map.put("chartT", yxStoreOrderMapper.chartListT(nowMonth)); + + return map; + } + + @Override + public void retrunStock(String orderId) { + YxStoreOrderQueryVo order = this.getOrderInfo(orderId, null); + this.regressionIntegral(order, 1); + this.regressionStock(order, 1); + this.regressionCoupon(order, 1); + } + + @Override + public Map queryAll(YxStoreOrderQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + List storeOrderDTOS = new ArrayList<>(); + for (YxStoreOrder yxStoreOrder : page.getList()) { + this.orderList(storeOrderDTOS, yxStoreOrder); + + } + Map map = new LinkedHashMap<>(2); + map.put("content", storeOrderDTOS); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + public List queryAll(YxStoreOrderQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreOrder.class, criteria)); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(YxStoreOrder resources) { + YxStoreOrder yxStoreOrder = this.getById(resources.getId()); + YxStoreOrder yxStoreOrder1 = this.getOne(new LambdaQueryWrapper() + .eq(YxStoreOrder::getUnique, resources.getUnique())); + if (yxStoreOrder1 != null && !yxStoreOrder1.getId().equals(yxStoreOrder.getId())) { + throw new EntityExistException(YxStoreOrder.class, "unique", resources.getUnique()); + } + yxStoreOrder.copy(resources); + this.saveOrUpdate(yxStoreOrder); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreOrderDto yxStoreOrder : all) { + Map map = new LinkedHashMap<>(); + map.put("订单号", yxStoreOrder.getOrderId()); + map.put("用户id", yxStoreOrder.getUid()); + map.put("用户姓名", yxStoreOrder.getRealName()); + map.put("用户电话", yxStoreOrder.getUserPhone()); + map.put("详细地址", yxStoreOrder.getUserAddress()); + map.put("购物车id", yxStoreOrder.getCartId()); + map.put("运费金额", yxStoreOrder.getFreightPrice()); + map.put("订单商品总数", yxStoreOrder.getTotalNum()); + map.put("订单总价", yxStoreOrder.getTotalPrice()); + map.put("邮费", yxStoreOrder.getTotalPostage()); + map.put("实际支付金额", yxStoreOrder.getPayPrice()); + map.put("支付邮费", yxStoreOrder.getPayPostage()); + map.put("抵扣金额", yxStoreOrder.getDeductionPrice()); + map.put("优惠券id", yxStoreOrder.getCouponId()); + map.put("优惠券金额", yxStoreOrder.getCouponPrice()); + map.put("支付状态", yxStoreOrder.getPaid()); + map.put("支付时间", yxStoreOrder.getPayTime()); + map.put("支付方式", yxStoreOrder.getPayType()); + map.put("订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款)", yxStoreOrder.getStatus()); + map.put("0 未退款 1 申请中 2 已退款", yxStoreOrder.getRefundStatus()); + map.put("退款图片", yxStoreOrder.getRefundReasonWapImg()); + map.put("退款用户说明", yxStoreOrder.getRefundReasonWapExplain()); + map.put("退款时间", yxStoreOrder.getRefundReasonTime()); + map.put("前台退款原因", yxStoreOrder.getRefundReasonWap()); + map.put("不退款的理由", yxStoreOrder.getRefundReason()); + map.put("退款金额", yxStoreOrder.getRefundPrice()); + map.put("快递公司编号", yxStoreOrder.getDeliverySn()); + map.put("快递名称/送货人姓名", yxStoreOrder.getDeliveryName()); + map.put("发货类型", yxStoreOrder.getDeliveryType()); + map.put("快递单号/手机号", yxStoreOrder.getDeliveryId()); + map.put("消费赚取积分", yxStoreOrder.getGainIntegral()); + map.put("使用积分", yxStoreOrder.getUseIntegral()); + map.put("给用户退了多少积分", yxStoreOrder.getBackIntegral()); + map.put("备注", yxStoreOrder.getMark()); + map.put("唯一id(md5加密)类似id", yxStoreOrder.getUnique()); + map.put("管理员备注", yxStoreOrder.getRemark()); + map.put("商户ID", yxStoreOrder.getMerId()); + map.put(" isMerCheck", yxStoreOrder.getIsMerCheck()); + map.put("拼团产品id0一般产品", yxStoreOrder.getCombinationId()); + map.put("拼团id 0没有拼团", yxStoreOrder.getPinkId()); + map.put("成本价", yxStoreOrder.getCost()); + map.put("秒杀产品ID", yxStoreOrder.getSeckillId()); + map.put("砍价id", yxStoreOrder.getBargainId()); + map.put("核销码", yxStoreOrder.getVerifyCode()); + map.put("门店id", yxStoreOrder.getStoreId()); + map.put("配送方式 1=快递 ,2=门店自提", yxStoreOrder.getShippingType()); + map.put("支付渠道(0微信公众号1微信小程序)", yxStoreOrder.getIsChannel()); + map.put(" isRemind", yxStoreOrder.getIsRemind()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 获取订单详情 + * + * @param orderId + * @return + */ + @Override + public YxStoreOrderDto getOrderDetail(Long orderId) { + YxStoreOrder yxStoreOrder = this.getById(orderId); + if (ObjectUtil.isEmpty(yxStoreOrder)) { + throw new BadRequestException("订单详情不存在"); + } + YxStoreOrderDto yxStoreOrderDto = generator.convert(yxStoreOrder, YxStoreOrderDto.class); + Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(), yxStoreOrder.getStatus(), + yxStoreOrder.getRefundStatus()); + + if (yxStoreOrder.getStoreId() > 0) { + String storeName = systemStoreService.getById(yxStoreOrder.getStoreId()).getName(); + yxStoreOrderDto.setStoreName(storeName); + } + + //订单状态 + String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid() + , yxStoreOrder.getStatus(), yxStoreOrder.getShippingType() + , yxStoreOrder.getRefundStatus()); + + if (_status == 3) { + + String refundTime = DateUtil.formatDateTime(yxStoreOrder.getRefundReasonTime()); + String str = "申请退款" + + "退款原因:" + yxStoreOrder.getRefundReasonWap() + "" + + "备注说明:" + yxStoreOrder.getRefundReasonWapExplain() + "" + + "退款时间:" + refundTime + ""; + orderStatusStr = str; + } + yxStoreOrderDto.setStatusName(orderStatusStr); + + yxStoreOrderDto.set_status(_status); + + String payTypeName = OrderUtil.payTypeName(yxStoreOrder.getPayType() + , yxStoreOrder.getPaid()); + yxStoreOrderDto.setPayTypeName(payTypeName); + //订单类型处理 + yxStoreOrderDto.setPinkName(this.orderType(yxStoreOrder.getId() + , yxStoreOrder.getPinkId(), yxStoreOrder.getCombinationId() + , yxStoreOrder.getSeckillId(), yxStoreOrder.getBargainId(), + yxStoreOrder.getShippingType(), yxStoreOrder.getPayIntegral())); + + //添加订单状态 + List storeOrderStatuses = orderStatusService.list(new LambdaQueryWrapper() + .eq(YxStoreOrderStatus::getOid, yxStoreOrder.getId())); + List orderStatusDtos = generator.convert(storeOrderStatuses, YxStoreOrderStatusDto.class); + yxStoreOrderDto.setStoreOrderStatusList(orderStatusDtos); + //添加购物车详情 + List cartInfos = storeOrderCartInfoService.list( + new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); + List cartInfoDTOS = new ArrayList<>(); + for (YxStoreOrderCartInfo cartInfo : cartInfos) { + StoreOrderCartInfoDto cartInfoDTO = new StoreOrderCartInfoDto(); + cartInfoDTO.setCartInfoMap(JSON.parseObject(cartInfo.getCartInfo())); + + cartInfoDTOS.add(cartInfoDTO); + } + yxStoreOrderDto.setCartInfoList(cartInfoDTOS); + //添加用户信息 + yxStoreOrderDto.setUserDTO(generator.convert(userService.getById(yxStoreOrder.getUid()), YxUserDto.class)); + if (yxStoreOrderDto.getUserDTO() == null) { + yxStoreOrderDto.setUserDTO(new YxUserDto()); + } + return yxStoreOrderDto; + } + + @Override + public Map queryAll(List ids) { + List yxStoreOrders = this.list(new LambdaQueryWrapper().in(YxStoreOrder::getOrderId, ids)); + List storeOrderDTOS = new ArrayList<>(); + for (YxStoreOrder yxStoreOrder : yxStoreOrders) { + this.orderList(storeOrderDTOS, yxStoreOrder); + } + + Map map = new LinkedHashMap<>(2); + map.put("content", storeOrderDTOS); + + return map; + } + + + /** + * 处理订单 + * + * @param storeOrderDTOS 订单列表 + * @param yxStoreOrder 订单 + */ + private void orderList(List storeOrderDTOS, YxStoreOrder yxStoreOrder) { + YxStoreOrderDto yxStoreOrderDto = generator.convert(yxStoreOrder, YxStoreOrderDto.class); + Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(), yxStoreOrder.getStatus(), + yxStoreOrder.getRefundStatus()); + + if (yxStoreOrder.getStoreId() > 0) { + YxSystemStore systemStore = systemStoreService.getById(yxStoreOrder.getStoreId()); + if (Objects.nonNull(systemStore)) { + String storeName = systemStore.getName(); + yxStoreOrderDto.setStoreName(storeName); + } + } + + //订单状态 + String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid() + , yxStoreOrder.getStatus(), yxStoreOrder.getShippingType() + , yxStoreOrder.getRefundStatus()); + + if (_status == 3) { + + String refundTime = DateUtil.formatDateTime(yxStoreOrder.getRefundReasonTime()); + String str = "申请退款
" + + "退款原因:" + yxStoreOrder.getRefundReasonWap() + "
" + + "备注说明:" + yxStoreOrder.getRefundReasonWapExplain() + "
" + + "退款时间:" + refundTime + "
"; + orderStatusStr = str; + } + yxStoreOrderDto.setStatusName(orderStatusStr); + + yxStoreOrderDto.set_status(_status); + + String payTypeName = OrderUtil.payTypeName(yxStoreOrder.getPayType() + , yxStoreOrder.getPaid()); + yxStoreOrderDto.setPayTypeName(payTypeName); + //订单类型处理 + yxStoreOrderDto.setPinkName(this.orderType(yxStoreOrder.getId() + , yxStoreOrder.getPinkId(), yxStoreOrder.getCombinationId() + , yxStoreOrder.getSeckillId(), yxStoreOrder.getBargainId(), + yxStoreOrder.getShippingType(), yxStoreOrder.getPayIntegral())); + + List cartInfos = storeOrderCartInfoService.list( + new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); + List cartInfoDTOS = new ArrayList<>(); + for (YxStoreOrderCartInfo cartInfo : cartInfos) { + StoreOrderCartInfoDto cartInfoDTO = new StoreOrderCartInfoDto(); + cartInfoDTO.setCartInfoMap(JSON.parseObject(cartInfo.getCartInfo())); + + cartInfoDTOS.add(cartInfoDTO); + } + yxStoreOrderDto.setCartInfoList(cartInfoDTOS); + yxStoreOrderDto.setUserDTO(generator.convert(userService.getById(yxStoreOrder.getUid()), YxUserDto.class)); + if (yxStoreOrderDto.getUserDTO() == null) { + yxStoreOrderDto.setUserDTO(new YxUserDto()); + } + storeOrderDTOS.add(yxStoreOrderDto); + } + + + /** + * 订单状态处理 + * + * @param id 订单id + * @param pinkId 拼团id + * @param combinationId 拼团产品id + * @param seckillId 秒杀id + * @param bargainId 砍价id + * @param shippingType 发货类型 + * @return string + */ + private String orderType(Long id, Long pinkId, Long combinationId, Long seckillId, + Long bargainId, Integer shippingType, BigDecimal payIntegral) { + String str = "[普通订单]"; + if (pinkId > 0 || combinationId > 0) { + YxStorePink storePink = storePinkService.getOne(new LambdaQueryWrapper() + .eq(YxStorePink::getOrderIdKey, id)); + if (ObjectUtil.isNull(storePink)) { + str = "[拼团订单]"; + } else { + if (OrderInfoEnum.PINK_STATUS_1.getValue().equals(storePink.getStatus())) { + str = "[拼团订单]正在进行中"; + } else if (OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())) { + str = "[拼团订单]已完成"; + } else if (OrderInfoEnum.PINK_STATUS_3.getValue().equals(storePink.getStatus())) { + str = "[拼团订单]未完成"; + } else { + str = "[拼团订单]历史订单"; + } + + } + + } else if (seckillId > 0) { + str = "[秒杀订单]"; + } else if (bargainId > 0) { + str = "[砍价订单]"; + } + + if (OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(shippingType)) { + str = "[核销订单]"; + } + if (payIntegral.compareTo(new BigDecimal("0.00")) == 1) { + str = "[积分兑换]"; + } + return str; + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderStatusServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderStatusServiceImpl.java new file mode 100644 index 00000000..6aef21bb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderStatusServiceImpl.java @@ -0,0 +1,94 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.order.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.order.domain.YxStoreOrderStatus; +import co.yixiang.modules.order.service.YxStoreOrderStatusService; +import co.yixiang.modules.order.service.dto.YxStoreOrderStatusDto; +import co.yixiang.modules.order.service.dto.YxStoreOrderStatusQueryCriteria; +import co.yixiang.modules.order.service.mapper.StoreOrderStatusMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreOrderStatusServiceImpl extends BaseServiceImpl implements YxStoreOrderStatusService { + + private final IGenerator generator; + + + /** + * 添加订单操作记录 + * @param oid 订单id + * @param changetype 操作状态 + * @param changeMessage 操作内容 + */ + @Override + public void create(Long oid, String changetype, String changeMessage) { + YxStoreOrderStatus storeOrderStatus = new YxStoreOrderStatus(); + storeOrderStatus.setOid(oid); + storeOrderStatus.setChangeType(changetype); + storeOrderStatus.setChangeMessage(changeMessage); + this.baseMapper.insert(storeOrderStatus); + } + + + + @Override + //@Cacheable + public Map queryAll(YxStoreOrderStatusQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreOrderStatusDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreOrderStatusQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreOrderStatus.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreOrderStatusDto yxStoreOrderStatus : all) { + Map map = new LinkedHashMap<>(); + map.put("订单id", yxStoreOrderStatus.getOid()); + map.put("操作类型", yxStoreOrderStatus.getChangeType()); + map.put("操作备注", yxStoreOrderStatus.getChangeMessage()); + map.put("操作时间", yxStoreOrderStatus.getChangeTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/ExpressMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/ExpressMapper.java new file mode 100644 index 00000000..4a62a10e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/ExpressMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.order.domain.YxExpress; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface ExpressMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderCartInfoMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderCartInfoMapper.java new file mode 100644 index 00000000..c6e90b5f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderCartInfoMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreOrderCartInfoMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java new file mode 100644 index 00000000..474b32ba --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java @@ -0,0 +1,74 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.service.dto.ChartDataDto; +import co.yixiang.modules.order.vo.OrderDataVo; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreOrderMapper extends CoreMapper { + + + + @Select("SELECT sum(pay_price) as price,count(id) as count," + + "DATE_FORMAT(create_time, '%m-%d') as time FROM yx_store_order" + + " WHERE is_del = 0 AND paid = 1 AND refund_status = 0 " + + "GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time DESC") + List getOrderDataPriceList(Page page); + + + @Select("SELECT IFNULL(sum(pay_price),0) " + + " FROM yx_store_order ${ew.customSqlSegment}") + Double todayPrice(@Param(Constants.WRAPPER) Wrapper wrapper); + + + + @Select("select IFNULL(sum(pay_price),0) from yx_store_order " + + "where paid=1 and is_del=0 and refund_status=0 and uid=#{uid}") + double sumPrice(@Param("uid") Long uid); + + + @Select("SELECT COUNT(*) FROM yx_store_order WHERE pay_time >= ${today}") + Integer countByPayTimeGreaterThanEqual(@Param("today")int today); + + @Select("SELECT COUNT(*) FROM yx_store_order WHERE pay_time < ${today} and pay_time >= ${yesterday}") + Integer countByPayTimeLessThanAndPayTimeGreaterThanEqual(@Param("today")int today, @Param("yesterday")int yesterday); + + @Select( "select IFNULL(sum(pay_price),0) from yx_store_order " + + "where refund_status=0 and is_del=0 and paid=1") + Double sumTotalPrice(); + + @Select("SELECT IFNULL(sum(pay_price),0) as num," + + "DATE_FORMAT(create_time, '%m-%d') as time " + + " FROM yx_store_order where refund_status=0 and is_del=0 and paid=1 and pay_time >= #{time}" + + " GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') " + + " ORDER BY create_time ASC") + List chartList(@Param("time") Date time); + @Select("SELECT count(id) as num," + + "DATE_FORMAT(create_time, '%m-%d') as time " + + " FROM yx_store_order where refund_status=0 and is_del=0 and paid=1 and pay_time >= #{time}" + + " GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') " + + " ORDER BY create_time ASC") + List chartListT(@Param("time") Date time); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderStatusMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderStatusMapper.java new file mode 100644 index 00000000..e565401a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderStatusMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.order.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.order.domain.YxStoreOrderStatus; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreOrderStatusMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ComputeVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ComputeVo.java new file mode 100644 index 00000000..a5f0340d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ComputeVo.java @@ -0,0 +1,43 @@ +package co.yixiang.modules.order.vo; + +import co.yixiang.serializer.BigDecimalSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @ClassName ComputeVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/27 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ComputeVo implements Serializable { + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal couponPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal deductionPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal payPostage; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal payPrice; + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal totalPrice; + + private Double usedIntegral; //使用了多少积分 + + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal payIntegral; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ConfirmOrderVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ConfirmOrderVo.java new file mode 100644 index 00000000..57c93436 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ConfirmOrderVo.java @@ -0,0 +1,66 @@ +package co.yixiang.modules.order.vo; + +import co.yixiang.modules.activity.vo.StoreCouponUserVo; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.service.dto.PriceGroupDto; +import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; +import co.yixiang.modules.user.domain.YxUserAddress; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName ConfirmOrderVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/27 + **/ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class ConfirmOrderVo implements Serializable { + //地址信息 + private YxUserAddress addressInfo; + + //砍价id + private Integer bargainId; + + private List cartInfo; + + private Integer combinationId; + + //优惠券减 + private Boolean deduction; + + private Boolean enableIntegral; + + private Double enableIntegralNum; + + //积分抵扣 + private Integer integralRatio; + + private String orderKey; + + private PriceGroupDto priceGroup; + + private Integer seckillId; + + //店铺自提 + private Integer storeSelfMention; + + //店铺信息 + private YxSystemStoreQueryVo systemStore; + + + private StoreCouponUserVo usableCoupon; + + private YxUserQueryVo userInfo; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/OrderCartInfoVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/OrderCartInfoVo.java new file mode 100644 index 00000000..a0e0cd9b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/OrderCartInfoVo.java @@ -0,0 +1,45 @@ +package co.yixiang.modules.order.vo; + +import co.yixiang.modules.order.service.dto.ProductDto; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 订单商品对象 + *

+ * + * @author hupeng + * @date 2019-11-03 + */ +@Data +@Builder +public class OrderCartInfoVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "订单ID") + private String orderId; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "购物车数量") + private Integer cartNum; + + @ApiModelProperty(value = "拼团产品ID") + private Long combinationId; + + @ApiModelProperty(value = "秒杀产品ID") + private Long seckillId; + + @ApiModelProperty(value = "砍价产品ID") + private Long bargainId; + + @ApiModelProperty(value = "产品信息") + private ProductDto productInfo; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/OrderDataVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/OrderDataVo.java new file mode 100644 index 00000000..98de219e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/OrderDataVo.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.order.vo; + +import co.yixiang.serializer.DoubleSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName OrderDataVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/25 + **/ +@Data +public class OrderDataVo implements Serializable { + private Integer count; + @JsonSerialize(using = DoubleSerializer.class) + private Double price; + private String time; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ShoperOrderTimeDataVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ShoperOrderTimeDataVo.java new file mode 100644 index 00000000..b7f20bee --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/ShoperOrderTimeDataVo.java @@ -0,0 +1,38 @@ +package co.yixiang.modules.order.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName OrderTimeDataDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/25 + **/ +@Data +public class ShoperOrderTimeDataVo implements Serializable { + + /**今日成交额*/ + private Double todayPrice; + + /**今日订单数*/ + private Long todayCount; + + /**昨日成交额*/ + private Double proPrice; + + /**昨日订单数*/ + private Long proCount; + + /**本月成交额*/ + private Double monthPrice; + + /**本月订单数*/ + private Long monthCount; + + /**上周订单数*/ + private Long lastWeekCount; + + /**上周成交额*/ + private Double lastWeekPrice; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/UserOrderCountVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/UserOrderCountVo.java new file mode 100644 index 00000000..41008e0f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/UserOrderCountVo.java @@ -0,0 +1,55 @@ +package co.yixiang.modules.order.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.io.Serializable; + +/** + * @ClassName OrderCountDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/30 + **/ +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class UserOrderCountVo implements Serializable { + + /**订单支付没有退款 数量*/ + @ApiModelProperty(value = "订单支付没有退款数量") + private Long orderCount; + + /**订单支付没有退款 支付总金额*/ + @ApiModelProperty(value = "订单支付没有退款支付总金额") + private Double sumPrice; + + /**订单待支付 数量*/ + @ApiModelProperty(value = "订单待支付数量") + private Long unpaidCount; + + /**订单待发货数量*/ + @ApiModelProperty(value = "订单待发货数量") + private Long unshippedCount; + + /**订单待收货数量*/ + @ApiModelProperty(value = "订单待收货数量") + private Long receivedCount; + + /**订单待评价数量*/ + @ApiModelProperty(value = "订单待评价数量") + private Long evaluatedCount; + + /**订单已完成数量*/ + @ApiModelProperty(value = "订单已完成数量") + private Long completeCount; + + /**订单退款数量*/ + @ApiModelProperty(value = "订单退款数量") + private Long refundCount; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderCartInfoQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderCartInfoQueryVo.java new file mode 100644 index 00000000..c330911d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderCartInfoQueryVo.java @@ -0,0 +1,39 @@ +package co.yixiang.modules.order.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 订单购物详情表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxStoreOrderCartInfoQueryVo对象", description = "订单购物详情表查询参数") +public class YxStoreOrderCartInfoQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "订单id") + private Integer oid; + + @ApiModelProperty(value = "购物车id") + private Integer cartId; + + @ApiModelProperty(value = "商品ID") + private Integer productId; + + @ApiModelProperty(value = "购买东西的详细信息") + private String cartInfo; + + @ApiModelProperty(value = "唯一id") + private String unique; + +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderQueryVo.java new file mode 100644 index 00000000..3539eebd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderQueryVo.java @@ -0,0 +1,209 @@ +package co.yixiang.modules.order.vo; + + +import cn.hutool.core.util.StrUtil; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.service.dto.StatusDto; +import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + *

+ * 订单表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxStoreOrderQueryVo对象", description = "订单表查询参数") +public class YxStoreOrderQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "订单ID") + private Long id; + + @ApiModelProperty(value = "订单号") + private String orderId; + + + private String extendOrderId; + + @ApiModelProperty(value = "用户id") + private Long uid; + + @ApiModelProperty(value = "用户姓名") + private String realName; + + @ApiModelProperty(value = "用户电话") + private String userPhone; + + @ApiModelProperty(value = "详细地址") + private String userAddress; + + @ApiModelProperty(value = "购物车id") + private String cartId; + + private List cartInfo; + + private StatusDto _status; + + @ApiModelProperty(value = "运费金额") + private BigDecimal freightPrice; + + @ApiModelProperty(value = "订单商品总数") + private Integer totalNum; + + @ApiModelProperty(value = "订单总价") + private BigDecimal totalPrice; + + @ApiModelProperty(value = "邮费") + private BigDecimal totalPostage; + + @ApiModelProperty(value = "实际支付金额") + private BigDecimal payPrice; + + @ApiModelProperty(value = "实际支付积分") + private BigDecimal payIntegral; + + @ApiModelProperty(value = "支付邮费") + private BigDecimal payPostage; + + @ApiModelProperty(value = "抵扣金额") + private BigDecimal deductionPrice; + + @ApiModelProperty(value = "优惠券id") + private Integer couponId; + + @ApiModelProperty(value = "优惠券金额") + private BigDecimal couponPrice; + + @ApiModelProperty(value = "支付状态") + private Integer paid; + + @ApiModelProperty(value = "支付时间") + private Date payTime; + + @ApiModelProperty(value = "支付方式") + private String payType; + + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + @ApiModelProperty(value = "订单状态(-1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款)") + private Integer status; + + @ApiModelProperty(value = "0 未退款 1 申请中 2 已退款") + private Integer refundStatus; + + @ApiModelProperty(value = "退款图片") + private String refundReasonWapImg; + + @ApiModelProperty(value = "退款用户说明") + private String refundReasonWapExplain; + + @ApiModelProperty(value = "退款时间") + private Date refundReasonTime; + + @ApiModelProperty(value = "前台退款原因") + private String refundReasonWap; + + @ApiModelProperty(value = "不退款的理由") + private String refundReason; + + @ApiModelProperty(value = "退款金额") + private BigDecimal refundPrice; + + @ApiModelProperty(value = "快递名称/送货人姓名") + private String deliveryName; + + private String deliverySn; + + @ApiModelProperty(value = "发货类型") + private String deliveryType; + + public String getDeliveryType() { + if(StrUtil.isBlank(deliveryType)) { + return "express"; + } + return deliveryType; + } + + + @ApiModelProperty(value = "快递单号/手机号") + private String deliveryId; + + @ApiModelProperty(value = "消费赚取积分") + private BigDecimal gainIntegral; + + @ApiModelProperty(value = "使用积分") + private BigDecimal useIntegral; + + @ApiModelProperty(value = "给用户退了多少积分") + private BigDecimal backIntegral; + + @ApiModelProperty(value = "备注") + private String mark; + + @ApiModelProperty(value = "唯一id(md5加密)类似id") + private String unique; + + @ApiModelProperty(value = "管理员备注") + private String remark; + + @ApiModelProperty(value = "商户ID") + private Integer merId; + + private Integer isMerCheck; + + @ApiModelProperty(value = "拼团产品id0一般产品") + private Long combinationId; + + @ApiModelProperty(value = "拼团id 0没有拼团") + private Long pinkId; + + @ApiModelProperty(value = "成本价") + private BigDecimal cost; + + @ApiModelProperty(value = "秒杀产品ID") + private Long seckillId; + + @ApiModelProperty(value = "砍价id") + private Long bargainId; + + @ApiModelProperty(value = "核销码") + private String verifyCode; + + @ApiModelProperty(value = "门店id") + private Integer storeId; + + @ApiModelProperty(value = "配送方式 1=快递 ,2=门店自提") + private Integer shippingType; + + + @ApiModelProperty(value = "支付渠道(0微信公众号1微信小程序)") + private Integer isChannel; + + private Integer isRemind; + + private Integer isSystemDel; + + @ApiModelProperty(value = "门店信息与二维码链接") + private String code; + + @ApiModelProperty(value = "腾讯地图key") + private String mapKey; + + @ApiModelProperty(value = "门店信息") + private YxSystemStoreQueryVo systemStore; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderStatusQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderStatusQueryVo.java new file mode 100644 index 00000000..40036c65 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/vo/YxStoreOrderStatusQueryVo.java @@ -0,0 +1,36 @@ +package co.yixiang.modules.order.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 订单操作记录表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxStoreOrderStatusQueryVo对象", description = "订单操作记录表查询参数") +public class YxStoreOrderStatusQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "订单id") + private Integer oid; + + @ApiModelProperty(value = "操作类型") + private String changeType; + + @ApiModelProperty(value = "操作备注") + private String changeMessage; + + @ApiModelProperty(value = "操作时间") + private Integer changeTime; + +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java new file mode 100644 index 00000000..e8262170 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java @@ -0,0 +1,250 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import co.yixiang.modules.category.domain.YxStoreCategory; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.DecimalMax; +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + + +@TableName("yx_store_product") +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +public class YxStoreProduct extends BaseDomain { + + /** 商品id */ + @TableId + @ApiModelProperty(value = "商品ID") + private Long id; + + + /** 商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) */ + @ApiModelProperty(value = "商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) 预留字段") + private Integer merId; + + + /** 商品图片 */ + @NotBlank(message = "请上传商品图片") + @ApiModelProperty(value = "商品图片") + private String image; + + + /** 轮播图 */ + @NotBlank(message = "请上传商品轮播图") + @ApiModelProperty(value = "商品轮播图") + private String sliderImage; + + + /** 商品名称 */ + @NotBlank(message = "商品名称不能空") + @ApiModelProperty(value = "商品名称") + private String storeName; + + + /** 商品简介 */ + @ApiModelProperty(value = "商品简介") + private String storeInfo; + + + /** 关键字 */ + @ApiModelProperty(value = "关键字") + private String keyword; + + + /** 产品条码(一维码) */ + @ApiModelProperty(value = "产品条码(一维码)") + private String barCode; + + + /** 分类id */ + @ApiModelProperty(value = "分类id") + private String cateId; + + + /** 商品价格 */ + @ApiModelProperty(value = "商品价格") + @NotNull(message = "请输入商品价格") + @DecimalMin(value="0.00", message = "商品价格不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "商品价格不在合法范围内") + private BigDecimal price; + + + /** 会员价格 */ + @ApiModelProperty(value = "会员价格") + private BigDecimal vipPrice; + + + /** 市场价 */ + @ApiModelProperty(value = "市场价") + @NotNull(message = "请输入市场价") + @DecimalMin(value="0.00", message = "市场价不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "市场价不在合法范围内") + private BigDecimal otPrice; + + + /** 邮费 */ + @ApiModelProperty(value = "邮费") + private BigDecimal postage; + + + /** 单位名 */ + @NotBlank(message = "请填写单位") + @ApiModelProperty(value = "单位名") + private String unitName; + + + /** 排序 */ + @ApiModelProperty(value = "排序") + private Integer sort; + + + /** 销量 */ + @ApiModelProperty(value = "销量") + private Integer sales; + + + /** 库存 */ + @ApiModelProperty(value = "库存") + @NotNull(message = "请输入库存") + @Min(message = "库存不能小于0",value = 1) + private Integer stock; + + + /** 需要多少积分兑换 */ + @ApiModelProperty(value = "需要多少积分兑换 只在开启积分兑换时生效") + private Integer integral; + + + /** 状态(0:未上架,1:上架) */ + @ApiModelProperty(value = "状态(0:未上架,1:上架)") + private Integer isShow; + + + /** 是否热卖 */ + @ApiModelProperty(value = "是否热卖(0:否,1:是)") + private Integer isHot; + + + /** 是否优惠 */ + @ApiModelProperty(value = "是否猜你喜欢(0:否,1:是)") + private Integer isBenefit; + + + /** 是否精品 */ + @ApiModelProperty(value = "是否精品(0:否,1:是)") + private Integer isBest; + + + /** 是否新品 */ + @ApiModelProperty(value = "是否新品(0:否,1:是)") + private Integer isNew; + + + /** 产品描述 */ + @NotBlank(message = "请填写商品详情") + @ApiModelProperty(value = "商品详情") + private String description; + + + /** 是否包邮 */ + @ApiModelProperty(value = "是否包邮") + private Integer isPostage; + + + /** 商户是否代理 0不可代理1可代理 */ + @ApiModelProperty(value = "商户是否代理 0不可代理1可代理 ") + private Integer merUse; + + + /** 获得积分 */ + @ApiModelProperty(value = "获得积分") + @DecimalMin(value="0.00", message = "获得积分不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "获得积分不在合法范围内") + private BigDecimal giveIntegral; + + + /** 成本价 */ + @ApiModelProperty(value = "成本价") + @NotNull(message = "请输入成本价") + @DecimalMin(value="0.00", message = "成本价不在合法范围内" ) + @DecimalMax(value="99999999.99", message = "成本价不在合法范围内") + private BigDecimal cost; + + + /** 秒杀状态 0 未开启 1已开启 */ + @ApiModelProperty(value = "秒杀状态 0 未开启 1已开启") + private Integer isSeckill; + + + /** 砍价状态 0未开启 1开启 */ + @ApiModelProperty(value = "砍价状态 0 未开启 1已开启") + private Integer isBargain; + + + /** 是否优品推荐 */ + @ApiModelProperty(value = "是否优品推荐(0:否,1:是)") + private Integer isGood; + + + /** 虚拟销量 */ + @ApiModelProperty(value = "虚拟销量") + private Integer ficti; + + + /** 浏览量 */ + @ApiModelProperty(value = "浏览量") + private Integer browse; + + + /** 产品二维码地址(用户小程序海报) */ + @ApiModelProperty(value = "品二维码地址(用户小程序海报) ") + private String codePath; + + @ApiModelProperty(value = "邮费模版ID") + private Integer tempId; + + @ApiModelProperty(value = "规格 0单 1多 ") + private Integer specType; + + @ApiModelProperty(value = "是否单独分佣") + private Integer isSub; + + @ApiModelProperty(value = "是否开启积分兑换") + private Integer isIntegral; + + @TableField(exist = false) + private YxStoreCategory storeCategory; + + + public void copy(YxStoreProduct source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttr.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttr.java new file mode 100644 index 00000000..2f29cb06 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttr.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@TableName("yx_store_product_attr") +public class YxStoreProductAttr implements Serializable { + + @TableId + private Long id; + + + /** 商品ID */ + private Long productId; + + + /** 属性名 */ + private String attrName; + + + /** 属性值 */ + private String attrValues; + + + public void copy(YxStoreProductAttr source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttrResult.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttrResult.java new file mode 100644 index 00000000..44188fb6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttrResult.java @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@TableName("yx_store_product_attr_result") +public class YxStoreProductAttrResult implements Serializable { + + @TableId + private Long id; + + + /** 商品ID */ + private Long productId; + + + /** 商品属性参数 */ + private String result; + + + /** 上次修改时间 */ + private Date changeTime; + + + public void copy(YxStoreProductAttrResult source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttrValue.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttrValue.java new file mode 100644 index 00000000..01c2b960 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductAttrValue.java @@ -0,0 +1,133 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.serializer.BigDecimalSerializer; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@TableName("yx_store_product_attr_value") +public class YxStoreProductAttrValue implements Serializable { + + @TableId + private Long id; + + + /** 商品ID */ + @ApiModelProperty(value = "商品ID") + private Long productId; + + + /** 商品属性索引值 (attr_value|attr_value[|....]) */ + @ApiModelProperty(value = "商品属性索引值 (attr_value|attr_value[|....])") + private String sku; + + + /** 属性对应的库存 */ + @ApiModelProperty(value = "属性对应的库存") + private Integer stock; + + /** 拼团库存属性对应的库存 */ + @ApiModelProperty(value = "拼团库存属性对应的库存") + private Integer pinkStock; + + /** 秒杀库存属性对应的库存 */ + @ApiModelProperty(value = "秒杀库存属性对应的库存") + private Integer seckillStock; + + /** 销量 */ + @ApiModelProperty(value = "销量") + private Integer sales; + + + /** 属性金额 */ + @ApiModelProperty(value = "属性金额") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal price; + + /** 拼团属性对应的金额 */ + @ApiModelProperty(value = "拼团属性对应的金额") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal pinkPrice; + + /** 秒杀属性对应的金额 */ + @ApiModelProperty(value = "秒杀属性对应的金额") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal seckillPrice; + + /** 图片 */ + @ApiModelProperty(value = "属性对应的图片") + private String image; + + + /** 唯一值 */ + @TableField(value = "`unique`") + @ApiModelProperty(value = "唯一值") + private String unique; + + + /** 成本价 */ + @ApiModelProperty(value = "成本价") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal cost; + + /** 商品条码 */ + @ApiModelProperty(value = "商品条码") + private String barCode; + + /** 原价 */ + @ApiModelProperty(value = "原价") + private BigDecimal otPrice; + + /** 重量 */ + @ApiModelProperty(value = "重量") + private BigDecimal weight; + + /** 体积 */ + @ApiModelProperty(value = "体积") + private BigDecimal volume; + + + /** 一级返佣 */ + @ApiModelProperty(value = "一级返佣") + private BigDecimal brokerage; + + /** 二级返佣 */ + @ApiModelProperty(value = "二级返佣") + private BigDecimal brokerageTwo; + + /** 所需多少积分兑换商品 */ + @ApiModelProperty(value = "所需多少积分兑换商品") + private Integer integral; + + + public void copy(YxStoreProductAttrValue source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductRelation.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductRelation.java new file mode 100644 index 00000000..0d5465a8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductRelation.java @@ -0,0 +1,49 @@ +package co.yixiang.modules.product.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + *

+ * 商品点赞和收藏表 + *

+ * + * @author hupeng + * @since 2019-10-23 + */ + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class YxStoreProductRelation extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "类型(收藏(collect)、点赞(like)、足迹(foot))") + private String type; + + @ApiModelProperty(value = "某种类型的商品(普通商品、秒杀商品)") + private String category; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductReply.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductReply.java new file mode 100644 index 00000000..651051b9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductReply.java @@ -0,0 +1,101 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import co.yixiang.modules.user.domain.YxUser; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("yx_store_product_reply") +public class YxStoreProductReply extends BaseDomain { + + /** 评论ID */ + @TableId + private Long id; + + + /** 用户ID */ + private Long uid; + + + /** 订单ID */ + private Long oid; + + + /** 唯一id */ + @TableField(value = "`unique`") + private String unique; + + + /** 产品id */ + private Long productId; + + + /** 某种商品类型(普通商品、秒杀商品) */ + private String replyType; + + + /** 商品分数 */ + private Integer productScore; + + + /** 服务分数 */ + private Integer serviceScore; + + + /** 评论内容 */ + private String comment; + + + /** 评论图片 */ + private String pics; + + + + /** 管理员回复内容 */ + @NotBlank(message = "回复内容不能为空") + private String merchantReplyContent; + + + /** 管理员回复时间 */ + private Date merchantReplyTime; + + + /** 0未回复1已回复 */ + private Integer isReply; + + @TableField(exist = false) + private YxStoreProduct storeProduct; + + @TableField(exist = false) + private YxUser user; + + public void copy(YxStoreProductReply source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductRule.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductRule.java new file mode 100644 index 00000000..7622f181 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProductRule.java @@ -0,0 +1,51 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** +* @author hupeng +* @date 2020-06-28 +*/ +@Data +@TableName(value = "yx_store_product_rule",autoResultMap = true) +public class YxStoreProductRule extends BaseDomain { + + @TableId + private Integer id; + + + /** 规格名称 */ + @NotBlank(message = "请输入规则名称") + private String ruleName; + + + /** 规格值 */ + @TableField(typeHandler = FastjsonTypeHandler.class) + @NotNull(message = "规格名称/值必填") + private JSONArray ruleValue; + + + + public void copy(YxStoreProductRule source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/param/YxStoreProductQueryParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/param/YxStoreProductQueryParam.java new file mode 100644 index 00000000..3ec842e3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/param/YxStoreProductQueryParam.java @@ -0,0 +1,43 @@ +package co.yixiang.modules.product.param; + +import co.yixiang.common.web.param.QueryParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 商品表 查询参数对象 + *

+ * + * @author hupeng + * @date 2019-10-19 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value="YxStoreProductQueryParam对象", description="商品表查询参数") +public class YxStoreProductQueryParam extends QueryParam { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "类别") + private String type; + + @ApiModelProperty(value = "分类ID") + private String sid; + + @ApiModelProperty(value = "是否新品") + private String news; + + @ApiModelProperty(value = "是否积分兑换商品") + private Integer isIntegral; + + @ApiModelProperty(value = "价格排序") + private String priceOrder; + + @ApiModelProperty(value = "销量排序") + private String salesOrder; + + @ApiModelProperty(value = "关键字") + private String keyword; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java new file mode 100644 index 00000000..f7bbe2bd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java @@ -0,0 +1,282 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.rest; + +import cn.hutool.core.bean.BeanUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.enums.SpecTypeEnum; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.category.domain.YxStoreCategory; +import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.modules.category.service.dto.YxStoreCategoryDto; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.domain.YxStoreProductAttrResult; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrResultService; +import co.yixiang.modules.product.service.YxStoreProductAttrValueService; +import co.yixiang.modules.product.service.YxStoreProductRuleService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.service.dto.ProductDto; +import co.yixiang.modules.product.service.dto.ProductFormatDto; +import co.yixiang.modules.product.service.dto.StoreProductDto; +import co.yixiang.modules.product.service.dto.YxStoreProductQueryCriteria; +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.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Maps; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.util.CollectionUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author hupeng + * @date 2019-10-04 + */ +@Api(tags = "商城:商品管理") +@RestController +@RequestMapping("api") +public class StoreProductController { + + private final YxStoreProductService yxStoreProductService; + private final YxStoreCategoryService yxStoreCategoryService; + private final YxShippingTemplatesService yxShippingTemplatesService; + private final YxStoreProductRuleService yxStoreProductRuleService; + private final YxStoreProductAttrResultService yxStoreProductAttrResultService; + private final YxStoreProductAttrValueService storeProductAttrValueService; + private final IGenerator generator; + public StoreProductController(YxStoreProductService yxStoreProductService, + YxStoreCategoryService yxStoreCategoryService, + YxShippingTemplatesService yxShippingTemplatesService, + YxStoreProductRuleService yxStoreProductRuleService, + YxStoreProductAttrResultService yxStoreProductAttrResultService, YxStoreProductAttrValueService storeProductAttrValueService, IGenerator generator) { + this.yxStoreProductService = yxStoreProductService; + this.yxStoreCategoryService = yxStoreCategoryService; + this.yxShippingTemplatesService = yxShippingTemplatesService; + this.yxStoreProductRuleService = yxStoreProductRuleService; + this.yxStoreProductAttrResultService = yxStoreProductAttrResultService; + this.storeProductAttrValueService = storeProductAttrValueService; + this.generator = generator; + } + + @Log("查询商品") + @ApiOperation(value = "查询商品") + @GetMapping(value = "/yxStoreProduct") + @PreAuthorize("hasAnyRole('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_SELECT')") + public ResponseEntity getYxStoreProducts(YxStoreProductQueryCriteria criteria, Pageable pageable){ + //商品分类 + List storeCategories = yxStoreCategoryService.lambdaQuery() + .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxStoreCategory::getPid) + .list(); + List> cateList = new ArrayList<>(); + Map queryAll = yxStoreProductService.queryAll(criteria, pageable); + queryAll.put("cateList", this.makeCate(storeCategories,cateList,0,1)); + return new ResponseEntity<>(queryAll,HttpStatus.OK); + } + + @ForbidSubmit + @Log("新增/修改商品") + @ApiOperation(value = "新增/修改商品") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @PostMapping(value = "/yxStoreProduct/addOrSave") + @PreAuthorize("hasAnyRole('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_CREATE')") + public ResponseEntity create(@Validated @RequestBody StoreProductDto storeProductDto){ + yxStoreProductService.insertAndEditYxStoreProduct(storeProductDto); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + + @ForbidSubmit + @Log("删除商品") + @ApiOperation(value = "删除商品") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @DeleteMapping(value = "/yxStoreProduct/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_DELETE')") + public ResponseEntity delete(@PathVariable Long id){ + yxStoreProductService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } + + + + @ApiOperation(value = "商品上架/下架") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @PostMapping(value = "/yxStoreProduct/onsale/{id}") + public ResponseEntity onSale(@PathVariable Long id,@RequestBody String jsonStr){ + JSONObject jsonObject = JSON.parseObject(jsonStr); + Integer status = jsonObject.getInteger("status"); + 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,false),HttpStatus.OK); + } + + + + @ApiOperation(value = "获取商品信息") + @GetMapping(value = "/yxStoreProduct/info/{id}") + public ResponseEntity info(@PathVariable Long id){ + Map map = new LinkedHashMap<>(3); + + //运费模板 + List shippingTemplatesList = yxShippingTemplatesService.list(); + map.put("tempList", shippingTemplatesList); + + //商品分类 + List storeCategories = yxStoreCategoryService.lambdaQuery() + .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxStoreCategory::getPid) + .list(); + + List> 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); + } + + //处理商品详情 + YxStoreProduct yxStoreProduct = yxStoreProductService.getById(id); + ProductDto productDto = new ProductDto(); + BeanUtil.copyProperties(yxStoreProduct,productDto,"sliderImage"); + productDto.setSliderImage(Arrays.asList(yxStoreProduct.getSliderImage().split(","))); + YxStoreProductAttrResult storeProductAttrResult = yxStoreProductAttrResultService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrResult::getProductId,id).last("limit 1")); + JSONObject result = JSON.parseObject(storeProductAttrResult.getResult()); + List attrValues = storeProductAttrValueService.list(new LambdaQueryWrapper().eq(YxStoreProductAttrValue::getProductId, yxStoreProduct.getId())); + List productFormatDtos =attrValues.stream().map(i ->{ + ProductFormatDto productFormatDto = new ProductFormatDto(); + BeanUtils.copyProperties(i,productFormatDto); + productFormatDto.setPic(i.getImage()); + return productFormatDto; + }).collect(Collectors.toList()); + if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreProduct.getSpecType())){ + productDto.setAttr(new ProductFormatDto()); + productDto.setAttrs(productFormatDtos); + productDto.setItems(result.getObject("attr",ArrayList.class)); + }else{ + + productFromat(productDto, result); + } + + map.put("productInfo",productDto); + + return new ResponseEntity<>(map,HttpStatus.OK); + } + + /** + * 获取商品属性 + * @param productDto + * @param result + */ + private void productFromat(ProductDto productDto, JSONObject result) { + Map mapAttr = (Map) result.getObject("value",ArrayList.class).get(0); + ProductFormatDto productFormatDto = ProductFormatDto.builder() + .pic(mapAttr.get("pic").toString()) + .price(Double.valueOf(mapAttr.get("price").toString())) + .cost(Double.valueOf(mapAttr.get("cost").toString())) + .otPrice(Double.valueOf(mapAttr.get("otPrice").toString())) + .stock(Integer.valueOf(mapAttr.get("stock").toString())) + .barCode(mapAttr.get("barCode").toString()) + .weight(Double.valueOf(mapAttr.get("weight").toString())) + .volume(Double.valueOf(mapAttr.get("volume").toString())) + .value1(mapAttr.get("value1").toString()) + .integral(mapAttr.get("integral") !=null ? Integer.valueOf(mapAttr.get("integral").toString()) : 0) + .brokerage(Double.valueOf(mapAttr.get("brokerage").toString())) + .brokerageTwo(Double.valueOf(mapAttr.get("brokerageTwo").toString())) + .pinkPrice(Double.valueOf(mapAttr.get("pinkPrice").toString())) + .pinkStock(Integer.valueOf(mapAttr.get("pinkStock").toString())) + .seckillPrice(Double.valueOf(mapAttr.get("seckillPrice").toString())) + .seckillStock(Integer.valueOf(mapAttr.get("seckillStock").toString())) + .build(); + productDto.setAttr(productFormatDto); + } + + + /** + * 分类递归 + * @param data 分类列表 + * @param pid 附件id + * @param level d等级 + * @return list + */ + private List> makeCate(List data,List> cateList,int pid, int level) + { + String html = "|-----"; + String newHtml = ""; + List storeCategories = yxStoreCategoryService.lambdaQuery().eq(YxStoreCategory::getPid, 0).list(); + + for (int i = 0; i < data.size(); i++) { + YxStoreCategory storeCategory = data.get(i); + int catePid = storeCategory.getPid(); + Map map = new HashMap<>(); + if(catePid == pid){ + newHtml = String.join("", Collections.nCopies(level,html)); + map.put("value",storeCategory.getId()); + map.put("label",newHtml + storeCategory.getCateName()); + if(storeCategory.getPid() == 0){ + map.put("disabled",0); + }else{ + map.put("disabled",1); + } + cateList.add(map); + data.remove(i); + + i--; + if(storeCategory.getPid() > 0){ + this.makeCate(data,cateList,storeCategory.getPid(),level); + }else{ + this.makeCate(data,cateList,storeCategory.getId(),level + 1); + } + + } + } + + + return cateList; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductReplyController.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductReplyController.java new file mode 100644 index 00000000..d2f8a853 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductReplyController.java @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.rest; + +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.product.domain.YxStoreProductReply; +import co.yixiang.modules.product.service.YxStoreProductReplyService; +import co.yixiang.modules.product.service.dto.YxStoreProductReplyQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +/** +* @author hupeng +* @date 2019-11-03 +*/ +@Api(tags = "商城:评论管理") +@RestController +@RequestMapping("api") +public class StoreProductReplyController { + + + private final YxStoreProductReplyService yxStoreProductReplyService; + + public StoreProductReplyController(YxStoreProductReplyService yxStoreProductReplyService) { + this.yxStoreProductReplyService = yxStoreProductReplyService; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxStoreProductReply") + @PreAuthorize("hasAnyRole('admin','YXSTOREPRODUCTREPLY_ALL','YXSTOREPRODUCTREPLY_SELECT')") + public ResponseEntity getYxStoreProductReplys(YxStoreProductReplyQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreProductReplyService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + + @Log("修改") + @ApiOperation(value = "修改") + @PutMapping(value = "/yxStoreProductReply") + @PreAuthorize("hasAnyRole('admin','YXSTOREPRODUCTREPLY_ALL','YXSTOREPRODUCTREPLY_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxStoreProductReply resources){ + resources.setMerchantReplyTime(new Date()); + resources.setIsReply(ShopCommonEnum.REPLY_1.getValue()); + yxStoreProductReplyService.updateById(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxStoreProductReply/{id}") + @PreAuthorize("hasAnyRole('admin','YXSTOREPRODUCTREPLY_ALL','YXSTOREPRODUCTREPLY_DELETE')") + public ResponseEntity delete(@PathVariable Long id){ + yxStoreProductReplyService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductRuleController.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductRuleController.java new file mode 100644 index 00000000..b90b4648 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/rest/StoreProductRuleController.java @@ -0,0 +1,95 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.product.domain.YxStoreProductRule; +import co.yixiang.modules.product.service.YxStoreProductRuleService; +import co.yixiang.modules.product.service.dto.YxStoreProductRuleDto; +import co.yixiang.modules.product.service.dto.YxStoreProductRuleQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +/** +* @author hupeng +* @date 2020-06-28 +*/ +@AllArgsConstructor +@Api(tags = "sku规则管理") +@RestController +@RequestMapping("/api/yxStoreProductRule") +public class StoreProductRuleController { + + private final YxStoreProductRuleService yxStoreProductRuleService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRule:list')") + public void download(HttpServletResponse response, YxStoreProductRuleQueryCriteria criteria) throws IOException { + yxStoreProductRuleService.download(yxStoreProductRuleService.queryAll(criteria) , response); + } + + @GetMapping + @Log("查询sku规则") + @ApiOperation("查询sku规则") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRule:list')") + public ResponseEntity getYxStoreProductRules(YxStoreProductRuleQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreProductRuleService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + @PostMapping("/save/{id}") + @Log("新增/修改sku规则") + @ApiOperation("新增/修改sku规则") + @PreAuthorize("hasAnyRole('admin','yxStoreProductRule:add','yxStoreProductRule:edit')") + public ResponseEntity create(@Validated @RequestBody YxStoreProductRule resources,@PathVariable Integer id){ + if(id != null && id > 0){ + resources.setId(id); + yxStoreProductRuleService.updateById(resources); + }else{ + yxStoreProductRuleService.save(resources); + } + + return new ResponseEntity<>(HttpStatus.CREATED); + } + + + @ForbidSubmit + @Log("删除sku规则") + @ApiOperation("删除sku规则") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRule:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + yxStoreProductRuleService.removeByIds(new ArrayList<>(Arrays.asList(ids))); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrResultService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrResultService.java new file mode 100644 index 00000000..b3044c78 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrResultService.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.domain.YxStoreProductAttrResult; + +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreProductAttrResultService extends BaseService{ + + /** + * 新增商品属性详情 + * @param map map + * @param productId 商品id + */ + void insertYxStoreProductAttrResult(Map map, Long productId); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java new file mode 100644 index 00000000..69f5ba3c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrService.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.domain.YxStoreProductAttr; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.dto.FromatDetailDto; +import co.yixiang.modules.product.service.dto.ProductFormatDto; + +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreProductAttrService extends BaseService{ + + /** + * 增加库存减去销量 + * @param num 数量 + * @param productId 商品id + * @param unique sku唯一值 + */ + void incProductAttrStock(Integer num, Long productId, String unique,String type); + + /** + * 减少库存增加销量 + * @param num 数量 + * @param productId 商品id + * @param unique sku唯一值 + */ + void decProductAttrStock(int num, Long productId, String unique,String type); + + + /** + * 更加sku 唯一值获取sku对象 + * @param unique 唯一值 + * @return YxStoreProductAttrValue + */ + YxStoreProductAttrValue uniqueByAttrInfo(String unique); + + /** + * 获取商品sku属性 + * @param productId 商品id + * @return map + */ + Map getProductAttrDetail(long productId); + + /** + * 新增商品属性 + * @param items attr + * @param attrs value + * @param productId 商品id + */ + void insertYxStoreProductAttr(List items, List attrs, + Long productId); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrValueService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrValueService.java new file mode 100644 index 00000000..18e0f611 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductAttrValueService.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreProductAttrValueService extends BaseService{ + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java new file mode 100644 index 00000000..b347263b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java @@ -0,0 +1,93 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service; + + +import co.yixiang.common.service.BaseService; +import co.yixiang.domain.PageResult; +import co.yixiang.modules.product.domain.YxStoreProductRelation; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationDto; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria; +import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo; +import javax.servlet.http.HttpServletResponse; +import org.springframework.data.domain.Pageable; +import java.io.IOException; +import java.util.List; + +/** + *

+ * 商品点赞和收藏表 服务类 + *

+ * + * @author hupeng + * @since 2019-10-23 + */ +public interface YxStoreProductRelationService extends BaseService { + + /** + * 是否收藏 + * @param productId 商品ID + * @param uid 用户ID + * @return Boolean + */ + Boolean isProductRelation(long productId, long uid); + + /** + *添加收藏 + * @param productId 商品id + * @param uid 用户id + */ + void addRroductRelation(long productId,long uid,String category); + + /** + * 取消收藏 + * @param productId 商品id + * @param uid 用户id + */ + void delRroductRelation(long productId,long uid,String category); + + /** + * 获取用户收藏列表 + * @param page page + * @param limit limit + * @param uid 用户id + * @return list + */ + List userCollectProduct(int page, int limit, Long uid,String type); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxStoreProductRelationQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreProductRelationQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + + /** + * 批量删除 + * @param ids / + */ + void collectDelFoot(List ids); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductReplyService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductReplyService.java new file mode 100644 index 00000000..55fa2992 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductReplyService.java @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.domain.YxStoreProductReply; +import co.yixiang.modules.product.service.dto.YxStoreProductReplyDto; +import co.yixiang.modules.product.service.dto.YxStoreProductReplyQueryCriteria; +import co.yixiang.modules.product.vo.ReplyCountVo; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreProductReplyService extends BaseService{ + + /** + * 评价数据 + * @param productId 商品id + * @return ReplyCountVO + */ + ReplyCountVo getReplyCount(long productId); + + /** + * 处理评价 + * @param replyQueryVo replyQueryVo + * @return YxStoreProductReplyQueryVo + */ + YxStoreProductReplyQueryVo handleReply(YxStoreProductReplyQueryVo replyQueryVo); + + /** + * 获取单条评价 + * @param productId 商品di + * @return YxStoreProductReplyQueryVo + */ + YxStoreProductReplyQueryVo getReply(long productId); + + /** + * 获取评价列表 + * @param productId 商品id + * @param type 0-全部 1-好评 2-中评 3-差评 + * @param page page + * @param limit limit + * @return list + */ + List getReplyList(long productId,int type,int page, int limit); + + Long getInfoCount(Integer oid, String unique); + + Long productReplyCount(long productId); + + Long replyCount(String unique); + + String replyPer(long productId); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreProductReplyQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreProductReplyQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductRuleService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductRuleService.java new file mode 100644 index 00000000..bcb78ba0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductRuleService.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.domain.YxStoreProductRule; +import co.yixiang.modules.product.service.dto.YxStoreProductRuleDto; +import co.yixiang.modules.product.service.dto.YxStoreProductRuleQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-06-28 +*/ +public interface YxStoreProductRuleService extends BaseService { + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreProductRuleQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreProductRuleQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductService.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductService.java new file mode 100644 index 00000000..03b8d160 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/YxStoreProductService.java @@ -0,0 +1,151 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.param.YxStoreProductQueryParam; +import co.yixiang.modules.product.service.dto.StoreProductDto; +import co.yixiang.modules.product.service.dto.YxStoreProductDto; +import co.yixiang.modules.product.service.dto.YxStoreProductQueryCriteria; +import co.yixiang.modules.product.vo.ProductVo; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxStoreProductService extends BaseService{ + + /** + * 增加库存 减少销量 + * @param num 数量 + * @param productId 商品id + * @param unique sku唯一值 + */ + void incProductStock(Integer num, Long productId, String unique,Long activityId, String type); + + /** + * 减少库存与增加销量 + * @param num 数量 + * @param productId 商品id + * @param unique sku + */ + void decProductStock(int num, Long productId, String unique,Long activityId,String type); + + YxStoreProduct getProductInfo(Long id); + + /** + * 获取单个商品 + * @param id 商品id + * @return YxStoreProductQueryVo + */ + YxStoreProductQueryVo getStoreProductById(Long id); + + /** + * 返回普通商品库存 + * @param productId 商品id + * @param unique sku唯一值 + * @return int + */ + int getProductStock(Long productId, String unique,String type); + + /** + * 商品列表 + * @param productQueryParam YxStoreProductQueryParam + * @return list + */ + List getGoodsList(YxStoreProductQueryParam productQueryParam); + + /** + * 商品详情 + * @param id 商品id + * @param uid 用户id + * @param latitude 纬度 + * @param longitude 经度 + * @return ProductVo + */ + ProductVo goodsDetail(Long id, Long uid, String latitude, String longitude); + + /** + * 商品浏览量 + * @param productId + */ + void incBrowseNum(Long productId); + + /** + * 商品列表 + * @param page 页码 + * @param limit 条数 + * @param order ProductEnum + * @return List + */ + List getList(int page, int limit, int order); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreProductQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreProductQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + + + /** + * 商品上架下架 + * @param id 商品id + * @param status ShopCommonEnum + */ + void onSale(Long id,Integer status); + + /** + * 获取生成的属性 + * @param id 商品id + * @param jsonStr jsonStr + * @return map + */ + Map getFormatAttr(Long id, String jsonStr,boolean isActivity); + + + + + /** + * 新增/保存商品 + * @param storeProductDto 商品 + */ + void insertAndEditYxStoreProduct(StoreProductDto storeProductDto); + + /**+ + * 删除商品转发海报 + * @param id + */ + void deleteForwardImg(Long id); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/AttrValueDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/AttrValueDto.java new file mode 100644 index 00000000..6b3f48c0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/AttrValueDto.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.product.service.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @ClassName AttrValueDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/23 + **/ +@Data +public class AttrValueDto { + + @ApiModelProperty(value = "属性") + private String attr; + + @ApiModelProperty(value = "是否选择") + private Boolean check = false; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/DetailDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/DetailDto.java new file mode 100644 index 00000000..eef35100 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/DetailDto.java @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName DetailDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/12 + **/ +@Data +public class DetailDto { + private List data; + + //private List>>> res; + + private List>> res; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/FromatDetailDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/FromatDetailDto.java new file mode 100644 index 00000000..5cec7ab7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/FromatDetailDto.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +/** + * @ClassName FromatDetailDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/12 + **/ + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class FromatDetailDto { + private String attrHidden; + + private String detailValue; + + private List detail; + + private String value; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java new file mode 100644 index 00000000..397045ba --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java @@ -0,0 +1,150 @@ +package co.yixiang.modules.product.service.dto; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; +import java.util.Map; + +/** + * 商品对象VO + * + * @author hupeng + * @date 2020-04-25 + */ +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Setter +public class ProductDto +{ + + /** 商品id */ + private Long id; + + + /** 商品图片 */ + private String image; + + /** 轮播图 */ + @JsonProperty("slider_image") + private List sliderImage; + + /** 商品名称 */ + @JsonProperty("store_name") + private String storeName; + + /** 商品简介 */ + @JsonProperty("store_info") + private String storeInfo; + + /** 关键字 */ + private String keyword; + + /** 商品条码(一维码) */ + @JsonProperty("bar_code") + private String barCode; + + /** 分类id */ + @JsonProperty("cate_id") + private String cateId; + + /** 商品价格 */ + private Double price; + + + /** 市场价 */ + @JsonProperty("ot_price") + private Double otPrice; + + /** 邮费 */ + private Double postage; + + /** 单位名 */ + @JsonProperty("unit_name") + private String unitName; + + /** 排序 */ + private Long sort; + + /** 销量 */ + private Long sales; + + /** 库存 */ + private Long stock; + + /** 状态(0:未上架,1:上架) */ + @JsonProperty("is_show") + private Integer isShow; + + /** 是否热卖 */ + @JsonProperty("is_hot") + private Integer isHot; + + /** 是否优惠 */ + @JsonProperty("is_benefit") + private Integer isBenefit; + + /** 是否精品 */ + @JsonProperty("is_best") + private Integer isBest; + + /** 是否新品 */ + @JsonProperty("is_new") + private Integer isNew; + + /** 商品描述 */ + private String description; + + + /** 是否包邮 */ + @JsonProperty("is_postage") + private Integer isPostage; + + + /** 获得积分 */ + @JsonProperty("give_integral") + private Double giveIntegral; + + /** 成本价 */ + private Double cost; + + + /** 是否优品推荐 */ + @JsonProperty("is_good") + private Integer isGood; + + /** 是否单独分佣 */ + @JsonProperty("is_sub") + private Integer isSub; + + /** 是否开启啊积分兑换 */ + @JsonProperty("is_integral") + private Integer isIntegral; + + /** 虚拟销量 */ + private Long ficti; + + + /** 运费模板ID */ + @JsonProperty("temp_id") + private Long tempId; + + /** 规格 0单 1多 */ + @JsonProperty("spec_type") + private Integer specType; + + private ProductFormatDto attr; + + private List items; + + private List attrs; + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductFormatDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductFormatDto.java new file mode 100644 index 00000000..1d53c740 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductFormatDto.java @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Map; + +/** + * @ClassName ProductFormatDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/12 + **/ + +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +public class ProductFormatDto { + + private String sku = ""; + + @JsonProperty("bar_code") + private String barCode = ""; + + private Double brokerage = 0d; + + @JsonProperty("brokerage_two") + private Double brokerageTwo = 0d; + + private Double price = 0d; + + @JsonProperty("ot_price") + private Double otPrice = 0d; + + private Double cost = 0d; + + private Integer stock = 0; + + private Integer integral = 0; + + private String pic = ""; + + private String value1 = ""; + + private String value2 = ""; + + private Double volume = 0d; + + private Double weight = 0d; + @JsonProperty("pink_price") + private Double pinkPrice = 0d; + @JsonProperty("pink_stock") + private Integer pinkStock = 0; + @JsonProperty("seckill_price") + private Double seckillPrice = 0d; + @JsonProperty("seckill_stock") + private Integer seckillStock = 0; + + private Map detail; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductResultDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductResultDto.java new file mode 100644 index 00000000..4e791ac9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductResultDto.java @@ -0,0 +1,26 @@ +package co.yixiang.modules.product.service.dto; + +import io.swagger.models.auth.In; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; + +/** + * @ClassName 产品结果DTO + * @Author hupeng <610796224@qq.com> + * @Date 2020/4/24 + **/ +@Getter +@Setter +@Builder +public class ProductResultDto { + private Double minPrice; + + private Double minOtPrice; + + private Double minCost; + + private Integer stock; + + private Integer minIntegral; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java new file mode 100644 index 00000000..06e22bf5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/StoreProductDto.java @@ -0,0 +1,150 @@ +package co.yixiang.modules.product.service.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + + +/** + * 商品对象DTO + * + * @author hupeng + * @date 2020-04-23 + */ +@Getter +@Setter +@ToString +public class StoreProductDto +{ + + /** 商品id */ + private Long id; + + + /** 商品图片 */ + @NotBlank(message = "商品图片必传") + private String image; + + /** 轮播图 */ + @NotNull(message = "轮播图不为空") + @JsonProperty("slider_image") + private List sliderImage; + + /** 商品名称 */ + @NotBlank(message = "商品名称不能为空") + @JsonProperty("store_name") + private String storeName; + + /** 商品简介 */ + @JsonProperty("store_info") + private String storeInfo; + + /** 关键字 */ + @NotBlank(message = "关键字不能为空") + private String keyword; + + /** 商品条码(一维码) */ + @JsonProperty("bar_code") + private String barCode; + + /** 分类id */ + @NotNull(message = "分类id不能为空") + @JsonProperty("cate_id") + private String cateId; + + /** 商品价格 */ + private Double price; + + /** 市场价 */ + private Double otPrice; + + /** 邮费 */ + private Double postage; + + /** 单位名 */ + @JsonProperty("unit_name") + private String unitName; + + /** 排序 */ + private Long sort; + + /** 销量 */ + private Long sales; + + /** 库存 */ + private Long stock; + + /** 状态(0:未上架,1:上架) */ + @JsonProperty("is_show") + private Integer isShow; + + /** 是否热卖 */ + @JsonProperty("is_hot") + private Integer isHot; + + /** 是否优惠 */ + @JsonProperty("is_benefit") + private Integer isBenefit; + + /** 是否精品 */ + @JsonProperty("is_best") + private Integer isBest; + + /** 是否新品 */ + @JsonProperty("is_new") + private Integer isNew; + + /** 商品描述 */ + @NotBlank(message = "商品详情不能为空") + private String description; + + + /** 是否包邮 */ + @JsonProperty("is_postage") + private Integer isPostage; + + /** 获得积分 */ + @JsonProperty("give_integral") + private Double giveIntegral; + + /** 成本价 */ + private Double cost; + + + /** 是否优品推荐 */ + @JsonProperty("is_good") + private Integer isGood; + + /** 是否单独分佣 */ + @JsonProperty("is_sub") + private Integer isSub; + + /** 是否开启啊积分兑换 */ + @JsonProperty("is_integral") + private Integer isIntegral; + + /** 虚拟销量 */ + private Long ficti; + + /** 运费模板ID */ + @JsonProperty("temp_id") + private Long tempId; + + /** 规格 0单 1多 */ + @JsonProperty("spec_type") + private Integer specType; + + //属性项目 + private List items; + + //sku结果集 + private List attrs; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductAttrQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductAttrQueryCriteria.java new file mode 100644 index 00000000..bd74a715 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductAttrQueryCriteria.java @@ -0,0 +1,12 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import lombok.Data; + +@Data +public class YxStoreProductAttrQueryCriteria { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductAttrValueQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductAttrValueQueryCriteria.java new file mode 100644 index 00000000..fe092091 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductAttrValueQueryCriteria.java @@ -0,0 +1,12 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import lombok.Data; + +@Data +public class YxStoreProductAttrValueQueryCriteria { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductDto.java new file mode 100644 index 00000000..c0d2645b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductDto.java @@ -0,0 +1,134 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import co.yixiang.modules.category.service.dto.YxStoreCategorySmallDto; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreProductDto implements Serializable { + + /** 商品id */ + private Integer id; + + /** 商户Id(0为总后台管理员创建,不为0的时候是商户后台创建) */ + private Integer merId; + + /** 商品图片 */ + private String image; + + /** 轮播图 */ + private String sliderImage; + + /** 商品名称 */ + private String storeName; + + /** 商品简介 */ + private String storeInfo; + + /** 关键字 */ + private String keyword; + + /** 产品条码(一维码) */ + private String barCode; + + /** 分类id */ + private String cateId; + + /** 商品价格 */ + private BigDecimal price; + + /** 会员价格 */ + private BigDecimal vipPrice; + + /** 市场价 */ + private BigDecimal otPrice; + + /** 邮费 */ + private BigDecimal postage; + + /** 单位名 */ + private String unitName; + + /** 排序 */ + private Integer sort; + + /** 销量 */ + private Integer sales; + + /** 库存 */ + private Integer stock; + + /** 状态(0:未上架,1:上架) */ + private Integer isShow; + + /** 是否热卖 */ + private Integer isHot; + + /** 是否优惠 */ + private Integer isBenefit; + + /** 是否精品 */ + private Integer isBest; + + /** 是否新品 */ + private Integer isNew; + + /** 产品描述 */ + private String description; + + /** 添加时间 */ + private Integer addTime; + + /** 是否包邮 */ + private Integer isPostage; + + /** 是否删除 */ + private Integer isDel; + + /** 商户是否代理 0不可代理1可代理 */ + private Integer merUse; + + /** 获得积分 */ + private BigDecimal giveIntegral; + + /** 成本价 */ + private BigDecimal cost; + + /** 秒杀状态 0 未开启 1已开启 */ + private Integer isSeckill; + + /** 砍价状态 0未开启 1开启 */ + private Integer isBargain; + + /** 是否优品推荐 */ + private Integer isGood; + + /** 虚拟销量 */ + private Integer ficti; + + /** 浏览量 */ + private Integer browse; + + /** 产品二维码地址(用户小程序海报) */ + private String codePath; + + /** 淘宝京东1688类型 */ + private String soureLink; + + @ApiModelProperty(value = "是否开启积分兑换") + private Integer isIntegral; + + private YxStoreCategorySmallDto storeCategory; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductQueryCriteria.java new file mode 100644 index 00000000..e65473cb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductQueryCriteria.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreProductQueryCriteria{ + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String storeName; + + // 精确 + @Query + private Integer isDel; + + @Query + private Integer isShow; + + @Query + private Integer cateId; + + @Query + private Integer isIntegral; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRelationDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRelationDto.java new file mode 100644 index 00000000..fa416018 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRelationDto.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.dto; + +import co.yixiang.modules.product.domain.YxStoreProduct; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.sql.Timestamp; +import java.io.Serializable; + +/** + * @author hupeng + * @date 2020-09-03 + */ +@Data +public class YxStoreProductRelationDto implements Serializable { + + private Long id; + + /** 用户ID */ + private Long uid; + + private String userName; + + /** 商品ID */ + private Long productId; + + private YxStoreProduct product; + + /** 类型(收藏(collect)、点赞(like)) */ + private String type; + + /** 某种类型的商品(普通商品、秒杀商品) */ + private String category; + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp createTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp updateTime; + + private Integer isDel; +} + diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRelationQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRelationQueryCriteria.java new file mode 100644 index 00000000..155070e2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRelationQueryCriteria.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.dto; + +import lombok.Data; +import java.util.List; +import co.yixiang.annotation.Query; + +/** + * @author hupeng + * @date 2020-09-03 + */ +@Data +public class YxStoreProductRelationQueryCriteria{ + @Query(type = Query.Type.EQUAL) + private String type; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductReplyDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductReplyDto.java new file mode 100644 index 00000000..f5ca7ada --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductReplyDto.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import co.yixiang.modules.user.service.dto.YxUserSmallDto; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreProductReplyDto implements Serializable { + + // 评论ID + private Long id; + + // 用户ID + private Long uid; + + private YxUserSmallDto user; + + // 订单ID + private Long oid; + + // 唯一id + private String unique; + + // 产品id + private Long productId; + + private YxStoreProductSmallDto storeProduct; + + + // 某种商品类型(普通商品、秒杀商品) + private String replyType; + + // 商品分数 + private Integer productScore; + + // 服务分数 + private Integer serviceScore; + + // 评论内容 + private String comment; + + // 评论图片 + private String pics; + + // 评论时间 + private Date createTime; + + // 管理员回复内容 + private String merchantReplyContent; + + // 管理员回复时间 + private Date merchantReplyTime; + + // 0未回复1已回复 + private Integer isReply; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductReplyQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductReplyQueryCriteria.java new file mode 100644 index 00000000..319ad684 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductReplyQueryCriteria.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxStoreProductReplyQueryCriteria{ + @Query + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRuleDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRuleDto.java new file mode 100644 index 00000000..0fea7050 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRuleDto.java @@ -0,0 +1,37 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.service.dto; + +import com.alibaba.fastjson.JSONArray; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-06-28 +*/ +@Data +public class YxStoreProductRuleDto implements Serializable { + + private Integer id; + + /** 规格名称 */ + private String ruleName; + + /** 规格值 */ + private JSONArray ruleValue; + + private Timestamp createTime; + + private Timestamp updateTime; + + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRuleQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRuleQueryCriteria.java new file mode 100644 index 00000000..72783144 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductRuleQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-06-28 +*/ +@Data +public class YxStoreProductRuleQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductSmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductSmallDto.java new file mode 100644 index 00000000..632adf9a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/YxStoreProductSmallDto.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.product.service.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** +* @author hupeng +* @date 2019-10-04 +*/ +@Data +public class YxStoreProductSmallDto implements Serializable { + + // 商品id + private Integer id; + + // 商品图片 + private String image; + + + // 商品名称 + private String storeName; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrResultServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrResultServiceImpl.java new file mode 100644 index 00000000..d7da7e13 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrResultServiceImpl.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.product.domain.YxStoreProductAttrResult; +import co.yixiang.modules.product.service.YxStoreProductAttrResultService; +import co.yixiang.modules.product.service.mapper.StoreProductAttrResultMapper; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreProductAttrResultServiceImpl extends BaseServiceImpl implements YxStoreProductAttrResultService { + + /** + * 新增商品属性详情 + * @param map map + * @param productId 商品id + */ + @Override + public void insertYxStoreProductAttrResult(Map map, Long productId) + { + YxStoreProductAttrResult yxStoreProductAttrResult = new YxStoreProductAttrResult(); + yxStoreProductAttrResult.setProductId(productId); + yxStoreProductAttrResult.setResult(JSON.toJSONString(map)); + yxStoreProductAttrResult.setChangeTime(new Date()); + + Long count = this.count(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrResult::getProductId,productId)); + if(count > 0) { + this.remove(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrResult::getProductId,productId)); + } + + this.save(yxStoreProductAttrResult); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java new file mode 100644 index 00000000..dbedaeec --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrServiceImpl.java @@ -0,0 +1,263 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.BusinessException; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.ProductTypeEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.product.domain.YxStoreProductAttr; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrResultService; +import co.yixiang.modules.product.service.YxStoreProductAttrService; +import co.yixiang.modules.product.service.YxStoreProductAttrValueService; +import co.yixiang.modules.product.service.dto.AttrValueDto; +import co.yixiang.modules.product.service.dto.FromatDetailDto; +import co.yixiang.modules.product.service.dto.ProductFormatDto; +import co.yixiang.modules.product.service.mapper.StoreProductAttrMapper; +import co.yixiang.modules.product.service.mapper.StoreProductAttrValueMapper; +import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class YxStoreProductAttrServiceImpl extends BaseServiceImpl implements YxStoreProductAttrService { + + @Autowired + private IGenerator generator; + + @Autowired + private StoreProductAttrMapper yxStoreProductAttrMapper; + @Autowired + private StoreProductAttrValueMapper yxStoreProductAttrValueMapper; + + @Autowired + private YxStoreProductAttrValueService storeProductAttrValueService; + @Autowired + private YxStoreProductAttrResultService storeProductAttrResultService; + + /** + * 新增商品属性 + * @param items attr + * @param attrs value + * @param productId 商品id + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void insertYxStoreProductAttr(List items, List attrs, + Long productId) + { + List attrGroup = new ArrayList<>(); + for (FromatDetailDto fromatDetailDto : items) { + YxStoreProductAttr yxStoreProductAttr = YxStoreProductAttr.builder() + .productId(productId) + .attrName(fromatDetailDto.getValue()) + .attrValues(StrUtil.join(",",fromatDetailDto.getDetail())) + .build(); + + attrGroup.add(yxStoreProductAttr); + } + + /*Long count = storeProductAttrValueService.count(Wrappers.lambdaQuery().eq(YxStoreProductAttrValue::getProductId, productId)); + if (count > 0 ) { + throw new BadRequestException("该产品已被添加到其他活动,禁止操作!"); + }*/ + + List valueGroup = new ArrayList<>(); + for (ProductFormatDto productFormatDto : attrs) { + + if(productFormatDto.getPinkStock()>productFormatDto.getStock() || productFormatDto.getSeckillStock()>productFormatDto.getStock()){ + throw new BadRequestException("活动商品库存不能大于原有商品库存"); + } + List stringList = new ArrayList<>(productFormatDto.getDetail().values()); + Collections.sort(stringList); + + YxStoreProductAttrValue yxStoreProductAttrValue = YxStoreProductAttrValue.builder() + .productId(productId) + .sku(StrUtil.join(",",stringList)) + .price(BigDecimal.valueOf(productFormatDto.getPrice())) + .cost(BigDecimal.valueOf(productFormatDto.getCost())) + .otPrice(BigDecimal.valueOf(productFormatDto.getOtPrice())) + .unique(IdUtil.simpleUUID()) + .image(productFormatDto.getPic()) + .barCode(productFormatDto.getBarCode()) + .weight(BigDecimal.valueOf(productFormatDto.getWeight())) + .volume(BigDecimal.valueOf(productFormatDto.getVolume())) + .brokerage(BigDecimal.valueOf(productFormatDto.getBrokerage())) + .brokerageTwo(BigDecimal.valueOf(productFormatDto.getBrokerageTwo())) + .stock(productFormatDto.getStock()) + .integral(productFormatDto.getIntegral()) + .pinkPrice(BigDecimal.valueOf(productFormatDto.getPinkPrice()==null?0:productFormatDto.getPinkPrice())) + .seckillPrice(BigDecimal.valueOf(productFormatDto.getSeckillPrice()==null?0:productFormatDto.getSeckillPrice())) + .pinkStock(productFormatDto.getPinkStock()==null?0:productFormatDto.getPinkStock()) + .seckillStock(productFormatDto.getSeckillStock()==null?0:productFormatDto.getSeckillStock()) + .build(); + + + valueGroup.add(yxStoreProductAttrValue); + } + + if(attrGroup.isEmpty() || valueGroup.isEmpty()){ + throw new BusinessException("请设置至少一个属性!"); + } + + //清理属性 + this.clearProductAttr(productId); + + //批量添加 + this.saveBatch(attrGroup); + storeProductAttrValueService.saveBatch(valueGroup); + + Map map = new LinkedHashMap<>(); + map.put("attr",items); + map.put("value",attrs); + + storeProductAttrResultService.insertYxStoreProductAttrResult(map,productId); + } + + /** + * 删除YxStoreProductAttrValue表的属性 + * @param productId 商品id + */ + private void clearProductAttr(Long productId) { + if(ObjectUtil.isNull(productId)) { + throw new YshopException("产品不存在"); + } + + yxStoreProductAttrMapper.delete(Wrappers.lambdaQuery() + .eq(YxStoreProductAttr::getProductId,productId)); + yxStoreProductAttrValueMapper.delete(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrValue::getProductId,productId)); + + } + + + /** + * 增加库存减去销量 + * @param num 数量 + * @param productId 商品id + * @param unique sku唯一值 + */ + @Override + public void incProductAttrStock(Integer num, Long productId, String unique, String type ) { + + if(ProductTypeEnum.COMBINATION.getValue().equals(type)){ + yxStoreProductAttrValueMapper.incCombinationStockDecSales(num,productId,unique); + }else if(ProductTypeEnum.SECKILL.getValue().equals(type)){ + yxStoreProductAttrValueMapper.incSeckillStockDecSales(num,productId,unique); + }else { + yxStoreProductAttrValueMapper.incStockDecSales(num,productId,unique); + } + } + + /** + * 减少库存增加销量(针对sku操作) + * @param num 数量 + * @param productId 商品id + * @param unique sku唯一值 + */ + @Override + public void decProductAttrStock(int num, Long productId, String unique,String type) { + int res = 0; + if(ProductTypeEnum.COMBINATION.getValue().equals(type)){ + res = yxStoreProductAttrValueMapper.decCombinationStockIncSales(num,productId,unique); + }else if(ProductTypeEnum.SECKILL.getValue().equals(type)){ + res = yxStoreProductAttrValueMapper.decSeckillStockIncSales(num,productId,unique); + }else { + res = yxStoreProductAttrValueMapper.decStockIncSales(num,productId,unique); + } + if(res == 0) { + throw new YshopException("商品库存不足"); + } + } + + + + /** + * 更加sku 唯一值获取sku对象 + * @param unique 唯一值 + * @return YxStoreProductAttrValue + */ + @Override + public YxStoreProductAttrValue uniqueByAttrInfo(String unique) { + return yxStoreProductAttrValueMapper.selectOne(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrValue::getUnique,unique)); + } + + + /** + * 获取商品sku属性 + * @param productId 商品id + * @return map + */ + @Override + public Map getProductAttrDetail(long productId) { + + List storeProductAttrs = yxStoreProductAttrMapper + .selectList(Wrappers.lambdaQuery() + .eq(YxStoreProductAttr::getProductId,productId) + .orderByAsc(YxStoreProductAttr::getAttrValues)); + + List productAttrValues = storeProductAttrValueService + .list(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrValue::getProductId,productId)); + + + Map map = productAttrValues.stream() + .collect(Collectors.toMap(YxStoreProductAttrValue::getSku, p -> p)); + + List yxStoreProductAttrQueryVoList = new ArrayList<>(); + + for (YxStoreProductAttr attr : storeProductAttrs) { + List stringList = Arrays.asList(attr.getAttrValues().split(",")); + List attrValueDTOS = new ArrayList<>(); + for (String str : stringList) { + AttrValueDto attrValueDTO = new AttrValueDto(); + attrValueDTO.setAttr(str); + attrValueDTOS.add(attrValueDTO); + } + YxStoreProductAttrQueryVo attrQueryVo = generator.convert(attr,YxStoreProductAttrQueryVo.class); + attrQueryVo.setAttrValue(attrValueDTOS); + attrQueryVo.setAttrValueArr(stringList); + + yxStoreProductAttrQueryVoList.add(attrQueryVo); + } + + Map returnMap = new LinkedHashMap<>(2); + returnMap.put("productAttr",yxStoreProductAttrQueryVoList); + returnMap.put("productValue",map); + + return returnMap; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrValueServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrValueServiceImpl.java new file mode 100644 index 00000000..9597e768 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductAttrValueServiceImpl.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.service.YxStoreProductAttrValueService; +import co.yixiang.modules.product.service.mapper.StoreProductAttrValueMapper; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreProductAttrValueServiceImpl extends BaseServiceImpl implements YxStoreProductAttrValueService { + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java new file mode 100644 index 00000000..0899ec60 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java @@ -0,0 +1,174 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.impl; + +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.product.domain.YxStoreProductRelation; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationDto; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria; +import co.yixiang.modules.product.service.mapper.YxStoreProductRelationMapper; +import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import org.springframework.data.domain.Pageable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** + *

+ * 商品点赞和收藏表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-10-23 + */ +@Slf4j +@Service +@AllArgsConstructor +@Transactional(rollbackFor = Exception.class) +public class YxStoreProductRelationServiceImpl extends BaseServiceImpl implements YxStoreProductRelationService { + + private final YxStoreProductRelationMapper yxStoreProductRelationMapper; + private final YxStoreProductService storeProductService; + private final YxUserService userService; + private final IGenerator generator; + + /** + * 获取用户收藏列表 + * @param page page + * @param limit limit + * @param uid 用户id + * @return list + */ + @Override + public List userCollectProduct(int page, int limit, Long uid,String type) { + Page pageModel = new Page<>(page, limit); + List list = yxStoreProductRelationMapper.selectRelationList(pageModel,uid,type); + return list; + } + + /** + * 添加收藏 + * @param productId 商品id + * @param uid 用户id + */ + @Override + public void addRroductRelation(long productId,long uid,String category) { + if(isProductRelation(productId,uid)) { + throw new YshopException("已收藏"); + } + YxStoreProductRelation storeProductRelation = YxStoreProductRelation.builder() + .productId(productId) + .uid(uid) + .type(category) + .build(); + yxStoreProductRelationMapper.insert(storeProductRelation); + } + + /** + * 取消收藏 + * @param productId 商品id + * @param uid 用户id + */ + @Override + public void delRroductRelation(long productId,long uid,String category) { + YxStoreProductRelation productRelation = this.lambdaQuery() + .eq(YxStoreProductRelation::getProductId,productId) + .eq(YxStoreProductRelation::getUid,uid) + .eq(YxStoreProductRelation::getType,category) + .one(); + if(productRelation == null) { + throw new YshopException("已取消"); + } + this.removeById(productRelation.getId()); + } + + + /** + * 是否收藏 + * @param productId 商品ID + * @param uid 用户ID + * @return Boolean + */ + @Override + public Boolean isProductRelation(long productId, long uid) { + Long count = yxStoreProductRelationMapper + .selectCount(Wrappers.lambdaQuery() + .eq(YxStoreProductRelation::getUid,uid) + .eq(YxStoreProductRelation::getType,"collect") + .eq(YxStoreProductRelation::getProductId,productId)); + if(count > 0) { + return true; + } + + return false; + } + + @Override + //@Cacheable + public PageResult queryAll(YxStoreProductRelationQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + PageResult relationDtoPageResult = generator.convertPageInfo(page, YxStoreProductRelationDto.class); + relationDtoPageResult.getContent().forEach(i ->{ + i.setProduct(storeProductService.getById(i.getProductId())); + i.setUserName(userService.getYxUserById(i.getUid()).getNickname()); + }); + return relationDtoPageResult; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreProductRelationQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProductRelation.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreProductRelationDto yxStoreProductRelation : all) { + Map map = new LinkedHashMap<>(); + map.put("用户ID", yxStoreProductRelation.getUid()); + map.put("商品ID", yxStoreProductRelation.getProductId()); + map.put("类型(收藏(collect)、点赞(like))", yxStoreProductRelation.getType()); + map.put("某种类型的商品(普通商品、秒杀商品)", yxStoreProductRelation.getCategory()); + map.put("添加时间", yxStoreProductRelation.getCreateTime()); + map.put(" updateTime", yxStoreProductRelation.getUpdateTime()); + map.put(" isDel", yxStoreProductRelation.getIsDel()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public void collectDelFoot(List ids) { + yxStoreProductRelationMapper.deleteBatchIds(ids); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductReplyServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductReplyServiceImpl.java new file mode 100644 index 00000000..51d06d49 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductReplyServiceImpl.java @@ -0,0 +1,280 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.impl; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.product.domain.YxStoreProductReply; +import co.yixiang.modules.product.service.YxStoreProductReplyService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.service.dto.YxStoreProductReplyDto; +import co.yixiang.modules.product.service.dto.YxStoreProductReplyQueryCriteria; +import co.yixiang.modules.product.service.mapper.StoreProductReplyMapper; +import co.yixiang.modules.product.vo.ReplyCountVo; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreProductReplyServiceImpl extends BaseServiceImpl implements YxStoreProductReplyService { + + @Autowired + private IGenerator generator; + + @Autowired + private YxUserService yxUserService; + + @Autowired + private YxStoreProductService yxStoreProductService; + + + /** + * 评价数据 + * @param productId 商品id + * @return ReplyCountVO + */ + @Override + public ReplyCountVo getReplyCount(long productId) { + Long sumCount = productReplyCount(productId); + + if(sumCount == 0) { + return new ReplyCountVo(); + } + + //好评 + Long goodCount = this.baseMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxStoreProductReply::getProductId,productId) + .eq(YxStoreProductReply::getProductScore,5)); + + //中评 + Long inCount = this.baseMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxStoreProductReply::getProductId,productId) + .lt(YxStoreProductReply::getProductScore,5) + .gt(YxStoreProductReply::getProductScore,2)); + + //差评 + Long poorCount = this.baseMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxStoreProductReply::getProductId,productId) + .lt(YxStoreProductReply::getProductScore,2)); + + //好评率 + String replyChance = ""+NumberUtil.round(NumberUtil.mul(NumberUtil.div(goodCount,sumCount),100),2); + String replyStar = ""+NumberUtil.round(NumberUtil.mul(NumberUtil.div(goodCount,sumCount),5),2); + + return ReplyCountVo.builder() + .sumCount(sumCount) + .goodCount(goodCount) + .inCount(inCount) + .poorCount(poorCount) + .replyChance(replyChance) + .replySstar(replyStar) + .build(); + + } + + /** + * 处理评价 + * @param replyQueryVo replyQueryVo + * @return YxStoreProductReplyQueryVo + */ + @Override + public YxStoreProductReplyQueryVo handleReply(YxStoreProductReplyQueryVo replyQueryVo) { + YxStoreCartQueryVo cartInfo = JSONObject.parseObject(replyQueryVo.getCartInfo() + ,YxStoreCartQueryVo.class); + if(ObjectUtil.isNotNull(cartInfo)){ + if(ObjectUtil.isNotNull(cartInfo.getProductInfo())){ + if(ObjectUtil.isNotNull(cartInfo.getProductInfo().getAttrInfo())){ + replyQueryVo.setSku(cartInfo.getProductInfo().getAttrInfo().getSku()); + } + } + } + + BigDecimal star = NumberUtil.add(replyQueryVo.getProductScore(), + replyQueryVo.getServiceScore()); + + star = NumberUtil.div(star,2); + + replyQueryVo.setStar(String.valueOf(star.intValue())); + + if(StrUtil.isEmpty(replyQueryVo.getComment())){ + replyQueryVo.setComment("此用户没有填写评价"); + } + + return replyQueryVo; + } + + /** + * 获取单条评价 + * @param productId 商品di + * @return YxStoreProductReplyQueryVo + */ + @Override + public YxStoreProductReplyQueryVo getReply(long productId) { + YxStoreProductReplyQueryVo vo = this.baseMapper.getReply(productId); + if(ObjectUtil.isNotNull(vo)){ + return handleReply(this.baseMapper.getReply(productId)); + } + return null; + } + + + /** + * 获取评价列表 + * @param productId 商品id + * @param type 0-全部 1-好评 2-中评 3-差评 + * @param page page + * @param limit limit + * @return list + */ + @Override + public List getReplyList(long productId,int type,int page, int limit) { + List newList = new ArrayList<>(); + Page pageModel = new Page<>(page, limit); + List list = this.baseMapper + .selectReplyList(pageModel,productId,type); + List list1 = list.stream().map(i ->{ + YxStoreProductReplyQueryVo vo = new YxStoreProductReplyQueryVo(); + BeanUtils.copyProperties(i,vo); + if(i.getPictures().contains(",")){ + vo.setPics(i.getPictures().split(",")); + } + return vo; + }).collect(Collectors.toList()); + for (YxStoreProductReplyQueryVo queryVo : list1) { + newList.add(handleReply(queryVo)); + } + return newList; + } + + @Override + public Long getInfoCount(Integer oid, String unique) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProductReply::getUnique,unique).eq(YxStoreProductReply::getOid,oid); + return this.baseMapper.selectCount(wrapper); + } + + @Override + public Long productReplyCount(long productId) { + + return this.baseMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxStoreProductReply::getProductId,productId)); + + } + + @Override + public Long replyCount(String unique) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProductReply::getUnique,unique); + return this.baseMapper.selectCount(wrapper); + } + + /** + * 好评比例 + * @param productId 商品id + * @return % + */ + @Override + public String replyPer(long productId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProductReply::getProductId,productId) + .eq(YxStoreProductReply::getIsDel,ShopCommonEnum.DELETE_0.getValue()) + .eq(YxStoreProductReply::getProductScore,5); + Long productScoreCount = this.baseMapper.selectCount(wrapper); + Long count = productReplyCount(productId); + if(count > 0){ + return ""+NumberUtil.round(NumberUtil.mul(NumberUtil.div(productScoreCount,count),100),2); + } + + return "0"; + } + + + + + + //===================================// + + @Override + //@Cacheable + public Map queryAll(YxStoreProductReplyQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreProductReplyDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreProductReplyQueryCriteria criteria){ + List storeProductReplyList = baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProductReply.class, criteria)); + storeProductReplyList.forEach(yxStoreProductReply->{ + yxStoreProductReply.setUser(yxUserService.getById(yxStoreProductReply.getUid())); + yxStoreProductReply.setStoreProduct(yxStoreProductService.getById(yxStoreProductReply.getProductId())); + }); + return storeProductReplyList; + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreProductReplyDto yxStoreProductReply : all) { + Map map = new LinkedHashMap<>(); + map.put("用户ID", yxStoreProductReply.getUid()); + map.put("订单ID", yxStoreProductReply.getOid()); + map.put("唯一id", yxStoreProductReply.getUnique()); + map.put("产品id", yxStoreProductReply.getProductId()); + map.put("某种商品类型(普通商品、秒杀商品)", yxStoreProductReply.getReplyType()); + map.put("商品分数", yxStoreProductReply.getProductScore()); + map.put("服务分数", yxStoreProductReply.getServiceScore()); + map.put("评论内容", yxStoreProductReply.getComment()); + map.put("评论图片", yxStoreProductReply.getPics()); + map.put("管理员回复内容", yxStoreProductReply.getMerchantReplyContent()); + map.put("管理员回复时间", yxStoreProductReply.getMerchantReplyTime()); + map.put("0未回复1已回复", yxStoreProductReply.getIsReply()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRuleServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRuleServiceImpl.java new file mode 100644 index 00000000..caa65201 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRuleServiceImpl.java @@ -0,0 +1,80 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.product.domain.YxStoreProductRule; +import co.yixiang.modules.product.service.YxStoreProductRuleService; +import co.yixiang.modules.product.service.dto.YxStoreProductRuleDto; +import co.yixiang.modules.product.service.dto.YxStoreProductRuleQueryCriteria; +import co.yixiang.modules.product.service.mapper.YxStoreProductRuleMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-06-28 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxStoreProductRuleServiceImpl extends BaseServiceImpl implements YxStoreProductRuleService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxStoreProductRuleQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", page.getList()); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreProductRuleQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProductRule.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreProductRule yxStoreProductRule : all) { + Map map = new LinkedHashMap<>(); + map.put("规格名称", yxStoreProductRule.getRuleName()); + map.put("规格值", yxStoreProductRule.getRuleValue()); + map.put(" createTime", yxStoreProductRule.getCreateTime()); + map.put(" updateTime", yxStoreProductRule.getUpdateTime()); + map.put(" isDel", yxStoreProductRule.getIsDel()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java new file mode 100644 index 00000000..691c6a8b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java @@ -0,0 +1,974 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.CommonEnum; +import co.yixiang.enums.ProductEnum; +import co.yixiang.enums.ProductTypeEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.enums.SortEnum; +import co.yixiang.enums.SpecTypeEnum; +import co.yixiang.exception.BadRequestException; +import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.category.service.YxStoreCategoryService; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.modules.product.domain.YxStoreProductRelation; +import co.yixiang.modules.product.param.YxStoreProductQueryParam; +import co.yixiang.modules.product.service.YxStoreProductAttrService; +import co.yixiang.modules.product.service.YxStoreProductAttrValueService; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.product.service.YxStoreProductReplyService; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.product.service.dto.DetailDto; +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.modules.product.service.dto.StoreProductDto; +import co.yixiang.modules.product.service.dto.YxStoreProductDto; +import co.yixiang.modules.product.service.dto.YxStoreProductQueryCriteria; +import co.yixiang.modules.product.service.mapper.StoreProductMapper; +import co.yixiang.modules.product.vo.ProductVo; +import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.utils.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import com.qiniu.util.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +/** + * @author hupeng + * @date 2020-05-12 + */ +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class YxStoreProductServiceImpl extends BaseServiceImpl implements YxStoreProductService { + + @Autowired + private IGenerator generator; + @Autowired + private StoreProductMapper storeProductMapper; + @Autowired + private YxStoreCategoryService yxStoreCategoryService; + @Autowired + private YxStoreProductAttrService yxStoreProductAttrService; + @Autowired + private YxStoreProductAttrValueService yxStoreProductAttrValueService; + @Autowired + private YxUserService userService; + @Autowired + private YxStoreProductReplyService replyService; + @Autowired + private YxStoreProductRelationService relationService; + @Autowired + private YxSystemStoreService systemStoreService; + @Autowired + private YxShippingTemplatesService shippingTemplatesService; + @Autowired + private RedisUtils redisUtils; + + + /** + * 增加库存 减少销量 + * + * @param num 数量 + * @param productId 商品id + * @param unique sku唯一值 + */ + @Override + public void incProductStock(Integer num, Long productId, String unique, Long activityId, String type) { + //处理属性sku + if (StrUtil.isNotEmpty(unique)) { + yxStoreProductAttrService.incProductAttrStock(num, productId, unique, type); + } + //先处理商品库存,活动商品也要处理,因为共享库存 + storeProductMapper.incStockDecSales(num, productId); + //处理商品外层显示的库存 + if (ProductTypeEnum.COMBINATION.getValue().equals(type)) { + storeProductMapper.incCombinationStockIncSales(num, productId, activityId); + } else if (ProductTypeEnum.SECKILL.getValue().equals(type)) { + storeProductMapper.incSeckillStockIncSales(num, productId, activityId); + } + //todo 处理砍价商品库存 + } + + /** + * 减少库存与增加销量 + * + * @param num 数量 + * @param productId 商品id + * @param unique sku + */ + @Override + public void decProductStock(int num, Long productId, String unique, Long activityId, String type) { + //处理属性sku + if (StrUtil.isNotEmpty(unique)) { + yxStoreProductAttrService.decProductAttrStock(num, productId, unique, type); + } + //先处理商品库存,活动商品也要处理,因为共享库存 + int product = storeProductMapper.decStockIncSales(num, productId); + if (product == 0) { + throw new YshopException("共享商品库存不足"); + } + //处理商品外层显示的库存 + if (ProductTypeEnum.COMBINATION.getValue().equals(type)) { + int combinationRes = storeProductMapper.decCombinationStockIncSales(num, productId, activityId); + if (combinationRes == 0) { + throw new YshopException("拼团商品库存不足"); + } + } else if (ProductTypeEnum.SECKILL.getValue().equals(type)) { + int seckillRes = storeProductMapper.decSeckillStockIncSales(num, productId, activityId); + if (seckillRes == 0) { + throw new YshopException("秒杀商品库存不足"); + } + } + //todo 处理砍价库存 + + } + + + @Override + public YxStoreProduct getProductInfo(Long id) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProduct::getIsShow, 1).eq(YxStoreProduct::getId, id); + YxStoreProduct storeProduct = this.baseMapper.selectOne(wrapper); + if (ObjectUtil.isNull(storeProduct)) { + throw new ErrorRequestException("商品不存在或已下架"); + } + + return storeProduct; + } + + + /** + * 获取单个商品 + * + * @param id 商品id + * @return YxStoreProductQueryVo + */ + @Override + public YxStoreProductQueryVo getStoreProductById(Long id) { + return generator.convert(this.baseMapper.selectById(id), YxStoreProductQueryVo.class); + } + + + /** + * 返回普通商品库存 + * + * @param productId 商品id + * @param unique sku唯一值 + * @return int + */ + @Override + public int getProductStock(Long productId, String unique, String type) { + YxStoreProductAttrValue storeProductAttrValue = yxStoreProductAttrValueService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrValue::getUnique, unique) + .eq(YxStoreProductAttrValue::getProductId, productId)); + + if (storeProductAttrValue == null) { + return 0; + } + if (ProductTypeEnum.PINK.getValue().equals(type)) { + return storeProductAttrValue.getPinkStock(); + } else if (ProductTypeEnum.SECKILL.getValue().equals(type)) { + return storeProductAttrValue.getSeckillStock(); + } + return storeProductAttrValue.getStock(); + + } + + + /** + * 商品列表 + * + * @param productQueryParam YxStoreProductQueryParam + * @return list + */ + @Override + public List getGoodsList(YxStoreProductQueryParam productQueryParam) { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProduct::getIsShow, CommonEnum.SHOW_STATUS_1.getValue()); + wrapper.eq(YxStoreProduct::getIsDel, CommonEnum.DEL_STATUS_0.getValue()); +// wrapper.eq(YxStoreProduct::getIsIntegral, CommonEnum.SHOW_STATUS_1.getValue()); + + if(productQueryParam.getIsIntegral()!=null){ + wrapper.eq(YxStoreProduct::getIsIntegral, productQueryParam.getIsIntegral()); + } + //多字段模糊查询分类搜索 + if (StrUtil.isNotBlank(productQueryParam.getSid()) && + !ShopConstants.YSHOP_ZERO.equals(productQueryParam.getSid())) { + wrapper.eq(YxStoreProduct::getCateId, productQueryParam.getSid()); + } + //关键字搜索 + if (StrUtil.isNotEmpty(productQueryParam.getKeyword())) { + wrapper.and(wrapper1 -> { + wrapper1.or(); + wrapper1.like(YxStoreProduct::getStoreName, productQueryParam.getKeyword()); + wrapper1.or(); + wrapper1.like(YxStoreProduct::getStoreInfo, productQueryParam.getKeyword()); + wrapper1.or(); + wrapper1.like(YxStoreProduct::getKeyword, productQueryParam.getKeyword()); + }); + } + //新品搜索 + if (StrUtil.isNotBlank(productQueryParam.getNews()) && + !ShopConstants.YSHOP_ZERO.equals(productQueryParam.getNews())) { + wrapper.eq(YxStoreProduct::getIsNew, ShopCommonEnum.IS_NEW_1.getValue()); + } + + //销量排序 + if (SortEnum.DESC.getValue().equals(productQueryParam.getSalesOrder())) { + wrapper.orderByDesc(YxStoreProduct::getSales); + } else if (SortEnum.ASC.getValue().equals(productQueryParam.getSalesOrder())) { + wrapper.orderByAsc(YxStoreProduct::getSales); + } + + //价格排序 + if (SortEnum.DESC.getValue().equals(productQueryParam.getPriceOrder())) { + wrapper.orderByDesc(YxStoreProduct::getPrice); + } else if (SortEnum.ASC.getValue().equals(productQueryParam.getPriceOrder())) { + wrapper.orderByAsc(YxStoreProduct::getPrice); + } + + //无其他排序条件时,防止因为商品排序导致商品重复 + if (StringUtils.isNullOrEmpty(productQueryParam.getPriceOrder()) && StringUtils.isNullOrEmpty(productQueryParam.getSalesOrder())) { + wrapper.orderByDesc(YxStoreProduct::getId); + wrapper.orderByDesc(YxStoreProduct::getSort); + } + Page pageModel = new Page<>(productQueryParam.getPage(), + productQueryParam.getLimit()); + + IPage pageList = storeProductMapper.selectPage(pageModel, wrapper); + + List list = generator.convert(pageList.getRecords(), YxStoreProductQueryVo.class); + + return list; + } + + /** + * 商品详情 + * + * @param id 商品id + * @param uid 用户id + * @param latitude 纬度 + * @param longitude 经度 + * @return ProductVo + */ + @Override + public ProductVo goodsDetail(Long id, Long uid, String latitude, String longitude) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .eq(YxStoreProduct::getId, id); + YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper); + if (ObjectUtil.isNull(storeProduct)) { + throw new ErrorRequestException("商品不存在或已下架"); + } + + //获取商品sku + Map returnMap = yxStoreProductAttrService.getProductAttrDetail(id); + ProductVo productVo = new ProductVo(); + YxStoreProductQueryVo storeProductQueryVo = generator.convert(storeProduct, YxStoreProductQueryVo.class); + + //设置销量 + storeProductQueryVo.setSales(storeProductQueryVo.getSales() + storeProductQueryVo.getFicti()); + + if (uid.longValue() > 0) { + //设置VIP价格 + double vipPrice = userService.setLevelPrice( + storeProductQueryVo.getPrice().doubleValue(), uid); + storeProductQueryVo.setVipPrice(BigDecimal.valueOf(vipPrice)); + + //收藏 + boolean isCollect = relationService.isProductRelation(id, uid); + storeProductQueryVo.setUserCollect(isCollect); + } + //总条数 + Long totalCount = replyService.productReplyCount(id); + productVo.setReplyCount(totalCount); + + //评价 + YxStoreProductReplyQueryVo storeProductReplyQueryVo = replyService.getReply(id); + productVo.setReply(storeProductReplyQueryVo); + + //好评比例 + String replyPer = replyService.replyPer(id); + productVo.setReplyChance(replyPer); + + //获取运费模板名称 + String storeFreePostage = redisUtils.getY("store_free_postage"); + String tempName = ""; + if (StrUtil.isBlank(storeFreePostage) + || !NumberUtil.isNumber(storeFreePostage) + || Integer.valueOf(storeFreePostage) == 0) { + tempName = "全国包邮"; + } else { + YxShippingTemplates shippingTemplates = shippingTemplatesService.getById(storeProduct.getTempId()); + if (ObjectUtil.isNotNull(shippingTemplates)) { + tempName = shippingTemplates.getName(); + } else { + throw new BadRequestException("请配置运费模板"); + } + + } + productVo.setTempName(tempName); + + //设置商品相关信息 + productVo.setStoreInfo(storeProductQueryVo); + productVo.setProductAttr((List) returnMap.get("productAttr")); + productVo.setProductValue((Map) returnMap.get("productValue")); + + + //门店 + productVo.setSystemStore(systemStoreService.getStoreInfo(latitude, longitude)); + productVo.setMapKey(redisUtils.getY(ShopKeyUtils.getTengXunMapKey())); + if (uid.longValue() > 0) { + //添加足迹 + YxStoreProductRelation foot = relationService.getOne(new LambdaQueryWrapper() + .eq(YxStoreProductRelation::getUid, uid) + .eq(YxStoreProductRelation::getProductId, storeProductQueryVo.getId()) + .eq(YxStoreProductRelation::getType, "foot")); + + if (ObjectUtil.isNotNull(foot)) { + foot.setCreateTime(new Date()); + relationService.saveOrUpdate(foot); + } else { + YxStoreProductRelation storeProductRelation = new YxStoreProductRelation(); + storeProductRelation.setProductId(storeProductQueryVo.getId()); + storeProductRelation.setUid(uid); + storeProductRelation.setCreateTime(new Date()); + storeProductRelation.setType("foot"); + relationService.save(storeProductRelation); + } + } + + return productVo; + } + + /** + * 商品浏览量 + * + * @param productId + */ + @Override + public void incBrowseNum(Long productId) { + storeProductMapper.incBrowseNum(productId); + } + + + /** + * 商品列表 + * + * @param page 页码 + * @param limit 条数 + * @param order ProductEnum + * @return List + */ + @Override + public List getList(int page, int limit, int order) { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .eq(YxStoreProduct::getIsDel,ShopCommonEnum.DELETE_0.getValue()) + .orderByDesc(YxStoreProduct::getSort); + wrapper.eq(YxStoreProduct::getIsIntegral,0); + // order + switch (ProductEnum.toType(order)) { + //精品推荐 + case TYPE_1: + wrapper.eq(YxStoreProduct::getIsBest, + ShopCommonEnum.IS_STATUS_1.getValue()); + break; + //首发新品 + case TYPE_3: + wrapper.eq(YxStoreProduct::getIsNew, + ShopCommonEnum.IS_STATUS_1.getValue()); + break; + // 猜你喜欢 + case TYPE_4: + wrapper.eq(YxStoreProduct::getIsBenefit, + ShopCommonEnum.IS_STATUS_1.getValue()); + break; + // 热门榜单 + case TYPE_2: + wrapper.eq(YxStoreProduct::getIsHot, + ShopCommonEnum.IS_STATUS_1.getValue()); + break; + default: + } + Page pageModel = new Page<>(page, limit); + + IPage pageList = storeProductMapper.selectPage(pageModel, wrapper); + + return generator.convert(pageList.getRecords(), YxStoreProductQueryVo.class); + } + + + //============ 分割线================// + + + @Override + public Map queryAll(YxStoreProductQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxStoreProductDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + public List queryAll(YxStoreProductQueryCriteria criteria) { + List yxStoreProductList = baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProduct.class, criteria)); + yxStoreProductList.forEach(yxStoreProduct -> { + yxStoreProduct.setStoreCategory(yxStoreCategoryService.getById(yxStoreProduct.getCateId())); + }); + return yxStoreProductList; + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreProductDto yxStoreProduct : all) { + Map map = new LinkedHashMap<>(); + map.put("商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)", yxStoreProduct.getMerId()); + map.put("商品图片", yxStoreProduct.getImage()); + map.put("轮播图", yxStoreProduct.getSliderImage()); + map.put("商品名称", yxStoreProduct.getStoreName()); + map.put("商品简介", yxStoreProduct.getStoreInfo()); + map.put("关键字", yxStoreProduct.getKeyword()); + map.put("产品条码(一维码)", yxStoreProduct.getBarCode()); + map.put("分类id", yxStoreProduct.getCateId()); + map.put("商品价格", yxStoreProduct.getPrice()); + map.put("会员价格", yxStoreProduct.getVipPrice()); + map.put("市场价", yxStoreProduct.getOtPrice()); + map.put("邮费", yxStoreProduct.getPostage()); + map.put("单位名", yxStoreProduct.getUnitName()); + map.put("排序", yxStoreProduct.getSort()); + map.put("销量", yxStoreProduct.getSales()); + map.put("库存", yxStoreProduct.getStock()); + map.put("状态(0:未上架,1:上架)", yxStoreProduct.getIsShow()); + map.put("是否热卖", yxStoreProduct.getIsHot()); + map.put("是否优惠", yxStoreProduct.getIsBenefit()); + map.put("是否精品", yxStoreProduct.getIsBest()); + map.put("是否新品", yxStoreProduct.getIsNew()); + map.put("产品描述", yxStoreProduct.getDescription()); + map.put("添加时间", yxStoreProduct.getAddTime()); + map.put("是否包邮", yxStoreProduct.getIsPostage()); + map.put("是否删除", yxStoreProduct.getIsDel()); + map.put("商户是否代理 0不可代理1可代理", yxStoreProduct.getMerUse()); + map.put("获得积分", yxStoreProduct.getGiveIntegral()); + map.put("成本价", yxStoreProduct.getCost()); + map.put("秒杀状态 0 未开启 1已开启", yxStoreProduct.getIsSeckill()); + map.put("砍价状态 0未开启 1开启", yxStoreProduct.getIsBargain()); + map.put("是否优品推荐", yxStoreProduct.getIsGood()); + map.put("虚拟销量", yxStoreProduct.getFicti()); + map.put("浏览量", yxStoreProduct.getBrowse()); + map.put("产品二维码地址(用户小程序海报)", yxStoreProduct.getCodePath()); + map.put("淘宝京东1688类型", yxStoreProduct.getSoureLink()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + + /** + * 商品上架下架 + * + * @param id 商品id + * @param status ShopCommonEnum + */ + @Override + public void onSale(Long id, Integer status) { + if (ShopCommonEnum.SHOW_1.getValue().equals(status)) { + status = ShopCommonEnum.SHOW_0.getValue(); + } else { + status = ShopCommonEnum.SHOW_1.getValue(); + } + storeProductMapper.updateOnsale(status, id); + } + + + /** + * 新增/保存商品 + * + * @param storeProductDto 商品 + */ + @Override + public void insertAndEditYxStoreProduct(StoreProductDto storeProductDto) { + storeProductDto.setDescription(RegexUtil.converProductDescription(storeProductDto.getDescription())); + ProductResultDto resultDTO = this.computedProduct(storeProductDto.getAttrs()); + + //添加商品 + YxStoreProduct yxStoreProduct = new YxStoreProduct(); + BeanUtil.copyProperties(storeProductDto, yxStoreProduct, "sliderImage"); + if (storeProductDto.getSliderImage().isEmpty()) { + throw new YshopException("请上传轮播图"); + } + + yxStoreProduct.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice())); + yxStoreProduct.setOtPrice(BigDecimal.valueOf(resultDTO.getMinOtPrice())); + yxStoreProduct.setCost(BigDecimal.valueOf(resultDTO.getMinCost())); + yxStoreProduct.setIntegral(resultDTO.getMinIntegral()); + yxStoreProduct.setStock(resultDTO.getStock()); + yxStoreProduct.setSliderImage(String.join(",", storeProductDto.getSliderImage())); + + if (storeProductDto.getId() != null) { + //清空商品转发图 + deleteForwardImg(storeProductDto.getId()); + } + + this.saveOrUpdate(yxStoreProduct); + + //属性处理 + //处理单sKu + if (SpecTypeEnum.TYPE_0.getValue().equals(storeProductDto.getSpecType())) { + FromatDetailDto fromatDetailDto = FromatDetailDto.builder() + .value("规格") + .detailValue("") + .attrHidden("") + .detail(ListUtil.toList("默认")) + .build(); + List attrs = storeProductDto.getAttrs(); + ProductFormatDto productFormatDto = attrs.get(0); + productFormatDto.setValue1("规格"); + Map map = new HashMap<>(); + map.put("规格", "默认"); + productFormatDto.setDetail(map); + yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto), + ListUtil.toList(productFormatDto), yxStoreProduct.getId()); + } else { + yxStoreProductAttrService.insertYxStoreProductAttr(storeProductDto.getItems(), + storeProductDto.getAttrs(), yxStoreProduct.getId()); + } + + + } + + + /** + * 获取生成的属性 + * + * @param id 商品id + * @param jsonStr jsonStr + * @return map + */ + @Override + public Map getFormatAttr(Long id, String jsonStr, boolean isActivity) { + JSONObject jsonObject = JSON.parseObject(jsonStr); + Map resultMap = new LinkedHashMap<>(3); + + if (jsonObject == null || jsonObject.get("attrs") == null || jsonObject.getJSONArray("attrs").isEmpty()) { + resultMap.put("attr", new ArrayList<>()); + resultMap.put("value", new ArrayList<>()); + resultMap.put("header", new ArrayList<>()); + return resultMap; + } + + + List fromatDetailDTOList = JSON.parseArray(jsonObject.get("attrs").toString(), + FromatDetailDto.class); + + //fromatDetailDTOList + DetailDto detailDto = this.attrFormat(fromatDetailDTOList); + + List> headerMapList = null; + List> valueMapList = new ArrayList<>(); + String align = "center"; + Map headerMap = new LinkedHashMap<>(); + for (Map> map : detailDto.getRes()) { + Map detail = map.get("detail"); + String[] detailArr = detail.values().toArray(new String[]{}); + Arrays.sort(detailArr); + + String sku = String.join(",", detailArr); + + Map valueMap = new LinkedHashMap<>(); + + List detailKeys = + detail.entrySet() + .stream() + .map(Map.Entry::getKey) + .collect(Collectors.toList()); + + int i = 0; + headerMapList = new ArrayList<>(); + for (String title : detailKeys) { + headerMap.put("title", title); + headerMap.put("minWidth", "130"); + headerMap.put("align", align); + headerMap.put("key", "value" + (i + 1)); + headerMap.put("slot", "value" + (i + 1)); + headerMapList.add(ObjectUtil.clone(headerMap)); + i++; + } + + String[] detailValues = detail.values().toArray(new String[]{}); + for (int j = 0; j < detailValues.length; j++) { + String key = "value" + (j + 1); + valueMap.put(key, detailValues[j]); + } +// /** 拼团属性对应的金额 */ +// private BigDecimal pinkPrice; +// +// /** 秒杀属性对应的金额 */ +// private BigDecimal seckillPrice; +// /** 拼团库存属性对应的库存 */ +// private Integer pinkStock; +// +// private Integer seckillStock; + valueMap.put("detail", detail); + valueMap.put("sku", ""); + valueMap.put("pic", ""); + valueMap.put("price", 0); + valueMap.put("cost", 0); + valueMap.put("ot_price", 0); + valueMap.put("stock", 0); + valueMap.put("bar_code", ""); + valueMap.put("weight", 0); + valueMap.put("volume", 0); + valueMap.put("brokerage", 0); + valueMap.put("brokerage_two", 0); + valueMap.put("pink_price", 0); + valueMap.put("seckill_price", 0); + valueMap.put("pink_stock", 0); + valueMap.put("seckill_stock", 0); + valueMap.put("integral", 0); + if (id > 0) { + YxStoreProductAttrValue storeProductAttrValue = yxStoreProductAttrValueService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreProductAttrValue::getProductId, id) + .eq(YxStoreProductAttrValue::getSku, sku)); + if (storeProductAttrValue != null) { + valueMap.put("sku",storeProductAttrValue.getSku()); + valueMap.put("pic", storeProductAttrValue.getImage()); + valueMap.put("price", storeProductAttrValue.getPrice()); + valueMap.put("cost", storeProductAttrValue.getCost()); + valueMap.put("ot_price", storeProductAttrValue.getOtPrice()); + valueMap.put("stock", storeProductAttrValue.getStock()); + valueMap.put("bar_code", storeProductAttrValue.getBarCode()); + valueMap.put("weight", storeProductAttrValue.getWeight()); + valueMap.put("volume", storeProductAttrValue.getVolume()); + valueMap.put("brokerage", storeProductAttrValue.getBrokerage()); + valueMap.put("brokerage_two", storeProductAttrValue.getBrokerageTwo()); + valueMap.put("pink_price", storeProductAttrValue.getPinkPrice()); + valueMap.put("seckill_price", storeProductAttrValue.getSeckillPrice()); + valueMap.put("pink_stock", storeProductAttrValue.getPinkStock()); + valueMap.put("seckill_stock", storeProductAttrValue.getSeckillStock()); + valueMap.put("integral", storeProductAttrValue.getIntegral()); + } + } + + valueMapList.add(ObjectUtil.clone(valueMap)); + + } + + this.addMap(headerMap, headerMapList, align, isActivity); + + + resultMap.put("attr", fromatDetailDTOList); + resultMap.put("value", valueMapList); + resultMap.put("header", headerMapList); + + return resultMap; + } + + + /** + * 计算产品数据 + * + * @param attrs attrs + * @return ProductResultDto + */ + private ProductResultDto computedProduct(List attrs) { + //取最小价格 + Double minPrice = attrs + .stream() + .map(ProductFormatDto::getPrice) + .min(Comparator.naturalOrder()) + .orElse(0d); + + //取最小积分 + Integer minIntegral = attrs + .stream() + .map(ProductFormatDto::getIntegral) + .min(Comparator.naturalOrder()) + .orElse(0); + + Double minOtPrice = attrs + .stream() + .map(ProductFormatDto::getOtPrice) + .min(Comparator.naturalOrder()) + .orElse(0d); + + Double minCost = attrs + .stream() + .map(ProductFormatDto::getCost) + .min(Comparator.naturalOrder()) + .orElse(0d); + //计算库存 + Integer stock = 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) + .minIntegral(minIntegral) + .build(); + } + + /** + * mapTobean + * + * @param listMap listMap + * @return list + */ + private List ListMapToListBean(List> listMap) { + List list = new ArrayList<>(); + // 循环遍历出map对象 + for (Map m : listMap) { + list.add(BeanUtil.mapToBean(m, ProductFormatDto.class, true)); + } + return list; + } + + /** + * 增加表头 + * + * @param headerMap headerMap + * @param headerMapList headerMapList + * @param align align + */ + private void addMap(Map headerMap, List> headerMapList, String align, boolean isActivity) { + headerMap.put("title", "图片"); + headerMap.put("slot", "pic"); + headerMap.put("align", align); + headerMap.put("minWidth", 80); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "售价"); + headerMap.put("slot", "price"); + headerMap.put("align", align); + headerMap.put("minWidth", 120); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "成本价"); + headerMap.put("slot", "cost"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "原价"); + headerMap.put("slot", "ot_price"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "库存"); + headerMap.put("slot", "stock"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "产品编号"); + headerMap.put("slot", "bar_code"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "重量(KG)"); + headerMap.put("slot", "weight"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "体积(m³)"); + headerMap.put("slot", "volume"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "所需兑换积分"); + headerMap.put("slot", "integral"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + if (isActivity) { + headerMap.put("title", "拼团价"); + headerMap.put("slot", "pink_price"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "拼团活动库存"); + headerMap.put("slot", "pink_stock"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "秒杀价"); + headerMap.put("slot", "seckill_price"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + + headerMap.put("title", "秒杀活动库存"); + headerMap.put("slot", "seckill_stock"); + headerMap.put("align", align); + headerMap.put("minWidth", 140); + headerMapList.add(ObjectUtil.clone(headerMap)); + } + + headerMap.put("title", "操作"); + headerMap.put("slot", "action"); + headerMap.put("align", align); + headerMap.put("minWidth", 70); + headerMapList.add(ObjectUtil.clone(headerMap)); + } + + /** + * 组合规则属性算法 + * + * @param fromatDetailDTOList + * @return DetailDto + */ + private DetailDto attrFormat(List fromatDetailDTOList) { + + List data = new ArrayList<>(); + List>> res = new ArrayList<>(); + + fromatDetailDTOList.stream() + .map(FromatDetailDto::getDetail) + .forEach(i -> { + if (i == null || i.isEmpty()) { + throw new YshopException("请至少添加一个规格值哦"); + } + String str = ArrayUtil.join(i.toArray(), ","); + if (str.contains("-")) { + throw new YshopException("规格值里包含'-',请重新添加"); + } + }); + + if (fromatDetailDTOList.size() > 1) { + for (int i = 0; i < fromatDetailDTOList.size() - 1; i++) { + if (i == 0) { + data = fromatDetailDTOList.get(i).getDetail(); + } + List tmp = new LinkedList<>(); + for (String v : data) { + for (String g : fromatDetailDTOList.get(i + 1).getDetail()) { + String rep2 = ""; + if (i == 0) { + rep2 = fromatDetailDTOList.get(i).getValue() + "_" + v + "-" + + fromatDetailDTOList.get(i + 1).getValue() + "_" + g; + } else { + rep2 = v + "-" + + fromatDetailDTOList.get(i + 1).getValue() + "_" + g; + } + + tmp.add(rep2); + + if (i == fromatDetailDTOList.size() - 2) { + Map> rep4 = new LinkedHashMap<>(); + Map reptemp = new LinkedHashMap<>(); + for (String h : Arrays.asList(rep2.split("-"))) { + List rep3 = Arrays.asList(h.split("_")); + if (rep3.size() > 1) { + reptemp.put(rep3.get(0), rep3.get(1)); + } else { + reptemp.put(rep3.get(0), ""); + } + } + rep4.put("detail", reptemp); + + res.add(rep4); + } + } + + } + + if (!tmp.isEmpty()) { + data = tmp; + } + } + } else { + List dataArr = new ArrayList<>(); + for (FromatDetailDto fromatDetailDTO : fromatDetailDTOList) { + for (String str : fromatDetailDTO.getDetail()) { + Map> map2 = new LinkedHashMap<>(); + dataArr.add(fromatDetailDTO.getValue() + "_" + str); + Map map1 = new LinkedHashMap<>(); + map1.put(fromatDetailDTO.getValue(), str); + map2.put("detail", map1); + res.add(map2); + } + } + String s = StrUtil.join("-", dataArr); + data.add(s); + } + + DetailDto detailDto = new DetailDto(); + detailDto.setData(data); + detailDto.setRes(res); + + return detailDto; + } + + @Override + public void deleteForwardImg(Long id) { + baseMapper.deleteForwardImg(id, "_product_detail_wap"); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrMapper.java new file mode 100644 index 00000000..645840ce --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProductAttr; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreProductAttrMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrResultMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrResultMapper.java new file mode 100644 index 00000000..6dadc945 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrResultMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProductAttrResult; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreProductAttrResultMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrValueMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrValueMapper.java new file mode 100644 index 00000000..fef1a0bd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductAttrValueMapper.java @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreProductAttrValueMapper extends CoreMapper { + + + /** + * 正常商品 加库存 减销量 + * @param num + * @param productId + * @param unique + * @return + */ + @Update("update yx_store_product_attr_value set stock=stock+#{num}, sales=sales-#{num}" + + " where product_id=#{productId} and `unique`=#{unique}") + int incStockDecSales(@Param("num") Integer num,@Param("productId") Long productId, + @Param("unique") String unique); + + + /** + * 拼团商品 加库存 减销量 + * @param num + * @param productId + * @param unique + * @return + */ + + @Update("update yx_store_product_attr_value set stock=stock+#{num}, pink_stock=pink_stock+#{num}, sales=sales-#{num}" + + " where product_id=#{productId} and `unique`=#{unique}") + int incCombinationStockDecSales(@Param("num") Integer num,@Param("productId") Long productId, + @Param("unique") String unique); + + + /** + * 秒杀 加库存 减销量 + * @param num + * @param productId + * @param unique + * @return + */ + @Update("update yx_store_product_attr_value set stock=stock+#{num},seckill_stock=seckill_stock+#{num}, sales=sales-#{num}" + + " where product_id=#{productId} and `unique`=#{unique}") + int incSeckillStockDecSales(@Param("num") Integer num,@Param("productId") Long productId, + @Param("unique") String unique); + + + /** + * 普通商品 减库存 加销量 + * @param num + * @param productId + * @param unique + * @return + */ + @Update("update yx_store_product_attr_value set stock=stock-#{num}, sales=sales+#{num}" + + " where product_id=#{productId} and `unique`=#{unique} and stock >= #{num}") + int decStockIncSales(@Param("num") Integer num, @Param("productId") Long productId, + @Param("unique") String unique); + + /** + * 拼团产品 减库存 加销量 + * @param num + * @param productId + * @param unique + * @return + */ + @Update("update yx_store_product_attr_value set stock=stock-#{num}, pink_stock=pink_stock-#{num} ,sales=sales+#{num}" + + " where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and pink_stock>=#{num}") + int decCombinationStockIncSales(@Param("num") Integer num, @Param("productId") Long productId, + @Param("unique") String unique); + + /** + * 秒杀产品 减库存 加销量 + * @param num + * @param productId + * @param unique + * @return + */ + @Update("update yx_store_product_attr_value set stock=stock-#{num}, seckill_stock=seckill_stock-#{num},sales=sales+#{num}" + + " where product_id=#{productId} and `unique`=#{unique} and stock >= #{num} and seckill_stock>=#{num}") + int decSeckillStockIncSales(@Param("num") Integer num, @Param("productId") Long productId, + @Param("unique") String unique); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java new file mode 100644 index 00000000..d9027dd0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductMapper.java @@ -0,0 +1,111 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProduct; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreProductMapper extends CoreMapper { + + /** + * 正常商品库存 减库存 加销量 + * @param num + * @param productId + * @return + */ + @Update("update yx_store_product set stock=stock-#{num}, sales=sales+#{num}" + + " where id=#{productId} and stock >= #{num}") + int decStockIncSales(@Param("num") Integer num,@Param("productId") Long productId); + + /** + * 正常商品库存 加库存 减销量 + * @param num + * @param productId + * @return + */ + @Update("update yx_store_product set stock=stock+#{num}, sales=sales-#{num}" + + " where id=#{productId}") + int incStockDecSales(@Param("num") Integer num,@Param("productId") Long productId); + + + @Update("update yx_store_product set is_show = #{status} where id = #{id}") + void updateOnsale(@Param("status") Integer status, @Param("id") Long id); + + /** + * 拼团商品库存,减库存 加销量 + * @param num + * @param productId + * @param activityId + * @return + */ + @Update("update yx_store_combination set stock=stock-#{num}, sales=sales+#{num}" + + " where id=#{activityId} and stock >= #{num}") + int decCombinationStockIncSales(@Param("num") Integer num, @Param("productId") Long productId,@Param("activityId") Long activityId); + + /** + * 秒杀产品库存 减库存,加销量 + * @param num + * @param productId + * @param activityId + * @return + */ + @Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" + + " where id=#{activityId} and stock >= #{num}") + int decSeckillStockIncSales(@Param("num") Integer num, @Param("productId") Long productId,@Param("activityId") Long activityId); + + /** + * 拼团商品库存,加库存 减销量 + * @param num + * @param productId + * @param activityId + */ + @Update("update yx_store_combination set stock=stock+#{num}, sales=sales-#{num}" + + " where id=#{activityId} and stock >= #{num}") + void incCombinationStockIncSales(@Param("num") Integer num, @Param("productId") Long productId,@Param("activityId") Long activityId); + + /** + * 秒杀产品库存 加库存,减销量 + * @param num + * @param productId + * @param activityId + * @return + */ + @Update("update yx_store_seckill set stock=stock+#{num}, sales=sales-#{num}" + + " where id=#{activityId} and stock >= #{num}") + void incSeckillStockIncSales(@Param("num") Integer num, @Param("productId") Long productId,@Param("activityId") Long activityId); + + /** + * 商品浏览量 + * @param productId + * @return + */ + @Update("update yx_store_product set browse=browse+1 " + + "where id=#{productId}") + int incBrowseNum(@Param("productId") Long productId); + + @Delete("DELETE from yx_system_attachment where name like CONCAT(#{id},'_%',#{name}, '%')") + void deleteForwardImg(@Param("id") Long id,@Param("name") String name); + + @Override + @Select("SELECT id,spec_type,ot_price,mer_use,description,is_postage,is_sub,is_best,(sales+ficti) as sales,price,is_bargain,vip_price,store_name,stock,keyword,image,cost,is_good,unit_name,is_benefit,update_time,give_integral,is_new,sort,slider_image,is_show,bar_code,postage,code_path,create_time,cate_id,is_seckill,mer_id,temp_id,ficti,store_info,is_del,is_hot,is_integral,integral,browse FROM yx_store_product ${ew.customSqlSegment}") + > E selectPage(E page, @Param(Constants.WRAPPER) Wrapper queryWrapper); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductReplyMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductReplyMapper.java new file mode 100644 index 00000000..6bf0a38d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/StoreProductReplyMapper.java @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProductReply; +import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface StoreProductReplyMapper extends CoreMapper { + + @Select("select A.product_score as productScore,A.service_score as serviceScore," + + "A.comment,A.merchant_reply_content as merchantReplyContent," + + "A.merchant_reply_time as merchantReplyTime,A.pics as pictures,A.create_Time as createTime," + + "B.nickname,B.avatar,C.cart_info as cartInfo" + + " from yx_store_product_reply A left join yx_user B " + + "on A.uid = B.uid left join yx_store_order_cart_info C on A.`unique` = C.`unique`" + + " where A.product_id=#{productId} and A.is_del=0 " + + "order by A.create_Time DESC limit 1") + YxStoreProductReplyQueryVo getReply(long productId); + + @Select("") + List selectReplyList(Page page, @Param("productId") long productId, @Param("type") int type); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java new file mode 100644 index 00000000..69f079dc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.product.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProductRelation; +import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + *

+ * 商品点赞和收藏表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-10-23 + */ +@Repository +public interface YxStoreProductRelationMapper extends CoreMapper { + + @Select("select B.id pid,A.type as category,B.store_name as storeName,B.price,B.is_integral as isIntegral,A.id id," + + "B.ot_price as otPrice,B.sales,B.image,B.is_show as isShow" + + " from yx_store_product_relation A left join yx_store_product B " + + "on A.product_id = B.id where A.type=#{type} and A.uid=#{uid} and A.is_del = 0 and B.is_del = 0 order by A.create_time desc") + List selectRelationList(Page page, @Param("uid") Long uid, @Param("type") String type); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRuleMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRuleMapper.java new file mode 100644 index 00000000..07048d83 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRuleMapper.java @@ -0,0 +1,23 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.product.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.domain.YxStoreProductRule; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-06-28 +*/ +@Repository +public interface YxStoreProductRuleMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java new file mode 100644 index 00000000..49a0f1ac --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ProductVo.java @@ -0,0 +1,62 @@ +package co.yixiang.modules.product.vo; + +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + *

+ * 商品dto + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +public class ProductVo{ + + @ApiModelProperty(value = "商品信息列表") + private List goodList = new ArrayList(); + + @ApiModelProperty(value = "商户ID,预留字段") + private Integer merId = 0; + + private String priceName = ""; + + private List productAttr = new ArrayList(); + + private Map productValue = new LinkedHashMap<>(); + + @ApiModelProperty(value = "评论信息") + private YxStoreProductReplyQueryVo reply; + + @ApiModelProperty(value = "回复渠道") + private String replyChance; + + @ApiModelProperty(value = "回复数") + private Long replyCount = 0L; + + //todo + private List similarity = new ArrayList(); + + @ApiModelProperty(value = "商品信息") + private YxStoreProductQueryVo storeInfo; + + @ApiModelProperty(value = "腾讯地图key") + private String mapKey; + + @ApiModelProperty(value = "门店信息") + private YxSystemStoreQueryVo systemStore; + + @ApiModelProperty(value = "用户ID") + private Integer uid = 0; + + @ApiModelProperty(value = "模版名称") + private String tempName; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ReplyCountVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ReplyCountVo.java new file mode 100644 index 00000000..7e0866de --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/ReplyCountVo.java @@ -0,0 +1,42 @@ +package co.yixiang.modules.product.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.io.Serializable; + +/** + * @ClassName ReplyCount + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/4 + **/ +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ReplyCountVo implements Serializable { + + @ApiModelProperty(value = "总的评论数") + private Long sumCount; + + @ApiModelProperty(value = "好评数") + private Long goodCount; + + @ApiModelProperty(value = "中评数") + private Long inCount; + + @ApiModelProperty(value = "差评数") + private Long poorCount; + + @ApiModelProperty(value = "好评率") + private String replyChance; + + @ApiModelProperty(value = "好评星星数") + private String replySstar; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductAttrQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductAttrQueryVo.java new file mode 100644 index 00000000..b585476c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductAttrQueryVo.java @@ -0,0 +1,41 @@ +package co.yixiang.modules.product.vo; + +import co.yixiang.modules.product.service.dto.AttrValueDto; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 商品属性表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@ApiModel(value = "YxStoreProductAttrQueryVo对象", description = "商品属性表查询参数") +public class YxStoreProductAttrQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "属性名") + private String attrName; + + @ApiModelProperty(value = "属性值") + private String attrValues; + + @ApiModelProperty(value = "属性值集合") + private List attrValue; + + @ApiModelProperty(value = "属性") + private List attrValueArr; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java new file mode 100644 index 00000000..387cf761 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductQueryVo.java @@ -0,0 +1,160 @@ +package co.yixiang.modules.product.vo; + + + +import cn.hutool.core.util.StrUtil; +import co.yixiang.modules.product.domain.YxStoreProductAttrValue; +import co.yixiang.serializer.BigDecimalSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + *

+ * 商品表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-19 + */ +@Data +@ApiModel(value = "YxStoreProductQueryVo对象", description = "商品表查询参数") +public class YxStoreProductQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "商品id") + private Long id; + + @ApiModelProperty(value = "商户Id(0为总后台管理员创建,不为0的时候是商户后台创建)") + private Integer merId; + + @ApiModelProperty(value = "商品图片") + private String image; + + private String image_base; + + private String codeBase; + + public String getImage_base() { + return image; + } + + @ApiModelProperty(value = "是否收藏") + private Boolean userCollect = false; + + @ApiModelProperty(value = "是否喜欢") + private Boolean userLike = false; + + @ApiModelProperty(value = "轮播图,多个用,分割") + private String sliderImage; + + private List sliderImageArr; + + public List getSliderImageArr() { + //Arrays.asList(sliderImage.split(",")); + if(StrUtil.isNotEmpty(sliderImage)){ + return Arrays.asList(sliderImage.split(",")); + } + return new ArrayList<>(); + } + + private YxStoreProductAttrValue attrInfo; + + @ApiModelProperty(value = "商品名称") + private String storeName; + + @ApiModelProperty(value = "商品简介") + private String storeInfo; + + @ApiModelProperty(value = "关键字") + private String keyword; + + @ApiModelProperty(value = "分类id") + private String cateId; + + @ApiModelProperty(value = "商品价格") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal price; + + @ApiModelProperty(value = "会员价格") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal vipPrice; + + @ApiModelProperty(value = "市场价") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal otPrice; + + @ApiModelProperty(value = "邮费") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal postage; + + @ApiModelProperty(value = "单位名") + private String unitName; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "销量") + private Integer sales; + + @ApiModelProperty(value = "库存") + private Integer stock; + + @ApiModelProperty(value = "产品描述") + private String description; + + @ApiModelProperty(value = "是否包邮") + private Integer isPostage; + + @ApiModelProperty(value = "成本价") + @JsonSerialize(using = BigDecimalSerializer.class) + private BigDecimal cost; + + @ApiModelProperty(value = "秒杀状态 0 未开启 1已开启") + private Integer isSeckill; + + @ApiModelProperty(value = "砍价状态 0未开启 1开启") + private Integer isBargain; + + @ApiModelProperty(value = "是否优品推荐") + private Integer isGood; + + @ApiModelProperty(value = "虚拟销量") + private Integer ficti; + + @ApiModelProperty(value = "浏览量") + private Integer browse; + + @ApiModelProperty(value = "状态(0:未上架,1:上架)") + private Integer isShow; + + @ApiModelProperty(value = "获得积分") + private BigDecimal giveIntegral; + + @ApiModelProperty(value = "运费模板ID") + private Integer tempId; + + /** 是否单独分佣 */ + @ApiModelProperty(value = "是否单独分佣") + private Integer isSub; + + /** 规格 0单 1多 */ + @ApiModelProperty(value = "规格 0单 1多 ") + private Integer specType; + + /** 是否开启积分兑换*/ + @ApiModelProperty(value = "是否开启积分兑换") + private Integer isIntegral; + + /** 需要多少积分*/ + @ApiModelProperty(value = "需要多少积分") + private Integer integral; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductRelationQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductRelationQueryVo.java new file mode 100644 index 00000000..97991425 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductRelationQueryVo.java @@ -0,0 +1,68 @@ +package co.yixiang.modules.product.vo; + +import co.yixiang.serializer.DoubleSerializer; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 商品点赞和收藏表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@ApiModel(value = "YxStoreProductRelationQueryVo对象", description = "商品点赞和收藏表查询参数") +public class YxStoreProductRelationQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + + @ApiModelProperty(value = "用户ID") + private Long uid; + + @ApiModelProperty(value = "商品ID") + private Long productId; + + @ApiModelProperty(value = "类型(收藏(collect)、点赞(like))") + private String type; + + @ApiModelProperty(value = "某种类型的商品(普通商品、秒杀商品)") + private String category; + + @ApiModelProperty(value = "添加时间") + private Date createTime; + + @ApiModelProperty(value = "产品图片") + private String image; + + @ApiModelProperty(value = "是否显示") + private Integer isShow; + + @ApiModelProperty(value = "原价") + @JsonSerialize(using = DoubleSerializer.class) + private Double otPrice; + + @ApiModelProperty(value = "父ID") + private Integer pid; + + @ApiModelProperty(value = "产品价格") + @JsonSerialize(using = DoubleSerializer.class) + private Double price; + + @ApiModelProperty(value = "产品销量") + private Integer sales; + + @ApiModelProperty(value = "商品名称") + private String storeName; + + @ApiModelProperty(value = "是否开启积分兑换") + private Integer isIntegral; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductReplyQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductReplyQueryVo.java new file mode 100644 index 00000000..8036ea9b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxStoreProductReplyQueryVo.java @@ -0,0 +1,86 @@ +package co.yixiang.modules.product.vo; + +import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 评论表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-23 + */ +@Data +@ApiModel(value = "YxStoreProductReplyQueryVo对象", description = "评论表查询参数") +public class YxStoreProductReplyQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "评论ID") + private Long id; + + @ApiModelProperty(value = "产品id") + private Long productId; + + @ApiModelProperty(value = "某种商品类型(普通商品、秒杀商品)") + private String replyType; + + @ApiModelProperty(value = "商品分数") + private Integer productScore; + + @ApiModelProperty(value = "服务分数") + private Integer serviceScore; + + @ApiModelProperty(value = "评论内容") + private String comment; + + @ApiModelProperty(value = "评论图片") + private String[] pics; + + private String pictures; + + private String[] picturesArr; + + public String[] getPicturesArr() { + if(StrUtil.isNotEmpty(pictures)){ + return pictures.split(","); + }else{ + return new String[]{}; + } + + } + + + @ApiModelProperty(value = "管理员回复内容") + private String merchantReplyContent; + + @ApiModelProperty(value = "管理员回复时间") + private Date merchantReplyTime; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + @ApiModelProperty(value = "评价星星数") + private String star; + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "用户头像") + private String avatar; + + @ApiModelProperty(value = "商品sku") + private String sku; + + @JsonIgnore + private String cartInfo; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxSystemStoreQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxSystemStoreQueryVo.java new file mode 100644 index 00000000..75230c2c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/vo/YxSystemStoreQueryVo.java @@ -0,0 +1,64 @@ +package co.yixiang.modules.product.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 门店自提 查询结果对象 + *

+ * + * @author hupeng + * @date 2020-03-04 + */ +@Data +@ApiModel(value = "YxSystemStoreQueryVo对象", description = "门店自提查询参数") +public class YxSystemStoreQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "门店ID") + private Integer id; + + @ApiModelProperty(value = "门店名称") + private String name; + + @ApiModelProperty(value = "简介") + private String introduction; + + @ApiModelProperty(value = "手机号码") + private String phone; + + @ApiModelProperty(value = "省市区") + private String address; + + @ApiModelProperty(value = "详细地址") + private String detailedAddress; + + @ApiModelProperty(value = "门店logo") + private String image; + + @ApiModelProperty(value = "纬度") + private String latitude; + + @ApiModelProperty(value = "经度") + private String longitude; + + @ApiModelProperty(value = "核销有效日期") + private String validTime; + + private String latlng; + + public String getLatlng(){ + return latitude+","+longitude; + } + + @ApiModelProperty(value = "每日营业开关时间") + private String dayTime; + + @ApiModelProperty(value = "距离") + private String distance; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java new file mode 100644 index 00000000..b5c87fcc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java @@ -0,0 +1,113 @@ +package co.yixiang.modules.sales; + +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.mp.service.WeixinPayService; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.param.SalesCheckDto; +import co.yixiang.modules.sales.param.YxStoreAfterSalesDto; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.sales.param.YxStoreAfterSalesQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.Map; + +/** + * @author : gzlv 2021/6/29 3:48 + */ +@Api(tags = "商城:售后管理") +@RestController +@RequestMapping("/api/yxStoreAfterSales") +@Slf4j +@SuppressWarnings("unchecked") +@AllArgsConstructor +public class StoreAfterSalesController { + + private final StoreAfterSalesService storeAfterSalesService; + private final WeixinPayService weixinPayService; + private final IGenerator generator; + + /** + * 审核 + */ + @Log("审核") + @ApiOperation("审核") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:edit')") + @PostMapping(value = "/salesCheck") + public ResponseEntity salesCheck(@RequestBody SalesCheckDto salesCheckDto) { + return new ResponseEntity<>(storeAfterSalesService.salesCheck(salesCheckDto.getSalesId(), salesCheckDto.getOrderCode(), salesCheckDto.getApprovalStatus(), salesCheckDto.getConsignee(), salesCheckDto.getPhoneNumber(), salesCheckDto.getAddress()), HttpStatus.OK); + } + + /** + * 打款 + */ + @Log("打款") + @ApiOperation("打款") + @PostMapping(value = "/makeMoney") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:edit')") + public ResponseEntity makeMoney(@RequestParam(value = "salesId") Long salesId, @RequestParam("orderCode") String orderCode) { + StoreAfterSales sales = storeAfterSalesService.makeMoney(salesId, orderCode); + BigDecimal bigDecimal = new BigDecimal("100"); + int payPrice = bigDecimal.multiply(sales.getRefundAmount()).intValue(); + weixinPayService.refundOrder(orderCode, payPrice); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:list')") + public void download(HttpServletResponse response, YxStoreAfterSalesQueryCriteria criteria) throws IOException { + storeAfterSalesService.download(generator.convert(storeAfterSalesService.queryAll(criteria), YxStoreAfterSalesDto.class), response); + } + + @GetMapping(value = "/sales/List") + @Log("查询售后") + @ApiOperation("查询售后") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:list')") + public ResponseEntity> getYxStoreAfterSaless(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(storeAfterSalesService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增售后") + @ApiOperation("新增售后") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:add')") + public ResponseEntity create(@Validated @RequestBody StoreAfterSales resources){ + return new ResponseEntity<>(storeAfterSalesService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改售后") + @ApiOperation("修改售后") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:edit')") + public ResponseEntity update(@Validated @RequestBody StoreAfterSales resources){ + storeAfterSalesService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除售后") + @ApiOperation("删除售后") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreAfterSales:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(storeAfterSalesService::removeById); + return new ResponseEntity<>(HttpStatus.OK); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java new file mode 100644 index 00000000..d1cf43cf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java @@ -0,0 +1,79 @@ +package co.yixiang.modules.sales.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * @author : gzlv 2021/6/27 15:42 + */ +@Data +@TableName("yx_store_after_sales") +public class StoreAfterSales { + + /** id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 订单号 */ + private String orderCode; + + /** 退款金额 */ + private BigDecimal refundAmount; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; + + /** 申请原因 */ + private String reasons; + + /** 说明 */ + private String explains; + + /** 说明图片->多个用逗号分割 */ + private String explainImg; + + @ApiModelProperty(value = "快递公司编码") + private String shipperCode; + + /** 物流单号 */ + private String deliverySn; + + /** 物流名称 */ + private String deliveryName; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3已完成 */ + private Integer state; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + /** 添加时间 */ + private Timestamp createTime; + + /** 逻辑删除 */ + private Integer isDel; + + /** 用户id */ + private Long userId; + + /** + * 收货人 + */ + private String consignee; + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 地址 + */ + private String address; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java new file mode 100644 index 00000000..1102f24f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java @@ -0,0 +1,30 @@ +package co.yixiang.modules.sales.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * @author : gzlv 2021/6/27 15:49 + */ +@Data +@TableName("yx_store_after_sales_item") +public class StoreAfterSalesItem { + + /** 主键id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 售后id */ + private Long storeAfterSalesId; + + /** 商品id */ + private Long productId; + + /** 退货东西的详情信息 */ + private String cartInfo; + + /** 逻辑删除 */ + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java new file mode 100644 index 00000000..74418cf6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java @@ -0,0 +1,35 @@ +package co.yixiang.modules.sales.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.sql.Timestamp; + +/** + * @author : gzlv 2021/6/27 15:51 + */ +@Data +@TableName("yx_store_after_sales_status") +public class StoreAfterSalesStatus { + + /** Id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 售后id */ + private Long storeAfterSalesId; + + /** 操作类型 0售后订单生成 1后台审核成功 2用户发货 3打款 4审核失败 5用户撤销*/ + private Integer changeType; + + /** 操作备注 */ + private String changeMessage; + + /** 操作时间 */ + private Timestamp changeTime; + + /** 操作人 */ + private String operator; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java new file mode 100644 index 00000000..f267fde3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java @@ -0,0 +1,16 @@ +package co.yixiang.modules.sales.param; + +import lombok.Data; + +/** + * @author : gzlv 2021/6/27 17:18 + */ +@Data +public class ProsuctParam { + + /** + * 商品id + */ + private Long productId; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java new file mode 100644 index 00000000..973d8fcb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java @@ -0,0 +1,40 @@ +package co.yixiang.modules.sales.param; + +import lombok.Data; + +/** + * @author : gzlv 2021/6/29 5:25 + */ +@Data +public class SalesCheckDto { + + /** + * 售后id + */ + private Long salesId; + + /** + * 订单编号 + */ + private String orderCode; + + /** + * 审核状态0成功1失败 + */ + private Integer approvalStatus; + + /** + * 收货人 + */ + private String consignee; + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 地址 + */ + private String address; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java new file mode 100644 index 00000000..6a046a65 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java @@ -0,0 +1,48 @@ +package co.yixiang.modules.sales.param; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * @author : gzlv 2021/6/27 16:36 + */ +@Data +public class StoreAfterSalesParam { + + /** + * 订单号 + */ + @NotBlank + private String orderCode; + + /** + * 服务类型 0仅退款1退货退款 + */ + @NotBlank + private Integer serviceType; + + /** + * 申请原因 + */ + @NotBlank + private String reasonForApplication; + + /** + * 申请说明 + */ + private String applicationInstructions; + + /** + * 申请说明图片 + */ + private String applicationDescriptionPicture; + + /** + * 商品数据 + */ + @NotBlank + private List productParamList; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java new file mode 100644 index 00000000..cf633668 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java @@ -0,0 +1,75 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.sales.param; + +import lombok.Data; +import java.util.Date; +import java.math.BigDecimal; +import java.io.Serializable; + +/** +* @author gzlv +* @date 2021-06-30 +*/ +@Data +public class YxStoreAfterSalesDto implements Serializable { + + private Long id; + + /** 订单号 */ + private String orderCode; + + /** 退款金额 */ + private BigDecimal refundAmount; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; + + /** 申请原因 */ + private String reasons; + + /** 说明 */ + private String explains; + + /** 说明图片->多个用逗号分割 */ + private String explainImg; + + /** 物流公司编码 */ + private String shipperCode; + + /** 物流单号 */ + private String deliverySn; + + /** 物流名称 */ + private String deliveryName; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功 */ + private Integer state; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + /** 添加时间 */ + private Date createTime; + + /** 逻辑删除 */ + private Integer isDel; + + /** 用户id */ + private Long userId; + + /** 商家收货人 */ + private String consignee; + + /** 商家手机号 */ + private String phoneNumber; + + /** 商家地址 */ + private String address; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java new file mode 100644 index 00000000..7635f33e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java @@ -0,0 +1,41 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.sales.param; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.Date; +import java.util.List; +import co.yixiang.annotation.Query; + +/** +* @author gzlv +* @date 2021-06-30 +*/ +@Data +public class YxStoreAfterSalesQueryCriteria{ + + /** + * 订单号 + */ + private String orderCode; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + private List time; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3已完成 */ + private Integer state; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java new file mode 100644 index 00000000..bd567799 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; + +/** + * @author : gzlv 2021/6/27 15:55 + */ +public interface StoreAfterSalesItemService extends BaseService { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java new file mode 100644 index 00000000..1276ca84 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java @@ -0,0 +1,138 @@ +package co.yixiang.modules.sales.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.param.StoreAfterSalesParam; +import co.yixiang.modules.sales.param.YxStoreAfterSalesDto; +import co.yixiang.modules.sales.param.YxStoreAfterSalesQueryCriteria; +import co.yixiang.modules.sales.service.vo.StoreAfterSalesVo; +import co.yixiang.modules.sales.service.vo.YxStoreOrderCartInfoVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author : gzlv 2021/6/27 15:54 + */ +public interface StoreAfterSalesService extends BaseService { + + /** + * 创建售后订单 + * + * @param userId 用户id + * @param nickname 用户昵称 + * @param storeAfterSalesParam / + */ + void applyForAfterSales(Long userId, String nickname, StoreAfterSalesParam storeAfterSalesParam); + + /** + * 查询订单详情 + * @param key 订单号 + * @return + */ + List checkOrderDetails(String key); + + /** + * 查询列表 + * @param uid 用户id + * @param status 状态 + * @param page 页 + * @param orderCode + * @param limit 数量 + * @return + */ + Map salesList(Long uid, Integer status, Integer page, String orderCode, Integer limit); + + /** + * 查询详情 + * @param key 订单号 + * @param id 售后单id + * @param uid 用户id + */ + StoreAfterSalesVo getStoreInfoByOrderCodeAndAfterIdAndUid(String key, Long id, Long uid); + + /** + * 查询详情 + * @param key 订单号 + * @param uid 用户id + */ + List getStoreInfoByOrderCodeAndUid(String key, Long uid); + + /** + * + * @param storeInfo + * @return + */ + StoreAfterSalesVo handleSales(StoreAfterSalesVo storeInfo); + + /** + * 撤销申请 + * @param key 订单号 + * @param uid 用户id + * @param aLong + * @return Boolean + */ + Boolean revoke(String key, Long uid, Long aLong); + + /** + * 添加快递信息 + * @param code 物流公司编码 + * @param name 物流公司名称 + * @param postalCode + * @param orderCode + * @return + */ + Boolean addLogisticsInformation(String code, String name, String postalCode ,String orderCode); + + /** + * 删除售后订单 + * @param orderCode / + * @param id + * @return / + */ + Boolean deleteAfterSalesOrder(String orderCode, Long id); + + /** + * 售后订单审核 + * @param salesId 售后id + * @param orderCode 订单id + * @param approvalStatus 审核状态 + * @param consignee 收货人 + * @param phoneNumber 收货人电话 + * @param address 地址 + * @return / + */ + Object salesCheck(Long salesId, String orderCode, Integer approvalStatus, String consignee, String phoneNumber, String address); + + /** + * 打款 + */ + StoreAfterSales makeMoney(Long salesId, String orderCode); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreAfterSalesQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java new file mode 100644 index 00000000..3232e20a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; + +/** + * @author : gzlv 2021/6/27 15:55 + */ +public interface StoreAfterSalesStatusService extends BaseService { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java new file mode 100644 index 00000000..049759c3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.sales.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; +import co.yixiang.modules.sales.service.StoreAfterSalesItemService; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesItemMapper; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author : gzlv 2021/6/27 15:55 + */ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreAfterSalesItemServiceImpl extends BaseServiceImpl implements StoreAfterSalesItemService { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java new file mode 100644 index 00000000..89549a68 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java @@ -0,0 +1,435 @@ +package co.yixiang.modules.sales.service.impl; + +import cn.hutool.core.util.NumberUtil; +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.AfterSalesStatusEnum; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.service.mapper.StoreOrderCartInfoMapper; +import co.yixiang.modules.order.service.mapper.StoreOrderMapper; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; +import co.yixiang.modules.sales.param.ProsuctParam; +import co.yixiang.modules.sales.param.StoreAfterSalesParam; +import co.yixiang.modules.sales.param.YxStoreAfterSalesDto; +import co.yixiang.modules.sales.param.YxStoreAfterSalesQueryCriteria; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesItemMapper; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesMapper; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesStatusMapper; +import co.yixiang.modules.sales.service.vo.StoreAfterSalesVo; +import co.yixiang.modules.sales.service.vo.YxStoreOrderCartInfoVo; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.AllArgsConstructor; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author : gzlv 2021/6/27 15:56 + */ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreAfterSalesServiceImpl extends BaseServiceImpl implements StoreAfterSalesService { + + private final StoreOrderMapper storeOrderMapper; + private final StoreOrderCartInfoMapper storeOrderCartInfoMapper; + private final StoreAfterSalesItemMapper storeAfterSalesItemMapper; + private final StoreAfterSalesStatusMapper storeAfterSalesStatusMapper; + private final IGenerator generator; + + @Override + public void applyForAfterSales(Long userId, String nickname, StoreAfterSalesParam storeAfterSalesParam) { + + YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(YxStoreOrder::getOrderId, storeAfterSalesParam.getOrderCode()).eq(YxStoreOrder::getUid, userId)); + checkOrder(yxStoreOrder); + //商品除去优惠后的总价格 + BigDecimal totalPrice = BigDecimal.ZERO; + //拿到所有的商品 + List yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.lambdaQuery().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); + for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) { + YxStoreCartQueryVo cartInfo = JSONObject.parseObject(yxStoreOrderCartInfo.getCartInfo(), YxStoreCartQueryVo.class); + ProsuctParam prosuctParam = storeAfterSalesParam.getProductParamList().stream().filter(item -> item.getProductId().equals(yxStoreOrderCartInfo.getProductId())).findFirst().orElse(new ProsuctParam()); + if (prosuctParam.getProductId() != null) { + //商品优惠前总金额 + BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum()); + //商品优惠总金额 + BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice()); + //商品优惠后总金额 + totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount)); + + yxStoreOrderCartInfo.setIsAfterSales(0); + storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo); + + } + } + //更新订单状态 + yxStoreOrder.setStatus(OrderInfoEnum.STATUS_NE1.getValue()); + yxStoreOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_1.getValue()); + yxStoreOrder.setRefundReasonWap(storeAfterSalesParam.getReasonForApplication()); + yxStoreOrder.setRefundReasonWapExplain(storeAfterSalesParam.getApplicationInstructions()); + yxStoreOrder.setRefundReasonTime(new Date()); + storeOrderMapper.updateById(yxStoreOrder); + //生成售后订单 + StoreAfterSales storeAfterSales = new StoreAfterSales(); + storeAfterSales.setOrderCode(storeAfterSalesParam.getOrderCode()); + storeAfterSales.setRefundAmount(totalPrice); + storeAfterSales.setServiceType(storeAfterSalesParam.getServiceType()); + storeAfterSales.setReasons(storeAfterSalesParam.getReasonForApplication()); + storeAfterSales.setExplains(storeAfterSalesParam.getApplicationInstructions()); + storeAfterSales.setExplainImg(storeAfterSalesParam.getApplicationDescriptionPicture()); + storeAfterSales.setState(AfterSalesStatusEnum.STATUS_0.getValue()); + storeAfterSales.setSalesState(0); + storeAfterSales.setCreateTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSales.setIsDel(0); + storeAfterSales.setUserId(userId); + baseMapper.insert(storeAfterSales); + //售后商品详情 + for (ProsuctParam prosuctParam : storeAfterSalesParam.getProductParamList()) { + YxStoreOrderCartInfo yxStoreOrderCartInfo = yxStoreOrderCartInfos.stream().filter(item -> item.getProductId().equals(prosuctParam.getProductId())).findFirst().orElse(new YxStoreOrderCartInfo()); + StoreAfterSalesItem storeAfterSalesItem = new StoreAfterSalesItem(); + storeAfterSalesItem.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesItem.setProductId(yxStoreOrderCartInfo.getProductId()); + storeAfterSalesItem.setCartInfo(yxStoreOrderCartInfo.getCartInfo()); + storeAfterSalesItem.setIsDel(0); + storeAfterSalesItemMapper.insert(storeAfterSalesItem); + } + + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(0); + storeAfterSalesStatus.setChangeMessage("售后订单生成"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator(nickname); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + } + + @Override + public List checkOrderDetails(String key) { + List yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.lambdaQuery().eq(YxStoreOrderCartInfo::getOid, key)); + YxStoreOrder yxStoreOrder = storeOrderMapper.selectById(key); + //查询 售后信息 + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, yxStoreOrder.getOrderId())); + List yxStoreOrderCartInfoVos = new ArrayList<>(); + for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) { + + YxStoreOrderCartInfoVo yxStoreOrderCartInfoVo = new YxStoreOrderCartInfoVo(); + yxStoreOrderCartInfoVo.setId(yxStoreOrderCartInfo.getId()); + yxStoreOrderCartInfoVo.setOid(yxStoreOrderCartInfo.getOid()); + yxStoreOrderCartInfoVo.setCartId(yxStoreOrderCartInfo.getCartId()); + yxStoreOrderCartInfoVo.setProductId(yxStoreOrderCartInfo.getProductId()); + YxStoreCartQueryVo cartInfo = JSONObject.parseObject(yxStoreOrderCartInfo.getCartInfo(), YxStoreCartQueryVo.class); + yxStoreOrderCartInfoVo.setCartInfo(cartInfo); + yxStoreOrderCartInfoVo.setUnique(yxStoreOrderCartInfo.getUnique()); + yxStoreOrderCartInfoVo.setIsAfterSales(yxStoreOrderCartInfo.getIsAfterSales() == null ? 0 : yxStoreOrderCartInfo.getIsAfterSales()); + + //商品优惠前总金额 + BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum()); + //商品优惠总金额 + BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice()); + + yxStoreOrderCartInfoVo.setRefundablePrice(NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount)); + + yxStoreOrderCartInfoVo.setReasons(storeAfterSales.getReasons()); + yxStoreOrderCartInfoVos.add(yxStoreOrderCartInfoVo); + } + + return yxStoreOrderCartInfoVos; + + } + + @Override + public Map salesList(Long uid, Integer status, Integer page, String orderCode, Integer limit) { + Page storeAfterSalesPage = new Page<>(page, limit); + List integers = new ArrayList<>(); + if (status == 1) { + integers.add(0); + integers.add(1); + integers.add(2); + } + if (status == 2) { + integers.add(3); + } + baseMapper.selectPage(storeAfterSalesPage, Wrappers.lambdaQuery() + .eq(uid != null, StoreAfterSales::getUserId, uid).in(status.equals(AfterSalesStatusEnum.STATUS_1.getValue()), StoreAfterSales::getState, integers) + .in(!status.equals(AfterSalesStatusEnum.STATUS_0.getValue()), StoreAfterSales::getState, integers) + .eq(StringUtils.isNotBlank(orderCode), StoreAfterSales::getOrderCode, orderCode) + .orderByDesc(StoreAfterSales::getCreateTime) + .eq(StoreAfterSales::getIsDel, ShopCommonEnum.DELETE_0.getValue())); + List storeAfterSalesVos = generator.convert(storeAfterSalesPage.getRecords(), StoreAfterSalesVo.class); + Map map = new HashMap<>(); + if (uid == null) { + map.put("content", storeAfterSalesVos.stream().map(this::handleSales).collect(Collectors.toList())); + map.put("totalElements", storeAfterSalesPage.getTotal()); + } else { + map.put("list", storeAfterSalesVos.stream().map(this::handleSales).collect(Collectors.toList())); + map.put("total", storeAfterSalesPage.getTotal()); + map.put("totalPage", storeAfterSalesPage.getPages()); + } + return map; + } + + @Override + public StoreAfterSalesVo getStoreInfoByOrderCodeAndAfterIdAndUid(String key, Long id, Long uid) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(id != null, StoreAfterSales::getId, id).eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getOrderCode, key)); + StoreAfterSalesVo salesVo = generator.convert(storeAfterSales, StoreAfterSalesVo.class); +// salesVo.setCloseAfterSaleTime(DateUtil.tomorrow().toTimestamp()); + return salesVo; + } + + @Override + public List getStoreInfoByOrderCodeAndUid(String key, Long uid) { + List storeAfterSales = baseMapper.selectList(Wrappers.lambdaQuery().eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getOrderCode, key)); + return generator.convert(storeAfterSales, StoreAfterSalesVo.class); + } + + /** + * 处理售后订单返回的状态 + * + * @param storeAfterSalesVo / + * @return StoreAfterSalesVo / + */ + @Override + public StoreAfterSalesVo handleSales(StoreAfterSalesVo storeAfterSalesVo) { + List storeAfterSalesItems = storeAfterSalesItemMapper.selectList(Wrappers.lambdaQuery().eq(StoreAfterSalesItem::getStoreAfterSalesId, storeAfterSalesVo.getId())); + List cartInfo = storeAfterSalesItems.stream() + .map(cart -> JSON.parseObject(cart.getCartInfo(), YxStoreCartQueryVo.class)) + .collect(Collectors.toList()); + storeAfterSalesVo.setCartInfo(cartInfo); + List storeAfterSalesStatuses = storeAfterSalesStatusMapper.selectList(Wrappers.lambdaQuery().eq(StoreAfterSalesStatus::getStoreAfterSalesId, storeAfterSalesVo.getId())); + + storeAfterSalesVo.setCompleteTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 3).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setDeliveryTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 2).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setAuditFailedTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 4).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setReviewTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 1).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setRevocationTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 5).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + return storeAfterSalesVo; + } + + @Override + public Boolean revoke(String key, Long uid, Long id) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getId, id).eq(StoreAfterSales::getOrderCode, key)); + if (storeAfterSales == null) { + throw new YshopException("未查询到售后订单信息"); + } + if (storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_2.getValue()) || storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_3.getValue())) { + throw new YshopException("订单不能撤销"); + } + storeAfterSales.setSalesState(1); + + YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(YxStoreOrder::getOrderId, key)); + yxStoreOrder.setStatus(OrderInfoEnum.STATUS_0.getValue()); + yxStoreOrder.setRefundStatus(OrderInfoEnum.STATUS_0.getValue()); + storeOrderMapper.updateById(yxStoreOrder); + + List yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.lambdaQuery().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); + for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) { + yxStoreOrderCartInfo.setIsAfterSales(1); + storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo); + } + + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(5); + storeAfterSalesStatus.setChangeMessage("售后订单生成"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("用户操作"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + return baseMapper.updateById(storeAfterSales) > 0; + } + + @Override + public Boolean addLogisticsInformation(String code, String name, String postalCode, String orderCode) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, orderCode)); + if (!storeAfterSales.getState().equals(AfterSalesStatusEnum.STATUS_1.getValue())) { + throw new YshopException("当前状态不能添加物流信息!"); + } + storeAfterSales.setShipperCode(code); + storeAfterSales.setDeliverySn(postalCode); + storeAfterSales.setDeliveryName(name); + storeAfterSales.setState(AfterSalesStatusEnum.STATUS_2.getValue()); + + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(2); + storeAfterSalesStatus.setChangeMessage("售后订单生成"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("用户操作"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + return baseMapper.updateById(storeAfterSales) > 0; + } + + @Override + public Boolean deleteAfterSalesOrder(String orderCode, Long id) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getId, id).eq(StoreAfterSales::getOrderCode, orderCode)); + return baseMapper.deleteById(storeAfterSales.getId()) > 0; + } + + @Override + public Object salesCheck(Long salesId, String orderCode, Integer approvalStatus, String consignee, String phoneNumber, String address) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, orderCode).eq(StoreAfterSales::getId, salesId)); + if (approvalStatus == 0) { + storeAfterSales.setState(AfterSalesStatusEnum.STATUS_1.getValue()); + if (storeAfterSales.getServiceType() == 1) { + if (StringUtils.isEmpty(consignee) || StringUtils.isEmpty(phoneNumber) || StringUtils.isEmpty(address)) { + throw new ErrorRequestException("请输入收货人信息"); + } + storeAfterSales.setConsignee(consignee); + storeAfterSales.setPhoneNumber(phoneNumber); + storeAfterSales.setAddress(address); + } + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(1); + storeAfterSalesStatus.setChangeMessage("平台审核成功"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("admin"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + } else { + storeAfterSales.setState(AfterSalesStatusEnum.STATUS_1.getValue()); + storeAfterSales.setSalesState(2); + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(4); + storeAfterSalesStatus.setChangeMessage("平台审核失败"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("admin"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + this.makeMoney(storeAfterSales.getId(),storeAfterSales.getOrderCode()); + } + return baseMapper.updateById(storeAfterSales) > 0; + } + + @Override + public StoreAfterSales makeMoney(Long salesId, String orderCode) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, orderCode).eq(StoreAfterSales::getId, salesId)); + storeAfterSales.setState(AfterSalesStatusEnum.STATUS_3.getValue()); + baseMapper.updateById(storeAfterSales); + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(3); + storeAfterSalesStatus.setChangeMessage("平台打款成功"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("admin"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(YxStoreOrder::getOrderId, storeAfterSales.getOrderCode())); + yxStoreOrder.setStatus(-2); + storeOrderMapper.updateById(yxStoreOrder); + return storeAfterSales; + } + + /** + * 检查订单是否符合售后订单 + * + * @param yxStoreOrder 订单 + */ + private void checkOrder(YxStoreOrder yxStoreOrder) { + if (yxStoreOrder == null) { + throw new YshopException("未查询到订单信息"); + } + + if (!yxStoreOrder.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue()) + || !yxStoreOrder.getRefundStatus().equals(OrderInfoEnum.REFUND_STATUS_0.getValue()) + || yxStoreOrder.getStatus() < OrderInfoEnum.STATUS_0.getValue()) { + throw new YshopException("订单状态不能售后"); + } + } + + @Override + //@Cacheable + public Map queryAll(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable) { + Page storeAfterSalesPage = new Page<>(pageable.getPageNumber(), pageable.getPageSize()); + + LambdaQueryWrapper eq = Wrappers.lambdaQuery() + .in(ObjectUtils.isNotEmpty(criteria.getState()), StoreAfterSales::getState, criteria.getState()) + .eq(StringUtils.isNotBlank(criteria.getOrderCode()), StoreAfterSales::getOrderCode, criteria.getOrderCode()) + .eq(ObjectUtils.isNotEmpty(criteria.getSalesState()), StoreAfterSales::getSalesState, criteria.getSalesState()) + .eq(ObjectUtils.isNotEmpty(criteria.getServiceType()), StoreAfterSales::getServiceType, criteria.getServiceType()) + .orderByDesc(StoreAfterSales::getCreateTime) + .eq(StoreAfterSales::getIsDel, ShopCommonEnum.DELETE_0.getValue()); + if (CollectionUtils.isNotEmpty(criteria.getTime())) { + eq.ge(StoreAfterSales::getCreateTime, criteria.getTime().get(0)) + .le(StoreAfterSales::getCreateTime, criteria.getTime().get(1)); + } + + baseMapper.selectPage(storeAfterSalesPage, eq); + List storeAfterSalesVos = generator.convert(storeAfterSalesPage.getRecords(), StoreAfterSalesVo.class); + Map map = new HashMap<>(); + map.put("content", storeAfterSalesVos.stream().map(this::handleSales).collect(Collectors.toList())); + map.put("totalElements", storeAfterSalesPage.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreAfterSalesQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(StoreAfterSales.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreAfterSalesDto yxStoreAfterSales : all) { + Map map = new LinkedHashMap<>(); + map.put("订单号", yxStoreAfterSales.getOrderCode()); + map.put("退款金额", yxStoreAfterSales.getRefundAmount()); + map.put("服务类型0仅退款1退货退款", yxStoreAfterSales.getServiceType()); + map.put("申请原因", yxStoreAfterSales.getReasons()); + map.put("说明", yxStoreAfterSales.getExplains()); + map.put("说明图片->多个用逗号分割", yxStoreAfterSales.getExplainImg()); + map.put("物流公司编码", yxStoreAfterSales.getShipperCode()); + map.put("物流单号", yxStoreAfterSales.getDeliverySn()); + map.put("物流名称", yxStoreAfterSales.getDeliveryName()); + map.put("状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功", yxStoreAfterSales.getState()); + map.put("售后状态-0正常1用户取消2商家拒绝", yxStoreAfterSales.getSalesState()); + map.put("添加时间", yxStoreAfterSales.getCreateTime()); + map.put("逻辑删除", yxStoreAfterSales.getIsDel()); + map.put("用户id", yxStoreAfterSales.getUserId()); + map.put("商家收货人", yxStoreAfterSales.getConsignee()); + map.put("商家手机号", yxStoreAfterSales.getPhoneNumber()); + map.put("商家地址", yxStoreAfterSales.getAddress()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java new file mode 100644 index 00000000..a66a5cb2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.sales.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; +import co.yixiang.modules.sales.service.StoreAfterSalesStatusService; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesStatusMapper; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author : gzlv 2021/6/27 15:56 + */ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreAfterSalesStatusServiceImpl extends BaseServiceImpl implements StoreAfterSalesStatusService { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java new file mode 100644 index 00000000..a21ebd20 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; + +/** + * @author : gzlv 2021/6/27 15:53 + */ +public interface StoreAfterSalesItemMapper extends CoreMapper { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java new file mode 100644 index 00000000..51fd30e7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.sales.domain.StoreAfterSales; + +/** + * @author : gzlv 2021/6/27 15:53 + */ +public interface StoreAfterSalesMapper extends CoreMapper { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java new file mode 100644 index 00000000..a7ce7d43 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; + +/** + * @author : gzlv 2021/6/27 15:52 + */ +public interface StoreAfterSalesStatusMapper extends CoreMapper { +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java new file mode 100644 index 00000000..dfe8a654 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java @@ -0,0 +1,127 @@ +package co.yixiang.modules.sales.service.vo; + +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.List; + +/** + * @author : gzlv 2021/6/28 0:43 + */ +@Data +public class StoreAfterSalesVo { + + /** id */ + @TableId(value = "uid", type = IdType.AUTO) + private Long id; + + /** 订单号 */ + private String orderCode; + + /** 退款金额 */ + private BigDecimal refundAmount; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; + + /** 申请原因 */ + private String reasons; + + /** 说明 */ + private String explains; + + /** 说明图片->多个用逗号分割 */ + private String explainImg; + + /** 物流单号 */ + private String deliverySn; + + /** 物流名称 */ + private String deliveryName; + + @ApiModelProperty(value = "快递公司编码") + private String shipperCode; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功 */ + private Integer state; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp createTime; + + /** 逻辑删除 */ + private Integer isDel; + + /** 用户id */ + private Long userId; + + private List cartInfo; + + /** + * 收货人 + */ + private String consignee; + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 地址 + */ + private String address; + + + /** + * 审核时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp reviewTime; + + /** + * 发货时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp deliveryTime; + + /** + * 完成时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp completeTime; + + /** + * 审核失败时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp auditFailedTime; + + /** + * 撤销时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp revocationTime; + + /** + * 关闭售后时间 + */ + private Timestamp closeAfterSaleTime; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java new file mode 100644 index 00000000..ba5c5c1c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java @@ -0,0 +1,49 @@ +package co.yixiang.modules.sales.service.vo; + +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author : gzlv 2021/6/27 22:40 + */ +@Data +public class YxStoreOrderCartInfoVo { + + @TableId + private Long id; + + + /** 订单id */ + private Long oid; + + + /** 购物车id */ + private Long cartId; + + + /** 商品ID */ + private Long productId; + + + /** 购买东西的详细信息 */ + private YxStoreCartQueryVo cartInfo; + + + /** 唯一id */ + @TableField(value = "`unique`") + private String unique; + + /** 是否能售后0不能1能 */ + private Integer isAfterSales; + + /** 可退價格 */ + private BigDecimal refundablePrice; + + /** 申请原因 */ + private String reasons; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/services/WechatArticleService.java b/zsw-bxg/src/main/java/co/yixiang/modules/services/WechatArticleService.java new file mode 100644 index 00000000..bda6f5a0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/services/WechatArticleService.java @@ -0,0 +1,146 @@ +package co.yixiang.modules.services; + +import cn.hutool.core.util.ReUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONUtil; +import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.mp.service.dto.YxArticleDto; +import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.modules.mp.utils.URLUtils; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.api.WxConsts; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.WxMpMassTagMessage; +import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; +import me.chanjar.weixin.mp.bean.material.WxMpMaterial; +import me.chanjar.weixin.mp.bean.material.WxMpMaterialNews; +import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; +import me.chanjar.weixin.mp.bean.material.WxMpNewsArticle; +import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.util.List; + +/** + * @ClassName WechatArticleService + * @Author hupeng <610796224@qq.com> + * @Date 2020/7/2 + **/ +@Service +@Slf4j +public class WechatArticleService { + + /** + * 发布微信图文 + * @param wxNewsArticleItem YxArticleDto + * @throws WxErrorException + */ + public void publish(YxArticleDto wxNewsArticleItem) throws WxErrorException { + WxMpService wxMpService = WxMpConfiguration.getWxMpService(); + + WxMpMaterialNews wxMpMaterialNews = new WxMpMaterialNews(); + + + WxMpNewsArticle article = new WxMpNewsArticle(); + + WxMpMaterialUploadResult wxMpMaterialUploadResult = uploadPhotoToWx( wxMpService, + wxNewsArticleItem.getImageInput() ); + wxNewsArticleItem.setThumbMediaId( wxMpMaterialUploadResult.getMediaId() ); + + article.setAuthor( wxNewsArticleItem.getAuthor() ); + + + //处理content + String content = processContent(wxMpService, wxNewsArticleItem.getContent()); + System.out.println(content); + article.setContent( content ); + article.setContentSourceUrl( wxNewsArticleItem.getUrl() ); + article.setDigest( wxNewsArticleItem.getSynopsis() ); + article.setShowCoverPic( true ); + article.setThumbMediaId( wxNewsArticleItem.getThumbMediaId() ); + article.setTitle( wxNewsArticleItem.getTitle() ); + //TODO 暂时注释掉,测试号没有留言权限 + //article.setNeedOpenComment( wxNewsArticleItem ); + //article.setOnlyFansCanComment( wxNewsArticleItem ); + wxMpMaterialNews.addArticle( article ); + + log.info( "wxMpMaterialNews : {}", JSONUtil.toJsonStr( wxMpMaterialNews ) ); + + WxMpMaterialUploadResult wxMpMaterialUploadResult1 = wxMpService.getMaterialService() + .materialNewsUpload( wxMpMaterialNews ); + + //推送开始 + WxMpMassTagMessage massMessage = new WxMpMassTagMessage(); + massMessage.setMsgType(WxConsts.MassMsgType.MPNEWS); + massMessage.setMediaId(wxMpMaterialUploadResult1.getMediaId()); + massMessage.setSendAll(true); + + WxMpMassSendResult massResult = wxMpService.getMassMessageService() + .massGroupMessageSend(massMessage); + if(!"0".equals(massResult.getErrorCode())) { + log.info("error:"+massResult.getErrorMsg()); + throw new ErrorRequestException("发送失败"); + } + + log.info( "massResult : {}", JSONUtil.toJsonStr( massResult ) ); + + log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMpMaterialUploadResult1 ) ); + } + + + /** + * 上传素材 + * @param wxMpService WxMpService + * @param picPath 图片路径 + * @return WxMpMaterialUploadResult + * @throws WxErrorException + */ + private WxMpMaterialUploadResult uploadPhotoToWx(WxMpService wxMpService, String picPath) throws WxErrorException { + WxMpMaterial wxMpMaterial = new WxMpMaterial(); + + String filename = String.valueOf( (int)System.currentTimeMillis() ) + ".png"; + String downloadPath = "" + filename; + long size = HttpUtil.downloadFile(picPath, cn.hutool.core.io.FileUtil.file(downloadPath)); + picPath = downloadPath; + File picFile = new File( picPath ); + wxMpMaterial.setFile( picFile ); + wxMpMaterial.setName( picFile.getName() ); + log.info( "picFile name : {}", picFile.getName() ); + WxMpMaterialUploadResult wxMpMaterialUploadResult = wxMpService.getMaterialService().materialFileUpload( WxConsts.MediaFileType.IMAGE, wxMpMaterial ); + log.info( "wxMpMaterialUploadResult : {}", JSONUtil.toJsonStr( wxMpMaterialUploadResult ) ); + return wxMpMaterialUploadResult; + } + + /** + * 处理内容 + * @param wxMpService WxMpService + * @param content 内容 + * @return String + * @throws WxErrorException + */ + private String processContent(WxMpService wxMpService,String content) throws WxErrorException { + if(StringUtils.isBlank( content )){ + return content; + } + String imgReg = "]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>"; + List imgList = ReUtil.findAllGroup1( imgReg,content); + for (int j = 0; j < imgList.size(); j++) { + String imgSrc = imgList.get( j ); + String filepath = URLUtils.getParam( imgSrc,"filepath" ); + + if(StringUtils.isBlank( filepath )){//网络图片URL,需下载到本地 + String filename = System.currentTimeMillis() + ".png"; + String downloadPath = "" + filename; + long size = HttpUtil.downloadFile(imgSrc, cn.hutool.core.io.FileUtil.file(downloadPath)); + filepath = downloadPath; + } + WxMediaImgUploadResult wxMediaImgUploadResult = wxMpService.getMaterialService().mediaImgUpload( new File(filepath) ); + content = StringUtils.replace( content,imgList.get( j ),wxMediaImgUploadResult.getUrl()); + } + return content; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxAppVersion.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxAppVersion.java new file mode 100644 index 00000000..3f396a6b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxAppVersion.java @@ -0,0 +1,54 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.domain; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.validation.constraints.*; +import java.util.Date; +import co.yixiang.domain.BaseDomain; + +/** +* @author lioncity +* @date 2020-12-09 +*/ +@Data +@TableName("yx_app_version") +public class YxAppVersion extends BaseDomain { + @TableId + private Integer id; + + + + + /** 版本code */ + private String versionCode; + + /** 版本名称 */ + private String versionName; + + /** 版本描述 */ + private String versionInfo; + + /** 安卓下载链接 */ + private String androidUrl; + + /** 是否强制升级 */ + private Integer forceUpdate; + + /** ios store应用商店链接 */ + private String iosUrl; + + + public void copy(YxAppVersion source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxMaterial.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxMaterial.java new file mode 100644 index 00000000..a2bcd1f4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxMaterial.java @@ -0,0 +1,55 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_material") +public class YxMaterial extends BaseDomain { + + /** PK */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + + /** 创建者ID */ + private String createId; + + + /** 类型1、图片;2、视频 */ + private String type; + + + /** 分组ID */ + private String groupId; + + + /** 素材名 */ + private String name; + + + /** 素材链接 */ + private String url; + + + public void copy(YxMaterial source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxMaterialGroup.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxMaterialGroup.java new file mode 100644 index 00000000..6ef7b3fe --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxMaterialGroup.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_material_group") +public class YxMaterialGroup extends BaseDomain { + + /** PK */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + + /** 创建者ID */ + private String createId; + + + /** 分组名 */ + private String name; + + + public void copy(YxMaterialGroup source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemAttachment.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemAttachment.java new file mode 100644 index 00000000..d3b58931 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemAttachment.java @@ -0,0 +1,64 @@ +package co.yixiang.modules.shop.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + *

+ * 附件管理表 + *

+ * + * @author hupeng + * @since 2019-11-11 + */ +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "YxSystemAttachment对象", description = "附件管理表") +public class YxSystemAttachment extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @TableId(value = "att_id", type = IdType.AUTO) + private Long attId; + + @ApiModelProperty(value = "附件名称") + private String name; + + @ApiModelProperty(value = "附件路径") + private String attDir; + + @ApiModelProperty(value = "压缩图片路径") + private String sattDir; + + @ApiModelProperty(value = "附件大小") + private String attSize; + + @ApiModelProperty(value = "附件类型") + private String attType; + + @ApiModelProperty(value = "分类ID0编辑器,1产品图片,2拼团图片,3砍价图片,4秒杀图片,5文章图片,6组合数据图") + private Integer pid; + + @ApiModelProperty(value = "图片上传类型 1本地 2七牛云 3OSS 4COS ") + private Integer imageType; + + @ApiModelProperty(value = "图片上传模块类型 1 后台上传 2 用户生成") + private Integer moduleType; + + private Long uid; + + private String inviteCode; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemConfig.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemConfig.java new file mode 100644 index 00000000..e31a527d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemConfig.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@TableName("yx_system_config") +public class YxSystemConfig implements Serializable { + + /** 配置id */ + @TableId + private Integer id; + + + /** 字段名称 */ + private String menuName; + + + /** 默认值 */ + private String value; + + + /** 排序 */ + private Integer sort; + + + /** 是否隐藏 */ + private Integer status; + + + public void copy(YxSystemConfig source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemGroupData.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemGroupData.java new file mode 100644 index 00000000..8fc3c985 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemGroupData.java @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("yx_system_group_data") +public class YxSystemGroupData extends BaseDomain { + + /** 组合数据详情ID */ + @TableId + private Integer id; + + + /** 对应的数据名称 */ + private String groupName; + + + /** 数据组对应的数据值(json数据) */ + private String value; + + + /** 数据排序 */ + private Integer sort; + + + /** 状态(1:开启;2:关闭;) */ + private Integer status; + + + public void copy(YxSystemGroupData source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemStore.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemStore.java new file mode 100644 index 00000000..bf9b0d4d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemStore.java @@ -0,0 +1,99 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_system_store") +public class YxSystemStore extends BaseDomain { + + @TableId + private Integer id; + + + /** 门店名称 */ + @NotBlank(message = "请填写门店名称") + private String name; + + + /** 简介 */ + @NotBlank(message = "请填写门店简介") + private String introduction; + + + /** 手机号码 */ + @NotBlank(message = "请填手机号码") + private String phone; + + + /** 省市区 */ + @NotBlank(message = "请填地址") + private String address; + + + /** 详细地址 */ + private String detailedAddress; + + + /** 门店logo */ + @NotBlank(message = "请上传门店logo") + private String image; + + + /** 纬度 */ + @NotBlank(message = "请输入纬度") + private String latitude; + + + /** 经度 */ + @NotBlank(message = "请输入经度") + private String longitude; + + + /** 核销有效日期 */ + @NotBlank(message = "请输入核销时效") + private String validTime; + + + /** 每日营业开关时间 */ + @NotBlank(message = "请输入营业时间") + private String dayTime; + + + + /** 是否显示 */ + private Integer isShow; + + + private Date validTimeEnd; + + private Date validTimeStart; + + private Date dayTimeStart; + + private Date dayTimeEnd; + + + public void copy(YxSystemStore source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemStoreStaff.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemStoreStaff.java new file mode 100644 index 00000000..2734fa11 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemStoreStaff.java @@ -0,0 +1,77 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_system_store_staff") +public class YxSystemStoreStaff extends BaseDomain { + + @TableId + private Integer id; + + + /** 微信用户id */ + private Long uid; + + + /** 店员头像 */ + @NotBlank(message = "请选择用户") + private String avatar; + + + /** 门店id */ + @NotNull(message = "请选择门店") + private Integer storeId; + + + /** 店员名称 */ + @NotBlank(message = "请输入店员名称") + private String staffName; + + + /** 手机号码 */ + @NotBlank(message = "请输入手机号码") + private String phone; + + + /** 核销开关 */ + private Integer verifyStatus; + + + /** 状态 */ + private Integer status; + + + + /** 微信昵称 */ + private String nickname; + + + /** 所属门店 */ + private String storeName; + + + public void copy(YxSystemStoreStaff source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemUserLevel.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemUserLevel.java new file mode 100644 index 00000000..de40c249 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/domain/YxSystemUserLevel.java @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_system_user_level") +public class YxSystemUserLevel extends BaseDomain { + + @TableId + private Integer id; + + + /** 商户id */ + private Integer merId; + + + /** 会员名称 */ + @NotBlank(message = "名称必填") + private String name; + + + /** 购买金额 */ + private BigDecimal money; + + + /** 有效时间 */ + private Integer validDate; + + + /** 是否为永久会员 */ + private Integer isForever; + + + /** 是否购买,1=购买,0=不购买 */ + private Integer isPay; + + + /** 是否显示 1=显示,0=隐藏 */ + private Integer isShow; + + + /** 会员等级 */ + @NotNull(message = "请输入会员等级") + private Integer grade; + + + /** 享受折扣 */ + @NotNull(message = "请输入会员折扣") + private BigDecimal discount; + + /** 会员卡背景 */ + @NotBlank(message = "请上传会员背景") + private String image; + + + /** 会员图标 */ + @NotBlank(message = "请上传会员图标") + private String icon; + + + /** 说明 */ + @TableField(value = "`explain`") + private String explain; + + + + public void copy(YxSystemUserLevel source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/ExpressController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/ExpressController.java new file mode 100644 index 00000000..7a48b338 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/ExpressController.java @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.order.domain.YxExpress; +import co.yixiang.modules.order.service.YxExpressService; +import co.yixiang.modules.order.service.dto.YxExpressQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-12-12 +*/ +@Api(tags = "商城:快递管理") +@RestController +@RequestMapping("api") +public class ExpressController { + + + private final YxExpressService yxExpressService; + + public ExpressController(YxExpressService yxExpressService) { + this.yxExpressService = yxExpressService; + } + + @Log("查询快递") + @ApiOperation(value = "查询快递") + @GetMapping(value = "/yxExpress") + @PreAuthorize("hasAnyRole('admin','YXEXPRESS_ALL','YXEXPRESS_SELECT')") + public ResponseEntity getYxExpresss(YxExpressQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxExpressService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @Log("新增快递") + @ApiOperation(value = "新增快递") + @PostMapping(value = "/yxExpress") + @PreAuthorize("hasAnyRole('admin','YXEXPRESS_ALL','YXEXPRESS_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxExpress resources){ + return new ResponseEntity<>(yxExpressService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @Log("修改快递") + @ApiOperation(value = "修改快递") + @PutMapping(value = "/yxExpress") + @PreAuthorize("hasAnyRole('admin','YXEXPRESS_ALL','YXEXPRESS_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxExpress resources){ + yxExpressService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除快递") + @ApiOperation(value = "删除快递") + @DeleteMapping(value = "/yxExpress/{id}") + @PreAuthorize("hasAnyRole('admin','YXEXPRESS_ALL','YXEXPRESS_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxExpressService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/MaterialController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/MaterialController.java new file mode 100644 index 00000000..e0aad9c8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/MaterialController.java @@ -0,0 +1,82 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.rest; + + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxMaterial; +import co.yixiang.modules.shop.service.YxMaterialService; +import co.yixiang.modules.shop.service.dto.YxMaterialQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2020-01-09 +*/ +@Api(tags = "商城:素材管理管理") +@RestController +@RequestMapping("/api/material") +public class MaterialController { + + private final YxMaterialService yxMaterialService; + + public MaterialController(YxMaterialService yxMaterialService) { + this.yxMaterialService = yxMaterialService; + } + + + + @GetMapping(value = "/page") + @Log("查询素材管理") + @ApiOperation("查询素材管理") + public ResponseEntity getYxMaterials(YxMaterialQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxMaterialService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增素材管理") + @ApiOperation("新增素材管理") + public ResponseEntity create(@Validated @RequestBody YxMaterial resources){ + resources.setCreateId("admin"); + return new ResponseEntity<>(yxMaterialService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改素材管理") + @ApiOperation("修改素材管理") + public ResponseEntity update(@Validated @RequestBody YxMaterial resources){ + yxMaterialService.saveOrUpdate(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除素材管理") + @ApiOperation("删除素材管理") + @DeleteMapping(value = "/{id}") + public ResponseEntity deleteAll(@PathVariable String id) { + yxMaterialService.removeById(id); + return new ResponseEntity<>(HttpStatus.OK); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/MaterialGroupController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/MaterialGroupController.java new file mode 100644 index 00000000..239b2b54 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/MaterialGroupController.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxMaterialGroup; +import co.yixiang.modules.shop.service.YxMaterialGroupService; +import co.yixiang.modules.shop.service.dto.YxMaterialGroupQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2020-01-09 +*/ +@Api(tags = "商城:素材分组管理") +@RestController +@RequestMapping("/api/materialgroup") +public class MaterialGroupController { + + private final YxMaterialGroupService yxMaterialGroupService; + + public MaterialGroupController(YxMaterialGroupService yxMaterialGroupService) { + this.yxMaterialGroupService = yxMaterialGroupService; + } + + + + @GetMapping(value = "/page") + @Log("查询素材分组") + @ApiOperation("查询素材分组") + public ResponseEntity getYxMaterialGroups(YxMaterialGroupQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxMaterialGroupService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + @GetMapping(value = "/list") + @Log("查询所有素材分组") + @ApiOperation("查询所有素材分组") + public ResponseEntity getYxMaterialGroupsList(YxMaterialGroupQueryCriteria criteria){ + return new ResponseEntity<>(yxMaterialGroupService.queryAll(criteria),HttpStatus.OK); + } + + + @PostMapping + @Log("新增素材分组") + @ApiOperation("新增素材分组") + public ResponseEntity create(@Validated @RequestBody YxMaterialGroup resources){ + return new ResponseEntity<>(yxMaterialGroupService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @PutMapping + @Log("修改素材分组") + @ApiOperation("修改素材分组") + public ResponseEntity update(@Validated @RequestBody YxMaterialGroup resources){ + yxMaterialGroupService.saveOrUpdate(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除素材分组") + @ApiOperation("删除素材分组") + @DeleteMapping(value = "/{id}") + public ResponseEntity deleteAll(@PathVariable String id) { + yxMaterialGroupService.removeById(id); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemConfigController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemConfigController.java new file mode 100644 index 00000000..ed7c94c7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemConfigController.java @@ -0,0 +1,107 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.rest; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxSystemConfig; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.shop.service.dto.YxSystemConfigQueryCriteria; +import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.modules.mp.config.WxPayConfiguration; +import co.yixiang.modules.mp.config.WxMaConfiguration; + +import co.yixiang.utils.RedisUtils; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-10-10 +*/ +@Api(tags = "商城:配置管理") +@RestController +@RequestMapping("api") +public class SystemConfigController { + + private final YxSystemConfigService yxSystemConfigService; + private final RedisUtils redisUtils; + + public SystemConfigController(YxSystemConfigService yxSystemConfigService, RedisUtils redisUtils) { + this.yxSystemConfigService = yxSystemConfigService; + this.redisUtils = redisUtils; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxSystemConfig") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_SELECT')") + public ResponseEntity getYxSystemConfigs(YxSystemConfigQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxSystemConfigService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @Log("新增或修改") + @ApiOperation(value = "新增或修改") + @PostMapping(value = "/yxSystemConfig") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @PreAuthorize("hasAnyRole('admin','YXSYSTEMCONFIG_ALL','YXSYSTEMCONFIG_CREATE')") + public ResponseEntity create(@RequestBody String jsonStr){ + JSONObject jsonObject = JSON.parseObject(jsonStr); + jsonObject.forEach( + (key,value)->{ + YxSystemConfig yxSystemConfig = yxSystemConfigService.getOne(new LambdaQueryWrapper() + .eq(YxSystemConfig::getMenuName,key)); + YxSystemConfig yxSystemConfigModel = new YxSystemConfig(); + yxSystemConfigModel.setMenuName(key); + yxSystemConfigModel.setValue(value.toString()); + //重新配置微信相关 + if(SystemConfigConstants.WECHAT_APPID.equals(key)){ + WxMpConfiguration.removeWxMpService(); + WxPayConfiguration.removeWxPayService(); + WxMaConfiguration.removeWxMaService(); + } + if(SystemConfigConstants.WXPAY_MCHID.equals(key) || SystemConfigConstants.WXAPP_APPID.equals(key)){ + WxPayConfiguration.removeWxPayService(); + } + if(SystemConfigConstants.EXP_APPID.equals(key)){ + redisUtils.del(ShopConstants.YSHOP_EXPRESS_SERVICE); + } + redisUtils.set(key,value.toString(),0); + if(ObjectUtil.isNull(yxSystemConfig)){ + yxSystemConfigService.save(yxSystemConfigModel); + }else{ + yxSystemConfigModel.setId(yxSystemConfig.getId()); + yxSystemConfigService.saveOrUpdate(yxSystemConfigModel); + } + } + ); + + return new ResponseEntity(HttpStatus.CREATED); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemGroupDataController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemGroupDataController.java new file mode 100644 index 00000000..6a331ae1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemGroupDataController.java @@ -0,0 +1,184 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + */ +package co.yixiang.modules.shop.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.exception.BadRequestException; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxSystemGroupData; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria; +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.cache.annotation.CacheEvict; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static co.yixiang.constant.ShopConstants.YSHOP_SECKILL_TIME; + +/** + * @author hupeng + * @date 2019-10-18 + */ +@Api(tags = "商城:数据配置管理") +@RestController +@RequestMapping("api") +public class SystemGroupDataController { + + private final YxSystemGroupDataService yxSystemGroupDataService; + + public SystemGroupDataController(YxSystemGroupDataService yxSystemGroupDataService) { + this.yxSystemGroupDataService = yxSystemGroupDataService; + } + + @Log("查询数据配置") + @ApiOperation(value = "查询数据配置") + @GetMapping(value = "/yxSystemGroupData") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_SELECT')") + public ResponseEntity getYxSystemGroupDatas(YxSystemGroupDataQueryCriteria criteria, + Pageable pageable) { + Sort sort = Sort.by(Sort.Direction.DESC, "sort"); + Pageable pageableT = PageRequest.of(pageable.getPageNumber(), + pageable.getPageSize(), + sort); + return new ResponseEntity<>(yxSystemGroupDataService.queryAll(criteria, pageableT), HttpStatus.OK); + } + + @ForbidSubmit + @Log("新增数据配置") + @ApiOperation(value = "新增数据配置") + @PostMapping(value = "/yxSystemGroupData") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + @PreAuthorize("hasAnyRole('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_CREATE')") + public ResponseEntity create(@RequestBody String jsonStr) { + JSONObject jsonObject = JSON.parseObject(jsonStr); + this.checkParam(jsonObject); + + YxSystemGroupData yxSystemGroupData = new YxSystemGroupData(); + yxSystemGroupData.setGroupName(jsonObject.get("groupName").toString()); + jsonObject.remove("groupName"); + yxSystemGroupData.setValue(jsonObject.toJSONString()); + yxSystemGroupData.setStatus(jsonObject.getInteger("status")); + yxSystemGroupData.setSort(jsonObject.getInteger("sort")); + + List yxSeckillTime = yxSystemGroupDataService.list(Wrappers.lambdaQuery() + .eq(YxSystemGroupData::getGroupName, YSHOP_SECKILL_TIME)); + if (yxSystemGroupData.getStatus() == 1) { + yxSeckillTime.forEach(item -> { + Map map = JSONUtil.toBean(item.getValue(), Map.class); + if (Objects.nonNull(jsonObject.getInteger("time")) && jsonObject.getInteger("time").equals(map.get("time"))) { + throw new BadRequestException("不能同时开启同一时间点"); + } + }); + } + + return new ResponseEntity<>(yxSystemGroupDataService.save(yxSystemGroupData), HttpStatus.CREATED); + } + + @ForbidSubmit + @Log("修改数据配置") + @ApiOperation(value = "修改数据配置") + @PutMapping(value = "/yxSystemGroupData") + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY, allEntries = true) + @PreAuthorize("hasAnyRole('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_EDIT')") + public ResponseEntity update(@RequestBody String jsonStr) { + JSONObject jsonObject = JSON.parseObject(jsonStr); + this.checkParam(jsonObject); + + YxSystemGroupData yxSystemGroupData = new YxSystemGroupData(); + + yxSystemGroupData.setGroupName(jsonObject.get("groupName").toString()); + jsonObject.remove("groupName"); + yxSystemGroupData.setValue(jsonObject.toJSONString()); + yxSystemGroupData.setStatus(jsonObject.getInteger("status")); + + List yshop_seckill_time = yxSystemGroupDataService.list(Wrappers.lambdaQuery() + .eq(YxSystemGroupData::getGroupName, "yshop_seckill_time")); + if (yxSystemGroupData.getStatus() == 1 && ObjectUtil.isNotEmpty(jsonObject.getInteger("time"))) { + yshop_seckill_time.forEach(item -> { + Map map = JSONUtil.toBean(item.getValue(), Map.class); + if (jsonObject.getInteger("time").equals(map.get("time"))) { + throw new BadRequestException("不能同时开启同一时间点"); + } + }); + } + + if (jsonObject.getInteger("status") == null) { + yxSystemGroupData.setStatus(1); + } else { + yxSystemGroupData.setStatus(jsonObject.getInteger("status")); + } + + if (jsonObject.getInteger("sort") == null) { + yxSystemGroupData.setSort(0); + } else { + yxSystemGroupData.setSort(jsonObject.getInteger("sort")); + } + + + yxSystemGroupData.setId(Integer.valueOf(jsonObject.get("id").toString())); + yxSystemGroupDataService.saveOrUpdate(yxSystemGroupData); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除数据配置") + @ApiOperation(value = "删除数据配置") + @DeleteMapping(value = "/yxSystemGroupData/{id}") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_DELETE')") + public ResponseEntity delete(@PathVariable Integer id) { + yxSystemGroupDataService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } + + /** + * 检测参数 + * + * @param jsonObject + */ + private void checkParam(JSONObject jsonObject) { + if (ObjectUtil.isNotNull(jsonObject.get("name"))) { + if (StrUtil.isEmpty(jsonObject.getString("name"))) { + throw new BadRequestException("名称必须填写"); + } + } + + if (ObjectUtil.isNotNull(jsonObject.get("title"))) { + if (StrUtil.isEmpty(jsonObject.getString("title"))) { + throw new BadRequestException("标题必须填写"); + } + } + + if (ObjectUtil.isNotNull(jsonObject.get("pic"))) { + if (StrUtil.isEmpty(jsonObject.getString("pic"))) { + throw new BadRequestException("图片必须上传"); + } + } + + + if (ObjectUtil.isNotNull(jsonObject.get("info"))) { + if (StrUtil.isEmpty(jsonObject.getString("info"))) { + throw new BadRequestException("简介必须填写"); + } + } + + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java new file mode 100644 index 00000000..c554ff47 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java @@ -0,0 +1,141 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.rest; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.shop.service.dto.YxSystemStoreDto; +import co.yixiang.modules.shop.service.dto.YxSystemStoreQueryCriteria; +import co.yixiang.utils.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import co.yixiang.utils.location.GetTencentLocationVO; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +import static co.yixiang.constant.ShopConstants.QQ_MAP_URL; + +/** +* @author hupeng +* @date 2020-03-03 +*/ +@Api(tags = "门店管理") +@RestController +@RequestMapping("/api/yxSystemStore") +public class SystemStoreController { + + private final YxSystemStoreService yxSystemStoreService; + private final IGenerator generator; + private final RedisUtils redisUtils; + + public SystemStoreController(YxSystemStoreService yxSystemStoreService, IGenerator generator, RedisUtils redisUtils) { + this.yxSystemStoreService = yxSystemStoreService; + this.generator = generator; + this.redisUtils = redisUtils; + } + + + @Log("所有门店") + @ApiOperation("所有门店") + @GetMapping(value = "/all") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:list')") + public ResponseEntity getAll(YxSystemStoreQueryCriteria criteria) { + return new ResponseEntity<>(yxSystemStoreService.queryAll(criteria),HttpStatus.OK); + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:list')") + public void download(HttpServletResponse response, YxSystemStoreQueryCriteria criteria) throws IOException { + yxSystemStoreService.download(generator.convert(yxSystemStoreService.queryAll(criteria), YxSystemStoreDto.class), response); + } + + @GetMapping + @Log("查询门店") + @ApiOperation("查询门店") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:list')") + public ResponseEntity getYxSystemStores(YxSystemStoreQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxSystemStoreService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping(value = "/getL") + @Log("获取经纬度") + @ApiOperation("获取经纬度") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:getl')") + public ResponseEntity create(@Validated @RequestBody String jsonStr) { + JSONObject jsonObject = JSON.parseObject(jsonStr); + String addr = jsonObject.getString("addr"); + + + String key = redisUtils.getY(ShopKeyUtils.getTengXunMapKey()); + if (StrUtil.isBlank(key)) { + throw new BadRequestException("请先配置腾讯地图key"); + } + String url = StrUtil.format("?address={}&key={}", addr, key); + String json = HttpUtil.get(QQ_MAP_URL + url); + GetTencentLocationVO locationVO = JSONObject.parseObject(json, GetTencentLocationVO.class); + + + if(locationVO.getStatus()!=0){ + throw new BadRequestException(locationVO.getMessage()); + } + return new ResponseEntity<>(locationVO, HttpStatus.CREATED); + } + + @ForbidSubmit + @PostMapping + @Log("新增门店") + @ApiOperation("新增门店") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:add')") + public ResponseEntity create(@Validated @RequestBody YxSystemStore resources){ + return new ResponseEntity<>(yxSystemStoreService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @PutMapping + @Log("修改门店") + @ApiOperation("修改门店") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:edit')") + public ResponseEntity update(@Validated @RequestBody YxSystemStore resources){ + yxSystemStoreService.saveOrUpdate(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除门店") + @ApiOperation("删除门店") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStore:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + yxSystemStoreService.removeByIds(new ArrayList<>(Arrays.asList(ids))); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreStaffController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreStaffController.java new file mode 100644 index 00000000..f5a62057 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreStaffController.java @@ -0,0 +1,109 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.domain.YxSystemStoreStaff; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.shop.service.YxSystemStoreStaffService; +import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffDto; +import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +/** +* @author hupeng +* @date 2020-03-22 +*/ +@Api(tags = "门店店员管理") +@RestController +@RequestMapping("/api/yxSystemStoreStaff") +public class SystemStoreStaffController { + + private final YxSystemStoreStaffService yxSystemStoreStaffService; + private final YxSystemStoreService yxSystemStoreService; + + private final IGenerator generator; + + public SystemStoreStaffController(YxSystemStoreService yxSystemStoreService,YxSystemStoreStaffService yxSystemStoreStaffService, IGenerator generator) { + this.yxSystemStoreService = yxSystemStoreService; + this.yxSystemStoreStaffService = yxSystemStoreStaffService; + this.generator = generator; + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStoreStaff:list')") + public void download(HttpServletResponse response, YxSystemStoreStaffQueryCriteria criteria) throws IOException { + yxSystemStoreStaffService.download(generator.convert(yxSystemStoreStaffService.queryAll(criteria), YxSystemStoreStaffDto.class), response); + } + + @GetMapping + @Log("查询门店店员") + @ApiOperation("查询门店店员") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStoreStaff:list')") + public ResponseEntity getYxSystemStoreStaffs(YxSystemStoreStaffQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxSystemStoreStaffService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增门店店员") + @ApiOperation("新增门店店员") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStoreStaff:add')") + public ResponseEntity create(@Validated @RequestBody YxSystemStoreStaff resources){ + YxSystemStore systemStore = yxSystemStoreService.getOne(Wrappers.lambdaQuery() + .eq(YxSystemStore::getId,resources.getStoreId())); + resources.setStoreName(systemStore.getName()); + return new ResponseEntity<>(yxSystemStoreStaffService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改门店店员") + @ApiOperation("修改门店店员") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStoreStaff:edit')") + public ResponseEntity update(@Validated @RequestBody YxSystemStoreStaff resources){ + YxSystemStore systemStore = yxSystemStoreService.getOne(Wrappers.lambdaQuery() + .eq(YxSystemStore::getId,resources.getStoreId())); + resources.setStoreName(systemStore.getName()); + yxSystemStoreStaffService.saveOrUpdate(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除门店店员") + @ApiOperation("删除门店店员") + @PreAuthorize("@ss.hasAnyPermissions('yxSystemStoreStaff:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + yxSystemStoreStaffService.removeByIds(new ArrayList<>(Arrays.asList(ids))); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/YxAppVersionController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/YxAppVersionController.java new file mode 100644 index 00000000..47f6a23d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/YxAppVersionController.java @@ -0,0 +1,93 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.rest; + +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxAppVersion; +import co.yixiang.modules.shop.service.YxAppVersionService; +import co.yixiang.modules.shop.service.dto.YxAppVersionDto; +import co.yixiang.modules.shop.service.dto.YxAppVersionQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; + +/** +* @author lioncity +* @date 2020-12-09 +*/ +@AllArgsConstructor +@Api(tags = "app版本控制管理") +@RestController +@RequestMapping("/api/yxAppVersion") +public class YxAppVersionController { + + private final YxAppVersionService yxAppVersionService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxAppVersion:list')") + public void download(HttpServletResponse response, YxAppVersionQueryCriteria criteria) throws IOException { + yxAppVersionService.download(generator.convert(yxAppVersionService.queryAll(criteria), YxAppVersionDto.class), response); + } + + @GetMapping + @Log("查询app版本控制") + @ApiOperation("查询app版本控制") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxAppVersion:list')") + public ResponseEntity> getYxAppVersions(YxAppVersionQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxAppVersionService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @PostMapping + @Log("新增app版本控制") + @ApiOperation("新增app版本控制") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxAppVersion:add')") + public ResponseEntity create(@Validated @RequestBody YxAppVersion resources){ + return new ResponseEntity<>(yxAppVersionService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @PutMapping + @Log("修改app版本控制") + @ApiOperation("修改app版本控制") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxAppVersion:edit')") + public ResponseEntity update(@Validated @RequestBody YxAppVersion resources){ + yxAppVersionService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除app版本控制") + @ApiOperation("删除app版本控制") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxAppVersion:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + Arrays.asList(ids).forEach(id->{ + yxAppVersionService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/YxStoreProductRelationController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/YxStoreProductRelationController.java new file mode 100644 index 00000000..2d79fcfb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/YxStoreProductRelationController.java @@ -0,0 +1,87 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.rest; +import java.util.Arrays; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.aop.ForbidSubmit; +import lombok.AllArgsConstructor; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.product.domain.YxStoreProductRelation; +import co.yixiang.modules.product.service.YxStoreProductRelationService; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria; +import co.yixiang.modules.product.service.dto.YxStoreProductRelationDto; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** + * @author hupeng + * @date 2020-09-03 + */ +@AllArgsConstructor +@Api(tags = "ProductRelation管理") +@RestController +@RequestMapping("/api/yxStoreProductRelation") +public class YxStoreProductRelationController { + + private final YxStoreProductRelationService yxStoreProductRelationService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRelation:list')") + public void download(HttpServletResponse response, YxStoreProductRelationQueryCriteria criteria) throws IOException { + yxStoreProductRelationService.download(generator.convert(yxStoreProductRelationService.queryAll(criteria), YxStoreProductRelationDto.class), response); + } + + @GetMapping + @Log("查询ProductRelation") + @ApiOperation("查询ProductRelation") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRelation:list')") + public ResponseEntity> getYxStoreProductRelations(YxStoreProductRelationQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxStoreProductRelationService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增ProductRelation") + @ApiOperation("新增ProductRelation") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRelation:add')") + public ResponseEntity create(@Validated @RequestBody YxStoreProductRelation resources){ + return new ResponseEntity<>(yxStoreProductRelationService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改ProductRelation") + @ApiOperation("修改ProductRelation") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRelation:edit')") + public ResponseEntity update(@Validated @RequestBody YxStoreProductRelation resources){ + yxStoreProductRelationService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除ProductRelation") + @ApiOperation("删除ProductRelation") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreProductRelation:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + yxStoreProductRelationService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxAppVersionService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxAppVersionService.java new file mode 100644 index 00000000..db56b6a9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxAppVersionService.java @@ -0,0 +1,48 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.service; +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxAppVersion; +import co.yixiang.modules.shop.service.dto.YxAppVersionDto; +import co.yixiang.modules.shop.service.dto.YxAppVersionQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** +* @author lioncity +* @date 2020-12-09 +*/ +public interface YxAppVersionService extends BaseService{ + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult queryAll(YxAppVersionQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxAppVersionQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxMaterialGroupService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxMaterialGroupService.java new file mode 100644 index 00000000..55c61d86 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxMaterialGroupService.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxMaterialGroup; +import co.yixiang.modules.shop.service.dto.YxMaterialGroupDto; +import co.yixiang.modules.shop.service.dto.YxMaterialGroupQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxMaterialGroupService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxMaterialGroupQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxMaterialGroupQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxMaterialService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxMaterialService.java new file mode 100644 index 00000000..b8470be0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxMaterialService.java @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxMaterial; +import co.yixiang.modules.shop.service.dto.YxMaterialQueryCriteria; +import org.springframework.data.domain.Pageable; + +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxMaterialService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxMaterialQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxMaterialQueryCriteria criteria); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemAttachmentService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemAttachmentService.java new file mode 100644 index 00000000..b710051b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemAttachmentService.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxSystemAttachment; + +/** + *

+ * 附件管理表 服务类 + *

+ * + * @author hupeng + * @since 2019-11-11 + */ +public interface YxSystemAttachmentService extends BaseService { + + /** + * 根据名称获取 + * @param name name + * @return YxSystemAttachment + */ + YxSystemAttachment getInfo(String name); + + /** + * 根据code获取 + * @param code code + * @return YxSystemAttachment + */ + YxSystemAttachment getByCode(String code); + + /** + * 添加附件记录 + * @param name 名称 + * @param attSize 附件大小 + * @param attDir 路径 + * @param sattDir 路径 + */ + void attachmentAdd(String name,String attSize,String attDir,String sattDir); + + /** + * 添加附件记录 + * @param name 名称 + * @param attSize 附件大小 + * @param attDir 路径 + * @param sattDir 路径 + * @param uid 用户id + * @param code 邀请码 + */ + void newAttachmentAdd(String name,String attSize,String attDir,String sattDir,Long uid,String code); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemConfigService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemConfigService.java new file mode 100644 index 00000000..bd003f02 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemConfigService.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxSystemConfig; +import co.yixiang.modules.shop.service.dto.YxSystemConfigDto; +import co.yixiang.modules.shop.service.dto.YxSystemConfigQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxSystemConfigService extends BaseService{ + + /** + * 获取配置值 + * @param name 配置名 + * @return string + */ + String getData(String name); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemConfigQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemConfigQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + YxSystemConfig findByKey(String store_brokerage_statu); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemGroupDataService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemGroupDataService.java new file mode 100644 index 00000000..3961e9aa --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemGroupDataService.java @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxSystemGroupData; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataDto; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria; +import com.alibaba.fastjson.JSONObject; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxSystemGroupDataService extends BaseService{ + + /** + * 获取配置数据 + * @param name 配置名称 + * @return List + */ + List getDatas(String name); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemGroupDataQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemGroupDataQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemStoreService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemStoreService.java new file mode 100644 index 00000000..c5a3d066 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemStoreService.java @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; +import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.service.dto.YxSystemStoreDto; +import co.yixiang.modules.shop.service.dto.YxSystemStoreQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxSystemStoreService extends BaseService{ + + YxSystemStoreQueryVo getYxSystemStoreById(int id); + + /** + * 获取门店列表 + * @param latitude 纬度 + * @param longitude 经度 + * @param page page + * @param limit limit + * @return List + */ + List getStoreList(String latitude, String longitude, int page, int limit); + + /** + * 获取最新单个门店 + * @param latitude 纬度 + * @param longitude 经度 + * @return YxSystemStoreQueryVo + */ + YxSystemStoreQueryVo getStoreInfo(String latitude,String longitude); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemStoreQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemStoreQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemStoreStaffService.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemStoreStaffService.java new file mode 100644 index 00000000..55f3063e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/YxSystemStoreStaffService.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxSystemStoreStaff; +import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffDto; +import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxSystemStoreStaffService extends BaseService{ + + /** + * 接测店员客服状态 + * @param uid 用户id + * @param storeId 门店id + * @return boolean true=可核销 + */ + boolean checkStatus(Long uid,Integer storeId); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemStoreStaffQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemStoreStaffQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxAppVersionDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxAppVersionDto.java new file mode 100644 index 00000000..4709ced3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxAppVersionDto.java @@ -0,0 +1,48 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; +import java.util.Date; +import java.io.Serializable; + +/** +* @author lioncity +* @date 2020-12-09 +*/ +@Data +public class YxAppVersionDto implements Serializable { + + private Integer id; + + private Integer isDel; + + /** 更新时间 */ + private Date createTime; + + private Date updateTime; + + /** 版本code */ + private String versionCode; + + /** 版本名称 */ + private String versionName; + + /** 版本描述 */ + private String versionInfo; + + /** 安卓下载链接 */ + private String androidUrl; + + /** 是否强制升级 */ + private Integer forceUpdate; + + /** ios store应用商店链接 */ + private String iosUrl; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxAppVersionQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxAppVersionQueryCriteria.java new file mode 100644 index 00000000..c9dad5c8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxAppVersionQueryCriteria.java @@ -0,0 +1,21 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; +import java.util.List; +import co.yixiang.annotation.Query; + +/** +* @author lioncity +* @date 2020-12-09 +*/ +@Data +public class YxAppVersionQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialDto.java new file mode 100644 index 00000000..45501c76 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialDto.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxMaterialDto implements Serializable { + + /** PK */ + private String id; + + + /** 创建时间 */ + private Date createTime; + + + /** 创建者ID */ + private String createId; + + /** 类型1、图片;2、视频 */ + private String type; + + /** 分组ID */ + private String groupId; + + /** 素材名 */ + private String name; + + /** 素材链接 */ + private String url; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialGroupDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialGroupDto.java new file mode 100644 index 00000000..b922854b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialGroupDto.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxMaterialGroupDto implements Serializable { + /** PK */ + private String id; + + + /** 创建时间 */ + private Date createTime; + + /** 创建者ID */ + private String createId; + + /** 分组名 */ + private String name; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialGroupQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialGroupQueryCriteria.java new file mode 100644 index 00000000..b19cb7ae --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialGroupQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxMaterialGroupQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialQueryCriteria.java new file mode 100644 index 00000000..d0af1db4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxMaterialQueryCriteria.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxMaterialQueryCriteria{ + + @Query + private String groupId; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemConfigDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemConfigDto.java new file mode 100644 index 00000000..eddb7274 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemConfigDto.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemConfigDto implements Serializable { + + /** 配置id */ + private Integer id; + + /** 字段名称 */ + private String menuName; + + /** 默认值 */ + private String value; + + /** 排序 */ + private Integer sort; + + /** 是否隐藏 */ + private Integer status; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemConfigQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemConfigQueryCriteria.java new file mode 100644 index 00000000..06525b4c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemConfigQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemConfigQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemGroupDataDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemGroupDataDto.java new file mode 100644 index 00000000..6e84df27 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemGroupDataDto.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemGroupDataDto implements Serializable { + + // 组合数据详情ID + private Integer id; + + // 对应的数据名称 + private String groupName; + + // 数据组对应的数据值(json数据) + private String value; + + private Map map; + + // 添加数据时间 + private Integer addTime; + + // 数据排序 + private Integer sort; + + // 状态(1:开启;2:关闭;) + private Integer status; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemGroupDataQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemGroupDataQueryCriteria.java new file mode 100644 index 00000000..2cd21443 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemGroupDataQueryCriteria.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemGroupDataQueryCriteria{ + + // 精确 + @Query + private String groupName; + + @Query + private Integer status; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreDto.java new file mode 100644 index 00000000..9f8cf5be --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreDto.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemStoreDto implements Serializable { + + private Integer id; + + /** 门店名称 */ + private String name; + + /** 简介 */ + private String introduction; + + /** 手机号码 */ + private String phone; + + /** 省市区 */ + private String address; + + /** 详细地址 */ + private String detailedAddress; + + /** 门店logo */ + private String image; + + /** 纬度 */ + private String latitude; + + /** 经度 */ + private String longitude; + + /** 核销有效日期 */ + private String validTime; + + /** 每日营业开关时间 */ + private String dayTime; + + /** 添加时间 */ + private Date createTime; + + /** 是否显示 */ + private Integer isShow; + + private Date validTimeEnd; + + private Date validTimeStart; + + private Date dayTimeStart; + + private Date dayTimeEnd; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreQueryCriteria.java new file mode 100644 index 00000000..8c10b3de --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemStoreQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreStaffDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreStaffDto.java new file mode 100644 index 00000000..7fd9d840 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreStaffDto.java @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemStoreStaffDto implements Serializable { + + private Integer id; + + /** 微信用户id */ + private Long uid; + + /** 店员头像 */ + private String avatar; + + /** 门店id */ + private Integer storeId; + + /** 店员名称 */ + private String staffName; + + /** 手机号码 */ + private String phone; + + /** 核销开关 */ + private Integer verifyStatus; + + /** 状态 */ + private Integer status; + + /** 添加时间 */ + private Date createTime; + + /** 微信昵称 */ + private String nickname; + + /** 所属门店 */ + private String storeName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreStaffQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreStaffQueryCriteria.java new file mode 100644 index 00000000..4b1cdab5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/dto/YxSystemStoreStaffQueryCriteria.java @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemStoreStaffQueryCriteria{ + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String staffName; + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String nickname; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxAppVersionServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxAppVersionServiceImpl.java new file mode 100644 index 00000000..67eb312d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxAppVersionServiceImpl.java @@ -0,0 +1,86 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.service.impl; + +import co.yixiang.modules.shop.domain.YxAppVersion; +import co.yixiang.common.service.impl.BaseServiceImpl; +import lombok.AllArgsConstructor; +import co.yixiang.dozer.service.IGenerator; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.utils.ValidationUtil; +import co.yixiang.utils.FileUtil; +import co.yixiang.modules.shop.service.YxAppVersionService; +import co.yixiang.modules.shop.service.dto.YxAppVersionDto; +import co.yixiang.modules.shop.service.dto.YxAppVersionQueryCriteria; +import co.yixiang.modules.shop.service.mapper.YxAppVersionMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import co.yixiang.domain.PageResult; +/** +* @author lioncity +* @date 2020-12-09 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxAppVersion") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxAppVersionServiceImpl extends BaseServiceImpl implements YxAppVersionService { + + private final IGenerator generator; + + @Override + //@Cacheable + public PageResult queryAll(YxAppVersionQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + return generator.convertPageInfo(page,YxAppVersionDto.class); + } + + + @Override + //@Cacheable + public List queryAll(YxAppVersionQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxAppVersion.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxAppVersionDto yxAppVersion : all) { + Map map = new LinkedHashMap<>(); + map.put(" isDel", yxAppVersion.getIsDel()); + map.put("更新时间", yxAppVersion.getCreateTime()); + map.put(" updateTime", yxAppVersion.getUpdateTime()); + map.put("版本code", yxAppVersion.getVersionCode()); + map.put("版本名称", yxAppVersion.getVersionName()); + map.put("版本描述", yxAppVersion.getVersionInfo()); + map.put("安卓下载链接", yxAppVersion.getAndroidUrl()); + map.put("是否强制升级", yxAppVersion.getForceUpdate()); + map.put("ios store应用商店链接", yxAppVersion.getIosUrl()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialGroupServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialGroupServiceImpl.java new file mode 100644 index 00000000..5e9e46c2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialGroupServiceImpl.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.shop.domain.YxMaterialGroup; +import co.yixiang.modules.shop.service.YxMaterialGroupService; +import co.yixiang.modules.shop.service.dto.YxMaterialGroupDto; +import co.yixiang.modules.shop.service.dto.YxMaterialGroupQueryCriteria; +import co.yixiang.modules.shop.service.mapper.MaterialGroupMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxMaterialGroupServiceImpl extends BaseServiceImpl implements YxMaterialGroupService { + + private final IGenerator generator; + + @Override + public Map queryAll(YxMaterialGroupQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxMaterialGroupDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + public List queryAll(YxMaterialGroupQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxMaterialGroup.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxMaterialGroupDto yxMaterialGroup : all) { + Map map = new LinkedHashMap<>(); + map.put("创建时间", yxMaterialGroup.getCreateTime()); + map.put("创建者ID", yxMaterialGroup.getCreateId()); + map.put("分组名", yxMaterialGroup.getName()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialServiceImpl.java new file mode 100644 index 00000000..5b42a2b6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxMaterialServiceImpl.java @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.shop.domain.YxMaterial; +import co.yixiang.modules.shop.service.YxMaterialService; +import co.yixiang.modules.shop.service.dto.YxMaterialDto; +import co.yixiang.modules.shop.service.dto.YxMaterialQueryCriteria; +import co.yixiang.modules.shop.service.mapper.MaterialMapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxMaterialServiceImpl extends BaseServiceImpl implements YxMaterialService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxMaterialQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxMaterialDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxMaterialQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxMaterial.class, criteria)); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemAttachmentServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemAttachmentServiceImpl.java new file mode 100644 index 00000000..4fb3c61d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemAttachmentServiceImpl.java @@ -0,0 +1,111 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.impl; + + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.shop.domain.YxSystemAttachment; +import co.yixiang.modules.shop.service.YxSystemAttachmentService; +import co.yixiang.modules.shop.service.mapper.YxSystemAttachmentMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + *

+ * 附件管理表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-11-11 + */ +@Slf4j +@Service +@AllArgsConstructor +@Transactional(rollbackFor = Exception.class) +public class YxSystemAttachmentServiceImpl extends BaseServiceImpl implements YxSystemAttachmentService { + + private final YxSystemAttachmentMapper yxSystemAttachmentMapper; + + /** + * 根据名称获取 + * @param name name + * @return YxSystemAttachment + */ + @Override + public YxSystemAttachment getInfo(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxSystemAttachment::getName,name) + .last("limit 1"); + return yxSystemAttachmentMapper.selectOne(wrapper); + } + + /** + * 根据code获取 + * @param code code + * @return YxSystemAttachment + */ + @Override + public YxSystemAttachment getByCode(String code) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxSystemAttachment::getInviteCode,code) + .last("limit 1"); + return yxSystemAttachmentMapper.selectOne(wrapper); + } + + /** + * 添加附件记录 + * @param name 名称 + * @param attSize 附件大小 + * @param attDir 路径 + * @param sattDir 路径 + */ + @Override + public void attachmentAdd(String name, String attSize, String attDir,String sattDir) { + YxSystemAttachment attachment = YxSystemAttachment.builder() + .name(name) + .attSize(attSize) + .attDir(attDir) + .attType("image/jpeg") + .sattDir(sattDir) + .build(); + yxSystemAttachmentMapper.insert(attachment); + } + + /** + * 添加附件记录 + * @param name 名称 + * @param attSize 附件大小 + * @param attDir 路径 + * @param sattDir 路径 + * @param uid 用户id + * @param code 邀请码 + */ + @Override + public void newAttachmentAdd(String name, String attSize, String attDir, String sattDir, + Long uid, String code) { + + YxSystemAttachment attachment = YxSystemAttachment.builder() + .name(name) + .attSize(attSize) + .attDir(attDir) + .attType("image/jpeg") + .sattDir(sattDir) + .uid(uid) + .inviteCode(code) + .build(); + yxSystemAttachmentMapper.insert(attachment); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemConfigServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemConfigServiceImpl.java new file mode 100644 index 00000000..b422744f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemConfigServiceImpl.java @@ -0,0 +1,109 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.impl; + +import cn.hutool.core.util.StrUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.shop.domain.YxSystemConfig; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.shop.service.dto.YxSystemConfigDto; +import co.yixiang.modules.shop.service.dto.YxSystemConfigQueryCriteria; +import co.yixiang.modules.shop.service.mapper.SystemConfigMapper; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.RedisUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemConfigServiceImpl extends BaseServiceImpl implements YxSystemConfigService { + + private final IGenerator generator; + private final RedisUtils redisUtils; + + /** + * 获取配置值 + * @param name 配置名 + * @return string + */ + @Override + public String getData(String name) { + String result = redisUtils.getY(name); + if(StrUtil.isNotBlank(result)) { + return result; + } + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxSystemConfig::getMenuName,name); + YxSystemConfig systemConfig = this.baseMapper.selectOne(wrapper); + if(systemConfig == null) { + return ""; + } + return systemConfig.getValue(); + } + + @Override + //@Cacheable + public Map queryAll(YxSystemConfigQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxSystemConfigDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemConfigQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemConfig.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemConfigDto yxSystemConfig : all) { + Map map = new LinkedHashMap<>(); + map.put("字段名称", yxSystemConfig.getMenuName()); + map.put("默认值", yxSystemConfig.getValue()); + map.put("排序", yxSystemConfig.getSort()); + map.put("是否隐藏", yxSystemConfig.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public YxSystemConfig findByKey(String key) { + return this.getOne(new LambdaQueryWrapper() + .eq(YxSystemConfig::getMenuName,key)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java new file mode 100644 index 00000000..deaca51e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemGroupDataServiceImpl.java @@ -0,0 +1,119 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.CommonEnum; +import co.yixiang.modules.shop.domain.YxSystemGroupData; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataDto; +import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria; +import co.yixiang.modules.shop.service.mapper.SystemGroupDataMapper; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemGroupDataServiceImpl extends BaseServiceImpl implements YxSystemGroupDataService { + + private final IGenerator generator; + + + /** + * 获取配置数据 + * @param name 配置名称 + * @return List + */ + @Override + //@Cacheable(value = "yshop:configDatas",key = "#name") + public List getDatas(String name) { + List systemGroupDatas = this.baseMapper + .selectList(Wrappers.lambdaQuery() + .eq(YxSystemGroupData::getGroupName,name) + .eq(YxSystemGroupData::getStatus,CommonEnum.SHOW_STATUS_1.getValue()) + .orderByDesc(YxSystemGroupData::getSort)); + + List list = systemGroupDatas + .stream() + .map(YxSystemGroupData::getValue) + .map(JSONObject::parseObject) + .collect(Collectors.toList()); + + return list; + } + + + //===============管理后台============== + + @Override + //@Cacheable + public Map queryAll(YxSystemGroupDataQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + List systemGroupDataDTOS = new ArrayList<>(); + for (YxSystemGroupData systemGroupData : page.getList()) { + + YxSystemGroupDataDto systemGroupDataDTO = generator.convert(systemGroupData,YxSystemGroupDataDto.class); + systemGroupDataDTO.setMap(JSON.parseObject(systemGroupData.getValue())); + systemGroupDataDTOS.add(systemGroupDataDTO); + } + map.put("content",systemGroupDataDTOS); + map.put("totalElements",page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemGroupDataQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemGroupData.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemGroupDataDto yxSystemGroupData : all) { + Map map = new LinkedHashMap<>(); + map.put("对应的数据名称", yxSystemGroupData.getGroupName()); + map.put("数据组对应的数据值(json数据)", yxSystemGroupData.getValue()); + map.put("添加数据时间", yxSystemGroupData.getAddTime()); + map.put("数据排序", yxSystemGroupData.getSort()); + map.put("状态(1:开启;2:关闭;)", yxSystemGroupData.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java new file mode 100644 index 00000000..4c3c65d7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java @@ -0,0 +1,158 @@ +/** + * Copyright (C) 2018-2022 + * 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; +import cn.hutool.core.util.StrUtil; +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.modules.product.vo.YxSystemStoreQueryVo; +import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.service.YxSystemStoreService; +import co.yixiang.modules.shop.service.dto.YxSystemStoreDto; +import co.yixiang.modules.shop.service.dto.YxSystemStoreQueryCriteria; +import co.yixiang.modules.shop.service.mapper.SystemStoreMapper; +import co.yixiang.utils.FileUtil; + +import co.yixiang.utils.RedisUtils; +import co.yixiang.utils.ShopKeyUtils; +import co.yixiang.utils.location.LocationUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemStoreServiceImpl extends BaseServiceImpl implements YxSystemStoreService { + + private final IGenerator generator; + private final SystemStoreMapper systemStoreMapper; + private final RedisUtils redisUtils; + + @Override + public YxSystemStoreQueryVo getYxSystemStoreById(int id){ + return generator.convert(this.getById(id),YxSystemStoreQueryVo.class); + } + + /** + * 获取门店列表 + * @param latitude 纬度 + * @param longitude 经度 + * @param page page + * @param limit limit + * @return List + */ + @Override + public List getStoreList(String latitude, String longitude, int page, int limit) { + Page pageModel = new Page<>(page, limit); + if(StrUtil.isBlank(latitude) || StrUtil.isBlank(longitude)){ + return generator.convert(this.page(pageModel).getRecords(),YxSystemStoreQueryVo.class); + } + List list = systemStoreMapper.getStoreList(pageModel,Double.valueOf(longitude),Double.valueOf(latitude)); + list.forEach(item->{ + String newDis = NumberUtil.round(Double.valueOf(item.getDistance()) / 1000,2).toString(); + item.setDistance(newDis); + }); + return list; + } + + /** + * 获取最新单个门店 + * @param latitude 纬度 + * @param longitude 经度 + * @return YxSystemStoreQueryVo + */ + @Override + public YxSystemStoreQueryVo getStoreInfo(String latitude,String longitude) { + YxSystemStore yxSystemStore = systemStoreMapper.selectOne( + Wrappers.lambdaQuery() + .eq(YxSystemStore::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByDesc(YxSystemStore::getId) + .last("limit 1")); + if(yxSystemStore == null) { + return null; + } + String mention = redisUtils.getY(ShopKeyUtils.getStoreSelfMention()); + if(StrUtil.isBlank(mention) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(mention)) { + return null; + } + YxSystemStoreQueryVo systemStoreQueryVo = generator.convert(yxSystemStore,YxSystemStoreQueryVo.class); + if(StrUtil.isNotEmpty(latitude) && StrUtil.isNotEmpty(longitude)){ + double distance = LocationUtils.getDistance(Double.valueOf(latitude),Double.valueOf(longitude), + Double.valueOf(yxSystemStore.getLatitude()),Double.valueOf(yxSystemStore.getLongitude())); + systemStoreQueryVo.setDistance(String.valueOf(distance)); + } + return systemStoreQueryVo; + } + + + + //===================================// + + @Override + //@Cacheable + public Map queryAll(YxSystemStoreQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxSystemStoreDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemStoreQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemStore.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemStoreDto yxSystemStore : all) { + Map map = new LinkedHashMap<>(); + map.put("门店名称", yxSystemStore.getName()); + map.put("简介", yxSystemStore.getIntroduction()); + map.put("手机号码", yxSystemStore.getPhone()); + map.put("省市区", yxSystemStore.getAddress()); + map.put("详细地址", yxSystemStore.getDetailedAddress()); + map.put("门店logo", yxSystemStore.getImage()); + map.put("纬度", yxSystemStore.getLatitude()); + map.put("经度", yxSystemStore.getLongitude()); + map.put("核销有效日期", yxSystemStore.getValidTime()); + map.put("每日营业开关时间", yxSystemStore.getDayTime()); + map.put("是否显示", yxSystemStore.getIsShow()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreStaffServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreStaffServiceImpl.java new file mode 100644 index 00000000..806d4cb0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreStaffServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.impl; + +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.modules.shop.domain.YxSystemStoreStaff; +import co.yixiang.modules.shop.service.YxSystemStoreStaffService; +import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffDto; +import co.yixiang.modules.shop.service.dto.YxSystemStoreStaffQueryCriteria; +import co.yixiang.modules.shop.service.mapper.SystemStoreStaffMapper; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemStoreStaffServiceImpl extends BaseServiceImpl implements YxSystemStoreStaffService { + + private final IGenerator generator; + + + /** + * 接测店员客服状态 + * @param uid 用户id + * @param storeId 门店id + * @return boolean true=可核销 + */ + @Override + public boolean checkStatus(Long uid,Integer storeId) { + YxSystemStoreStaff storeStaff = new YxSystemStoreStaff(); + storeStaff.setUid(uid); + storeStaff.setVerifyStatus(ShopCommonEnum.IS_STATUS_1.getValue()); + if(storeId != null) { + storeStaff.setStoreId(storeId); + } + return this.baseMapper.selectCount(Wrappers.query(storeStaff)) > 0; + } + + @Override + //@Cacheable + public Map queryAll(YxSystemStoreStaffQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxSystemStoreStaffDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemStoreStaffQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemStoreStaff.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemStoreStaffDto yxSystemStoreStaff : all) { + Map map = new LinkedHashMap<>(); + map.put("微信用户id", yxSystemStoreStaff.getUid()); + map.put("店员头像", yxSystemStoreStaff.getAvatar()); + map.put("门店id", yxSystemStoreStaff.getStoreId()); + map.put("店员名称", yxSystemStoreStaff.getStaffName()); + map.put("手机号码", yxSystemStoreStaff.getPhone()); + map.put("核销开关", yxSystemStoreStaff.getVerifyStatus()); + map.put("状态", yxSystemStoreStaff.getStatus()); + map.put("微信昵称", yxSystemStoreStaff.getNickname()); + map.put("所属门店", yxSystemStoreStaff.getStoreName()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialGroupMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialGroupMapper.java new file mode 100644 index 00000000..9df3cfa7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialGroupMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxMaterialGroup; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface MaterialGroupMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialMapper.java new file mode 100644 index 00000000..9306679d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/MaterialMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxMaterial; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface MaterialMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemConfigMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemConfigMapper.java new file mode 100644 index 00000000..da2df771 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemConfigMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxSystemConfig; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface SystemConfigMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemGroupDataMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemGroupDataMapper.java new file mode 100644 index 00000000..0f27e934 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemGroupDataMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxSystemGroupData; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface SystemGroupDataMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemStoreMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemStoreMapper.java new file mode 100644 index 00000000..549752f7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemStoreMapper.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; +import co.yixiang.modules.shop.domain.YxSystemStore; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface SystemStoreMapper extends CoreMapper { + + @Select("SELECT*,ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN((#{lat} * PI() / 180 - latitude * PI() / 180" + + " ) / 2),2) + COS(40.0497810000 * PI() / 180) * COS(latitude * PI() / 180) * POW(" + + " SIN((#{lon} * PI() / 180 - longitude * PI() / 180) / 2),2))) * 1000) AS distance" + + " FROM yx_system_store WHERE is_del=0 AND is_show = 1 ORDER BY distance ASC" + ) + List getStoreList(Page page, @Param("lon") double lon, @Param("lat") double lat); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemStoreStaffMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemStoreStaffMapper.java new file mode 100644 index 00000000..223bc487 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/SystemStoreStaffMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxSystemStoreStaff; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface SystemStoreStaffMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxAppVersionMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxAppVersionMapper.java new file mode 100644 index 00000000..2903a893 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxAppVersionMapper.java @@ -0,0 +1,23 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.shop.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxAppVersion; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author lioncity +* @date 2020-12-09 +*/ +@Repository +public interface YxAppVersionMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxSystemAttachmentMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxSystemAttachmentMapper.java new file mode 100644 index 00000000..383e72d2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/mapper/YxSystemAttachmentMapper.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.shop.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxSystemAttachment; +import org.springframework.stereotype.Repository; + +/** + *

+ * 附件管理表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-11-11 + */ +@Repository +public interface YxSystemAttachmentMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/AppCheckVersion.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/AppCheckVersion.java new file mode 100644 index 00000000..a64ac42b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/AppCheckVersion.java @@ -0,0 +1,26 @@ +package co.yixiang.modules.shop.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author :LionCity + * @date :Created in 2020-12-09 10:47 + * @description: + * @modified By: + * @version: + */ +@Data +@ApiModel(description = "app校验升级") +public class AppCheckVersion implements Serializable { + + private static final long serialVersionUID = 1L; + @ApiModelProperty(value = "类型 1101 安卓 1102 ios") + private String type; + + @ApiModelProperty(value = "app版本名称") + private String versionName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/YxAppVersionVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/YxAppVersionVo.java new file mode 100644 index 00000000..dc11c8f5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/YxAppVersionVo.java @@ -0,0 +1,45 @@ +package co.yixiang.modules.shop.vo; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author :LionCity + * @date :Created in 2020-12-09 10:25 + * @description: + * @modified By: + * @version: + */ + +@Data +public class YxAppVersionVo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + + /** 版本code */ + private String versionCode; + + /** 版本名称 */ + private String versionName; + + /** 版本描述 */ + private String versionInfo; + + /** 安卓下载链接 */ + private String downloadUrl; + + /**是否强制升级*/ + private Boolean forceUpdate; + + public void copy(co.yixiang.modules.shop.domain.YxAppVersion source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/YxSystemGroupDataVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/YxSystemGroupDataVo.java new file mode 100644 index 00000000..1f98fffc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/vo/YxSystemGroupDataVo.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.shop.vo; + +import com.alibaba.fastjson.JSONObject; +import lombok.Getter; +import lombok.Setter; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Getter +@Setter +public class YxSystemGroupDataVo{ + + /** 组合数据详情ID */ + + private Integer id; + + + /** 对应的数据名称 */ + private String groupName; + + + /** 数据组对应的数据值(json数据) */ + private JSONObject value; + + + /** 数据排序 */ + private Integer sort; + + + /** 状态(1:开启;2:关闭;) */ + private Integer status; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/Menu.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/Menu.java new file mode 100644 index 00000000..53d06bca --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/Menu.java @@ -0,0 +1,96 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("menu") +public class Menu extends BaseDomain { + + /** ID */ + @TableId + private Long id; + + + /** 是否外链 */ + private Boolean iFrame; + + + /** 菜单名称 */ + @NotBlank(message = "请填写菜单名称") + @TableField("`name`") + private String name; + + + /** 组件 */ + private String component; + + + /** 上级菜单ID */ + @NotNull(message = "上级菜单ID不能为空") + private Long pid; + + + /** 排序 */ + @NotNull(message = "排序不能为空") + private Long sort; + + + /** 图标 */ + private String icon; + + + /** 链接地址 */ + private String path; + + + /** 缓存 */ + @TableField("`cache`") + private Boolean cache; + + + /** 是否隐藏 */ + private Boolean hidden; + + + /** 组件名称 */ + private String componentName; + + + + + /** 权限 */ + private String permission; + + + /** 类型,目录、菜单、按钮 */ + @TableField("`type`") + private Integer type; + + + public void copy(Menu source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/MenuMetaVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/MenuMetaVo.java new file mode 100644 index 00000000..a302e193 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/MenuMetaVo.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author hupeng + * @date 2018-12-20 + */ +@Data +@AllArgsConstructor +public class MenuMetaVo implements Serializable { + + private String title; + + private String icon; + + private Boolean noCache; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/MenuVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/MenuVo.java new file mode 100644 index 00000000..54a605c5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/MenuVo.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 构建前端路由时用到 + * @author hupeng + * @date 2018-12-20 + */ +@Data +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class MenuVo implements Serializable { + + private String name; + + private String path; + + private Boolean hidden; + + private String redirect; + + private String component; + + private Boolean alwaysShow; + + private MenuMetaVo meta; + + private List children; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/UserPassVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/UserPassVo.java new file mode 100644 index 00000000..86c56f9a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/domain/vo/UserPassVo.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.domain.vo; + +import lombok.Data; + +/** + * 修改密码的 Vo 类 + * @author hupeng + * @date 2019年7月11日13:59:49 + */ +@Data +public class UserPassVo { + + private String oldPass; + + private String newPass; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/rest/BxgMenuController.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/rest/BxgMenuController.java new file mode 100644 index 00000000..403a1ee7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/rest/BxgMenuController.java @@ -0,0 +1,68 @@ +package co.yixiang.modules.system.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; +import cn.iocoder.yudao.module.system.dal.mysql.permission.MenuMapper; +import cn.iocoder.yudao.module.system.service.permission.MenuService; +import co.yixiang.modules.system.domain.Menu; +import co.yixiang.modules.system.service.BxgMenuService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@Api(tags = "菜单复制") +@RestController +@RequestMapping("/api/menussss") +@Slf4j +public class BxgMenuController { + + @Autowired + private BxgMenuService bxgMenuService; + + @Resource + private MenuMapper menuMapper; + + @ApiOperation("test...") + @GetMapping("/menu") + public CommonResult test() { + List list1 = bxgMenuService.list(Wrappers.lambdaQuery().eq(Menu::getPid, 0)); + list1.forEach(s -> { + this.ttt(s, 1292L); + }); + return CommonResult.success("123"); + } + + void ttt(Menu m, Long topId) { + MenuDO menudo = new MenuDO(); + menudo.setParentId(topId); + menudo.setIcon(m.getIcon()); + menudo.setName(m.getName()); + menudo.setPath(m.getPath()); + menudo.setPermission(m.getPermission()); + menudo.setSort(m.getSort().intValue()); + menudo.setType(m.getType()); + if (ObjectUtil.isNotEmpty(m.getComponent())){ + menudo.setComponent("bxg/" + m.getComponent()); + } + + menuMapper.insert(menudo); + + // 查看m的下级 + List subM = bxgMenuService.list(Wrappers.lambdaQuery().eq(Menu::getPid, m.getId())); + if (ObjectUtil.isNotEmpty(subM)) { + //只要他有下级就一直循环。 + subM.forEach(s -> { + this.ttt(s, menudo.getId()); + }); + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/BxgMenuService.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/BxgMenuService.java new file mode 100644 index 00000000..2c9ffcb0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/BxgMenuService.java @@ -0,0 +1,112 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.system.domain.Menu; +import co.yixiang.modules.system.domain.vo.MenuVo; +import co.yixiang.modules.system.service.dto.MenuDto; +import co.yixiang.modules.system.service.dto.MenuQueryCriteria; +import co.yixiang.modules.system.service.dto.RoleSmallDto; +import com.baomidou.dynamic.datasource.annotation.DS; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +public interface BxgMenuService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(MenuQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(MenuQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * 构建菜单树 + * @param menuDtos 原始数据 + * @return / + */ + Map buildTree(List menuDtos); + + /** + * 构建菜单树 + * @param menuDtos / + * @return / + */ + List buildMenus(List menuDtos); + + /** + * 获取菜单树 + * @param menus / + * @return / + */ + Object getMenuTree(List menus); + + + /** + * 获取待删除的菜单 + * @param menuList / + * @param menuSet / + * @return / + */ + Set getDeleteMenus(List menuList, Set menuSet); + + /** + * 根据pid查询 + * @param pid / + * @return / + */ + List findByPid(long pid); + + /** + * 根据角色查询 + * @param roles / + * @return / + */ + List findByRoles(List roles); + + /** + * 删除 + * @param menuSet / + */ + void delete(Set menuSet); + + /** + * 编辑 + * @param resources / + */ + void update(Menu resources); + + Object create(Menu resources); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptDto.java new file mode 100644 index 00000000..6e95e599 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptDto.java @@ -0,0 +1,48 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Getter +@Setter +public class DeptDto implements Serializable { + + /** ID */ + private Long id; + + /** 名称 */ + private String name; + + /** 上级部门 */ + private Long pid; + + /** 状态 */ + private Boolean enabled; + + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + /** 创建日期 */ + private Timestamp createTime; + + public String getLabel() { + return name; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptQueryCriteria.java new file mode 100644 index 00000000..a8a92442 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptQueryCriteria.java @@ -0,0 +1,39 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; +import java.util.Set; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class DeptQueryCriteria{ + + @Query(type = Query.Type.IN, propName="id") + private Set ids; + + @Query(type = Query.Type.INNER_LIKE) + private String name; + + @Query + private Boolean enabled; + + @Query + private Long pid; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptSmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptSmallDto.java new file mode 100644 index 00000000..af1cb2bf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DeptSmallDto.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2019-6-10 16:32:18 +*/ +@Data +public class DeptSmallDto implements Serializable { + + private Long id; + + private String name; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDetailDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDetailDto.java new file mode 100644 index 00000000..1d100d89 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDetailDto.java @@ -0,0 +1,40 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class DictDetailDto implements Serializable { + + /** 字典详细 */ + private Long id; + + /** 字典标签 */ + private String label; + + /** 字典值 */ + private String value; + + /** 排序 */ + private String sort; + + /** 字典id */ + private Long dictId; + + /** 创建日期 */ + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDetailQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDetailQueryCriteria.java new file mode 100644 index 00000000..f2c5f291 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDetailQueryCriteria.java @@ -0,0 +1,25 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class DictDetailQueryCriteria{ + + @Query(type = Query.Type.INNER_LIKE) + private String label; + + private String dictName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDto.java new file mode 100644 index 00000000..3e12757e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictDto.java @@ -0,0 +1,37 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class DictDto implements Serializable { + + /** 字典ID */ + private Long id; + + /** 字典名称 */ + private String name; + + private List dictDetails; + + /** 描述 */ + private String remark; + + /** 创建日期 */ + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictQueryCriteria.java new file mode 100644 index 00000000..354f527e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictQueryCriteria.java @@ -0,0 +1,23 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class DictQueryCriteria{ + + @Query(blurry = "name,remark") + private String blurry; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictSmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictSmallDto.java new file mode 100644 index 00000000..d3f87ca3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/DictSmallDto.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2019-04-10 +*/ +@Getter +@Setter +public class DictSmallDto implements Serializable { + + private Long id; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobDto.java new file mode 100644 index 00000000..b16a56b6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobDto.java @@ -0,0 +1,41 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class JobDto implements Serializable { + + private Long id; + + private Long sort; + + private String name; + + private Boolean enabled; + + private DeptDto dept; + + private String deptSuperiorName; + + private Timestamp createTime; + +// public JobDto(String name, Boolean enabled) { +// this.name = name; +// this.enabled = enabled; +// } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobQueryCriteria.java new file mode 100644 index 00000000..693a66b4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobQueryCriteria.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.sql.Timestamp; +import java.util.List; +import java.util.Set; + +/** +* @author hupeng +* @date 2019-6-4 14:49:34 +*/ +@Data +@NoArgsConstructor +public class JobQueryCriteria { + + @Query(type = Query.Type.INNER_LIKE) + private String name; + + @Query + private Boolean enabled; + + @Query + private Long deptId; + + @Query(propName = "deptId", type = Query.Type.IN) + private Set deptIds; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobSmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobSmallDto.java new file mode 100644 index 00000000..7dd5aa51 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/JobSmallDto.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2019-6-10 16:32:18 +*/ +@Data +@NoArgsConstructor +public class JobSmallDto implements Serializable { + + private Long id; + + private String name; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/MenuDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/MenuDto.java new file mode 100644 index 00000000..7c0807e8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/MenuDto.java @@ -0,0 +1,53 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class MenuDto implements Serializable { + + private Long id; + + private Integer type; + + private String permission; + + private String name; + + private Long sort; + + private String path; + + private String component; + + private Long pid; + + private Boolean iFrame; + + private Boolean cache; + + private Boolean hidden; + + private String componentName; + + private String icon; + + private List children; + + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/MenuQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/MenuQueryCriteria.java new file mode 100644 index 00000000..7235eded --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/MenuQueryCriteria.java @@ -0,0 +1,29 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class MenuQueryCriteria{ + + @Query(blurry = "name") + private String blurry; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/PermissionDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/PermissionDto.java new file mode 100644 index 00000000..eb877636 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/PermissionDto.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.List; + +/** + * @author hupeng + * @date 2018-12-03 + */ +@Data +public class PermissionDto implements Serializable{ + + private Long id; + + private String name; + + private Long pid; + + private String alias; + + private Timestamp createTime; + + private List children; + + @Override + public String toString() { + return "Permission{" + + "id=" + id + + ", name='" + name + '\'' + + ", pid=" + pid + + ", alias='" + alias + '\'' + + ", createTime=" + createTime + + '}'; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/PermissionQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/PermissionQueryCriteria.java new file mode 100644 index 00000000..083243eb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/PermissionQueryCriteria.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** + * 公共查询类 + */ +@Data +public class PermissionQueryCriteria { + + // 多字段模糊 + @Query(blurry = "name,alias") + private String blurry; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleDto.java new file mode 100644 index 00000000..80c426e6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleDto.java @@ -0,0 +1,47 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.modules.system.domain.Menu; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.Set; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class RoleDto implements Serializable { + + /** ID */ + private Long id; + + /** 名称 */ + private String name; + + /** 备注 */ + private String remark; + + /** 数据权限 */ + private String dataScope; + + /** 角色级别 */ + private Integer level; + + private Set menus; + + /** 创建日期 */ + private Timestamp createTime; + + /** 功能权限 */ + private String permission; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleQueryCriteria.java new file mode 100644 index 00000000..e285eef9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleQueryCriteria.java @@ -0,0 +1,29 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class RoleQueryCriteria{ + + @Query(blurry = "name") + private String blurry; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleSmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleSmallDto.java new file mode 100644 index 00000000..282d938c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/RoleSmallDto.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author hupeng + * @date 2018-11-23 + */ +@Data +public class RoleSmallDto implements Serializable { + + private Long id; + + private String name; + + private Integer level; + + private String dataScope; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserAvatarDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserAvatarDto.java new file mode 100644 index 00000000..81592530 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserAvatarDto.java @@ -0,0 +1,36 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class UserAvatarDto implements Serializable { + + private Long id; + + /** 真实文件名 */ + private String realName; + + /** 路径 */ + private String path; + + /** 大小 */ + private String size; + + /** 创建时间 */ + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserAvatarQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserAvatarQueryCriteria.java new file mode 100644 index 00000000..5d988e7b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserAvatarQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class UserAvatarQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserDto.java new file mode 100644 index 00000000..2f7c46f8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserDto.java @@ -0,0 +1,60 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.util.Set; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class UserDto implements Serializable { + + + @ApiModelProperty(hidden = true) + private Long id; + + private String username; + + private String nickName; + + private String sex; + + private String avatar; + + private String email; + + private String phone; + + private Boolean enabled; + + @JsonIgnore + private String password; + + private Timestamp lastPasswordResetTime; + + @ApiModelProperty(hidden = true) + private Set roles; + + @ApiModelProperty(hidden = true) + private JobSmallDto job; + + private DeptSmallDto dept; + + private Long deptId; + + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserQueryCriteria.java new file mode 100644 index 00000000..235ee610 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/dto/UserQueryCriteria.java @@ -0,0 +1,41 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; +import java.util.Set; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Data +public class UserQueryCriteria{ + + @Query + private Long id; + + @Query(propName = "deptId", type = Query.Type.IN) + private Set deptIds; + + @Query(blurry = "email,username,nickName") + private String blurry; + + @Query + private Boolean enabled; + + private Long deptId; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/impl/BxgMenuServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/impl/BxgMenuServiceImpl.java new file mode 100644 index 00000000..3866d307 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/impl/BxgMenuServiceImpl.java @@ -0,0 +1,363 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +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.exception.BadRequestException; +import co.yixiang.exception.EntityExistException; +import co.yixiang.modules.system.domain.Menu; +import co.yixiang.modules.system.domain.vo.MenuMetaVo; +import co.yixiang.modules.system.domain.vo.MenuVo; +import co.yixiang.modules.system.service.BxgMenuService; +import co.yixiang.modules.system.service.dto.MenuDto; +import co.yixiang.modules.system.service.dto.MenuQueryCriteria; +import co.yixiang.modules.system.service.dto.RoleSmallDto; +import co.yixiang.modules.system.service.mapper.BxgMenuMapper; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.StringUtils; +import co.yixiang.utils.ValidationUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Service +@AllArgsConstructor +@CacheConfig(cacheNames = "menu") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class BxgMenuServiceImpl extends BaseServiceImpl implements BxgMenuService { + + private final IGenerator generator; + private final BxgMenuMapper menuMapper; + + @Override + @Cacheable + public Map queryAll(MenuQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), MenuDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + @Cacheable + public List queryAll(MenuQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(Menu.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (MenuDto menu : all) { + Map map = new LinkedHashMap<>(); + map.put("是否外链", menu.getIFrame()); + map.put("菜单名称", menu.getName()); + map.put("组件", menu.getComponent()); + map.put("上级菜单ID", menu.getPid()); + map.put("排序", menu.getSort()); + map.put("图标", menu.getIcon()); + map.put("链接地址", menu.getPath()); + map.put("缓存", menu.getCache()); + map.put("是否隐藏", menu.getHidden()); + map.put("组件名称", menu.getComponentName()); + map.put("创建日期", menu.getCreateTime()); + map.put("权限", menu.getPermission()); + map.put("类型", menu.getType()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 构建菜单树 + * + * @param menuDtos 原始数据 + * @return / + */ + @Override + public Map buildTree(List menuDtos) { + List trees = new ArrayList<>(); + Set ids = new HashSet<>(); + for (MenuDto menuDto : menuDtos) { + if (menuDto.getPid() == 0) { + trees.add(menuDto); + } + for (MenuDto it : menuDtos) { + if (it.getPid().equals(menuDto.getId())) { + if (menuDto.getChildren() == null) { + menuDto.setChildren(new ArrayList<>()); + } + menuDto.getChildren().add(it); + ids.add(it.getId()); + } + } + } + Map map = new HashMap<>(2); + if(trees.size() == 0){ + trees = menuDtos.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList()); + } + map.put("content",trees); + map.put("totalElements", menuDtos.size()); + return map; + } + + /** + * 构建菜单树 + * + * @param menuDtos / + * @return / + */ + @Override + public List buildMenus(List menuDtos) { + List list = new LinkedList<>(); + menuDtos.forEach(menuDTO -> { + if (menuDTO!=null){ + List menuDtoList = menuDTO.getChildren(); + MenuVo menuVo = new MenuVo(); + menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getName()); + // 一级目录需要加斜杠,不然会报警告 + menuVo.setPath(menuDTO.getPid() == 0 ? "/" + menuDTO.getPath() :menuDTO.getPath()); + menuVo.setHidden(menuDTO.getHidden()); + // 如果不是外链 + if(!menuDTO.getIFrame()){ + if(menuDTO.getPid() == 0){ + menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent())?"Layout":menuDTO.getComponent()); + }else if(!StrUtil.isEmpty(menuDTO.getComponent())){ + menuVo.setComponent(menuDTO.getComponent()); + } + } + menuVo.setMeta(new MenuMetaVo(menuDTO.getName(),menuDTO.getIcon(),!menuDTO.getCache())); + if(menuDtoList !=null && menuDtoList.size()!=0){ + menuVo.setAlwaysShow(true); + menuVo.setRedirect("noredirect"); + menuVo.setChildren(buildMenus(menuDtoList)); + // 处理是一级菜单并且没有子菜单的情况 + } else if(menuDTO.getPid() == 0){ + MenuVo menuVo1 = new MenuVo(); + menuVo1.setMeta(menuVo.getMeta()); + // 非外链 + if(!menuDTO.getIFrame()){ + menuVo1.setPath("index"); + menuVo1.setName(menuVo.getName()); + menuVo1.setComponent(menuVo.getComponent()); + } else { + menuVo1.setPath(menuDTO.getPath()); + } + menuVo.setName(null); + menuVo.setMeta(null); + menuVo.setComponent("Layout"); + List list1 = new ArrayList<>(); + list1.add(menuVo1); + menuVo.setChildren(list1); + } + list.add(menuVo); + } + } + ); + return list; + } + + /** + * 获取菜单树 + * + * @param menus / + * @return / + */ + @Override + @Cacheable(key = "'tree'") + public Object getMenuTree(List menus) { + List> list = new LinkedList<>(); + menus.forEach(menu -> { + if (menu!=null){ + List menuList = menuMapper.findByPid(menu.getId()); + Map map = new HashMap<>(16); + map.put("id",menu.getId()); + map.put("label",menu.getName()); + if(menuList!=null && menuList.size()!=0){ + map.put("children",getMenuTree(menuList)); + } + list.add(map); + } + } + ); + return list; + } + + /** + * 获取待删除的菜单 + * + * @param menuList / + * @param menuSet / + * @return / + */ + @Override + public Set getDeleteMenus(List menuList, Set menuSet) { + // 递归找出待删除的菜单 + for (Menu menu1 : menuList) { + menuSet.add(menu1); + List menus = menuMapper.findByPid(menu1.getId()); + if(menus!=null && menus.size()!=0){ + getDeleteMenus(menus, menuSet); + } + } + return menuSet; + } + + /** + * 根据pid查询 + * + * @param pid / + * @return / + */ + @Override + @Cacheable(key = "'pid:'+#p0") + public List findByPid(long pid) { + return menuMapper.findByPid(pid); + } + + /** + * 根据角色查询 + * + * @param roles / + * @return / + */ + @Override + public List findByRoles(List roles) { + List roleIds = roles.stream().map(i ->{ + Long role = i.getId(); + return role; + }).collect(Collectors.toList()); + List list = menuMapper.selectListByRoles(roleIds); + + return generator.convert(list,MenuDto.class); + } + + /** + * 删除 + * + * @param menuSet / + */ + @Override + @CacheEvict(allEntries = true) + public void delete(Set menuSet) { + for (Menu menu : menuSet) { + this.removeById(menu.getId()); + } + } + + /** + * 编辑 + * + * @param resources / + */ + @Override + @CacheEvict(allEntries = true) + public void update(Menu resources) { + if(resources.getId().equals(resources.getPid())) { + throw new BadRequestException("上级不能为自己"); + } + Menu menu = this.getById(resources.getId()); + ValidationUtil.isNull(menu.getId(),"Permission","id",resources.getId()); + + isExitHttp(resources); + + Menu menu1 = this.getOne(new LambdaQueryWrapper() + .eq(Menu::getName,resources.getName())); + + if(menu1 != null && !menu1.getId().equals(menu.getId())){ + throw new EntityExistException(Menu.class,"name",resources.getName()); + } + + if(StringUtils.isNotBlank(resources.getComponentName())&&resources.getType()!=1&& !resources.getIFrame()){ + Long menuCount = this.lambdaQuery().eq(Menu::getComponentName,resources.getComponentName()).count(); + if(menuCount > 1) { + throw new YshopException("请保持菜单组件名称唯一"); + } + menu1 = this.getOne(new LambdaQueryWrapper() + .eq(Menu::getComponentName,resources.getComponentName())); + if(menu1 != null && !menu1.getId().equals(menu.getId())){ + throw new EntityExistException(Menu.class,"componentName",resources.getComponentName()); + } + } + + menu.setId(resources.getId()); + menu.setName(resources.getName()); + menu.setComponent(resources.getComponent()); + menu.setPath(resources.getPath()); + menu.setIcon(resources.getIcon()); + menu.setIFrame(resources.getIFrame()); + menu.setPid(resources.getPid()); + menu.setSort(resources.getSort()); + menu.setCache(resources.getCache()); + menu.setHidden(resources.getHidden()); + menu.setComponentName(resources.getComponentName()); + menu.setPermission(resources.getPermission()); + menu.setType(resources.getType()); + this.saveOrUpdate(menu); + } + + @Override + @CacheEvict(allEntries = true) + public MenuDto create(Menu resources) { + isExitHttp(resources); + if(this.getOne(new LambdaQueryWrapper().eq(Menu::getName,resources.getName())) != null){ + throw new EntityExistException(Menu.class,"name",resources.getName()); + } + if(StringUtils.isNotBlank(resources.getComponentName())){ + if(this.getOne(new LambdaQueryWrapper().eq(Menu::getComponentName,resources.getComponentName())) != null){ + throw new EntityExistException(Menu.class,"componentName",resources.getComponentName()); + } + } + this.save(resources); + return generator.convert(resources,MenuDto.class); + } + + /** + * 公共方法提取出来 + * @param resources + */ + private void isExitHttp(Menu resources){ + if(resources.getIFrame()){ + String http = "http://", https = "https://"; + if (!(resources.getPath().toLowerCase().startsWith(http)||resources.getPath().toLowerCase().startsWith(https))) { + throw new BadRequestException("外链必须以http://或者https://开头"); + } + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/system/service/mapper/BxgMenuMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/mapper/BxgMenuMapper.java new file mode 100644 index 00000000..d06f3ad3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/system/service/mapper/BxgMenuMapper.java @@ -0,0 +1,42 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.system.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.system.domain.Menu; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Set; + +/** +* @author hupeng +* @date 2020-05-14 +*/ +@Repository +@Mapper +public interface BxgMenuMapper extends CoreMapper { + + + /**MenuService + * 根据菜单的 PID 查询 + * @param pid / + * @return / + */ + @Select("SELECT * from menu m where m.pid = #{pid} and m.is_del = 0 ") + List findByPid(@Param("pid") long pid); + + @Select("select m.* from menu m LEFT JOIN roles_menus t on m.id= t.menu_id LEFT JOIN role r on r.id = t.role_id where r.id = #{roleId} and m.is_del=0") + Set findMenuByRoleId(@Param("roleId") Long roleId); + @Select("") + List selectListByRoles(@Param("roleIds") List roleIds); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplates.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplates.java new file mode 100644 index 00000000..9f220c8e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplates.java @@ -0,0 +1,62 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_shipping_templates") +public class YxShippingTemplates extends BaseDomain { + + /** 模板ID */ + @TableId + private Integer id; + + + /** 模板名称 */ + private String name; + + + /** 计费方式 */ + private Integer type; + + + /** 地域以及费用 */ + private String regionInfo; + + + /** 指定包邮开关 */ + private Integer appoint; + + + /** 指定包邮内容 */ + private String appointInfo; + + + + + /** 排序 */ + private Integer sort; + + + public void copy(YxShippingTemplates source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplatesFree.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplatesFree.java new file mode 100644 index 00000000..b611cf16 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplatesFree.java @@ -0,0 +1,79 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Data +@TableName("yx_shipping_templates_free") +public class YxShippingTemplatesFree implements Serializable { + + /** 编号 */ + @TableId + private Integer id; + + + /** 省ID */ + @NotNull + private Integer provinceId; + + + /** 模板ID */ + @NotNull + private Integer tempId; + + + /** 城市ID */ + @NotNull + private Integer cityId; + + + /** 包邮件数 */ + @NotNull + private BigDecimal number; + + + /** 包邮金额 */ + @NotNull + private BigDecimal price; + + + /** 计费方式 */ + @NotNull + private Integer type; + + + /** 分组唯一值 */ + @NotBlank + private String uniqid; + + + public void copy(YxShippingTemplatesFree source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplatesRegion.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplatesRegion.java new file mode 100644 index 00000000..c172ae9f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxShippingTemplatesRegion.java @@ -0,0 +1,89 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Data +@TableName("yx_shipping_templates_region") +public class YxShippingTemplatesRegion implements Serializable { + + /** 编号 */ + @TableId + private Integer id; + + + /** 省ID */ + @NotNull + private Integer provinceId; + + + /** 模板ID */ + @NotNull + private Integer tempId; + + + /** 城市ID */ + @NotNull + private Integer cityId; + + + /** 首件 */ + @NotNull + private BigDecimal first; + + + /** 首件运费 */ + @NotNull + private BigDecimal firstPrice; + + + /** 续件 */ + @NotNull + private BigDecimal continues; + + + /** 续件运费 */ + @NotNull + private BigDecimal continuePrice; + + + /** 计费方式 */ + @NotNull + private Integer type; + + + /** 分组唯一值 */ + @NotBlank + private String uniqid; + + + public void copy(YxShippingTemplatesRegion source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxSystemCity.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxSystemCity.java new file mode 100644 index 00000000..7e70ffdf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/domain/YxSystemCity.java @@ -0,0 +1,88 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +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 javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +@TableName("yx_system_city") +public class YxSystemCity implements Serializable { + + @TableId + private Integer id; + + + /** 城市id */ + @NotNull + @JsonProperty(value = "city_id") + private Integer cityId; + + + /** 省市级别 */ + @NotNull + private Integer level; + + + /** 父级id */ + @NotNull + private Integer parentId; + + + /** 区号 */ + @NotBlank + private String areaCode; + + + /** 名称 */ + @NotBlank + private String name; + + + /** 合并名称 */ + @NotBlank + private String mergerName; + + + /** 经度 */ + @NotBlank + private String lng; + + + /** 纬度 */ + @NotBlank + private String lat; + + + /** 是否展示 */ + @NotNull + private Integer isShow; + + @TableField(exist = false) + private List children; + + + public void copy(YxSystemCity source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/rest/ShippingTemplatesController.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/rest/ShippingTemplatesController.java new file mode 100644 index 00000000..14c48b24 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/rest/ShippingTemplatesController.java @@ -0,0 +1,131 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.rest; + +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.service.YxStoreProductService; +import co.yixiang.modules.template.domain.YxSystemCity; +import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.modules.template.service.YxSystemCityService; +import co.yixiang.modules.template.service.dto.ShippingTemplatesDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesQueryCriteria; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@AllArgsConstructor +@Api(tags = "运费模板管理") +@RestController +@RequestMapping("/api/yxShippingTemplates") +public class ShippingTemplatesController { + + private final YxShippingTemplatesService yxShippingTemplatesService; + private final YxSystemCityService yxSystemCityService; + private final IGenerator generator; + private final YxStoreProductService yxStoreProductService; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxShippingTemplates:list')") + public void download(HttpServletResponse response, YxShippingTemplatesQueryCriteria criteria) throws IOException { + yxShippingTemplatesService.download(generator.convert(yxShippingTemplatesService.queryAll(criteria), YxShippingTemplatesDto.class), response); + } + + @GetMapping + @Log("查询运费模板") + @ApiOperation("查询运费模板") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxShippingTemplates:list')") + public ResponseEntity getYxShippingTemplatess(YxShippingTemplatesQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxShippingTemplatesService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @PostMapping("/save/{id}") + @Log("新增/保存运费模板") + @ApiOperation("新增/保存运费模板") + @PreAuthorize("hasAnyRole('admin','yxShippingTemplates:add','yxShippingTemplates:edit')") + public ResponseEntity create(@PathVariable Integer id, + @Validated @RequestBody ShippingTemplatesDto shippingTemplatesDto){ + yxShippingTemplatesService.addAndUpdate(id,shippingTemplatesDto); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + + @ForbidSubmit + @Log("删除运费模板") + @ApiOperation("删除运费模板") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxShippingTemplates:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + List productList = yxStoreProductService.list(); + Arrays.asList(ids).forEach(id->{ + for (YxStoreProduct yxStoreProduct : productList) { + if(id.equals(yxStoreProduct.getTempId())){ + throw new BadRequestException("运费模板存在商品关联,请删除对应商品"); + } + } + yxShippingTemplatesService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } + + + /** + * 获取城市列表 + */ + @Cacheable(cacheNames = ShopConstants.YSHOP_REDIS_SYS_CITY_KEY) + @GetMapping("/citys") + public ResponseEntity cityList() + { + List cityList = yxSystemCityService.list(Wrappers.lambdaQuery() + .eq(YxSystemCity::getParentId,0)); + + for (YxSystemCity systemCity : cityList){ + List children = yxSystemCityService.list(Wrappers + .lambdaQuery() + .eq(YxSystemCity::getParentId,systemCity.getCityId())); + + systemCity.setChildren(children); + } + + return new ResponseEntity<>(cityList,HttpStatus.OK); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesFreeService.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesFreeService.java new file mode 100644 index 00000000..d5935184 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesFreeService.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.template.domain.YxShippingTemplatesFree; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesFreeDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesFreeQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +public interface YxShippingTemplatesFreeService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxShippingTemplatesFreeQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxShippingTemplatesFreeQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesRegionService.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesRegionService.java new file mode 100644 index 00000000..27b27553 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesRegionService.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.template.domain.YxShippingTemplatesRegion; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesRegionDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesRegionQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +public interface YxShippingTemplatesRegionService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxShippingTemplatesRegionQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxShippingTemplatesRegionQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesService.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesService.java new file mode 100644 index 00000000..18081cad --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxShippingTemplatesService.java @@ -0,0 +1,58 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.service.dto.ShippingTemplatesDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +public interface YxShippingTemplatesService extends BaseService{ + + /** + * 新增与更新模板 + * @param id 模板id + * @param shippingTemplatesDto ShippingTemplatesDto + */ + void addAndUpdate(Integer id,ShippingTemplatesDto shippingTemplatesDto); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxShippingTemplatesQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxShippingTemplatesQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxSystemCityService.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxSystemCityService.java new file mode 100644 index 00000000..5f65191e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/YxSystemCityService.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.template.domain.YxSystemCity; +import co.yixiang.modules.template.service.dto.YxSystemCityDto; +import co.yixiang.modules.template.service.dto.YxSystemCityQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +public interface YxSystemCityService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemCityQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemCityQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/AppointInfoDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/AppointInfoDto.java new file mode 100644 index 00000000..100322ff --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/AppointInfoDto.java @@ -0,0 +1,28 @@ +package co.yixiang.modules.template.service.dto; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @ClassName AppointInfoDto + * @Author hupeng <610796224@qq.com> + * @Date 2020/5/26 + **/ +@Getter +@Setter +public class AppointInfoDto { + + /** 包邮件数 */ + private String a_num; + + /** 包邮费用 */ + private String a_price; + + /** 包邮地区 */ + private List place; + + private String placeName; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionChildrenDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionChildrenDto.java new file mode 100644 index 00000000..6a28aede --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionChildrenDto.java @@ -0,0 +1,16 @@ +package co.yixiang.modules.template.service.dto; + +import lombok.Getter; +import lombok.Setter; + +/** + * @ClassName RegionChildrenDto + * @Author hupeng <610796224@qq.com> + * @Date 2020/5/25 + **/ +@Getter +@Setter +public class RegionChildrenDto { + + private String city_id; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionDto.java new file mode 100644 index 00000000..8f563139 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionDto.java @@ -0,0 +1,23 @@ +package co.yixiang.modules.template.service.dto; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @ClassName RegionDto + * @Author hupeng <610796224@qq.com> + * @Date 2020/5/25 + **/ +@Getter +@Setter +public class RegionDto { + + private String name; + + private String city_id; + + List children; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionInfoDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionInfoDto.java new file mode 100644 index 00000000..3c5bec60 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/RegionInfoDto.java @@ -0,0 +1,38 @@ +package co.yixiang.modules.template.service.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * @ClassName RegionInfoDto + * @Author hupeng <610796224@qq.com> + * @Date 2020/5/25 + **/ +@Getter +@Setter +@ToString +public class RegionInfoDto { + + @NotBlank(message = "请填写可配送区域") + private String regionName; + + @NotBlank(message = "请填写首件") + private String first; + + @NotBlank(message = "请填写首件价格") + private String price; + + @NotBlank(message = "请填写续件") + @JsonProperty("_continue") + private String _continue; + + @NotBlank(message = "请填写续件价格") + private String continue_price; + + private List region; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/ShippingTemplatesDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/ShippingTemplatesDto.java new file mode 100644 index 00000000..2989c178 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/ShippingTemplatesDto.java @@ -0,0 +1,51 @@ +package co.yixiang.modules.template.service.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * 运费模板对象 yx_shipping_templates + * + * @author hupeng + * @date 2020-05-23 + */ +@Getter +@Setter +public class ShippingTemplatesDto implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 模板ID */ + private Integer id; + + /** 模板名称 */ + @NotBlank(message = "模板名称不能为空") + private String name; + + /** 计费方式 */ + private Integer type; + + /** 地域以及费用 */ + @NotNull(message = "请设置地域") + @JsonProperty(value = "region_info") + private List regionInfo; + + /** 指定包邮开关 */ + private Integer appoint; + + /** 指定包邮内容 */ + @JsonProperty(value = "appoint_info") + private List appointInfo; + + /** 排序 */ + private Long sort; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesDto.java new file mode 100644 index 00000000..1ee93076 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesDto.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxShippingTemplatesDto implements Serializable { + + /** 模板ID */ + private Integer id; + + /** 模板名称 */ + private String name; + + /** 计费方式 */ + private Integer type; + + /** 地域以及费用 */ + private String regionInfo; + + /** 指定包邮开关 */ + private Integer appoint; + + /** 指定包邮内容 */ + private String appointInfo; + + /** 添加时间 */ + private Timestamp createTime; + + private Timestamp updateTime; + + private Integer isDel; + + /** 排序 */ + private Integer sort; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesFreeDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesFreeDto.java new file mode 100644 index 00000000..01672c9b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesFreeDto.java @@ -0,0 +1,46 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxShippingTemplatesFreeDto implements Serializable { + + /** 编号 */ + private Integer id; + + /** 省ID */ + private Integer provinceId; + + /** 模板ID */ + private Integer tempId; + + /** 城市ID */ + private Integer cityId; + + /** 包邮件数 */ + private BigDecimal number; + + /** 包邮金额 */ + private BigDecimal price; + + /** 计费方式 */ + private Integer type; + + /** 分组唯一值 */ + private String uniqid; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesFreeQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesFreeQueryCriteria.java new file mode 100644 index 00000000..e369c3af --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesFreeQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxShippingTemplatesFreeQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesQueryCriteria.java new file mode 100644 index 00000000..78d624cb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxShippingTemplatesQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesRegionDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesRegionDto.java new file mode 100644 index 00000000..fb2cd4e7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesRegionDto.java @@ -0,0 +1,52 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxShippingTemplatesRegionDto implements Serializable { + + /** 编号 */ + private Integer id; + + /** 省ID */ + private Integer provinceId; + + /** 模板ID */ + private Integer tempId; + + /** 城市ID */ + private Integer cityId; + + /** 首件 */ + private BigDecimal first; + + /** 首件运费 */ + private BigDecimal firstPrice; + + /** 续件 */ + private BigDecimal continues; + + /** 续件运费 */ + private BigDecimal continuePrice; + + /** 计费方式 */ + private Integer type; + + /** 分组唯一值 */ + private String uniqid; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesRegionQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesRegionQueryCriteria.java new file mode 100644 index 00000000..e24dc24d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxShippingTemplatesRegionQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxShippingTemplatesRegionQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxSystemCityDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxSystemCityDto.java new file mode 100644 index 00000000..d3abe900 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxSystemCityDto.java @@ -0,0 +1,50 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxSystemCityDto implements Serializable { + + private Integer id; + + /** 城市id */ + private Integer cityId; + + /** 省市级别 */ + private Integer level; + + /** 父级id */ + private Integer parentId; + + /** 区号 */ + private String areaCode; + + /** 名称 */ + private String name; + + /** 合并名称 */ + private String mergerName; + + /** 经度 */ + private String lng; + + /** 纬度 */ + private String lat; + + /** 是否展示 */ + private Integer isShow; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxSystemCityQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxSystemCityQueryCriteria.java new file mode 100644 index 00000000..ba72a3de --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/dto/YxSystemCityQueryCriteria.java @@ -0,0 +1,19 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Data +public class YxSystemCityQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesFreeServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesFreeServiceImpl.java new file mode 100644 index 00000000..d042be81 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesFreeServiceImpl.java @@ -0,0 +1,82 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.impl; + + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.template.domain.YxShippingTemplatesFree; +import co.yixiang.modules.template.service.YxShippingTemplatesFreeService; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesFreeDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesFreeQueryCriteria; +import co.yixiang.modules.template.service.mapper.YxShippingTemplatesFreeMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxShippingTemplatesFreeServiceImpl extends BaseServiceImpl implements YxShippingTemplatesFreeService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxShippingTemplatesFreeQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxShippingTemplatesFreeDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxShippingTemplatesFreeQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxShippingTemplatesFree.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxShippingTemplatesFreeDto yxShippingTemplatesFree : all) { + Map map = new LinkedHashMap<>(); + map.put("省ID", yxShippingTemplatesFree.getProvinceId()); + map.put("模板ID", yxShippingTemplatesFree.getTempId()); + map.put("城市ID", yxShippingTemplatesFree.getCityId()); + map.put("包邮件数", yxShippingTemplatesFree.getNumber()); + map.put("包邮金额", yxShippingTemplatesFree.getPrice()); + map.put("计费方式", yxShippingTemplatesFree.getType()); + map.put("分组唯一值", yxShippingTemplatesFree.getUniqid()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesRegionServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesRegionServiceImpl.java new file mode 100644 index 00000000..8119c1a7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesRegionServiceImpl.java @@ -0,0 +1,89 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.impl; + + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.template.domain.YxShippingTemplatesRegion; +import co.yixiang.modules.template.service.YxShippingTemplatesRegionService; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesRegionDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesRegionQueryCriteria; +import co.yixiang.modules.template.service.mapper.YxShippingTemplatesRegionMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "yxShippingTemplatesRegion") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxShippingTemplatesRegionServiceImpl extends BaseServiceImpl implements YxShippingTemplatesRegionService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxShippingTemplatesRegionQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxShippingTemplatesRegionDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxShippingTemplatesRegionQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxShippingTemplatesRegion.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxShippingTemplatesRegionDto yxShippingTemplatesRegion : all) { + Map map = new LinkedHashMap<>(); + map.put("省ID", yxShippingTemplatesRegion.getProvinceId()); + map.put("模板ID", yxShippingTemplatesRegion.getTempId()); + map.put("城市ID", yxShippingTemplatesRegion.getCityId()); + map.put("首件", yxShippingTemplatesRegion.getFirst()); + map.put("首件运费", yxShippingTemplatesRegion.getFirstPrice()); + map.put("续件", yxShippingTemplatesRegion.getContinues()); + map.put("续件运费", yxShippingTemplatesRegion.getContinuePrice()); + map.put("计费方式", yxShippingTemplatesRegion.getType()); + map.put("分组唯一值", yxShippingTemplatesRegion.getUniqid()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesServiceImpl.java new file mode 100644 index 00000000..17fb1b7b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxShippingTemplatesServiceImpl.java @@ -0,0 +1,257 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.IdUtil; +import co.yixiang.api.BusinessException; +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.modules.template.domain.YxShippingTemplates; +import co.yixiang.modules.template.domain.YxShippingTemplatesFree; +import co.yixiang.modules.template.domain.YxShippingTemplatesRegion; +import co.yixiang.modules.template.service.YxShippingTemplatesFreeService; +import co.yixiang.modules.template.service.YxShippingTemplatesRegionService; +import co.yixiang.modules.template.service.YxShippingTemplatesService; +import co.yixiang.modules.template.service.dto.AppointInfoDto; +import co.yixiang.modules.template.service.dto.RegionChildrenDto; +import co.yixiang.modules.template.service.dto.RegionDto; +import co.yixiang.modules.template.service.dto.RegionInfoDto; +import co.yixiang.modules.template.service.dto.ShippingTemplatesDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesDto; +import co.yixiang.modules.template.service.dto.YxShippingTemplatesQueryCriteria; +import co.yixiang.modules.template.service.mapper.YxShippingTemplatesMapper; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxShippingTemplatesServiceImpl extends BaseServiceImpl implements YxShippingTemplatesService { + + private final IGenerator generator; + + + private final YxShippingTemplatesRegionService yxShippingTemplatesRegionService; + private final YxShippingTemplatesFreeService yxShippingTemplatesFreeService; + + + /** + * 新增与更新模板 + * @param id 模板id + * @param shippingTemplatesDto ShippingTemplatesDto + */ + @Override + public void addAndUpdate(Integer id,ShippingTemplatesDto shippingTemplatesDto) { + if(ShopCommonEnum.ENABLE_1.getValue().equals(shippingTemplatesDto.getAppoint()) + && shippingTemplatesDto.getAppointInfo().isEmpty()){ + throw new YshopException("请指定包邮地区"); + } + YxShippingTemplates shippingTemplates = new YxShippingTemplates(); + BeanUtil.copyProperties(shippingTemplatesDto,shippingTemplates); + shippingTemplates.setRegionInfo(JSON.toJSONString(shippingTemplatesDto.getRegionInfo())); + shippingTemplates.setAppointInfo(JSON.toJSONString(shippingTemplatesDto.getAppointInfo())); + if(id != null && id > 0){ + shippingTemplates.setId(id); + this.updateById(shippingTemplates); + }else{ + this.save(shippingTemplates); + } + + this.saveRegion(shippingTemplatesDto,shippingTemplates.getId()); + this.saveFreeReigion(shippingTemplatesDto,shippingTemplates.getId()); + } + + @Override + //@Cacheable + public Map queryAll(YxShippingTemplatesQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxShippingTemplatesDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxShippingTemplatesQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxShippingTemplates.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxShippingTemplatesDto yxShippingTemplates : all) { + Map map = new LinkedHashMap<>(); + map.put("模板名称", yxShippingTemplates.getName()); + map.put("计费方式", yxShippingTemplates.getType()); + map.put("地域以及费用", yxShippingTemplates.getRegionInfo()); + map.put("指定包邮开关", yxShippingTemplates.getAppoint()); + map.put("指定包邮内容", yxShippingTemplates.getAppointInfo()); + map.put("添加时间", yxShippingTemplates.getCreateTime()); + map.put(" updateTime", yxShippingTemplates.getUpdateTime()); + map.put(" isDel", yxShippingTemplates.getIsDel()); + map.put("排序", yxShippingTemplates.getSort()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 保存包邮区域 + * @param yxShippingTemplates ShippingTemplatesDto + * @param tempId 模板id + */ + private void saveFreeReigion(ShippingTemplatesDto yxShippingTemplates,Integer tempId){ + + if(yxShippingTemplates.getAppointInfo() == null + || yxShippingTemplates.getAppointInfo().isEmpty()){ + return; + } + + Long count = yxShippingTemplatesFreeService.count(Wrappers + .lambdaQuery() + .eq(YxShippingTemplatesFree::getTempId,tempId)); + if(count > 0) { + yxShippingTemplatesFreeService.remove(Wrappers + .lambdaQuery() + .eq(YxShippingTemplatesFree::getTempId,tempId)); + } + + List shippingTemplatesFrees = new ArrayList<>(); + + + List appointInfo = yxShippingTemplates.getAppointInfo(); + for (AppointInfoDto appointInfoDto : appointInfo){ + String uni = IdUtil.simpleUUID(); + + if(appointInfoDto.getPlace() != null && !appointInfoDto.getPlace().isEmpty()){ + for (RegionDto regionDto : appointInfoDto.getPlace()){ + if(regionDto.getChildren() != null && !regionDto.getChildren().isEmpty()){ + for (RegionChildrenDto childrenDto : regionDto.getChildren()){ + YxShippingTemplatesFree shippingTemplatesFree = YxShippingTemplatesFree.builder() + .tempId(tempId) + .number(new BigDecimal(appointInfoDto.getA_num())) + .price(new BigDecimal(appointInfoDto.getA_price())) + .type(yxShippingTemplates.getType()) + .uniqid(uni) + .provinceId(Integer.valueOf(regionDto.getCity_id())) + .cityId(Integer.valueOf(childrenDto.getCity_id())) + .build(); + shippingTemplatesFrees.add(shippingTemplatesFree); + } + } + } + } + } + + + if(shippingTemplatesFrees.isEmpty()) { + throw new YshopException("请添加包邮区域"); + } + + yxShippingTemplatesFreeService.saveBatch(shippingTemplatesFrees); + + + } + + /** + * 保存模板设置的区域价格 + * @param yxShippingTemplates ShippingTemplatesDTO + * @param tempId 运费模板id + */ + private void saveRegion(ShippingTemplatesDto yxShippingTemplates,Integer tempId){ + Long count = yxShippingTemplatesRegionService.count(Wrappers + .lambdaQuery() + .eq(YxShippingTemplatesRegion::getTempId,tempId)); + if(count > 0) { + yxShippingTemplatesRegionService.remove(Wrappers + .lambdaQuery() + .eq(YxShippingTemplatesRegion::getTempId,tempId)); + } + + List shippingTemplatesRegions = new ArrayList<>(); + + + List regionInfo = yxShippingTemplates.getRegionInfo(); + + + for (RegionInfoDto regionInfoDto : regionInfo){ + String uni = IdUtil.simpleUUID(); + if(regionInfoDto.getRegion() != null && !regionInfoDto.getRegion().isEmpty()){ + for (RegionDto regionDto : regionInfoDto.getRegion()){ + if(regionDto.getChildren() != null && !regionDto.getChildren().isEmpty()){ + for (RegionChildrenDto childrenDtp : regionDto.getChildren()){ + YxShippingTemplatesRegion shippingTemplatesRegion = YxShippingTemplatesRegion.builder() + .tempId(tempId) + .first(new BigDecimal(regionInfoDto.getFirst())) + .firstPrice(new BigDecimal(regionInfoDto.getPrice())) + .continues(new BigDecimal(regionInfoDto.get_continue())) + .continuePrice(new BigDecimal(regionInfoDto.getContinue_price())) + .type(yxShippingTemplates.getType()) + .uniqid(uni) + .provinceId(Integer.valueOf(regionDto.getCity_id())) + .cityId(Integer.valueOf(childrenDtp.getCity_id())) + .build(); + shippingTemplatesRegions.add(shippingTemplatesRegion); + } + }else{ + YxShippingTemplatesRegion shippingTemplatesRegion = YxShippingTemplatesRegion.builder() + .tempId(tempId) + .first(new BigDecimal(regionInfoDto.getFirst())) + .firstPrice(new BigDecimal(regionInfoDto.getPrice())) + .continues(new BigDecimal(regionInfoDto.get_continue())) + .continuePrice(new BigDecimal(regionInfoDto.getContinue_price())) + .type(yxShippingTemplates.getType()) + .uniqid(uni) + .provinceId(Integer.valueOf(regionDto.getCity_id())) + .build(); + shippingTemplatesRegions.add(shippingTemplatesRegion); + } + } + } + } + + if(shippingTemplatesRegions.isEmpty()) { + throw new BusinessException("请添加区域"); + } + + yxShippingTemplatesRegionService.saveBatch(shippingTemplatesRegions); + + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxSystemCityServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxSystemCityServiceImpl.java new file mode 100644 index 00000000..6993e71f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/impl/YxSystemCityServiceImpl.java @@ -0,0 +1,83 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.template.domain.YxSystemCity; +import co.yixiang.modules.template.service.YxSystemCityService; +import co.yixiang.modules.template.service.dto.YxSystemCityDto; +import co.yixiang.modules.template.service.dto.YxSystemCityQueryCriteria; +import co.yixiang.modules.template.service.mapper.YxSystemCityMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemCityServiceImpl extends BaseServiceImpl implements YxSystemCityService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(YxSystemCityQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxSystemCityDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemCityQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemCity.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemCityDto yxSystemCity : all) { + Map map = new LinkedHashMap<>(); + map.put("城市id", yxSystemCity.getCityId()); + map.put("省市级别", yxSystemCity.getLevel()); + map.put("父级id", yxSystemCity.getParentId()); + map.put("区号", yxSystemCity.getAreaCode()); + map.put("名称", yxSystemCity.getName()); + map.put("合并名称", yxSystemCity.getMergerName()); + map.put("经度", yxSystemCity.getLng()); + map.put("纬度", yxSystemCity.getLat()); + map.put("是否展示", yxSystemCity.getIsShow()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesFreeMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesFreeMapper.java new file mode 100644 index 00000000..916a3b9e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesFreeMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.template.domain.YxShippingTemplatesFree; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Repository +public interface YxShippingTemplatesFreeMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesMapper.java new file mode 100644 index 00000000..597de537 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.template.domain.YxShippingTemplates; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Repository +public interface YxShippingTemplatesMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesRegionMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesRegionMapper.java new file mode 100644 index 00000000..138368cf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxShippingTemplatesRegionMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.template.domain.YxShippingTemplatesRegion; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Repository +public interface YxShippingTemplatesRegionMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxSystemCityMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxSystemCityMapper.java new file mode 100644 index 00000000..1c6e3336 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/template/service/mapper/YxSystemCityMapper.java @@ -0,0 +1,22 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.template.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.template.domain.YxSystemCity; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-06-29 +*/ +@Repository +public interface YxSystemCityMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxSystemUserTask.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxSystemUserTask.java new file mode 100644 index 00000000..7a0c55bc --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxSystemUserTask.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@TableName("yx_system_user_task") +public class YxSystemUserTask extends BaseDomain { + + @TableId + private Integer id; + + + /** 任务名称 */ + private String name; + + + /** 配置原名 */ + private String realName; + + + /** 任务类型 */ + private String taskType; + + + /** 限定数 */ + private Integer number; + + + /** 等级id */ + private Integer levelId; + + + /** 排序 */ + private Integer sort; + + + /** 是否显示 */ + private Integer isShow; + + + /** 是否务必达成任务,1务必达成,0=满足其一 */ + private Integer isMust; + + + /** 任务说明 */ + private String illustrate; + + + public void copy(YxSystemUserTask source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUser.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUser.java new file mode 100644 index 00000000..9f73e7fe --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUser.java @@ -0,0 +1,173 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import co.yixiang.modules.user.service.dto.WechatUserDto; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Builder +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +@ToString +@TableName(value = "yx_user",autoResultMap = true) +public class YxUser extends BaseDomain { + + /** 用户id */ + @TableId(value = "uid", type = IdType.AUTO) + private Long uid; + + + /** 用户账户(跟accout一样) */ + private String username; + + + + + /** 用户密码(跟pwd) */ + private String password; + + + + /** 真实姓名 */ + private String realName; + + + /** 生日 */ + private Integer birthday; + + + /** 身份证号码 */ + private String cardId; + + + /** 用户备注 */ + private String mark; + + + /** 合伙人id */ + private Integer partnerId; + + + /** 用户分组id */ + private Integer groupId; + + + /** 用户昵称 */ + private String nickname; + + + /** 用户头像 */ + private String avatar; + + + /** 手机号码 */ + private String phone; + + + + /** 添加ip */ + private String addIp; + + + + /** 最后一次登录ip */ + private String lastIp; + + + /** 用户余额 */ + private BigDecimal nowMoney; + + + /** 佣金金额 */ + private BigDecimal brokeragePrice; + + + /** 用户剩余积分 */ + private BigDecimal integral; + + + /** 连续签到天数 */ + private Integer signNum; + + + /** 1为正常,0为禁止 */ + private Integer status; + + + /** 等级 */ + private Integer level; + + + /** 推广元id */ + private Long spreadUid; + + + /** 推广员关联时间 */ + private Date spreadTime; + + + /** 用户类型 */ + private String userType; + + + /** 是否为推广员 */ + private Integer isPromoter; + + + /** 用户购买次数 */ + private Long payCount; + + + /** 下级人数 */ + private Long spreadCount; + + + + /** 详细地址 */ + private String addres; + + + /** 管理员编号 */ + private Integer adminid; + + + /** 用户登陆类型,h5,wechat,routine */ + private String loginType; + + /** 微信用户json信息 */ + @TableField(typeHandler = FastjsonTypeHandler.class) + private WechatUserDto wxProfile; + + + public void copy(YxUser source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserAddress.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserAddress.java new file mode 100644 index 00000000..fc8a2d38 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserAddress.java @@ -0,0 +1,72 @@ +package co.yixiang.modules.user.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + *

+ * 用户地址表 + *

+ * + * @author hupeng + * @since 2019-10-28 + */ +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@ApiModel(value = "YxUserAddress对象", description = "用户地址表") +public class YxUserAddress extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户地址id") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "用户id") + private Long uid; + + @ApiModelProperty(value = "收货人姓名") + private String realName; + + @ApiModelProperty(value = "收货人电话") + private String phone; + + @ApiModelProperty(value = "收货人所在省") + private String province; + + @ApiModelProperty(value = "收货人所在市") + private String city; + + private Integer cityId; + + @ApiModelProperty(value = "收货人所在区") + private String district; + + @ApiModelProperty(value = "收货人详细地址") + private String detail; + + @ApiModelProperty(value = "邮编") + private String postCode; + + @ApiModelProperty(value = "经度") + private String longitude; + + @ApiModelProperty(value = "纬度") + private String latitude; + + @ApiModelProperty(value = "是否默认") + private Integer isDefault; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserBill.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserBill.java new file mode 100644 index 00000000..12458595 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserBill.java @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName("yx_user_bill") +public class YxUserBill extends BaseDomain { + + /** 用户账单id */ + @TableId + private Long id; + + + /** 用户uid */ + private Long uid; + + + /** 关联id */ + private String linkId; + + + /** 0 = 支出 1 = 获得 */ + private Integer pm; + + + /** 账单标题 */ + private String title; + + + /** 明细种类 */ + private String category; + + + /** 明细类型 */ + private String type; + + + /** 明细数字 */ + private BigDecimal number; + + + /** 剩余 */ + private BigDecimal balance; + + + /** 备注 */ + private String mark; + + + + /** 0 = 带确定 1 = 有效 -1 = 无效 */ + private Integer status; + + + public void copy(YxUserBill source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserLevel.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserLevel.java new file mode 100644 index 00000000..89fda054 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserLevel.java @@ -0,0 +1,60 @@ +package co.yixiang.modules.user.domain; + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户等级记录表 + *

+ * + * @author hupeng + * @since 2019-12-06 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "YxUserLevel对象", description = "用户等级记录表") +public class YxUserLevel extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "用户uid") + private Long uid; + + @ApiModelProperty(value = "等级vip") + private Integer levelId; + + @ApiModelProperty(value = "会员等级") + private Integer grade; + + @ApiModelProperty(value = "过期时间") + private Integer validTime; + + @ApiModelProperty(value = "是否永久") + private Integer isForever; + + @ApiModelProperty(value = "商户id") + private Integer merId; + + @ApiModelProperty(value = "0:禁止,1:正常") + private Integer status; + + @ApiModelProperty(value = "备注") + private String mark; + + @ApiModelProperty(value = "是否已通知") + private Integer remind; + + + @ApiModelProperty(value = "享受折扣") + private Integer discount; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserRecharge.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserRecharge.java new file mode 100644 index 00000000..a252a303 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserRecharge.java @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ + +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_user_recharge") +public class YxUserRecharge extends BaseDomain { + + @TableId + private Long id; + + + /** 充值用户UID */ + private Long uid; + + + /** 订单号 */ + private String orderId; + + + /** 充值金额 */ + private BigDecimal price; + + private BigDecimal givePrice; + + + /** 充值类型 */ + private String rechargeType; + + + /** 是否充值 */ + private Integer paid; + + + /** 充值支付时间 */ + private Date payTime; + + + + /** 退款金额 */ + private BigDecimal refundPrice; + + + /** 昵称 */ + private String nickname; + + + public void copy(YxUserRecharge source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserSign.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserSign.java new file mode 100644 index 00000000..13219869 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserSign.java @@ -0,0 +1,48 @@ +package co.yixiang.modules.user.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + *

+ * 签到记录表 + *

+ * + * @author hupeng + * @since 2019-12-05 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "YxUserSign对象", description = "签到记录表") +public class YxUserSign extends BaseDomain { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "用户uid") + private Long uid; + + @ApiModelProperty(value = "签到说明") + private String title; + + @ApiModelProperty(value = "获得积分") + private Integer number; + + @ApiModelProperty(value = "剩余积分") + private Integer balance; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserTaskFinish.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserTaskFinish.java new file mode 100644 index 00000000..d74bfa1f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/domain/YxUserTaskFinish.java @@ -0,0 +1,39 @@ +package co.yixiang.modules.user.domain; + + +import co.yixiang.domain.BaseDomain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户任务完成记录表 + *

+ * + * @author hupeng + * @since 2019-12-07 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("yx_user_task_finish") +public class YxUserTaskFinish extends BaseDomain { + + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "任务id") + private Integer taskId; + + @ApiModelProperty(value = "用户id") + private Long uid; + + @ApiModelProperty(value = "是否有效") + private Integer status; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/param/AddressDetailParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/param/AddressDetailParam.java new file mode 100644 index 00000000..5b5513c5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/param/AddressDetailParam.java @@ -0,0 +1,29 @@ +package co.yixiang.modules.user.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName AddressDetailParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/28 + **/ +@Data +public class AddressDetailParam implements Serializable { + + @JsonProperty(value = "city_id") + @ApiModelProperty(value = "城市ID") + private Integer cityId; + + @ApiModelProperty(value = "城市") + private String city; + + @ApiModelProperty(value = "地区") + private String district; + + @ApiModelProperty(value = "省份") + private String province; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/param/AddressParam.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/param/AddressParam.java new file mode 100644 index 00000000..75f795f5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/param/AddressParam.java @@ -0,0 +1,46 @@ +package co.yixiang.modules.user.param; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * @ClassName AddressParam + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/28 + **/ +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class AddressParam implements Serializable { + + @ApiModelProperty(value = "地址ID") + private String id; + @NotBlank + @Size(min = 1, max = 30,message = "长度超过了限制") + @ApiModelProperty(value = "收货地址真实名字") + private String real_name; + + @ApiModelProperty(value = "收货地址邮编") + private String post_code; + + @ApiModelProperty(value = "是否默认收货地址 true是 false否") + private String is_default; + + private String wx_export; + + @NotBlank + @Size(min = 1, max = 60,message = "长度超过了限制") + @ApiModelProperty(value = "收货详细地址") + private String detail; + + @NotBlank + @ApiModelProperty(value = "收货手机号码") + private String phone; + + @ApiModelProperty(value = "收货地址详情") + private AddressDetailParam address; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/MemberController.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/MemberController.java new file mode 100644 index 00000000..4a497319 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/MemberController.java @@ -0,0 +1,105 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.dto.UserMoneyDto; +import co.yixiang.modules.user.service.dto.YxUserQueryCriteria; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-10-06 +*/ +@Api(tags = "商城:会员管理") +@RestController +@RequestMapping("api") +public class MemberController { + + private final YxUserService yxUserService; + + public MemberController(YxUserService yxUserService) { + this.yxUserService = yxUserService; + } + + @Log("查看下级") + @ApiOperation(value = "查看下级") + @PostMapping(value = "/yxUser/spread") + @PreAuthorize("hasAnyRole('admin','YXUSER_ALL','YXUSER_EDIT')") + public ResponseEntity getSpread(@RequestBody YxUserQueryCriteria criteria){ + return new ResponseEntity<>(yxUserService.querySpread(criteria.getUid(),criteria.getGrade()), + HttpStatus.OK); + } + + @Log("查询用户") + @ApiOperation(value = "查询用户") + @GetMapping(value = "/yxUser") + @PreAuthorize("hasAnyRole('admin','YXUSER_ALL','YXUSER_SELECT')") + public ResponseEntity getYxUsers(YxUserQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxUserService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + @Log("修改用户") + @ApiOperation(value = "修改用户") + @PutMapping(value = "/yxUser") + @PreAuthorize("hasAnyRole('admin','YXUSER_ALL','YXUSER_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxUser resources){ + yxUserService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除用户") + @ApiOperation(value = "删除用户") + @DeleteMapping(value = "/yxUser/{uid}") + @PreAuthorize("hasAnyRole('admin','YXUSER_ALL','YXUSER_DELETE')") + public ResponseEntity delete(@PathVariable Integer uid){ + yxUserService.removeById(uid); + return new ResponseEntity(HttpStatus.OK); + } + + @ForbidSubmit + @ApiOperation(value = "用户禁用启用") + @PostMapping(value = "/yxUser/onStatus/{id}") + public ResponseEntity onStatus(@PathVariable Long id,@RequestBody String jsonStr){ + JSONObject jsonObject = JSON.parseObject(jsonStr); + Integer status = jsonObject.getInteger("status"); + yxUserService.onStatus(id,status); + return new ResponseEntity(HttpStatus.OK); + } + + @ApiOperation(value = "修改余额") + @PostMapping(value = "/yxUser/money") + @PreAuthorize("hasAnyRole('admin','YXUSER_ALL','YXUSER_EDIT')") + public ResponseEntity updatePrice(@Validated @RequestBody UserMoneyDto param){ + yxUserService.updateMoney(param); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserLevelController.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserLevelController.java new file mode 100644 index 00000000..1cffd7d4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserLevelController.java @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.shop.domain.YxSystemUserLevel; +import co.yixiang.modules.user.service.YxSystemUserLevelService; +import co.yixiang.modules.user.service.dto.YxSystemUserLevelQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-12-04 +*/ +@Api(tags = "商城:用户等级管理") +@RestController +@RequestMapping("api") +public class SystemUserLevelController { + + private final YxSystemUserLevelService yxSystemUserLevelService; + + public SystemUserLevelController(YxSystemUserLevelService yxSystemUserLevelService) { + this.yxSystemUserLevelService = yxSystemUserLevelService; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxSystemUserLevel") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_SELECT')") + public ResponseEntity getYxSystemUserLevels(YxSystemUserLevelQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxSystemUserLevelService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @Log("新增") + @ApiOperation(value = "新增") + @PostMapping(value = "/yxSystemUserLevel") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxSystemUserLevel resources){ + return new ResponseEntity<>(yxSystemUserLevelService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @Log("修改") + @ApiOperation(value = "修改") + @PutMapping(value = "/yxSystemUserLevel") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxSystemUserLevel resources){ + yxSystemUserLevelService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxSystemUserLevel/{id}") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERLEVEL_ALL','YXSYSTEMUSERLEVEL_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxSystemUserLevelService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserTaskController.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserTaskController.java new file mode 100644 index 00000000..49bab01a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/SystemUserTaskController.java @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.user.domain.YxSystemUserTask; +import co.yixiang.modules.user.service.YxSystemUserTaskService; +import co.yixiang.modules.user.service.dto.YxSystemUserTaskQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-12-04 +*/ +@Api(tags = "商城:用户任务管理") +@RestController +@RequestMapping("api") +public class SystemUserTaskController { + + private final YxSystemUserTaskService yxSystemUserTaskService; + + public SystemUserTaskController(YxSystemUserTaskService yxSystemUserTaskService) { + this.yxSystemUserTaskService = yxSystemUserTaskService; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxSystemUserTask") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERTASK_ALL','YXSYSTEMUSERTASK_SELECT')") + public ResponseEntity getYxSystemUserTasks(YxSystemUserTaskQueryCriteria criteria, + Pageable pageable){ + Sort sort = Sort.by(Sort.Direction.ASC, "level_id"); + Pageable pageableT = PageRequest.of(pageable.getPageNumber(), + pageable.getPageSize(), + sort); + return new ResponseEntity(yxSystemUserTaskService.queryAll(criteria,pageableT), + HttpStatus.OK); + } + + @Log("新增") + @ApiOperation(value = "新增") + @PostMapping(value = "/yxSystemUserTask") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERTASK_ALL','YXSYSTEMUSERTASK_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxSystemUserTask resources){ + return new ResponseEntity(yxSystemUserTaskService.save(resources),HttpStatus.CREATED); + } + + @Log("修改") + @ApiOperation(value = "修改") + @PutMapping(value = "/yxSystemUserTask") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERTASK_ALL','YXSYSTEMUSERTASK_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxSystemUserTask resources){ + //if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作"); + yxSystemUserTaskService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @Log("删除") + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxSystemUserTask/{id}") + @PreAuthorize("hasAnyRole('admin','YXSYSTEMUSERTASK_ALL','YXSYSTEMUSERTASK_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + //if(StrUtil.isNotEmpty("22")) throw new BadRequestException("演示环境禁止操作"); + yxSystemUserTaskService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/UserBillController.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/UserBillController.java new file mode 100644 index 00000000..40f5c09d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/UserBillController.java @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.dto.YxUserBillQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-11-06 +*/ +@Api(tags = "商城:用户账单管理") +@RestController +@RequestMapping("api") +public class UserBillController { + + private final YxUserBillService yxUserBillService; + + public UserBillController(YxUserBillService yxUserBillService) { + this.yxUserBillService = yxUserBillService; + } + + @Log("查询") + @ApiOperation(value = "查询") + @GetMapping(value = "/yxUserBill") + @PreAuthorize("hasAnyRole('admin','YXUSERBILL_ALL','YXUSERBILL_SELECT')") + public ResponseEntity getYxUserBills(YxUserBillQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxUserBillService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/UserRechargeController.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/UserRechargeController.java new file mode 100644 index 00000000..b22e96f6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/rest/UserRechargeController.java @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.user.service.dto.YxUserRechargeDto; +import co.yixiang.modules.user.service.dto.YxUserRechargeQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +/** +* @author hupeng +* @date 2020-03-02 +*/ +@Api(tags = "充值管理管理") +@RestController +@RequestMapping("/api/yxUserRecharge") +public class UserRechargeController { + + private final YxUserRechargeService yxUserRechargeService; + private final IGenerator generator; + public UserRechargeController(YxUserRechargeService yxUserRechargeService, IGenerator generator) { + this.yxUserRechargeService = yxUserRechargeService; + this.generator = generator; + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('yxUserRecharge:list')") + public void download(HttpServletResponse response, YxUserRechargeQueryCriteria criteria) throws IOException { + yxUserRechargeService.download(generator.convert(yxUserRechargeService.queryAll(criteria), YxUserRechargeDto.class), response); + } + + @GetMapping + @Log("查询充值管理") + @ApiOperation("查询充值管理") + @PreAuthorize("@ss.hasAnyPermissions('yxUserRecharge:list')") + public ResponseEntity getYxUserRecharges(YxUserRechargeQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxUserRechargeService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + + + @ForbidSubmit + @Log("删除充值管理") + @ApiOperation("删除充值管理") + @PreAuthorize("@ss.hasAnyPermissions('yxUserRecharge:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Integer[] ids) { + yxUserRechargeService.removeByIds(new ArrayList<>(Arrays.asList(ids))); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxSystemUserLevelService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxSystemUserLevelService.java new file mode 100644 index 00000000..25b4877e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxSystemUserLevelService.java @@ -0,0 +1,68 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.shop.domain.YxSystemUserLevel; +import co.yixiang.modules.user.service.dto.UserLevelDto; +import co.yixiang.modules.user.service.dto.YxSystemUserLevelDto; +import co.yixiang.modules.user.service.dto.YxSystemUserLevelQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxSystemUserLevelService extends BaseService{ + + + /** + * 获取当前的下一个会员等级id + * @param levelId 等级id + * @return int + */ + int getNextLevelId(int levelId); + + //boolean getClear(int levelId); + + + /** + * 获取会员等级列表及其任务列表 + * @return UserLevelDto + */ + UserLevelDto getLevelInfo(Long uid); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemUserLevelQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemUserLevelQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxSystemUserTaskService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxSystemUserTaskService.java new file mode 100644 index 00000000..9be0cda6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxSystemUserTaskService.java @@ -0,0 +1,68 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxSystemUserTask; +import co.yixiang.modules.user.service.dto.TaskDto; +import co.yixiang.modules.user.service.dto.YxSystemUserTaskDto; +import co.yixiang.modules.user.service.dto.YxSystemUserTaskQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxSystemUserTaskService extends BaseService{ + + + /** + * 获取已经完成的任务数量 + * @param levelId 等级id + * @param uid uid + * @return int + */ + Long getTaskComplete(int levelId,Long uid); + + /** + * 获取等级会员任务列表 + * @param levelId 等级id + * @param uid uid + * @return TaskDto + */ + TaskDto getTaskList(int levelId, Long uid); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxSystemUserTaskQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxSystemUserTaskQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserAddressService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserAddressService.java new file mode 100644 index 00000000..37d49739 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserAddressService.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxUserAddress; +import co.yixiang.modules.user.param.AddressParam; +import co.yixiang.modules.user.vo.YxUserAddressQueryVo; + +import java.util.List; + +/** + *

+ * 用户地址表 服务类 + *

+ * + * @author hupeng + * @since 2019-10-28 + */ +public interface YxUserAddressService extends BaseService { + + /** + * 设置默认地址 + * @param uid uid + * @param addressId 地址id + */ + void setDefault(Long uid,Long addressId); + + /** + * 添加或者修改地址 + * @param uid uid + * @param param AddressParam + */ + Long addAndEdit(Long uid, AddressParam param); + + /** + * 地址详情 + * @param id 地址id + * @return YxUserAddressQueryVo + */ + YxUserAddressQueryVo getDetail(Long id); + + /** + * 获取用户地址 + * @param uid uid + * @param page page + * @param limit limit + * @return List + */ + List getList(Long uid,int page,int limit); + + /** + * 获取默认地址 + * @param uid uid + * @return YxUserAddress + */ + YxUserAddress getUserDefaultAddress(Long uid); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserBillService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserBillService.java new file mode 100644 index 00000000..5e9f8980 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserBillService.java @@ -0,0 +1,119 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxUserBill; +import co.yixiang.modules.user.service.dto.YxUserBillDto; +import co.yixiang.modules.user.service.dto.YxUserBillQueryCriteria; +import co.yixiang.modules.user.vo.BillVo; +import co.yixiang.modules.user.vo.YxUserBillQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxUserBillService extends BaseService{ + + /** + * 增加支出流水 + * @param uid uid + * @param title 账单标题 + * @param category 明细种类 + * @param type 明细类型 + * @param number 明细数字 + * @param balance 剩余 + * @param mark 备注 + */ + void expend(Long uid,String title,String category,String type,double number,double balance,String mark); + + /** + * 增加收入/支入流水 + * @param uid uid + * @param title 账单标题 + * @param category 明细种类 + * @param type 明细类型 + * @param number 明细数字 + * @param balance 剩余 + * @param mark 备注 + * @param linkid 关联id + */ + void income(Long uid,String title,String category,String type,double number, + double balance,String mark,String linkid); + + Long cumulativeAttendance(Long uid); + + /** + * 获取推广订单列表 + * @param uid uid + * @param page page + * @param limit limit + * @return Map + */ + Map spreadOrder(Long uid,int page,int limit); + + /** + * 获取用户账单记录 + * @param page page + * @param limit limit + * @param uid uid + * @param type BillDetailEnum + * @return map + */ + Map getUserBillList(int page, int limit, long uid, int type); + + + double getBrokerage(int uid); + + /** + * 统计昨天的佣金 + * @param uid uid + * @return double + */ + double yesterdayCommissionSum(Long uid); + + /** + * 根据类别获取账单记录 + * @param uid uid + * @param category BillDetailEnum + * @param page page + * @param limit limit + * @return List + */ + List userBillList(Long uid,String category,int page,int limit); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxUserBillQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxUserBillQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserLevelService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserLevelService.java new file mode 100644 index 00000000..08f57e51 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserLevelService.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxUserLevel; + + +/** + *

+ * 用户等级记录表 服务类 + *

+ * + * @author hupeng + * @since 2019-12-06 + */ +public interface YxUserLevelService extends BaseService { + + + /** + * 检查是否能成为会员 + * @param uid 用户id + */ + boolean setLevelComplete(Long uid); + + //UserLevelInfoDto getUserLevelInfo(int id); + + /** + * 获取当前用户会员等级返回当前用户等级 + * @param uid uid + * @param grade 用户级别 + * @return YxUserLevel + */ + YxUserLevel getUserLevel(Long uid, Integer grade); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserRechargeService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserRechargeService.java new file mode 100644 index 00000000..9b32fae0 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserRechargeService.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserRecharge; +import co.yixiang.modules.user.service.dto.YxUserRechargeDto; +import co.yixiang.modules.user.service.dto.YxUserRechargeQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxUserRechargeService extends BaseService{ + + + void updateRecharge(YxUserRecharge userRecharge); + + YxUserRecharge getInfoByOrderId(String orderId); + + /** + * 添加充值记录 + * @param user 用户 + * @param price 充值金额 + * @param paidPrice 赠送金额 + */ + String addRecharge(YxUser user, String price, String paidPrice); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxUserRechargeQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxUserRechargeQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserService.java new file mode 100644 index 00000000..7175843e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserService.java @@ -0,0 +1,192 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.dto.PromUserDto; +import co.yixiang.modules.user.service.dto.UserMoneyDto; +import co.yixiang.modules.user.service.dto.YxUserDto; +import co.yixiang.modules.user.service.dto.YxUserQueryCriteria; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +public interface YxUserService extends BaseService{ + + /** + * 返回用户累计充值金额与消费金额 + * @param uid uid + * @return Double[] + */ + Double[] getUserMoney(Long uid); + + /** + * 一级返佣 + * @param order 订单 + */ + void backOrderBrokerage(YxStoreOrderQueryVo order); + + + + /** + * 统计分销人员 + * @param uid uid + * @return map + */ + Map getSpreadCount(Long uid); + + /** + * 获取我的分销下人员列表 + * @param uid uid + * @param page page + * @param limit limit + * @param grade ShopCommonEnum.GRADE_0 + * @param keyword 关键字搜索 + * @param sort 排序 + * @return list + */ + List getUserSpreadGrade(Long uid, int page, int limit, Integer grade, String keyword, String sort); + + /** + * 减去用户积分 + * @param uid 用户id + * @param integral 积分 + */ + void decIntegral(Long uid,double integral); + + /** + * 增加购买次数 + * @param uid uid + */ + void incPayCount(Long uid); + + /** + * 减去用户余额 + * @param uid uid + * @param payPrice 金额 + */ + void decPrice(Long uid, BigDecimal payPrice); + + // YxUser findByName(String name); + + /** + * 更新用户余额 + * @param uid y用户id + * @param price 金额 + */ + void incMoney(Long uid,BigDecimal price); + + /** + * 增加积分 + * @param uid uid + * @param integral 积分 + */ + void incIntegral(Long uid,double integral); + + /** + * 获取用户信息 + * @param uid uid + * @return YxUserQueryVo + */ + YxUserQueryVo getYxUserById(Long uid); + + /** + * 获取用户个人详细信息 + * @param yxUser yxUser + * @return YxUserQueryVo + */ + YxUserQueryVo getNewYxUserById(YxUser yxUser); + + /** + * 转换用户信息 + * @param yxUser user + * @return YxUserQueryVo + */ + YxUserQueryVo handleUser(YxUser yxUser); + + /** + * 返回会员价 + * @param price 原价 + * @param uid 用户id + * @return vip 价格 + */ + double setLevelPrice(double price, long uid); + + /** + * 设置推广关系 + * @param spread 上级人 + * @param uid 本人 + */ + void setSpread(String spread, long uid); + + + /** + * 查看下级 + * @param uid uid + * @param grade 等级 + * @return list + */ + List querySpread(Long uid, Integer grade); + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxUserQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxUserQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + /** + * 更新用户状态 + * @param uid uid + * @param status ShopCommonEnum + */ + void onStatus(Long uid, Integer status); + + /** + * 修改余额 + * @param param UserMoneyDto + */ + void updateMoney(UserMoneyDto param); + + /** + * 增加佣金 + * @param price 金额 + * @param uid 用户id + */ + void incBrokeragePrice(BigDecimal price, Long uid); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserSignService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserSignService.java new file mode 100644 index 00000000..083911b5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserSignService.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + + + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserSign; +import co.yixiang.modules.user.vo.SignVo; +import co.yixiang.modules.user.vo.YxUserQueryVo; + +import java.util.List; + +/** + *

+ * 签到记录表 服务类 + *

+ * + * @author hupeng + * @since 2019-12-05 + */ +public interface YxUserSignService extends BaseService { + + /** + * + * @param yxUser 用户 + * @return 签到积分 + */ + int sign(YxUser yxUser); + + /** + * 分页获取用户签到数据 + * @param uid 用户id + * @param page page + * @param limit limit + * @return list + */ + List getSignList(Long uid, int page, int limit); + + //boolean getYesterDayIsSign(int uid); + + //boolean getToDayIsSign(int uid); + + //int getSignSumDay(int uid); + + /** + * 获取签到用户信息 + * @param yxUser yxUser + * @return YxUserQueryVo + */ + YxUserQueryVo userSignInfo(YxUser yxUser); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserTaskFinishService.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserTaskFinishService.java new file mode 100644 index 00000000..1f53951d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/YxUserTaskFinishService.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service; + + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.user.domain.YxUserTaskFinish; + +/** + *

+ * 用户任务完成记录表 服务类 + *

+ * + * @author hupeng + * @since 2019-12-07 + */ +public interface YxUserTaskFinishService extends BaseService { + + /** + * 设置任务完成 + * @param uid uid + * @param taskId 任务id + */ + void setFinish(Long uid,int taskId); + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/BillOrderDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/BillOrderDto.java new file mode 100644 index 00000000..90dc3f67 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/BillOrderDto.java @@ -0,0 +1,17 @@ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.util.List; + +/** + * @ClassName BillVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class BillOrderDto { + private String time; + private Integer count; + private List child; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/BillOrderRecordDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/BillOrderRecordDto.java new file mode 100644 index 00000000..82cfd9f9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/BillOrderRecordDto.java @@ -0,0 +1,17 @@ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** + * @ClassName BillVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class BillOrderRecordDto { + private String orderId; + private String time; + private Double number; + private String avatar; + private String nickname; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/MUserBillDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/MUserBillDto.java new file mode 100644 index 00000000..b5480f1d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/MUserBillDto.java @@ -0,0 +1,16 @@ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** + * @ClassName UserBillDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class MUserBillDto { + private String addTime; + private String title; + private Double number; + private Integer pm; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/PromUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/PromUserDto.java new file mode 100644 index 00000000..c6d19052 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/PromUserDto.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** + * @ClassName PromUserDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class PromUserDto { + private String avatar; + private String nickname; + private Integer childCount; + private Integer numberCount; + private Integer orderCount; + private Integer uid; + private String time; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/TaskDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/TaskDto.java new file mode 100644 index 00000000..a43a7e33 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/TaskDto.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.user.service.dto; + + +import co.yixiang.modules.user.vo.YxSystemUserTaskQueryVo; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName TaskDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/6 + **/ +@Data +public class TaskDto implements Serializable { + private List list; + private Long reachCount; + private List task; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserBillDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserBillDto.java new file mode 100644 index 00000000..284b899c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserBillDto.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** + * @ClassName UserBillDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/11 + **/ +@Data +public class UserBillDto { + private Integer pm; + private String gtitle; + private String category; + private String type; + private Double number; + private String nickname; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserLevelDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserLevelDto.java new file mode 100644 index 00000000..8df5086b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserLevelDto.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.user.service.dto; + + +import co.yixiang.modules.user.vo.YxSystemUserLevelQueryVo; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @ClassName UserLevelDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/6 + **/ +@Data +public class UserLevelDto implements Serializable { + private List list; + private TaskDto task; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserLevelInfoDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserLevelInfoDto.java new file mode 100644 index 00000000..1c0afe04 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserLevelInfoDto.java @@ -0,0 +1,21 @@ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @ClassName UserLevelInfoDto + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/7 + **/ +@Data +public class UserLevelInfoDto implements Serializable { + private Integer id; + private Integer addTime; + private Double discount; + private Integer levelId; + private String name; + private String icon; + private Integer grade; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserMoneyDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserMoneyDto.java new file mode 100644 index 00000000..25a982cb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/UserMoneyDto.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import javax.validation.constraints.Min; +import java.io.Serializable; + +/** + * @ClassName UserMoneyDTO + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/4 + **/ +@Data +public class UserMoneyDto implements Serializable { + //@NotNull(message = "参数缺失") + private Long uid; + //@NotNull(message = "请选择修改余额方式") + private Integer ptype; + //@NotNull(message = "金额必填") + @Min(message = "最低金额为0",value = 0) + private Double money; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/WechatUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/WechatUserDto.java new file mode 100644 index 00000000..41dffe04 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/WechatUserDto.java @@ -0,0 +1,45 @@ +package co.yixiang.modules.user.service.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * @ClassName WechatUserDTO + * @Author hupeng <610796224@qq.com> + * @Date 2020/6/4 + **/ +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class WechatUserDto { + + private String openid; + + private String unionId; + + private String routineOpenid; + + private String nickname; + + private String headimgurl; + + private Integer sex; + + private String city; + + private String language; + + private String province; + + private String country; + + private Boolean subscribe; + + private Long subscribeTime; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserLevelDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserLevelDto.java new file mode 100644 index 00000000..aa9d562e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserLevelDto.java @@ -0,0 +1,63 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemUserLevelDto implements Serializable { + + private Integer id; + + /** 商户id */ + private Integer merId; + + /** 会员名称 */ + private String name; + + /** 购买金额 */ + private BigDecimal money; + + /** 有效时间 */ + private Integer validDate; + + /** 是否为永久会员 */ + private Integer isForever; + + /** 是否购买,1=购买,0=不购买 */ + private Integer isPay; + + /** 是否显示 1=显示,0=隐藏 */ + private Integer isShow; + + /** 会员等级 */ + private Integer grade; + + /** 享受折扣 */ + private BigDecimal discount; + + /** 会员卡背景 */ + private String image; + + /** 会员图标 */ + private String icon; + + /** 说明 */ + private String explain; + + /** 添加时间 */ + private Integer addTime; + + /** 是否删除.1=删除,0=未删除 */ + private Integer isDel; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserLevelQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserLevelQueryCriteria.java new file mode 100644 index 00000000..a06f5976 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserLevelQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemUserLevelQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserTaskDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserTaskDto.java new file mode 100644 index 00000000..a0c79cb1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserTaskDto.java @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemUserTaskDto implements Serializable { + private Integer id; + + // 任务名称 + private String name; + + // 配置原名 + private String realName; + + // 任务类型 + private String taskType; + + // 限定数 + private Integer number; + + // 等级id + private Integer levelId; + + private String levalName; + + // 排序 + private Integer sort; + + // 是否显示 + private Integer isShow; + + // 是否务必达成任务,1务必达成,0=满足其一 + private Integer isMust; + + // 任务说明 + private String illustrate; + + // 新增时间 + private Integer addTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserTaskQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserTaskQueryCriteria.java new file mode 100644 index 00000000..ac59f656 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxSystemUserTaskQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxSystemUserTaskQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserBillDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserBillDto.java new file mode 100644 index 00000000..5b57dc2c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserBillDto.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxUserBillDto implements Serializable { + + /** 用户账单id */ + private Long id; + + /** 用户uid */ + private Long uid; + + /** 关联id */ + private String linkId; + + /** 0 = 支出 1 = 获得 */ + private Integer pm; + + /** 账单标题 */ + private String title; + + /** 明细种类 */ + private String category; + + /** 明细类型 */ + private String type; + + /** 明细数字 */ + private BigDecimal number; + + /** 剩余 */ + private BigDecimal balance; + + /** 备注 */ + private String mark; + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + /** 0 = 带确定 1 = 有效 -1 = 无效 */ + private Integer status; + + private String nickname; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserBillQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserBillQueryCriteria.java new file mode 100644 index 00000000..11a0e80b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserBillQueryCriteria.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxUserBillQueryCriteria{ + @Query(type = Query.Type.EQUAL) + private String nickname = ""; + @Query(type = Query.Type.EQUAL) + private String category = ""; + @Query(type = Query.Type.EQUAL) + private String type = ""; + @Query(type = Query.Type.EQUAL) + private Integer pm; + @Query(type = Query.Type.EQUAL) + private String title = ""; + private String startTime; + + private String endTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserDto.java new file mode 100644 index 00000000..adcbdfa2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserDto.java @@ -0,0 +1,111 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxUserDto implements Serializable { + + /** 用户id */ + private Long uid; + + /** 用户账户(跟accout一样) */ + private String username; + + /** 用户密码(跟pwd) */ + private String password; + + + /** 真实姓名 */ + private String realName; + + /** 生日 */ + private Integer birthday; + + /** 身份证号码 */ + private String cardId; + + /** 用户备注 */ + private String mark; + + /** 合伙人id */ + private Integer partnerId; + + /** 用户分组id */ + private Integer groupId; + + /** 用户昵称 */ + private String nickname = ""; + + /** 用户头像 */ + private String avatar; + + /** 手机号码 */ + private String phone; + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + /** 添加ip */ + private String addIp; + + + /** 用户余额 */ + private BigDecimal nowMoney; + + /** 佣金金额 */ + private BigDecimal brokeragePrice; + + /** 用户剩余积分 */ + private BigDecimal integral; + + /** 连续签到天数 */ + private Integer signNum; + + /** 1为正常,0为禁止 */ + private Integer status; + + /** 等级 */ + private Integer level; + + /** 推广元id */ + private Long spreadUid; + + /** 推广员关联时间 */ + private Date spreadTime; + + /** 用户类型 */ + private String userType; + + /** 是否为推广员 */ + private Integer isPromoter; + + /** 用户购买次数 */ + private Integer payCount; + + /** 下级人数 */ + private Integer spreadCount; + + /** 详细地址 */ + private String addres; + + /** 管理员编号 */ + private Integer adminid; + + /** 用户登陆类型,h5,wechat,routine */ + private String loginType; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserQueryCriteria.java new file mode 100644 index 00000000..10a7bea4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserQueryCriteria.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxUserQueryCriteria{ + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String nickname; + + // 模糊 + @Query(type = Query.Type.INNER_LIKE) + private String phone; + + @Query + private Integer isPromoter; + + @Query + private String userType; + + private Long uid; + + private Integer grade; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserRechargeDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserRechargeDto.java new file mode 100644 index 00000000..9171a005 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserRechargeDto.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxUserRechargeDto implements Serializable { + + private Long id; + + /** 充值用户UID */ + private Long uid; + + /** 订单号 */ + private String orderId; + + /** 充值金额 */ + private BigDecimal price; + + /** 充值类型 */ + private String rechargeType; + + /** 是否充值 */ + private Integer paid; + + /** 充值支付时间 */ + private Date payTime; + + /** 充值时间 */ + private Date createTime; + + /** 退款金额 */ + private BigDecimal refundPrice; + + /** 昵称 */ + private String nickname; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserRechargeQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserRechargeQueryCriteria.java new file mode 100644 index 00000000..58cfb229 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserRechargeQueryCriteria.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxUserRechargeQueryCriteria{ + + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private String nickname; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserSmallDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserSmallDto.java new file mode 100644 index 00000000..77a3b324 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxUserSmallDto.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.io.Serializable; + + +/** +* @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; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxWechatUserDto.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxWechatUserDto.java new file mode 100644 index 00000000..2d7993a4 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxWechatUserDto.java @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatUserDto implements Serializable { + + /** 微信用户id */ + private Integer uid; + + /** 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段 */ + private String unionid; + + /** 用户的标识,对当前公众号唯一 */ + private String openid; + + /** 小程序唯一身份ID */ + private String routineOpenid; + + /** 用户的昵称 */ + private String nickname; + + /** 用户头像 */ + private String headimgurl; + + /** 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知 */ + private Integer sex; + + /** 用户所在城市 */ + private String city; + + /** 用户的语言,简体中文为zh_CN */ + private String language; + + /** 用户所在省份 */ + private String province; + + /** 用户所在国家 */ + private String country; + + /** 公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 */ + private String remark; + + /** 用户所在的分组ID(兼容旧的用户分组接口) */ + private Integer groupid; + + /** 用户被打上的标签ID列表 */ + private String tagidList; + + /** 用户是否订阅该公众号标识 */ + private Integer subscribe; + + /** 关注公众号时间 */ + private Integer subscribeTime; + + /** 添加时间 */ + private Integer addTime; + + /** 一级推荐人 */ + private Integer stair; + + /** 二级推荐人 */ + private Integer second; + + /** 一级推荐人订单 */ + private Integer orderStair; + + /** 二级推荐人订单 */ + private Integer orderSecond; + + /** 佣金 */ + private BigDecimal nowMoney; + + /** 小程序用户会话密匙 */ + private String sessionKey; + + /** 用户类型 */ + private String userType; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxWechatUserQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxWechatUserQueryCriteria.java new file mode 100644 index 00000000..a2d80b0d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/dto/YxWechatUserQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Data +public class YxWechatUserQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxSystemUserLevelServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxSystemUserLevelServiceImpl.java new file mode 100644 index 00000000..7e1aae16 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxSystemUserLevelServiceImpl.java @@ -0,0 +1,204 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.util.ObjectUtil; +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.modules.shop.domain.YxSystemUserLevel; +import co.yixiang.modules.user.domain.YxUserLevel; +import co.yixiang.modules.user.service.YxSystemUserLevelService; +import co.yixiang.modules.user.service.YxSystemUserTaskService; +import co.yixiang.modules.user.service.YxUserLevelService; +import co.yixiang.modules.user.service.dto.TaskDto; +import co.yixiang.modules.user.service.dto.UserLevelDto; +import co.yixiang.modules.user.service.dto.YxSystemUserLevelDto; +import co.yixiang.modules.user.service.dto.YxSystemUserLevelQueryCriteria; +import co.yixiang.modules.user.service.mapper.SystemUserLevelMapper; +import co.yixiang.modules.user.vo.YxSystemUserLevelQueryVo; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemUserLevelServiceImpl extends BaseServiceImpl implements YxSystemUserLevelService { + + @Autowired + private IGenerator generator; + + @Autowired + private SystemUserLevelMapper yxSystemUserLevelMapper; + @Autowired + private YxUserLevelService userLevelService; + @Autowired + private YxSystemUserTaskService systemUserTaskService; + + /** + * 获取当前的下一个会员等级id + * @param levelId 等级id + * @return int + */ + @Override + public int getNextLevelId(int levelId) { + List list = this.lambdaQuery() + .eq(YxSystemUserLevel::getIsShow,ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxSystemUserLevel::getGrade) + .list(); + + int grade = 0; + for (YxSystemUserLevel userLevel : list) { + if(userLevel.getId() == levelId) { + grade = userLevel.getGrade(); + } + } + + YxSystemUserLevel userLevel = this.lambdaQuery() + .eq(YxSystemUserLevel::getIsShow,ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxSystemUserLevel::getGrade) + .gt(YxSystemUserLevel::getGrade,grade) + .last("limit 1") + .one(); + if(ObjectUtil.isNull(userLevel)) { + return 0; + } + return userLevel.getId(); + } + +// @Override +// public boolean getClear(int levelId) { +// List systemUserLevelQueryVos = this.getLevelListAndGrade(levelId); +// for (YxSystemUserLevelQueryVo userLevelQueryVo : systemUserLevelQueryVos) { +// if(userLevelQueryVo.getId() == levelId) return userLevelQueryVo.getIsClear(); +// } +// return false; +// } + + + + /** + * 获取会员等级列表及其任务列表 + * @return UserLevelDto + */ + @Override + public UserLevelDto getLevelInfo(Long uid) { + int levelId = 0; //用户当前等级id 0-表示无 + YxUserLevel userLevel = userLevelService.getUserLevel(uid, null); + if(userLevel != null){ + levelId = userLevel.getLevelId(); + } + + + //会员等级列表 + List list = this.getLevelListAndGrade(levelId); + if(list.isEmpty()) { + throw new YshopException("请后台设置会员等级"); + } + + //任务列表 + TaskDto taskDTO = systemUserTaskService.getTaskList(list.get(0).getId(),uid); + + UserLevelDto userLevelDTO = new UserLevelDto(); + userLevelDTO.setList(list); + userLevelDTO.setTask(taskDTO); + + return userLevelDTO; + } + + /** + * 获取会员等级列表 + * @param levelId 等级id + * @return list + */ + private List getLevelListAndGrade(Integer levelId) { + Integer grade = 0; + List list = this.lambdaQuery() + .eq(YxSystemUserLevel::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByAsc(YxSystemUserLevel::getGrade) + .list(); + List newList = generator.convert(list,YxSystemUserLevelQueryVo.class); + for (YxSystemUserLevelQueryVo userLevelQueryVo : newList) { + if(userLevelQueryVo.getId().compareTo(levelId) == 0) { + grade = userLevelQueryVo.getGrade(); + } + if(grade.compareTo(userLevelQueryVo.getGrade()) < 0){ + userLevelQueryVo.setIsClear(true); //不解锁 + }else{ + userLevelQueryVo.setIsClear(false);//开启会员解锁 + } + } + return newList; + } + + + //=========================================================================================// + + @Override + //@Cacheable + public Map queryAll(YxSystemUserLevelQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxSystemUserLevelDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemUserLevelQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemUserLevel.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemUserLevelDto yxSystemUserLevel : all) { + Map map = new LinkedHashMap<>(); + map.put("商户id", yxSystemUserLevel.getMerId()); + map.put("会员名称", yxSystemUserLevel.getName()); + map.put("购买金额", yxSystemUserLevel.getMoney()); + map.put("有效时间", yxSystemUserLevel.getValidDate()); + map.put("是否为永久会员", yxSystemUserLevel.getIsForever()); + map.put("是否购买,1=购买,0=不购买", yxSystemUserLevel.getIsPay()); + map.put("是否显示 1=显示,0=隐藏", yxSystemUserLevel.getIsShow()); + map.put("会员等级", yxSystemUserLevel.getGrade()); + map.put("享受折扣", yxSystemUserLevel.getDiscount()); + map.put("会员卡背景", yxSystemUserLevel.getImage()); + map.put("会员图标", yxSystemUserLevel.getIcon()); + map.put("说明", yxSystemUserLevel.getExplain()); + map.put("添加时间", yxSystemUserLevel.getAddTime()); + map.put("是否删除.1=删除,0=未删除", yxSystemUserLevel.getIsDel()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxSystemUserTaskServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxSystemUserTaskServiceImpl.java new file mode 100644 index 00000000..407e6ea5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxSystemUserTaskServiceImpl.java @@ -0,0 +1,235 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.util.NumberUtil; +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.modules.order.service.mapper.StoreOrderMapper; +import co.yixiang.modules.shop.domain.YxSystemUserLevel; +import co.yixiang.modules.user.domain.YxSystemUserTask; +import co.yixiang.modules.user.domain.YxUserTaskFinish; +import co.yixiang.modules.user.service.YxSystemUserLevelService; +import co.yixiang.modules.user.service.YxSystemUserTaskService; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserTaskFinishService; +import co.yixiang.modules.user.service.dto.TaskDto; +import co.yixiang.modules.user.service.dto.YxSystemUserTaskDto; +import co.yixiang.modules.user.service.dto.YxSystemUserTaskQueryCriteria; +import co.yixiang.modules.user.service.mapper.SystemUserTaskMapper; +import co.yixiang.modules.user.service.mapper.UserBillMapper; +import co.yixiang.modules.user.service.mapper.YxUserTaskFinishMapper; +import co.yixiang.modules.user.vo.YxSystemUserTaskQueryVo; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxSystemUserTaskServiceImpl extends BaseServiceImpl implements YxSystemUserTaskService { + + @Autowired + private IGenerator generator; + @Autowired + private YxSystemUserLevelService systemUserLevelService; + + @Autowired + private SystemUserTaskMapper yxSystemUserTaskMapper; + @Autowired + private YxUserTaskFinishMapper yxUserTaskFinishMapper; + + @Autowired + private UserBillMapper userBillMapper; + @Autowired + private StoreOrderMapper storeOrderMapper; + + @Autowired + private YxUserTaskFinishService userTaskFinishService; + @Autowired + private YxUserBillService userBillService; + + + + + + /** + * 获取已经完成的任务数量 + * @param levelId 等级id + * @param uid uid + * @return int + */ + @Override + public Long getTaskComplete(int levelId, Long uid) { + List list = this.lambdaQuery() + .eq(YxSystemUserTask::getLevelId,levelId) + .eq(YxSystemUserTask::getIsShow,ShopCommonEnum.SHOW_1.getValue()) + .list(); + List taskIds = list.stream().map(YxSystemUserTask::getId) + .collect(Collectors.toList()); + if(taskIds.isEmpty()) { + return 0L; + } + + return yxUserTaskFinishMapper.selectCount(Wrappers.lambdaQuery() + .in(YxUserTaskFinish::getTaskId,taskIds) + .eq(YxUserTaskFinish::getUid,uid)); + } + + /** + * 获取等级会员任务列表 + * @param levelId 等级id + * @param uid uid + * @return TaskDto + */ + @Override + public TaskDto getTaskList(int levelId, Long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxSystemUserTask::getLevelId,levelId) + .eq(YxSystemUserTask::getIsShow, ShopCommonEnum.SHOW_1.getValue()) + .orderByDesc(YxSystemUserTask::getSort); + List list = generator.convert(yxSystemUserTaskMapper + .selectList(wrapper),YxSystemUserTaskQueryVo.class); + + TaskDto taskDTO = new TaskDto(); + taskDTO.setList(list); + taskDTO.setReachCount(this.getTaskComplete(levelId,uid)); + taskDTO.setTask(this.tidyTask(list,uid)); + + return taskDTO; + } + + + /** + * 设置任务内容完成情况 + * @param task 任务列表 + * @param uid uid + * @return list + */ + private List tidyTask(List task,Long uid) { + for (YxSystemUserTaskQueryVo taskQueryVo : task) { + Long count = userTaskFinishService.lambdaQuery() + .eq(YxUserTaskFinish::getTaskId,taskQueryVo.getId()) + .eq(YxUserTaskFinish::getUid,uid) + .count(); + if(count > 0){ + taskQueryVo.setNewNumber(taskQueryVo.getNumber()); + taskQueryVo.setSpeed(100); //完成比例 + taskQueryVo.setFinish(ShopCommonEnum.IS_FINISH_1.getValue()); + taskQueryVo.setTaskTypeTitle(""); + }else{ + double sumNumber = 0d; + String title = ""; + switch (taskQueryVo.getTaskType()){ + case "SatisfactionIntegral": + sumNumber = userBillMapper.sumIntegral(uid); + title = "还需要{0}经验"; + break; + case "ConsumptionAmount": + sumNumber = storeOrderMapper.sumPrice(uid); + title = "还需消费{0}元"; + break; + case "CumulativeAttendance": + sumNumber = userBillService.cumulativeAttendance(uid); + title = "还需签到{0}天"; + break; + default: + } + + if(sumNumber >= taskQueryVo.getNumber()){ + userTaskFinishService.setFinish(uid,taskQueryVo.getId()); + taskQueryVo.setFinish(ShopCommonEnum.IS_FINISH_1.getValue()); + taskQueryVo.setSpeed(100); + taskQueryVo.setTaskTypeTitle(""); + taskQueryVo.setNewNumber(taskQueryVo.getNumber()); + }else{ + double numdata = NumberUtil.sub(taskQueryVo.getNumber().doubleValue(),sumNumber); + taskQueryVo.setTaskTypeTitle(MessageFormat.format(title,numdata)); + double speed = NumberUtil.div(sumNumber,taskQueryVo.getNumber().doubleValue()); + taskQueryVo.setSpeed(Double.valueOf(NumberUtil.mul(speed,100)).intValue()); + taskQueryVo.setFinish(ShopCommonEnum.IS_FINISH_0.getValue()); + taskQueryVo.setNewNumber(Double.valueOf(sumNumber).intValue()); + } + } + } + + return task; + } + + + //==========================================================// + + @Override + //@Cacheable + public Map queryAll(YxSystemUserTaskQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + List systemUserTaskDTOS = generator.convert(page.getList(),YxSystemUserTaskDto.class); + for (YxSystemUserTaskDto systemUserTaskDTO : systemUserTaskDTOS) { + YxSystemUserLevel userLevel=systemUserLevelService.getById(systemUserTaskDTO.getLevelId()); + if(userLevel == null) { + continue; + } + systemUserTaskDTO.setLevalName(userLevel.getName()); + } + Map map = new LinkedHashMap<>(2); + map.put("content", systemUserTaskDTOS); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxSystemUserTaskQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxSystemUserTask.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxSystemUserTaskDto yxSystemUserTask : all) { + Map map = new LinkedHashMap<>(); + map.put("任务名称", yxSystemUserTask.getName()); + map.put("配置原名", yxSystemUserTask.getRealName()); + map.put("任务类型", yxSystemUserTask.getTaskType()); + map.put("限定数", yxSystemUserTask.getNumber()); + map.put("等级id", yxSystemUserTask.getLevelId()); + map.put("排序", yxSystemUserTask.getSort()); + map.put("是否显示", yxSystemUserTask.getIsShow()); + map.put("是否务必达成任务,1务必达成,0=满足其一", yxSystemUserTask.getIsMust()); + map.put("任务说明", yxSystemUserTask.getIllustrate()); + map.put("新增时间", yxSystemUserTask.getAddTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserAddressServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserAddressServiceImpl.java new file mode 100644 index 00000000..293fbcaf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserAddressServiceImpl.java @@ -0,0 +1,147 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.user.domain.YxUserAddress; +import co.yixiang.modules.user.param.AddressParam; +import co.yixiang.modules.user.service.YxUserAddressService; +import co.yixiang.modules.user.service.mapper.YxUserAddressMapper; +import co.yixiang.modules.user.vo.YxUserAddressQueryVo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + + +/** + *

+ * 用户地址表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-10-28 + */ +@Slf4j +@Service +@AllArgsConstructor +@Transactional(rollbackFor = Exception.class) +public class YxUserAddressServiceImpl extends BaseServiceImpl implements YxUserAddressService { + + private final YxUserAddressMapper yxUserAddressMapper; + private final IGenerator generator; + + /** + * 设置默认地址 + * @param uid uid + * @param addressId 地址id + */ + @Override + public void setDefault(Long uid,Long addressId){ + YxUserAddress address = new YxUserAddress(); + address.setIsDefault(ShopCommonEnum.DEFAULT_0.getValue()); + yxUserAddressMapper.update(address, + new LambdaQueryWrapper().eq(YxUserAddress::getUid,uid)); + + YxUserAddress userAddress = new YxUserAddress(); + userAddress.setIsDefault(ShopCommonEnum.DEFAULT_1.getValue()); + userAddress.setId(addressId); + yxUserAddressMapper.updateById(userAddress); + } + + + /** + * 添加或者修改地址 + * @param uid uid + * @param param AddressParam + */ + @Override + public Long addAndEdit(Long uid, AddressParam param){ + YxUserAddress userAddress = YxUserAddress.builder() + .city(param.getAddress().getCity()) + .cityId(param.getAddress().getCityId()) + .district(param.getAddress().getDistrict()) + .province(param.getAddress().getProvince()) + .detail(param.getDetail()) + .uid(uid) + .phone(param.getPhone()) + .postCode(param.getPost_code()) + .realName(param.getReal_name()) + .build(); + if("true".equals(param.getIs_default())){ + userAddress.setIsDefault(ShopCommonEnum.DEFAULT_1.getValue()); + //新增地址如果是默认,把之前的状态改掉 + YxUserAddress address = new YxUserAddress(); + address.setIsDefault(ShopCommonEnum.DEFAULT_0.getValue()); + baseMapper.update(address,new LambdaQueryWrapper().eq(YxUserAddress::getUid,uid)); + }else{ + userAddress.setIsDefault(ShopCommonEnum.DEFAULT_0.getValue()); + } + if(StrUtil.isBlank(param.getId())){ + this.save(userAddress); + }else{ + userAddress.setId(Long.valueOf(param.getId())); + this.updateById(userAddress); + } + + return userAddress.getId(); + } + + /** + * 地址详情 + * @param id 地址id + * @return YxUserAddressQueryVo + */ + @Override + public YxUserAddressQueryVo getDetail(Long id){ + return generator.convert(this.getById(id),YxUserAddressQueryVo.class); + } + + + /** + * 获取用户地址 + * @param uid uid + * @param page page + * @param limit limit + * @return List + */ + @Override + public List getList(Long uid,int page,int limit){ + Page pageModel = new Page<>(page, limit); + IPage pageList = this.lambdaQuery().eq(YxUserAddress::getUid,uid).page(pageModel); + return generator.convert(pageList.getRecords(),YxUserAddressQueryVo.class); + } + + /** + * 获取默认地址 + * @param uid uid + * @return YxUserAddress + */ + @Override + public YxUserAddress getUserDefaultAddress(Long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxUserAddress::getIsDefault,1). + eq(YxUserAddress::getUid,uid) + .last("limit 1"); + return getOne(wrapper); + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserBillServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserBillServiceImpl.java new file mode 100644 index 00000000..55c90461 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserBillServiceImpl.java @@ -0,0 +1,309 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.enums.BillEnum; +import co.yixiang.enums.BillInfoEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.user.domain.YxUserBill; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.dto.BillOrderDto; +import co.yixiang.modules.user.service.dto.BillOrderRecordDto; +import co.yixiang.modules.user.service.dto.YxUserBillDto; +import co.yixiang.modules.user.service.dto.YxUserBillQueryCriteria; +import co.yixiang.modules.user.service.mapper.UserBillMapper; +import co.yixiang.modules.user.vo.BillVo; +import co.yixiang.modules.user.vo.YxUserBillQueryVo; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxUserBillServiceImpl extends BaseServiceImpl implements YxUserBillService { + + private final IGenerator generator; + private final UserBillMapper yxUserBillMapper; + + + /** + * 增加支出流水 + * @param uid uid + * @param title 账单标题 + * @param category 明细种类 + * @param type 明细类型 + * @param number 明细数字 + * @param balance 剩余 + * @param mark 备注 + */ + @Override + public void expend(Long uid,String title,String category,String type,double number,double balance,String mark){ + YxUserBill userBill = YxUserBill.builder() + .uid(uid) + .title(title) + .category(category) + .type(type) + .number(BigDecimal.valueOf(number)) + .balance(BigDecimal.valueOf(balance)) + .mark(mark) + .pm(BillEnum.PM_0.getValue()) + .build(); + + yxUserBillMapper.insert(userBill); + } + + /** + * 增加收入/支入流水 + * @param uid uid + * @param title 账单标题 + * @param category 明细种类 + * @param type 明细类型 + * @param number 明细数字 + * @param balance 剩余 + * @param mark 备注 + * @param linkid 关联id + */ + @Override + public void income(Long uid,String title,String category,String type,double number, + double balance,String mark,String linkid){ + YxUserBill userBill = YxUserBill.builder() + .uid(uid) + .title(title) + .category(category) + .type(type) + .number(BigDecimal.valueOf(number)) + .balance(BigDecimal.valueOf(balance)) + .mark(mark) + .pm(BillEnum.PM_1.getValue()) + .linkId(linkid) + .build(); + + yxUserBillMapper.insert(userBill); + } + + /** + * 签到了多少次 + * @param uid + * @return + */ + @Override + public Long cumulativeAttendance(Long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxUserBill::getUid,uid).eq(YxUserBill::getCategory,"integral") + .eq(YxUserBill::getType,"sign").eq(YxUserBill::getPm,1); + return yxUserBillMapper.selectCount(wrapper); + } + + /** + * 获取推广订单列表 + * @param uid uid + * @param page page + * @param limit limit + * @return Map + */ + @Override + public Map spreadOrder(Long uid, int page, int limit) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.lambda().in(YxUserBill::getUid, uid) + .eq(YxUserBill::getType, BillDetailEnum.TYPE_2.getValue()) + .eq(YxUserBill::getCategory, BillDetailEnum.CATEGORY_1.getValue()); + wrapper.orderByDesc("time").groupBy("time"); + Page pageModel = new Page<>(page, limit); + List list = yxUserBillMapper.getBillOrderList(wrapper, pageModel); + + Long count = yxUserBillMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxUserBill::getUid, uid) + .eq(YxUserBill::getType, BillDetailEnum.TYPE_2.getValue()) + .eq(YxUserBill::getCategory, BillDetailEnum.CATEGORY_1.getValue())); + List listT = new ArrayList<>(); + for (String str : list) { + BillOrderDto billOrderDTO = new BillOrderDto(); + List orderRecordDTOS = yxUserBillMapper + .getBillOrderRList(str, uid); + billOrderDTO.setChild(orderRecordDTOS); + billOrderDTO.setCount(orderRecordDTOS.size()); + billOrderDTO.setTime(str); + + listT.add(billOrderDTO); + } + + Map map = new LinkedHashMap<>(2); + map.put("list", listT); + map.put("count", count); + + return map; + } + + /** + * 获取用户账单记录 + * @param page page + * @param limit limit + * @param uid uid + * @param type BillDetailEnum + * @return map + */ + @Override + public Map getUserBillList(int page, int limit, long uid, int type) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.lambda().eq(YxUserBill::getUid,uid).orderByDesc(YxUserBill::getCreateTime) + .orderByAsc(YxUserBill::getId); + wrapper.groupBy("time"); + switch (BillInfoEnum.toType(type)){ + case PAY_PRODUCT: + wrapper.lambda().eq(YxUserBill::getCategory,BillDetailEnum.CATEGORY_1.getValue()); + wrapper.lambda().eq(YxUserBill::getType,BillDetailEnum.TYPE_3.getValue()); + break; + case RECHAREGE: + wrapper.lambda().eq(YxUserBill::getCategory,BillDetailEnum.CATEGORY_1.getValue()); + wrapper.lambda().eq(YxUserBill::getType,BillDetailEnum.TYPE_1.getValue()); + break; + case BROKERAGE: + wrapper.lambda().eq(YxUserBill::getCategory,BillDetailEnum.CATEGORY_1.getValue()); + wrapper.lambda().eq(YxUserBill::getType,BillDetailEnum.TYPE_2.getValue()); + break; + case EXTRACT: + wrapper.lambda().eq(YxUserBill::getCategory,BillDetailEnum.CATEGORY_1.getValue()); + wrapper.lambda().eq(YxUserBill::getType,BillDetailEnum.TYPE_4.getValue()); + break; + case SIGN_INTEGRAL: + wrapper.lambda().eq(YxUserBill::getCategory,BillDetailEnum.CATEGORY_2.getValue()); + wrapper.lambda().eq(YxUserBill::getType,BillDetailEnum.TYPE_10.getValue()); + break; + default: + wrapper.lambda().eq(YxUserBill::getCategory,BillDetailEnum.CATEGORY_1.getValue()); + + } + Page pageModel = new Page<>(page, limit); + List billDTOList = yxUserBillMapper.getBillList(wrapper,pageModel); + for (BillVo billDTO : billDTOList) { + LambdaQueryWrapper wrapperT = new LambdaQueryWrapper<>(); + wrapperT.in(YxUserBill::getId,Arrays.asList(billDTO.getIds().split(","))); + wrapperT.orderByDesc(YxUserBill::getCreateTime); + billDTO.setList(yxUserBillMapper.getUserBillList(wrapperT)); + + } + Map map = new HashMap<>(); + map.put("list",billDTOList); + map.put("total",pageModel.getTotal()); + map.put("totalPage",pageModel.getPages()); + return map; + // return billDTOList; + } + + @Override + public double getBrokerage(int uid) { + return yxUserBillMapper.sumPrice(uid); + } + + /** + * 统计昨天的佣金 + * @param uid uid + * @return double + */ + @Override + public double yesterdayCommissionSum(Long uid) { + return yxUserBillMapper.sumYesterdayPrice(uid); + } + + /** + * 根据类别获取账单记录 + * @param uid uid + * @param category BillDetailEnum + * @param page page + * @param limit limit + * @return List + */ + @Override + public List userBillList(Long uid,String category,int page,int limit) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper + .eq(YxUserBill::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxUserBill::getUid,uid) + .eq(YxUserBill::getCategory,category) + .orderByDesc(YxUserBill::getId); + Page pageModel = new Page<>(page, limit); + IPage pageList = yxUserBillMapper.selectPage(pageModel,wrapper); + return generator.convert(pageList.getRecords(),YxUserBillQueryVo.class); + } + + + //============================================// + + @Override + //@Cacheable + public Map queryAll(YxUserBillQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", page.getList()); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + public List queryAll(YxUserBillQueryCriteria criteria){ + String date =null; + String date1 = null; + if(StringUtils.isNotEmpty(criteria.getStartTime())){ + date = criteria.getStartTime()+ " 00:00:00"; + if(StringUtils.isNotEmpty(criteria.getEndTime())){ + date1 =criteria.getEndTime()+ " 23:59:59"; + } + } + + return baseMapper.findAllByQueryCriteria(criteria.getCategory(),criteria.getType(),criteria.getNickname(),criteria.getPm(),date,date1,criteria.getTitle()); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxUserBillDto yxUserBill : all) { + Map map = new LinkedHashMap<>(); + map.put("用户uid", yxUserBill.getUid()); + map.put("关联id", yxUserBill.getLinkId()); + map.put("0 = 支出 1 = 获得", yxUserBill.getPm()); + map.put("账单标题", yxUserBill.getTitle()); + map.put("明细种类", yxUserBill.getCategory()); + map.put("明细类型", yxUserBill.getType()); + map.put("明细数字", yxUserBill.getNumber()); + map.put("剩余", yxUserBill.getBalance()); + map.put("备注", yxUserBill.getMark()); + map.put("0 = 带确定 1 = 有效 -1 = 无效", yxUserBill.getStatus()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserLevelServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserLevelServiceImpl.java new file mode 100644 index 00000000..76f377bb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserLevelServiceImpl.java @@ -0,0 +1,176 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.shop.domain.YxSystemUserLevel; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserLevel; +import co.yixiang.modules.user.service.YxSystemUserLevelService; +import co.yixiang.modules.user.service.YxSystemUserTaskService; +import co.yixiang.modules.user.service.YxUserLevelService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.mapper.SystemUserTaskMapper; +import co.yixiang.modules.user.service.mapper.YxUserLevelMapper; +import co.yixiang.utils.OrderUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + *

+ * 用户等级记录表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-12-06 + */ +@Slf4j +@Service +@Transactional(rollbackFor = Exception.class) +public class YxUserLevelServiceImpl extends BaseServiceImpl implements YxUserLevelService { + + @Autowired + private YxUserLevelMapper yxUserLevelMapper; + @Autowired + private SystemUserTaskMapper yxSystemUserTaskMapper; + + @Autowired + private YxUserService userService; + @Autowired + private YxSystemUserLevelService systemUserLevelService; + @Autowired + private YxSystemUserTaskService systemUserTaskService; + + + /** + * 检查是否能成为会员 + * @param uid 用户id + */ + @Override + public boolean setLevelComplete(Long uid) { + //获取当前用户级别 + int levelId = 0; + YxUserLevel yxUserLevel = this.getUserLevel(uid,null); + if(yxUserLevel != null ){ + levelId = yxUserLevel.getLevelId(); + } + int nextLevelId = systemUserLevelService.getNextLevelId(levelId); + if(nextLevelId == 0) { + return false; + } + + Long finishCount = systemUserTaskService.getTaskComplete(nextLevelId,uid); + + //目前任务固定,如果增加任务需要自己增加逻辑,目前每个会员任务固定3 + if(finishCount == ShopConstants.TASK_FINISH_COUNT){ + this.setUserLevel(uid,nextLevelId); + return true; + } + return false; + } + + + + /** + * 获取当前用户会员等级返回当前用户等级 + * @param uid uid + * @param grade 用户级别 + * @return YxUserLevel + */ + @Override + public YxUserLevel getUserLevel(Long uid, Integer grade) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper + .eq(YxUserLevel::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxUserLevel::getUid,uid) + .orderByDesc(YxUserLevel::getGrade); + if(grade != null) { + wrapper.lt(YxUserLevel::getGrade,grade); + } + YxUserLevel userLevel = this.getOne(wrapper,false); + if(ObjectUtil.isNull(userLevel)) { + return null; + } + if(ShopCommonEnum.IS_FOREVER_1.getValue().equals(userLevel.getIsForever())) { + return userLevel; + } + int nowTime = OrderUtil.getSecondTimestampTwo(); + if(nowTime > userLevel.getValidTime()){ + if(ShopCommonEnum.IS_STATUS_1.getValue().equals(userLevel.getStatus())){ + userLevel.setStatus(ShopCommonEnum.IS_STATUS_0.getValue()); + yxUserLevelMapper.updateById(userLevel); + } + return this.getUserLevel(uid,userLevel.getGrade()); + } + return userLevel; + } + + + /** + * 设置会员等级 + * @param uid 用户id + * @param levelId 等级id + */ + private void setUserLevel(Long uid, int levelId){ + YxSystemUserLevel systemUserLevelQueryVo = systemUserLevelService + .getById(levelId); + if(ObjectUtil.isNull(systemUserLevelQueryVo)) { + return; + } + + int validTime = systemUserLevelQueryVo.getValidDate() * 86400; + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxUserLevel::getStatus,ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxUserLevel::getUid,uid) + .eq(YxUserLevel::getLevelId,levelId) + .last("limit 1"); + + YxUserLevel yxUserLevel = new YxUserLevel(); + yxUserLevel.setIsForever(systemUserLevelQueryVo.getIsForever()); + yxUserLevel.setStatus(ShopCommonEnum.IS_STATUS_1.getValue()); + yxUserLevel.setGrade(systemUserLevelQueryVo.getGrade()); + yxUserLevel.setUid(uid); + yxUserLevel.setLevelId(levelId); + yxUserLevel.setDiscount(systemUserLevelQueryVo.getDiscount().intValue()); + + if(ShopCommonEnum.IS_FOREVER_1.getValue().equals(systemUserLevelQueryVo.getIsForever())){ + yxUserLevel.setValidTime(0); //永久 + }else{ + yxUserLevel.setValidTime(validTime+OrderUtil.getSecondTimestampTwo()); + } + + yxUserLevel.setMark("恭喜你成为了"+systemUserLevelQueryVo.getName()); + yxUserLevelMapper.insert(yxUserLevel); + + //更新用户等级 + YxUser yxUser = new YxUser(); + yxUser.setLevel(levelId); + yxUser.setUid(uid); + userService.updateById(yxUser); + + } + + + + // @Override +// public UserLevelInfoDto getUserLevelInfo(int id) { +// return yxUserLevelMapper.getUserLevelInfo(id); +// } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserRechargeServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserRechargeServiceImpl.java new file mode 100644 index 00000000..7c0ce614 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserRechargeServiceImpl.java @@ -0,0 +1,190 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +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.BillDetailEnum; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.PayTypeEnum; +import co.yixiang.event.TemplateBean; +import co.yixiang.event.TemplateEvent; +import co.yixiang.event.TemplateListenEnum; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserRecharge; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserRechargeService; +import co.yixiang.modules.user.service.dto.YxUserRechargeDto; +import co.yixiang.modules.user.service.dto.YxUserRechargeQueryCriteria; +import co.yixiang.modules.user.service.mapper.BxgUserMapper; +import co.yixiang.modules.user.service.mapper.UserRechargeMapper; +import co.yixiang.utils.FileUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@SuppressWarnings("unchecked") +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxUserRechargeServiceImpl extends BaseServiceImpl implements YxUserRechargeService { + @Autowired + private IGenerator generator; + + @Autowired + private UserRechargeMapper yxUserRechargeMapper; + @Autowired + private YxUserBillService billService; + + @Autowired + private BxgUserMapper yxUserMapper; + + @Autowired + private ApplicationEventPublisher publisher; + + + @Override + public void updateRecharge(YxUserRecharge userRecharge) { + YxUser user = yxUserMapper.selectById(userRecharge.getUid()); + + //修改状态 + userRecharge.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + userRecharge.setPayTime(new Date()); + yxUserRechargeMapper.updateById(userRecharge); + + //最终充值金额 + BigDecimal newPrice = NumberUtil.add(userRecharge.getPrice(),user.getNowMoney()); + newPrice = newPrice.add(userRecharge.getGivePrice()); + + + //增加流水 + billService.income(userRecharge.getUid(),"用户余额充值",BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_1.getValue(),userRecharge.getPrice().doubleValue(),newPrice.doubleValue(), + "成功充值余额"+userRecharge.getPrice(),userRecharge.getId().toString()); + + + //update 余额 + user.setNowMoney(newPrice); + yxUserMapper.updateById(user); + + //模板消息发布事件 + TemplateBean templateBean = TemplateBean.builder() + .time(DateUtil.formatTime(userRecharge.getPayTime())) + .price(userRecharge.getPrice().toString()) + .orderId(userRecharge.getOrderId()) + .uid(userRecharge.getUid()) + .templateType(TemplateListenEnum.TYPE_4.getValue()) + .build(); + publisher.publishEvent(new TemplateEvent(this, templateBean)); + + } + + @Override + public YxUserRecharge getInfoByOrderId(String orderId) { + YxUserRecharge userRecharge = new YxUserRecharge(); + userRecharge.setOrderId(orderId); + + return yxUserRechargeMapper.selectOne(Wrappers.query(userRecharge)); + } + + /** + * 添加充值记录 + * @param user 用户 + * @param price 充值金额 + * @param paidPrice 赠送金额 + */ + @Override + public String addRecharge(YxUser user,String price,String paidPrice) { + if(StrUtil.isBlank(price) || StrUtil.isBlank(paidPrice)){ + throw new YshopException("参数非法"); + } + YxUserRecharge yxUserRecharge = new YxUserRecharge(); + + String orderSn = IdUtil.getSnowflake(0,0).nextIdStr(); + + yxUserRecharge.setNickname(user.getNickname()); + yxUserRecharge.setOrderId(orderSn); + yxUserRecharge.setUid(user.getUid()); + yxUserRecharge.setPrice(new BigDecimal(price)); + yxUserRecharge.setGivePrice(new BigDecimal(paidPrice)); + yxUserRecharge.setRechargeType(PayTypeEnum.WEIXIN.getValue()); + yxUserRecharge.setPaid(OrderInfoEnum.PAY_STATUS_0.getValue()); + + yxUserRechargeMapper.insert(yxUserRecharge); + + return orderSn; + + } + + + + //==========================================================================// + + @Override + //@Cacheable + public Map queryAll(YxUserRechargeQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxUserRechargeDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxUserRechargeQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxUserRecharge.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxUserRechargeDto yxUserRecharge : all) { + Map map = new LinkedHashMap<>(); + map.put("充值用户UID", yxUserRecharge.getUid()); + map.put("订单号", yxUserRecharge.getOrderId()); + map.put("充值金额", yxUserRecharge.getPrice()); + map.put("充值类型", yxUserRecharge.getRechargeType()); + map.put("是否充值", yxUserRecharge.getPaid()); + map.put("充值支付时间", yxUserRecharge.getPayTime()); + map.put("退款金额", yxUserRecharge.getRefundPrice()); + map.put("昵称", yxUserRecharge.getNickname()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserServiceImpl.java new file mode 100644 index 00000000..b9dbba00 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserServiceImpl.java @@ -0,0 +1,692 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiCode; +import co.yixiang.api.UnAuthenticatedException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.enums.Brokerage; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.activity.service.YxStoreCouponUserService; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.service.YxStoreOrderCartInfoService; +import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.mapper.StoreOrderMapper; +import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; +import co.yixiang.modules.product.vo.YxStoreProductQueryVo; +import co.yixiang.modules.shop.domain.YxSystemUserLevel; +import co.yixiang.modules.shop.service.YxSystemConfigService; +import co.yixiang.modules.shop.service.YxSystemStoreStaffService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserLevel; +import co.yixiang.modules.user.service.YxSystemUserLevelService; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserLevelService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.dto.PromUserDto; +import co.yixiang.modules.user.service.dto.UserMoneyDto; +import co.yixiang.modules.user.service.dto.YxUserDto; +import co.yixiang.modules.user.service.dto.YxUserQueryCriteria; +import co.yixiang.modules.user.service.mapper.UserBillMapper; +import co.yixiang.modules.user.service.mapper.BxgUserMapper; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class YxUserServiceImpl extends BaseServiceImpl implements YxUserService { + + @Autowired + private IGenerator generator; + + @Autowired + private BxgUserMapper yxUserMapper; + @Autowired + private StoreOrderMapper storeOrderMapper; + @Autowired + private UserBillMapper userBillMapper; + + + @Autowired + private YxSystemUserLevelService systemUserLevelService; + @Autowired + private YxUserLevelService userLevelService; + @Autowired + private YxStoreOrderService orderService; + @Autowired + private YxSystemConfigService systemConfigService; + @Autowired + private YxUserBillService billService; + @Autowired + private YxStoreCouponUserService storeCouponUserService; + @Autowired + private YxSystemStoreStaffService systemStoreStaffService; + @Autowired + private YxStoreOrderCartInfoService storeOrderCartInfoService; + + + /** + * 返回用户累计充值金额与消费金额 + * @param uid uid + * @return Double[] + */ + @Override + public Double[] getUserMoney(Long uid){ + double sumPrice = storeOrderMapper.sumPrice(uid); + double sumRechargePrice = userBillMapper.sumRechargePrice(uid); + return new Double[]{sumPrice,sumRechargePrice}; + } + + + /** + * 增加购买次数 + * @param uid uid + */ + @Override + public void incPayCount(Long uid) { + yxUserMapper.incPayCount(uid); + } + + /** + * 减去用户余额 + * @param uid uid + * @param payPrice 金额 + */ + @Override + public void decPrice(Long uid, BigDecimal payPrice) { + yxUserMapper.decPrice(payPrice,uid); + } + + /** + * 减去用户积分 + * @param uid 用户id + * @param integral 积分 + */ + @Override + public void decIntegral(Long uid, double integral) { + yxUserMapper.decIntegral(integral,uid); + } + + + /** + * 获取我的分销下人员列表 + * @param uid uid + * @param page page + * @param limit limit + * @param grade ShopCommonEnum.GRADE_0 + * @param keyword 关键字搜索 + * @param sort 排序 + * @return list + */ + @Override + public List getUserSpreadGrade(Long uid, int page, int limit, Integer grade, + String keyword, String sort) { + List userList = yxUserMapper.selectList(Wrappers.lambdaQuery() + .eq(YxUser::getSpreadUid, uid)); + List userIds = userList.stream() + .map(YxUser::getUid) + .collect(Collectors.toList()); + + List list = new ArrayList<>(); + if (userIds.isEmpty()) { + return list; + } + + if (StrUtil.isBlank(sort)) { + sort = "u.uid desc"; + } + + Page pageModel = new Page<>(page, limit); + if (ShopCommonEnum.GRADE_0.getValue().equals(grade)) {//-级 + list = yxUserMapper.getUserSpreadCountList(pageModel, userIds, + keyword, sort); + } else {//二级 + List userListT = yxUserMapper.selectList(Wrappers.lambdaQuery() + .in(YxUser::getSpreadUid, userIds)); + List userIdsT = userListT.stream() + .map(YxUser::getUid) + .collect(Collectors.toList()); + if (userIdsT.isEmpty()) { + return list; + } + list = yxUserMapper.getUserSpreadCountList(pageModel, userIdsT, + keyword, sort); + + } + return list; + } + + /** + * 统计分销人员 + * @param uid uid + * @return map + */ + @Override + public Map getSpreadCount(Long uid) { + Long countOne = yxUserMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxUser::getSpreadUid,uid)); + + Long countTwo = 0L; + List userList = yxUserMapper.selectList((Wrappers.lambdaQuery() + .eq(YxUser::getSpreadUid,uid))); + List userIds = userList.stream().map(YxUser::getUid) + .collect(Collectors.toList()); + if(!userIds.isEmpty()){ + countTwo = yxUserMapper.selectCount(Wrappers.lambdaQuery() + .in(YxUser::getSpreadUid,userIds)); + } + + Map map = new LinkedHashMap<>(2); + map.put("first",countOne); //一级 + map.put("second",countTwo);//二级 + + return map; + } + + /** + * 一级返佣 + * @param order 订单 + */ + @Override + public void backOrderBrokerage(YxStoreOrderQueryVo order) { + //如果分销没开启直接返回 + String open = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_OPEN); + if(StrUtil.isBlank(open) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(open)) { + return; + } + + + //获取购买商品的用户 + YxUser userInfo = this.getById(order.getUid()); + System.out.println("userInfo:"+userInfo); + //当前用户不存在 没有上级 直接返回 + if(ObjectUtil.isNull(userInfo) || userInfo.getSpreadUid() == 0) { + return; + } + + + YxUser preUser = this.getById(userInfo.getSpreadUid()); + + //一级返佣金额 + BigDecimal brokeragePrice = this.computeProductBrokerage(order, Brokerage.LEVEL_1); + + //返佣金额小于等于0 直接返回不返佣金 + + if(brokeragePrice.compareTo(BigDecimal.ZERO) <= 0) { + return; + } + + //计算上级推广员返佣之后的金额 + double balance = NumberUtil.add(preUser.getBrokeragePrice(),brokeragePrice).doubleValue(); + String mark = userInfo.getNickname()+"成功消费"+order.getPayPrice()+"元,奖励推广佣金"+ + brokeragePrice; + //增加流水 + billService.income(userInfo.getSpreadUid(),"获得推广佣金",BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_2.getValue(),brokeragePrice.doubleValue(),balance, mark,order.getId().toString()); + + //添加用户余额 + yxUserMapper.incBrokeragePrice(brokeragePrice, userInfo.getSpreadUid()); + + //一级返佣成功 跳转二级返佣 + this.backOrderBrokerageTwo(order); + + } + + + + + /** + * 更新用户余额 + * @param uid y用户id + * @param price 金额 + */ + @Override + public void incMoney(Long uid, BigDecimal price) { + if(price!=null&&price.doubleValue()>0){ + yxUserMapper.incMoney(uid,price); + } + } + + /** + * 增加积分 + * @param uid uid + * @param integral 积分 + */ + @Override + public void incIntegral(Long uid, double integral) { + yxUserMapper.incIntegral(integral,uid); + } + + + /** + * 获取用户信息 + * @param uid uid + * @return YxUserQueryVo + */ + @Override + public YxUserQueryVo getYxUserById(Long uid) { + return generator.convert(this.getById(uid),YxUserQueryVo.class); + } + + + /** + * 转换用户信息 + * @param yxUser user + * @return YxUserQueryVo + */ + @Override + public YxUserQueryVo handleUser(YxUser yxUser) { + return generator.convert(yxUser,YxUserQueryVo.class); + } + + /** + * 获取用户个人详细信息 + * @param yxUser yxUser + * @return YxUserQueryVo + */ + @Override + public YxUserQueryVo getNewYxUserById(YxUser yxUser) { + YxUserQueryVo userQueryVo = generator.convert(yxUser,YxUserQueryVo.class); + if(userQueryVo == null){ + throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED); + } + userQueryVo.setOrderStatusNum(orderService.orderData(yxUser.getUid())); + userQueryVo.setCouponCount(storeCouponUserService.getUserValidCouponCount(yxUser.getUid())); + //判断分销类型,指定分销废弃掉,只有一种分销方式 + /** + String statu = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_STATU); + if(StrUtil.isNotEmpty(statu)){ + userQueryVo.setStatu(Integer.valueOf(statu)); + }else{ + userQueryVo.setStatu(0); + } + **/ + + //获取核销权限 + userQueryVo.setCheckStatus(systemStoreStaffService.checkStatus(yxUser.getUid(),null)); + + this.setUserSpreadCount(yxUser); + return userQueryVo; + } + + + + /** + * 返回会员价 + * @param price 原价 + * @param uid 用户id + * @return vip 价格 + */ + @Override + public double setLevelPrice(double price, long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxUserLevel::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()) + .eq(YxUserLevel::getUid,uid) + .orderByDesc(YxUserLevel::getGrade) + .last("limit 1"); + YxUserLevel userLevel = userLevelService.getOne(wrapper); + YxSystemUserLevel systemUserLevel = new YxSystemUserLevel(); + if(ObjectUtil.isNotNull(userLevel)) { + systemUserLevel= systemUserLevelService.getById(userLevel.getLevelId()); + } + int discount = 100; + if(ObjectUtil.isNotNull(userLevel)) { + discount = systemUserLevel.getDiscount().intValue(); + } + return NumberUtil.mul(NumberUtil.div(discount,100),price); + } + + + /** + * 设置推广关系 + * @param spread 上级人 + * @param uid 本人 + */ + @Override + public void setSpread(String spread, long uid) { + if(StrUtil.isBlank(spread) || !NumberUtil.isNumber(spread)) { + return; + } + + //如果分销没开启直接返回 + String open = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_OPEN); + if(StrUtil.isBlank(open) || ShopCommonEnum.ENABLE_2.getValue().toString().equals(open)) { + return; + } + //当前用户信息 + YxUser userInfo = this.getById(uid); + if(ObjectUtil.isNull(userInfo)) { + return; + } + + //当前用户有上级直接返回 + if(userInfo.getSpreadUid() != null && userInfo.getSpreadUid() > 0) { + return; + } + //没有推广编号直接返回 + long spreadInt = Long.valueOf(spread); + if(spreadInt == 0) { + return; + } + if(spreadInt == uid) { + return; + } + + //不能互相成为上下级 + YxUser userInfoT = this.getById(spreadInt); + if(ObjectUtil.isNull(userInfoT)) { + return; + } + + if(userInfoT.getSpreadUid() == uid) { + return; + } + + YxUser yxUser = YxUser.builder() + .spreadUid(spreadInt) + .spreadTime(new Date()) + .uid(uid) + .build(); + + yxUserMapper.updateById(yxUser); + + } + + + /** + * 二级返佣 + * @param order 订单 + */ + private void backOrderBrokerageTwo(YxStoreOrderQueryVo order) { + + YxUser userInfo = this.getById(order.getUid()); + + //获取上推广人 + YxUser userInfoTwo = this.getById(userInfo.getSpreadUid()); + + //上推广人不存在 或者 上推广人没有上级 直接返回 + if(ObjectUtil.isNull(userInfoTwo) || userInfoTwo.getSpreadUid() == 0) { + return; + } + + + //指定分销 判断 上上级是否时推广员 如果不是推广员直接返回 + YxUser preUser = this.getById(userInfoTwo.getSpreadUid()); + + + //二级返佣金额 + BigDecimal brokeragePrice = this.computeProductBrokerage(order,Brokerage.LEVEL_2); + + //返佣金额小于等于0 直接返回不返佣金 + if(brokeragePrice.compareTo(BigDecimal.ZERO) <= 0) { + return; + } + + //获取上上级推广员信息 + double balance = NumberUtil.add(preUser.getBrokeragePrice(),brokeragePrice).doubleValue(); + String mark = "二级推广人"+userInfo.getNickname()+"成功消费"+order.getPayPrice()+"元,奖励推广佣金"+ + brokeragePrice; + + //增加流水 + billService.income(userInfoTwo.getSpreadUid(),"获得推广佣金",BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_2.getValue(),brokeragePrice.doubleValue(),balance, mark,order.getId().toString()); + //添加用户余额 + yxUserMapper.incBrokeragePrice(brokeragePrice, + userInfoTwo.getSpreadUid()); + } + + + /** + * 计算获取返佣金额 + * @param order 订单信息 + * @param level 分销级别 + * @return double + */ + private BigDecimal computeProductBrokerage(YxStoreOrderQueryVo order , Brokerage level){ + List storeOrderCartInfoList = storeOrderCartInfoService + .list(Wrappers.lambdaQuery() + .in(YxStoreOrderCartInfo::getCartId, Arrays.asList(order.getCartId().split(",")))); + BigDecimal oneBrokerage = BigDecimal.ZERO;//一级返佣金额 + BigDecimal twoBrokerage = BigDecimal.ZERO;//二级返佣金额 + + List cartInfos = storeOrderCartInfoList.stream() + .map(YxStoreOrderCartInfo::getCartInfo) + .collect(Collectors.toList()); + + for (String cartInfo : cartInfos){ + YxStoreCartQueryVo cart = JSON.parseObject(cartInfo,YxStoreCartQueryVo.class); + + YxStoreProductQueryVo storeProductVO = cart.getProductInfo(); + //产品是否单独分销 + if(ShopCommonEnum.IS_SUB_1.getValue().equals(storeProductVO.getIsSub())){ + oneBrokerage = NumberUtil.round(NumberUtil.add(oneBrokerage, + NumberUtil.mul(cart.getCartNum(),storeProductVO.getAttrInfo().getBrokerage())) + ,2); + + twoBrokerage = NumberUtil.round(NumberUtil.add(twoBrokerage, + NumberUtil.mul(cart.getCartNum(),storeProductVO.getAttrInfo().getBrokerageTwo())) + ,2); + } + + } + + //获取后台一级返佣比例 + String storeBrokerageRatioStr = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_RATIO); + String storeBrokerageTwoStr = systemConfigService.getData(SystemConfigConstants.STORE_BROKERAGE_TWO); + + + //一级返佣比例未设置直接返回 + if(StrUtil.isBlank(storeBrokerageRatioStr) + || !NumberUtil.isNumber(storeBrokerageRatioStr)){ + return oneBrokerage; + } + //二级返佣比例未设置直接返回 + if(StrUtil.isBlank(storeBrokerageTwoStr) + || !NumberUtil.isNumber(storeBrokerageTwoStr)){ + return twoBrokerage; + } + + + switch (level){ + case LEVEL_1: + //根据订单获取一级返佣比例 + BigDecimal storeBrokerageRatio = NumberUtil.round(NumberUtil.div(storeBrokerageRatioStr,"100"),2); + BigDecimal brokeragePrice = NumberUtil + .round(NumberUtil.mul(order.getTotalPrice(),storeBrokerageRatio),2); + //固定返佣 + 比例返佣 = 总返佣金额 + return NumberUtil.add(oneBrokerage,brokeragePrice); + case LEVEL_2: + //根据订单获取一级返佣比例 + BigDecimal storeBrokerageTwo = NumberUtil.round(NumberUtil.div(storeBrokerageTwoStr,"100"),2); + BigDecimal storeBrokerageTwoPrice = NumberUtil + .round(NumberUtil.mul(order.getTotalPrice(),storeBrokerageTwo),2); + //固定返佣 + 比例返佣 = 总返佣金额 + return NumberUtil.add(twoBrokerage,storeBrokerageTwoPrice); + default: + } + + + return BigDecimal.ZERO; + + } + + + + /** + * 更新下级人数 + * @param yxUser user + */ + private void setUserSpreadCount(YxUser yxUser) { + Long count = yxUserMapper.selectCount(Wrappers.lambdaQuery() + .eq(YxUser::getSpreadUid,yxUser.getUid())); + yxUser.setSpreadCount(count); + yxUserMapper.updateById(yxUser); + } + + + //===========后面管理后台部分=====================// + + + /** + * 查看下级 + * @param uid uid + * @param grade 等级 + * @return list + */ + @Override + public List querySpread(Long uid, Integer grade) { + return this.getUserSpreadGrade(uid,1, 999,grade,"",""); + } + + + @Override + public Map queryAll(YxUserQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), YxUserDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxUserQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(YxUser.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxUserDto yxUser : all) { + Map map = new LinkedHashMap<>(); + map.put("用户账户(跟accout一样)", yxUser.getUsername()); + map.put("用户密码(跟pwd)", yxUser.getPassword()); + map.put("真实姓名", yxUser.getRealName()); + map.put("生日", yxUser.getBirthday()); + map.put("身份证号码", yxUser.getCardId()); + map.put("用户备注", yxUser.getMark()); + map.put("合伙人id", yxUser.getPartnerId()); + map.put("用户分组id", yxUser.getGroupId()); + map.put("用户昵称", yxUser.getNickname()); + map.put("用户头像", yxUser.getAvatar()); + map.put("手机号码", yxUser.getPhone()); + map.put("添加时间", yxUser.getCreateTime()); + map.put("添加ip", yxUser.getAddIp()); + map.put("用户余额", yxUser.getNowMoney()); + map.put("佣金金额", yxUser.getBrokeragePrice()); + map.put("用户剩余积分", yxUser.getIntegral()); + map.put("连续签到天数", yxUser.getSignNum()); + map.put("1为正常,0为禁止", yxUser.getStatus()); + map.put("等级", yxUser.getLevel()); + map.put("推广元id", yxUser.getSpreadUid()); + map.put("推广员关联时间", yxUser.getSpreadTime()); + map.put("用户类型", yxUser.getUserType()); + map.put("是否为推广员", yxUser.getIsPromoter()); + map.put("用户购买次数", yxUser.getPayCount()); + map.put("下级人数", yxUser.getSpreadCount()); + map.put("详细地址", yxUser.getAddres()); + map.put("管理员编号 ", yxUser.getAdminid()); + map.put("用户登陆类型,h5,wechat,routine", yxUser.getLoginType()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + /** + * 更新用户状态 + * @param uid uid + * @param status ShopCommonEnum + */ + @Override + public void onStatus(Long uid, Integer status) { + if(ShopCommonEnum.IS_STATUS_1.getValue().equals(status)){ + status = ShopCommonEnum.IS_STATUS_0.getValue(); + }else{ + status = ShopCommonEnum.IS_STATUS_1.getValue(); + } + yxUserMapper.updateOnstatus(status,uid); + } + + /** + * 修改余额 + * @param param UserMoneyDto + */ + @Override + public void updateMoney(UserMoneyDto param) { + YxUser yxUser = this.getById(param.getUid()); + double newMoney = 0d; + String mark = ""; + if(param.getPtype() == 1){ + mark = "系统增加了"+param.getMoney()+"余额"; + newMoney = NumberUtil.add(yxUser.getNowMoney(),param.getMoney()).doubleValue(); + billService.income(yxUser.getUid(),"系统增加余额", BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_6.getValue(),param.getMoney(),newMoney, mark,""); + }else{ + mark = "系统扣除了"+param.getMoney()+"余额"; + newMoney = NumberUtil.sub(yxUser.getNowMoney(),param.getMoney()).doubleValue(); + if(newMoney < 0) { + newMoney = 0d; + } + billService.expend(yxUser.getUid(), "系统减少余额", + BillDetailEnum.CATEGORY_1.getValue(), + BillDetailEnum.TYPE_7.getValue(), + param.getMoney(), newMoney, mark); + } +// YxUser user = new YxUser(); +// user.setUid(yxUser.getUid()); + yxUser.setNowMoney(BigDecimal.valueOf(newMoney)); + saveOrUpdate(yxUser); + } + + /** + * 增加佣金 + * @param price 金额 + * @param uid 用户id + */ + @Override + public void incBrokeragePrice(BigDecimal price, Long uid) { + yxUserMapper.incBrokeragePrice(price,uid); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserSignServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserSignServiceImpl.java new file mode 100644 index 00000000..1f9edb04 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserSignServiceImpl.java @@ -0,0 +1,222 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.BillDetailEnum; +import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.domain.YxUserBill; +import co.yixiang.modules.user.domain.YxUserSign; +import co.yixiang.modules.user.service.YxUserBillService; +import co.yixiang.modules.user.service.YxUserLevelService; +import co.yixiang.modules.user.service.YxUserService; +import co.yixiang.modules.user.service.YxUserSignService; +import co.yixiang.modules.user.service.mapper.UserBillMapper; +import co.yixiang.modules.user.service.mapper.YxUserSignMapper; +import co.yixiang.modules.user.vo.SignVo; +import co.yixiang.modules.user.vo.YxUserQueryVo; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; +import java.util.Map; + + +/** + *

+ * 签到记录表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-12-05 + */ +@Slf4j +@Service +@Transactional(rollbackFor = Exception.class) +public class YxUserSignServiceImpl extends BaseServiceImpl implements YxUserSignService { + + @Autowired + private YxUserSignMapper yxUserSignMapper; + @Autowired + private UserBillMapper userBillMapper; + + @Autowired + private IGenerator generator; + + @Autowired + private YxSystemGroupDataService systemGroupDataService; + @Autowired + private YxUserService yxUserService; + @Autowired + private YxUserBillService billService; + @Autowired + private YxUserLevelService userLevelService; + + + /** + * + * @param yxUser 用户 + * @return 签到积分 + */ + @Override + public int sign(YxUser yxUser) { + List list = systemGroupDataService.getDatas(ShopConstants.YSHOP_SIGN_DAY_NUM); + if(ObjectUtil.isNull(list) || list.isEmpty()) { + throw new YshopException("请先配置签到天数"); + } + + boolean isDaySign = this.getToDayIsSign(yxUser.getUid()); + if(isDaySign) { + throw new YshopException("已签到"); + } + int signNumber = 0; //积分 + int userSignNum = yxUser.getSignNum(); //签到次数 + if(getYesterDayIsSign(yxUser.getUid())){ + if(yxUser.getSignNum() > (list.size() - 1)){ + userSignNum = 0; + } + }else{ + userSignNum = 0; + } + int index = 0; + for (Map map : list) { + if(index == userSignNum){ + signNumber = Integer.valueOf(map.get("sign_num").toString()); + break; + } + index++; + } + + userSignNum += 1; + + YxUserSign userSign = new YxUserSign(); + userSign.setUid(yxUser.getUid()); + String title = "签到奖励"; + if(userSignNum == list.size()){ + title = "连续签到奖励"; + } + userSign.setTitle(title); + userSign.setNumber(signNumber); + userSign.setBalance(yxUser.getIntegral().intValue()); + yxUserSignMapper.insert(userSign); + + //用户积分增加 + YxUser user = YxUser.builder() + .integral(NumberUtil.add(yxUser.getIntegral(),signNumber)) + .uid(yxUser.getUid()) + .signNum(userSignNum) + .build(); + boolean res = yxUserService.updateById(user); + if(!res) { + throw new YshopException("签到失败"); + } + + //插入流水 + billService.income(yxUser.getUid(),title, BillDetailEnum.CATEGORY_2.getValue(), + BillDetailEnum.TYPE_10.getValue(),signNumber,yxUser.getIntegral().doubleValue(), + "",""); + + //检查是否符合会员升级条件 + userLevelService.setLevelComplete(yxUser.getUid()); + return signNumber; + } + + /** + * 分页获取用户签到数据 + * @param uid 用户id + * @param page page + * @param limit limit + * @return list + */ + @Override + public List getSignList(Long uid, int page, int limit) { + Page pageModel = new Page<>(page, limit); + return userBillMapper.getSignList(uid,pageModel); + } + + + /** + * 获取签到用户信息 + * @param yxUser yxUser + * @return YxUserQueryVo + */ + @Override + public YxUserQueryVo userSignInfo(YxUser yxUser) { + YxUserQueryVo userQueryVo = generator.convert(yxUser,YxUserQueryVo.class); + Long uid = yxUser.getUid(); + Long sumSignDay = this.getSignSumDay(uid); + boolean isDaySign = this.getToDayIsSign(uid); + boolean isYesterDaySign = this.getYesterDayIsSign(uid); + userQueryVo.setSumSignDay(sumSignDay); + userQueryVo.setIsDaySign(isDaySign); + userQueryVo.setIsYesterDaySign(isYesterDaySign); + if(!isDaySign && !isYesterDaySign) { + userQueryVo.setSignNum(0); + } + return userQueryVo; + } + + /** + * 获取用户今天是否签到 + * @param uid uid + * @return boolean true=YES false=NO + */ + private boolean getToDayIsSign(Long uid) { + Date today = DateUtil.beginOfDay(new Date()); + Long count = this.lambdaQuery().eq(YxUserSign::getUid,uid) + .ge(YxUserSign::getCreateTime,today) + .count(); + if(count > 0) { + return true; + } + return false; + } + + /** + * 获取用户昨天是否签到 + * @param uid uid + * @return boolean + */ + private boolean getYesterDayIsSign(Long uid) { + Date today = DateUtil.beginOfDay(new Date()); + Date yesterday = DateUtil.beginOfDay(DateUtil.yesterday()); + + Long count = this.lambdaQuery().eq(YxUserSign::getUid,uid) + .lt(YxUserSign::getCreateTime,today) + .ge(YxUserSign::getCreateTime,yesterday) + .count(); + if(count > 0) { + return true; + } + return false; + } + + /** + * 获取用户累计签到次数 + * @param uid 用户id + * @return int + */ + private Long getSignSumDay(Long uid) { + return this.lambdaQuery().eq(YxUserSign::getUid,uid).count(); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserTaskFinishServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserTaskFinishServiceImpl.java new file mode 100644 index 00000000..8cc0746e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/impl/YxUserTaskFinishServiceImpl.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.impl; + + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.user.domain.YxUserTaskFinish; +import co.yixiang.modules.user.service.YxUserTaskFinishService; +import co.yixiang.modules.user.service.mapper.YxUserTaskFinishMapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +/** + *

+ * 用户任务完成记录表 服务实现类 + *

+ * + * @author hupeng + * @since 2019-12-07 + */ +@Slf4j +@Service +@AllArgsConstructor +@Transactional(rollbackFor = Exception.class) +public class YxUserTaskFinishServiceImpl extends BaseServiceImpl implements YxUserTaskFinishService { + + private final YxUserTaskFinishMapper yxUserTaskFinishMapper; + + + /** + * 设置任务完成 + * @param uid uid + * @param taskId 任务id + */ + @Override + public void setFinish(Long uid, int taskId) { + Long count = this.lambdaQuery() + .eq(YxUserTaskFinish::getUid,uid) + .eq(YxUserTaskFinish::getTaskId,taskId) + .count(); + if(count == 0){ + YxUserTaskFinish userTaskFinish = new YxUserTaskFinish(); + userTaskFinish.setUid(uid); + userTaskFinish.setTaskId(taskId); + yxUserTaskFinishMapper.insert(userTaskFinish); + } + } + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/BxgUserMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/BxgUserMapper.java new file mode 100644 index 00000000..07602379 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/BxgUserMapper.java @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxUser; +import co.yixiang.modules.user.service.dto.PromUserDto; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +import java.math.BigDecimal; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface BxgUserMapper extends CoreMapper { + + + @Select("") + List getUserSpreadCountList(Page page, + @Param("uids") List uids, + @Param("keyword") String keyword, + @Param("orderByStr") String orderBy); + + @Update("update yx_user set now_money=now_money-#{payPrice}" + + " where uid=#{uid}") + int decPrice(@Param("payPrice") BigDecimal payPrice, @Param("uid") Long uid); +// +// @Update("update yx_user set brokerage_price=brokerage_price+#{brokeragePrice}" + +// " where uid=#{uid}") +// int incBrokeragePrice(@Param("brokeragePrice") double brokeragePrice,@Param("uid") int uid); + + @Update("update yx_user set pay_count=pay_count+1" + + " where uid=#{uid}") + int incPayCount(@Param("uid") Long uid); + + @Update("update yx_user set now_money=now_money+#{price}" + + " where uid=#{uid}") + int incMoney(@Param("uid") Long uid,BigDecimal price); + + @Update("update yx_user set integral=integral-#{integral}" + + " where uid=#{uid}") + int decIntegral(@Param("integral") double integral,@Param("uid") Long uid); + + @Update("update yx_user set integral=integral+#{integral}" + + " where uid=#{uid}") + int incIntegral(@Param("integral") double integral,@Param("uid") Long uid); + + @Update( "update yx_user set status = #{status} where uid = #{id}") + void updateOnstatus(@Param("status") Integer status, @Param("id") Long id); + + @Update( "update yx_user set now_money = now_money + ${money} where uid = #{id}") + void updateMoney(@Param("money") double money, @Param("id") long id); + + @Update("update yx_user set brokerage_price = brokerage_price+ ${price} where uid = #{id}") + void incBrokeragePrice(@Param("price") BigDecimal price,@Param("id") Long id); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/SystemUserLevelMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/SystemUserLevelMapper.java new file mode 100644 index 00000000..8ab2fe09 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/SystemUserLevelMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.shop.domain.YxSystemUserLevel; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface SystemUserLevelMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/SystemUserTaskMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/SystemUserTaskMapper.java new file mode 100644 index 00000000..cda325b1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/SystemUserTaskMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxSystemUserTask; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface SystemUserTaskMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/UserBillMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/UserBillMapper.java new file mode 100644 index 00000000..5e954eba --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/UserBillMapper.java @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxUserBill; +import co.yixiang.modules.user.service.dto.BillOrderRecordDto; +import co.yixiang.modules.user.service.dto.MUserBillDto; +import co.yixiang.modules.user.service.dto.YxUserBillDto; +import co.yixiang.modules.user.vo.BillVo; +import co.yixiang.modules.user.vo.SignVo; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface UserBillMapper extends CoreMapper { + + @Select("select IFNULL(sum(number),0) from yx_user_bill " + + "where status=1 and type='sign' and pm=1 and category='integral' " + + "and uid=#{uid}") + double sumIntegral(@Param("uid") Long uid); + + @Select("SELECT DATE_FORMAT(a.create_time,'%Y-%m-%d') as addTime,a.title,a.number " + + "FROM yx_user_bill a INNER JOIN yx_user u ON u.uid=a.uid WHERE a.category = 'integral'" + + " AND a.type = 'sign' AND a.status = 1 AND a.uid = #{uid} " + + "ORDER BY a.create_time DESC") + List getSignList(@Param("uid") Long uid, Page page); + + @Select("SELECT o.order_id as orderId,DATE_FORMAT(b.create_time, '%Y-%m-%d %H:%i') as time," + + "b.number,u.avatar,u.nickname FROM yx_user_bill b " + + "INNER JOIN yx_store_order o ON o.id=b.link_id " + + "RIGHT JOIN yx_user u ON u.uid=o.uid" + + " WHERE b.uid = #{uid} AND ( DATE_FORMAT(b.create_time, '%Y-%m')= #{time} ) AND " + + "b.category = 'now_money' AND b.type = 'brokerage' ORDER BY time DESC") + List getBillOrderRList(@Param("time") String time, @Param("uid") Long uid); + + @Select("SELECT DATE_FORMAT(create_time,'%Y-%m') as time " + + " FROM yx_user_bill ${ew.customSqlSegment}") + List getBillOrderList(@Param(Constants.WRAPPER) Wrapper userWrapper, Page page); + + @Select("SELECT DATE_FORMAT(create_time,'%Y-%m') as time,group_concat(id SEPARATOR ',') ids " + + " FROM yx_user_bill ${ew.customSqlSegment}") + List getBillList(@Param(Constants.WRAPPER) Wrapper userWrapper, Page page); + + @Select("SELECT DATE_FORMAT(create_time,'%Y-%m-%d %H:%i') as add_time,title,number,pm " + + " FROM yx_user_bill ${ew.customSqlSegment}") + List getUserBillList(@Param(Constants.WRAPPER) Wrapper userWrapper); + + @Select("select IFNULL(sum(number),0) from yx_user_bill " + + "where status=1 and type='brokerage' and pm=1 and category='now_money' " + + "and uid=#{uid}") + double sumPrice(@Param("uid") int uid); + + @Select("select IFNULL(sum(number),0) from yx_user_bill " + + "where status=1 and type='recharge' and pm=1 and category='now_money' " + + "and uid=#{uid}") + double sumRechargePrice(@Param("uid") Long uid); + + + @Select("select IFNULL(sum(number),0) from yx_user_bill " + + "where status=1 and type='brokerage' and pm=1 and category='now_money' " + + "and uid=#{uid} and TO_DAYS(NOW()) - TO_DAYS(create_time) <= 1") + double sumYesterdayPrice(@Param("uid") Long uid); + + @Select(" ") + List findAllByQueryCriteria(@Param("category") String category, @Param("type") String type, @Param("nickname") String nickname, @Param("pm") Integer pm, @Param("date")String date, @Param("date1")String date1,@Param("title")String title); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/UserRechargeMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/UserRechargeMapper.java new file mode 100644 index 00000000..f0107a59 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/UserRechargeMapper.java @@ -0,0 +1,22 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxUserRecharge; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-12 +*/ +@Repository +public interface UserRechargeMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserAddressMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserAddressMapper.java new file mode 100644 index 00000000..33a5e000 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserAddressMapper.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + + +import co.yixiang.modules.user.domain.YxUserAddress; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +/** + *

+ * 用户地址表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-10-28 + */ +@Repository +public interface YxUserAddressMapper extends BaseMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserLevelMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserLevelMapper.java new file mode 100644 index 00000000..36c944d8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserLevelMapper.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxUserLevel; +import co.yixiang.modules.user.service.dto.UserLevelInfoDto; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +/** + *

+ * 用户等级记录表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-12-06 + */ +@Repository +public interface YxUserLevelMapper extends CoreMapper { + + @Select("SELECT l.id,a.add_time as addTime,l.discount,a.level_id as levelId,l.name," + + "l.icon,l.grade FROM yx_user_level a INNER JOIN yx_system_user_level l " + + "ON l.id=a.level_id WHERE a.status = 1 AND a.is_del = 0 AND a.id = #{id} LIMIT 1") + UserLevelInfoDto getUserLevelInfo(int id); + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserSignMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserSignMapper.java new file mode 100644 index 00000000..8dc930d7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserSignMapper.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxUserSign; +import org.springframework.stereotype.Repository; + +/** + *

+ * 签到记录表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-12-05 + */ +@Repository +public interface YxUserSignMapper extends CoreMapper { + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserTaskFinishMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserTaskFinishMapper.java new file mode 100644 index 00000000..5e612371 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/service/mapper/YxUserTaskFinishMapper.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.modules.user.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.user.domain.YxUserTaskFinish; +import org.springframework.stereotype.Repository; + +/** + *

+ * 用户任务完成记录表 Mapper 接口 + *

+ * + * @author hupeng + * @since 2019-12-07 + */ +@Repository +public interface YxUserTaskFinishMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/BillVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/BillVo.java new file mode 100644 index 00000000..730a664b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/BillVo.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.user.vo; + +import co.yixiang.modules.user.service.dto.MUserBillDto; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.List; + +/** + * @ClassName BillVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/11/12 + **/ +@Data +public class BillVo { + private String time; + @JsonIgnore + private String ids; + private List list; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/CityVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/CityVo.java new file mode 100644 index 00000000..eec82ac2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/CityVo.java @@ -0,0 +1,33 @@ +package co.yixiang.modules.user.vo; + + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.io.Serializable; +import java.util.List; + + +/** + * 商城商品分类CateVO + * @author hupeng + * @since 2020-05-07 + */ +@Getter +@Setter +@ToString +public class CityVo implements Serializable { + + private static final long serialVersionUID = 1L; + + private Integer v; //id + + private String n; //名称 + + private Integer pid; + + private List c; //子集 + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/OnlineUser.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/OnlineUser.java new file mode 100644 index 00000000..9e202e31 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/OnlineUser.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.user.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author hupeng + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class OnlineUser implements Serializable { + + private String userName; + + private String nickName; + + private String job; + + private String browser; + + private String ip; + + private String address; + + private String key; + + private Date loginTime; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/SignVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/SignVo.java new file mode 100644 index 00000000..cbbcfe62 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/SignVo.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.user.vo; + + +import lombok.Data; + +import java.io.Serializable; + + +/** + * @ClassName SignVo + * @Author hupeng <610796224@qq.com> + * @Date 2019/12/5 + **/ +@Data +public class SignVo implements Serializable { + private String addTime; + private String title; + private Integer number; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxSystemUserLevelQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxSystemUserLevelQueryVo.java new file mode 100644 index 00000000..1d85e193 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxSystemUserLevelQueryVo.java @@ -0,0 +1,66 @@ +package co.yixiang.modules.user.vo; + + +import co.yixiang.modules.user.service.dto.TaskDto; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + *

+ * 设置用户等级表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-06 + */ +@Data +@ApiModel(value = "YxSystemUserLevelQueryVo对象", description = "设置用户等级表查询参数") +public class YxSystemUserLevelQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "商户id") + private Integer merId; + + @ApiModelProperty(value = "会员名称") + private String name; + + @ApiModelProperty(value = "购买金额") + private BigDecimal money; + + @ApiModelProperty(value = "有效时间") + private Integer validDate; + + + @ApiModelProperty(value = "会员等级") + private Integer grade; + + @ApiModelProperty(value = "享受折扣") + private BigDecimal discount; + + @ApiModelProperty(value = "会员卡背景") + private String image; + + @ApiModelProperty(value = "会员图标") + private String icon; + + @ApiModelProperty(value = "说明") + private String explain; + + @ApiModelProperty(value = "添加时间") + private Integer addTime; + + private TaskDto taskList; + + private Boolean isClear; + + private Integer isForever; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxSystemUserTaskQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxSystemUserTaskQueryVo.java new file mode 100644 index 00000000..5a225926 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxSystemUserTaskQueryVo.java @@ -0,0 +1,62 @@ +package co.yixiang.modules.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 等级任务设置 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-06 + */ +@Data +@ApiModel(value = "YxSystemUserTaskQueryVo对象", description = "等级任务设置查询参数") +public class YxSystemUserTaskQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "任务名称") + private String name; + + @ApiModelProperty(value = "配置原名") + private String realName; + + @ApiModelProperty(value = "任务类型") + private String taskType; + + @ApiModelProperty(value = "限定数") + private Integer number; + + @ApiModelProperty(value = "等级id") + private Integer levelId; + + @ApiModelProperty(value = "排序") + private Integer sort; + + @ApiModelProperty(value = "是否显示") + private Integer isShow; + + @ApiModelProperty(value = "是否务必达成任务,1务必达成,0=满足其一") + private Integer isMust; + + @ApiModelProperty(value = "任务说明") + private String illustrate; + + @ApiModelProperty(value = "新增时间") + private Integer addTime; + + private Integer newNumber;//已经完成了多少 + + private Integer speed;//进度比例 + + private Integer finish;//是否完成 + + private String taskTypeTitle;//任务类型标题 + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserAddressQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserAddressQueryVo.java new file mode 100644 index 00000000..679cd349 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserAddressQueryVo.java @@ -0,0 +1,59 @@ +package co.yixiang.modules.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 用户地址表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-28 + */ +@Data +@ApiModel(value = "YxUserAddressQueryVo对象", description = "用户地址表查询参数") +public class YxUserAddressQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户地址id") + private Long id; + + @ApiModelProperty(value = "用户id") + private Long uid; + + @ApiModelProperty(value = "收货人姓名") + private String realName; + + @ApiModelProperty(value = "收货人电话") + private String phone; + + @ApiModelProperty(value = "收货人所在省") + private String province; + + @ApiModelProperty(value = "收货人所在市") + private String city; + + @ApiModelProperty(value = "收货人所在区") + private String district; + + @ApiModelProperty(value = "收货人详细地址") + private String detail; + + @ApiModelProperty(value = "邮编") + private Integer postCode; + + @ApiModelProperty(value = "经度") + private String longitude; + + @ApiModelProperty(value = "纬度") + private String latitude; + + @ApiModelProperty(value = "是否默认") + private Integer isDefault; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserBillQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserBillQueryVo.java new file mode 100644 index 00000000..77b41458 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserBillQueryVo.java @@ -0,0 +1,49 @@ +package co.yixiang.modules.user.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + *

+ * 用户账单表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-27 + */ +@Data +@ApiModel(value = "YxUserBillQueryVo对象", description = "用户账单表查询参数") +public class YxUserBillQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户账单id") + private Long id; + + + + @ApiModelProperty(value = "0 = 支出 1 = 获得") + private Integer pm; + + @ApiModelProperty(value = "账单标题") + private String title; + + @ApiModelProperty(value = "明细数字") + private BigDecimal number; + + + @ApiModelProperty(value = "备注") + private String mark; + + @ApiModelProperty(value = "添加时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + private Date createTime; + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserQueryVo.java new file mode 100644 index 00000000..e8f65504 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserQueryVo.java @@ -0,0 +1,141 @@ +package co.yixiang.modules.user.vo; + + +import co.yixiang.modules.order.vo.UserOrderCountVo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + *

+ * 用户表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-10-16 + */ +@Data +@ApiModel(value = "YxUserQueryVo对象", description = "用户表查询参数") +public class YxUserQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "用户id") + private Long uid; + + @ApiModelProperty(value = "用户账户(跟accout一样)") + private String username; + + @ApiModelProperty(value = "用户账号") + private String account; + + @ApiModelProperty(value = "优惠券数量") + private Long couponCount = 0L; + + @ApiModelProperty(value = "订单详情数据") + private UserOrderCountVo orderStatusNum; + + + private Integer statu; + + @ApiModelProperty(value = "总的签到天数") + private Long sumSignDay; + + @ApiModelProperty(value = "当天是否签到") + private Boolean isDaySign; + + @ApiModelProperty(value = "昨天是否签到") + private Boolean isYesterDaySign; + + @ApiModelProperty(value = "核销权限") + private Boolean checkStatus; + + + + @ApiModelProperty(value = "真实姓名") + private String realName; + + @ApiModelProperty(value = "生日") + private Integer birthday; + + @ApiModelProperty(value = "身份证号码") + @JsonIgnore + private String cardId; + + @ApiModelProperty(value = "用户备注") + private String mark; + + + @ApiModelProperty(value = "用户昵称") + private String nickname; + + @ApiModelProperty(value = "用户头像") + private String avatar; + + @ApiModelProperty(value = "手机号码") + private String phone; + + @ApiModelProperty(value = "添加ip") + private String addIp; + + @ApiModelProperty(value = "最后一次登录ip") + private String lastIp; + + @ApiModelProperty(value = "用户余额") + private BigDecimal nowMoney; + + @ApiModelProperty(value = "佣金金额") + private BigDecimal brokeragePrice; + + @ApiModelProperty(value = "用户剩余积分") + private BigDecimal integral; + + @ApiModelProperty(value = "连续签到天数") + private Integer signNum; + + @ApiModelProperty(value = "1为正常,0为禁止") + private Boolean status; + + @ApiModelProperty(value = "等级") + private Integer level; + + @ApiModelProperty(value = "推广元id") + private Long spreadUid; + + @ApiModelProperty(value = "用户类型") + private String userType; + + @ApiModelProperty(value = "是否为推广员") + private Integer isPromoter; + + @ApiModelProperty(value = "用户购买次数") + private Integer payCount; + + @ApiModelProperty(value = "下级人数") + private Integer spreadCount; + + @ApiModelProperty(value = "详细地址") + private String addres; + + @ApiModelProperty(value = "管理员编号 ") + private Integer adminid; + + @ApiModelProperty(value = "用户登陆类型,h5,wechat,routine") + private String loginType; + + @ApiModelProperty(value = "是否会员") + private Boolean vip; + + @ApiModelProperty(value = "会员ID") + private Integer vipId; + + @ApiModelProperty(value = "会员图标") + private String vipIcon; + + @ApiModelProperty(value = "会员名称") + private String vipName; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserSignQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserSignQueryVo.java new file mode 100644 index 00000000..8e32fd8f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserSignQueryVo.java @@ -0,0 +1,39 @@ +package co.yixiang.modules.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 签到记录表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-05 + */ +@Data +@ApiModel(value = "YxUserSignQueryVo对象", description = "签到记录表查询参数") +public class YxUserSignQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "用户uid") + private Integer uid; + + @ApiModelProperty(value = "签到说明") + private String title; + + @ApiModelProperty(value = "获得积分") + private Integer number; + + @ApiModelProperty(value = "剩余积分") + private Integer balance; + + @ApiModelProperty(value = "添加时间") + private Integer addTime; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserTaskFinishQueryVo.java b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserTaskFinishQueryVo.java new file mode 100644 index 00000000..c5b10830 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/user/vo/YxUserTaskFinishQueryVo.java @@ -0,0 +1,36 @@ +package co.yixiang.modules.user.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + *

+ * 用户任务完成记录表 查询结果对象 + *

+ * + * @author hupeng + * @date 2019-12-07 + */ +@Data +@ApiModel(value = "YxUserTaskFinishQueryVo对象", description = "用户任务完成记录表查询参数") +public class YxUserTaskFinishQueryVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer id; + + @ApiModelProperty(value = "任务id") + private Integer taskId; + + @ApiModelProperty(value = "用户id") + private Integer uid; + + @ApiModelProperty(value = "是否有效") + private Boolean status; + + @ApiModelProperty(value = "添加时间") + private Integer addTime; + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatArticleController.java b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatArticleController.java new file mode 100644 index 00000000..3ec1655a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatArticleController.java @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.wechat.rest; + +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.services.WechatArticleService; +import co.yixiang.modules.mp.domain.YxArticle; +import co.yixiang.modules.mp.service.YxArticleService; +import co.yixiang.modules.mp.service.dto.YxArticleDto; +import co.yixiang.modules.mp.service.dto.YxArticleQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-10-07 +*/ +@Api(tags = "商城:微信图文管理") +@RestController +@RequestMapping("api") +public class WechatArticleController { + + private final YxArticleService yxArticleService; + private final WechatArticleService wechatArticleService; + + public WechatArticleController(YxArticleService yxArticleService,WechatArticleService wechatArticleService) { + this.yxArticleService = yxArticleService; + this.wechatArticleService = wechatArticleService; + } + + @ApiOperation(value = "查询单条信息") + @GetMapping(value = "/yxArticle/info/{id}") + @PreAuthorize("hasAnyRole('admin','YXARTICLE_ALL','YXARTICLE_GET')") + public ResponseEntity getInfo(@PathVariable Integer id){ + return new ResponseEntity<>(yxArticleService.getById(id),HttpStatus.OK); + } + + @ApiOperation(value = "查询") + @GetMapping(value = "/yxArticle") + @PreAuthorize("hasAnyRole('admin','YXARTICLE_ALL','YXARTICLE_SELECT')") + public ResponseEntity getYxArticles(YxArticleQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxArticleService.queryAll(criteria,pageable),HttpStatus.OK); + } + + + @ApiOperation(value = "新增") + @PostMapping(value = "/yxArticle") + @PreAuthorize("hasAnyRole('admin','YXARTICLE_ALL','YXARTICLE_CREATE')") + public ResponseEntity create(@Validated @RequestBody YxArticle resources){ + return new ResponseEntity<>(yxArticleService.save(resources),HttpStatus.CREATED); + } + + + @ApiOperation(value = "修改") + @PutMapping(value = "/yxArticle") + @PreAuthorize("hasAnyRole('admin','YXARTICLE_ALL','YXARTICLE_EDIT')") + public ResponseEntity update(@Validated @RequestBody YxArticle resources){ + yxArticleService.saveOrUpdate(resources); + return new ResponseEntity(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @ApiOperation(value = "删除") + @DeleteMapping(value = "/yxArticle/{id}") + @PreAuthorize("hasAnyRole('admin','YXARTICLE_ALL','YXARTICLE_DELETE')") + public ResponseEntity delete(@PathVariable Integer id){ + yxArticleService.removeById(id); + return new ResponseEntity(HttpStatus.OK); + } + + @ForbidSubmit + @ApiOperation(value = "发布文章") + @GetMapping(value = "/yxArticle/publish/{id}") + @PreAuthorize("hasAnyRole('admin','YXARTICLE_ALL','YXARTICLE_DELETE')") + public ResponseEntity publish(@PathVariable Integer id) throws Exception{ + YxArticleDto yxArticleDTO= new YxArticleDto(); + YxArticle yxArticle = yxArticleService.getById(id); + BeanUtils.copyProperties(yxArticle,yxArticleDTO); + wechatArticleService.publish(yxArticleDTO); + return new ResponseEntity(HttpStatus.OK); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatMenuController.java b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatMenuController.java new file mode 100644 index 00000000..239d199d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatMenuController.java @@ -0,0 +1,96 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.wechat.rest; + + +import co.yixiang.constant.ShopConstants; +import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.mp.domain.YxWechatMenu; +import co.yixiang.modules.mp.service.YxWechatMenuService; +import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.utils.OrderUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import me.chanjar.weixin.common.bean.menu.WxMenu; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-10-06 +*/ +@Api(tags = "商城:微信菜單") +@RestController +@RequestMapping("api") +@SuppressWarnings("unchecked") +public class WechatMenuController { + + private final YxWechatMenuService YxWechatMenuService; + + public WechatMenuController(YxWechatMenuService YxWechatMenuService) { + this.YxWechatMenuService = YxWechatMenuService; + } + + @ApiOperation(value = "查询菜单") + @GetMapping(value = "/YxWechatMenu") + @PreAuthorize("hasAnyRole('admin','YxWechatMenu_ALL','YxWechatMenu_SELECT')") + public ResponseEntity getYxWechatMenus(){ + return new ResponseEntity(YxWechatMenuService.getOne(new LambdaQueryWrapper() + .eq(YxWechatMenu::getKey,ShopConstants.WECHAT_MENUS)),HttpStatus.OK); + } + + @ForbidSubmit + @ApiOperation(value = "创建菜单") + @PostMapping(value = "/YxWechatMenu") + @PreAuthorize("hasAnyRole('admin','YxWechatMenu_ALL','YxWechatMenu_CREATE')") + public ResponseEntity create( @RequestBody String jsonStr){ + JSONObject jsonObject = JSON.parseObject(jsonStr); + String jsonButton = jsonObject.get("buttons").toString(); + YxWechatMenu YxWechatMenu = new YxWechatMenu(); + Boolean isExist = YxWechatMenuService.isExist(ShopConstants.WECHAT_MENUS); + WxMenu menu = JSONObject.parseObject(jsonStr,WxMenu.class); + + WxMpService wxService = WxMpConfiguration.getWxMpService(); + if(isExist){ + YxWechatMenu.setKey(ShopConstants.WECHAT_MENUS); + YxWechatMenu.setResult(jsonButton); + YxWechatMenuService.saveOrUpdate(YxWechatMenu); + }else { + YxWechatMenu.setKey(ShopConstants.WECHAT_MENUS); + YxWechatMenu.setResult(jsonButton); + YxWechatMenu.setAddTime(OrderUtil.getSecondTimestampTwo()); + YxWechatMenuService.save(YxWechatMenu); + } + + + //创建菜单 + try { + wxService.getMenuService().menuDelete(); + wxService.getMenuService().menuCreate(menu); + } catch (WxErrorException e) { + throw new BadRequestException(e.getMessage()); + // e.printStackTrace(); + } + + return new ResponseEntity(HttpStatus.OK); + } + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatReplyController.java b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatReplyController.java new file mode 100644 index 00000000..e3f18e0e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatReplyController.java @@ -0,0 +1,74 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.wechat.rest; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.mp.domain.YxWechatReply; +import co.yixiang.modules.mp.service.YxWechatReplyService; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** +* @author hupeng +* @date 2019-10-10 +*/ +@Api(tags = "商城:微信回復管理") +@RestController +@RequestMapping("api") +public class WechatReplyController { + + private final YxWechatReplyService yxWechatReplyService; + + public WechatReplyController(YxWechatReplyService yxWechatReplyService) { + this.yxWechatReplyService = yxWechatReplyService; + } + + @ApiOperation(value = "查询") + @GetMapping(value = "/yxWechatReply") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXWECHATREPLY_ALL','YXWECHATREPLY_SELECT')") + public ResponseEntity getYxWechatReplys(){ + return new ResponseEntity<>(yxWechatReplyService.isExist("subscribe"),HttpStatus.OK); + } + + + @ForbidSubmit + @ApiOperation(value = "新增自动回复") + @PostMapping(value = "/yxWechatReply") + @PreAuthorize("@ss.hasAnyPermissions('admin','YXWECHATREPLY_ALL','YXWECHATREPLY_CREATE')") + public ResponseEntity create(@RequestBody String jsonStr){ + JSONObject jsonObject = JSON.parseObject(jsonStr); + YxWechatReply yxWechatReply = new YxWechatReply(); + YxWechatReply isExist = yxWechatReplyService.isExist(jsonObject.get("key").toString()); + yxWechatReply.setKey(jsonObject.get("key").toString()); + yxWechatReply.setStatus(Integer.valueOf(jsonObject.get("status").toString())); + yxWechatReply.setData(jsonObject.get("data").toString()); + yxWechatReply.setType(jsonObject.get("type").toString()); + if(ObjectUtil.isNull(isExist)){ + yxWechatReplyService.create(yxWechatReply); + }else{ + yxWechatReply.setId(isExist.getId()); + yxWechatReplyService.upDate(yxWechatReply); + } + + return new ResponseEntity(HttpStatus.CREATED); + } + + + + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatTemplateController.java b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatTemplateController.java new file mode 100644 index 00000000..aa3ba9fd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/WechatTemplateController.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.modules.wechat.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.mp.domain.YxWechatTemplate; +import co.yixiang.modules.mp.service.YxWechatTemplateService; +import co.yixiang.modules.mp.service.dto.YxWechatTemplateDto; +import co.yixiang.modules.mp.service.dto.YxWechatTemplateQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** +* @author hupeng +* @date 2019-12-10 +*/ +@Api(tags = "商城:微信模板管理") +@RestController +@RequestMapping("/api/yxWechatTemplate") +@AllArgsConstructor +public class WechatTemplateController { + + + private final YxWechatTemplateService yxWechatTemplateService; + private final IGenerator generator; + + + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatTemplate:list')") + public void download(HttpServletResponse response, YxWechatTemplateQueryCriteria criteria) throws IOException { + yxWechatTemplateService.download(generator.convert(yxWechatTemplateService.queryAll(criteria), YxWechatTemplateDto.class), response); + } + + @GetMapping + @ApiOperation("查询微信模板消息") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatTemplate:list')") + public ResponseEntity getYxWechatTemplates(YxWechatTemplateQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxWechatTemplateService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @PostMapping + @ApiOperation("新增微信模板消息") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatTemplate:add')") + public ResponseEntity create(@Validated @RequestBody YxWechatTemplate resources){ + return new ResponseEntity<>(yxWechatTemplateService.save(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @PutMapping + @ApiOperation("修改微信模板消息") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatTemplate:edit')") + public ResponseEntity update(@Validated @RequestBody YxWechatTemplate resources){ + yxWechatTemplateService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @ApiOperation("删除微信模板消息") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatTemplate:del')") + @DeleteMapping("/{id}") + public ResponseEntity deleteAll(@PathVariable Integer id) { + yxWechatTemplateService.removeById(id); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/YxWechatLiveController.java b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/YxWechatLiveController.java new file mode 100644 index 00000000..f57cabc8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/YxWechatLiveController.java @@ -0,0 +1,122 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.wechat.rest; + +import co.yixiang.constant.ShopConstants; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.mp.domain.YxWechatLive; +import co.yixiang.modules.mp.service.YxWechatLiveService; +import co.yixiang.modules.mp.service.dto.UpdateGoodsDto; +import co.yixiang.modules.mp.service.dto.YxWechatLiveDto; +import co.yixiang.modules.mp.service.dto.YxWechatLiveQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; + +/** +* @author hupeng +* @date 2020-08-10 +*/ +@AllArgsConstructor +@Api(tags = "wxlive管理") +@RestController +@RequestMapping("/api/yxWechatLive") +public class YxWechatLiveController { + + private final YxWechatLiveService yxWechatLiveService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLive:list')") + public void download(HttpServletResponse response, YxWechatLiveQueryCriteria criteria) throws IOException { + yxWechatLiveService.download(generator.convert(yxWechatLiveService.queryAll(criteria), YxWechatLiveDto.class), response); + } + + @GetMapping + @Log("查询wxlive") + @ApiOperation("查询wxlive") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLive:list')") + public ResponseEntity getYxWechatLives(YxWechatLiveQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxWechatLiveService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @ForbidSubmit + @PostMapping + @Log("新增wxlive") + @ApiOperation("新增wxlive") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLive:add')") + public ResponseEntity create(@Validated @RequestBody YxWechatLive resources){ + return new ResponseEntity<>(yxWechatLiveService.saveLive(resources),HttpStatus.CREATED); + } + + + @ForbidSubmit + @PostMapping("/addGoods") + @Log("添加商品") + @ApiOperation("添加商品") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLive:add')") + public ResponseEntity addGoods(@Validated @RequestBody UpdateGoodsDto resources){ + return new ResponseEntity<>(yxWechatLiveService.addGoods(resources),HttpStatus.CREATED); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @ForbidSubmit + @PutMapping + @Log("修改wxlive") + @ApiOperation("修改wxlive") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLive:edit')") + public ResponseEntity update(@Validated @RequestBody YxWechatLive resources){ + yxWechatLiveService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @ForbidSubmit + @Log("删除wxlive") + @ApiOperation("删除wxlive") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLive:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + yxWechatLiveService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } + + @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) + @ApiOperation("同步数据") + @GetMapping("/synchro") + public ResponseEntity synchroWxOlLive() { + yxWechatLiveService.synchroWxOlLive(); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/YxWechatLiveGoodsController.java b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/YxWechatLiveGoodsController.java new file mode 100644 index 00000000..d722a841 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/wechat/rest/YxWechatLiveGoodsController.java @@ -0,0 +1,104 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.wechat.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.aop.ForbidSubmit; +import co.yixiang.modules.mp.domain.YxWechatLiveGoods; +import co.yixiang.modules.mp.service.YxWechatLiveGoodsService; +import co.yixiang.modules.mp.service.dto.YxWechatLiveGoodsDto; +import co.yixiang.modules.mp.service.dto.YxWechatLiveGoodsQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; + +/** +* @author hupeng +* @date 2020-08-11 +*/ +@AllArgsConstructor +@Api(tags = "yxWechatLiveGoods管理") +@RestController +@RequestMapping("/api/yxWechatLiveGoods") +public class YxWechatLiveGoodsController { + + private final YxWechatLiveGoodsService yxWechatLiveGoodsService; + private final IGenerator generator; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLiveGoods:list')") + public void download(HttpServletResponse response, YxWechatLiveGoodsQueryCriteria criteria) throws IOException { + yxWechatLiveGoodsService.download(generator.convert(yxWechatLiveGoodsService.queryAll(criteria), YxWechatLiveGoodsDto.class), response); + } + + @GetMapping + @Log("查询yxWechatLiveGoods") + @ApiOperation("查询yxWechatLiveGoods") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLiveGoods:list')") + public ResponseEntity getYxWechatLiveGoodss(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(yxWechatLiveGoodsService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @ForbidSubmit + @PostMapping + @Log("新增yxWechatLiveGoods") + @ApiOperation("新增yxWechatLiveGoods") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLiveGoods:add')") + public ResponseEntity create(@Validated @RequestBody YxWechatLiveGoods resources){ + return new ResponseEntity<>(yxWechatLiveGoodsService.saveGoods(resources),HttpStatus.CREATED); + } + + @ForbidSubmit + @PutMapping + @Log("修改yxWechatLiveGoods") + @ApiOperation("修改yxWechatLiveGoods") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLiveGoods:edit')") + public ResponseEntity update(@Validated @RequestBody YxWechatLiveGoods resources){ + yxWechatLiveGoodsService.updateGoods(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @ForbidSubmit + @Log("删除yxWechatLiveGoods") + @ApiOperation("删除yxWechatLiveGoods") + @PreAuthorize("@ss.hasAnyPermissions('admin','yxWechatLiveGoods:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + yxWechatLiveGoodsService.removeGoods(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } + + @ApiOperation("同步数据") + @PostMapping("/synchro") + public ResponseEntity synchroWxOlLiveGoods(@RequestBody Integer[] ids) { + yxWechatLiveGoodsService.synchroWxOlLive(Arrays.asList(ids)); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/print/OrderPrint.java b/zsw-bxg/src/main/java/co/yixiang/print/OrderPrint.java new file mode 100644 index 00000000..8e87141e --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/print/OrderPrint.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.print; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 打印订单数据 + */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OrderPrint { + private String title; + private String price; + private String num; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/print/PrintOrderDataVO.java b/zsw-bxg/src/main/java/co/yixiang/print/PrintOrderDataVO.java new file mode 100644 index 00000000..75306cff --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/print/PrintOrderDataVO.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.print; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @author :LionCity + * @date :Created in 2020-05-11 10:33 + * @description:打印数据VO + * @modified By: + * @version: V1.0 + */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PrintOrderDataVO implements Serializable{ + @ApiModelProperty(value = "订单号") + private String orderId; + @ApiModelProperty(value = "实际支付金额") + private BigDecimal payPrice; + @ApiModelProperty(value = "用户姓名") + private String realName; + @ApiModelProperty(value = "详细地址") + private String userAddress; + @ApiModelProperty(value = "用户电话") + private String userPhone; + @ApiModelProperty(value = "备注") + private String mark; + @ApiModelProperty(value = "门店名称") + private String storeName; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/print/PrintStoreOrderVO.java b/zsw-bxg/src/main/java/co/yixiang/print/PrintStoreOrderVO.java new file mode 100644 index 00000000..beb3a653 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/print/PrintStoreOrderVO.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.print; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author :LionCity + * @date :Created in 2020-05-11 11:01 + * @description:门店销售数据 + * @modified By: + * @version: V1.0 + */ +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class PrintStoreOrderVO implements Serializable { + @ApiModelProperty(value = "开始时间") + private String startTime; + @ApiModelProperty(value = "结束时间") + private String endTime; + @ApiModelProperty(value = "打印机编号") + private String driverNo; + @ApiModelProperty(value = "门店列表") + private Integer storeId; + @ApiModelProperty(hidden = true) + Long startSecond; + @ApiModelProperty(hidden = true) + Long endSecond; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/print/PrintUtil4.java b/zsw-bxg/src/main/java/co/yixiang/print/PrintUtil4.java new file mode 100644 index 00000000..5a2972e5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/print/PrintUtil4.java @@ -0,0 +1,594 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.print; + +import cn.hutool.http.HttpUtil; +import co.yixiang.constant.ShopConstants; +import co.yixiang.utils.DateUtils; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("static-access") +public class PrintUtil4 { + public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改 + + public static final String USER = "";//*必填*:账号名 + public static final String UKEY = "";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】 + public static final String SN = "918502791";//*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API + + /** + * 保存文件到磁盘 + * + * @param path 保存路径 + * @param content 打印内容 + * writeFile("E:/retlog.txt", result); + */ + public void writeFile(String path, String content) { + content = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒").format(new Date()) + ",保存的订单日志信息为: " + content; + FileOutputStream fos = null; + try { + fos = new FileOutputStream(path, true); + fos.write(content.getBytes()); + fos.write("\r
".getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fos != null) { + try { + fos.flush(); + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + + public static void main(String[] args) { + try { + System.out.println(new String(addPrintEquip("918502791", "nvz8kw5n", "测试", "").getBytes("ISO-8859-1"), "UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + /** + * 添加打印机 + * + * @param sn 编号 + * @param key 密钥 + * @param remark 备注 + * @param phone 流量卡号码 + * @return 返回打印结果 + */ + public static String addPrintEquip(String sn, String key, String remark, String phone) { + String printerContent = sn + " # " + key + " # " + remark + " # " + phone; + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user", USER)); + String STIME = String.valueOf(System.currentTimeMillis() / 1000); + nvps.add(new BasicNameValuePair("stime", STIME)); + nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME))); + nvps.add(new BasicNameValuePair("apiname", "Open_printerAddlist")); + nvps.add(new BasicNameValuePair("printerContent", printerContent));// 固定值,不需要修改 + return sendHttpRequest(nvps); + } + + /** + * 编辑打印机信息 + * + * @param sn 编号 + * @param remark 备注 + * @param phone 电话 + * @return 结果 + */ + public static String editPrintEquip(String sn, String remark, String phone) { + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user", USER)); + String STIME = String.valueOf(System.currentTimeMillis() / 1000); + nvps.add(new BasicNameValuePair("stime", STIME)); + nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME))); + nvps.add(new BasicNameValuePair("apiname", "Open_printerEdit")); + nvps.add(new BasicNameValuePair("sn", sn)); + nvps.add(new BasicNameValuePair("name", remark)); + nvps.add(new BasicNameValuePair("phonenum", phone)); + return sendHttpRequest(nvps); + } + + /** + * 打印订单数据 + * + * @param sn 打印机编号 + * @param contentTitle 打印标题 + * @param orderList 订单数据 + * @param order + * @return + */ + public static String printOrder(String sn, String contentTitle, List orderList, PrintOrderDataVO order, int lian) { + String content = getPrintContent(contentTitle, orderList, 14, 6, 3, 6, order, lian + 1);//orderList为数组 b1代表名称列占用(14个字节) b2单价列(6个字节) b3数量列(3个字节) b4金额列(6个字节)-->这里的字节数可按自己需求自由改写,14+6+3+6再加上代码写的3个空格就是32了,58mm打印机一行总占32字节 +// List nvps = new ArrayList(); +// nvps.add(new BasicNameValuePair("user", USER)); +// String STIME = String.valueOf(System.currentTimeMillis() / 1000); +// nvps.add(new BasicNameValuePair("stime", STIME)); +// nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME))); +// nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 +// nvps.add(new BasicNameValuePair("sn", sn)); +// nvps.add(new BasicNameValuePair("content", content)); +// nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 +// return sendHttpRequest(nvps); + return print(sn, content); + } + + + /** + * 打印预养订单 + * + * @param orderList 订单数据 + * @param title 标题 + * @param mobile 联系方式 + * @param name 用户姓名 + * @param payPrice 实际支付 + * @return + */ + public static String printOrderByAdvance(List orderList, String title, String mobile, String name, String payPrice) { + String content = getOrderByAdvance(orderList, 14, 6, 3, 6, title, mobile, name, payPrice);//orderList为数组 b1代表名称列占用(14个字节) b2单价列(6个字节) b3数量列(3个字节) b4金额列(6个字节)-->这里的字节数可按自己需求自由改写,14+6+3+6再加上代码写的3个空格就是32了,58mm打印机一行总占32字节 +// List nvps = new ArrayList(); +// nvps.add(new BasicNameValuePair("user", USER)); +// String STIME = String.valueOf(System.currentTimeMillis() / 1000); +// nvps.add(new BasicNameValuePair("stime", STIME)); +// nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME))); +// nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 +// nvps.add(new BasicNameValuePair("sn", SN)); +// nvps.add(new BasicNameValuePair("content", content)); +// nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 +// return sendHttpRequest(nvps); + return print(SN, content); + } + + /** + * 打印订单数据 + * + * @param contentTitle 打印标题 + * @param orderList 订单数据 + * @return + */ + public static String printContentByStore(String contentTitle, List orderList, int b1, int b3, PrintStoreOrderVO printStoreOrder, int lian) { + String content = getPrintContentByStore(contentTitle, orderList, b1, b3, printStoreOrder, lian + 1);//orderList为数组 b1代表名称列占用(14个字节) b2单价列(6个字节) b3数量列(3个字节) b4金额列(6个字节)-->这里的字节数可按自己需求自由改写,14+6+3+6再加上代码写的3个空格就是32了,58mm打印机一行总占32字节 +// List nvps = new ArrayList(); +// nvps.add(new BasicNameValuePair("user", USER)); +// String STIME = String.valueOf(System.currentTimeMillis() / 1000); +// nvps.add(new BasicNameValuePair("stime", STIME)); +// nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME))); +// nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 +// nvps.add(new BasicNameValuePair("sn", sn)); +// nvps.add(new BasicNameValuePair("content", content)); +// nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 +// return sendHttpRequest(nvps); + return print(printStoreOrder.getDriverNo(), content); + } + + /** + * 打印订单数据 + * + * @param sn 打印机编号 + * @param content 打印内容 + * @return + */ + public static String print(String sn, String content) { + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user", USER)); + String STIME = String.valueOf(System.currentTimeMillis() / 1000); + nvps.add(new BasicNameValuePair("stime", STIME)); + nvps.add(new BasicNameValuePair("sig", signature(USER, UKEY, STIME))); + nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 + nvps.add(new BasicNameValuePair("sn", sn)); + nvps.add(new BasicNameValuePair("content", content)); + nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 + return sendHttpRequest(nvps); + } + + + /** + * 获取预养订单文本信息 + * + * @return + */ + public static String getOrderByAdvance(List orderList, int b1, int b2, int b3, int b4, String headTitle, String mobile, String name, String payPrice) { + String orderInfo = "" + headTitle + "
"; + orderInfo += "名称 单价 数量 金额
"; + orderInfo += "--------------------------------
"; + double totals = 0.0; + for (int i = 0; i < orderList.size(); i++) { + String title = orderList.get(i).getTitle(); + String price = orderList.get(i).getPrice(); + String num = orderList.get(i).getNum(); + String total = "" + Double.valueOf(price) * Integer.parseInt(num); + totals += Double.parseDouble(total); + price = addSpace(price, b2); + num = addSpace(num, b3); + total = addSpace(total, b4); + String otherStr = " " + price + num + " " + total; + + int tl = 0; + try { + tl = title.getBytes("GBK").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + int spaceNum = (tl / b1 + 1) * b1 - tl; + if (tl < b1) { + for (int k = 0; k < spaceNum; k++) { + title += " "; + } + title += otherStr; + } else if (tl == b1) { + title += otherStr; + } else { + List list = null; + if (isEn(title)) { + list = getStrList(title, b1); + } else { + list = getStrList(title, b1 / 2); + } + String s0 = titleAddSpace(list.get(0)); + title = s0 + otherStr + "
";// 添加 单价 数量 总额 + String s = ""; + for (int k = 1; k < list.size(); k++) { + s += list.get(k); + } + try { + s = getStringByEnter(b1, s); + } catch (Exception e) { + e.printStackTrace(); + } + title += s; + } + orderInfo += title + "
"; + } + orderInfo += "--------------------------------
"; + + orderInfo += "合计:" + totals + "元
"; + orderInfo += "实付:" + payPrice + "元
"; + //orderInfo += "送货地点:广州市南沙区xx路xx号
"; + orderInfo += "联系人:" + name + "
"; + orderInfo += "联系电话:" + mobile + "
"; + orderInfo += "下单时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "
"; + //orderInfo += "https://admin.jidanguo10.com/weixin?id=2"; + return orderInfo; + } + + + /** + * 打印各门店订单数据信息 + * + * @param contentTitle + * @param orderList + * @param b1 + * @param b3 + * @param lian + * @return + */ + public static String getPrintContentByStore(String contentTitle, List orderList, int b1, int b3, PrintStoreOrderVO printStoreOrder, int lian) { + String orderInfo = "----第" + lian + "联----
"; + orderInfo += "" + contentTitle + "
"; + orderInfo += "名称 数量
"; + orderInfo += "--------------------------------
"; + for (int i = 0; i < orderList.size(); i++) { + String title = orderList.get(i).getTitle(); + String num = orderList.get(i).getNum(); + num = addSpace(num, b3); + String otherStr = " " + num; + + int tl = 0; + try { + tl = title.getBytes("GBK").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + int spaceNum = (tl / b1 + 1) * b1 - tl; + if (tl < b1) { + for (int k = 0; k < spaceNum; k++) { + title += " "; + } + title += otherStr; + } else if (tl == b1) { + title += otherStr; + } else { + List list = null; + if (isEn(title)) { + list = getStrList(title, b1); + } else { + list = getStrList(title, b1 / 2); + } + String s0 = titleAddSpace(list.get(0)); + title = s0 + otherStr + "
";// 添加 单价 数量 总额 + String s = ""; + for (int k = 1; k < list.size(); k++) { + s += list.get(k); + } + try { + s = getStringByEnter(b1, s); + } catch (Exception e) { + e.printStackTrace(); + } + title += s; + } + orderInfo += title + "
"; + } + orderInfo += "--------------------------------
"; + orderInfo += "社区门店:" + contentTitle + "
"; + orderInfo += "开始时间:" + printStoreOrder.getStartTime() + "
"; + orderInfo += "截止时间:" + printStoreOrder.getEndTime() + "
"; + orderInfo += "打印时间:" + DateUtils.getTime() + "
"; + //orderInfo += "https://admin.jidanguo10.com/weixin?id=2"; + return orderInfo; + } + + + //orderList为数组 b1代表名称列占用字节 b2单价列 b3数量列 b4金额列-->这里的字节数可按自己需求自由改写,详细往上看112行调用实际例子运用 + + /** + * 获取打印订单的文本内容 + * + * @param contentTitle 打印内容标题 + * @param orderList 订单数据 + * @param b1 + * @param b2 + * @param b3 + * @param b4 + * @param order + * @return + */ + public static String getPrintContent(String contentTitle, List orderList, int b1, int b2, int b3, int b4, PrintOrderDataVO order, int lian) { + String orderInfo = "----第" + lian + "联----
"; + orderInfo += "" + contentTitle + "
"; + orderInfo += "名称 单价 数量 金额
"; + orderInfo += "--------------------------------
"; + double totals = 0.0; + for (int i = 0; i < orderList.size(); i++) { + String title = orderList.get(i).getTitle(); + String price = orderList.get(i).getPrice(); + String num = orderList.get(i).getNum(); + String total = "" + Double.valueOf(price) * Integer.parseInt(num); + totals += Double.parseDouble(total); + price = addSpace(price, b2); + num = addSpace(num, b3); + total = addSpace(total, b4); + String otherStr = " " + price + num + " " + total; + + int tl = 0; + try { + tl = title.getBytes("GBK").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + int spaceNum = (tl / b1 + 1) * b1 - tl; + if (tl < b1) { + for (int k = 0; k < spaceNum; k++) { + title += " "; + } + title += otherStr; + } else if (tl == b1) { + title += otherStr; + } else { + List list = null; + if (isEn(title)) { + list = getStrList(title, b1); + } else { + list = getStrList(title, b1 / 2); + } + String s0 = titleAddSpace(list.get(0)); + title = s0 + otherStr + "
";// 添加 单价 数量 总额 + String s = ""; + for (int k = 1; k < list.size(); k++) { + s += list.get(k); + } + try { + s = getStringByEnter(b1, s); + } catch (Exception e) { + e.printStackTrace(); + } + title += s; + } + orderInfo += title + "
"; + } + orderInfo += "--------------------------------
"; + orderInfo += "社区门店:" + order.getStoreName() + "
"; + orderInfo += "订单编号:" + order.getOrderId() + "
"; + orderInfo += "合计:" + totals + "元
"; + orderInfo += "实付:" + order.getPayPrice() + "元
"; + //orderInfo += "送货地点:广州市南沙区xx路xx号
"; + orderInfo += "联系人:" + order.getRealName() + "
"; + orderInfo += "详细地址:" + order.getUserAddress() + "
"; + orderInfo += "联系电话:" + order.getUserPhone() + "
"; + orderInfo += "下单时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "
"; + orderInfo += "备注:" + order.getMark() + "
"; + //orderInfo += "https://admin.jidanguo10.com/weixin?id=2"; + return orderInfo; + } + + + /** + * 发送打印请求 + * + * @param nvps + * @return + */ + public static String sendHttpRequest(List nvps) { + // 通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)// 读取超时 + .setConnectTimeout(30000)// 连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build(); + + HttpPost post = new HttpPost(URL); + CloseableHttpResponse response = null; + String result = null; + try { + post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if (statecode == 200) { + HttpEntity httpentity = response.getEntity(); + if (httpentity != null) { + // 服务器返回的JSON字符串,建议要当做日志记录起来 + result = EntityUtils.toString(httpentity); + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + close(response, post, httpClient); + } + return result; + } + + /** + * 关闭流 + * + * @param response + * @param post + * @param httpClient + */ + public static void close(CloseableHttpResponse response, HttpPost post, CloseableHttpClient httpClient) { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + public static String titleAddSpace(String str) { + int k = 0; + int b = 14; + try { + k = str.getBytes("GBK").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + for (int i = 0; i < b - k; i++) { + str += " "; + } + return str; + } + + public static String getStringByEnter(int length, String string) throws Exception { + for (int i = 1; i <= string.length(); i++) { + if (string.substring(0, i).getBytes("GBK").length > length) { + return string.substring(0, i - 1) + "
" + getStringByEnter(length, string.substring(i - 1)); + } + } + return string; + } + + /** + * 添加空格,文本对齐 + * + * @param str + * @param size + * @return + */ + public static String addSpace(String str, int size) { + int len = str.length(); + if (len < size) { + for (int i = 0; i < size - len; i++) { + str += " "; + } + } + return str; + } + + public static Boolean isEn(String str) { + Boolean b = false; + try { + b = str.getBytes("GBK").length == str.length(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return b; + } + + public static List getStrList(String inputString, int length) { + int size = inputString.length() / length; + if (inputString.length() % length != 0) { + size += 1; + } + return getStrList(inputString, length, size); + } + + public static List getStrList(String inputString, int length, int size) { + List list = new ArrayList(); + for (int index = 0; index < size; index++) { + String childStr = substring(inputString, index * length, (index + 1) * length); + list.add(childStr); + } + return list; + } + + /** + * 字符串切割 + * + * @param str + * @param f + * @param t + * @return + */ + public static String substring(String str, int f, int t) { + if (f > str.length()) { + return null; + } + if (t > str.length()) { + return str.substring(f, str.length()); + } else { + return str.substring(f, t); + } + } + + /** + * 签名 + * + * @param USER 用户 + * @param UKEY UKEY + * @param STIME 时间戳 + * @return {@link String} + */ + private static String signature(String USER, String UKEY, String STIME) { + return DigestUtils.sha1Hex(USER + UKEY + STIME); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/serializer/BigDecimalSerializer.java b/zsw-bxg/src/main/java/co/yixiang/serializer/BigDecimalSerializer.java new file mode 100644 index 00000000..953dae92 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/serializer/BigDecimalSerializer.java @@ -0,0 +1,28 @@ +package co.yixiang.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.math.BigDecimal; +import java.text.DecimalFormat; + +/** + * @author :LionCity + * @date :Created in 2020-05-30 14:12 + * @description: + * @modified By: + * @version: + */ +public class BigDecimalSerializer extends JsonSerializer { + @Override + public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { + if (value != null && !"".equals(value)) { + DecimalFormat df2 =new DecimalFormat("0.00"); + gen.writeString(df2.format(value)); + } else { + gen.writeString(value + ""); + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/serializer/DoubleSerializer.java b/zsw-bxg/src/main/java/co/yixiang/serializer/DoubleSerializer.java new file mode 100644 index 00000000..d23311fd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/serializer/DoubleSerializer.java @@ -0,0 +1,27 @@ +package co.yixiang.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.text.DecimalFormat; + +/** + * @author :LionCity + * @date :Created in 2020-05-30 14:12 + * @description: + * @modified By: + * @version: + */ +public class DoubleSerializer extends JsonSerializer { + @Override + public void serialize(Double value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { + if (value != null && !"".equals(value)) { + DecimalFormat df2 =new DecimalFormat("0.00"); + gen.writeString(df2.format(value)); + } else { + gen.writeString(value + ""); + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/AlipayConfig.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/AlipayConfig.java new file mode 100644 index 00000000..c8eb6ed6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/AlipayConfig.java @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ + +@Data +@TableName("yx_alipay_config") +public class AlipayConfig implements Serializable { + + /** 主键 */ + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + // @Column(name = "id") + private Long id; + + + /** 应用ID */ + // @Column(name = "app_id") + private String appId; + + + /** 编码 */ + // @Column(name = "charset") + private String charset; + + + /** 类型 固定格式json */ + // @Column(name = "format") + private String format; + + + /** 网关地址 */ + // @Column(name = "gateway_url") + private String gatewayUrl; + + + /** 异步回调 */ + // @Column(name = "notify_url") + private String notifyUrl; + + + /** 私钥 */ + // @Column(name = "private_key") + private String privateKey; + + + /** 公钥 */ + // @Column(name = "public_key") + private String publicKey; + + + /** 回调地址 */ + // @Column(name = "return_url") + private String returnUrl; + + + /** 签名方式 */ + // @Column(name = "sign_type") + private String signType; + + + /** 商户号 */ + // @Column(name = "sys_service_provider_id") + private String sysServiceProviderId; + + + public void copy(AlipayConfig source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/EmailConfig.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/EmailConfig.java new file mode 100644 index 00000000..2ea1acf6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/EmailConfig.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ + +@Data +@TableName("yx_email_config") +public class EmailConfig implements Serializable { + + /** ID */ + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + // @Column(name = "id") + private Long id; + + + /** 收件人 */ + // @Column(name = "from_user") + private String fromUser; + + + /** 邮件服务器SMTP地址 */ + // @Column(name = "host") + private String host; + + + /** 密码 */ + // @Column(name = "pass") + private String pass; + + + /** 端口 */ + // @Column(name = "port") + private String port; + + + /** 发件者用户名 */ + // @Column(name = "user") + private String user; + + + public void copy(EmailConfig source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/LocalStorage.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/LocalStorage.java new file mode 100644 index 00000000..18b4d826 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/LocalStorage.java @@ -0,0 +1,90 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-13 +*/ + +@Getter +@Setter +@TableName("yx_local_storage") +public class LocalStorage implements Serializable { + + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + // @Column(name = "id") + private Long id; + + + /** 文件真实的名称 */ + // @Column(name = "real_name") + private String realName; + + + /** 文件名 */ + // @Column(name = "name") + private String name; + + + /** 后缀 */ + // @Column(name = "suffix") + private String suffix; + + + /** 路径 */ + // @Column(name = "path") + private String path; + + + /** 类型 */ + // @Column(name = "type") + private String type; + + + /** 大小 */ + // @Column(name = "size") + private String size; + + + /** 操作人 */ + // @Column(name = "operate") + private String operate; + + + /** 创建日期 */ + // @Column(name = "create_time") + @TableField(fill= FieldFill.INSERT) + private Timestamp createTime; + + + public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) { + this.realName = realName; + this.name = name; + this.suffix = suffix; + this.path = path; + this.type = type; + this.size = size; + this.operate = operate; + } + + public void copy(LocalStorage source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/Picture.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/Picture.java new file mode 100644 index 00000000..69573c3a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/Picture.java @@ -0,0 +1,83 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-13 +*/ + +@Data +@TableName("yx_picture") +public class Picture implements Serializable { + + /** ID */ + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + // @Column(name = "id") + private Long id; + + + /** 上传日期 */ + // @Column(name = "create_time") + @TableField(fill= FieldFill.INSERT) + private Timestamp createTime; + + + /** 删除的URL */ + // @Column(name = "delete_url") + private String deleteUrl; + + + /** 图片名称 */ + // @Column(name = "filename") + private String filename; + + + /** 图片高度 */ + // @Column(name = "height") + private String height; + + + /** 图片大小 */ + // @Column(name = "size") + private String size; + + + /** 图片地址 */ + // @Column(name = "url") + private String url; + + + /** 用户名称 */ + // @Column(name = "username") + private String username; + + + /** 图片宽度 */ + // @Column(name = "width") + private String width; + + + /** 文件的MD5值 */ + // @Column(name = "md5code") + private String md5code; + + public void copy(Picture source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/QiniuConfig.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/QiniuConfig.java new file mode 100644 index 00000000..1dd88af2 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/QiniuConfig.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ + +@Data +@TableName("yx_qiniu_config") +public class QiniuConfig implements Serializable { + + /** ID */ + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + // @Column(name = "id") + private Long id; + + + /** accessKey */ + // @Column(name = "access_key") + private String accessKey; + + + /** Bucket 识别符 */ + // @Column(name = "bucket") + private String bucket; + + + /** 外链域名 */ + // @Column(name = "host",nullable = false) + private String host; + + + /** secretKey */ + // @Column(name = "secret_key") + private String secretKey; + + + /** 空间类型 */ + // @Column(name = "type") + private String type; + + + /** 机房 */ + // @Column(name = "zone") + private String zone; + + + public void copy(QiniuConfig source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/QiniuContent.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/QiniuContent.java new file mode 100644 index 00000000..7aaa68bf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/QiniuContent.java @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-13 +*/ + +@Data +@TableName("yx_qiniu_content") +public class QiniuContent implements Serializable { + + /** ID */ + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + // @Column(name = "id") + private Long id; + + + /** Bucket 识别符 */ + // @Column(name = "bucket") + private String bucket; + + + /** 文件名称 */ + @TableField("name") + private String name; + + + /** 文件大小 */ + // @Column(name = "size") + private String size; + + + /** 文件类型:私有或公开 */ + // @Column(name = "type") + private String type; + + + /** 上传或同步的时间 */ + // @Column(name = "update_time") + @TableField(fill= FieldFill.INSERT_UPDATE) + private Timestamp updateTime; + + + /** 文件url */ + // @Column(name = "url") + private String url; + + + // @Column(name = "suffix") + private String suffix; + + + public void copy(QiniuContent source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/VerificationCode.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/VerificationCode.java new file mode 100644 index 00000000..78a5b4cb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/VerificationCode.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * @author hupeng + * @date 2018-12-26 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("yx_verification_code") +public class VerificationCode implements Serializable { + + @TableId + //@GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String code; + + /** 使用场景,自己定义 */ + private String scenes; + + /** true 为有效,false 为无效,验证时状态+时间+具体的邮箱或者手机号 */ + private Boolean status = true; + + /** 类型 :phone 和 email */ + private String type; + + /** 具体的phone与email */ + private String value; + + /** 创建日期 */ + @TableField(fill= FieldFill.INSERT) + // @Column(name = "create_time") + private Timestamp createTime; + + public VerificationCode(String code, String scenes, @NotBlank String type, @NotBlank String value) { + this.code = code; + this.scenes = scenes; + this.type = type; + this.value = value; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/vo/EmailVo.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/vo/EmailVo.java new file mode 100644 index 00000000..1a286960 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/vo/EmailVo.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * 发送邮件时,接收参数的类 + * @author 郑杰 + * @date 2018/09/28 12:02:14 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class EmailVo { + + /** 收件人,支持多个收件人 */ + @NotEmpty + private List tos; + + @NotBlank + private String subject; + + @NotBlank + private String content; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/domain/vo/TradeVo.java b/zsw-bxg/src/main/java/co/yixiang/tools/domain/vo/TradeVo.java new file mode 100644 index 00000000..80ffaa4b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/domain/vo/TradeVo.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.domain.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.sql.Date; +import java.sql.Timestamp; + +/** + * 交易详情,按需应该存入数据库,这里存入数据库,仅供临时测试 + * @author hupeng + * @date 2018-12-31 + */ +@Data +public class TradeVo { + + /** (必填)商品描述 */ + @NotBlank + private String body; + + /** (必填)商品名称 */ + @NotBlank + private String subject; + + /** (必填)商户订单号,应该由后台生成 */ + @ApiModelProperty(hidden = true) + private String outTradeNo; + + /** (必填)第三方订单号 */ + @ApiModelProperty(hidden = true) + private String tradeNo; + + /** (必填)价格 */ + @NotBlank + private String totalAmount; + + /** 订单状态,已支付,未支付,作废 */ + @ApiModelProperty(hidden = true) + private String state; + + /** 创建时间,存入数据库时需要 */ + @ApiModelProperty(hidden = true) + private Timestamp createTime; + + /** 作废时间,存入数据库时需要 */ + @ApiModelProperty(hidden = true) + private Date cancelTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/express/ExpressService.java b/zsw-bxg/src/main/java/co/yixiang/tools/express/ExpressService.java new file mode 100644 index 00000000..cb062169 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/express/ExpressService.java @@ -0,0 +1,159 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.express; + +import cn.hutool.http.HttpUtil; +import co.yixiang.enums.ShipperCodeEnum; +import co.yixiang.tools.express.config.ExpressProperties; +import co.yixiang.tools.express.dao.ExpressInfo; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.util.Base64Utils; + +import java.io.Serializable; +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.util.HashMap; +import java.util.Map; + +/** + * 物流查询服务 + *

+ * 快递鸟即时查询API http://www.kdniao.com/api-track + */ +public class ExpressService implements Serializable { + + private final Log logger = LogFactory.getLog(ExpressService.class); + //请求url + private String ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; + + private ExpressProperties properties; + + public ExpressProperties getProperties() { + return properties; + } + + public void setProperties(ExpressProperties properties) { + this.properties = properties; + } + + /** + * 获取物流供应商名 + * + * @param vendorCode + * @return + */ + public String getVendorName(String vendorCode) { + for (Map item : properties.getVendors()) { + if (item.get("code").equals(vendorCode)) { + return item.get("name"); + } + } + return null; + } + + /** + * 获取物流信息 + * + * @param OrderCode + * @param ShipperCode + * @return + */ + public ExpressInfo getExpressInfo(String OrderCode,String ShipperCode, String LogisticCode,String lastFourNumber) { + try { + String result = getOrderTracesByJson(OrderCode,ShipperCode, LogisticCode,lastFourNumber); + ObjectMapper objMap = new ObjectMapper(); + ExpressInfo ei = objMap.readValue(result, ExpressInfo.class); + ei.setShipperName(getVendorName(ShipperCode)); + return ei; + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + return null; + } + + /** + * Json方式 查询订单物流轨迹 + * + * @throws Exception + */ + private String getOrderTracesByJson(String OrderCode,String ShipperCode, String LogisticCode,String lastFourNumber) throws Exception { + if (!properties.isEnable()) { + return null; + } + + //处理顺丰查询轨迹需手机号码后4位 + String requestData; + if (ShipperCode.equals(ShipperCodeEnum.SF.getValue())) { + requestData = "{'OrderCode':'" + OrderCode + "','ShipperCode':'" + ShipperCode + "','LogisticCode':'" + LogisticCode + "','CustomerName':'" + lastFourNumber + "'}"; + } else { + requestData = "{'OrderCode':'" + OrderCode + "','ShipperCode':'" + ShipperCode + "','LogisticCode':'" + LogisticCode + "'}"; + } + + Map params = new HashMap<>(); + params.put("RequestData", URLEncoder.encode(requestData, "UTF-8")); + params.put("EBusinessID", properties.getAppId()); + params.put("RequestType", "1002"); + String dataSign = encrypt(requestData, properties.getAppKey(), "UTF-8"); + params.put("DataSign", URLEncoder.encode(dataSign, "UTF-8")); + params.put("DataType", "2"); + + String result = HttpUtil.post(ReqURL, params); + + //根据公司业务处理返回的信息...... + + return result; + } + + /** + * MD5加密 + * + * @param str 内容 + * @param charset 编码方式 + * @throws Exception + */ + private String MD5(String str, String charset) throws Exception { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(str.getBytes(charset)); + byte[] result = md.digest(); + StringBuilder sb = new StringBuilder(32); + for (int i = 0; i < result.length; i++) { + int val = result[i] & 0xff; + if (val <= 0xf) { + sb.append("0"); + } + sb.append(Integer.toHexString(val)); + } + return sb.toString().toLowerCase(); + } + + /** + * Sign签名生成 + * + * @param content 内容 + * @param keyValue Appkey + * @param charset 编码方式 + * @return DataSign签名 + */ + private String encrypt(String content, String keyValue, String charset) { + if (keyValue != null) { + content = content + keyValue; + } + byte[] src; + try { + src = MD5(content, charset).getBytes(charset); + return Base64Utils.encodeToString(src); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } + + return null; + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/express/config/ExpressAutoConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/tools/express/config/ExpressAutoConfiguration.java new file mode 100644 index 00000000..2c440449 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/express/config/ExpressAutoConfiguration.java @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.tools.express.config; + + +import co.yixiang.constant.ShopConstants; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.tools.express.ExpressService; +import co.yixiang.utils.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +public class ExpressAutoConfiguration { + + + private static RedisUtils redisUtil; + + @Autowired + public ExpressAutoConfiguration(RedisUtils redisUtil) { + ExpressAutoConfiguration.redisUtil = redisUtil; + } + + public static ExpressService expressService() { + ExpressService expressService = (ExpressService)redisUtil.get(ShopConstants.YSHOP_EXPRESS_SERVICE); + if(expressService != null) { + return expressService; + } + + ExpressProperties properties = new ExpressProperties(); + String enable = redisUtil.getY("exp_enable"); + String appId = redisUtil.getY("exp_appId"); + String appKey = redisUtil.getY("exp_appKey"); + properties.setAppId(appId); + properties.setAppKey(appKey); + + if(ShopCommonEnum.ENABLE_2.getValue().toString().equals(enable)){ + properties.setEnable(false); + }else{ + properties.setEnable(true); + } + ExpressService service = new ExpressService(); + service.setProperties(properties); + redisUtil.set(ShopConstants.YSHOP_EXPRESS_SERVICE,service); + return service; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/express/config/ExpressProperties.java b/zsw-bxg/src/main/java/co/yixiang/tools/express/config/ExpressProperties.java new file mode 100644 index 00000000..877d8c83 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/express/config/ExpressProperties.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.express.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class ExpressProperties { + private boolean enable; + private String appId; + private String appKey; + private List> vendors = new ArrayList<>(); + + public boolean isEnable() { + return enable; + } + + public void setEnable(boolean enable) { + this.enable = enable; + } + + public List> getVendors() { + return vendors; + } + + public void setVendors(List> vendors) { + this.vendors = vendors; + } + + public String getAppKey() { + return appKey; + } + + public void setAppKey(String appKey) { + this.appKey = appKey; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/express/dao/ExpressInfo.java b/zsw-bxg/src/main/java/co/yixiang/tools/express/dao/ExpressInfo.java new file mode 100644 index 00000000..b4f0e871 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/express/dao/ExpressInfo.java @@ -0,0 +1,65 @@ +/** + * Copyright 2018 bejson.com + */ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.express.dao; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * Auto-generated: 2018-07-19 22:27:22 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +@Data +public class ExpressInfo { + + @JsonProperty("LogisticCode") + @ApiModelProperty(value = "物流运单号") + private String LogisticCode; + + @JsonProperty("ShipperCode") + @ApiModelProperty(value = "快递公司编码") + private String ShipperCode; + + + @JsonProperty("Traces") + @ApiModelProperty(value = "物流轨迹") + private List Traces; + + + @JsonProperty("State") + @ApiModelProperty(value = "物流状态:2-在途中,3-签收,4-问题件") + private String State; + + @JsonProperty("EBusinessID") + @ApiModelProperty(value = "用户ID") + private String EBusinessID; + + + @JsonProperty("Success") + @ApiModelProperty(value = "成功与否") + private boolean Success; + + + @JsonProperty("Reason") + @ApiModelProperty(value = "失败原因") + private String Reason; + + private String ShipperName; + + @JsonProperty("OrderCode") + @ApiModelProperty(value = "订单编号") + private String OrderCode; + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/express/dao/Traces.java b/zsw-bxg/src/main/java/co/yixiang/tools/express/dao/Traces.java new file mode 100644 index 00000000..8ba2403d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/express/dao/Traces.java @@ -0,0 +1,46 @@ +/** + * Copyright 2018 bejson.com + */ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.express.dao; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +/** + * Auto-generated: 2018-07-19 22:27:22 + * + * @author bejson.com (i@bejson.com) + * @website http://www.bejson.com/java2pojo/ + */ +public class Traces { + + @JsonProperty("AcceptStation") + @ApiModelProperty(value = "描述") + private String AcceptStation; + + @JsonProperty("AcceptTime") + @ApiModelProperty(value = "时间") + private String AcceptTime; + + public String getAcceptStation() { + return AcceptStation; + } + + public void setAcceptStation(String AcceptStation) { + this.AcceptStation = AcceptStation; + } + + public String getAcceptTime() { + return AcceptTime; + } + + public void setAcceptTime(String AcceptTime) { + this.AcceptTime = AcceptTime; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/AliPayController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/AliPayController.java new file mode 100644 index 00000000..584de796 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/AliPayController.java @@ -0,0 +1,136 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.tools.domain.AlipayConfig; +import co.yixiang.tools.domain.vo.TradeVo; +import co.yixiang.tools.service.AlipayConfigService; +import co.yixiang.tools.utils.AliPayStatusEnum; +import co.yixiang.tools.utils.AlipayUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.nio.charset.StandardCharsets; +import java.util.Map; + +/** + * @author hupeng + * @date 2018-12-31 + */ +@Slf4j +@RestController +@RequestMapping("/api/aliPay") +@Api(tags = "工具:支付宝管理") +public class AliPayController { + + private final AlipayUtils alipayUtils; + + private final AlipayConfigService alipayService; + + public AliPayController(AlipayUtils alipayUtils, AlipayConfigService alipayService) { + this.alipayUtils = alipayUtils; + this.alipayService = alipayService; + } + + @GetMapping + public ResponseEntity get(){ + return new ResponseEntity<>(alipayService.find(),HttpStatus.OK); + } + + @Log("配置支付宝") + @ApiOperation("配置支付宝") + @PutMapping + public ResponseEntity payConfig(@Validated @RequestBody AlipayConfig alipayConfig){ + alipayConfig.setId(1L); + alipayService.update(alipayConfig); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("支付宝PC网页支付") + @ApiOperation("PC网页支付") + @PostMapping(value = "/toPayAsPC") + public ResponseEntity toPayAsPc(@Validated@RequestBody TradeVo trade) throws Exception{ + AlipayConfig aliPay = alipayService.find(); + trade.setOutTradeNo(alipayUtils.getOrderCode()); + String payUrl = alipayService.toPayAsPc(aliPay,trade); + return ResponseEntity.ok(payUrl); + } + + @Log("支付宝手机网页支付") + @ApiOperation("手机网页支付") + @PostMapping(value = "/toPayAsWeb") + public ResponseEntity toPayAsWeb(@Validated @RequestBody TradeVo trade) throws Exception{ + AlipayConfig alipay = alipayService.find(); + trade.setOutTradeNo(alipayUtils.getOrderCode()); + String payUrl = alipayService.toPayAsWeb(alipay,trade); + return ResponseEntity.ok(payUrl); + } + + @ApiIgnore + @GetMapping("/return") + @AnonymousAccess + @ApiOperation("支付之后跳转的链接") + public ResponseEntity returnPage(HttpServletRequest request, HttpServletResponse response){ + AlipayConfig alipay = alipayService.find(); + response.setContentType("text/html;charset=" + alipay.getCharset()); + //内容验签,防止黑客篡改参数 + if(alipayUtils.rsaCheck(request,alipay)){ + //商户订单号 + String outTradeNo = new String(request.getParameter("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + //支付宝交易号 + String tradeNo = new String(request.getParameter("trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + System.out.println("商户订单号"+outTradeNo+" "+"第三方交易号"+tradeNo); + + // 根据业务需要返回数据,这里统一返回OK + return new ResponseEntity<>("payment successful",HttpStatus.OK); + }else{ + // 根据业务需要返回数据 + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + } + + @ApiIgnore + @RequestMapping("/notify") + @AnonymousAccess + @SuppressWarnings("all") + @ApiOperation("支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理") + public ResponseEntity notify(HttpServletRequest request){ + AlipayConfig alipay = alipayService.find(); + Map parameterMap = request.getParameterMap(); + //内容验签,防止黑客篡改参数 + if (alipayUtils.rsaCheck(request,alipay)) { + //交易状态 + String tradeStatus = new String(request.getParameter("trade_status").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + // 商户订单号 + String outTradeNo = new String(request.getParameter("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + //支付宝交易号 + String tradeNo = new String(request.getParameter("trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + //付款金额 + String totalAmount = new String(request.getParameter("total_amount").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + //验证 + if(tradeStatus.equals(AliPayStatusEnum.SUCCESS.getValue())||tradeStatus.equals(AliPayStatusEnum.FINISHED.getValue())){ + // 验证通过后应该根据业务需要处理订单 + } + return new ResponseEntity<>(HttpStatus.OK); + } + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/EmailController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/EmailController.java new file mode 100644 index 00000000..0fe415bd --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/EmailController.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.tools.domain.EmailConfig; +import co.yixiang.tools.domain.vo.EmailVo; +import co.yixiang.tools.service.EmailConfigService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 发送邮件 + * @author 郑杰 + * @date 2018/09/28 6:55:53 + */ +@RestController +@RequestMapping("api/email") +@Api(tags = "工具:邮件管理") +public class EmailController { + + private final EmailConfigService emailService; + + public EmailController(EmailConfigService emailService) { + this.emailService = emailService; + } + + @GetMapping + public ResponseEntity get(){ + return new ResponseEntity<>(emailService.find(),HttpStatus.OK); + } + + @Log("配置邮件") + @PutMapping + @ApiOperation("配置邮件") + public ResponseEntity emailConfig(@Validated @RequestBody EmailConfig emailConfig){ + emailService.update(emailConfig,emailService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("发送邮件") + @PostMapping + @ApiOperation("发送邮件") + public ResponseEntity send(@Validated @RequestBody EmailVo emailVo) throws Exception { + emailService.send(emailVo,emailService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/LocalStorageController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/LocalStorageController.java new file mode 100644 index 00000000..893bf080 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/LocalStorageController.java @@ -0,0 +1,92 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.tools.service.LocalStorageService; +import co.yixiang.tools.service.dto.LocalStorageDto; +import co.yixiang.tools.service.dto.LocalStorageQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Arrays; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@AllArgsConstructor +@Api(tags = "文件管理") +@RestController +@RequestMapping("/api/localStorage") +public class LocalStorageController { + + private final LocalStorageService localStorageService; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('admin','storage:list')") + public void download(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException { + localStorageService.download(generator.convert(localStorageService.queryAll(criteria), LocalStorageDto.class), response); + } + + @GetMapping + @Log("查询文件") + @ApiOperation("查询文件") + @PreAuthorize("@ss.hasAnyPermissions('admin','storage:list')") + public ResponseEntity getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增文件") + @ApiOperation("新增文件") + @PreAuthorize("@ss.hasAnyPermissions('admin','storage:add')") + public ResponseEntity create(@RequestParam String name, @RequestParam("file") MultipartFile file){ + return new ResponseEntity<>(localStorageService.create(name,file),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改文件") + @ApiOperation("修改文件") + @PreAuthorize("@ss.hasAnyPermissions('admin','storage:edit')") + public ResponseEntity update(@Validated @RequestBody LocalStorageDto resources){ + localStorageService.updateLocalStorage(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除文件") + @ApiOperation("删除文件") + @PreAuthorize("@ss.hasAnyPermissions('admin','storage:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(id->{ + localStorageService.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/PictureController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/PictureController.java new file mode 100644 index 00000000..cf416aeb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/PictureController.java @@ -0,0 +1,90 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.tools.domain.Picture; +import co.yixiang.tools.service.PictureService; +import co.yixiang.tools.service.dto.PictureDto; +import co.yixiang.tools.service.dto.PictureQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @author hupeng + * @date 2018/09/20 14:13:32 + */ +@RestController +@RequestMapping("/api/pictures") +@Api(tags = "工具:免费图床管理") +public class PictureController { + private final IGenerator generator; + private final PictureService pictureService; + + public PictureController(IGenerator generator, PictureService pictureService) { + this.generator = generator; + this.pictureService = pictureService; + } + + @Log("查询图片") + @PreAuthorize("@ss.hasAnyPermissions('pictures:list')") + @GetMapping + @ApiOperation("查询图片") + public ResponseEntity getRoles(PictureQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@ss.hasAnyPermissions('pictures:list')") + public void download(HttpServletResponse response, PictureQueryCriteria criteria) throws IOException { + pictureService.download(generator.convert(pictureService.queryAll(criteria), PictureDto.class), response); + } + + @Log("上传图片") + @PreAuthorize("@ss.hasAnyPermissions('pictures:add')") + @PostMapping + @ApiOperation("上传图片") + public ResponseEntity upload(@RequestParam MultipartFile file){ + String userName = "admin";//SecurityUtils.getUsername(); + Picture picture = pictureService.upload(file,userName); + return new ResponseEntity<>(picture,HttpStatus.OK); + } + + @Log("同步图床数据") + @ApiOperation("同步图床数据") + @PostMapping(value = "/synchronize") + public ResponseEntity synchronize(){ + pictureService.synchronize(); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("多选删除图片") + @ApiOperation("多选删除图片") + @PreAuthorize("@ss.hasAnyPermissions('pictures:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + pictureService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/QiniuController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/QiniuController.java new file mode 100644 index 00000000..c166bc27 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/QiniuController.java @@ -0,0 +1,125 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import co.yixiang.logging.aop.log.Log; +import co.yixiang.tools.domain.QiniuConfig; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.QiNiuService; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * 发送邮件 + * @author 郑杰 + * @date 2018/09/28 6:55:53 + */ +@Slf4j +@RestController +@RequestMapping("/api/qiNiuContent") +@Api(tags = "工具:七牛云存储管理") +public class QiniuController { + + private final QiNiuService qiNiuService; + + public QiniuController(QiNiuService qiNiuService) { + this.qiNiuService = qiNiuService; + } + + @GetMapping(value = "/config") + public ResponseEntity get(){ + return new ResponseEntity<>(qiNiuService.find(), HttpStatus.OK); + } + + @Log("配置七牛云存储") + @ApiOperation("配置七牛云存储") + @PutMapping(value = "/config") + public ResponseEntity emailConfig(@Validated @RequestBody QiniuConfig qiniuConfig){ + qiNiuService.update(qiniuConfig); + qiNiuService.update(qiniuConfig.getType()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + public void download(HttpServletResponse response, QiniuQueryCriteria criteria) throws IOException { + qiNiuService.downloadList(qiNiuService.queryAll(criteria), response); + } + + @Log("查询文件") + @ApiOperation("查询文件") + @GetMapping + public ResponseEntity getRoles(QiniuQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @Log("上传文件") + @ApiOperation("上传文件") + @PostMapping + public ResponseEntity upload(@RequestParam MultipartFile file){ + QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find()); + Map map = new HashMap<>(3); + map.put("id",qiniuContent.getId()); + map.put("errno",0); + map.put("data",new String[]{qiniuContent.getUrl()}); + return new ResponseEntity<>(map,HttpStatus.OK); + } + + @Log("同步七牛云数据") + @ApiOperation("同步七牛云数据") + @PostMapping(value = "/synchronize") + public ResponseEntity synchronize(){ + qiNiuService.synchronize(qiNiuService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("下载文件") + @ApiOperation("下载文件") + @GetMapping(value = "/download/{id}") + public ResponseEntity download(@PathVariable Long id){ + Map map = new HashMap<>(1); + map.put("url", qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.find())); + return new ResponseEntity<>(map,HttpStatus.OK); + } + + @Log("删除文件") + @ApiOperation("删除文件") + @DeleteMapping(value = "/{id}") + public ResponseEntity delete(@PathVariable Long id){ + qiNiuService.delete(qiNiuService.findByContentId(id),qiNiuService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("删除多张图片") + @ApiOperation("删除多张图片") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + qiNiuService.deleteAll(ids, qiNiuService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/UploadController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/UploadController.java new file mode 100644 index 00000000..67210a6d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/UploadController.java @@ -0,0 +1,98 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.YshopException; +import co.yixiang.constant.ShopConstants; +import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.LocalStorageService; +import co.yixiang.tools.service.QiNiuService; +import co.yixiang.tools.service.dto.LocalStorageDto; +import co.yixiang.utils.RedisUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author hupeng + * @date 2020-01-09 + */ +@Api(tags = "上传统一管理") +@RestController +@RequestMapping("/api/upload") +@Slf4j +@SuppressWarnings("unchecked") +public class UploadController { + + private final LocalStorageService localStorageService; + private final QiNiuService qiNiuService; + private final RedisUtils redisUtils; + + public UploadController(LocalStorageService localStorageService, QiNiuService qiNiuService, + RedisUtils redisUtils) { + this.localStorageService = localStorageService; + this.qiNiuService = qiNiuService; + this.redisUtils = redisUtils; + } + + + @ApiOperation("上传文件") + @PostMapping + public ResponseEntity create(@RequestParam(defaultValue = "") String name, + @RequestParam(defaultValue = "") String type, + @RequestParam("file") MultipartFile[] files) { + + String localUrl = redisUtils.getY(ShopConstants.ADMIN_API_URL); + if(StrUtil.isBlank(type)){ + localUrl = redisUtils.getY(SystemConfigConstants.API_URL) + "/api"; + } + String mode = redisUtils.getY(SystemConfigConstants.FILE_STORE_MODE); + StringBuilder url = new StringBuilder(); + if (ShopCommonEnum.STORE_MODE_1.getValue().toString().equals(mode)) { //存在走本地 + if(StrUtil.isBlank(localUrl)){ + throw new YshopException("本地上传,请先登陆系统配置后台/移动端API地址"); + } + for (MultipartFile file : files) { + LocalStorageDto localStorageDTO = localStorageService.create(name, file); + if ("".equals(url.toString())) { + url = url.append(localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName()); + } else { + url = url.append(","+localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName()); + } + } + } else {//走七牛云 + for (MultipartFile file : files) { + QiniuContent qiniuContent = qiNiuService.upload(file, qiNiuService.find()); + if ("".equals(url.toString())) { + url = url.append(qiniuContent.getUrl()); + }else{ + url = url.append(","+qiniuContent.getUrl()); + } + } + } + + Map map = new HashMap<>(2); + map.put("errno", 0); + map.put("link", url); + return new ResponseEntity(map, HttpStatus.CREATED); + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/rest/VerificationCodeController.java b/zsw-bxg/src/main/java/co/yixiang/tools/rest/VerificationCodeController.java new file mode 100644 index 00000000..ad032c9b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/rest/VerificationCodeController.java @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.rest; + +import co.yixiang.tools.domain.VerificationCode; +import co.yixiang.tools.domain.vo.EmailVo; +import co.yixiang.tools.service.EmailConfigService; +import co.yixiang.tools.service.VerificationCodeService; +import co.yixiang.utils.YshopConstant; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author hupeng + * @date 2018-12-26 + */ +@RestController +@RequestMapping("/api/code") +@Api(tags = "工具:验证码管理") +public class VerificationCodeController { + + private final VerificationCodeService verificationCodeService; + + private final EmailConfigService emailService; + + public VerificationCodeController(VerificationCodeService verificationCodeService, EmailConfigService emailService) { + this.verificationCodeService = verificationCodeService; + this.emailService = emailService; + } + + @PostMapping(value = "/resetEmail") + @ApiOperation("重置邮箱,发送验证码") + public ResponseEntity resetEmail(@RequestBody VerificationCode code) throws Exception { + code.setScenes(YshopConstant.RESET_MAIL); + EmailVo emailVo = verificationCodeService.sendEmail(code); + emailService.send(emailVo,emailService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PostMapping(value = "/email/resetPass") + @ApiOperation("重置密码,发送验证码") + public ResponseEntity resetPass(@RequestParam String email) throws Exception { + VerificationCode code = new VerificationCode(); + code.setType("email"); + code.setValue(email); + code.setScenes(YshopConstant.RESET_MAIL); + EmailVo emailVo = verificationCodeService.sendEmail(code); + emailService.send(emailVo,emailService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping(value = "/validated") + @ApiOperation("验证码验证") + public ResponseEntity validated(VerificationCode code){ + verificationCodeService.validated(code); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/AlipayConfigService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/AlipayConfigService.java new file mode 100644 index 00000000..9efee282 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/AlipayConfigService.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.tools.domain.AlipayConfig; +import co.yixiang.tools.domain.vo.TradeVo; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface AlipayConfigService extends BaseService{ + + /** + * 处理来自PC的交易请求 + * @param alipay 支付宝配置 + * @param trade 交易详情 + * @return String + * @throws Exception 异常 + */ + String toPayAsPc(AlipayConfig alipay, TradeVo trade) throws Exception; + + /** + * 处理来自手机网页的交易请求 + * @param alipay 支付宝配置 + * @param trade 交易详情 + * @return String + * @throws Exception 异常 + */ + String toPayAsWeb(AlipayConfig alipay, TradeVo trade) throws Exception; + + /** + * 查询配置 + * @return AlipayConfig + */ + AlipayConfig find(); + + /** + * 更新配置 + * @param alipayConfig 支付宝配置 + * @return AlipayConfig + */ + void update(AlipayConfig alipayConfig); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/EmailConfigService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/EmailConfigService.java new file mode 100644 index 00000000..3ff2df5d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/EmailConfigService.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.tools.domain.EmailConfig; +import co.yixiang.tools.domain.vo.EmailVo; +import org.springframework.scheduling.annotation.Async; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface EmailConfigService extends BaseService{ + /** + * 更新邮件配置 + * @param emailConfig 邮件配置 + * @param old 旧的配置 + * @return EmailConfig + */ + void update(EmailConfig emailConfig, EmailConfig old); + + /** + * 查询配置 + * @return EmailConfig 邮件配置 + */ + EmailConfig find(); + + /** + * 发送邮件 + * @param emailVo 邮件发送的内容 + * @param emailConfig 邮件配置 + * @throws Exception / + */ + @Async + void send(EmailVo emailVo, EmailConfig emailConfig) throws Exception; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/LocalStorageService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/LocalStorageService.java new file mode 100644 index 00000000..90d01688 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/LocalStorageService.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.tools.domain.LocalStorage; +import co.yixiang.tools.service.dto.LocalStorageDto; +import co.yixiang.tools.service.dto.LocalStorageQueryCriteria; +import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface LocalStorageService extends BaseService{ + + /** + * 分页查询 + * @param criteria 条件 + * @param pageable 分页参数 + * @return / + */ + Map queryAll(LocalStorageQueryCriteria criteria, Pageable pageable); + + /** + * 查询全部数据 + * @param criteria 条件 + * @return / + */ + List queryAll(LocalStorageQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id / + * @return / + */ + LocalStorageDto findById(Long id); + + /** + * 上传 + * @param name 文件名称 + * @param file 文件 + * @return / + */ + LocalStorageDto create(String name, MultipartFile file); + + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + /** + * 导出数据 + * @param localStorageDtos 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List localStorageDtos, HttpServletResponse response) throws IOException; + + /** + * 修改文件 + * @param resources + */ + void updateLocalStorage(LocalStorageDto resources); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/PictureService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/PictureService.java new file mode 100644 index 00000000..a2722257 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/PictureService.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.tools.domain.Picture; +import co.yixiang.tools.service.dto.PictureDto; +import co.yixiang.tools.service.dto.PictureQueryCriteria; +import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface PictureService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(PictureQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(PictureQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + + /** + * 上传文件 + * @param file / + * @param username / + * @return / + */ + Picture upload(MultipartFile file, String username); + + /** + * 根据ID查询 + * @param id / + * @return / + */ + Picture findById(Long id); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + + + /** + * 同步数据 + */ + void synchronize(); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/QiNiuService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/QiNiuService.java new file mode 100644 index 00000000..85bcf988 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/QiNiuService.java @@ -0,0 +1,108 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.tools.domain.QiniuConfig; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + * @author hupeng + * @date 2018-12-31 + */ +public interface QiNiuService { + + /** + * 分页查询 + * @param criteria 条件 + * @param pageable 分页参数 + * @return / + */ + Object queryAll(QiniuQueryCriteria criteria, Pageable pageable); + + /** + * 查询全部 + * @param criteria 条件 + * @return / + */ + List queryAll(QiniuQueryCriteria criteria); + + /** + * 查配置 + * @return QiniuConfig + */ + QiniuConfig find(); + + /** + * 修改配置 + * @param qiniuConfig 配置 + * @return QiniuConfig + */ + QiniuConfig update(QiniuConfig qiniuConfig); + + /** + * 上传文件 + * @param file 文件 + * @param qiniuConfig 配置 + * @return QiniuContent + */ + QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig); + + /** + * 查询文件 + * @param id 文件ID + * @return QiniuContent + */ + QiniuContent findByContentId(Long id); + + /** + * 下载文件 + * @param content 文件信息 + * @param config 配置 + * @return String + */ + String download(QiniuContent content, QiniuConfig config); + + /** + * 删除文件 + * @param content 文件 + * @param config 配置 + */ + void delete(QiniuContent content, QiniuConfig config); + + /** + * 同步数据 + * @param config 配置 + */ + void synchronize(QiniuConfig config); + + /** + * 删除文件 + * @param ids 文件ID数组 + * @param config 配置 + */ + void deleteAll(Long[] ids, QiniuConfig config); + + /** + * 更新数据 + * @param type 类型 + */ + void update(String type); + + /** + * 导出数据 + * @param queryAll / + * @param response / + * @throws IOException / + */ + void downloadList(List queryAll, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/QiniuConfigService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/QiniuConfigService.java new file mode 100644 index 00000000..aaf68a30 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/QiniuConfigService.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.tools.domain.QiniuConfig; +import co.yixiang.tools.service.dto.QiniuConfigDto; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface QiniuConfigService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(QiniuQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(QiniuQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; + + + void update(String type); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/QiniuContentService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/QiniuContentService.java new file mode 100644 index 00000000..9a940bce --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/QiniuContentService.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.dto.QiniuContentDto; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +public interface QiniuContentService extends BaseService{ + +/** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(QiniuQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(QiniuQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/VerificationCodeService.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/VerificationCodeService.java new file mode 100644 index 00000000..6ec81c41 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/VerificationCodeService.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service; + +import co.yixiang.tools.domain.VerificationCode; +import co.yixiang.tools.domain.vo.EmailVo; + +/** + * @author hupeng + * @date 2018-12-26 + */ +public interface VerificationCodeService { + + /** + * 发送邮件验证码 + * @param code 验证码 + * @return EmailVo + */ + EmailVo sendEmail(VerificationCode code); + + /** + * 验证 + * @param code 验证码 + */ + void validated(VerificationCode code); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/LocalStorageDto.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/LocalStorageDto.java new file mode 100644 index 00000000..3cce15ae --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/LocalStorageDto.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class LocalStorageDto implements Serializable { + private Long id; + + private String realName; + + private String name; + + private String suffix; + + private String path; + + private String type; + + private String size; + + private String operate; + + private Timestamp createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/LocalStorageQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/LocalStorageQueryCriteria.java new file mode 100644 index 00000000..fe978848 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/LocalStorageQueryCriteria.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class LocalStorageQueryCriteria{ + + @Query(blurry = "name,suffix,type,operate,size") + private String blurry; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/PictureDto.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/PictureDto.java new file mode 100644 index 00000000..b2ada73b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/PictureDto.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class PictureDto implements Serializable { + + /** ID */ + private Long id; + + /** 上传日期 */ + private Timestamp createTime; + + /** 删除的URL */ + private String deleteUrl; + + /** 图片名称 */ + private String filename; + + /** 图片高度 */ + private String height; + + /** 图片大小 */ + private String size; + + /** 图片地址 */ + private String url; + + /** 用户名称 */ + private String username; + + /** 图片宽度 */ + private String width; + + /** 文件的MD5值 */ + private String md5code; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/PictureQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/PictureQueryCriteria.java new file mode 100644 index 00000000..b15fe8c1 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/PictureQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class PictureQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuConfigDto.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuConfigDto.java new file mode 100644 index 00000000..e366d3e9 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuConfigDto.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class QiniuConfigDto implements Serializable { + + /** ID */ + private Long id; + + /** accessKey */ + private String accessKey; + + /** Bucket 识别符 */ + private String bucket; + + /** 外链域名 */ + private String host; + + /** secretKey */ + private String secretKey; + + /** 空间类型 */ + private String type; + + /** 机房 */ + private String zone; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuConfigQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuConfigQueryCriteria.java new file mode 100644 index 00000000..d3545a80 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuConfigQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class QiniuConfigQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuContentDto.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuContentDto.java new file mode 100644 index 00000000..3448be78 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuContentDto.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.sql.Timestamp; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class QiniuContentDto implements Serializable { + + /** ID */ + private Long id; + + /** Bucket 识别符 */ + private String bucket; + + /** 文件名称 */ + private String name; + + /** 文件大小 */ + private String size; + + /** 文件类型:私有或公开 */ + private String type; + + /** 上传或同步的时间 */ + private Timestamp updateTime; + + /** 文件url */ + private String url; + + private String suffix; + + public String getKey(){ + return this.name; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuContentQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuContentQueryCriteria.java new file mode 100644 index 00000000..52ef5aa8 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuContentQueryCriteria.java @@ -0,0 +1,16 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import lombok.Data; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Data +public class QiniuContentQueryCriteria{ +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuQueryCriteria.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuQueryCriteria.java new file mode 100644 index 00000000..267fc09b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/dto/QiniuQueryCriteria.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.dto; + +import co.yixiang.annotation.Query; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +/** + * @author hupeng + * @date 2019-6-4 09:54:37 + */ +@Data +public class QiniuQueryCriteria{ + + @Query(type = Query.Type.INNER_LIKE) + private String name; + + @Query(type = Query.Type.BETWEEN) + private List createTime; +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/AlipayConfigServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/AlipayConfigServiceImpl.java new file mode 100644 index 00000000..95f70683 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/AlipayConfigServiceImpl.java @@ -0,0 +1,109 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.exception.BadRequestException; +import co.yixiang.tools.domain.AlipayConfig; +import co.yixiang.tools.domain.vo.TradeVo; +import co.yixiang.tools.service.AlipayConfigService; +import co.yixiang.tools.service.mapper.AlipayConfigMapper; +import com.alipay.api.AlipayClient; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.request.AlipayTradePagePayRequest; +import com.alipay.api.request.AlipayTradeWapPayRequest; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "alipayConfig") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class AlipayConfigServiceImpl extends BaseServiceImpl implements AlipayConfigService { + @Override + public String toPayAsPc(AlipayConfig alipay, TradeVo trade) throws Exception { + + if(alipay.getId() == null){ + throw new BadRequestException("请先添加相应配置,再操作"); + } + AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType()); + + // 创建API对应的request(电脑网页版) + AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); + + // 订单完成后返回的页面和异步通知地址 + request.setReturnUrl(alipay.getReturnUrl()); + request.setNotifyUrl(alipay.getNotifyUrl()); + // 填充订单参数 + request.setBizContent("{" + + " \"out_trade_no\":\""+trade.getOutTradeNo()+"\"," + + " \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," + + " \"total_amount\":"+trade.getTotalAmount()+"," + + " \"subject\":\""+trade.getSubject()+"\"," + + " \"body\":\""+trade.getBody()+"\"," + + " \"extend_params\":{" + + " \"sys_service_provider_id\":\""+alipay.getSysServiceProviderId()+"\"" + + " }"+ + " }");//填充业务参数 + // 调用SDK生成表单, 通过GET方式,口可以获取url + return alipayClient.pageExecute(request, "GET").getBody(); + + } + + @Override + public String toPayAsWeb(AlipayConfig alipay, TradeVo trade) throws Exception { + if(alipay.getId() == null){ + throw new BadRequestException("请先添加相应配置,再操作"); + } + AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType()); + + double money = Double.parseDouble(trade.getTotalAmount()); + double maxMoney = 5000; + if(money <= 0 || money >= maxMoney){ + throw new BadRequestException("测试金额过大"); + } + // 创建API对应的request(手机网页版) + AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest(); + request.setReturnUrl(alipay.getReturnUrl()); + request.setNotifyUrl(alipay.getNotifyUrl()); + request.setBizContent("{" + + " \"out_trade_no\":\""+trade.getOutTradeNo()+"\"," + + " \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," + + " \"total_amount\":"+trade.getTotalAmount()+"," + + " \"subject\":\""+trade.getSubject()+"\"," + + " \"body\":\""+trade.getBody()+"\"," + + " \"extend_params\":{" + + " \"sys_service_provider_id\":\""+alipay.getSysServiceProviderId()+"\"" + + " }"+ + " }"); + return alipayClient.pageExecute(request, "GET").getBody(); + } + + @Override +// @Cacheable(key = "'1'") + public AlipayConfig find() { + AlipayConfig alipayConfig = this.list().get(0); + return alipayConfig; + } + + @Override +// @CachePut(key = "'1'") + @Transactional(rollbackFor = Exception.class) + public void update(AlipayConfig alipayConfig) { + this.save(alipayConfig); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/EmailConfigServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/EmailConfigServiceImpl.java new file mode 100644 index 00000000..cf0274c6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/EmailConfigServiceImpl.java @@ -0,0 +1,103 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import cn.hutool.extra.mail.Mail; +import cn.hutool.extra.mail.MailAccount; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.tools.domain.EmailConfig; +import co.yixiang.tools.domain.vo.EmailVo; +import co.yixiang.tools.service.EmailConfigService; +import co.yixiang.tools.service.mapper.EmailConfigMapper; +import co.yixiang.utils.EncryptUtils; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "emailConfig") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class EmailConfigServiceImpl extends BaseServiceImpl implements EmailConfigService { + + private final IGenerator generator; + + @Override +// @CachePut(key = "'1'") + @Transactional(rollbackFor = Exception.class) + public void update(EmailConfig emailConfig, EmailConfig old) { + try { + if(!emailConfig.getPass().equals(old.getPass())){ + // 对称加密 + emailConfig.setPass(EncryptUtils.desEncrypt(emailConfig.getPass())); + } + } catch (Exception e) { + e.printStackTrace(); + } + this.saveOrUpdate(emailConfig); + } + + @Override +// @Cacheable(key = "'1'") + public EmailConfig find() { + EmailConfig emailConfig = this.list().get(0); + return emailConfig; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void send(EmailVo emailVo, EmailConfig emailConfig){ + if(emailConfig == null){ + throw new BadRequestException("请先配置,再操作"); + } + // 封装 + MailAccount account = new MailAccount(); + // 设置用户 + String user = emailConfig.getFromUser().split("@")[0]; + account.setUser(user); + account.setHost(emailConfig.getHost()); + account.setPort(Integer.parseInt(emailConfig.getPort())); + account.setAuth(true); + try { + // 对称解密 + account.setPass(EncryptUtils.desDecrypt(emailConfig.getPass())); + } catch (Exception e) { + throw new BadRequestException(e.getMessage()); + } + account.setFrom(emailConfig.getUser()+"<"+emailConfig.getFromUser()+">"); + // ssl方式发送 + account.setSslEnable(true); + // 使用STARTTLS安全连接 + account.setStarttlsEnable(true); + String content = emailVo.getContent(); + // 发送 + try { + int size = emailVo.getTos().size(); + Mail.create(account) + .setTos(emailVo.getTos().toArray(new String[size])) + .setTitle(emailVo.getSubject()) + .setContent(content) + .setHtml(true) + //关闭session + .setUseGlobalSession(false) + .send(); + }catch (Exception e){ + throw new BadRequestException(e.getMessage()); + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/LocalStorageServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/LocalStorageServiceImpl.java new file mode 100644 index 00000000..86bcd7e6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/LocalStorageServiceImpl.java @@ -0,0 +1,147 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.tools.domain.LocalStorage; +import co.yixiang.tools.service.LocalStorageService; +import co.yixiang.tools.service.dto.LocalStorageDto; +import co.yixiang.tools.service.dto.LocalStorageQueryCriteria; +import co.yixiang.tools.service.mapper.LocalStorageMapper; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.StringUtils; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +//@CacheConfig(cacheNames = "localStorage") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class LocalStorageServiceImpl extends BaseServiceImpl implements LocalStorageService { + + private final IGenerator generator; + + private String path = ""; + + private long maxSize = 500000; + + public LocalStorageServiceImpl(IGenerator generator) { + this.generator = generator; + } + + @Override + //@Cacheable + public Map queryAll(LocalStorageQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(baseMapper.selectList(QueryHelpPlus.getPredicate(LocalStorage.class, criteria))); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), LocalStorageDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(LocalStorageQueryCriteria criteria){ + return generator.convert(baseMapper.selectList(QueryHelpPlus.getPredicate(LocalStorage.class, criteria)),LocalStorageDto.class); + } + + @Override + public LocalStorageDto findById(Long id) { + LocalStorage localStorage = this.getById(id); + return generator.convert(localStorage,LocalStorageDto.class); + } + + @Override + public LocalStorageDto create(String name, MultipartFile multipartFile) { + FileUtil.checkSize(maxSize, multipartFile.getSize()); + String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename()); + String type = FileUtil.getFileType(suffix); + File file = FileUtil.upload(multipartFile, path + type + File.separator); + if(ObjectUtil.isNull(file)){ + throw new BadRequestException("上传失败"); + } + try { + name = StringUtils.isBlank(name) ? FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename()) : name; + LocalStorage localStorage = new LocalStorage( + file.getName(), + name, + suffix, + file.getPath(), + type, + FileUtil.getSize(multipartFile.getSize()), + "yshop" + ); + this.save(localStorage); + return generator.convert(localStorage,LocalStorageDto.class); + }catch (Exception e){ + FileUtil.del(file); + throw e; + } + } + + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + LocalStorage storage = this.getById(id); + FileUtil.del(storage.getPath()); + this.removeById(id); + } + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (LocalStorageDto localStorage : all) { + Map map = new LinkedHashMap<>(); + map.put("文件真实的名称", localStorage.getRealName()); + map.put("文件名", localStorage.getName()); + map.put("后缀", localStorage.getSuffix()); +// map.put("路径", localStorage.getPath()); + map.put("类型", localStorage.getType()); + map.put("大小", localStorage.getSize()); + map.put("操作人", localStorage.getOperate()); + map.put("创建日期", localStorage.getCreateTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public void updateLocalStorage(LocalStorageDto resources) { + LocalStorage localStorage = this.getById(resources.getId()); + BeanUtils.copyProperties(resources,localStorage); + this.saveOrUpdate(localStorage); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/PictureServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/PictureServiceImpl.java new file mode 100644 index 00000000..c26eb492 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/PictureServiceImpl.java @@ -0,0 +1,185 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.tools.domain.Picture; +import co.yixiang.tools.service.PictureService; +import co.yixiang.tools.service.dto.PictureDto; +import co.yixiang.tools.service.dto.PictureQueryCriteria; +import co.yixiang.tools.service.mapper.PictureMapper; +import co.yixiang.utils.FileUtil; +import co.yixiang.utils.TranslatorUtil; +import co.yixiang.utils.ValidationUtil; +import co.yixiang.utils.YshopConstant; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.pagehelper.PageInfo; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +//@AllArgsConstructor +//@CacheConfig(cacheNames = "picture") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class PictureServiceImpl extends BaseServiceImpl implements PictureService { + + private final IGenerator generator; + + @Value("${smms.token}") + private String token; + + + private static final String SUCCESS = "success"; + + private static final String CODE = "code"; + + private static final String MSG = "message"; + + public PictureServiceImpl(IGenerator generator) { + this.generator = generator; + } + + @Override + //@Cacheable + public Map queryAll(PictureQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), PictureDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(PictureQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(Picture.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (PictureDto picture : all) { + Map map = new LinkedHashMap<>(); + map.put("上传日期", picture.getCreateTime()); + map.put("删除的URL", picture.getDeleteUrl()); + map.put("图片名称", picture.getFilename()); + map.put("图片高度", picture.getHeight()); + map.put("图片大小", picture.getSize()); + map.put("图片地址", picture.getUrl()); + map.put("用户名称", picture.getUsername()); + map.put("图片宽度", picture.getWidth()); + map.put("文件的MD5值", picture.getMd5code()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + @Transactional(rollbackFor = Throwable.class) + public Picture upload(MultipartFile multipartFile, String username) { + File file = FileUtil.toFile(multipartFile); + // 验证是否重复上传 + Picture picture = this.getOne(new LambdaQueryWrapper().eq(Picture::getMd5code,FileUtil.getMd5(file))); + if(picture != null){ + return picture; + } + HashMap paramMap = new HashMap<>(1); + paramMap.put("smfile", file); + // 上传文件 + String result= HttpRequest.post(YshopConstant.Url.SM_MS_URL + "/v2/upload") + .header("Authorization", token) + .form(paramMap) + .timeout(20000) + .execute().body(); + JSONObject jsonObject = JSONUtil.parseObj(result); + if(!jsonObject.get(CODE).toString().equals(SUCCESS)){ + throw new BadRequestException(TranslatorUtil.translate(jsonObject.get(MSG).toString())); + } + picture = JSON.parseObject(jsonObject.get("data").toString(), Picture.class); + picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize()))); + picture.setUsername(username); + picture.setMd5code(FileUtil.getMd5(file)); + picture.setFilename(FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename())+"."+FileUtil.getExtensionName(multipartFile.getOriginalFilename())); + this.save(picture); + //删除临时文件 + FileUtil.del(file); + return picture; + + } + + @Override + public Picture findById(Long id) { + Picture picture = this.getById(id); + ValidationUtil.isNull(picture.getId(),"Picture","id",id); + return picture; + } + + @Override + public void deleteAll(Long[] ids) { + for (Long id : ids) { + Picture picture = findById(id); + try { + HttpUtil.get(picture.getDeleteUrl()); + this.removeById(id); + } catch(Exception e){ + this.removeById(id); + } + } + } + + @Override + public void synchronize() { + //链式构建请求 + String result = HttpRequest.get(YshopConstant.Url.SM_MS_URL + "/v2/upload_history") + //头信息,多个头信息多次调用此方法即可 + .header("Authorization", token) + .timeout(20000) + .execute().body(); + JSONObject jsonObject = JSONUtil.parseObj(result); + List pictures = JSON.parseArray(jsonObject.get("data").toString(), Picture.class); + for (Picture picture : pictures) { + if(this.getOne(new LambdaQueryWrapper().eq(Picture::getUrl,picture.getUrl()))==null){ + picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize()))); + picture.setUsername("System Sync"); + picture.setMd5code(null); + this.save(picture); + } + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiNiuServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiNiuServiceImpl.java new file mode 100644 index 00000000..2ac06c6f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiNiuServiceImpl.java @@ -0,0 +1,243 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.exception.BadRequestException; +import co.yixiang.tools.domain.QiniuConfig; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.QiNiuService; +import co.yixiang.tools.service.QiniuConfigService; +import co.yixiang.tools.service.QiniuContentService; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import co.yixiang.tools.utils.QiNiuUtil; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.qiniu.common.QiniuException; +import com.qiniu.http.Response; +import com.qiniu.storage.BucketManager; +import com.qiniu.storage.Configuration; +import com.qiniu.storage.UploadManager; +import com.qiniu.storage.model.DefaultPutRet; +import com.qiniu.storage.model.FileInfo; +import com.qiniu.util.Auth; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author hupeng + * @date 2018-12-31 + */ +@Service +//@CacheConfig(cacheNames = "qiNiu") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class QiNiuServiceImpl implements QiNiuService { + + private final QiniuConfigService qiniuConfigService; + + private final QiniuContentService qiniuContentService; + + private final IGenerator generator; + + public QiNiuServiceImpl(QiniuConfigService qiniuConfigService, QiniuContentService qiniuContentService, IGenerator generator) { + this.qiniuConfigService = qiniuConfigService; + this.qiniuContentService = qiniuContentService; + this.generator = generator; + } + + @Override +// @Cacheable + public Object queryAll(QiniuQueryCriteria criteria, Pageable pageable){ + return qiniuContentService.queryAll(criteria,pageable); + } + + @Override + public List queryAll(QiniuQueryCriteria criteria) { + return qiniuContentService.queryAll(criteria); + } + + @Override +// @Cacheable(key = "'1'") + public QiniuConfig find() { + QiniuConfig qiniuConfig = qiniuConfigService.getOne(new LambdaQueryWrapper().orderByAsc(QiniuConfig::getId).last("limit 1")); + return qiniuConfig; + } + + @Override +// @CachePut(cacheNames = "qiNiuConfig", key = "'1'") + @Transactional(rollbackFor = Exception.class) + public QiniuConfig update(QiniuConfig qiniuConfig) { + String http = "http://", https = "https://"; + if (!(qiniuConfig.getHost().toLowerCase().startsWith(http)||qiniuConfig.getHost().toLowerCase().startsWith(https))) { + throw new BadRequestException("外链域名必须以http://或者https://开头"); + } + qiniuConfig.setId(1L); + qiniuConfigService.saveOrUpdate(qiniuConfig); + return qiniuConfig; + } + + @Override +// @CacheEvict(allEntries = true) + @Transactional(rollbackFor = Exception.class) + public QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig) { + if(qiniuConfig.getId() == null){ + throw new BadRequestException("请先添加相应配置,再操作"); + } + // 构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(QiNiuUtil.getRegion(qiniuConfig.getZone())); + UploadManager uploadManager = new UploadManager(cfg); + Auth auth = Auth.create(qiniuConfig.getAccessKey(), qiniuConfig.getSecretKey()); + String upToken = auth.uploadToken(qiniuConfig.getBucket()); + try { + String key = file.getOriginalFilename(); + if(qiniuContentService.getOne(new LambdaQueryWrapper().eq(QiniuContent::getName,key)) != null) { + key = QiNiuUtil.getKey(key); + } + Response response = uploadManager.put(file.getBytes(), key, upToken); + //解析上传成功的结果 + + DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); + + QiniuContent content = qiniuContentService.getOne(new LambdaQueryWrapper().eq(QiniuContent::getName,FileUtil.getFileNameNoEx(putRet.key))); + if (content == null) { + //存入数据库 + QiniuContent qiniuContent = new QiniuContent(); + qiniuContent.setSuffix(FileUtil.getExtensionName(putRet.key)); + qiniuContent.setBucket(qiniuConfig.getBucket()); + qiniuContent.setType(qiniuConfig.getType()); + qiniuContent.setName(FileUtil.getFileNameNoEx(putRet.key)); + qiniuContent.setUrl(qiniuConfig.getHost()+"/"+putRet.key); + qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(file.getSize()+""))); + qiniuContentService.save(qiniuContent); + return qiniuContent; + } + return content; + } catch (Exception e) { + throw new BadRequestException(e.getMessage()); + } + } + + @Override +// @Cacheable + public QiniuContent findByContentId(Long id) { + QiniuContent qiniuContent = qiniuContentService.getById(id); + return qiniuContent; + } + + @Override +// @Cacheable + public String download(QiniuContent content,QiniuConfig config){ + String finalUrl; + String type = "公开"; + if(type.equals(content.getType())){ + finalUrl = content.getUrl(); + } else { + Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); + // 1小时,可以自定义链接过期时间 + long expireInSeconds = 3600; + finalUrl = auth.privateDownloadUrl(content.getUrl(), expireInSeconds); + } + return finalUrl; + } + + @Override +// @CacheEvict(allEntries = true) + @Transactional(rollbackFor = Exception.class) + public void delete(QiniuContent content, QiniuConfig config) { + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(QiNiuUtil.getRegion(config.getZone())); + Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); + BucketManager bucketManager = new BucketManager(auth, cfg); + try { + bucketManager.delete(content.getBucket(), content.getName() + "." + content.getSuffix()); + qiniuContentService.removeById(content.getId()); + } catch (QiniuException ex) { + qiniuConfigService.removeById(content.getId()); + } + } + + @Override +// @CacheEvict(allEntries = true) + @Transactional(rollbackFor = Exception.class) + public void synchronize(QiniuConfig config) { + if(config.getId() == null){ + throw new BadRequestException("请先添加相应配置,再操作"); + } + //构造一个带指定Zone对象的配置类 + Configuration cfg = new Configuration(QiNiuUtil.getRegion(config.getZone())); + Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); + BucketManager bucketManager = new BucketManager(auth, cfg); + //文件名前缀 + String prefix = ""; + //每次迭代的长度限制,最大1000,推荐值 1000 + int limit = 1000; + //指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串 + String delimiter = ""; + //列举空间文件列表 + BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(config.getBucket(), prefix, limit, delimiter); + while (fileListIterator.hasNext()) { + //处理获取的file list结果 + QiniuContent qiniuContent; + FileInfo[] items = fileListIterator.next(); + for (FileInfo item : items) { + if(qiniuContentService.getOne(new LambdaQueryWrapper().eq(QiniuContent::getName,FileUtil.getFileNameNoEx(item.key))) + == null){ + qiniuContent = new QiniuContent(); + qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(item.fsize+""))); + qiniuContent.setSuffix(FileUtil.getExtensionName(item.key)); + qiniuContent.setName(FileUtil.getFileNameNoEx(item.key)); + qiniuContent.setType(config.getType()); + qiniuContent.setBucket(config.getBucket()); + qiniuContent.setUrl(config.getHost()+"/"+item.key); + qiniuContentService.save(qiniuContent); + } + } + } + } + + @Override +// @CacheEvict(allEntries = true) + public void deleteAll(Long[] ids, QiniuConfig config) { + for (Long id : ids) { + delete(findByContentId(id), config); + } + } + + @Override +// @CacheEvict(allEntries = true) + @Transactional(rollbackFor = Exception.class) + public void update(String type) { + qiniuConfigService.update(type); + } + + @Override + public void downloadList(List queryAll, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (QiniuContent content : queryAll) { + Map map = new LinkedHashMap<>(); + map.put("文件名", content.getName()); + map.put("文件类型", content.getSuffix()); + map.put("空间名称", content.getBucket()); + map.put("文件大小", content.getSize()); + map.put("空间类型", content.getType()); + map.put("创建日期", content.getUpdateTime()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiniuConfigServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiniuConfigServiceImpl.java new file mode 100644 index 00000000..74f0cabf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiniuConfigServiceImpl.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.tools.domain.QiniuConfig; +import co.yixiang.tools.service.QiniuConfigService; +import co.yixiang.tools.service.dto.QiniuConfigDto; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import co.yixiang.tools.service.mapper.QiniuConfigMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "qiniuConfig") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class QiniuConfigServiceImpl extends BaseServiceImpl implements QiniuConfigService { + + private final IGenerator generator; + + private final QiniuConfigMapper qiniuConfigMapper; + @Override + //@Cacheable + public Map queryAll(QiniuQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), QiniuConfigDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(QiniuQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(QiniuConfig.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (QiniuConfigDto qiniuConfig : all) { + Map map = new LinkedHashMap<>(); + map.put("accessKey", qiniuConfig.getAccessKey()); + map.put("Bucket 识别符", qiniuConfig.getBucket()); + map.put("外链域名", qiniuConfig.getHost()); + map.put("secretKey", qiniuConfig.getSecretKey()); + map.put("空间类型", qiniuConfig.getType()); + map.put("机房", qiniuConfig.getZone()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + @Override + public void update(String type) { + qiniuConfigMapper.updateType(type); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiniuContentServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiniuContentServiceImpl.java new file mode 100644 index 00000000..702177ec --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/QiniuContentServiceImpl.java @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.tools.domain.QiniuContent; +import co.yixiang.tools.service.QiniuContentService; +import co.yixiang.tools.service.dto.QiniuContentDto; +import co.yixiang.tools.service.dto.QiniuQueryCriteria; +import co.yixiang.tools.service.mapper.QiniuContentMapper; +import co.yixiang.utils.FileUtil; +import com.github.pagehelper.PageInfo; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Service +@AllArgsConstructor +@SuppressWarnings("unchecked") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class QiniuContentServiceImpl extends BaseServiceImpl implements QiniuContentService { + + private final IGenerator generator; + + @Override + //@Cacheable + public Map queryAll(QiniuQueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo page = new PageInfo<>(queryAll(criteria)); + Map map = new LinkedHashMap<>(2); + map.put("content", generator.convert(page.getList(), QiniuContentDto.class)); + map.put("totalElements", page.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(QiniuQueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(QiniuContent.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (QiniuContentDto qiniuContent : all) { + Map map = new LinkedHashMap<>(); + map.put("Bucket 识别符", qiniuContent.getBucket()); + map.put("文件名称", qiniuContent.getKey()); + map.put("文件大小", qiniuContent.getSize()); + map.put("文件类型:私有或公开", qiniuContent.getType()); + map.put("上传或同步的时间", qiniuContent.getUpdateTime()); + map.put("文件url", qiniuContent.getUrl()); + map.put(" suffix", qiniuContent.getSuffix()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/VerificationCodeServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/VerificationCodeServiceImpl.java new file mode 100644 index 00000000..d9775e08 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/impl/VerificationCodeServiceImpl.java @@ -0,0 +1,97 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.impl; + +import cn.hutool.core.lang.Dict; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.extra.template.Template; +import cn.hutool.extra.template.TemplateConfig; +import cn.hutool.extra.template.TemplateEngine; +import cn.hutool.extra.template.TemplateUtil; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.exception.BadRequestException; +import co.yixiang.tools.domain.VerificationCode; +import co.yixiang.tools.domain.vo.EmailVo; +import co.yixiang.tools.service.VerificationCodeService; +import co.yixiang.tools.service.mapper.VerificationCodeMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.apache.commons.lang3.concurrent.BasicThreadFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * @author hupeng + * @date 2018-12-26 + */ +@Service +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class VerificationCodeServiceImpl extends BaseServiceImpl implements VerificationCodeService { + + private Integer expiration = 5; + + + @Override + @Transactional(rollbackFor = Exception.class) + public EmailVo sendEmail(VerificationCode code) { + EmailVo emailVo; + String content; + VerificationCode verificationCode = this.getOne(new LambdaQueryWrapper() + .eq(VerificationCode::getScenes,code.getScenes()).eq(VerificationCode::getType,code.getType()).eq(VerificationCode::getValue,code.getValue())); + // 如果不存在有效的验证码,就创建一个新的 + TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); + Template template = engine.getTemplate("email/email.ftl"); + if(verificationCode == null){ + code.setCode(RandomUtil.randomNumbers (6)); + content = template.render(Dict.create().set("code",code.getCode())); + emailVo = new EmailVo(Collections.singletonList(code.getValue()),"yshop后台管理系统",content); + this.save(code); + timedDestruction(code); + // 存在就再次发送原来的验证码 + } else { + content = template.render(Dict.create().set("code",verificationCode.getCode())); + emailVo = new EmailVo(Collections.singletonList(verificationCode.getValue()),"yshop后台管理系统",content); + } + return emailVo; + } + + @Override + public void validated(VerificationCode code) { + VerificationCode verificationCode = this.getOne(new LambdaQueryWrapper() + .eq(VerificationCode::getScenes,code.getScenes()).eq(VerificationCode::getType,code.getType()).eq(VerificationCode::getValue,code.getValue()) + .eq(VerificationCode::getStatus,true)); + if(verificationCode == null || !verificationCode.getCode().equals(code.getCode())){ + throw new BadRequestException("无效验证码"); + } else { + verificationCode.setStatus(false); + this.save(verificationCode); + } + } + + /** + * 定时任务,指定分钟后改变验证码状态 + * @param verifyCode 验证码 + */ + private void timedDestruction(VerificationCode verifyCode) { + //以下示例为程序调用结束继续运行 + ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1, + new BasicThreadFactory.Builder().namingPattern("verifyCode-schedule-pool-%d").daemon(true).build()); + try { + executorService.schedule(() -> { + verifyCode.setStatus(false); + this.save(verifyCode); + }, expiration * 60 * 1000L, TimeUnit.MILLISECONDS); + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/AlipayConfigMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/AlipayConfigMapper.java new file mode 100644 index 00000000..da889752 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/AlipayConfigMapper.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.AlipayConfig; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +@Mapper +public interface AlipayConfigMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/EmailConfigMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/EmailConfigMapper.java new file mode 100644 index 00000000..70f27747 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/EmailConfigMapper.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.EmailConfig; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +@Mapper +public interface EmailConfigMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/LocalStorageMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/LocalStorageMapper.java new file mode 100644 index 00000000..be1aa268 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/LocalStorageMapper.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.LocalStorage; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +@Mapper +public interface LocalStorageMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/PictureMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/PictureMapper.java new file mode 100644 index 00000000..444b0df7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/PictureMapper.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.Picture; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +@Mapper +public interface PictureMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/QiniuConfigMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/QiniuConfigMapper.java new file mode 100644 index 00000000..89970b9f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/QiniuConfigMapper.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.QiniuConfig; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +@Mapper +public interface QiniuConfigMapper extends CoreMapper { + + + @Update("update yx_qiniu_config set type = #{type} ") + void updateType(@Param("type") String type); +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/QiniuContentMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/QiniuContentMapper.java new file mode 100644 index 00000000..f97f0bf6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/QiniuContentMapper.java @@ -0,0 +1,21 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.QiniuContent; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author hupeng +* @date 2020-05-13 +*/ +@Repository +@Mapper +public interface QiniuContentMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/VerificationCodeMapper.java b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/VerificationCodeMapper.java new file mode 100644 index 00000000..4a787c5b --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/service/mapper/VerificationCodeMapper.java @@ -0,0 +1,18 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.service.mapper; + + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.tools.domain.VerificationCode; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +@Repository +@Mapper +public interface VerificationCodeMapper extends CoreMapper { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/utils/AliPayStatusEnum.java b/zsw-bxg/src/main/java/co/yixiang/tools/utils/AliPayStatusEnum.java new file mode 100644 index 00000000..a3c67985 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/utils/AliPayStatusEnum.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.utils; + +/** + * 支付状态 + * @author zhengjie + * @date 2018/08/01 16:45:43 + */ +public enum AliPayStatusEnum { + + /** 交易成功 */ + FINISHED("交易成功", "TRADE_FINISHED"), + + /** 支付成功 */ + SUCCESS("支付成功", "TRADE_SUCCESS"), + + /** 交易创建 */ + BUYER_PAY("交易创建", "WAIT_BUYER_PAY"), + + /** 交易关闭 */ + CLOSED("交易关闭", "TRADE_CLOSED"); + + private String value; + + AliPayStatusEnum(String name, String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/utils/AlipayUtils.java b/zsw-bxg/src/main/java/co/yixiang/tools/utils/AlipayUtils.java new file mode 100644 index 00000000..5686b22c --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/utils/AlipayUtils.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.utils; + +import co.yixiang.tools.domain.AlipayConfig; +import com.alipay.api.AlipayApiException; +import com.alipay.api.internal.util.AlipaySignature; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 支付宝工具类 + * @author zhengjie + * @date 2018/09/30 14:04:35 + */ +@Component +public class AlipayUtils { + + /** + * 生成订单号 + * @return String + */ + public String getOrderCode() { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + int a = (int)(Math.random() * 9000.0D) + 1000; + System.out.println(a); + Date date = new Date(); + String str = sdf.format(date); + String[] split = str.split("-"); + String s = split[0] + split[1] + split[2]; + String[] split1 = s.split(" "); + String s1 = split1[0] + split1[1]; + String[] split2 = s1.split(":"); + return split2[0] + split2[1] + split2[2] + a; + } + + /** + * 校验签名 + * @param request HttpServletRequest + * @param alipay 阿里云配置 + * @return boolean + */ + public boolean rsaCheck(HttpServletRequest request, AlipayConfig alipay){ + + // 获取支付宝POST过来反馈信息 + Map params = new HashMap<>(1); + Map requestParams = request.getParameterMap(); + for (Object o : requestParams.keySet()) { + String name = (String) o; + String[] values = (String[]) requestParams.get(name); + String valueStr = ""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + params.put(name, valueStr); + } + + try { + return AlipaySignature.rsaCheckV1(params, + alipay.getPublicKey(), + alipay.getCharset(), + alipay.getSignType()); + } catch (AlipayApiException e) { + return false; + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/utils/JacksonUtil.java b/zsw-bxg/src/main/java/co/yixiang/tools/utils/JacksonUtil.java new file mode 100644 index 00000000..39bc566f --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/utils/JacksonUtil.java @@ -0,0 +1,184 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public class JacksonUtil { + + private static final Log logger = LogFactory.getLog(JacksonUtil.class); + + public static String parseString(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + return leaf.asText(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + + public static List parseStringList(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + + if (leaf != null) { + return mapper.convertValue(leaf, new TypeReference>() { + }); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Integer parseInteger(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + return leaf.asInt(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static List parseIntegerList(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + + if (leaf != null) { + return mapper.convertValue(leaf, new TypeReference>() { + }); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + + public static Boolean parseBoolean(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + return leaf.asBoolean(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Short parseShort(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + Integer value = leaf.asInt(); + return value.shortValue(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Byte parseByte(String body, String field) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + JsonNode leaf = node.get(field); + if (leaf != null) { + Integer value = leaf.asInt(); + return value.byteValue(); + } + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static T parseObject(String body, String field, Class clazz) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node; + try { + node = mapper.readTree(body); + node = node.get(field); + return mapper.treeToValue(node, clazz); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static Object toNode(String json) { + if (json == null) { + return null; + } + ObjectMapper mapper = new ObjectMapper(); + try { + + return mapper.readTree(json); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + + return null; + } + + public static Map toMap(String data) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.readValue(data, new TypeReference>() { + }); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + public static String toJson(Object data) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.writeValueAsString(data); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/tools/utils/QiNiuUtil.java b/zsw-bxg/src/main/java/co/yixiang/tools/utils/QiNiuUtil.java new file mode 100644 index 00000000..fd8a8762 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/tools/utils/QiNiuUtil.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.tools.utils; + +import co.yixiang.utils.FileUtil; +import com.qiniu.storage.Region; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 七牛云存储工具类 + * @author hupeng + * @date 2018-12-31 + */ +public class QiNiuUtil { + + private static final String HUAD = "华东"; + + private static final String HUAD2 = "华东2-浙江"; + + private static final String HUAB = "华北"; + + private static final String HUAN = "华南"; + + private static final String BEIM = "北美"; + + /** + * 得到机房的对应关系 + * @param zone 机房名称 + * @return Region + */ + public static Region getRegion(String zone){ + + if(HUAD.equals(zone)){ + return Region.huadong(); + } if (HUAD2.equals(zone)){ + return Region.huadongZheJiang2(); + }else if(HUAB.equals(zone)){ + return Region.huabei(); + } else if(HUAN.equals(zone)){ + return Region.huanan(); + } else if (BEIM.equals(zone)){ + return Region.beimei(); + // 否则就是东南亚 + } else { + return Region.qvmHuadong(); + } + } + + /** + * 默认不指定key的情况下,以文件内容的hash值作为文件名 + * @param file 文件名 + * @return String + */ + public static String getKey(String file){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + Date date = new Date(); + return FileUtil.getFileNameNoEx(file) + "-" + + sdf.format(date) + + "." + + FileUtil.getExtensionName(file); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/BeanUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/BeanUtil.java new file mode 100644 index 00000000..b412a041 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/BeanUtil.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +@Component +public class BeanUtil implements ApplicationContextAware { + protected static ApplicationContext context; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + context = applicationContext; + } + + public static Object getBean(String name) { + return context.getBean(name); + } + + public static T getBean(Class c){ + return context.getBean(c); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/BigNum.java b/zsw-bxg/src/main/java/co/yixiang/utils/BigNum.java new file mode 100644 index 00000000..912f01a6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/BigNum.java @@ -0,0 +1,201 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; +import java.math.BigDecimal; +import java.text.DecimalFormat; + +public class BigNum { + public static final String BIG_NUM_FMT_COMMA = "#,###,###,###,###,###,##0.00";//千位分隔符 方便查看金额具体大小 + public static final String BIG_NUM_FMT = "##################0.00";//不带千位分隔符 + public static final String BIG_NUM_HUNDRED = "100";//100常量 + public static final int BIG_NUM_SCALE = 2;//保留两位小数 + + + // 除法运算默认精度 + private static final int DEF_DIV_SCALE = 10; + + + /** + * 精确加法 + */ + public static BigDecimal add(double value1, double value2) { + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + return new BigDecimal(b1.add(b2).toString()); + } + + /** + * 精确加法 + */ + public static BigDecimal add(Object value1, Object value2) { + BigDecimal b1 = new BigDecimal(value1.toString()); + BigDecimal b2 = new BigDecimal(value2.toString()); + return new BigDecimal(b1.add(b2).toString()); + } + + /** + * 精确减法 + */ + public static BigDecimal sub(double value1, double value2) { + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + return new BigDecimal(b1.subtract(b2).toString()); + } + + /** + * 精确减法 + */ + public static BigDecimal sub(Object value1, Object value2) { + BigDecimal b1 = new BigDecimal(value1.toString()); + BigDecimal b2 = new BigDecimal(value2.toString()); + return new BigDecimal(b1.subtract(b2).toString()); + } + + /** + * 精确乘法 + */ + public static BigDecimal mul(double value1, double value2) { + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + return new BigDecimal(b1.multiply(b2).toString()); + } + + /** + * 精确乘法 + */ + public static BigDecimal mul(Object value1, Object value2) { + BigDecimal b1 = new BigDecimal(value1.toString()); + BigDecimal b2 = new BigDecimal(value2.toString()); + return new BigDecimal(b1.multiply(b2).toString()); + } + + /** + * 精确除法 使用默认精度 + */ + public static BigDecimal div(double value1, double value2) throws IllegalAccessException { + return div(value1, value2, DEF_DIV_SCALE); + } + + /** + * 精确除法 使用默认精度 + */ + public static BigDecimal div(String value1, String value2) throws IllegalAccessException { + return div(value1, value2, DEF_DIV_SCALE); + } + + /** + * 精确除法 + * + * @param scale + * 精度 + */ + public static BigDecimal div(double value1, double value2, int scale) throws IllegalAccessException { + if (scale < 0) { + throw new IllegalAccessException("精确度不能小于0"); + } + BigDecimal b1 = BigDecimal.valueOf(value1); + BigDecimal b2 = BigDecimal.valueOf(value2); + // return b1.divide(b2, scale).doubleValue(); + return new BigDecimal(b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).toString()); + } + + /** + * 精确除法 + * + * @param scale + * 精度 + */ + public static BigDecimal div(String value1, String value2, int scale) throws IllegalAccessException { + if (scale < 0) { + throw new IllegalAccessException("精确度不能小于0"); + } + BigDecimal b1 = new BigDecimal(value1); + BigDecimal b2 = new BigDecimal(value2); + // return b1.divide(b2, scale).doubleValue(); + return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP); + } + + /** + * 四舍五入 + * + * @param scale + * 小数点后保留几位 + */ + public static BigDecimal round(double v, int scale) throws IllegalAccessException { + return div(v, 1, scale); + } + + /** + * 四舍五入 + * + * @param scale + * 小数点后保留几位 + */ + public static BigDecimal round(String v, int scale) throws IllegalAccessException { + return div(v, "1", scale); + } + + /** + * 比较大小 + */ + public static boolean equalTo(BigDecimal b1, BigDecimal b2) { + if (b1 == null || b2 == null) { + return false; + } + return 0 == b1.compareTo(b2); + } + + + /** + * 分转换成元 + * @param v + * @return + */ + public static BigDecimal penny2dollar(String v){ + BigDecimal s = new BigDecimal("0.00");//保留两位小数 + try { + s = div(v,"100",2); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return s; + } + + /** + * 元转换成分 + * @param v + * @return + */ + public static BigDecimal dollar2penny(String v){ + return mul(v, "100"); + } + + /** + * 格式化金额 + * 千位分隔符 方便查看金额具体大小 BIG_NUM_FMT = "#,###,###,###,###,###,##0.00" + * 精确两位小数 .99 -> 0.99 + * 1111111.985 -> 1,111,111.99 + * @param v + * @return + */ + public static String formatNumber(String v){ + return formatNumber(v,BIG_NUM_FMT_COMMA); + } + + /** + * 格式化金额 + * @param v + * @param pattern BigNum类中的常量 BIG_NUM_FMT_COMMA,BIG_NUM_FMT + * @return + */ + public static String formatNumber(String v,String pattern) { + return new DecimalFormat(pattern).format(new BigDecimal(v)); + } + + public static void main(String[] args) { + System.out.println(new BigDecimal("0.00").toString()); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/CateDTO.java b/zsw-bxg/src/main/java/co/yixiang/utils/CateDTO.java new file mode 100644 index 00000000..df36f415 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/CateDTO.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + + +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + + +/** + *

+ * 商城商品分类 + *

+ * + * @author hupeng + * @since 2019-09-08 + */ +@Data +public class CateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + + private Long id; + /** + * 上级分类编号 + */ + private Long pid; + + /** + * 商品分类名称 + */ + private String cateName; + + /** + * 缩略图url + */ + private String pic; + + private List children = new ArrayList<>(); + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/DateUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/DateUtils.java new file mode 100644 index 00000000..a27c1721 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/DateUtils.java @@ -0,0 +1,154 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import org.apache.commons.lang3.time.DateFormatUtils; + +import java.lang.management.ManagementFactory; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +/** + * 时间工具类 + */ +public class DateUtils extends org.apache.commons.lang3.time.DateUtils { + public static String YYYY = "yyyy"; + + public static String YYYY_MM = "yyyy-MM"; + + public static String YYYY_MM_DD = "yyyy-MM-dd"; + + public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; + + public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + + private static String[] parsePatterns = { + "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", + "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", + "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"}; + + /** + * 获取当前Date型日期 + * + * @return Date() 当前日期 + */ + public static Date getNowDate() { + return new Date(); + } + + /** + * 获取当前日期, 默认格式为yyyy-MM-dd + * + * @return String + */ + public static String getDate() { + return dateTimeNow(YYYY_MM_DD); + } + + public static final String getTime() { + return dateTimeNow(YYYY_MM_DD_HH_MM_SS); + } + + public static final String dateTimeNow() { + return dateTimeNow(YYYYMMDDHHMMSS); + } + + public static final String dateTimeNow(final String format) { + return parseDateToStr(format, new Date()); + } + + public static final String dateTime(final Date date) { + return parseDateToStr(YYYY_MM_DD, date); + } + + public static final String parseDateToStr(final String format, final Date date) { + return new SimpleDateFormat(format).format(date); + } + + public static final Date dateTime(final String format, final String ts) { + try { + return new SimpleDateFormat(format).parse(ts); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + /** + * 日期路径 即年/月/日 如2018/08/08 + */ + public static final String datePath() { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyy/MM/dd"); + } + + /** + * 日期路径 即年/月/日 如20180808 + */ + public static final String dateTime() { + Date now = new Date(); + return DateFormatUtils.format(now, "yyyyMMdd"); + } + + /** + * 日期型字符串转化为日期 格式 + */ + public static Date parseDate(Object str) { + if (str == null) { + return null; + } + try { + return parseDate(str.toString(), parsePatterns); + } catch (ParseException e) { + return null; + } + } + + /** + * 获取服务器启动时间 + */ + public static Date getServerStartDate() { + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + return new Date(time); + } + + /** + * 计算两个时间差 + */ + public static String getDatePoor(Date endDate, Date nowDate) { + long nd = 1000 * 24 * 60 * 60; + long nh = 1000 * 60 * 60; + long nm = 1000 * 60; + // long ns = 1000; + // 获得两个时间的毫秒时间差异 + long diff = endDate.getTime() - nowDate.getTime(); + // 计算差多少天 + long day = diff / nd; + // 计算差多少小时 + long hour = diff % nd / nh; + // 计算差多少分钟 + long min = diff % nd % nh / nm; + // 计算差多少秒//输出结果 + // long sec = diff % nd % nh % nm / ns; + return day + "天" + hour + "小时" + min + "分钟"; + } + + /** + * 秒转换为指定格式的日期 + * + * @param second + * @return + */ + public static String secondToDate(long second) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(second * 1000);//转换为毫秒 + Date date = calendar.getTime(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + String dateString = format.format(date); + return dateString; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/ElAdminConstant.java b/zsw-bxg/src/main/java/co/yixiang/utils/ElAdminConstant.java new file mode 100644 index 00000000..0d87a645 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/ElAdminConstant.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +/** + * 常用静态常量 + * @author Zheng Jie + * @date 2018-12-26 + */ +public class ElAdminConstant { + + public static final String RESET_PASS = "重置密码"; + + public static final String RESET_MAIL = "重置邮箱"; + + /** + * 用于IP定位转换 + */ + public static final String REGION = "内网IP|内网IP"; + + /** + * 常用接口 + */ + public static class Url{ + public static final String SM_MS_URL = "https://sm.ms/api/upload"; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/EncryptUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/EncryptUtils.java new file mode 100644 index 00000000..2473ea08 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/EncryptUtils.java @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import org.springframework.util.DigestUtils; + +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.DESKeySpec; +import javax.crypto.spec.IvParameterSpec; +import java.nio.charset.StandardCharsets; + +/** + * 加密 + * @author Zheng Jie + * @date 2018-11-23 + */ +public class EncryptUtils { + + private static String strParam = "Passw0rd"; + + private static Cipher cipher; + + private static IvParameterSpec iv = new IvParameterSpec(strParam.getBytes(StandardCharsets.UTF_8)); + + private static DESKeySpec getDesKeySpec(String source) throws Exception { + if (source == null || source.length() == 0){ + return null; + } + cipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); + String strKey = "Passw0rd"; + return new DESKeySpec(strKey.getBytes(StandardCharsets.UTF_8)); + } + + /** + * 对称加密 + */ + public static String desEncrypt(String source) throws Exception { + DESKeySpec desKeySpec = getDesKeySpec(source); + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); + SecretKey secretKey = keyFactory.generateSecret(desKeySpec); + cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv); + return byte2hex( + cipher.doFinal(source.getBytes(StandardCharsets.UTF_8))).toUpperCase(); + } + + /** + * 对称解密 + */ + public static String desDecrypt(String source) throws Exception { + byte[] src = hex2byte(source.getBytes()); + DESKeySpec desKeySpec = getDesKeySpec(source); + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); + SecretKey secretKey = keyFactory.generateSecret(desKeySpec); + cipher.init(Cipher.DECRYPT_MODE, secretKey, iv); + byte[] retByte = cipher.doFinal(src); + return new String(retByte); + } + + private static String byte2hex(byte[] inStr) { + String stmp; + StringBuilder out = new StringBuilder(inStr.length * 2); + for (byte b : inStr) { + stmp = Integer.toHexString(b & 0xFF); + if (stmp.length() == 1) { + // 如果是0至F的单位字符串,则添加0 + out.append("0").append(stmp); + } else { + out.append(stmp); + } + } + return out.toString(); + } + + private static byte[] hex2byte(byte[] b) { + int size = 2; + if ((b.length % size) != 0){ + throw new IllegalArgumentException("长度不是偶数"); + } + byte[] b2 = new byte[b.length / 2]; + for (int n = 0; n < b.length; n += size) { + String item = new String(b, n, 2); + b2[n / 2] = (byte) Integer.parseInt(item, 16); + } + return b2; + } + + /** + * 密码加密 + * @param password + * @return + */ + public static String encryptPassword(String password){ + return DigestUtils.md5DigestAsHex(password.getBytes()); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/FeiEHttpUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/FeiEHttpUtil.java new file mode 100644 index 00000000..f23724ae --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/FeiEHttpUtil.java @@ -0,0 +1,17 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +/** + * @author :LionCity + * @date :Created in 2020-04-21 17:30 + * @description:飞鹅打印机打印帮助类 + * @modified By: + * @version: V1.0 + */ +public class FeiEHttpUtil { + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/FileUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/FileUtil.java new file mode 100644 index 00000000..5c66d971 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/FileUtil.java @@ -0,0 +1,453 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import cn.hutool.core.codec.Base64; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.poi.excel.BigExcelWriter; +import cn.hutool.poi.excel.ExcelUtil; +import co.yixiang.exception.BadRequestException; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Random; + +/** + * File工具类,扩展 hutool 工具包 + * @author Zheng Jie + * @date 2018-12-27 + */ +public class FileUtil extends cn.hutool.core.io.FileUtil { + + /** + * 定义GB的计算常量 + */ + private static final int GB = 1024 * 1024 * 1024; + /** + * 定义MB的计算常量 + */ + private static final int MB = 1024 * 1024; + /** + * 定义KB的计算常量 + */ + private static final int KB = 1024; + + /** + * 格式化小数 + */ + private static final DecimalFormat DF = new DecimalFormat("0.00"); + + /** + * MultipartFile转File + */ + public static File toFile(MultipartFile multipartFile){ + // 获取文件名 + String fileName = multipartFile.getOriginalFilename(); + // 获取文件后缀 + String prefix="."+getExtensionName(fileName); + File file = null; + try { + // 用uuid作为文件名,防止生成的临时文件重复 + file = File.createTempFile(IdUtil.simpleUUID(), prefix); + // MultipartFile to File + multipartFile.transferTo(file); + } catch (IOException e) { + e.printStackTrace(); + } + return file; + } + + /** + * 获取文件扩展名,不带 . + */ + public static String getExtensionName(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot >-1) && (dot < (filename.length() - 1))) { + return filename.substring(dot + 1); + } + } + return filename; + } + + /** + * Java文件操作 获取不带扩展名的文件名 + */ + public static String getFileNameNoEx(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot >-1) && (dot < (filename.length()))) { + return filename.substring(0, dot); + } + } + return filename; + } + + /** + * 文件大小转换 + */ + public static String getSize(long size){ + String resultSize; + if (size / GB >= 1) { + //如果当前Byte的值大于等于1GB + resultSize = DF.format(size / (float) GB) + "GB "; + } else if (size / MB >= 1) { + //如果当前Byte的值大于等于1MB + resultSize = DF.format(size / (float) MB) + "MB "; + } else if (size / KB >= 1) { + //如果当前Byte的值大于等于1KB + resultSize = DF.format(size / (float) KB) + "KB "; + } else { + resultSize = size + "B "; + } + return resultSize; + } + + /** + * inputStream 转 File + */ + public static File inputStreamToFile(InputStream ins, String name) throws Exception{ + File file = new File(System.getProperty("java.io.tmpdir") + File.separator + name); + if (file.exists()) { + return file; + } + OutputStream os = new FileOutputStream(file); + int bytesRead; + int len = 8192; + byte[] buffer = new byte[len]; + while ((bytesRead = ins.read(buffer, 0, len)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + return file; + } + + /** + * 将文件名解析成文件的上传路径 + */ + public static File upload(MultipartFile file, String filePath) { + //String name = getFileNameNoEx(file.getOriginalFilename()); + String suffix = getExtensionName(file.getOriginalFilename()); + StringBuffer nowStr = fileRename(); + try { + String fileName = nowStr + "." + suffix; + String path = filePath + fileName; + // getCanonicalFile 可解析正确各种路径 + File dest = new File(path).getCanonicalFile(); + // 检测是否存在目录 + if (!dest.getParentFile().exists()) { + dest.getParentFile().mkdirs(); + } + // 文件写入 + file.transferTo(dest); + return dest; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String fileToBase64(File file) throws Exception { + FileInputStream inputFile = new FileInputStream(file); + String base64; + byte[] buffer = new byte[(int)file.length()]; + inputFile.read(buffer); + inputFile.close(); + base64=Base64.encode(buffer); + return base64.replaceAll("[\\s*\t\n\r]", ""); + } + + /** + * 导出excel + */ + public static void downloadExcel(List> list, HttpServletResponse response) throws IOException { + String tempPath =System.getProperty("java.io.tmpdir") + IdUtil.fastSimpleUUID() + ".xlsx"; + File file = new File(tempPath); + BigExcelWriter writer= ExcelUtil.getBigWriter(file); + // 一次性写出内容,使用默认样式,强制输出标题 + writer.write(list, true); + //response为HttpServletResponse对象 + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); + //test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码 + response.setHeader("Content-Disposition","attachment;filename=file.xlsx"); + ServletOutputStream out=response.getOutputStream(); + // 终止后删除临时文件 + file.deleteOnExit(); + writer.flush(out, true); + //此处记得关闭输出Servlet流 + IoUtil.close(out); + } + + public static String getFileType(String type) { + String documents = "txt doc pdf ppt pps xlsx xls docx"; + String music = "mp3 wav wma mpa ram ra aac aif m4a"; + String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg"; + String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg"; + if(image.contains(type)){ + return "pic"; + } else if(documents.contains(type)){ + return "txt"; + } else if(music.contains(type)){ + return "music"; + } else if(video.contains(type)){ + return "vedio"; + } else { + return "other"; + } + } + + + public static void checkSize(long maxSize, long size) { + // 1M + int len = 1024 * 1024; + if(size > (maxSize * len)){ + throw new BadRequestException("文件超出规定大小"); + } + } + + /** + * 判断两个文件是否相同 + */ + public static boolean check(File file1, File file2) { + String img1Md5 = getMd5(file1); + String img2Md5 = getMd5(file2); + return img1Md5.equals(img2Md5); + } + + /** + * 判断两个文件是否相同 + */ + public static boolean check(String file1Md5, String file2Md5) { + return file1Md5.equals(file2Md5); + } + + private static byte[] getByte(File file) { + // 得到文件长度 + byte[] b = new byte[(int) file.length()]; + try { + InputStream in = new FileInputStream(file); + try { + in.read(b); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + return null; + } + return b; + } + + private static String getMd5(byte[] bytes) { + // 16进制字符 + char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + try { + MessageDigest mdTemp = MessageDigest.getInstance("MD5"); + mdTemp.update(bytes); + byte[] md = mdTemp.digest(); + int j = md.length; + char[] str = new char[j * 2]; + int k = 0; + // 移位 输出字符串 + for (byte byte0 : md) { + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; + str[k++] = hexDigits[byte0 & 0xf]; + } + return new String(str); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 下载文件 + * @param request / + * @param response / + * @param file / + */ + public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit){ + response.setCharacterEncoding(request.getCharacterEncoding()); + response.setContentType("application/octet-stream"); + FileInputStream fis = null; + try { + fis = new FileInputStream(file); + response.setHeader("Content-Disposition", "attachment; filename="+file.getName()); + IoUtil.copy(fis,response.getOutputStream()); + response.flushBuffer(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (fis != null) { + try { + fis.close(); + if(deleteOnExit){ + file.deleteOnExit(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + public static String getMd5(File file) { + return getMd5(getByte(file)); + } + + /** + * 读取json文件,返回json串 + * @param fileName + * @return + */ + public static String readJsonFile(String fileName) { + String jsonStr = ""; + try { + File jsonFile = new File(fileName); + FileReader fileReader = new FileReader(jsonFile); + + Reader reader = new InputStreamReader(new FileInputStream(jsonFile),"utf-8"); + int ch = 0; + StringBuffer sb = new StringBuffer(); + while ((ch = reader.read()) != -1) { + sb.append((char) ch); + } + fileReader.close(); + reader.close(); + jsonStr = sb.toString(); + return jsonStr; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + public static BufferedImage inputImage(MultipartFile file) { + BufferedImage srcImage = null; + try { + FileInputStream in = (FileInputStream) file.getInputStream(); + srcImage = javax.imageio.ImageIO.read(in); + } catch (IOException e) { + System.out.println("读取图片文件出错!" + e.getMessage()); + } + return srcImage; + } + /** + * 自动调节精度(经验数值) + * + * @param size 源图片大小 + * @return 图片压缩质量比 + */ + public static float getAccuracy(long size) { + float accuracy; + if (size < 400) { + accuracy = 0.85f; + } else if (size < 900) { + accuracy = 0.75f; + } else if (size < 2047) { + accuracy = 0.6f; + } else if (size < 3275) { + accuracy = 0.44f; + } else { + accuracy = 0.4f; + } + return accuracy; + } + + /** + * 上传文件重命名 + * @return 新的文件名 + */ + public static StringBuffer fileRename() { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + String time = sdf.format(new Date()); + StringBuffer buf = new StringBuffer(time); + Random r = new Random(); + //循环取得三个不大于10的随机整数 + for (int x = 0; x < 3; x++) { + buf.append(r.nextInt(10)); + } + return buf; + } + + /** + * 对中文字符进行UTF-8编码 + * @param source 要转义的字符串 + * @return + * @throws UnsupportedEncodingException + */ + public static String transformStyle(String source) throws UnsupportedEncodingException + { + char[] arr = source.toCharArray(); + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < arr.length; i++) + { + char temp = arr[i]; + if(isChinese(temp)) + { + sb.append(URLEncoder.encode("" + temp, "UTF-8")); + continue; + } + sb.append(arr[i]); + } + return sb.toString(); + } + + /** + * 判断是不是中文字符 + * @param c + * @return + */ + public static boolean isChinese(char c) + { + + Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); + + if(ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS + + || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS + + || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A + + || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION + + || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION + + || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) + { + + return true; + + } + + return false; + + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/FontUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/FontUtil.java new file mode 100644 index 00000000..7af2cd65 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/FontUtil.java @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import java.awt.Font; +import java.awt.FontFormatException; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * 字体工具类 + * Created by 刘彦民 on 2018/5/5. + */ +public class FontUtil { + /** + * 默认字体 + */ + public static final int DEFAULT_FONT = 1; + /** + * PingFangSC字体 + */ + public static final int PINGFANG_FONT = 2; + /** + * PingFangSCBold字体 + */ + public static final int PINGFANG_BOLD_FONT = 3; + /** + * 方正兰亭特黑GBK + */ + public static final int FZLTTH_GBK_FONT = 4; + + + /** + * 根据字体类型获取字体 + * @param type + * @param size + * @return + */ + public static Font getFont(int type, float size) { + // 字体路径 + String path = ""; + switch (type) { + case DEFAULT_FONT: + path = "D:/upload/resources/font/simhei.ttf"; + break; + case PINGFANG_FONT: + path = "D:/upload/resources/font/PingFangSC.ttf"; + break; + case PINGFANG_BOLD_FONT: + path = "D:/upload/resources/font/PingFangBold.ttf"; + break; + case FZLTTH_GBK_FONT: + path = "D:/upload/resources/font/fzltthjwgb10.ttf"; + break; + default: + path = "D:/upload/resources/font/simhei.ttf"; + } + + File file = new File(path); + InputStream inputStream = null; + try { + inputStream = new FileInputStream(file); + Font sPfBoldFont = Font.createFont(Font.TRUETYPE_FONT, inputStream); + sPfBoldFont = sPfBoldFont.deriveFont(size); + return sPfBoldFont; + } catch (FontFormatException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (inputStream != null) { + inputStream.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/GsonParser.java b/zsw-bxg/src/main/java/co/yixiang/utils/GsonParser.java new file mode 100644 index 00000000..c62bb9bb --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/GsonParser.java @@ -0,0 +1,26 @@ +package co.yixiang.utils; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.stream.JsonReader; + +import java.io.Reader; + +/** + * @author niefy + */ +public class GsonParser { + private static final JsonParser JSON_PARSER = new JsonParser(); + + public static JsonObject parse(String json) { + return JSON_PARSER.parse(json).getAsJsonObject(); + } + + public static JsonObject parse(Reader json) { + return JSON_PARSER.parse(json).getAsJsonObject(); + } + + public static JsonObject parse(JsonReader json) { + return JSON_PARSER.parse(json).getAsJsonObject(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/IpUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/IpUtil.java new file mode 100644 index 00000000..abf02cbf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/IpUtil.java @@ -0,0 +1,165 @@ +package co.yixiang.utils; + +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +public class IpUtil { + private IpUtil(){} + /** + * 此方法描述的是:获得服务器的IP地址 + * @author: zhangyang33@sinopharm.com + * @version: 2014年9月5日 下午4:57:15 + */ + public static String getLocalIP() { + String sIP = ""; + InetAddress ip = null; + try { + boolean bFindIP = false; + Enumeration netInterfaces = (Enumeration) NetworkInterface + .getNetworkInterfaces(); + while (netInterfaces.hasMoreElements()) { + if (bFindIP) { + break; + } + NetworkInterface ni = (NetworkInterface) netInterfaces + .nextElement(); + Enumeration ips = ni.getInetAddresses(); + while (ips.hasMoreElements()) { + ip = (InetAddress) ips.nextElement(); + if (!ip.isLoopbackAddress() + && ip.getHostAddress().matches( + "(\\d{1,3}\\.){3}\\d{1,3}")) { + bFindIP = true; + break; + } + } + } + } catch (Exception e) { + } + if (null != ip) { + sIP = ip.getHostAddress(); + } + return sIP; + } + /** + * 此方法描述的是:获得服务器的IP地址(多网卡) + * @author: zhangyang33@sinopharm.com + * @version: 2014年9月5日 下午4:57:15 + */ + public static List getLocalIPS() { + InetAddress ip = null; + List ipList = new ArrayList(); + try { + Enumeration netInterfaces = (Enumeration) NetworkInterface + .getNetworkInterfaces(); + while (netInterfaces.hasMoreElements()) { + NetworkInterface ni = (NetworkInterface) netInterfaces + .nextElement(); + Enumeration ips = ni.getInetAddresses(); + while (ips.hasMoreElements()) { + ip = (InetAddress) ips.nextElement(); + if (!ip.isLoopbackAddress() + && ip.getHostAddress().matches( + "(\\d{1,3}\\.){3}\\d{1,3}")) { + ipList.add(ip.getHostAddress()); + } + } + } + } catch (Exception e) { + } + return ipList; + } + /** + * 此方法描述的是:获得服务器的MAC地址 + * @author: zhangyang33@sinopharm.com + * @version: 2014年9月5日 下午1:27:25 + */ + public static String getMacId() { + String macId = ""; + InetAddress ip = null; + NetworkInterface ni = null; + try { + boolean bFindIP = false; + Enumeration netInterfaces = (Enumeration) NetworkInterface + .getNetworkInterfaces(); + while (netInterfaces.hasMoreElements()) { + if (bFindIP) { + break; + } + ni = (NetworkInterface) netInterfaces + .nextElement(); + // ----------特定情况,可以考虑用ni.getName判断 + // 遍历所有ip + Enumeration ips = ni.getInetAddresses(); + while (ips.hasMoreElements()) { + ip = (InetAddress) ips.nextElement(); + if (!ip.isLoopbackAddress() // 非127.0.0.1 + && ip.getHostAddress().matches( + "(\\d{1,3}\\.){3}\\d{1,3}")) { + bFindIP = true; + break; + } + } + } + } catch (Exception e) { + } + if (null != ip) { + try { + macId = getMacFromBytes(ni.getHardwareAddress()); + } catch (SocketException e) { + } + } + return macId; + } + /** + * 此方法描述的是:获得服务器的MAC地址(多网卡) + * @author: zhangyang33@sinopharm.com + * @version: 2014年9月5日 下午1:27:25 + */ + public static List getMacIds() { + InetAddress ip = null; + NetworkInterface ni = null; + List macList = new ArrayList(); + try { + Enumeration netInterfaces = (Enumeration) NetworkInterface + .getNetworkInterfaces(); + while (netInterfaces.hasMoreElements()) { + ni = (NetworkInterface) netInterfaces + .nextElement(); + // ----------特定情况,可以考虑用ni.getName判断 + // 遍历所有ip + Enumeration ips = ni.getInetAddresses(); + while (ips.hasMoreElements()) { + ip = (InetAddress) ips.nextElement(); + if (!ip.isLoopbackAddress() // 非127.0.0.1 + && ip.getHostAddress().matches( + "(\\d{1,3}\\.){3}\\d{1,3}")) { + macList.add(getMacFromBytes(ni.getHardwareAddress())); + } + } + } + } catch (Exception e) { + } + return macList; + } + private static String getMacFromBytes(byte[] bytes) { + StringBuffer mac = new StringBuffer(); + byte currentByte; + boolean first = false; + for (byte b : bytes) { + if (first) { + mac.append("-"); + } + currentByte = (byte) ((b & 240) >> 4); + mac.append(Integer.toHexString(currentByte)); + currentByte = (byte) (b & 15); + mac.append(Integer.toHexString(currentByte)); + first = true; + } + return mac.toString().toUpperCase(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/OrderUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/OrderUtil.java new file mode 100644 index 00000000..cfc193df --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/OrderUtil.java @@ -0,0 +1,295 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; +import co.yixiang.enums.ShopCommonEnum; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; + +/** + * @ClassName OrderUtil + * @Author hupeng <610796224@qq.com> + * @Date 2019/9/13 + **/ +public class OrderUtil { + + + /** + * 获取精确到秒的时间戳 + * @return + **/ + public static int getSecondTimestamp(){ + String timestamp = String.valueOf(System.currentTimeMillis()/1000); + return Integer.valueOf(timestamp); + } + + + /** + * 返回活动状态 + * @param starTime 开始时间 + * @param endTime 结束时间 + * @param status 0-关闭 其他表示相反 + * @return String + */ + public static String checkActivityStatus(Date starTime,Date endTime,Integer status){ + Date nowTime = new Date(); + + if(ShopCommonEnum.IS_STATUS_0.getValue().equals(status)) { + return "关闭"; + } + + if(DateUtil.compare(starTime,nowTime) > 0){ + return "活动未开始"; + }else if(DateUtil.compare(endTime,nowTime) < 0){ + return "活动已结束"; + }else if(DateUtil.compare(endTime,nowTime) > 0 && DateUtil.compare(starTime,nowTime) < 0){ + return "正在进行中"; + } + + return "未知"; + + } + + /** + * 生成邀请码 + * + * @return + */ + public static String createShareCode() { + int maxNum = 36; + int i; + int count = 0; + char[] str = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', + 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + StringBuffer pwd = new StringBuffer(""); + Random r = new Random(); + while (count < 10) { + i = Math.abs(r.nextInt(maxNum)); + if (i >= 0 && i < str.length) { + pwd.append(str[i]); + count++; + } + } + return pwd.toString(); + } + + /** + * 获取俩个数之间的随机数 + * + * @param min + * @param max + * @return + */ + public static Double randomNumber(double min, double max) { + return NumberUtil.add(min, + NumberUtil.mul(Math.random(), + NumberUtil.sub(max, min))); + } + + /** + * 时间戳订单号 + * + * @return + */ + public static String orderSn() { + Date date = DateUtil.date(); + return DateUtil.format(date, "yyyyMMddHHmmssSSS"); + } + + /* + * 将时间戳转换为时间 + */ + public static String stampToDate(String s) { + String res; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + long lt = new Long(s) * 1000; + Date date = new Date(lt); + res = simpleDateFormat.format(date); + return res; + } + + /* + * 将时间戳转换为date + */ + public static Date stampToDateObj(String s) { + long lt = new Long(s) * 1000; + Date date = new Date(lt); + return date; + } + + + /** + * 获取精确到秒的时间戳 + * + * @return + **/ + public static int getSecondTimestampTwo() { + String timestamp = String.valueOf(System.currentTimeMillis() / 1000); + return Integer.valueOf(timestamp); + } + + /** + * 获取精确到秒的时间戳 + * + * @return + **/ + public static int dateToTimestamp(Date date) { + String timestamp = String.valueOf(date.getTime() / 1000); + return Integer.valueOf(timestamp); + } + + /** + * 获取精确到秒的时间戳 + * + * @return + **/ + public static int dateToTimestampT(DateTime date) { + String timestamp = String.valueOf(date.getTime() / 1000); + return Integer.valueOf(timestamp); + } + + public static long dateToSecond(String str) throws Exception { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = simpleDateFormat.parse(str); + long ts = date.getTime(); + return ts/1000; + } + + /** + * 获取订单状态名称 + * + * @param paid + * @param status + * @param shipping_type + * @param refund_status + * @return + */ + public static String orderStatusStr(int paid, int status, + int shipping_type, int refund_status) { + String statusName = ""; + if (paid == 0 && status == 0) { + statusName = "未支付"; + } else if (paid == 1 && status == 0 && shipping_type == 1 && refund_status == 0) { + statusName = "未发货"; + } else if (paid == 1 && status == 0 && shipping_type == 2 && refund_status == 0) { + statusName = "未核销"; + } else if (paid == 1 && status == 1 && shipping_type == 1 && refund_status == 0) { + statusName = "待收货"; + } else if (paid == 1 && status == 1 && shipping_type == 2 && refund_status == 0) { + statusName = "未核销"; + } else if (paid == 1 && status == 2 && refund_status == 0) { + statusName = "待评价"; + } else if (paid == 1 && status == 3 && refund_status == 0) { + statusName = "已完成"; + } else if (paid == 1 && refund_status == 1) { + statusName = "退款中"; + } else if (paid == 1 && refund_status == 2) { + statusName = "已退款"; + } + + return statusName; + } + + + /** + * 获取状态数值 + * + * @param paid + * @param status + * @param refund_status + * @return + */ + public static int orderStatus(int paid, int status, int refund_status) { + //todo 1-未付款 2-未发货 3-退款中 4-待收货 5-待评价 6-已完成 7-已退款 + int _status = 0; + + if (paid == 0 && status == 0 && refund_status == 0) { + _status = 1; + } else if (paid == 1 && status == 0 && refund_status == 0) { + _status = 2; + } else if (paid == 1 && refund_status == 1) { + _status = 3; + } else if (paid == 1 && status == 1 && refund_status == 0) { + _status = 4; + } else if (paid == 1 && status == 2 && refund_status == 0) { + _status = 5; + } else if (paid == 1 && status == 3 && refund_status == 0) { + _status = 6; + } else if (paid == 1 && refund_status == 2) { + _status = 7; + } + + return _status; + + } + + + /** + * 支付方式 + * + * @param pay_type + * @param paid + * @return + */ + public static String payTypeName(String pay_type, int paid) { + String payTypeName = ""; + if (paid == 1) { + switch (pay_type) { + case "weixin": + payTypeName = "微信支付"; + break; + case "yue": + payTypeName = "余额支付"; + break; + case "integral": + payTypeName = "积分兑换"; + break; + case "offline": + payTypeName = "线下支付"; + break; + default: + payTypeName = "其他支付"; + break; + } + } else { + switch (pay_type) { + default: + payTypeName = "未支付"; + break; + case "offline": + payTypeName = "线下支付"; + break; + } + } + return payTypeName; + } + + /** + * 支付渠道(0微信公众号1微信小程序) + * + * @return + */ + public static String payChannel(Integer pay_channel) { + if (pay_channel.equals(1)) { + return "微信小程序"; + } else { + return "微信公众号"; + } + } + + //todo 订单类型 + public static String orderType(int pinkId) { + return "普通订单"; + } + + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/PageUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/PageUtil.java new file mode 100644 index 00000000..f2b9c49d --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/PageUtil.java @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import org.springframework.data.domain.Page; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * 分页工具 + * @author Zheng Jie + * @date 2018-12-10 + */ +public class PageUtil extends cn.hutool.core.util.PageUtil { + + /** + * List 分页 + */ + public static List toPage(int page, int size , List list) { + int fromIndex = page * size; + int toIndex = page * size + size; + if(fromIndex > list.size()){ + return new ArrayList(); + } else if(toIndex >= list.size()) { + return list.subList(fromIndex,list.size()); + } else { + return list.subList(fromIndex,toIndex); + } + } + + /** + * Page 数据处理,预防redis反序列化报错 + */ + public static Map toPage(Page page) { + Map map = new LinkedHashMap<>(2); + map.put("content",page.getContent()); + map.put("totalElements",page.getTotalElements()); + return map; + } + + + + /** + * 自定义分页 + */ + public static Map toPage(Object object, Object totalElements) { + Map map = new LinkedHashMap<>(2); + map.put("content",object); + map.put("totalElements",totalElements); + return map; + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/RecodeUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/RecodeUtil.java new file mode 100644 index 00000000..13c9f477 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/RecodeUtil.java @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; +import com.google.zxing.BarcodeFormat; +import com.google.zxing.EncodeHintType; +import com.google.zxing.MultiFormatWriter; +import com.google.zxing.WriterException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletResponse; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Hashtable; + +/** + * @author :LionCity + * @date :Created in 2020/2/27 15:33 + * @description: + * @modified By: + * @version: + */ +public class RecodeUtil { + + public static void creatRrCode(String contents, int width, int height, HttpServletResponse response) { + Hashtable hints = new Hashtable(); + + hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); //容错级别最高 + hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); //设置字符编码 + hints.put(EncodeHintType.MARGIN, 1); //二维码空白区域,最小为0也有白边,只是很小,最小是6像素左右 + try { + BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, width, height, hints); // 1、读取文件转换为字节数组 +// ByteArrayOutputStream out = new ByteArrayOutputStream(); + BufferedImage image = toBufferedImage(bitMatrix); + //转换成png格式的IO流 + ImageIO.write(image, "png", response.getOutputStream()); +// byte[] bytes = out.toByteArray(); +// // 2、将字节数组转为二进制 +// BASE64Encoder encoder = new BASE64Encoder(); +// binary = encoder.encodeBuffer(bytes).trim(); + } catch (WriterException e) { // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + + /** + * image流数据处理 + * + * @author ianly + */ + public static BufferedImage toBufferedImage(BitMatrix matrix) { + int width = matrix.getWidth(); + int height = matrix.getHeight(); + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + image.setRGB(x, y, matrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF); + } + } + return image; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/RedisUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/RedisUtils.java new file mode 100644 index 00000000..cbc32a24 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/RedisUtils.java @@ -0,0 +1,624 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + * 注意: + * 本软件为www.yixiang.co开发研制,未经购买不得使用 + * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) + * 一经发现盗用、分享等行为,将追究法律责任,后果自负 + */ +package co.yixiang.utils; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.*; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * @author / + */ +@Component +@SuppressWarnings({"unchecked","all"}) +public class RedisUtils { + + @Autowired + private RedisTemplate stringRedisTemplate; + + + // =============================commonold============================ + + /** + * 指定缓存失效时间 + * @param key 键 + * @param time 时间(秒) + */ + public boolean expire(String key, long time) { + try { + if (time > 0) { + stringRedisTemplate.expire(key, time, TimeUnit.SECONDS); + } + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + /** + * 根据 key 获取过期时间 + * @param key 键 不能为null + * @return 时间(秒) 返回0代表为永久有效 + */ + public long getExpire(String key) { + return stringRedisTemplate.getExpire(key, TimeUnit.SECONDS); + } + + /** + * 查找匹配key + * @param pattern key + * @return / + */ + public List scan(String pattern) { + ScanOptions options = ScanOptions.scanOptions().match(pattern).build(); + RedisConnectionFactory factory = stringRedisTemplate.getConnectionFactory(); + RedisConnection rc = Objects.requireNonNull(factory).getConnection(); + Cursor cursor = rc.scan(options); + List result = new ArrayList<>(); + while (cursor.hasNext()) { + result.add(new String(cursor.next())); + } + try { + RedisConnectionUtils.releaseConnection(rc, factory); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + /** + * 分页查询 key + * @param patternKey key + * @param page 页码 + * @param size 每页数目 + * @return / + */ + public List findKeysForPage(String patternKey, int page, int size) { + ScanOptions options = ScanOptions.scanOptions().match(patternKey).build(); + RedisConnectionFactory factory = stringRedisTemplate.getConnectionFactory(); + RedisConnection rc = Objects.requireNonNull(factory).getConnection(); + Cursor cursor = rc.scan(options); + List result = new ArrayList<>(size); + int tmpIndex = 0; + int fromIndex = page * size; + int toIndex = page * size + size; + while (cursor.hasNext()) { + if (tmpIndex >= fromIndex && tmpIndex < toIndex) { + result.add(new String(cursor.next())); + tmpIndex++; + continue; + } + // 获取到满足条件的数据后,就可以退出了 + if(tmpIndex >=toIndex) { + break; + } + tmpIndex++; + cursor.next(); + } + try { + RedisConnectionUtils.releaseConnection(rc, factory); + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + /** + * 判断key是否存在 + * @param key 键 + * @return true 存在 false不存在 + */ + public boolean hasKey(String key) { + try { + return stringRedisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * @param key 可以传一个值 或多个 + */ + public void del(String... key) { + if (key != null && key.length > 0) { + if (key.length == 1) { + stringRedisTemplate.delete(key[0]); + } else { + stringRedisTemplate.delete((Collection) CollectionUtils.arrayToList(key)); + } + } + } + + // ============================String============================= + + /** + * 普通缓存获取 + * @param key 键 + * @return 值 + */ + public Object get(String key) { + return key == null ? null : stringRedisTemplate.opsForValue().get(key); + } + + public String getY(String key){ + return key == null || !stringRedisTemplate.hasKey(key) ? "" : stringRedisTemplate.opsForValue().get(key).toString(); + } + + /** + * 批量获取 + * @param keys + * @return + */ + public List multiGet(List keys) { + Object obj = stringRedisTemplate.opsForValue().multiGet(keys); + return null; + } + + /** + * 普通缓存放入 + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean set(String key, Object value) { + try { + stringRedisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入并设置时间 + * @param key 键 + * @param value 值 + * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean set(String key, Object value, long time) { + try { + if (time > 0) { + stringRedisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); + } else { + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 普通缓存放入并设置时间 + * @param key 键 + * @param value 值 + * @param time 时间 + * @param timeUnit 类型 + * @return true成功 false 失败 + */ + public boolean set(String key, String value, long time, TimeUnit timeUnit) { + try { + if (time > 0) { + stringRedisTemplate.opsForValue().set(key, value, time, timeUnit); + } else { + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + // ================================Map================================= + + /** + * HashGet + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public Object hget(String key, String item) { + return stringRedisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * @param key 键 + * @return 对应的多个键值 + */ + public Map hmget(String key) { + return stringRedisTemplate.opsForHash().entries(key); + + } + + /** + * HashSet + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public boolean hmset(String key, Map map) { + try { + stringRedisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public boolean hmset(String key, Map map, long time) { + try { + stringRedisTemplate.opsForHash().putAll(key, map); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public boolean hset(String key, String item, Object value) { + try { + stringRedisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public boolean hset(String key, String item, Object value, long time) { + try { + stringRedisTemplate.opsForHash().put(key, item, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public void hdel(String key, Object... item) { + stringRedisTemplate.opsForHash().delete(key, item); + } + + /** + * 判断hash表中是否有该项的值 + * + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public boolean hHasKey(String key, String item) { + return stringRedisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return + */ + public double hincr(String key, String item, double by) { + return stringRedisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return + */ + public double hdecr(String key, String item, double by) { + return stringRedisTemplate.opsForHash().increment(key, item, -by); + } + + // ============================set============================= + + /** + * 根据key获取Set中的所有值 + * + * @param key 键 + * @return + */ + public Set sGet(String key) { + try { + return stringRedisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public boolean sHasKey(String key, Object value) { + try { + return stringRedisTemplate.opsForSet().isMember(key, value); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSet(String key, Object... values) { + try { + return stringRedisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSetAndTime(String key, long time, Object... values) { + try { + Long count = stringRedisTemplate.opsForSet().add(key, values); + if (time > 0) { + expire(key, time); + } + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * @param key 键 + * @return + */ + public long sGetSetSize(String key) { + try { + return stringRedisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public long setRemove(String key, Object... values) { + try { + Long count = stringRedisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + // ===============================list================================= + + /** + * 获取list缓存的内容 + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return + */ + public List lGet(String key, long start, long end) { + try { + return stringRedisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * @param key 键 + * @return + */ + public long lGetListSize(String key) { + try { + return stringRedisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * @param key 键 + * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 + * @return + */ + public Object lGetIndex(String key, long index) { + try { + return stringRedisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, Object value) { + try { + stringRedisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, Object value, long time) { + try { + stringRedisTemplate.opsForList().rightPush(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, List value) { + try { + stringRedisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, List value, long time) { + try { + stringRedisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * @param key 键 + * @param index 索引 + * @param value 值 + * @return / + */ + public boolean lUpdateIndex(String key, long index, Object value) { + try { + stringRedisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public long lRemove(String key, long count, Object value) { + try { + return stringRedisTemplate.opsForList().remove(key, count, value); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/RegexUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/RegexUtil.java new file mode 100644 index 00000000..1b7fee3a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/RegexUtil.java @@ -0,0 +1,86 @@ +package co.yixiang.utils; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author :LionCity + * @date :Created in 2020-10-19 14:44 + * @description:正则表达式匹配两个字符串之间的内容 + * @modified By: + * @version: + */ +public class RegexUtil { + + + /** + * 转换产品描述 + * + * @param str str + * @return {@link String} + */ + public static String converProductDescription(String str){ + StringBuilder sb = new StringBuilder(); + List imgArr=Arrays.asList(str.split("p>0){ + if(img.indexOf("style=")>0){ + String rgex = "style=\"(.*?)\""; + String rgexStr = getSubUtilSimple(img, rgex); + if(rgexStr.indexOf("max-width: 100%;")<0){ + img=img.replace( rgexStr ,rgexStr+"max-width: 100%"); + } + }else{ + img=" style=\"max-width: 100%;\""+img; + } + } + sb.append(img); + } + return sb.toString(); + } + + + /** + * 正则表达式匹配两个指定字符串中间的内容 + * + * @param soap + * @return + */ + public static List getSubUtil(String soap, String rgex) { + List list = new ArrayList(); + // 匹配的模式 + Pattern pattern = Pattern.compile(rgex); + Matcher m = pattern.matcher(soap); + while (m.find()) { + int i = 1; + list.add(m.group(i)); + i++; + } + return list; + } + + /** + * 返回单个字符串,若匹配到多个的话就返回第一个,方法与getSubUtil一样 + * + * @param soap + * @param rgex + * @return + */ + public static String getSubUtilSimple(String soap, String rgex) { + // 匹配的模式 + Pattern pattern = Pattern.compile(rgex); + Matcher m = pattern.matcher(soap); + while (m.find()) { + return m.group(1); + } + return ""; + } +} \ No newline at end of file diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/RequestHolder.java b/zsw-bxg/src/main/java/co/yixiang/utils/RequestHolder.java new file mode 100644 index 00000000..cd7b2ca3 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/RequestHolder.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; + +/** + * 获取 HttpServletRequest + * @author Zheng Jie + * @date 2018-11-24 + */ +public class RequestHolder { + + public static HttpServletRequest getHttpServletRequest() { + return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/SecurityUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/SecurityUtils.java new file mode 100644 index 00000000..83e4f990 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/SecurityUtils.java @@ -0,0 +1,58 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.utils; +// +//import cn.hutool.json.JSONObject; +//import co.yixiang.exception.BadRequestException; +//import org.springframework.http.HttpStatus; +//import org.springframework.security.core.Authentication; +//import org.springframework.security.core.context.SecurityContextHolder; +//import org.springframework.security.core.userdetails.UserDetails; +//import org.springframework.security.core.userdetails.UserDetailsService; +// +///** +// * 获取当前登录的用户 +// * @author Zheng Jie +// * @date 2019-01-17 +// */ +//public class SecurityUtils { +// +// public static UserDetails getUserDetails() { +// final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); +// if (authentication == null) { +// throw new BadRequestException(HttpStatus.UNAUTHORIZED, "当前登录状态过期"); +// } +// if (authentication.getPrincipal() instanceof UserDetails) { +// UserDetails userDetails = (UserDetails) authentication.getPrincipal(); +// UserDetailsService userDetailsService = SpringContextHolder.getBean(UserDetailsService.class); +// return userDetailsService.loadUserByUsername(userDetails.getUsername()); +// } +// throw new BadRequestException(HttpStatus.UNAUTHORIZED, "找不到当前登录的信息"); +// } +// +// /** +// * 获取系统用户名称 +// * @return 系统用户名称 +// */ +// public static String getUsername(){ +// final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); +// if (authentication == null) { +// throw new BadRequestException(HttpStatus.UNAUTHORIZED, "当前登录状态过期"); +// } +// UserDetails userDetails = (UserDetails) authentication.getPrincipal(); +// return userDetails.getUsername(); +// } +// +// /** +// * 获取系统用户id +// * @return 系统用户id +// */ +// public static Long getUserId(){ +// Object obj = getUserDetails(); +// JSONObject json = new JSONObject(obj); +// return json.get("id", Long.class); +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/ShopKeyUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/ShopKeyUtils.java new file mode 100644 index 00000000..5ee41875 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/ShopKeyUtils.java @@ -0,0 +1,180 @@ +package co.yixiang.utils; + +import co.yixiang.constant.ShopConstants; +import co.yixiang.constant.SystemConfigConstants; + +/** + * 处理缓存key值的统一入口,方面后面扩展, + * 例如:多租户就要在每个key后拼接上租户ID,只要统一修改这里就可以了 + */ +public class ShopKeyUtils { + /** + *扩展值,默认为空, 把这个值追加到所有key值上 + */ + private static String getExtendValue(){ + String extendValue= ""; + return extendValue; + } + + //*********************************begin yx_system_config 通用值 ***************************************************** + + /** + * api_url + */ + public static String getApiUrl(){ + String apiUrl= SystemConfigConstants.API_URL; + return apiUrl; + } + /** + * site_url + */ + public static String getSiteUrl(){ + String siteUrl= SystemConfigConstants.SITE_URL; + return siteUrl; + } + /** + * 腾讯mapkey tengxun_map_key + */ + public static String getTengXunMapKey(){ + String tengxunMapKey= SystemConfigConstants.TENGXUN_MAP_KEY; + return tengxunMapKey; + } + + //*********************************begin yx_system_config 业务字段 ***************************************************** + /** + * store_self_mention + */ + public static String getStoreSelfMention(){ + String storeSelfMention= SystemConfigConstants.STORE_SEFL_MENTION; + return storeSelfMention+getExtendValue(); + } + + + //*********************************begin yx_system_config 微信配置相关字段 ***************************************************** + + /** + * 微信公众号service + */ + public static String getYshopWeiXinMpSevice(){ + String yshopWeiXinMpSevice= ShopConstants.YSHOP_WEIXIN_MP_SERVICE; + return yshopWeiXinMpSevice+getExtendValue(); + } + + /** + * 微信公众号id + */ + public static String getWechatAppId(){ + String wechatAppId= SystemConfigConstants.WECHAT_APPID; + return wechatAppId+getExtendValue(); + } + /** + * 微信公众号secret + */ + public static String getWechatAppSecret(){ + String wechatAppSecret= SystemConfigConstants.WECHAT_APPSECRET; + return wechatAppSecret+getExtendValue(); + } + /** + * 微信公众号验证token + */ + public static String getWechatToken(){ + String wechatToken= SystemConfigConstants.WECHAT_TOKEN; + return wechatToken+getExtendValue(); + } + /** + * 微信公众号 EncodingAESKey + */ + public static String getWechatEncodingAESKey(){ + String wechatEncodingAESKey= SystemConfigConstants.WECHAT_ENCODINGAESKEY; + return wechatEncodingAESKey+getExtendValue(); + } + /** + * 微信支付service + */ + public static String getYshopWeiXinPayService(){ + String yshopWeiXinPayService= ShopConstants.YSHOP_WEIXIN_PAY_SERVICE; + return yshopWeiXinPayService+getExtendValue(); + } + /** + * 商户号 + */ + public static String getWxPayMchId(){ + String wxPayMchId= SystemConfigConstants.WXPAY_MCHID; + return wxPayMchId+getExtendValue(); + } + /** + * 商户秘钥 + */ + public static String getWxPayMchKey(){ + String wxPayMchKey= SystemConfigConstants.WXPAY_MCHKEY; + return wxPayMchKey+getExtendValue(); + } + /** + * 商户证书路径 + */ + public static String getWxPayKeyPath(){ + String wxPayKeyPath= SystemConfigConstants.WXPAY_KEYPATH; + return wxPayKeyPath+getExtendValue(); + } + /** + * 微信支付小程序service + */ + public static String getYshopWeiXinMiniPayService(){ + String yshopWeiXinMiniPayService= ShopConstants.YSHOP_WEIXIN_MINI_PAY_SERVICE; + return yshopWeiXinMiniPayService+getExtendValue(); + } + /** + * 微信支付app service + */ + public static String getYshopWeiXinAppPayService(){ + String yshopWeiXinAppPayService= ShopConstants.YSHOP_WEIXIN_APP_PAY_SERVICE; + return yshopWeiXinAppPayService+getExtendValue(); + } + /** + * 微信小程序id + */ + public static String getWxAppAppId(){ + String wxAppAppId= SystemConfigConstants.WXAPP_APPID; + return wxAppAppId+getExtendValue(); + } + /** + * 微信小程序秘钥 + */ + public static String getWxAppSecret(){ + String wxAppSecret= SystemConfigConstants.WXAPP_SECRET; + return wxAppSecret+getExtendValue(); + } + + /** + * 微信公众号验证token + */ + public static String getWechatMaToken(){ + String wechatToken= SystemConfigConstants.WECHAT_MA_TOKEN; + return wechatToken+getExtendValue(); + } + /** + * 微信公众号 EncodingAESKey + */ + public static String getWechatMaEncodingAESKey(){ + String wechatEncodingAESKey= SystemConfigConstants.WECHAT_MA_ENCODINGAESKEY; + return wechatEncodingAESKey+getExtendValue(); + } + + /** + * 支付appId + */ + public static String getWxNativeAppAppId(){ + String wxNativeAppAppId= SystemConfigConstants.WX_NATIVE_APP_APPID; + return wxNativeAppAppId+getExtendValue(); + } + + /** + * 微信小程序service + * @return + */ + public static String getYshopWeiXinMaSevice() { + String yshopWeiXinMaSevice= ShopConstants.YSHOP_WEIXIN_MA_SERVICE; + return yshopWeiXinMaSevice+getExtendValue(); + } + +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/SpringContextHolder.java b/zsw-bxg/src/main/java/co/yixiang/utils/SpringContextHolder.java new file mode 100644 index 00000000..0ecd1caf --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/SpringContextHolder.java @@ -0,0 +1,71 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.utils; +// +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.BeansException; +//import org.springframework.beans.factory.DisposableBean; +//import org.springframework.context.ApplicationContext; +//import org.springframework.context.ApplicationContextAware; +// +///** +// * @author Jie +// * @date 2019-01-07 +// */ +//@Slf4j +//public class SpringContextHolder implements ApplicationContextAware, DisposableBean { +// +// private static ApplicationContext applicationContext = null; +// +// /** +// * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. +// */ +// @SuppressWarnings("unchecked") +// public static T getBean(String name) { +// assertContextInjected(); +// return (T) applicationContext.getBean(name); +// } +// +// /** +// * 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型. +// */ +// public static T getBean(Class requiredType) { +// assertContextInjected(); +// return applicationContext.getBean(requiredType); +// } +// +// /** +// * 检查ApplicationContext不为空. +// */ +// private static void assertContextInjected() { +// if (applicationContext == null) { +// throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext" + +// ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder."); +// } +// } +// +// /** +// * 清除SpringContextHolder中的ApplicationContext为Null. +// */ +// private static void clearHolder() { +// log.debug("清除SpringContextHolder中的ApplicationContext:" +// + applicationContext); +// applicationContext = null; +// } +// +// @Override +// public void destroy(){ +// SpringContextHolder.clearHolder(); +// } +// +// @Override +// public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { +// if (SpringContextHolder.applicationContext != null) { +// log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext); +// } +// SpringContextHolder.applicationContext = applicationContext; +// } +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/SpringContextUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/SpringContextUtils.java new file mode 100644 index 00000000..61f5dc59 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/SpringContextUtils.java @@ -0,0 +1,46 @@ +///** +// * Copyright (C) 2018-2022 +// * All rights reserved, Designed By www.yixiang.co +// +// */ +//package co.yixiang.utils; +// +//import org.springframework.beans.BeansException; +//import org.springframework.context.ApplicationContext; +//import org.springframework.context.ApplicationContextAware; +//import org.springframework.stereotype.Component; +// +///** +// * Spring Context 工具类 +// */ +//@Component +//public class SpringContextUtils implements ApplicationContextAware { +// public static ApplicationContext applicationContext; +// +// @Override +// public void setApplicationContext(ApplicationContext applicationContext) +// throws BeansException { +// SpringContextUtils.applicationContext = applicationContext; +// } +// +// public static Object getBean(String name) { +// return applicationContext.getBean(name); +// } +// +// public static T getBean(String name, Class requiredType) { +// return applicationContext.getBean(name, requiredType); +// } +// +// public static boolean containsBean(String name) { +// return applicationContext.containsBean(name); +// } +// +// public static boolean isSingleton(String name) { +// return applicationContext.isSingleton(name); +// } +// +// public static Class getType(String name) { +// return applicationContext.getType(name); +// } +// +//} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/StringUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/StringUtils.java new file mode 100644 index 00000000..a4c7ac70 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/StringUtils.java @@ -0,0 +1,175 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import cn.hutool.http.HttpUtil; +import cn.hutool.http.useragent.Browser; +import cn.hutool.http.useragent.UserAgent; +import cn.hutool.http.useragent.UserAgentUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; + +import javax.servlet.http.HttpServletRequest; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Calendar; +import java.util.Date; + +/** + * @author Zheng Jie + * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类 + */ +public class StringUtils extends org.apache.commons.lang3.StringUtils { + + private static final char SEPARATOR = '_'; + + private static final String UNKNOWN = "unknown"; + + /** + * 驼峰命名法工具 + * + * @return toCamelCase(" hello_world ") == "helloWorld" + * toCapitalizeCamelCase("hello_world") == "HelloWorld" + * toUnderScoreCase("helloWorld") = "hello_world" + */ + public static String toCamelCase(String s) { + if (s == null) { + return null; + } + + s = s.toLowerCase(); + + StringBuilder sb = new StringBuilder(s.length()); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + if (c == SEPARATOR) { + upperCase = true; + } else if (upperCase) { + sb.append(Character.toUpperCase(c)); + upperCase = false; + } else { + sb.append(c); + } + } + + return sb.toString(); + } + + /** + * 驼峰命名法工具 + * + * @return toCamelCase(" hello_world ") == "helloWorld" + * toCapitalizeCamelCase("hello_world") == "HelloWorld" + * toUnderScoreCase("helloWorld") = "hello_world" + */ + public static String toCapitalizeCamelCase(String s) { + if (s == null) { + return null; + } + s = toCamelCase(s); + return s.substring(0, 1).toUpperCase() + s.substring(1); + } + + /** + * 驼峰命名法工具 + * + * @return toCamelCase(" hello_world ") == "helloWorld" + * toCapitalizeCamelCase("hello_world") == "HelloWorld" + * toUnderScoreCase("helloWorld") = "hello_world" + */ + static String toUnderScoreCase(String s) { + if (s == null) { + return null; + } + + StringBuilder sb = new StringBuilder(); + boolean upperCase = false; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + + boolean nextUpperCase = true; + + if (i < (s.length() - 1)) { + nextUpperCase = Character.isUpperCase(s.charAt(i + 1)); + } + + if ((i > 0) && Character.isUpperCase(c)) { + if (!upperCase || !nextUpperCase) { + sb.append(SEPARATOR); + } + upperCase = true; + } else { + upperCase = false; + } + + sb.append(Character.toLowerCase(c)); + } + + return sb.toString(); + } + + /** + * 获取ip地址 + */ + public static String getIp(HttpServletRequest request) { + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + String comma = ","; + String localhost = "127.0.0.1"; + if (ip.contains(comma)) { + ip = ip.split(",")[0]; + } + if (localhost.equals(ip)) { + // 获取本机真正的ip地址 + try { + ip = InetAddress.getLocalHost().getHostAddress(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + } + return ip; + } + + /** + * 根据ip获取详细地址 + */ + public static String getCityInfo(String ip) { + String api = String.format(YshopConstant.Url.IP_URL,ip); + JSONObject object = JSONUtil.parseObj(HttpUtil.get(api)); + return object.get("addr", String.class); + } + + public static String getBrowser(HttpServletRequest request){ + UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent")); + Browser browser = userAgent.getBrowser(); + return browser.getName(); + } + + /** + * 获得当天是周几 + */ + public static String getWeekDay(){ + String[] weekDays = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + + int w = cal.get(Calendar.DAY_OF_WEEK) - 1; + if (w < 0){ + w = 0; + } + return weekDays[w]; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/ThrowableUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/ThrowableUtil.java new file mode 100644 index 00000000..7bc8448a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/ThrowableUtil.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import co.yixiang.exception.BadRequestException; + +import javax.validation.ConstraintViolationException; +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * 异常工具 2019-01-06 + * @author Zheng Jie + */ +public class ThrowableUtil { + + /** + * 获取堆栈信息 + */ + public static String getStackTrace(Throwable throwable){ + StringWriter sw = new StringWriter(); + try (PrintWriter pw = new PrintWriter(sw)) { + throwable.printStackTrace(pw); + return sw.toString(); + } + } + + public static void throwForeignKeyException(Throwable e, String msg){ + Throwable t = e.getCause(); + while ((t != null) && !(t instanceof ConstraintViolationException)) { + t = t.getCause(); + } + if (t != null) { + throw new BadRequestException(msg); + } + assert false; + throw new BadRequestException("删除失败:" + t.getMessage()); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/TranslatorUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/TranslatorUtil.java new file mode 100644 index 00000000..96040fad --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/TranslatorUtil.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import cn.hutool.json.JSONArray; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; + +/** + * @author Zheng Jie + * 翻译工具类 + */ +public class TranslatorUtil { + + public static String translate(String word){ + try { + String url = "https://translate.googleapis.com/translate_a/single?" + + "client=gtx&" + + "sl=en" + + "&tl=zh-CN" + + "&dt=t&q=" + URLEncoder.encode(word, "UTF-8"); + + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + con.setRequestProperty("User-Agent", "Mozilla/5.0"); + + BufferedReader in = new BufferedReader( + new InputStreamReader(con.getInputStream())); + String inputLine; + StringBuilder response = new StringBuilder(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + return parseResult(response.toString()); + }catch (Exception e){ + return word; + } + } + + private static String parseResult(String inputJson){ + JSONArray jsonArray2 = (JSONArray) new JSONArray(inputJson).get(0); + StringBuilder result = new StringBuilder(); + for (Object o : jsonArray2) { + result.append(((JSONArray) o).get(0).toString()); + } + return result.toString(); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/TreeUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/TreeUtil.java new file mode 100644 index 00000000..9b5b4e01 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/TreeUtil.java @@ -0,0 +1,93 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + + +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * @ClassName TreeUtil + * @Author hupeng <610796224@qq.com> + * @Date 2019/10/22 + **/ +public class TreeUtil { + /** + * 获得指定节点下所有归档 + * @param list + * @param parentId + * @return + */ + public static List list2TreeConverter(List list, int parentId) { + List returnList = new ArrayList<>(); + + for (CateDTO res : list) { + //判断对象是否为根节点 + + if (res.getPid() == parentId) { + //该节点为根节点,开始递归 + + recursionFn(list, res); //通过递归为节点设置childList + + returnList.add(res); + } + } + + return returnList; + } + + /** + * 递归列表 + * 通过递归,给指定t节点设置childList + * @param list + * @param t + */ + public static void recursionFn(List list, CateDTO t) { + //只能获取当前t节点的子节点集,并不是所有子节点集 + List childsList = getChildList(list, t); + //设置他的子集对象集 + t.setChildren(childsList); + + //迭代子集对象集 + for (CateDTO nextChild : childsList) { //遍历完,则退出递归 + + //判断子集对象是否还有子节点 + if (!CollectionUtils.isEmpty(childsList)) { + //有下一个子节点,继续递归 + recursionFn(list, nextChild); + } + } + } + + /** + * 获得指定节点下的所有子节点 + * @param list + * @param t + * @return + */ + public static List getChildList(List list, CateDTO t) { + List childsList = new ArrayList(); + //遍历集合元素,如果元素的Parentid==指定元素的id,则说明是该元素的子节点 + for (CateDTO t1 : list) { + if (t1.getPid().equals(t.getId())) { + childsList.add(t1); + } + } + + return childsList; + } + + /** + * 判断是否还有下一个子节点 + * @param list + * @param t + */ + public static boolean hasChild(List list, CateDTO t) { + return getChildList(list, t).size() > 0 ? true : false; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/ValidationUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/ValidationUtil.java new file mode 100644 index 00000000..4cae9e7a --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/ValidationUtil.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +import cn.hutool.core.util.ObjectUtil; +import co.yixiang.exception.BadRequestException; +import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator; + +/** + * 验证工具 + * @author Zheng Jie + * @date 2018-11-23 + */ +public class ValidationUtil{ + + /** + * 验证空 + */ + public static void isNull(Object obj, String entity, String parameter , Object value){ + if(ObjectUtil.isNull(obj)){ + String msg = entity + " 不存在: "+ parameter +" is "+ value; + throw new BadRequestException(msg); + } + } + + /** + * 验证是否为邮箱 + */ + public static boolean isEmail(String email) { + return new EmailValidator().isValid(email, null); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/YshopConstant.java b/zsw-bxg/src/main/java/co/yixiang/utils/YshopConstant.java new file mode 100644 index 00000000..3de0c1e6 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/YshopConstant.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang.utils; + +/** + * 常用静态常量 + * @author Zheng Jie + * @date 2018-12-26 + */ +public class YshopConstant { + + public static final String RESET_PASS = "重置密码"; + + public static final String RESET_MAIL = "重置邮箱"; + + /** + * 常用接口 + */ + public static class Url{ + //免费图床 + public static final String SM_MS_URL = "https://sm.ms/api"; + + // IP归属地查询 + public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true"; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/html/EscapeUtil.java b/zsw-bxg/src/main/java/co/yixiang/utils/html/EscapeUtil.java new file mode 100644 index 00000000..0d4986f5 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/html/EscapeUtil.java @@ -0,0 +1,154 @@ +package co.yixiang.utils.html; + +import cn.hutool.core.util.StrUtil; + + +/** + * 转义和反转义工具类 + * @author hupeng + */ +public class EscapeUtil +{ + public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)"; + + private static final char[][] TEXT = new char[64][]; + + static + { + for (int i = 0; i < 64; i++) + { + TEXT[i] = new char[] { (char) i }; + } + + // special HTML characters + TEXT['\''] = "'".toCharArray(); // 单引号 + TEXT['"'] = """.toCharArray(); // 单引号 + TEXT['&'] = "&".toCharArray(); // &符 + TEXT['<'] = "<".toCharArray(); // 小于号 + TEXT['>'] = ">".toCharArray(); // 大于号 + } + + /** + * 转义文本中的HTML字符为安全的字符 + * + * @param text 被转义的文本 + * @return 转义后的文本 + */ + public static String escape(String text) + { + return encode(text); + } + + /** + * 还原被转义的HTML特殊字符 + * + * @param content 包含转义符的HTML内容 + * @return 转换后的字符串 + */ + public static String unescape(String content) + { + return decode(content); + } + + /** + * 清除所有HTML标签,但是不删除标签内的内容 + * + * @param content 文本 + * @return 清除标签后的文本 + */ + public static String clean(String content) + { + return new HTMLFilter().filter(content); + } + + /** + * Escape编码 + * + * @param text 被编码的文本 + * @return 编码后的字符 + */ + private static String encode(String text) + { + int len; + if ((text == null) || ((len = text.length()) == 0)) + { + return StrUtil.EMPTY; + } + StringBuilder buffer = new StringBuilder(len + (len >> 2)); + char c; + for (int i = 0; i < len; i++) + { + c = text.charAt(i); + if (c < 64) + { + buffer.append(TEXT[c]); + } + else + { + buffer.append(c); + } + } + return buffer.toString(); + } + + /** + * Escape解码 + * + * @param content 被转义的内容 + * @return 解码后的字符串 + */ + public static String decode(String content) + { + if (StrUtil.isEmpty(content)) + { + return content; + } + + StringBuilder tmp = new StringBuilder(content.length()); + int lastPos = 0, pos = 0; + char ch; + while (lastPos < content.length()) + { + pos = content.indexOf("%", lastPos); + if (pos == lastPos) + { + if (content.charAt(pos + 1) == 'u') + { + ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16); + tmp.append(ch); + lastPos = pos + 6; + } + else + { + ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16); + tmp.append(ch); + lastPos = pos + 3; + } + } + else + { + if (pos == -1) + { + tmp.append(content.substring(lastPos)); + lastPos = content.length(); + } + else + { + tmp.append(content.substring(lastPos, pos)); + lastPos = pos; + } + } + } + return tmp.toString(); + } + + public static void main(String[] args) + { + String html = ""; + // String html = "ipt>alert(\"XSS\")ipt>"; + // String html = "<123"; + System.out.println(EscapeUtil.clean(html)); + System.out.println(EscapeUtil.escape(html)); + System.out.println(EscapeUtil.unescape(html)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/html/HTMLFilter.java b/zsw-bxg/src/main/java/co/yixiang/utils/html/HTMLFilter.java new file mode 100644 index 00000000..1f3be192 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/html/HTMLFilter.java @@ -0,0 +1,570 @@ +package co.yixiang.utils.html; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * HTML过滤器,用于去除XSS漏洞隐患。 + * + * @author hupeng + */ +public final class HTMLFilter +{ + /** + * regex flag union representing /si modifiers in php + **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + // private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("\""); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); + + /** + * set of allowed html elements, along with allowed attributes for each element + **/ + private final Map> vAllowed; + /** + * counts of open tags for each (allowable) html element + **/ + private final Map vTagCounts = new HashMap<>(); + + /** + * html elements which must always be self-closing (e.g. "") + **/ + private final String[] vSelfClosingTags; + /** + * html elements which must always have separate opening and closing tags (e.g. "") + **/ + private final String[] vNeedClosingTags; + /** + * set of disallowed html elements + **/ + private final String[] vDisallowed; + /** + * attributes which should be checked for valid protocols + **/ + private final String[] vProtocolAtts; + /** + * allowed protocols + **/ + private final String[] vAllowedProtocols; + /** + * tags which should be removed if they contain no content (e.g. "" or "") + **/ + private final String[] vRemoveBlanks; + /** + * entities allowed within html markup + **/ + private final String[] vAllowedEntities; + /** + * flag determining whether comments are allowed in input String. + */ + private final boolean stripComment; + private final boolean encodeQuotes; + /** + * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "" + * becomes " text "). If set to false, unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** + * Default constructor. + */ + public HTMLFilter() + { + vAllowed = new HashMap<>(); + + final ArrayList a_atts = new ArrayList<>(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList<>(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList<>(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[] { "img" }; + vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; + vDisallowed = new String[] {}; + vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. + vProtocolAtts = new String[] { "src", "href" }; + vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; + vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = true; + } + + /** + * Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + @SuppressWarnings("unchecked") + public HTMLFilter(final Map conf) + { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() + { + vTagCounts.clear(); + } + + // --------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) + { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) + { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + // --------------------------------------------------------------- + + /** + * given a user submitted input String, filter out any invalid or restricted html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) + { + reset(); + String s = input; + + s = escapeComments(s); + + s = balanceHTML(s); + + s = checkTags(s); + + s = processRemoveBlanks(s); + + s = validateEntities(s); + + return s; + } + + public boolean isAlwaysMakeTags() + { + return alwaysMakeTags; + } + + public boolean isStripComments() + { + return stripComment; + } + + private String escapeComments(final String s) + { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) + { + final String match = m.group(1); // (.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) + { + if (alwaysMakeTags) + { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + // 不追加结束标签 + // s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } + else + { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) + { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) + { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + final StringBuilder sBuilder = new StringBuilder(buf.toString()); + for (String key : vTagCounts.keySet()) + { + for (int ii = 0; ii < vTagCounts.get(key); ii++) + { + sBuilder.append(""); + } + } + s = sBuilder.toString(); + + return s; + } + + private String processRemoveBlanks(final String s) + { + String result = s; + for (String tag : vRemoveBlanks) + { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) + { + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) + { + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) + { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) + { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) + { + if (false == inArray(name, vSelfClosingTags)) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) + { + final StringBuilder params = new StringBuilder(); + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList<>(); + final List paramValues = new ArrayList<>(); + while (m2.find()) + { + paramNames.add(m2.group(1)); // ([a-z0-9]+) + paramValues.add(m2.group(3)); // (.*?) + } + while (m3.find()) + { + paramNames.add(m3.group(1)); // ([a-z0-9]+) + paramValues.add(m3.group(3)); // ([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) + { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + + // debug( "paramName='" + paramName + "'" ); + // debug( "paramValue='" + paramValue + "'" ); + // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) + { + if (inArray(paramName, vProtocolAtts)) + { + paramValue = processParamProtocol(paramValue); + } + params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); + } + } + + if (inArray(name, vSelfClosingTags)) + { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) + { + ending = ""; + } + + if (ending == null || ending.length() < 1) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } + else + { + vTagCounts.put(name, 1); + } + } + else + { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } + else + { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) + { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) + { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) + { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) + { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1); + if (s.startsWith("#//")) + { + s = "#" + s.substring(3); + } + } + } + + return s; + } + + private String decodeEntities(String s) + { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) + { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // ([^&;]*) + final String two = m.group(2); // (?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s) + { + if (encodeQuotes) + { + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // (>|^) + final String two = m.group(2); // ([^<]+?) + final String three = m.group(3); // (<|$) + // 不替换双引号为",防止json格式无效 regexReplace(P_QUOTE, """, two) + m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); + } + m.appendTail(buf); + return buf.toString(); + } + else + { + return s; + } + } + + private String checkEntity(final String preamble, final String term) + { + + return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; + } + + private boolean isValidEntity(final String entity) + { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) + { + for (String item : array) + { + if (item != null && item.equals(s)) + { + return true; + } + } + return false; + } + + private boolean allowed(final String name) + { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) + { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/location/GetTencentLocationVO.java b/zsw-bxg/src/main/java/co/yixiang/utils/location/GetTencentLocationVO.java new file mode 100644 index 00000000..ce249105 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/location/GetTencentLocationVO.java @@ -0,0 +1,114 @@ +package co.yixiang.utils.location; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author :LionCity + * @date :Created in 2020-09-10 11:39 + * @description: + * @modified By: + * @version: + */ +@SuppressWarnings("ALL") +@Data +@ApiModel(value="腾讯地图返回对象") +public class GetTencentLocationVO implements Serializable { + + /** + * result : {"level":2,"similarity":0.8,"ad_info":{"adcode":"441302"},"reliability":1,"location":{"lng":114.38257,"lat":23.08464},"deviation":1000,"title":"惠城区","address_components":{"province":"广东省","city":"惠州市","street":"","district":"惠城区","street_number":""}} + * message : query ok + * status : 0 + */ + @ApiModelProperty(value = "地址解析结果") + private ResultBean result; + @ApiModelProperty(value = "状态说明") + private String message; + @ApiModelProperty(value = "状态码,0为正常") + private Integer status; + + @Data + @ApiModel(value="地址解析结果") + public static class ResultBean { + /** + * level : 2 + * similarity : 0.8 + * ad_info : {"adcode":"441302"} + * reliability : 1 + * location : {"lng":114.38257,"lat":23.08464} + * deviation : 1000 + * title : 惠城区 + * address_components : {"province":"广东省","city":"惠州市","street":"","district":"惠城区","street_number":""} + */ + + @ApiModelProperty(value = "解析到的坐标") + private LocationBean location; + @ApiModelProperty(value = "解析精度级别,分为11个级别,一般>=9即可采用(定位到点,精度较高) 也可根据实际业务需求自行调整") + private int level; + @ApiModelProperty(value = "即将下线,由reliability代替") + private double similarity; + + @ApiModelProperty(value = "行政区划信息") + private AdInfoBean ad_info; + @ApiModelProperty(value = "可信度参考") + private int reliability; + @ApiModelProperty(value = "即将下线,由level代替") + private int deviation; + @ApiModelProperty(value = "区信息") + private String title; + @ApiModelProperty(value = "行政区划信息") + private AddressComponentsBean address_components; + + + @Data + @ApiModel(value="行政区划信息") + public static class AdInfoBean { + /** + * adcode : 441302 + */ + @ApiModelProperty(value = "行政区划代码") + private String adcode; + + } + @Data + @ApiModel(value="解析到的坐标") + public static class LocationBean { + /** + * lng : 114.38257 + * lat : 23.08464 + */ + + @ApiModelProperty(value = "经度") + private double lng; + + @ApiModelProperty(value = "纬度") + private double lat; + + + } + @Data + @ApiModel(value="解析后的地址部件") + public static class AddressComponentsBean { + /** + * province : 广东省 + * city : 惠州市 + * street : + * district : 惠城区 + * street_number : + */ + @ApiModelProperty(value = "省") + private String province; + @ApiModelProperty(value = "市") + private String city; + @ApiModelProperty(value = "街道,可能为空字串") + private String street; + @ApiModelProperty(value = "区,可能为空字串") + private String district; + @ApiModelProperty(value = "门牌,可能为空字串") + private String street_number; + } + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/utils/location/LocationUtils.java b/zsw-bxg/src/main/java/co/yixiang/utils/location/LocationUtils.java new file mode 100644 index 00000000..7f582df7 --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/utils/location/LocationUtils.java @@ -0,0 +1,58 @@ +package co.yixiang.utils.location; + +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import co.yixiang.exception.BadRequestException; + +import co.yixiang.utils.ShopKeyUtils; +import com.alibaba.fastjson.JSONObject; + +/** + * 具体查看 https://lbs.qq.com/service/webService/webServiceGuide/webServiceGeocoder + * @author :LionCity + * @date :Created in 2020-09-10 11:46 + * @description: + * @modified By: + * @version: + */ +public class LocationUtils { + + private static double EARTH_RADIUS = 6378.137; + + private static double rad(double d) { + return d * Math.PI / 180.0; + } + + /** + * 腾讯地图地址解析 + */ + private static final String QQ_MAP_URL = "https://apis.map.qq.com/ws/geocoder/v1/"; + + + /** + * 通过经纬度获取距离(单位:千米) + * + * @param lat1 + * @param lng1 + * @param lat2 + * @param lng2 + * @return + */ + public static double getDistance(double lat1, double lng1, double lat2, + double lng2) { + double radLat1 = rad(lat1); + double radLat2 = rad(lat2); + double a = radLat1 - radLat2; + double b = rad(lng1) - rad(lng2); + double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + + Math.cos(radLat1) * Math.cos(radLat2) + * Math.pow(Math.sin(b / 2), 2))); + s = s * EARTH_RADIUS; + s = Math.round(s * 10000d) / 10000d; + //s = s*1000; + return NumberUtil.round(s, 2).doubleValue(); + //return s; + } + +} diff --git a/zsw-bxg/src/main/resources/Alibaba-PuHuiTi-Regular.otf b/zsw-bxg/src/main/resources/Alibaba-PuHuiTi-Regular.otf new file mode 100644 index 00000000..5960ba12 Binary files /dev/null and b/zsw-bxg/src/main/resources/Alibaba-PuHuiTi-Regular.otf differ diff --git a/zsw-bxg/src/main/resources/background.png b/zsw-bxg/src/main/resources/background.png new file mode 100644 index 00000000..f05a8f97 Binary files /dev/null and b/zsw-bxg/src/main/resources/background.png differ diff --git a/zsw-bxg/src/main/resources/city.json b/zsw-bxg/src/main/resources/city.json new file mode 100644 index 00000000..e5b394a9 --- /dev/null +++ b/zsw-bxg/src/main/resources/city.json @@ -0,0 +1 @@ +{"province_list":{"110000":"北京市","120000":"天津市","130000":"河北省","140000":"山西省","150000":"内蒙古自治区","210000":"辽宁省","220000":"吉林省","230000":"黑龙江省","310000":"上海市","320000":"江苏省","330000":"浙江省","340000":"安徽省","350000":"福建省","360000":"江西省","370000":"山东省","410000":"河南省","420000":"湖北省","430000":"湖南省","440000":"广东省","450000":"广西壮族自治区","460000":"海南省","500000":"重庆市","510000":"四川省","520000":"贵州省","530000":"云南省","540000":"西藏自治区","610000":"陕西省","620000":"甘肃省","630000":"青海省","640000":"宁夏回族自治区","650000":"新疆维吾尔自治区","710000":"台湾省","810000":"香港特别行政区","820000":"澳门特别行政区","900000":"海外"},"city_list":{"110100":"北京市","120100":"天津市","130100":"石家庄市","130200":"唐山市","130300":"秦皇岛市","130400":"邯郸市","130500":"邢台市","130600":"保定市","130700":"张家口市","130800":"承德市","130900":"沧州市","131000":"廊坊市","131100":"衡水市","140100":"太原市","140200":"大同市","140300":"阳泉市","140400":"长治市","140500":"晋城市","140600":"朔州市","140700":"晋中市","140800":"运城市","140900":"忻州市","141000":"临汾市","141100":"吕梁市","150100":"呼和浩特市","150200":"包头市","150300":"乌海市","150400":"赤峰市","150500":"通辽市","150600":"鄂尔多斯市","150700":"呼伦贝尔市","150800":"巴彦淖尔市","150900":"乌兰察布市","152200":"兴安盟","152500":"锡林郭勒盟","152900":"阿拉善盟","210100":"沈阳市","210200":"大连市","210300":"鞍山市","210400":"抚顺市","210500":"本溪市","210600":"丹东市","210700":"锦州市","210800":"营口市","210900":"阜新市","211000":"辽阳市","211100":"盘锦市","211200":"铁岭市","211300":"朝阳市","211400":"葫芦岛市","220100":"长春市","220200":"吉林市","220300":"四平市","220400":"辽源市","220500":"通化市","220600":"白山市","220700":"松原市","220800":"白城市","222400":"延边朝鲜族自治州","230100":"哈尔滨市","230200":"齐齐哈尔市","230300":"鸡西市","230400":"鹤岗市","230500":"双鸭山市","230600":"大庆市","230700":"伊春市","230800":"佳木斯市","230900":"七台河市","231000":"牡丹江市","231100":"黑河市","231200":"绥化市","232700":"大兴安岭地区","310100":"上海市","320100":"南京市","320200":"无锡市","320300":"徐州市","320400":"常州市","320500":"苏州市","320600":"南通市","320700":"连云港市","320800":"淮安市","320900":"盐城市","321000":"扬州市","321100":"镇江市","321200":"泰州市","321300":"宿迁市","330100":"杭州市","330200":"宁波市","330300":"温州市","330400":"嘉兴市","330500":"湖州市","330600":"绍兴市","330700":"金华市","330800":"衢州市","330900":"舟山市","331000":"台州市","331100":"丽水市","340100":"合肥市","340200":"芜湖市","340300":"蚌埠市","340400":"淮南市","340500":"马鞍山市","340600":"淮北市","340700":"铜陵市","340800":"安庆市","341000":"黄山市","341100":"滁州市","341200":"阜阳市","341300":"宿州市","341500":"六安市","341600":"亳州市","341700":"池州市","341800":"宣城市","350100":"福州市","350200":"厦门市","350300":"莆田市","350400":"三明市","350500":"泉州市","350600":"漳州市","350700":"南平市","350800":"龙岩市","350900":"宁德市","360100":"南昌市","360200":"景德镇市","360300":"萍乡市","360400":"九江市","360500":"新余市","360600":"鹰潭市","360700":"赣州市","360800":"吉安市","360900":"宜春市","361000":"抚州市","361100":"上饶市","370100":"济南市","370200":"青岛市","370300":"淄博市","370400":"枣庄市","370500":"东营市","370600":"烟台市","370700":"潍坊市","370800":"济宁市","370900":"泰安市","371000":"威海市","371100":"日照市","371300":"临沂市","371400":"德州市","371500":"聊城市","371600":"滨州市","371700":"菏泽市","410100":"郑州市","410200":"开封市","410300":"洛阳市","410400":"平顶山市","410500":"安阳市","410600":"鹤壁市","410700":"新乡市","410800":"焦作市","410900":"濮阳市","411000":"许昌市","411100":"漯河市","411200":"三门峡市","411300":"南阳市","411400":"商丘市","411500":"信阳市","411600":"周口市","411700":"驻马店市","419000":"省直辖县","420100":"武汉市","420200":"黄石市","420300":"十堰市","420500":"宜昌市","420600":"襄阳市","420700":"鄂州市","420800":"荆门市","420900":"孝感市","421000":"荆州市","421100":"黄冈市","421200":"咸宁市","421300":"随州市","422800":"恩施土家族苗族自治州","429000":"省直辖县","430100":"长沙市","430200":"株洲市","430300":"湘潭市","430400":"衡阳市","430500":"邵阳市","430600":"岳阳市","430700":"常德市","430800":"张家界市","430900":"益阳市","431000":"郴州市","431100":"永州市","431200":"怀化市","431300":"娄底市","433100":"湘西土家族苗族自治州","440100":"广州市","440200":"韶关市","440300":"深圳市","440400":"珠海市","440500":"汕头市","440600":"佛山市","440700":"江门市","440800":"湛江市","440900":"茂名市","441200":"肇庆市","441300":"惠州市","441400":"梅州市","441500":"汕尾市","441600":"河源市","441700":"阳江市","441800":"清远市","441900":"东莞市","442000":"中山市","445100":"潮州市","445200":"揭阳市","445300":"云浮市","450100":"南宁市","450200":"柳州市","450300":"桂林市","450400":"梧州市","450500":"北海市","450600":"防城港市","450700":"钦州市","450800":"贵港市","450900":"玉林市","451000":"百色市","451100":"贺州市","451200":"河池市","451300":"来宾市","451400":"崇左市","460100":"海口市","460200":"三亚市","460300":"三沙市","460400":"儋州市","469000":"省直辖县","500100":"重庆市","500200":"县","510100":"成都市","510300":"自贡市","510400":"攀枝花市","510500":"泸州市","510600":"德阳市","510700":"绵阳市","510800":"广元市","510900":"遂宁市","511000":"内江市","511100":"乐山市","511300":"南充市","511400":"眉山市","511500":"宜宾市","511600":"广安市","511700":"达州市","511800":"雅安市","511900":"巴中市","512000":"资阳市","513200":"阿坝藏族羌族自治州","513300":"甘孜藏族自治州","513400":"凉山彝族自治州","520100":"贵阳市","520200":"六盘水市","520300":"遵义市","520400":"安顺市","520500":"毕节市","520600":"铜仁市","522300":"黔西南布依族苗族自治州","522600":"黔东南苗族侗族自治州","522700":"黔南布依族苗族自治州","530100":"昆明市","530300":"曲靖市","530400":"玉溪市","530500":"保山市","530600":"昭通市","530700":"丽江市","530800":"普洱市","530900":"临沧市","532300":"楚雄彝族自治州","532500":"红河哈尼族彝族自治州","532600":"文山壮族苗族自治州","532800":"西双版纳傣族自治州","532900":"大理白族自治州","533100":"德宏傣族景颇族自治州","533300":"怒江傈僳族自治州","533400":"迪庆藏族自治州","540100":"拉萨市","540200":"日喀则市","540300":"昌都市","540400":"林芝市","540500":"山南市","540600":"那曲市","542500":"阿里地区","610100":"西安市","610200":"铜川市","610300":"宝鸡市","610400":"咸阳市","610500":"渭南市","610600":"延安市","610700":"汉中市","610800":"榆林市","610900":"安康市","611000":"商洛市","620100":"兰州市","620200":"嘉峪关市","620300":"金昌市","620400":"白银市","620500":"天水市","620600":"武威市","620700":"张掖市","620800":"平凉市","620900":"酒泉市","621000":"庆阳市","621100":"定西市","621200":"陇南市","622900":"临夏回族自治州","623000":"甘南藏族自治州","630100":"西宁市","630200":"海东市","632200":"海北藏族自治州","632300":"黄南藏族自治州","632500":"海南藏族自治州","632600":"果洛藏族自治州","632700":"玉树藏族自治州","632800":"海西蒙古族藏族自治州","640100":"银川市","640200":"石嘴山市","640300":"吴忠市","640400":"固原市","640500":"中卫市","650100":"乌鲁木齐市","650200":"克拉玛依市","650400":"吐鲁番市","650500":"哈密市","652300":"昌吉回族自治州","652700":"博尔塔拉蒙古自治州","652800":"巴音郭楞蒙古自治州","652900":"阿克苏地区","653000":"克孜勒苏柯尔克孜自治州","653100":"喀什地区","653200":"和田地区","654000":"伊犁哈萨克自治州","654200":"塔城地区","654300":"阿勒泰地区","659000":"自治区直辖县级行政区划","710100":"台北市","710200":"高雄市","710300":"台南市","710400":"台中市","710500":"金门县","710600":"南投县","710700":"基隆市","710800":"新竹市","710900":"嘉义市","711100":"新北市","711200":"宜兰县","711300":"新竹县","711400":"桃园县","711500":"苗栗县","711700":"彰化县","711900":"嘉义县","712100":"云林县","712400":"屏东县","712500":"台东县","712600":"花莲县","712700":"澎湖县","712800":"连江县","810100":"香港岛","810200":"九龙","810300":"新界","820100":"澳门半岛","820200":"离岛","900400":"阿富汗","900800":"阿尔巴尼亚","901000":"南极洲","901200":"阿尔及利亚","901600":"美属萨摩亚","902000":"安道尔","902400":"安哥拉","902800":"安提瓜和巴布达","903100":"阿塞拜疆","903200":"阿根廷","903600":"澳大利亚","904000":"奥地利","904400":"巴哈马","904800":"巴林","905000":"孟加拉","905100":"亚美尼亚","905200":"巴巴多斯","905600":"比利时","906000":"百慕大","906400":"不丹","906800":"玻利维亚","907000":"波黑","907200":"博茨瓦纳","907400":"布韦岛","907600":"巴西","908400":"伯利兹","908600":"英属印度洋领地","909000":"所罗门群岛","909200":"英属维尔京群岛","909600":"文莱","910000":"保加利亚","910400":"缅甸","910800":"布隆迪","911200":"白俄罗斯","911600":"柬埔寨","912000":"喀麦隆","912400":"加拿大","913200":"佛得角","913600":"开曼群岛","914000":"中非","914400":"斯里兰卡","914800":"乍得","915200":"智利","916200":"圣诞岛","916600":"科科斯群岛","917000":"哥伦比亚","917400":"科摩罗","917500":"马约特","917800":"刚果(布)","918000":"刚果(金)","918400":"库克群岛","918800":"哥斯达黎加","919100":"克罗地亚","919200":"古巴","919600":"塞浦路斯","920300":"捷克","920400":"贝宁","920800":"丹麦","921200":"多米尼克","921400":"多米尼加","921800":"厄瓜多尔","922200":"萨尔瓦多","922600":"赤道几内亚","923100":"埃塞俄比亚","923200":"厄立特里亚","923300":"爱沙尼亚","923400":"法罗群岛","923800":"马尔维纳斯群岛( 福克兰)","923900":"南乔治亚岛和南桑威奇群岛","924200":"斐济群岛","924600":"芬兰","924800":"奥兰群岛","925000":"法国","925400":"法属圭亚那","925800":"法属波利尼西亚","926000":"法属南部领地","926200":"吉布提","926600":"加蓬","926800":"格鲁吉亚","927000":"冈比亚","927500":"巴勒斯坦","927600":"德国","928800":"加纳","929200":"直布罗陀","929600":"基里巴斯","930000":"希腊","930400":"格陵兰","930800":"格林纳达","931200":"瓜德罗普","931600":"关岛","932000":"危地马拉","932400":"几内亚","932800":"圭亚那","933200":"海地","933400":"赫德岛和麦克唐纳群岛","933600":"梵蒂冈","934000":"洪都拉斯","934800":"匈牙利","935200":"冰岛","935600":"印度","936000":"印尼","936400":"伊朗","936800":"伊拉克","937200":"爱尔兰","937600":"以色列","938000":"意大利","938400":"科特迪瓦","938800":"牙买加","939200":"日本","939800":"哈萨克斯坦","940000":"约旦","940400":"肯尼亚","940800":"朝鲜 北朝鲜","941000":"韩国","941400":"科威特","941700":"吉尔吉斯斯坦","941800":"老挝","942200":"黎巴嫩","942600":"莱索托","942800":"拉脱维亚","943000":"利比里亚","943400":"利比亚","943800":"列支敦士登","944000":"立陶宛","944200":"卢森堡","945000":"马达加斯加","945400":"马拉维","945800":"马来西亚","946200":"马尔代夫","946600":"马里","947000":"马耳他","947400":"马提尼克","947800":"毛里塔尼亚","948000":"毛里求斯","948400":"墨西哥","949200":"摩纳哥","949600":"蒙古国","949800":"摩尔多瓦","949900":"黑山","950000":"蒙塞拉特岛","950400":"摩洛哥","950800":"莫桑比克","951200":"阿曼","951600":"纳米比亚","952000":"瑙鲁","952400":"尼泊尔","952800":"荷兰","953300":"阿鲁巴","953500":"荷兰加勒比区","954000":"新喀里多尼亚","954800":"瓦努阿图","955400":"新西兰","955800":"尼加拉瓜","956200":"尼日尔","956600":"尼日利亚","957000":"纽埃","957400":"诺福克岛","957800":"挪威","958000":"北马里亚纳群岛","958100":"美国本土外小岛屿","958300":"密克罗尼西亚联邦","958400":"马绍尔群岛","958500":"帕劳","958600":"巴基斯坦","959100":"巴拿马","959800":"巴布亚新几内亚","960000":"巴拉圭","960400":"秘鲁","960800":"菲律宾","961200":"皮特凯恩群岛","961600":"波兰","962000":"葡萄牙","962400":"几内亚比绍","962600":"东帝汶","963000":"波多黎各","963400":"卡塔尔","963800":"留尼汪","964200":"罗马尼亚","964300":"俄罗斯","964600":"卢旺达","965200":"圣巴泰勒米岛","965400":"圣赫勒拿","965900":"圣基茨和尼维斯","966000":"安圭拉","966200":"圣卢西亚","966300":"法属圣马丁","966600":"圣皮埃尔和密克隆","967000":"圣文森特和格林纳丁斯","967400":"圣马力诺","967800":"圣多美和普林西比","968200":"沙特阿拉伯","968600":"塞内加尔","968800":"塞尔维亚","969000":"塞舌尔","969400":"塞拉利昂","970200":"新加坡","970300":"斯洛伐克","970400":"越南","970500":"斯洛文尼亚","970600":"索马里","971000":"南非","971600":"津巴布韦","972400":"西班牙","972800":"南苏丹","972900":"苏丹","973200":"西撒哈拉","974000":"苏里南","974400":"斯瓦尔巴群岛和 扬马延岛","974800":"斯威士兰","975200":"瑞典","975600":"瑞士","976000":"叙利亚","976200":"塔吉克斯坦","976400":"泰国","976800":"多哥","977200":"托克劳","977600":"汤加","978000":"特立尼达和多巴哥","978400":"阿联酋","978800":"突尼斯","979200":"土耳其","979500":"土库曼斯坦","979600":"特克斯和凯科斯群岛","979800":"图瓦卢","980000":"乌干达","980400":"乌克兰","980700":"马其顿","981800":"埃及","982600":"英国","983100":"根西岛","983200":"泽西岛","983300":"马恩岛","983400":"坦桑尼亚","984000":"美国","985000":"美属维尔京群岛","985400":"布基纳法索","985800":"乌拉圭","986000":"乌兹别克斯坦","986200":"委内瑞拉","987600":"瓦利斯和富图纳","988200":"萨摩亚","988700":"也门","989400":"赞比亚"},"county_list":{"110101":"东城区","110102":"西城区","110105":"朝阳区","110106":"丰台区","110107":"石景山区","110108":"海淀区","110109":"门头沟区","110111":"房山区","110112":"通州区","110113":"顺义区","110114":"昌平区","110115":"大兴区","110116":"怀柔区","110117":"平谷区","110118":"密云区","110119":"延庆区","120101":"和平区","120102":"河东区","120103":"河西区","120104":"南开区","120105":"河北区","120106":"红桥区","120110":"东丽区","120111":"西青区","120112":"津南区","120113":"北辰区","120114":"武清区","120115":"宝坻区","120116":"滨海新区","120117":"宁河区","120118":"静海区","120119":"蓟州区","130102":"长安区","130104":"桥西区","130105":"新华区","130107":"井陉矿区","130108":"裕华区","130109":"藁城区","130110":"鹿泉区","130111":"栾城区","130121":"井陉县","130123":"正定县","130125":"行唐县","130126":"灵寿县","130127":"高邑县","130128":"深泽县","130129":"赞皇县","130130":"无极县","130131":"平山县","130132":"元氏县","130133":"赵县","130181":"辛集市","130183":"晋州市","130184":"新乐市","130202":"路南区","130203":"路北区","130204":"古冶区","130205":"开平区","130207":"丰南区","130208":"丰润区","130209":"曹妃甸区","130224":"滦南县","130225":"乐亭县","130227":"迁西县","130229":"玉田县","130281":"遵化市","130283":"迁安市","130284":"滦州市","130302":"海港区","130303":"山海关区","130304":"北戴河区","130306":"抚宁区","130321":"青龙满族自治县","130322":"昌黎县","130324":"卢龙县","130390":"经济技术开发区","130402":"邯山区","130403":"丛台区","130404":"复兴区","130406":"峰峰矿区","130407":"肥乡区","130408":"永年区","130423":"临漳县","130424":"成安县","130425":"大名县","130426":"涉县","130427":"磁县","130430":"邱县","130431":"鸡泽县","130432":"广平县","130433":"馆陶县","130434":"魏县","130435":"曲周县","130481":"武安市","130502":"桥东区","130503":"桥西区","130521":"邢台县","130522":"临城县","130523":"内丘县","130524":"柏乡县","130525":"隆尧县","130526":"任县","130527":"南和县","130528":"宁晋县","130529":"巨鹿县","130530":"新河县","130531":"广宗县","130532":"平乡县","130533":"威县","130534":"清河县","130535":"临西县","130581":"南宫市","130582":"沙河市","130602":"竞秀区","130606":"莲池区","130607":"满城区","130608":"清苑区","130609":"徐水区","130623":"涞水县","130624":"阜平县","130626":"定兴县","130627":"唐县","130628":"高阳县","130629":"容城县","130630":"涞源县","130631":"望都县","130632":"安新县","130633":"易县","130634":"曲阳县","130635":"蠡县","130636":"顺平县","130637":"博野县","130638":"雄县","130681":"涿州市","130682":"定州市","130683":"安国市","130684":"高碑店市","130702":"桥东区","130703":"桥西区","130705":"宣化区","130706":"下花园区","130708":"万全区","130709":"崇礼区","130722":"张北县","130723":"康保县","130724":"沽源县","130725":"尚义县","130726":"蔚县","130727":"阳原县","130728":"怀安县","130730":"怀来县","130731":"涿鹿县","130732":"赤城县","130802":"双桥区","130803":"双滦区","130804":"鹰手营子矿区","130821":"承德县","130822":"兴隆县","130824":"滦平县","130825":"隆化县","130826":"丰宁满族自治县","130827":"宽城满族自治县","130828":"围场满族蒙古族自治县","130881":"平泉市","130902":"新华区","130903":"运河区","130921":"沧县","130922":"青县","130923":"东光县","130924":"海兴县","130925":"盐山县","130926":"肃宁县","130927":"南皮县","130928":"吴桥县","130929":"献县","130930":"孟村回族自治县","130981":"泊头市","130982":"任丘市","130983":"黄骅市","130984":"河间市","131002":"安次区","131003":"广阳区","131022":"固安县","131023":"永清县","131024":"香河县","131025":"大城县","131026":"文安县","131028":"大厂回族自治县","131081":"霸州市","131082":"三河市","131090":"开发区","131102":"桃城区","131103":"冀州区","131121":"枣强县","131122":"武邑县","131123":"武强县","131124":"饶阳县","131125":"安平县","131126":"故城县","131127":"景县","131128":"阜城县","131182":"深州市","140105":"小店区","140106":"迎泽区","140107":"杏花岭区","140108":"尖草坪区","140109":"万柏林区","140110":"晋源区","140121":"清徐县","140122":"阳曲县","140123":"娄烦县","140181":"古交市","140212":"新荣区","140213":"平城区","140214":"云冈区","140215":"云州区","140221":"阳高县","140222":"天镇县","140223":"广灵县","140224":"灵丘县","140225":"浑源县","140226":"左云县","140302":"城区","140303":"矿区","140311":"郊区","140321":"平定县","140322":"盂县","140403":"潞州区","140404":"上党区","140405":"屯留区","140406":"潞城区","140423":"襄垣县","140425":"平顺县","140426":"黎城县","140427":"壶关县","140428":"长子县","140429":"武乡县","140430":"沁县","140431":"沁源县","140502":"城区","140521":"沁水县","140522":"阳城县","140524":"陵川县","140525":"泽州县","140581":"高平市","140602":"朔城区","140603":"平鲁区","140621":"山阴县","140622":"应县","140623":"右玉县","140681":"怀仁市","140702":"榆次区","140721":"榆社县","140722":"左权县","140723":"和顺县","140724":"昔阳县","140725":"寿阳县","140726":"太谷县","140727":"祁县","140728":"平遥县","140729":"灵石县","140781":"介休市","140802":"盐湖区","140821":"临猗县","140822":"万荣县","140823":"闻喜县","140824":"稷山县","140825":"新绛县","140826":"绛县","140827":"垣曲县","140828":"夏县","140829":"平陆县","140830":"芮城县","140881":"永济市","140882":"河津市","140902":"忻府区","140921":"定襄县","140922":"五台县","140923":"代县","140924":"繁峙县","140925":"宁武县","140926":"静乐县","140927":"神池县","140928":"五寨县","140929":"岢岚县","140930":"河曲县","140931":"保德县","140932":"偏关县","140981":"原平市","141002":"尧都区","141021":"曲沃县","141022":"翼城县","141023":"襄汾县","141024":"洪洞县","141025":"古县","141026":"安泽县","141027":"浮山县","141028":"吉县","141029":"乡宁县","141030":"大宁县","141031":"隰县","141032":"永和县","141033":"蒲县","141034":"汾西县","141081":"侯马市","141082":"霍州市","141102":"离石区","141121":"文水县","141122":"交城县","141123":"兴县","141124":"临县","141125":"柳林县","141126":"石楼县","141127":"岚县","141128":"方山县","141129":"中阳县","141130":"交口县","141181":"孝义市","141182":"汾阳市","150102":"新城区","150103":"回民区","150104":"玉泉区","150105":"赛罕区","150121":"土默特左旗","150122":"托克托县","150123":"和林格尔县","150124":"清水河县","150125":"武川县","150202":"东河区","150203":"昆都仑区","150204":"青山区","150205":"石拐区","150206":"白云鄂博矿区","150207":"九原区","150221":"土默特右旗","150222":"固阳县","150223":"达尔罕茂明安联合旗","150302":"海勃湾区","150303":"海南区","150304":"乌达区","150402":"红山区","150403":"元宝山区","150404":"松山区","150421":"阿鲁科尔沁旗","150422":"巴林左旗","150423":"巴林右旗","150424":"林西县","150425":"克什克腾旗","150426":"翁牛特旗","150428":"喀喇沁旗","150429":"宁城县","150430":"敖汉旗","150502":"科尔沁区","150521":"科尔沁左翼中旗","150522":"科尔沁左翼后旗","150523":"开鲁县","150524":"库伦旗","150525":"奈曼旗","150526":"扎鲁特旗","150581":"霍林郭勒市","150602":"东胜区","150603":"康巴什区","150621":"达拉特旗","150622":"准格尔旗","150623":"鄂托克前旗","150624":"鄂托克旗","150625":"杭锦旗","150626":"乌审旗","150627":"伊金霍洛旗","150702":"海拉尔区","150703":"扎赉诺尔区","150721":"阿荣旗","150722":"莫力达瓦达斡尔族自治旗","150723":"鄂伦春自治旗","150724":"鄂温克族自治旗","150725":"陈巴尔虎旗","150726":"新巴尔虎左旗","150727":"新巴尔虎右旗","150781":"满洲里市","150782":"牙克石市","150783":"扎兰屯市","150784":"额尔古纳市","150785":"根河市","150802":"临河区","150821":"五原县","150822":"磴口县","150823":"乌拉特前旗","150824":"乌拉特中旗","150825":"乌拉特后旗","150826":"杭锦后旗","150902":"集宁区","150921":"卓资县","150922":"化德县","150923":"商都县","150924":"兴和县","150925":"凉城县","150926":"察哈尔右翼前旗","150927":"察哈尔右翼中旗","150928":"察哈尔右翼后旗","150929":"四子王旗","150981":"丰镇市","152201":"乌兰浩特市","152202":"阿尔山市","152221":"科尔沁右翼前旗","152222":"科尔沁右翼中旗","152223":"扎赉特旗","152224":"突泉县","152501":"二连浩特市","152502":"锡林浩特市","152522":"阿巴嘎旗","152523":"苏尼特左旗","152524":"苏尼特右旗","152525":"东乌珠穆沁旗","152526":"西乌珠穆沁旗","152527":"太仆寺旗","152528":"镶黄旗","152529":"正镶白旗","152530":"正蓝旗","152531":"多伦县","152921":"阿拉善左旗","152922":"阿拉善右旗","152923":"额济纳旗","210102":"和平区","210103":"沈河区","210104":"大东区","210105":"皇姑区","210106":"铁西区","210111":"苏家屯区","210112":"浑南区","210113":"沈北新区","210114":"于洪区","210115":"辽中区","210123":"康平县","210124":"法库县","210181":"新民市","210190":"经济技术开发区","210202":"中山区","210203":"西岗区","210204":"沙河口区","210211":"甘井子区","210212":"旅顺口区","210213":"金州区","210214":"普兰店区","210224":"长海县","210281":"瓦房店市","210283":"庄河市","210302":"铁东区","210303":"铁西区","210304":"立山区","210311":"千山区","210321":"台安县","210323":"岫岩满族自治县","210381":"海城市","210390":"高新区","210402":"新抚区","210403":"东洲区","210404":"望花区","210411":"顺城区","210421":"抚顺县","210422":"新宾满族自治县","210423":"清原满族自治县","210502":"平山区","210503":"溪湖区","210504":"明山区","210505":"南芬区","210521":"本溪满族自治县","210522":"桓仁满族自治县","210602":"元宝区","210603":"振兴区","210604":"振安区","210624":"宽甸满族自治县","210681":"东港市","210682":"凤城市","210702":"古塔区","210703":"凌河区","210711":"太和区","210726":"黑山县","210727":"义县","210781":"凌海市","210782":"北镇市","210793":"经济技术开发区","210802":"站前区","210803":"西市区","210804":"鲅鱼圈区","210811":"老边区","210881":"盖州市","210882":"大石桥市","210902":"海州区","210903":"新邱区","210904":"太平区","210905":"清河门区","210911":"细河区","210921":"阜新蒙古族自治县","210922":"彰武县","211002":"白塔区","211003":"文圣区","211004":"宏伟区","211005":"弓长岭区","211011":"太子河区","211021":"辽阳县","211081":"灯塔市","211102":"双台子区","211103":"兴隆台区","211104":"大洼区","211122":"盘山县","211202":"银州区","211204":"清河区","211221":"铁岭县","211223":"西丰县","211224":"昌图县","211281":"调兵山市","211282":"开原市","211302":"双塔区","211303":"龙城区","211321":"朝阳县","211322":"建平县","211324":"喀喇沁左翼蒙古族自治县","211381":"北票市","211382":"凌源市","211402":"连山区","211403":"龙港区","211404":"南票区","211421":"绥中县","211422":"建昌县","211481":"兴城市","220102":"南关区","220103":"宽城区","220104":"朝阳区","220105":"二道区","220106":"绿园区","220112":"双阳区","220113":"九台区","220122":"农安县","220182":"榆树市","220183":"德惠市","220192":"经济技术开发区","220202":"昌邑区","220203":"龙潭区","220204":"船营区","220211":"丰满区","220221":"永吉县","220281":"蛟河市","220282":"桦甸市","220283":"舒兰市","220284":"磐石市","220302":"铁西区","220303":"铁东区","220322":"梨树县","220323":"伊通满族自治县","220381":"公主岭市","220382":"双辽市","220402":"龙山区","220403":"西安区","220421":"东丰县","220422":"东辽县","220502":"东昌区","220503":"二道江区","220521":"通化县","220523":"辉南县","220524":"柳河县","220581":"梅河口市","220582":"集安市","220602":"浑江区","220605":"江源区","220621":"抚松县","220622":"靖宇县","220623":"长白朝鲜族自治县","220681":"临江市","220702":"宁江区","220721":"前郭尔罗斯蒙古族自治县","220722":"长岭县","220723":"乾安县","220781":"扶余市","220802":"洮北区","220821":"镇赉县","220822":"通榆县","220881":"洮南市","220882":"大安市","222401":"延吉市","222402":"图们市","222403":"敦化市","222404":"珲春市","222405":"龙井市","222406":"和龙市","222424":"汪清县","222426":"安图县","230102":"道里区","230103":"南岗区","230104":"道外区","230108":"平房区","230109":"松北区","230110":"香坊区","230111":"呼兰区","230112":"阿城区","230113":"双城区","230123":"依兰县","230124":"方正县","230125":"宾县","230126":"巴彦县","230127":"木兰县","230128":"通河县","230129":"延寿县","230183":"尚志市","230184":"五常市","230202":"龙沙区","230203":"建华区","230204":"铁锋区","230205":"昂昂溪区","230206":"富拉尔基区","230207":"碾子山区","230208":"梅里斯达斡尔族区","230221":"龙江县","230223":"依安县","230224":"泰来县","230225":"甘南县","230227":"富裕县","230229":"克山县","230230":"克东县","230231":"拜泉县","230281":"讷河市","230302":"鸡冠区","230303":"恒山区","230304":"滴道区","230305":"梨树区","230306":"城子河区","230307":"麻山区","230321":"鸡东县","230381":"虎林市","230382":"密山市","230402":"向阳区","230403":"工农区","230404":"南山区","230405":"兴安区","230406":"东山区","230407":"兴山区","230421":"萝北县","230422":"绥滨县","230502":"尖山区","230503":"岭东区","230505":"四方台区","230506":"宝山区","230521":"集贤县","230522":"友谊县","230523":"宝清县","230524":"饶河县","230602":"萨尔图区","230603":"龙凤区","230604":"让胡路区","230605":"红岗区","230606":"大同区","230621":"肇州县","230622":"肇源县","230623":"林甸县","230624":"杜尔伯特蒙古族自治县","230702":"伊春区","230703":"南岔区","230704":"友好区","230705":"西林区","230706":"翠峦区","230707":"新青区","230708":"美溪区","230709":"金山屯区","230710":"五营区","230711":"乌马河区","230712":"汤旺河区","230713":"带岭区","230714":"乌伊岭区","230715":"红星区","230716":"上甘岭区","230722":"嘉荫县","230781":"铁力市","230803":"向阳区","230804":"前进区","230805":"东风区","230811":"郊区","230822":"桦南县","230826":"桦川县","230828":"汤原县","230881":"同江市","230882":"富锦市","230883":"抚远市","230902":"新兴区","230903":"桃山区","230904":"茄子河区","230921":"勃利县","231002":"东安区","231003":"阳明区","231004":"爱民区","231005":"西安区","231025":"林口县","231081":"绥芬河市","231083":"海林市","231084":"宁安市","231085":"穆棱市","231086":"东宁市","231102":"爱辉区","231121":"嫩江县","231123":"逊克县","231124":"孙吴县","231181":"北安市","231182":"五大连池市","231202":"北林区","231221":"望奎县","231222":"兰西县","231223":"青冈县","231224":"庆安县","231225":"明水县","231226":"绥棱县","231281":"安达市","231282":"肇东市","231283":"海伦市","232701":"漠河市","232721":"呼玛县","232722":"塔河县","232790":"松岭区","232791":"呼中区","232792":"加格达奇区","232793":"新林区","310101":"黄浦区","310104":"徐汇区","310105":"长宁区","310106":"静安区","310107":"普陀区","310109":"虹口区","310110":"杨浦区","310112":"闵行区","310113":"宝山区","310114":"嘉定区","310115":"浦东新区","310116":"金山区","310117":"松江区","310118":"青浦区","310120":"奉贤区","310151":"崇明区","320102":"玄武区","320104":"秦淮区","320105":"建邺区","320106":"鼓楼区","320111":"浦口区","320113":"栖霞区","320114":"雨花台区","320115":"江宁区","320116":"六合区","320117":"溧水区","320118":"高淳区","320205":"锡山区","320206":"惠山区","320211":"滨湖区","320213":"梁溪区","320214":"新吴区","320281":"江阴市","320282":"宜兴市","320302":"鼓楼区","320303":"云龙区","320305":"贾汪区","320311":"泉山区","320312":"铜山区","320321":"丰县","320322":"沛县","320324":"睢宁县","320381":"新沂市","320382":"邳州市","320391":"工业园区","320402":"天宁区","320404":"钟楼区","320411":"新北区","320412":"武进区","320413":"金坛区","320481":"溧阳市","320505":"虎丘区","320506":"吴中区","320507":"相城区","320508":"姑苏区","320509":"吴江区","320581":"常熟市","320582":"张家港市","320583":"昆山市","320585":"太仓市","320590":"工业园区","320591":"高新区","320602":"崇川区","320611":"港闸区","320612":"通州区","320623":"如东县","320681":"启东市","320682":"如皋市","320684":"海门市","320685":"海安市","320691":"高新区","320703":"连云区","320706":"海州区","320707":"赣榆区","320722":"东海县","320723":"灌云县","320724":"灌南县","320803":"淮安区","320804":"淮阴区","320812":"清江浦区","320813":"洪泽区","320826":"涟水县","320830":"盱眙县","320831":"金湖县","320890":"经济开发区","320902":"亭湖区","320903":"盐都区","320904":"大丰区","320921":"响水县","320922":"滨海县","320923":"阜宁县","320924":"射阳县","320925":"建湖县","320981":"东台市","321002":"广陵区","321003":"邗江区","321012":"江都区","321023":"宝应县","321081":"仪征市","321084":"高邮市","321090":"经济开发区","321102":"京口区","321111":"润州区","321112":"丹徒区","321181":"丹阳市","321182":"扬中市","321183":"句容市","321202":"海陵区","321203":"高港区","321204":"姜堰区","321281":"兴化市","321282":"靖江市","321283":"泰兴市","321302":"宿城区","321311":"宿豫区","321322":"沭阳县","321323":"泗阳县","321324":"泗洪县","330102":"上城区","330103":"下城区","330104":"江干区","330105":"拱墅区","330106":"西湖区","330108":"滨江区","330109":"萧山区","330110":"余杭区","330111":"富阳区","330112":"临安区","330122":"桐庐县","330127":"淳安县","330182":"建德市","330203":"海曙区","330205":"江北区","330206":"北仑区","330211":"镇海区","330212":"鄞州区","330213":"奉化区","330225":"象山县","330226":"宁海县","330281":"余姚市","330282":"慈溪市","330302":"鹿城区","330303":"龙湾区","330304":"瓯海区","330305":"洞头区","330324":"永嘉县","330326":"平阳县","330327":"苍南县","330328":"文成县","330329":"泰顺县","330381":"瑞安市","330382":"乐清市","330402":"南湖区","330411":"秀洲区","330421":"嘉善县","330424":"海盐县","330481":"海宁市","330482":"平湖市","330483":"桐乡市","330502":"吴兴区","330503":"南浔区","330521":"德清县","330522":"长兴县","330523":"安吉县","330602":"越城区","330603":"柯桥区","330604":"上虞区","330624":"新昌县","330681":"诸暨市","330683":"嵊州市","330702":"婺城区","330703":"金东区","330723":"武义县","330726":"浦江县","330727":"磐安县","330781":"兰溪市","330782":"义乌市","330783":"东阳市","330784":"永康市","330802":"柯城区","330803":"衢江区","330822":"常山县","330824":"开化县","330825":"龙游县","330881":"江山市","330902":"定海区","330903":"普陀区","330921":"岱山县","330922":"嵊泗县","331002":"椒江区","331003":"黄岩区","331004":"路桥区","331022":"三门县","331023":"天台县","331024":"仙居县","331081":"温岭市","331082":"临海市","331083":"玉环市","331102":"莲都区","331121":"青田县","331122":"缙云县","331123":"遂昌县","331124":"松阳县","331125":"云和县","331126":"庆元县","331127":"景宁畲族自治县","331181":"龙泉市","340102":"瑶海区","340103":"庐阳区","340104":"蜀山区","340111":"包河区","340121":"长丰县","340122":"肥东县","340123":"肥西县","340124":"庐江县","340181":"巢湖市","340190":"高新技术开发区","340191":"经济技术开发区","340202":"镜湖区","340203":"弋江区","340207":"鸠江区","340208":"三山区","340221":"芜湖县","340222":"繁昌县","340223":"南陵县","340225":"无为县","340302":"龙子湖区","340303":"蚌山区","340304":"禹会区","340311":"淮上区","340321":"怀远县","340322":"五河县","340323":"固镇县","340402":"大通区","340403":"田家庵区","340404":"谢家集区","340405":"八公山区","340406":"潘集区","340421":"凤台县","340422":"寿县","340503":"花山区","340504":"雨山区","340506":"博望区","340521":"当涂县","340522":"含山县","340523":"和县","340602":"杜集区","340603":"相山区","340604":"烈山区","340621":"濉溪县","340705":"铜官区","340706":"义安区","340711":"郊区","340722":"枞阳县","340802":"迎江区","340803":"大观区","340811":"宜秀区","340822":"怀宁县","340824":"潜山县","340825":"太湖县","340826":"宿松县","340827":"望江县","340828":"岳西县","340881":"桐城市","341002":"屯溪区","341003":"黄山区","341004":"徽州区","341021":"歙县","341022":"休宁县","341023":"黟县","341024":"祁门县","341102":"琅琊区","341103":"南谯区","341122":"来安县","341124":"全椒县","341125":"定远县","341126":"凤阳县","341181":"天长市","341182":"明光市","341202":"颍州区","341203":"颍东区","341204":"颍泉区","341221":"临泉县","341222":"太和县","341225":"阜南县","341226":"颍上县","341282":"界首市","341302":"埇桥区","341321":"砀山县","341322":"萧县","341323":"灵璧县","341324":"泗县","341390":"经济开发区","341502":"金安区","341503":"裕安区","341504":"叶集区","341522":"霍邱县","341523":"舒城县","341524":"金寨县","341525":"霍山县","341602":"谯城区","341621":"涡阳县","341622":"蒙城县","341623":"利辛县","341702":"贵池区","341721":"东至县","341722":"石台县","341723":"青阳县","341802":"宣州区","341821":"郎溪县","341822":"广德县","341823":"泾县","341824":"绩溪县","341825":"旌德县","341881":"宁国市","350102":"鼓楼区","350103":"台江区","350104":"仓山区","350105":"马尾区","350111":"晋安区","350112":"长乐区","350121":"闽侯县","350122":"连江县","350123":"罗源县","350124":"闽清县","350125":"永泰县","350128":"平潭县","350181":"福清市","350203":"思明区","350205":"海沧区","350206":"湖里区","350211":"集美区","350212":"同安区","350213":"翔安区","350302":"城厢区","350303":"涵江区","350304":"荔城区","350305":"秀屿区","350322":"仙游县","350402":"梅列区","350403":"三元区","350421":"明溪县","350423":"清流县","350424":"宁化县","350425":"大田县","350426":"尤溪县","350427":"沙县","350428":"将乐县","350429":"泰宁县","350430":"建宁县","350481":"永安市","350502":"鲤城区","350503":"丰泽区","350504":"洛江区","350505":"泉港区","350521":"惠安县","350524":"安溪县","350525":"永春县","350526":"德化县","350527":"金门县","350581":"石狮市","350582":"晋江市","350583":"南安市","350602":"芗城区","350603":"龙文区","350622":"云霄县","350623":"漳浦县","350624":"诏安县","350625":"长泰县","350626":"东山县","350627":"南靖县","350628":"平和县","350629":"华安县","350681":"龙海市","350702":"延平区","350703":"建阳区","350721":"顺昌县","350722":"浦城县","350723":"光泽县","350724":"松溪县","350725":"政和县","350781":"邵武市","350782":"武夷山市","350783":"建瓯市","350802":"新罗区","350803":"永定区","350821":"长汀县","350823":"上杭县","350824":"武平县","350825":"连城县","350881":"漳平市","350902":"蕉城区","350921":"霞浦县","350922":"古田县","350923":"屏南县","350924":"寿宁县","350925":"周宁县","350926":"柘荣县","350981":"福安市","350982":"福鼎市","360102":"东湖区","360103":"西湖区","360104":"青云谱区","360105":"湾里区","360111":"青山湖区","360112":"新建区","360121":"南昌县","360123":"安义县","360124":"进贤县","360190":"经济技术开发区","360192":"高新区","360202":"昌江区","360203":"珠山区","360222":"浮梁县","360281":"乐平市","360302":"安源区","360313":"湘东区","360321":"莲花县","360322":"上栗县","360323":"芦溪县","360402":"濂溪区","360403":"浔阳区","360404":"柴桑区","360423":"武宁县","360424":"修水县","360425":"永修县","360426":"德安县","360428":"都昌县","360429":"湖口县","360430":"彭泽县","360481":"瑞昌市","360482":"共青城市","360483":"庐山市","360490":"经济技术开发区","360502":"渝水区","360521":"分宜县","360602":"月湖区","360603":"余江区","360681":"贵溪市","360702":"章贡区","360703":"南康区","360704":"赣县区","360722":"信丰县","360723":"大余县","360724":"上犹县","360725":"崇义县","360726":"安远县","360727":"龙南县","360728":"定南县","360729":"全南县","360730":"宁都县","360731":"于都县","360732":"兴国县","360733":"会昌县","360734":"寻乌县","360735":"石城县","360781":"瑞金市","360802":"吉州区","360803":"青原区","360821":"吉安县","360822":"吉水县","360823":"峡江县","360824":"新干县","360825":"永丰县","360826":"泰和县","360827":"遂川县","360828":"万安县","360829":"安福县","360830":"永新县","360881":"井冈山市","360902":"袁州区","360921":"奉新县","360922":"万载县","360923":"上高县","360924":"宜丰县","360925":"靖安县","360926":"铜鼓县","360981":"丰城市","360982":"樟树市","360983":"高安市","361002":"临川区","361003":"东乡区","361021":"南城县","361022":"黎川县","361023":"南丰县","361024":"崇仁县","361025":"乐安县","361026":"宜黄县","361027":"金溪县","361028":"资溪县","361030":"广昌县","361102":"信州区","361103":"广丰区","361121":"上饶县","361123":"玉山县","361124":"铅山县","361125":"横峰县","361126":"弋阳县","361127":"余干县","361128":"鄱阳县","361129":"万年县","361130":"婺源县","361181":"德兴市","370102":"历下区","370103":"市中区","370104":"槐荫区","370105":"天桥区","370112":"历城区","370113":"长清区","370114":"章丘区","370115":"济阳区","370124":"平阴县","370126":"商河县","370190":"高新区","370191":"莱芜区","370202":"市南区","370203":"市北区","370211":"黄岛区","370212":"崂山区","370213":"李沧区","370214":"城阳区","370215":"即墨区","370281":"胶州市","370283":"平度市","370285":"莱西市","370290":"开发区","370302":"淄川区","370303":"张店区","370304":"博山区","370305":"临淄区","370306":"周村区","370321":"桓台县","370322":"高青县","370323":"沂源县","370402":"市中区","370403":"薛城区","370404":"峄城区","370405":"台儿庄区","370406":"山亭区","370481":"滕州市","370502":"东营区","370503":"河口区","370505":"垦利区","370522":"利津县","370523":"广饶县","370602":"芝罘区","370611":"福山区","370612":"牟平区","370613":"莱山区","370634":"长岛县","370681":"龙口市","370682":"莱阳市","370683":"莱州市","370684":"蓬莱市","370685":"招远市","370686":"栖霞市","370687":"海阳市","370690":"开发区","370702":"潍城区","370703":"寒亭区","370704":"坊子区","370705":"奎文区","370724":"临朐县","370725":"昌乐县","370781":"青州市","370782":"诸城市","370783":"寿光市","370784":"安丘市","370785":"高密市","370786":"昌邑市","370790":"开发区","370791":"高新区","370811":"任城区","370812":"兖州区","370826":"微山县","370827":"鱼台县","370828":"金乡县","370829":"嘉祥县","370830":"汶上县","370831":"泗水县","370832":"梁山县","370881":"曲阜市","370883":"邹城市","370890":"高新区","370902":"泰山区","370911":"岱岳区","370921":"宁阳县","370923":"东平县","370982":"新泰市","370983":"肥城市","371002":"环翠区","371003":"文登区","371082":"荣成市","371083":"乳山市","371091":"经济技术开发区","371102":"东港区","371103":"岚山区","371121":"五莲县","371122":"莒县","371302":"兰山区","371311":"罗庄区","371312":"河东区","371321":"沂南县","371322":"郯城县","371323":"沂水县","371324":"兰陵县","371325":"费县","371326":"平邑县","371327":"莒南县","371328":"蒙阴县","371329":"临沭县","371402":"德城区","371403":"陵城区","371422":"宁津县","371423":"庆云县","371424":"临邑县","371425":"齐河县","371426":"平原县","371427":"夏津县","371428":"武城县","371481":"乐陵市","371482":"禹城市","371502":"东昌府区","371521":"阳谷县","371522":"莘县","371523":"茌平县","371524":"东阿县","371525":"冠县","371526":"高唐县","371581":"临清市","371602":"滨城区","371603":"沾化区","371621":"惠民县","371622":"阳信县","371623":"无棣县","371625":"博兴县","371681":"邹平市","371702":"牡丹区","371703":"定陶区","371721":"曹县","371722":"单县","371723":"成武县","371724":"巨野县","371725":"郓城县","371726":"鄄城县","371728":"东明县","410102":"中原区","410103":"二七区","410104":"管城回族区","410105":"金水区","410106":"上街区","410108":"惠济区","410122":"中牟县","410181":"巩义市","410182":"荥阳市","410183":"新密市","410184":"新郑市","410185":"登封市","410190":"高新技术开发区","410191":"经济技术开发区","410202":"龙亭区","410203":"顺河回族区","410204":"鼓楼区","410205":"禹王台区","410212":"祥符区","410221":"杞县","410222":"通许县","410223":"尉氏县","410225":"兰考县","410302":"老城区","410303":"西工区","410304":"瀍河回族区","410305":"涧西区","410306":"吉利区","410311":"洛龙区","410322":"孟津县","410323":"新安县","410324":"栾川县","410325":"嵩县","410326":"汝阳县","410327":"宜阳县","410328":"洛宁县","410329":"伊川县","410381":"偃师市","410402":"新华区","410403":"卫东区","410404":"石龙区","410411":"湛河区","410421":"宝丰县","410422":"叶县","410423":"鲁山县","410425":"郏县","410481":"舞钢市","410482":"汝州市","410502":"文峰区","410503":"北关区","410505":"殷都区","410506":"龙安区","410522":"安阳县","410523":"汤阴县","410526":"滑县","410527":"内黄县","410581":"林州市","410590":"开发区","410602":"鹤山区","410603":"山城区","410611":"淇滨区","410621":"浚县","410622":"淇县","410702":"红旗区","410703":"卫滨区","410704":"凤泉区","410711":"牧野区","410721":"新乡县","410724":"获嘉县","410725":"原阳县","410726":"延津县","410727":"封丘县","410728":"长垣县","410781":"卫辉市","410782":"辉县市","410802":"解放区","410803":"中站区","410804":"马村区","410811":"山阳区","410821":"修武县","410822":"博爱县","410823":"武陟县","410825":"温县","410882":"沁阳市","410883":"孟州市","410902":"华龙区","410922":"清丰县","410923":"南乐县","410926":"范县","410927":"台前县","410928":"濮阳县","411002":"魏都区","411003":"建安区","411024":"鄢陵县","411025":"襄城县","411081":"禹州市","411082":"长葛市","411102":"源汇区","411103":"郾城区","411104":"召陵区","411121":"舞阳县","411122":"临颍县","411202":"湖滨区","411203":"陕州区","411221":"渑池县","411224":"卢氏县","411281":"义马市","411282":"灵宝市","411302":"宛城区","411303":"卧龙区","411321":"南召县","411322":"方城县","411323":"西峡县","411324":"镇平县","411325":"内乡县","411326":"淅川县","411327":"社旗县","411328":"唐河县","411329":"新野县","411330":"桐柏县","411381":"邓州市","411402":"梁园区","411403":"睢阳区","411421":"民权县","411422":"睢县","411423":"宁陵县","411424":"柘城县","411425":"虞城县","411426":"夏邑县","411481":"永城市","411502":"浉河区","411503":"平桥区","411521":"罗山县","411522":"光山县","411523":"新县","411524":"商城县","411525":"固始县","411526":"潢川县","411527":"淮滨县","411528":"息县","411602":"川汇区","411621":"扶沟县","411622":"西华县","411623":"商水县","411624":"沈丘县","411625":"郸城县","411626":"淮阳县","411627":"太康县","411628":"鹿邑县","411681":"项城市","411690":"经济开发区","411702":"驿城区","411721":"西平县","411722":"上蔡县","411723":"平舆县","411724":"正阳县","411725":"确山县","411726":"泌阳县","411727":"汝南县","411728":"遂平县","411729":"新蔡县","419001":"济源市","420102":"江岸区","420103":"江汉区","420104":"硚口区","420105":"汉阳区","420106":"武昌区","420107":"青山区","420111":"洪山区","420112":"东西湖区","420113":"汉南区","420114":"蔡甸区","420115":"江夏区","420116":"黄陂区","420117":"新洲区","420202":"黄石港区","420203":"西塞山区","420204":"下陆区","420205":"铁山区","420222":"阳新县","420281":"大冶市","420302":"茅箭区","420303":"张湾区","420304":"郧阳区","420322":"郧西县","420323":"竹山县","420324":"竹溪县","420325":"房县","420381":"丹江口市","420502":"西陵区","420503":"伍家岗区","420504":"点军区","420505":"猇亭区","420506":"夷陵区","420525":"远安县","420526":"兴山县","420527":"秭归县","420528":"长阳土家族自治县","420529":"五峰土家族自治县","420581":"宜都市","420582":"当阳市","420583":"枝江市","420590":"经济开发区","420602":"襄城区","420606":"樊城区","420607":"襄州区","420624":"南漳县","420625":"谷城县","420626":"保康县","420682":"老河口市","420683":"枣阳市","420684":"宜城市","420702":"梁子湖区","420703":"华容区","420704":"鄂城区","420802":"东宝区","420804":"掇刀区","420822":"沙洋县","420881":"钟祥市","420882":"京山市","420902":"孝南区","420921":"孝昌县","420922":"大悟县","420923":"云梦县","420981":"应城市","420982":"安陆市","420984":"汉川市","421002":"沙市区","421003":"荆州区","421022":"公安县","421023":"监利县","421024":"江陵县","421081":"石首市","421083":"洪湖市","421087":"松滋市","421102":"黄州区","421121":"团风县","421122":"红安县","421123":"罗田县","421124":"英山县","421125":"浠水县","421126":"蕲春县","421127":"黄梅县","421181":"麻城市","421182":"武穴市","421202":"咸安区","421221":"嘉鱼县","421222":"通城县","421223":"崇阳县","421224":"通山县","421281":"赤壁市","421303":"曾都区","421321":"随县","421381":"广水市","422801":"恩施市","422802":"利川市","422822":"建始县","422823":"巴东县","422825":"宣恩县","422826":"咸丰县","422827":"来凤县","422828":"鹤峰县","429004":"仙桃市","429005":"潜江市","429006":"天门市","429021":"神农架林区","430102":"芙蓉区","430103":"天心区","430104":"岳麓区","430105":"开福区","430111":"雨花区","430112":"望城区","430121":"长沙县","430181":"浏阳市","430182":"宁乡市","430202":"荷塘区","430203":"芦淞区","430204":"石峰区","430211":"天元区","430212":"渌口区","430223":"攸县","430224":"茶陵县","430225":"炎陵县","430281":"醴陵市","430302":"雨湖区","430304":"岳塘区","430321":"湘潭县","430381":"湘乡市","430382":"韶山市","430405":"珠晖区","430406":"雁峰区","430407":"石鼓区","430408":"蒸湘区","430412":"南岳区","430421":"衡阳县","430422":"衡南县","430423":"衡山县","430424":"衡东县","430426":"祁东县","430481":"耒阳市","430482":"常宁市","430502":"双清区","430503":"大祥区","430511":"北塔区","430521":"邵东县","430522":"新邵县","430523":"邵阳县","430524":"隆回县","430525":"洞口县","430527":"绥宁县","430528":"新宁县","430529":"城步苗族自治县","430581":"武冈市","430602":"岳阳楼区","430603":"云溪区","430611":"君山区","430621":"岳阳县","430623":"华容县","430624":"湘阴县","430626":"平江县","430681":"汨罗市","430682":"临湘市","430702":"武陵区","430703":"鼎城区","430721":"安乡县","430722":"汉寿县","430723":"澧县","430724":"临澧县","430725":"桃源县","430726":"石门县","430781":"津市市","430802":"永定区","430811":"武陵源区","430821":"慈利县","430822":"桑植县","430902":"资阳区","430903":"赫山区","430921":"南县","430922":"桃江县","430923":"安化县","430981":"沅江市","431002":"北湖区","431003":"苏仙区","431021":"桂阳县","431022":"宜章县","431023":"永兴县","431024":"嘉禾县","431025":"临武县","431026":"汝城县","431027":"桂东县","431028":"安仁县","431081":"资兴市","431102":"零陵区","431103":"冷水滩区","431121":"祁阳县","431122":"东安县","431123":"双牌县","431124":"道县","431125":"江永县","431126":"宁远县","431127":"蓝山县","431128":"新田县","431129":"江华瑶族自治县","431202":"鹤城区","431221":"中方县","431222":"沅陵县","431223":"辰溪县","431224":"溆浦县","431225":"会同县","431226":"麻阳苗族自治县","431227":"新晃侗族自治县","431228":"芷江侗族自治县","431229":"靖州苗族侗族自治县","431230":"通道侗族自治县","431281":"洪江市","431302":"娄星区","431321":"双峰县","431322":"新化县","431381":"冷水江市","431382":"涟源市","433101":"吉首市","433122":"泸溪县","433123":"凤凰县","433124":"花垣县","433125":"保靖县","433126":"古丈县","433127":"永顺县","433130":"龙山县","440103":"荔湾区","440104":"越秀区","440105":"海珠区","440106":"天河区","440111":"白云区","440112":"黄埔区","440113":"番禺区","440114":"花都区","440115":"南沙区","440117":"从化区","440118":"增城区","440203":"武江区","440204":"浈江区","440205":"曲江区","440222":"始兴县","440224":"仁化县","440229":"翁源县","440232":"乳源瑶族自治县","440233":"新丰县","440281":"乐昌市","440282":"南雄市","440303":"罗湖区","440304":"福田区","440305":"南山区","440306":"宝安区","440307":"龙岗区","440308":"盐田区","440309":"龙华区","440310":"坪山区","440311":"光明区","440402":"香洲区","440403":"斗门区","440404":"金湾区","440507":"龙湖区","440511":"金平区","440512":"濠江区","440513":"潮阳区","440514":"潮南区","440515":"澄海区","440523":"南澳县","440604":"禅城区","440605":"南海区","440606":"顺德区","440607":"三水区","440608":"高明区","440703":"蓬江区","440704":"江海区","440705":"新会区","440781":"台山市","440783":"开平市","440784":"鹤山市","440785":"恩平市","440802":"赤坎区","440803":"霞山区","440804":"坡头区","440811":"麻章区","440823":"遂溪县","440825":"徐闻县","440881":"廉江市","440882":"雷州市","440883":"吴川市","440890":"经济技术开发区","440902":"茂南区","440904":"电白区","440981":"高州市","440982":"化州市","440983":"信宜市","441202":"端州区","441203":"鼎湖区","441204":"高要区","441223":"广宁县","441224":"怀集县","441225":"封开县","441226":"德庆县","441284":"四会市","441302":"惠城区","441303":"惠阳区","441322":"博罗县","441323":"惠东县","441324":"龙门县","441402":"梅江区","441403":"梅县区","441422":"大埔县","441423":"丰顺县","441424":"五华县","441426":"平远县","441427":"蕉岭县","441481":"兴宁市","441502":"城区","441521":"海丰县","441523":"陆河县","441581":"陆丰市","441602":"源城区","441621":"紫金县","441622":"龙川县","441623":"连平县","441624":"和平县","441625":"东源县","441702":"江城区","441704":"阳东区","441721":"阳西县","441781":"阳春市","441802":"清城区","441803":"清新区","441821":"佛冈县","441823":"阳山县","441825":"连山壮族瑶族自治县","441826":"连南瑶族自治县","441881":"英德市","441882":"连州市","441901":"中堂镇","441903":"南城街道办事处","441904":"长安镇","441905":"东坑镇","441906":"樟木头镇","441907":"莞城街道办事处","441908":"石龙镇","441909":"桥头镇","441910":"万江街道办事处","441911":"麻涌镇","441912":"虎门镇","441913":"谢岗镇","441914":"石碣镇","441915":"茶山镇","441916":"东城街道办事处","441917":"洪梅镇","441918":"道滘镇","441919":"高埗镇","441920":"企石镇","441921":"凤岗镇","441922":"大岭山镇","441923":"松山湖管委会","441924":"清溪镇","441925":"望牛墩镇","441926":"厚街镇","441927":"常平镇","441928":"寮步镇","441929":"石排镇","441930":"横沥镇","441931":"塘厦镇","441932":"黄江镇","441933":"大朗镇","441934":"东莞港","441935":"东莞生态园","441990":"沙田镇","442001":"南头镇","442002":"神湾镇","442003":"东凤镇","442004":"五桂山街道办事处","442005":"黄圃镇","442006":"小榄镇","442007":"石岐区街道办事处","442008":"横栏镇","442009":"三角镇","442010":"三乡镇","442011":"港口镇","442012":"沙溪镇","442013":"板芙镇","442015":"东升镇","442016":"阜沙镇","442017":"民众镇","442018":"东区街道办事处","442019":"火炬开发区街道办事处","442020":"西区街道办事处","442021":"南区街道办事处","442022":"古镇镇","442023":"坦洲镇","442024":"大涌镇","442025":"南朗镇","445102":"湘桥区","445103":"潮安区","445122":"饶平县","445202":"榕城区","445203":"揭东区","445222":"揭西县","445224":"惠来县","445281":"普宁市","445302":"云城区","445303":"云安区","445321":"新兴县","445322":"郁南县","445381":"罗定市","450102":"兴宁区","450103":"青秀区","450105":"江南区","450107":"西乡塘区","450108":"良庆区","450109":"邕宁区","450110":"武鸣区","450123":"隆安县","450124":"马山县","450125":"上林县","450126":"宾阳县","450127":"横县","450202":"城中区","450203":"鱼峰区","450204":"柳南区","450205":"柳北区","450206":"柳江区","450222":"柳城县","450223":"鹿寨县","450224":"融安县","450225":"融水苗族自治县","450226":"三江侗族自治县","450302":"秀峰区","450303":"叠彩区","450304":"象山区","450305":"七星区","450311":"雁山区","450312":"临桂区","450321":"阳朔县","450323":"灵川县","450324":"全州县","450325":"兴安县","450326":"永福县","450327":"灌阳县","450328":"龙胜各族自治县","450329":"资源县","450330":"平乐县","450332":"恭城瑶族自治县","450381":"荔浦市","450403":"万秀区","450405":"长洲区","450406":"龙圩区","450421":"苍梧县","450422":"藤县","450423":"蒙山县","450481":"岑溪市","450502":"海城区","450503":"银海区","450512":"铁山港区","450521":"合浦县","450602":"港口区","450603":"防城区","450621":"上思县","450681":"东兴市","450702":"钦南区","450703":"钦北区","450721":"灵山县","450722":"浦北县","450802":"港北区","450803":"港南区","450804":"覃塘区","450821":"平南县","450881":"桂平市","450902":"玉州区","450903":"福绵区","450921":"容县","450922":"陆川县","450923":"博白县","450924":"兴业县","450981":"北流市","451002":"右江区","451021":"田阳县","451022":"田东县","451023":"平果县","451024":"德保县","451026":"那坡县","451027":"凌云县","451028":"乐业县","451029":"田林县","451030":"西林县","451031":"隆林各族自治县","451081":"靖西市","451102":"八步区","451103":"平桂区","451121":"昭平县","451122":"钟山县","451123":"富川瑶族自治县","451202":"金城江区","451203":"宜州区","451221":"南丹县","451222":"天峨县","451223":"凤山县","451224":"东兰县","451225":"罗城仫佬族自治县","451226":"环江毛南族自治县","451227":"巴马瑶族自治县","451228":"都安瑶族自治县","451229":"大化瑶族自治县","451302":"兴宾区","451321":"忻城县","451322":"象州县","451323":"武宣县","451324":"金秀瑶族自治县","451381":"合山市","451402":"江州区","451421":"扶绥县","451422":"宁明县","451423":"龙州县","451424":"大新县","451425":"天等县","451481":"凭祥市","460105":"秀英区","460106":"龙华区","460107":"琼山区","460108":"美兰区","460202":"海棠区","460203":"吉阳区","460204":"天涯区","460205":"崖州区","460321":"西沙群岛","460322":"南沙群岛","460323":"中沙群岛的岛礁及其海域","460401":"那大镇","460402":"和庆镇","460403":"南丰镇","460404":"大成镇","460405":"雅星镇","460406":"兰洋镇","460407":"光村镇","460408":"木棠镇","460409":"海头镇","460410":"峨蔓镇","460411":"王五镇","460412":"白马井镇","460413":"中和镇","460414":"排浦镇","460415":"东成镇","460416":"新州镇","460417":"洋浦经济开发区","460418":"华南热作学院","469001":"五指山市","469002":"琼海市","469005":"文昌市","469006":"万宁市","469007":"东方市","469021":"定安县","469022":"屯昌县","469023":"澄迈县","469024":"临高县","469025":"白沙黎族自治县","469026":"昌江黎族自治县","469027":"乐东黎族自治县","469028":"陵水黎族自治县","469029":"保亭黎族苗族自治县","469030":"琼中黎族苗族自治县","500101":"万州区","500102":"涪陵区","500103":"渝中区","500104":"大渡口区","500105":"江北区","500106":"沙坪坝区","500107":"九龙坡区","500108":"南岸区","500109":"北碚区","500110":"綦江区","500111":"大足区","500112":"渝北区","500113":"巴南区","500114":"黔江区","500115":"长寿区","500116":"江津区","500117":"合川区","500118":"永川区","500119":"南川区","500120":"璧山区","500151":"铜梁区","500152":"潼南区","500153":"荣昌区","500154":"开州区","500155":"梁平区","500156":"武隆区","500229":"城口县","500230":"丰都县","500231":"垫江县","500233":"忠县","500235":"云阳县","500236":"奉节县","500237":"巫山县","500238":"巫溪县","500240":"石柱土家族自治县","500241":"秀山土家族苗族自治县","500242":"酉阳土家族苗族自治县","500243":"彭水苗族土家族自治县","510104":"锦江区","510105":"青羊区","510106":"金牛区","510107":"武侯区","510108":"成华区","510112":"龙泉驿区","510113":"青白江区","510114":"新都区","510115":"温江区","510116":"双流区","510117":"郫都区","510121":"金堂县","510129":"大邑县","510131":"蒲江县","510132":"新津县","510181":"都江堰市","510182":"彭州市","510183":"邛崃市","510184":"崇州市","510185":"简阳市","510191":"高新区","510302":"自流井区","510303":"贡井区","510304":"大安区","510311":"沿滩区","510321":"荣县","510322":"富顺县","510402":"东区","510403":"西区","510411":"仁和区","510421":"米易县","510422":"盐边县","510502":"江阳区","510503":"纳溪区","510504":"龙马潭区","510521":"泸县","510522":"合江县","510524":"叙永县","510525":"古蔺县","510603":"旌阳区","510604":"罗江区","510623":"中江县","510681":"广汉市","510682":"什邡市","510683":"绵竹市","510703":"涪城区","510704":"游仙区","510705":"安州区","510722":"三台县","510723":"盐亭县","510725":"梓潼县","510726":"北川羌族自治县","510727":"平武县","510781":"江油市","510791":"高新区","510802":"利州区","510811":"昭化区","510812":"朝天区","510821":"旺苍县","510822":"青川县","510823":"剑阁县","510824":"苍溪县","510903":"船山区","510904":"安居区","510921":"蓬溪县","510922":"射洪县","510923":"大英县","511002":"市中区","511011":"东兴区","511024":"威远县","511025":"资中县","511083":"隆昌市","511102":"市中区","511111":"沙湾区","511112":"五通桥区","511113":"金口河区","511123":"犍为县","511124":"井研县","511126":"夹江县","511129":"沐川县","511132":"峨边彝族自治县","511133":"马边彝族自治县","511181":"峨眉山市","511302":"顺庆区","511303":"高坪区","511304":"嘉陵区","511321":"南部县","511322":"营山县","511323":"蓬安县","511324":"仪陇县","511325":"西充县","511381":"阆中市","511402":"东坡区","511403":"彭山区","511421":"仁寿县","511423":"洪雅县","511424":"丹棱县","511425":"青神县","511502":"翠屏区","511503":"南溪区","511504":"叙州区","511523":"江安县","511524":"长宁县","511525":"高县","511526":"珙县","511527":"筠连县","511528":"兴文县","511529":"屏山县","511602":"广安区","511603":"前锋区","511621":"岳池县","511622":"武胜县","511623":"邻水县","511681":"华蓥市","511702":"通川区","511703":"达川区","511722":"宣汉县","511723":"开江县","511724":"大竹县","511725":"渠县","511781":"万源市","511802":"雨城区","511803":"名山区","511822":"荥经县","511823":"汉源县","511824":"石棉县","511825":"天全县","511826":"芦山县","511827":"宝兴县","511902":"巴州区","511903":"恩阳区","511921":"通江县","511922":"南江县","511923":"平昌县","512002":"雁江区","512021":"安岳县","512022":"乐至县","513201":"马尔康市","513221":"汶川县","513222":"理县","513223":"茂县","513224":"松潘县","513225":"九寨沟县","513226":"金川县","513227":"小金县","513228":"黑水县","513230":"壤塘县","513231":"阿坝县","513232":"若尔盖县","513233":"红原县","513301":"康定市","513322":"泸定县","513323":"丹巴县","513324":"九龙县","513325":"雅江县","513326":"道孚县","513327":"炉霍县","513328":"甘孜县","513329":"新龙县","513330":"德格县","513331":"白玉县","513332":"石渠县","513333":"色达县","513334":"理塘县","513335":"巴塘县","513336":"乡城县","513337":"稻城县","513338":"得荣县","513401":"西昌市","513422":"木里藏族自治县","513423":"盐源县","513424":"德昌县","513425":"会理县","513426":"会东县","513427":"宁南县","513428":"普格县","513429":"布拖县","513430":"金阳县","513431":"昭觉县","513432":"喜德县","513433":"冕宁县","513434":"越西县","513435":"甘洛县","513436":"美姑县","513437":"雷波县","520102":"南明区","520103":"云岩区","520111":"花溪区","520112":"乌当区","520113":"白云区","520115":"观山湖区","520121":"开阳县","520122":"息烽县","520123":"修文县","520181":"清镇市","520201":"钟山区","520203":"六枝特区","520221":"水城县","520281":"盘州市","520302":"红花岗区","520303":"汇川区","520304":"播州区","520322":"桐梓县","520323":"绥阳县","520324":"正安县","520325":"道真仡佬族苗族自治县","520326":"务川仡佬族苗族自治县","520327":"凤冈县","520328":"湄潭县","520329":"余庆县","520330":"习水县","520381":"赤水市","520382":"仁怀市","520402":"西秀区","520403":"平坝区","520422":"普定县","520423":"镇宁布依族苗族自治县","520424":"关岭布依族苗族自治县","520425":"紫云苗族布依族自治县","520502":"七星关区","520521":"大方县","520522":"黔西县","520523":"金沙县","520524":"织金县","520525":"纳雍县","520526":"威宁彝族回族苗族自治县","520527":"赫章县","520602":"碧江区","520603":"万山区","520621":"江口县","520622":"玉屏侗族自治县","520623":"石阡县","520624":"思南县","520625":"印江土家族苗族自治县","520626":"德江县","520627":"沿河土家族自治县","520628":"松桃苗族自治县","522301":"兴义市","522302":"兴仁市","522323":"普安县","522324":"晴隆县","522325":"贞丰县","522326":"望谟县","522327":"册亨县","522328":"安龙县","522601":"凯里市","522622":"黄平县","522623":"施秉县","522624":"三穗县","522625":"镇远县","522626":"岑巩县","522627":"天柱县","522628":"锦屏县","522629":"剑河县","522630":"台江县","522631":"黎平县","522632":"榕江县","522633":"从江县","522634":"雷山县","522635":"麻江县","522636":"丹寨县","522701":"都匀市","522702":"福泉市","522722":"荔波县","522723":"贵定县","522725":"瓮安县","522726":"独山县","522727":"平塘县","522728":"罗甸县","522729":"长顺县","522730":"龙里县","522731":"惠水县","522732":"三都水族自治县","530102":"五华区","530103":"盘龙区","530111":"官渡区","530112":"西山区","530113":"东川区","530114":"呈贡区","530115":"晋宁区","530124":"富民县","530125":"宜良县","530126":"石林彝族自治县","530127":"嵩明县","530128":"禄劝彝族苗族自治县","530129":"寻甸回族彝族自治县","530181":"安宁市","530302":"麒麟区","530303":"沾益区","530304":"马龙区","530322":"陆良县","530323":"师宗县","530324":"罗平县","530325":"富源县","530326":"会泽县","530381":"宣威市","530402":"红塔区","530403":"江川区","530422":"澄江县","530423":"通海县","530424":"华宁县","530425":"易门县","530426":"峨山彝族自治县","530427":"新平彝族傣族自治县","530428":"元江哈尼族彝族傣族自治县","530502":"隆阳区","530521":"施甸县","530523":"龙陵县","530524":"昌宁县","530581":"腾冲市","530602":"昭阳区","530621":"鲁甸县","530622":"巧家县","530623":"盐津县","530624":"大关县","530625":"永善县","530626":"绥江县","530627":"镇雄县","530628":"彝良县","530629":"威信县","530681":"水富市","530702":"古城区","530721":"玉龙纳西族自治县","530722":"永胜县","530723":"华坪县","530724":"宁蒗彝族自治县","530802":"思茅区","530821":"宁洱哈尼族彝族自治县","530822":"墨江哈尼族自治县","530823":"景东彝族自治县","530824":"景谷傣族彝族自治县","530825":"镇沅彝族哈尼族拉祜族自治县","530826":"江城哈尼族彝族自治县","530827":"孟连傣族拉祜族佤族自治县","530828":"澜沧拉祜族自治县","530829":"西盟佤族自治县","530902":"临翔区","530921":"凤庆县","530922":"云县","530923":"永德县","530924":"镇康县","530925":"双江拉祜族佤族布朗族傣族自治县","530926":"耿马傣族佤族自治县","530927":"沧源佤族自治县","532301":"楚雄市","532322":"双柏县","532323":"牟定县","532324":"南华县","532325":"姚安县","532326":"大姚县","532327":"永仁县","532328":"元谋县","532329":"武定县","532331":"禄丰县","532501":"个旧市","532502":"开远市","532503":"蒙自市","532504":"弥勒市","532523":"屏边苗族自治县","532524":"建水县","532525":"石屏县","532527":"泸西县","532528":"元阳县","532529":"红河县","532530":"金平苗族瑶族傣族自治县","532531":"绿春县","532532":"河口瑶族自治县","532601":"文山市","532622":"砚山县","532623":"西畴县","532624":"麻栗坡县","532625":"马关县","532626":"丘北县","532627":"广南县","532628":"富宁县","532801":"景洪市","532822":"勐海县","532823":"勐腊县","532901":"大理市","532922":"漾濞彝族自治县","532923":"祥云县","532924":"宾川县","532925":"弥渡县","532926":"南涧彝族自治县","532927":"巍山彝族回族自治县","532928":"永平县","532929":"云龙县","532930":"洱源县","532931":"剑川县","532932":"鹤庆县","533102":"瑞丽市","533103":"芒市","533122":"梁河县","533123":"盈江县","533124":"陇川县","533301":"泸水市","533323":"福贡县","533324":"贡山独龙族怒族自治县","533325":"兰坪白族普米族自治县","533401":"香格里拉市","533422":"德钦县","533423":"维西傈僳族自治县","540102":"城关区","540103":"堆龙德庆区","540104":"达孜区","540121":"林周县","540122":"当雄县","540123":"尼木县","540124":"曲水县","540127":"墨竹工卡县","540202":"桑珠孜区","540221":"南木林县","540222":"江孜县","540223":"定日县","540224":"萨迦县","540225":"拉孜县","540226":"昂仁县","540227":"谢通门县","540228":"白朗县","540229":"仁布县","540230":"康马县","540231":"定结县","540232":"仲巴县","540233":"亚东县","540234":"吉隆县","540235":"聂拉木县","540236":"萨嘎县","540237":"岗巴县","540302":"卡若区","540321":"江达县","540322":"贡觉县","540323":"类乌齐县","540324":"丁青县","540325":"察雅县","540326":"八宿县","540327":"左贡县","540328":"芒康县","540329":"洛隆县","540330":"边坝县","540402":"巴宜区","540421":"工布江达县","540422":"米林县","540423":"墨脱县","540424":"波密县","540425":"察隅县","540426":"朗县","540502":"乃东区","540521":"扎囊县","540522":"贡嘎县","540523":"桑日县","540524":"琼结县","540525":"曲松县","540526":"措美县","540527":"洛扎县","540528":"加查县","540529":"隆子县","540530":"错那县","540531":"浪卡子县","540602":"色尼区","540621":"嘉黎县","540622":"比如县","540623":"聂荣县","540624":"安多县","540625":"申扎县","540626":"索县","540627":"班戈县","540628":"巴青县","540629":"尼玛县","540630":"双湖县","542521":"普兰县","542522":"札达县","542523":"噶尔县","542524":"日土县","542525":"革吉县","542526":"改则县","542527":"措勤县","610102":"新城区","610103":"碑林区","610104":"莲湖区","610111":"灞桥区","610112":"未央区","610113":"雁塔区","610114":"阎良区","610115":"临潼区","610116":"长安区","610117":"高陵区","610118":"鄠邑区","610122":"蓝田县","610124":"周至县","610202":"王益区","610203":"印台区","610204":"耀州区","610222":"宜君县","610302":"渭滨区","610303":"金台区","610304":"陈仓区","610322":"凤翔县","610323":"岐山县","610324":"扶风县","610326":"眉县","610327":"陇县","610328":"千阳县","610329":"麟游县","610330":"凤县","610331":"太白县","610402":"秦都区","610403":"杨陵区","610404":"渭城区","610422":"三原县","610423":"泾阳县","610424":"乾县","610425":"礼泉县","610426":"永寿县","610428":"长武县","610429":"旬邑县","610430":"淳化县","610431":"武功县","610481":"兴平市","610482":"彬州市","610502":"临渭区","610503":"华州区","610522":"潼关县","610523":"大荔县","610524":"合阳县","610525":"澄城县","610526":"蒲城县","610527":"白水县","610528":"富平县","610581":"韩城市","610582":"华阴市","610602":"宝塔区","610603":"安塞区","610621":"延长县","610622":"延川县","610623":"子长县","610625":"志丹县","610626":"吴起县","610627":"甘泉县","610628":"富县","610629":"洛川县","610630":"宜川县","610631":"黄龙县","610632":"黄陵县","610702":"汉台区","610703":"南郑区","610722":"城固县","610723":"洋县","610724":"西乡县","610725":"勉县","610726":"宁强县","610727":"略阳县","610728":"镇巴县","610729":"留坝县","610730":"佛坪县","610802":"榆阳区","610803":"横山区","610822":"府谷县","610824":"靖边县","610825":"定边县","610826":"绥德县","610827":"米脂县","610828":"佳县","610829":"吴堡县","610830":"清涧县","610831":"子洲县","610881":"神木市","610902":"汉滨区","610921":"汉阴县","610922":"石泉县","610923":"宁陕县","610924":"紫阳县","610925":"岚皋县","610926":"平利县","610927":"镇坪县","610928":"旬阳县","610929":"白河县","611002":"商州区","611021":"洛南县","611022":"丹凤县","611023":"商南县","611024":"山阳县","611025":"镇安县","611026":"柞水县","620102":"城关区","620103":"七里河区","620104":"西固区","620105":"安宁区","620111":"红古区","620121":"永登县","620122":"皋兰县","620123":"榆中县","620201":"市辖区","620290":"雄关区","620291":"长城区","620292":"镜铁区","620293":"新城镇","620294":"峪泉镇","620295":"文殊镇","620302":"金川区","620321":"永昌县","620402":"白银区","620403":"平川区","620421":"靖远县","620422":"会宁县","620423":"景泰县","620502":"秦州区","620503":"麦积区","620521":"清水县","620522":"秦安县","620523":"甘谷县","620524":"武山县","620525":"张家川回族自治县","620602":"凉州区","620621":"民勤县","620622":"古浪县","620623":"天祝藏族自治县","620702":"甘州区","620721":"肃南裕固族自治县","620722":"民乐县","620723":"临泽县","620724":"高台县","620725":"山丹县","620802":"崆峒区","620821":"泾川县","620822":"灵台县","620823":"崇信县","620825":"庄浪县","620826":"静宁县","620881":"华亭市","620902":"肃州区","620921":"金塔县","620922":"瓜州县","620923":"肃北蒙古族自治县","620924":"阿克塞哈萨克族自治县","620981":"玉门市","620982":"敦煌市","621002":"西峰区","621021":"庆城县","621022":"环县","621023":"华池县","621024":"合水县","621025":"正宁县","621026":"宁县","621027":"镇原县","621102":"安定区","621121":"通渭县","621122":"陇西县","621123":"渭源县","621124":"临洮县","621125":"漳县","621126":"岷县","621202":"武都区","621221":"成县","621222":"文县","621223":"宕昌县","621224":"康县","621225":"西和县","621226":"礼县","621227":"徽县","621228":"两当县","622901":"临夏市","622921":"临夏县","622922":"康乐县","622923":"永靖县","622924":"广河县","622925":"和政县","622926":"东乡族自治县","622927":"积石山保安族东乡族撒拉族自治县","623001":"合作市","623021":"临潭县","623022":"卓尼县","623023":"舟曲县","623024":"迭部县","623025":"玛曲县","623026":"碌曲县","623027":"夏河县","630102":"城东区","630103":"城中区","630104":"城西区","630105":"城北区","630121":"大通回族土族自治县","630122":"湟中县","630123":"湟源县","630202":"乐都区","630203":"平安区","630222":"民和回族土族自治县","630223":"互助土族自治县","630224":"化隆回族自治县","630225":"循化撒拉族自治县","632221":"门源回族自治县","632222":"祁连县","632223":"海晏县","632224":"刚察县","632321":"同仁县","632322":"尖扎县","632323":"泽库县","632324":"河南蒙古族自治县","632521":"共和县","632522":"同德县","632523":"贵德县","632524":"兴海县","632525":"贵南县","632621":"玛沁县","632622":"班玛县","632623":"甘德县","632624":"达日县","632625":"久治县","632626":"玛多县","632701":"玉树市","632722":"杂多县","632723":"称多县","632724":"治多县","632725":"囊谦县","632726":"曲麻莱县","632801":"格尔木市","632802":"德令哈市","632803":"茫崖市","632821":"乌兰县","632822":"都兰县","632823":"天峻县","640104":"兴庆区","640105":"西夏区","640106":"金凤区","640121":"永宁县","640122":"贺兰县","640181":"灵武市","640202":"大武口区","640205":"惠农区","640221":"平罗县","640302":"利通区","640303":"红寺堡区","640323":"盐池县","640324":"同心县","640381":"青铜峡市","640402":"原州区","640422":"西吉县","640423":"隆德县","640424":"泾源县","640425":"彭阳县","640502":"沙坡头区","640521":"中宁县","640522":"海原县","650102":"天山区","650103":"沙依巴克区","650104":"新市区","650105":"水磨沟区","650106":"头屯河区","650107":"达坂城区","650109":"米东区","650121":"乌鲁木齐县","650202":"独山子区","650203":"克拉玛依区","650204":"白碱滩区","650205":"乌尔禾区","650402":"高昌区","650421":"鄯善县","650422":"托克逊县","650502":"伊州区","650521":"巴里坤哈萨克自治县","650522":"伊吾县","652301":"昌吉市","652302":"阜康市","652323":"呼图壁县","652324":"玛纳斯县","652325":"奇台县","652327":"吉木萨尔县","652328":"木垒哈萨克自治县","652701":"博乐市","652702":"阿拉山口市","652722":"精河县","652723":"温泉县","652801":"库尔勒市","652822":"轮台县","652823":"尉犁县","652824":"若羌县","652825":"且末县","652826":"焉耆回族自治县","652827":"和静县","652828":"和硕县","652829":"博湖县","652901":"阿克苏市","652922":"温宿县","652923":"库车县","652924":"沙雅县","652925":"新和县","652926":"拜城县","652927":"乌什县","652928":"阿瓦提县","652929":"柯坪县","653001":"阿图什市","653022":"阿克陶县","653023":"阿合奇县","653024":"乌恰县","653101":"喀什市","653121":"疏附县","653122":"疏勒县","653123":"英吉沙县","653124":"泽普县","653125":"莎车县","653126":"叶城县","653127":"麦盖提县","653128":"岳普湖县","653129":"伽师县","653130":"巴楚县","653131":"塔什库尔干塔吉克自治县","653201":"和田市","653221":"和田县","653222":"墨玉县","653223":"皮山县","653224":"洛浦县","653225":"策勒县","653226":"于田县","653227":"民丰县","654002":"伊宁市","654003":"奎屯市","654004":"霍尔果斯市","654021":"伊宁县","654022":"察布查尔锡伯自治县","654023":"霍城县","654024":"巩留县","654025":"新源县","654026":"昭苏县","654027":"特克斯县","654028":"尼勒克县","654201":"塔城市","654202":"乌苏市","654221":"额敏县","654223":"沙湾县","654224":"托里县","654225":"裕民县","654226":"和布克赛尔蒙古自治县","654301":"阿勒泰市","654321":"布尔津县","654322":"富蕴县","654323":"福海县","654324":"哈巴河县","654325":"青河县","654326":"吉木乃县","659001":"石河子市","659002":"阿拉尔市","659003":"图木舒克市","659004":"五家渠市","659005":"北屯市","659006":"铁门关市","659007":"双河市","659008":"可克达拉市","659009":"昆玉市","710101":"中正区","710102":"大同区","710103":"中山区","710104":"松山区","710105":"大安区","710106":"万华区","710107":"信义区","710108":"士林区","710109":"北投区","710110":"内湖区","710111":"南港区","710112":"文山区","710199":"其它区","710201":"新兴区","710202":"前金区","710203":"芩雅区","710204":"盐埕区","710205":"鼓山区","710206":"旗津区","710207":"前镇区","710208":"三民区","710209":"左营区","710210":"楠梓区","710211":"小港区","710241":"苓雅区","710242":"仁武区","710243":"大社区","710244":"冈山区","710245":"路竹区","710246":"阿莲区","710247":"田寮区","710248":"燕巢区","710249":"桥头区","710250":"梓官区","710251":"弥陀区","710252":"永安区","710253":"湖内区","710254":"凤山区","710255":"大寮区","710256":"林园区","710257":"鸟松区","710258":"大树区","710259":"旗山区","710260":"美浓区","710261":"六龟区","710262":"内门区","710263":"杉林区","710264":"甲仙区","710265":"桃源区","710266":"那玛夏区","710267":"茂林区","710268":"茄萣区","710299":"其它区","710301":"中西区","710302":"东区","710303":"南区","710304":"北区","710305":"安平区","710306":"安南区","710339":"永康区","710340":"归仁区","710341":"新化区","710342":"左镇区","710343":"玉井区","710344":"楠西区","710345":"南化区","710346":"仁德区","710347":"关庙区","710348":"龙崎区","710349":"官田区","710350":"麻豆区","710351":"佳里区","710352":"西港区","710353":"七股区","710354":"将军区","710355":"学甲区","710356":"北门区","710357":"新营区","710358":"后壁区","710359":"白河区","710360":"东山区","710361":"六甲区","710362":"下营区","710363":"柳营区","710364":"盐水区","710365":"善化区","710366":"大内区","710367":"山上区","710368":"新市区","710369":"安定区","710399":"其它区","710401":"中区","710402":"东区","710403":"南区","710404":"西区","710405":"北区","710406":"北屯区","710407":"西屯区","710408":"南屯区","710431":"太平区","710432":"大里区","710433":"雾峰区","710434":"乌日区","710435":"丰原区","710436":"后里区","710437":"石冈区","710438":"东势区","710439":"和平区","710440":"新社区","710441":"潭子区","710442":"大雅区","710443":"神冈区","710444":"大肚区","710445":"沙鹿区","710446":"龙井区","710447":"梧栖区","710448":"清水区","710449":"大甲区","710450":"外埔区","710451":"大安区","710499":"其它区","710507":"金沙镇","710508":"金湖镇","710509":"金宁乡","710510":"金城镇","710511":"烈屿乡","710512":"乌坵乡","710614":"南投市","710615":"中寮乡","710616":"草屯镇","710617":"国姓乡","710618":"埔里镇","710619":"仁爱乡","710620":"名间乡","710621":"集集镇","710622":"水里乡","710623":"鱼池乡","710624":"信义乡","710625":"竹山镇","710626":"鹿谷乡","710701":"仁爱区","710702":"信义区","710703":"中正区","710704":"中山区","710705":"安乐区","710706":"暖暖区","710707":"七堵区","710799":"其它区","710801":"东区","710802":"北区","710803":"香山区","710899":"其它区","710901":"东区","710902":"西区","710999":"其它区","711130":"万里区","711132":"板桥区","711133":"汐止区","711134":"深坑区","711135":"石碇区","711136":"瑞芳区","711137":"平溪区","711138":"双溪区","711139":"贡寮区","711140":"新店区","711141":"坪林区","711142":"乌来区","711143":"永和区","711144":"中和区","711145":"土城区","711146":"三峡区","711147":"树林区","711148":"莺歌区","711149":"三重区","711150":"新庄区","711151":"泰山区","711152":"林口区","711153":"芦洲区","711154":"五股区","711155":"八里区","711156":"淡水区","711157":"三芝区","711158":"石门区","711287":"宜兰市","711288":"头城镇","711289":"礁溪乡","711290":"壮围乡","711291":"员山乡","711292":"罗东镇","711293":"三星乡","711294":"大同乡","711295":"五结乡","711296":"冬山乡","711297":"苏澳镇","711298":"南澳乡","711299":"钓鱼台","711387":"竹北市","711388":"湖口乡","711389":"新丰乡","711390":"新埔镇","711391":"关西镇","711392":"芎林乡","711393":"宝山乡","711394":"竹东镇","711395":"五峰乡","711396":"横山乡","711397":"尖石乡","711398":"北埔乡","711399":"峨眉乡","711414":"中坜区","711415":"平镇区","711417":"杨梅区","711418":"新屋区","711419":"观音区","711420":"桃园区","711421":"龟山区","711422":"八德区","711423":"大溪区","711425":"大园区","711426":"芦竹区","711487":"中坜市","711488":"平镇市","711489":"龙潭乡","711490":"杨梅市","711491":"新屋乡","711492":"观音乡","711493":"桃园市","711494":"龟山乡","711495":"八德市","711496":"大溪镇","711497":"复兴乡","711498":"大园乡","711499":"芦竹乡","711520":"头份市","711582":"竹南镇","711583":"头份镇","711584":"三湾乡","711585":"南庄乡","711586":"狮潭乡","711587":"后龙镇","711588":"通霄镇","711589":"苑里镇","711590":"苗栗市","711591":"造桥乡","711592":"头屋乡","711593":"公馆乡","711594":"大湖乡","711595":"泰安乡","711596":"铜锣乡","711597":"三义乡","711598":"西湖乡","711599":"卓兰镇","711736":"员林市","711774":"彰化市","711775":"芬园乡","711776":"花坛乡","711777":"秀水乡","711778":"鹿港镇","711779":"福兴乡","711780":"线西乡","711781":"和美镇","711782":"伸港乡","711783":"员林镇","711784":"社头乡","711785":"永靖乡","711786":"埔心乡","711787":"溪湖镇","711788":"大村乡","711789":"埔盐乡","711790":"田中镇","711791":"北斗镇","711792":"田尾乡","711793":"埤头乡","711794":"溪州乡","711795":"竹塘乡","711796":"二林镇","711797":"大城乡","711798":"芳苑乡","711799":"二水乡","711982":"番路乡","711983":"梅山乡","711984":"竹崎乡","711985":"阿里山乡","711986":"中埔乡","711987":"大埔乡","711988":"水上乡","711989":"鹿草乡","711990":"太保市","711991":"朴子市","711992":"东石乡","711993":"六脚乡","711994":"新港乡","711995":"民雄乡","711996":"大林镇","711997":"溪口乡","711998":"义竹乡","711999":"布袋镇","712180":"斗南镇","712181":"大埤乡","712182":"虎尾镇","712183":"土库镇","712184":"褒忠乡","712185":"东势乡","712186":"台西乡","712187":"仑背乡","712188":"麦寮乡","712189":"斗六市","712190":"林内乡","712191":"古坑乡","712192":"莿桐乡","712193":"西螺镇","712194":"二仑乡","712195":"北港镇","712196":"水林乡","712197":"口湖乡","712198":"四湖乡","712199":"元长乡","712451":"崁顶乡","712467":"屏东市","712468":"三地门乡","712469":"雾台乡","712470":"玛家乡","712471":"九如乡","712472":"里港乡","712473":"高树乡","712474":"盐埔乡","712475":"长治乡","712476":"麟洛乡","712477":"竹田乡","712478":"内埔乡","712479":"万丹乡","712480":"潮州镇","712481":"泰武乡","712482":"来义乡","712483":"万峦乡","712484":"莰顶乡","712485":"新埤乡","712486":"南州乡","712487":"林边乡","712488":"东港镇","712489":"琉球乡","712490":"佳冬乡","712491":"新园乡","712492":"枋寮乡","712493":"枋山乡","712494":"春日乡","712495":"狮子乡","712496":"车城乡","712497":"牡丹乡","712498":"恒春镇","712499":"满州乡","712584":"台东市","712585":"绿岛乡","712586":"兰屿乡","712587":"延平乡","712588":"卑南乡","712589":"鹿野乡","712590":"关山镇","712591":"海端乡","712592":"池上乡","712593":"东河乡","712594":"成功镇","712595":"长滨乡","712596":"金峰乡","712597":"大武乡","712598":"达仁乡","712599":"太麻里乡","712686":"花莲市","712687":"新城乡","712688":"太鲁阁","712689":"秀林乡","712690":"吉安乡","712691":"寿丰乡","712692":"凤林镇","712693":"光复乡","712694":"丰滨乡","712695":"瑞穗乡","712696":"万荣乡","712697":"玉里镇","712698":"卓溪乡","712699":"富里乡","712794":"马公市","712795":"西屿乡","712796":"望安乡","712797":"七美乡","712798":"白沙乡","712799":"湖西乡","712896":"南竿乡","712897":"北竿乡","712898":"东引乡","712899":"莒光乡","810101":"中西区","810102":"湾仔区","810103":"东区","810104":"南区","810201":"九龙城区","810202":"油尖旺区","810203":"深水埗区","810204":"黄大仙区","810205":"观塘区","810301":"北区","810302":"大埔区","810303":"沙田区","810304":"西贡区","810305":"元朗区","810306":"屯门区","810307":"荃湾区","810308":"葵青区","810309":"离岛区","820101":"澳门半岛","820201":"离岛"}} \ No newline at end of file diff --git a/zsw-bxg/src/main/resources/dozer/bean-mappings.xml b/zsw-bxg/src/main/resources/dozer/bean-mappings.xml new file mode 100644 index 00000000..323a656f --- /dev/null +++ b/zsw-bxg/src/main/resources/dozer/bean-mappings.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/zsw-bxg/src/main/resources/dozer/global-configuration.xml b/zsw-bxg/src/main/resources/dozer/global-configuration.xml new file mode 100644 index 00000000..f09f7329 --- /dev/null +++ b/zsw-bxg/src/main/resources/dozer/global-configuration.xml @@ -0,0 +1,17 @@ + + + + yyyy-MM-dd HH:mm:ss + true + false + + + + \ No newline at end of file diff --git a/zsw-bxg/src/main/resources/fx.jpg b/zsw-bxg/src/main/resources/fx.jpg new file mode 100644 index 00000000..739d0c17 Binary files /dev/null and b/zsw-bxg/src/main/resources/fx.jpg differ diff --git a/zsw-bxg/src/main/resources/poster.jpg b/zsw-bxg/src/main/resources/poster.jpg new file mode 100644 index 00000000..7687578a Binary files /dev/null and b/zsw-bxg/src/main/resources/poster.jpg differ diff --git a/zsw-bxg/src/main/resources/red.jpg b/zsw-bxg/src/main/resources/red.jpg new file mode 100644 index 00000000..01c147c2 Binary files /dev/null and b/zsw-bxg/src/main/resources/red.jpg differ diff --git a/zsw-bxg/src/main/resources/simsunb.ttf b/zsw-bxg/src/main/resources/simsunb.ttf new file mode 100644 index 00000000..1c14f7fa Binary files /dev/null and b/zsw-bxg/src/main/resources/simsunb.ttf differ diff --git a/zsw-bxg/src/main/resources/template/email/email.ftl b/zsw-bxg/src/main/resources/template/email/email.ftl new file mode 100644 index 00000000..8f7e13a0 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/email/email.ftl @@ -0,0 +1,45 @@ + + + + + + + +
+
+

尊敬的用户,您好:

+

您正在申请邮箱验证,您的验证码为:

+

${code}

+ + +
+
+ + +
+
+ + diff --git a/zsw-bxg/src/main/resources/template/generator/admin/Controller.ftl b/zsw-bxg/src/main/resources/template/generator/admin/Controller.ftl new file mode 100644 index 00000000..adda5a03 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/Controller.ftl @@ -0,0 +1,81 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.rest; + +import co.yixiang.aop.log.Log; +import ${package}.domain.${className}; +import ${package}.service.${className}Service; +import ${package}.service.dto.${className}QueryCriteria; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @author ${author} +* @date ${date} +*/ +@Api(tags = "${apiAlias}管理") +@RestController +@RequestMapping("/api/${changeClassName}") +public class ${className}Controller { + + private final ${className}Service ${changeClassName}Service; + + public ${className}Controller(${className}Service ${changeClassName}Service) { + this.${changeClassName}Service = ${changeClassName}Service; + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('${changeClassName}:list')") + public void download(HttpServletResponse response, ${className}QueryCriteria criteria) throws IOException { + ${changeClassName}Service.download(${changeClassName}Service.queryAll(criteria), response); + } + + @GetMapping + @Log("查询${apiAlias}") + @ApiOperation("查询${apiAlias}") + @PreAuthorize("@el.check('${changeClassName}:list')") + public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增${apiAlias}") + @ApiOperation("新增${apiAlias}") + @PreAuthorize("@el.check('${changeClassName}:add')") + public ResponseEntity create(@Validated @RequestBody ${className} resources){ + return new ResponseEntity<>(${changeClassName}Service.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改${apiAlias}") + @ApiOperation("修改${apiAlias}") + @PreAuthorize("@el.check('${changeClassName}:edit')") + public ResponseEntity update(@Validated @RequestBody ${className} resources){ + ${changeClassName}Service.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除${apiAlias}") + @ApiOperation("删除${apiAlias}") + @PreAuthorize("@el.check('${changeClassName}:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody ${pkColumnType}[] ids) { + ${changeClassName}Service.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/ControllerP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/ControllerP.ftl new file mode 100644 index 00000000..49aa00e6 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/ControllerP.ftl @@ -0,0 +1,85 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.rest; +import java.util.Arrays; +import co.yixiang.dozer.service.IGenerator; +import lombok.AllArgsConstructor; +import co.yixiang.logging.aop.log.Log; +import ${package}.domain.${className}; +import ${package}.service.${className}Service; +import ${package}.service.dto.${className}QueryCriteria; +import ${package}.service.dto.${className}Dto; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** +* @author ${author} +* @date ${date} +*/ +@AllArgsConstructor +@Api(tags = "${apiAlias}管理") +@RestController +@RequestMapping("/api/${changeClassName}") +public class ${className}Controller { + + private final ${className}Service ${changeClassName}Service; + private final IGenerator generator; + + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('admin','${changeClassName}:list')") + public void download(HttpServletResponse response, ${className}QueryCriteria criteria) throws IOException { + ${changeClassName}Service.download(generator.convert(${changeClassName}Service.queryAll(criteria), ${className}Dto.class), response); + } + + @GetMapping + @Log("查询${apiAlias}") + @ApiOperation("查询${apiAlias}") + @PreAuthorize("@el.check('admin','${changeClassName}:list')") + public ResponseEntity> get${className}s(${className}QueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增${apiAlias}") + @ApiOperation("新增${apiAlias}") + @PreAuthorize("@el.check('admin','${changeClassName}:add')") + public ResponseEntity create(@Validated @RequestBody ${className} resources){ + return new ResponseEntity<>(${changeClassName}Service.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改${apiAlias}") + @ApiOperation("修改${apiAlias}") + @PreAuthorize("@el.check('admin','${changeClassName}:edit')") + public ResponseEntity update(@Validated @RequestBody ${className} resources){ + ${changeClassName}Service.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除${apiAlias}") + @ApiOperation("删除${apiAlias}") + @PreAuthorize("@el.check('admin','${changeClassName}:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody ${pkColumnType}[] ids) { + Arrays.asList(ids).forEach(id->{ + ${changeClassName}Service.removeById(id); + }); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/Dto.ftl b/zsw-bxg/src/main/resources/template/generator/admin/Dto.ftl new file mode 100644 index 00000000..6eb9219b --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/Dto.ftl @@ -0,0 +1,45 @@ +/** +* Copyright (C) 2018-2021 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.dto; + +import lombok.Data; +<#if hasDateTime> +import java.util.Date; + +<#if hasBigDecimal> +import java.math.BigDecimal; + +import java.io.Serializable; +<#if !auto && pkColumnType = 'Long'> +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + + +/** +* @author ${author} +* @date ${date} +*/ +@Data +public class ${className}Dto implements Serializable { +<#if columns??> + <#list columns as column> + + <#if column.remark != ''> + /** ${column.remark} */ + + <#if column.columnKey = 'PRI'> + <#if !auto && pkColumnType = 'Long'> + /** 防止精度丢失 */ + @JsonSerialize(using= ToStringSerializer.class) + + + private ${column.columnType} ${column.changeColumnName}; + + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/DtoP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/DtoP.ftl new file mode 100644 index 00000000..5814fccd --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/DtoP.ftl @@ -0,0 +1,47 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.dto; + +import lombok.Data; +<#if hasDateTime> +import java.util.Date; + +<#if hasBigDecimal> +import java.math.BigDecimal; + +import java.io.Serializable; +<#if !auto && pkColumnType == 'Long'> +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + + +/** +* @author ${author} +* @date ${date} +*/ +@Data +public class ${className}Dto implements Serializable { +<#if columns??> + <#list columns as column> + + <#if column.remark != ''> + /** ${column.remark} */ + + <#if column.columnKey = 'PRI'> + <#if !auto && pkColumnType = 'Long'> + /** 防止精度丢失 */ + @JsonSerialize(using= ToStringSerializer.class) + + + <#if column.changeColumnName != 'delFlag'> + private ${column.columnType} ${column.changeColumnName}; + + + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/Entity.ftl b/zsw-bxg/src/main/resources/template/generator/admin/Entity.ftl new file mode 100644 index 00000000..50bb221e --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/Entity.ftl @@ -0,0 +1,73 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; + +<#if isNotNullColumns??> +import javax.validation.constraints.*; + +<#if hasDateAnnotation> +import javax.persistence.Entity; +import javax.persistence.Table; +import org.hibernate.annotations.*; + +<#if hasDateTime> +import java.util.Date; + +<#if hasBigDecimal> +import java.math.BigDecimal; + +import java.io.Serializable; + +/** +* @author ${author} +* @date ${date} +*/ +@Entity +@Data +@Table(name="${tableName}") +public class ${className} implements Serializable { +<#if columns??> + <#list columns as column> + + <#if column.remark != ''> + /** ${column.remark} */ + + <#if column.columnKey = 'PRI'> + @Id + <#if auto> + @GeneratedValue(strategy = GenerationType.IDENTITY) + + + @Column(name = "${column.columnName}"<#if column.columnKey = 'UNI'>,unique = true<#if column.istNotNull && column.columnKey != 'PRI'>,nullable = false) + <#if column.istNotNull && column.columnKey != 'PRI'> + <#if column.columnType = 'String'> + @NotBlank + <#else> + @NotNull + + + <#if column.dateAnnotation??> + <#if column.dateAnnotation = 'CreationTimestamp'> + @CreationTimestamp + <#else> + @UpdateTimestamp + + + private ${column.columnType} ${column.changeColumnName}; + + + + public void copy(${className} source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/EntityP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/EntityP.ftl new file mode 100644 index 00000000..f868fa6c --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/EntityP.ftl @@ -0,0 +1,60 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.domain; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableName; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +<#if isNotNullColumns??> +import javax.validation.constraints.*; + +<#if hasDateAnnotation> + +<#if hasDateTime> +import java.util.Date; + +<#if hasBigDecimal> +import java.math.BigDecimal; + +import co.yixiang.domain.BaseDomain; + +/** +* @author ${author} +* @date ${date} +*/ +@Data +@TableName("${tableName}") +public class ${className} extends BaseDomain { +<#if columns??> + <#list columns as column> + <#if column.changeColumnName != 'isDel' && column.changeColumnName != 'createTime' && column.changeColumnName != 'updateTime' > + <#if column.remark != ''> + /** ${column.remark} */ + + <#if column.columnKey = 'PRI'> + @TableId + + <#if column.istNotNull && column.columnKey != 'PRI'> + <#if column.columnType = 'String'> + @NotBlank + <#else> + @NotNull + + + private ${column.columnType} ${column.changeColumnName}; + + + + + + public void copy(${className} source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/Mapper.ftl b/zsw-bxg/src/main/resources/template/generator/admin/Mapper.ftl new file mode 100644 index 00000000..f7ffc68b --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/Mapper.ftl @@ -0,0 +1,24 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.mapper; + +import co.yixiang.base.BaseMapper; +import ${package}.domain.${className}; +import ${package}.service.dto.${className}Dto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @author ${author} +* @date ${date} +*/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface ${className}Mapper extends BaseMapper<${className}Dto, ${className}> { + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/MapperP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/MapperP.ftl new file mode 100644 index 00000000..61a43915 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/MapperP.ftl @@ -0,0 +1,23 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import ${package}.domain.${className}; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Repository; + +/** +* @author ${author} +* @date ${date} +*/ +@Repository +public interface ${className}Mapper extends CoreMapper<${className}> { + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/QueryCriteria.ftl b/zsw-bxg/src/main/resources/template/generator/admin/QueryCriteria.ftl new file mode 100644 index 00000000..867fe0f2 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/QueryCriteria.ftl @@ -0,0 +1,73 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.dto; + +import lombok.Data; +<#if queryHasDateTime> +import java.util.Date; + +<#if queryHasBigDecimal> +import java.math.BigDecimal; + +<#if betweens??> +import java.util.List; + +<#if queryColumns??> +import co.yixiang.annotation.Query; + + +/** +* @author ${author} +* @date ${date} +*/ +@Data +public class ${className}QueryCriteria{ +<#if queryColumns??> + <#list queryColumns as column> + +<#if column.queryType = '='> + /** 精确 */ + @Query + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = 'Like'> + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = '!='> + /** 不等于 */ + @Query(type = Query.Type.NOT_EQUAL) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = 'NotNull'> + /** 不为空 */ + @Query(type = Query.Type.NOT_NULL) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = '>='> + /** 大于等于 */ + @Query(type = Query.Type.GREATER_THAN) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = '<='> + /** 小于等于 */ + @Query(type = Query.Type.LESS_THAN) + private ${column.columnType} ${column.changeColumnName}; + + + +<#if betweens??> + <#list betweens as column> + /** BETWEEN */ + @Query(type = Query.Type.BETWEEN) + private List<${column.columnType}> createTime; + + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/QueryCriteriaP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/QueryCriteriaP.ftl new file mode 100644 index 00000000..867fe0f2 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/QueryCriteriaP.ftl @@ -0,0 +1,73 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.dto; + +import lombok.Data; +<#if queryHasDateTime> +import java.util.Date; + +<#if queryHasBigDecimal> +import java.math.BigDecimal; + +<#if betweens??> +import java.util.List; + +<#if queryColumns??> +import co.yixiang.annotation.Query; + + +/** +* @author ${author} +* @date ${date} +*/ +@Data +public class ${className}QueryCriteria{ +<#if queryColumns??> + <#list queryColumns as column> + +<#if column.queryType = '='> + /** 精确 */ + @Query + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = 'Like'> + /** 模糊 */ + @Query(type = Query.Type.INNER_LIKE) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = '!='> + /** 不等于 */ + @Query(type = Query.Type.NOT_EQUAL) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = 'NotNull'> + /** 不为空 */ + @Query(type = Query.Type.NOT_NULL) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = '>='> + /** 大于等于 */ + @Query(type = Query.Type.GREATER_THAN) + private ${column.columnType} ${column.changeColumnName}; + +<#if column.queryType = '<='> + /** 小于等于 */ + @Query(type = Query.Type.LESS_THAN) + private ${column.columnType} ${column.changeColumnName}; + + + +<#if betweens??> + <#list betweens as column> + /** BETWEEN */ + @Query(type = Query.Type.BETWEEN) + private List<${column.columnType}> createTime; + + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/Repository.ftl b/zsw-bxg/src/main/resources/template/generator/admin/Repository.ftl new file mode 100644 index 00000000..06dbbc7c --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/Repository.ftl @@ -0,0 +1,32 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.repository; + +import ${package}.domain.${className}; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @author ${author} +* @date ${date} +*/ +public interface ${className}Repository extends JpaRepository<${className}, ${pkColumnType}>, JpaSpecificationExecutor<${className}> { +<#if columns??> + <#list columns as column> + <#if column.columnKey = 'UNI'> + /** + * 根据 ${column.capitalColumnName} 查询 + * @param ${column.columnName} / + * @return / + */ + ${className} findBy${column.capitalColumnName}(${column.columnType} ${column.columnName}); + + + +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/Service.ftl b/zsw-bxg/src/main/resources/template/generator/admin/Service.ftl new file mode 100644 index 00000000..1ae32c5a --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/Service.ftl @@ -0,0 +1,74 @@ +/** +* Copyright (C) 2018-2021 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service; + +import ${package}.domain.${className}; +import ${package}.service.dto.${className}Dto; +import ${package}.service.dto.${className}QueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @author ${author} +* @date ${date} +*/ +public interface ${className}Service { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(${className}QueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List<${className}Dto> + */ + List<${className}Dto> queryAll(${className}QueryCriteria criteria); + + /** + * 根据ID查询 + * @param ${pkChangeColName} ID + * @return ${className}Dto + */ + ${className}Dto findById(${pkColumnType} ${pkChangeColName}); + + /** + * 创建 + * @param resources / + * @return ${className}Dto + */ + ${className}Dto create(${className} resources); + + /** + * 编辑 + * @param resources / + */ + void update(${className} resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(${pkColumnType}[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List<${className}Dto> all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/ServiceImpl.ftl b/zsw-bxg/src/main/resources/template/generator/admin/ServiceImpl.ftl new file mode 100644 index 00000000..6ce10db1 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/ServiceImpl.ftl @@ -0,0 +1,162 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.impl; + +import ${package}.domain.${className}; +<#if columns??> + <#list columns as column> + <#if column.columnKey = 'UNI'> + <#if column_index = 1> +import co.yixiang.exception.EntityExistException; + + + + +import co.yixiang.utils.ValidationUtil; +import co.yixiang.utils.FileUtil; +import ${package}.repository.${className}Repository; +import ${package}.service.${className}Service; +import ${package}.service.dto.${className}Dto; +import ${package}.service.dto.${className}QueryCriteria; +import ${package}.service.mapper.${className}Mapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +<#if !auto && pkColumnType = 'Long'> +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; + +<#if !auto && pkColumnType = 'String'> +import cn.hutool.core.util.IdUtil; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @author ${author} +* @date ${date} +*/ +@Service +//@CacheConfig(cacheNames = "${changeClassName}") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class ${className}ServiceImpl implements ${className}Service { + + private final ${className}Repository ${changeClassName}Repository; + + private final ${className}Mapper ${changeClassName}Mapper; + + public ${className}ServiceImpl(${className}Repository ${changeClassName}Repository, ${className}Mapper ${changeClassName}Mapper) { + this.${changeClassName}Repository = ${changeClassName}Repository; + this.${changeClassName}Mapper = ${changeClassName}Mapper; + } + + @Override + //@Cacheable + public Map queryAll(${className}QueryCriteria criteria, Pageable pageable){ + Page<${className}> page = ${changeClassName}Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(${changeClassName}Mapper::toDto)); + } + + @Override + //@Cacheable + public List<${className}Dto> queryAll(${className}QueryCriteria criteria){ + return ${changeClassName}Mapper.toDto(${changeClassName}Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + //@Cacheable(key = "#p0") + public ${className}Dto findById(${pkColumnType} ${pkChangeColName}) { + ${className} ${changeClassName} = ${changeClassName}Repository.findById(${pkChangeColName}).orElseGet(${className}::new); + ValidationUtil.isNull(${changeClassName}.get${pkCapitalColName}(),"${className}","${pkChangeColName}",${pkChangeColName}); + return ${changeClassName}Mapper.toDto(${changeClassName}); + } + + @Override + //@CacheEvict(allEntries = true) + @Transactional(rollbackFor = Exception.class) + public ${className}Dto create(${className} resources) { +<#if !auto && pkColumnType = 'Long'> + Snowflake snowflake = IdUtil.createSnowflake(1, 1); + resources.set${pkCapitalColName}(snowflake.nextId()); + +<#if !auto && pkColumnType = 'String'> + resources.set${pkCapitalColName}(IdUtil.simpleUUID()); + +<#if columns??> + <#list columns as column> + <#if column.columnKey = 'UNI'> + if(${changeClassName}Repository.findBy${column.capitalColumnName}(resources.get${column.capitalColumnName}()) != null){ + throw new EntityExistException(${className}.class,"${column.columnName}",resources.get${column.capitalColumnName}()); + } + + + + return ${changeClassName}Mapper.toDto(${changeClassName}Repository.save(resources)); + } + + @Override + //@CacheEvict(allEntries = true) + @Transactional(rollbackFor = Exception.class) + public void update(${className} resources) { + ${className} ${changeClassName} = ${changeClassName}Repository.findById(resources.get${pkCapitalColName}()).orElseGet(${className}::new); + ValidationUtil.isNull( ${changeClassName}.get${pkCapitalColName}(),"${className}","id",resources.get${pkCapitalColName}()); +<#if columns??> + <#list columns as column> + <#if column.columnKey = 'UNI'> + <#if column_index = 1> + ${className} ${changeClassName}1 = null; + + ${changeClassName}1 = ${changeClassName}Repository.findBy${column.capitalColumnName}(resources.get${column.capitalColumnName}()); + if(${changeClassName}1 != null && !${changeClassName}1.get${pkCapitalColName}().equals(${changeClassName}.get${pkCapitalColName}())){ + throw new EntityExistException(${className}.class,"${column.columnName}",resources.get${column.capitalColumnName}()); + } + + + + ${changeClassName}.copy(resources); + ${changeClassName}Repository.save(${changeClassName}); + } + + @Override + //@CacheEvict(allEntries = true) + public void deleteAll(${pkColumnType}[] ids) { + for (${pkColumnType} id : ids) { + ${changeClassName}Repository.deleteById(${pkChangeColName}); + } + } + + @Override + public void download(List<${className}Dto> all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (${className}Dto ${changeClassName} : all) { + Map map = new LinkedHashMap<>(); + <#list columns as column> + <#if column.columnKey != 'PRI'> + <#if column.remark != ''> + map.put("${column.remark}", ${changeClassName}.get${column.capitalColumnName}()); + <#else> + map.put(" ${column.changeColumnName}", ${changeClassName}.get${column.capitalColumnName}()); + + + + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/ServiceImplP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/ServiceImplP.ftl new file mode 100644 index 00000000..505c76f2 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/ServiceImplP.ftl @@ -0,0 +1,102 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service.impl; + +import ${package}.domain.${className}; +<#if columns??> + <#list columns as column> + <#if column.columnKey = 'UNI'> + <#if column_index = 1> +import co.yixiang.exception.EntityExistException; + + + + +import co.yixiang.common.service.impl.BaseServiceImpl; +import lombok.AllArgsConstructor; +import co.yixiang.dozer.service.IGenerator; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.utils.ValidationUtil; +import co.yixiang.utils.FileUtil; +import ${package}.service.${className}Service; +import ${package}.service.dto.${className}Dto; +import ${package}.service.dto.${className}QueryCriteria; +import ${package}.service.mapper.${className}Mapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +<#if !auto && pkColumnType = 'Long'> +import cn.hutool.core.lang.Snowflake; +import cn.hutool.core.util.IdUtil; + +<#if !auto && pkColumnType = 'String'> +import cn.hutool.core.util.IdUtil; + +// 默认不使用缓存 +//import org.springframework.cache.annotation.CacheConfig; +//import org.springframework.cache.annotation.CacheEvict; +//import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import co.yixiang.domain.PageResult; +/** +* @author ${author} +* @date ${date} +*/ +@Service +@AllArgsConstructor +//@CacheConfig(cacheNames = "${changeClassName}") +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class ${className}ServiceImpl extends BaseServiceImpl<${className}Mapper, ${className}> implements ${className}Service { + + private final IGenerator generator; + + @Override + //@Cacheable + public PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable) { + getPage(pageable); + PageInfo<${className}> page = new PageInfo<>(queryAll(criteria)); + return generator.convertPageInfo(page,${className}Dto.class); + } + + + @Override + //@Cacheable + public List<${className}> queryAll(${className}QueryCriteria criteria){ + return baseMapper.selectList(QueryHelpPlus.getPredicate(${className}.class, criteria)); + } + + + @Override + public void download(List<${className}Dto> all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (${className}Dto ${changeClassName} : all) { + Map map = new LinkedHashMap<>(); + <#list columns as column> + <#if column.columnKey != 'PRI'> + <#if column.remark != ''> + map.put("${column.remark}", ${changeClassName}.get${column.capitalColumnName}()); + <#else> + map.put(" ${column.changeColumnName}", ${changeClassName}.get${column.capitalColumnName}()); + + + + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} diff --git a/zsw-bxg/src/main/resources/template/generator/admin/ServiceP.ftl b/zsw-bxg/src/main/resources/template/generator/admin/ServiceP.ftl new file mode 100644 index 00000000..1952cb14 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/admin/ServiceP.ftl @@ -0,0 +1,48 @@ +/** +* Copyright (C) 2018-2022 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package ${package}.service; +import co.yixiang.common.service.BaseService; +import ${package}.domain.${className}; +import ${package}.service.dto.${className}Dto; +import ${package}.service.dto.${className}QueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import co.yixiang.domain.PageResult; +/** +* @author ${author} +* @date ${date} +*/ +public interface ${className}Service extends BaseService<${className}>{ + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + PageResult<${className}Dto> queryAll(${className}QueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List<${className}Dto> + */ + List<${className}> queryAll(${className}QueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List<${className}Dto> all, HttpServletResponse response) throws IOException; +} diff --git a/zsw-bxg/src/main/resources/template/generator/front/api.ftl b/zsw-bxg/src/main/resources/template/generator/front/api.ftl new file mode 100644 index 00000000..9587d0df --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/front/api.ftl @@ -0,0 +1,27 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/${changeClassName}', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/${changeClassName}/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/${changeClassName}', + method: 'put', + data + }) +} + +export default { add, edit, del } diff --git a/zsw-bxg/src/main/resources/template/generator/front/eForm.ftl b/zsw-bxg/src/main/resources/template/generator/front/eForm.ftl new file mode 100644 index 00000000..1e8fbcd9 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/front/eForm.ftl @@ -0,0 +1,108 @@ + + + + + diff --git a/zsw-bxg/src/main/resources/template/generator/front/index.ftl b/zsw-bxg/src/main/resources/template/generator/front/index.ftl new file mode 100644 index 00000000..9e9af386 --- /dev/null +++ b/zsw-bxg/src/main/resources/template/generator/front/index.ftl @@ -0,0 +1,253 @@ +<#--noinspection ALL--> + + + + + diff --git a/zsw-bxg/src/test/java/co/yixiang/Api_java_demo.java b/zsw-bxg/src/test/java/co/yixiang/Api_java_demo.java new file mode 100644 index 00000000..5e0f87bf --- /dev/null +++ b/zsw-bxg/src/test/java/co/yixiang/Api_java_demo.java @@ -0,0 +1,545 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author :LionCity + * @date :Created in 2020-04-01 10:47 + * @description:飞鹅打印机 + * @modified By: + * @version: V1.0 + */ +public class Api_java_demo { + public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改 + + public static final String USER = "18948217680@163.com";//*必填*:账号名 + public static final String UKEY = "Fg4Nb6sykhK6wJDj";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】 + public static final String SN = "918502791";//*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API + + + //**********测试时,打开下面注释掉方法的即可,更多接口文档信息,请访问官网开放平台查看********** + public static void main(String[] args) throws Exception{ + //==================添加打印机接口(支持批量)================== + //***返回值JSON字符串*** + //正确例子:{"msg":"ok","ret":0,"data":{"ok":["sn#key#remark#carnum","316500011#abcdefgh#快餐前台"],"no":["316500012#abcdefgh#快餐前台#13688889999 (错误:识别码不正确)"]},"serverExecutedTime":3} + //错误:{"msg":"参数错误 : 该帐号未注册.","ret":-2,"data":null,"serverExecutedTime":37} + + //提示:打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100行(台)。 +// String snlist = "sn1#key1#remark1#carnum1\nsn2#key2#remark2#carnum2"; +// String method = addprinter(snlist); +// System.out.println(method); + + + + //==================方法1.小票机打印订单接口================== + //***返回值JSON字符串*** + //成功:{"msg":"ok","ret":0,"data":"xxxxxxx_xxxxxxxx_xxxxxxxx","serverExecutedTime":5} + //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5} + + String method1 = print(SN);//该接口只能是小票机使用,如购买的是标签机请使用下面方法2,调用打印 + System.out.println(method1); + + + + //==================方法2.标签机专用打印订单接口================== + //***返回值JSON字符串*** + //成功:{"msg":"ok","ret":0,"data":"xxxxxxx_xxxxxxxx_xxxxxxxx","serverExecutedTime":5} + //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5} + +// String method2 = printLabelMsg(SN);//打开注释调用标签机打印接口进行打印,该接口只能是标签机使用,其它型号打印机请勿使用该接口 +// System.out.println(method2); + + + + //===========方法3.查询某订单是否打印成功============= + //***返回值JSON字符串*** + //成功:{"msg":"ok","ret":0,"data":true,"serverExecutedTime":2}//data:true为已打印,false为未打印 + //失败:{"msg":"错误描述","ret":非0, "data":null,"serverExecutedTime":7} + +// String orderid = "xxxxxxx_xxxxxxxx_xxxxxxxx";//订单ID,从方法1返回值data获取 +// String method3 = queryOrderState(orderid); +// System.out.println(method3); + + + + //===========方法4.查询指定打印机某天的订单详情============ + //***返回值JSON字符串*** + //成功:{"msg":"ok","ret":0,"data":{"print":6,"waiting":1},"serverExecutedTime":9}//print已打印,waiting为打印 + //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5} + +// String strdate = "2016-11-12";//注意时间格式为"yyyy-MM-dd" +// String method4 = queryOrderInfoByDate(SN,strdate); +// System.out.println(method4); + + + + //===========方法5.查询打印机的状态========================== + //***返回值JSON字符串*** + //成功:{"msg":"ok","ret":0,"data":"状态","serverExecutedTime":4} + //失败:{"msg":"错误描述","ret":非0,"data":"null","serverExecutedTime":5} + +// String method5 = queryPrinterStatus(SN); +// System.out.println(method5); + + } + + + + + + //=====================以下是函数实现部分================================================ + + private static String addprinter(String snlist){ + + //通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)//读取超时 + .setConnectTimeout(30000)//连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user",USER)); + String STIME = String.valueOf(System.currentTimeMillis()/1000); + nvps.add(new BasicNameValuePair("stime",STIME)); + nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME))); + nvps.add(new BasicNameValuePair("apiname","Open_printerAddlist"));//固定值,不需要修改 + nvps.add(new BasicNameValuePair("printerContent",snlist)); + + CloseableHttpResponse response = null; + String result = null; + try + { + post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if(statecode == 200){ + HttpEntity httpentity = response.getEntity(); + if (httpentity != null){ + result = EntityUtils.toString(httpentity); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally{ + try { + if(response!=null){ + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + + } + + + //方法1 + private static String print(String sn){ + //标签说明: + //单标签: + //"
"为换行,""为切刀指令(主动切纸,仅限切刀打印机使用才有效果) + //""为打印LOGO指令(前提是预先在机器内置LOGO图片),""为钱箱或者外置音响指令 + //成对标签: + //""为居中放大一倍,""为放大一倍,""为居中,字体变高一倍 + //字体变宽一倍,""为二维码,""为字体加粗,""为右对齐 + //拼凑订单内容时可参考如下格式 + //根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式 + + String content; + content = "测试打印
"; + content += "名称      单价 数量 金额
"; + content += "--------------------------------
"; + content += "饭       1.0 1 1.0
"; + content += "炒饭      10.0 10 10.0
"; + content += "蛋炒饭     10.0 10 100.0
"; + content += "鸡蛋炒饭    100.0 1 100.0
"; + content += "番茄蛋炒饭   1000.0 1 100.0
"; + content += "西红柿蛋炒饭  1000.0 1 100.0
"; + content += "西红柿鸡蛋炒饭 100.0 10 100.0
"; + content += "西红柿鸡蛋炒饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭饭 100.0 10 100.0
"; + content += "备注:加辣
"; + content += "--------------------------------
"; + content += "合计:xx.0元
"; + content += "送货地点:广州市南沙区xx路xx号
"; + content += "联系电话:13888888888888
"; + content += "订餐时间:2016-08-08 08:08:08
"; + content += "https://admin.jidanguo10.com/weixin?id=2"; + + //通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)//读取超时 + .setConnectTimeout(30000)//连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user",USER)); + String STIME = String.valueOf(System.currentTimeMillis()/1000); + nvps.add(new BasicNameValuePair("stime",STIME)); + nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME))); + nvps.add(new BasicNameValuePair("apiname","Open_printMsg"));//固定值,不需要修改 + nvps.add(new BasicNameValuePair("sn",sn)); + nvps.add(new BasicNameValuePair("content",content)); + nvps.add(new BasicNameValuePair("times","1"));//打印联数 + + CloseableHttpResponse response = null; + String result = null; + try + { + post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if(statecode == 200){ + HttpEntity httpentity = response.getEntity(); + if (httpentity != null){ + //服务器返回的JSON字符串,建议要当做日志记录起来 + result = EntityUtils.toString(httpentity); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally{ + try { + if(response!=null){ + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + + } + + + + //方法2 + private static String printLabelMsg(String sn){ + + String content; + content = "1";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸, + content += "#001 五号桌 1/3可乐鸡翅张三先生 13800138000";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印 + + //通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)//读取超时 + .setConnectTimeout(30000)//连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user",USER)); + String STIME = String.valueOf(System.currentTimeMillis()/1000); + nvps.add(new BasicNameValuePair("stime",STIME)); + nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME))); + nvps.add(new BasicNameValuePair("apiname","Open_printLabelMsg"));//固定值,不需要修改 + nvps.add(new BasicNameValuePair("sn",sn)); + nvps.add(new BasicNameValuePair("content",content)); + nvps.add(new BasicNameValuePair("times","1"));//打印联数 + + CloseableHttpResponse response = null; + String result = null; + try + { + post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if(statecode == 200){ + HttpEntity httpentity = response.getEntity(); + if (httpentity != null){ + //服务器返回的JSON字符串,建议要当做日志记录起来 + result = EntityUtils.toString(httpentity); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally{ + try { + if(response!=null){ + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + + } + + + //方法3 + private static String queryOrderState(String orderid){ + + //通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)//读取超时 + .setConnectTimeout(30000)//连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user",USER)); + String STIME = String.valueOf(System.currentTimeMillis()/1000); + nvps.add(new BasicNameValuePair("stime",STIME)); + nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME))); + nvps.add(new BasicNameValuePair("apiname","Open_queryOrderState"));//固定值,不需要修改 + nvps.add(new BasicNameValuePair("orderid",orderid)); + + CloseableHttpResponse response = null; + String result = null; + try + { + post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if(statecode == 200){ + HttpEntity httpentity = response.getEntity(); + if (httpentity != null){ + //服务器返回 + result = EntityUtils.toString(httpentity); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally{ + try { + if(response!=null){ + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + + } + + + + //方法4 + private static String queryOrderInfoByDate(String sn,String strdate){ + + //通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)//读取超时 + .setConnectTimeout(30000)//连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user",USER)); + String STIME = String.valueOf(System.currentTimeMillis()/1000); + nvps.add(new BasicNameValuePair("stime",STIME)); + nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME))); + nvps.add(new BasicNameValuePair("apiname","Open_queryOrderInfoByDate"));//固定值,不需要修改 + nvps.add(new BasicNameValuePair("sn",sn)); + nvps.add(new BasicNameValuePair("date",strdate));//yyyy-MM-dd格式 + + CloseableHttpResponse response = null; + String result = null; + try + { + post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if(statecode == 200){ + HttpEntity httpentity = response.getEntity(); + if (httpentity != null){ + //服务器返回 + result = EntityUtils.toString(httpentity); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally{ + try { + if(response!=null){ + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + + } + + + + //方法5 + private static String queryPrinterStatus(String sn){ + + //通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)//读取超时 + .setConnectTimeout(30000)//连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom() + .setDefaultRequestConfig(requestConfig) + .build(); + + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user",USER)); + String STIME = String.valueOf(System.currentTimeMillis()/1000); + nvps.add(new BasicNameValuePair("stime",STIME)); + nvps.add(new BasicNameValuePair("sig",signature(USER,UKEY,STIME))); + nvps.add(new BasicNameValuePair("apiname","Open_queryPrinterStatus"));//固定值,不需要修改 + nvps.add(new BasicNameValuePair("sn",sn)); + + CloseableHttpResponse response = null; + String result = null; + try + { + post.setEntity(new UrlEncodedFormEntity(nvps,"utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if(statecode == 200){ + HttpEntity httpentity = response.getEntity(); + if (httpentity != null){ + //服务器返回 + result = EntityUtils.toString(httpentity); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally{ + try { + if(response!=null){ + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + + } + + + //生成签名字符串 + private static String signature(String USER,String UKEY,String STIME){ + String s = DigestUtils.sha1Hex(USER+UKEY+STIME); + return s; + } +} diff --git a/zsw-bxg/src/test/java/co/yixiang/DatasourceTest.java b/zsw-bxg/src/test/java/co/yixiang/DatasourceTest.java new file mode 100644 index 00000000..5c2f0cea --- /dev/null +++ b/zsw-bxg/src/test/java/co/yixiang/DatasourceTest.java @@ -0,0 +1,4 @@ +package co.yixiang; + +public class DatasourceTest { +} diff --git a/zsw-bxg/src/test/java/co/yixiang/FileTest.java b/zsw-bxg/src/test/java/co/yixiang/FileTest.java new file mode 100644 index 00000000..5e355c7c --- /dev/null +++ b/zsw-bxg/src/test/java/co/yixiang/FileTest.java @@ -0,0 +1,104 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang; + +import cn.hutool.core.img.ImgUtil; +import org.springframework.web.multipart.MultipartFile; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +/** + * @author :LionCity + * @date :Created in 2020-03-24 16:45 + * @description: + * @modified By: + * @version: + */ +public class FileTest { + public static void main(String[] args) throws IOException { + readfile("D:/upload"); + } + public static void readfile(String filepath) throws FileNotFoundException, IOException { + try { + + File file = new File(filepath); + if (!file.isDirectory()) { + System.out.println("文件"); + System.out.println("path=" + file.getPath()); + System.out.println("absolutepath=" + file.getAbsolutePath()); + System.out.println("name=" + file.getName()); + + File targetFile = new File(file.getPath().replace("upload","uploadZip")); + if (!targetFile.getParentFile().exists()) { + targetFile.getParentFile().mkdirs(); + } + ImgUtil.scale(file,targetFile,getAccuracy(file.length()/ 1024)); + } else if (file.isDirectory()) { + System.out.println("文件夹"); + String[] filelist = file.list(); + for (int i = 0; i < filelist.length; i++) { + File readfile = new File(filepath + "\\" + filelist[i]); + if (!readfile.isDirectory()) { + System.out.println("path=" + readfile.getPath()); + System.out.println("absolutepath=" + + readfile.getAbsolutePath()); + System.out.println("name=" + readfile.getName()); + File targetFile = new File(readfile.getPath().replace("upload","uploadZip")); + System.out.println("path2=" + targetFile.getPath()); + System.out.println("fileSize=" + targetFile.length()); + if (!targetFile.getParentFile().exists()) { + targetFile.getParentFile().mkdirs(); + } + ImgUtil.scale(readfile,targetFile,getAccuracy(file.length()/ 1024)); + } else if (readfile.isDirectory()) { + readfile(filepath + "\\" + filelist[i]); + } + } + + } + + } catch (FileNotFoundException e) { + System.out.println("readfile() Exception:" + e.getMessage()); + } + } + + public static BufferedImage inputImage(MultipartFile file) { + BufferedImage srcImage = null; + try { + FileInputStream in = (FileInputStream) file.getInputStream(); + srcImage = javax.imageio.ImageIO.read(in); + } catch (IOException e) { + System.out.println("读取图片文件出错!" + e.getMessage()); + } + return srcImage; + } + + /** + * 自动调节精度(经验数值) + * + * @param size 源图片大小 + * @return 图片压缩质量比 + */ + public static float getAccuracy(long size) { + float accuracy; + if (size < 400) { + accuracy = 0.85f; + } else if (size < 900) { + accuracy = 0.75f; + } else if (size < 2047) { + accuracy = 0.6f; + } else if (size < 3275) { + accuracy = 0.44f; + } else { + accuracy = 0.4f; + } + return accuracy; + } +} diff --git a/zsw-bxg/src/test/java/co/yixiang/Order.java b/zsw-bxg/src/test/java/co/yixiang/Order.java new file mode 100644 index 00000000..ed7f7791 --- /dev/null +++ b/zsw-bxg/src/test/java/co/yixiang/Order.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang; + +public class Order { + private String title; + private String price; + private String num; + + public Order() { + } + public Order(String title, String price, String num) { + this.title = title; + this.price = price; + this.num = num; + } + @Override + public String toString() { + return "Order [title=" + title + ", price=" + price + ", num=" + num + "]"; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getPrice() { + return price; + } + public void setPrice(String price) { + this.price = price; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } +} diff --git a/zsw-bxg/src/test/java/co/yixiang/PrintUtil4.java b/zsw-bxg/src/test/java/co/yixiang/PrintUtil4.java new file mode 100644 index 00000000..41409080 --- /dev/null +++ b/zsw-bxg/src/test/java/co/yixiang/PrintUtil4.java @@ -0,0 +1,351 @@ +/** + * Copyright (C) 2018-2022 + * All rights reserved, Designed By www.yixiang.co + + */ +package co.yixiang; + +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@SuppressWarnings("static-access") +public class PrintUtil4 { + static PrintUtil4 p = new PrintUtil4(); + public static final String URL = "http://api.feieyun.cn/Api/Open/";//不需要修改 + + public static final String USER = "18948217680@163.com";//*必填*:账号名 + public static final String UKEY = "Fg4Nb6sykhK6wJDj";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】 + public static final String SN = "918502791";//*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API + + public static void main(String[] args) { +// ======================1.多个打印机同时打印====================================== +// List list = new ArrayList<>(); +// list.add(SN); +// list.add(SN2); +// for (String sn : list) { +// String method1 = p.print(sn); +// System.out.println(method1); +// } + +// ======================2单个打印机打印====================================== + String result = p.print(SN); + System.out.println(result); + +// p.writeFile("E:/retlog.txt", result); +// System.out.println("返回json数据已保存至 E:/retlog.txt 文件,有需要请查看"); + + } + + // =====================打印订单排版Demo========================== + private static String print(String sn) { +// =====================1.字体大小效果测试===================================== +// String s1 = "放大两倍
"; +// String s2 = "放大一倍
"; +// String s3 = "变高一倍
"; +// String s4 = "变宽一倍
"; +// String s5 = "字体加粗
"; +// String s6 = "默认不加标签最小效果
"; +// String s7 = "变高一倍加粗
"; +// String s8 = "变宽一倍加粗
"; +// +// String content = s1+s2+s3+s4+s5+s6+s7+s8; +// =====================1.end=================================== + +// =====================2.字体行间距测试====================================== +// String content = "飞鹅云测试
"; +// content += "名称 单价 数量 金额
"; +// content += "--------------------------------
"; +// content += "鸡蛋炒饭1   100.0 1 100.0
"; +// content += "鸡蛋炒饭2   100.0 2 200.0
"; +// content += "鸡蛋炒饭3   100.0 3 300.0
"; +// byte[] spaces = new byte[3]; +// spaces[0] = 0x1b; +// spaces[1] = 0x33; +// spaces[2] = 0x30;//7f => 50 行距距离设置最小值为\x50 最大值为\x7f +// String ls = new String(spaces);//行距开始 +// byte[] spacee = new byte[2]; +// spacee[0] = 0x1b; +// spacee[1] = 0x32; +// String le = new String(spacee);//行距结束 +// content += ls+content+le; +// =====================2.end====================================== + +// =====================3.字体大小测试=========================================== +// String content = "鸡蛋炒饭 数量:1 单价:100.0 总额:100.0
"; +// byte[] start = new byte[3]; +// start[0] = 0x1d; +// start[1] = 0x21; +// start[2] = 0x11;//7f => 50 行距距离设置最小值为\x50 最大值为\x7f +// String ls = new String(start);//行距开始 +// byte[] end = new byte[4]; +// end[0] = 0x0d; +// end[1] = 0x0a; +// end[2] = 0x1b; +// end[3] = 0x40; +// String le = new String(end);//行距结束 +// content += ls+content+le; +// =====================3.end======================================= + + +// *********************4.排版测试******************************************************************* + Order order1 = new Order("青头鸭", "100.4", "10"); +/* Order order2 = new Order("小蘑菇音乐铃 JSN-3022 -文创 UP+", "10.3", "10"); + Order order3 = new Order("功夫小子 手机座 JSN-1002-文创 UP+", "10.5", "10"); + Order order4 = new Order("zsfhjksgh菜名四dk", "10.0", "8"); + Order order5 = new Order("zsfhjksghd菜名五hjk", "100.2", "8");*/ + + List orderList = new ArrayList<>(); + orderList.add(order1); + /*orderList.add(order2); + orderList.add(order3); + orderList.add(order4); + orderList.add(order5);*/ + String content = p.getOrder(orderList, 14, 6, 3, 6);//orderList为数组 b1代表名称列占用(14个字节) b2单价列(6个字节) b3数量列(3个字节) b4金额列(6个字节)-->这里的字节数可按自己需求自由改写,14+6+3+6再加上代码写的3个空格就是32了,58mm打印机一行总占32字节 + + // 通过POST请求,发送打印信息到服务器 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(30000)// 读取超时 + .setConnectTimeout(30000)// 连接超时 + .build(); + + CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build(); + HttpPost post = new HttpPost(URL); + List nvps = new ArrayList(); + nvps.add(new BasicNameValuePair("user", USER)); + String STIME = String.valueOf(System.currentTimeMillis() / 1000); + nvps.add(new BasicNameValuePair("stime", STIME)); + nvps.add(new BasicNameValuePair("sig", p.signature(USER, UKEY, STIME))); + nvps.add(new BasicNameValuePair("apiname", "Open_printMsg"));// 固定值,不需要修改 + nvps.add(new BasicNameValuePair("sn", sn)); + nvps.add(new BasicNameValuePair("content", content)); + nvps.add(new BasicNameValuePair("times", "1"));// 打印联数 + + CloseableHttpResponse response = null; + String result = null; + try { + post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8")); + response = httpClient.execute(post); + int statecode = response.getStatusLine().getStatusCode(); + if (statecode == 200) { + HttpEntity httpentity = response.getEntity(); + if (httpentity != null) { + // 服务器返回的JSON字符串,建议要当做日志记录起来 + result = EntityUtils.toString(httpentity); + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + p.close(response, post, httpClient); + } + return result; + } + + public void writeFile(String path, String content) { + content = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒").format(new Date()) + ",保存的订单日志信息为: " + content; + FileOutputStream fos = null; + try { + fos = new FileOutputStream(path, true); + fos.write(content.getBytes()); + fos.write("\r
".getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fos != null) { + try { + fos.flush(); + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + private static String signature(String USER, String UKEY, String STIME) { + return DigestUtils.sha1Hex(USER + UKEY + STIME); + } + + + //飞鹅技术支持 + //######################################################################################################### + + //进行订单的多列排版demo,实现商品超出字数的自动换下一行对齐处理,同时保持各列进行对齐 + + //排版原理是统计字符串字节数,补空格换行处理 + + //58mm的机器,一行打印16个汉字,32个字母;80mm的机器,一行打印24个汉字,48个字母 + + //######################################################################################################### + + //orderList为数组 b1代表名称列占用字节 b2单价列 b3数量列 b4金额列-->这里的字节数可按自己需求自由改写,详细往上看112行调用实际例子运用 + public static String getOrder(List orderList, int b1, int b2, int b3, int b4) { + String orderInfo = "预养订单测试
"; + orderInfo += "名称 单价 数量 金额
"; + orderInfo += "--------------------------------
"; + double totals = 0.0; + for (int i = 0; i < orderList.size(); i++) { + String title = orderList.get(i).getTitle(); + String price = orderList.get(i).getPrice(); + String num = orderList.get(i).getNum(); + String total = "" + Double.valueOf(price) * Integer.parseInt(num); + totals += Double.parseDouble(total); + price = p.addSpace(price, b2); + num = p.addSpace(num, b3); + total = p.addSpace(total, b4); + String otherStr = " " + price + num + " " + total; + + int tl = 0; + try { + tl = title.getBytes("GBK").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + int spaceNum = (tl / b1 + 1) * b1 - tl; + if (tl < b1) { + for (int k = 0; k < spaceNum; k++) { + title += " "; + } + title += otherStr; + } else if (tl == b1) { + title += otherStr; + } else { + List list = null; + if (p.isEn(title)) { + list = p.getStrList(title, b1); + } else { + list = p.getStrList(title, b1 / 2); + } + String s0 = p.titleAddSpace(list.get(0)); + title = s0 + otherStr + "
";// 添加 单价 数量 总额 + String s = ""; + for (int k = 1; k < list.size(); k++) { + s += list.get(k); + } + try { + s = p.getStringByEnter(b1, s); + } catch (Exception e) { + e.printStackTrace(); + } + title += s; + } + orderInfo += title + "
"; + } + orderInfo += "--------------------------------
"; + orderInfo += "合计:" + totals + "元
"; + orderInfo += "送货地点:广州市南沙区xx路xx号
"; + orderInfo += "联系电话:020-39004606
"; + orderInfo += "订餐时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "
"; + orderInfo += "备注:加辣
"; + orderInfo += "https://admin.jidanguo10.com/weixin?id=2"; + return orderInfo; + } + + public String titleAddSpace(String str) { + int k = 0; + int b = 14; + try { + k = str.getBytes("GBK").length; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + for (int i = 0; i < b - k; i++) { + str += " "; + } + return str; + } + + public static String getStringByEnter(int length, String string) throws Exception { + for (int i = 1; i <= string.length(); i++) { + if (string.substring(0, i).getBytes("GBK").length > length) { + return string.substring(0, i - 1) + "
" + getStringByEnter(length, string.substring(i - 1)); + } + } + return string; + } + + public static String addSpace(String str, int size) { + int len = str.length(); + if (len < size) { + for (int i = 0; i < size - len; i++) { + str += " "; + } + } + return str; + } + + public static Boolean isEn(String str) { + Boolean b = false; + try { + b = str.getBytes("GBK").length == str.length(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return b; + } + + public static List getStrList(String inputString, int length) { + int size = inputString.length() / length; + if (inputString.length() % length != 0) { + size += 1; + } + return getStrList(inputString, length, size); + } + + public static List getStrList(String inputString, int length, int size) { + List list = new ArrayList(); + for (int index = 0; index < size; index++) { + String childStr = substring(inputString, index * length, (index + 1) * length); + list.add(childStr); + } + return list; + } + + public static String substring(String str, int f, int t) { + if (f > str.length()) + return null; + if (t > str.length()) { + return str.substring(f, str.length()); + } else { + return str.substring(f, t); + } + } + + public static void close(CloseableHttpResponse response, HttpPost post, CloseableHttpClient httpClient) { + try { + if (response != null) { + response.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + post.abort(); + } catch (Exception e) { + e.printStackTrace(); + } + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +}